- Added dropdown and radio input components to the demo for application settings. - Introduced horizontal layout for display preferences and notification settings. - Implemented checkbox demo with programmatic selection and clear functionality. - Created file upload and quantity selector demos with various states and configurations. - Added comprehensive radio input demo showcasing group behavior and various states. - Developed text input demo with validation states and advanced features like password visibility. - Introduced a new panel component for better content organization in demos.
117 lines
2.7 KiB
TypeScript
117 lines
2.7 KiB
TypeScript
import { customElement, property, html, type TemplateResult, css, cssManager } from '@design.estate/dees-element';
|
|
import * as domtools from '@design.estate/dees-domtools';
|
|
import { DeesInputBase } from './dees-input-base.js';
|
|
import { demoFunc } from './dees-input-quantityselector.demo.js';
|
|
|
|
declare global {
|
|
interface HTMLElementTagNameMap {
|
|
'dees-input-quantityselector': DeesInputQuantitySelector;
|
|
}
|
|
}
|
|
|
|
@customElement('dees-input-quantityselector')
|
|
export class DeesInputQuantitySelector extends DeesInputBase<DeesInputQuantitySelector> {
|
|
public static demo = demoFunc;
|
|
|
|
// INSTANCE
|
|
|
|
@property({
|
|
type: Number
|
|
})
|
|
public value: number = 1;
|
|
|
|
|
|
|
|
public static styles = [
|
|
...DeesInputBase.baseStyles,
|
|
cssManager.defaultStyles,
|
|
css`
|
|
:host {
|
|
width: auto;
|
|
user-select: none;
|
|
}
|
|
|
|
.quantity-container {
|
|
transition: all 0.1s;
|
|
font-size: 14px;
|
|
display: grid;
|
|
grid-template-columns: 33% 34% 33%;
|
|
text-align: center;
|
|
background: ${cssManager.bdTheme('#fafafa', '#222222')};
|
|
line-height: 40px;
|
|
padding: 0px;
|
|
min-width: 110px;
|
|
color: ${cssManager.bdTheme('#666', '#CCC')};
|
|
border: 1px solid ${cssManager.bdTheme('#CCC', '#444')};
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.quantity-container.disabled {
|
|
opacity: 0.5;
|
|
pointer-events: none;
|
|
}
|
|
|
|
.quantity-container:hover {
|
|
color: ${cssManager.bdTheme('#333', '#fff')};
|
|
border-color: ${cssManager.bdTheme('#999', '#666')};
|
|
}
|
|
|
|
.minus {
|
|
padding-left: 5px;
|
|
}
|
|
|
|
.plus {
|
|
padding-right: 5px;
|
|
}
|
|
|
|
.selector {
|
|
text-align: center;
|
|
font-size: 20px;
|
|
}
|
|
|
|
.selector:hover {
|
|
}
|
|
|
|
.quantity {
|
|
text-align: center;
|
|
}
|
|
|
|
`,
|
|
];
|
|
|
|
public render(): TemplateResult {
|
|
return html`
|
|
<div class="input-wrapper">
|
|
<dees-label .label=${this.label}></dees-label>
|
|
<div class="quantity-container ${this.disabled ? 'disabled' : ''}">
|
|
<div class="selector minus" @click="${() => {this.decrease();}}">-</div>
|
|
<div class="quantity">${this.value}</div>
|
|
<div class="selector plus" @click="${() => {this.increase();}}">+</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
public increase() {
|
|
if (!this.disabled) {
|
|
this.value++;
|
|
this.changeSubject.next(this);
|
|
}
|
|
}
|
|
|
|
public decrease() {
|
|
if (!this.disabled && this.value > 0) {
|
|
this.value--;
|
|
this.changeSubject.next(this);
|
|
}
|
|
}
|
|
|
|
public getValue(): number {
|
|
return this.value;
|
|
}
|
|
|
|
public setValue(value: number): void {
|
|
this.value = value;
|
|
}
|
|
}
|