@universal-material/web 3.0.120 → 3.0.122
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +2034 -2084
- package/field/field-base.d.ts +0 -4
- package/field/field-base.d.ts.map +1 -1
- package/field/field-base.js +5 -29
- package/field/field-base.js.map +1 -1
- package/field/field-base.styles.d.ts.map +1 -1
- package/field/field-base.styles.js +80 -17
- package/field/field-base.styles.js.map +1 -1
- package/package.json +1 -1
- package/shared/selection-control/selection-control.d.ts +2 -0
- package/shared/selection-control/selection-control.d.ts.map +1 -1
- package/shared/selection-control/selection-control.js +13 -3
- package/shared/selection-control/selection-control.js.map +1 -1
package/field/field-base.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { CSSResultGroup } from '@lit/reactive-element/css-tag';
|
|
|
3
3
|
import { LitElement, nothing, TemplateResult } from 'lit';
|
|
4
4
|
import { UmFieldDefaults } from './field-defaults.js';
|
|
5
5
|
export declare abstract class UmFieldBase extends LitElement {
|
|
6
|
-
#private;
|
|
7
6
|
static styles: CSSResultGroup;
|
|
8
7
|
private config;
|
|
9
8
|
variant: 'filled' | 'outlined' | undefined;
|
|
@@ -56,17 +55,14 @@ export declare abstract class UmFieldBase extends LitElement {
|
|
|
56
55
|
private readonly assignedErrorTexts;
|
|
57
56
|
private _labelElement;
|
|
58
57
|
protected _container: HTMLElement;
|
|
59
|
-
private labelSizeObserver;
|
|
60
58
|
constructor();
|
|
61
59
|
protected render(): TemplateResult;
|
|
62
60
|
protected abstract renderControl(): TemplateResult;
|
|
63
61
|
protected renderAfterContent(): TemplateResult;
|
|
64
62
|
connectedCallback(): void;
|
|
65
|
-
disconnectedCallback(): void;
|
|
66
63
|
private handleLeadingIconSlotChange;
|
|
67
64
|
private handleTrailingIconSlotChange;
|
|
68
65
|
private handleErrorTextSlotChange;
|
|
69
|
-
private setLabelWidthProperties;
|
|
70
66
|
protected renderDefaultTrailingIcon(): TemplateResult | typeof nothing;
|
|
71
67
|
}
|
|
72
68
|
//# sourceMappingURL=field-base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-base.d.ts","sourceRoot":"","sources":["../../src/field/field-base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAQ,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAQhE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,8BAAsB,WAAY,SAAQ,UAAU
|
|
1
|
+
{"version":3,"file":"field-base.d.ts","sourceRoot":"","sources":["../../src/field/field-base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAQ,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAQhE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,8BAAsB,WAAY,SAAQ,UAAU;IAClD,OAAgB,MAAM,EAAE,cAAc,CAAwB;IAI9D,OAAO,CAAC,MAAM,CAA8B;IAEhC,OAAO,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAY;IAElE;;OAEG;IAEH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAEjB,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAEgB,WAAW,UAAS;IAE5E;;OAEG;IACyC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IAE/E;;;OAGG;IACoC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAErE;;OAEG;IACyC,KAAK,UAAS;IACd,QAAQ,UAAS;IAE7D;;OAEG;IACyC,OAAO,UAAS;IAE5D,MAAM,CAAC,WAAW,CAChB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,eAAe,GACtB,eAAe,CAAC,OAAO,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IAOzD;;;;OAIG;IAEH,cAAc,UAAS;IAEvB;;;;OAIG;IAEH,eAAe,UAAS;IAExB;;;;OAIG;IAEH,YAAY,UAAS;IAGrB,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAiB;IAGtD,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAiB;IAGvD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAiB;IAE7B,OAAO,CAAC,aAAa,CAAe;IAChC,SAAS,CAAC,UAAU,EAAG,WAAW,CAAC;;cAO3C,MAAM,IAAI,cAAc;IA+C3C,SAAS,CAAC,QAAQ,CAAC,aAAa,IAAI,cAAc;IAElD,SAAS,CAAC,kBAAkB,IAAI,cAAc;IAIrC,iBAAiB;IAK1B,OAAO,CAAC,2BAA2B;IASnC,OAAO,CAAC,4BAA4B;IAIpC,OAAO,CAAC,yBAAyB;IAIjC,SAAS,CAAC,yBAAyB,IAAI,cAAc,GAAG,OAAO,OAAO;CAGvE"}
|
package/field/field-base.js
CHANGED
|
@@ -50,13 +50,13 @@ export class UmFieldBase extends LitElement {
|
|
|
50
50
|
* _Note:_ Readonly
|
|
51
51
|
*/
|
|
52
52
|
this.hasErrorText = false;
|
|
53
|
-
this.labelSizeObserver = null;
|
|
54
53
|
this.variant = undefined;
|
|
55
54
|
}
|
|
56
55
|
render() {
|
|
57
56
|
const variant = this.variant ?? this.config?.variant ?? 'filled';
|
|
58
57
|
const classes = {
|
|
59
58
|
[variant]: true,
|
|
59
|
+
'no-label': !this.label,
|
|
60
60
|
};
|
|
61
61
|
const counter = html `
|
|
62
62
|
<slot class="counter" name="counter">
|
|
@@ -67,7 +67,7 @@ export class UmFieldBase extends LitElement {
|
|
|
67
67
|
<div class="outline">
|
|
68
68
|
<div class="outline-start"></div>
|
|
69
69
|
<div class="outline-notch">
|
|
70
|
-
<div class="outline-notch-label"
|
|
70
|
+
<div class="outline-notch-label">${this.label}</div>
|
|
71
71
|
</div>
|
|
72
72
|
<div class="outline-end"></div>
|
|
73
73
|
</div>
|
|
@@ -76,9 +76,7 @@ export class UmFieldBase extends LitElement {
|
|
|
76
76
|
<div class="container ${classMap(classes)}">
|
|
77
77
|
${variant === 'outlined' ? outline : nothing}
|
|
78
78
|
<slot class="icon leading-icon" name="leading-icon" @slotchange="${this.handleLeadingIconSlotChange}"></slot>
|
|
79
|
-
<label class="label"
|
|
80
|
-
<slot name="label">${this.label}</slot>
|
|
81
|
-
</label>
|
|
79
|
+
<label class="label" id="label">${this.label}</label>
|
|
82
80
|
<div class="input-wrapper" part="wrapper">${this.renderControl()}</div>
|
|
83
81
|
<slot class="icon trailing-icon" name="trailing-icon" @slotchange="${this.handleTrailingIconSlotChange}">
|
|
84
82
|
<span>${this.renderDefaultTrailingIcon()}</span>
|
|
@@ -102,18 +100,6 @@ export class UmFieldBase extends LitElement {
|
|
|
102
100
|
connectedCallback() {
|
|
103
101
|
super.connectedCallback();
|
|
104
102
|
this.hasLeadingIcon = !!this.assignedLeadingIcons.length;
|
|
105
|
-
this.#attach();
|
|
106
|
-
}
|
|
107
|
-
disconnectedCallback() {
|
|
108
|
-
super.disconnectedCallback();
|
|
109
|
-
this.labelSizeObserver?.disconnect();
|
|
110
|
-
this.labelSizeObserver = null;
|
|
111
|
-
}
|
|
112
|
-
async #attach() {
|
|
113
|
-
await this.updateComplete;
|
|
114
|
-
this.labelSizeObserver = new ResizeObserver(() => this.setLabelWidthProperties());
|
|
115
|
-
this.labelSizeObserver.observe(this._labelElement);
|
|
116
|
-
this.setLabelWidthProperties();
|
|
117
103
|
}
|
|
118
104
|
handleLeadingIconSlotChange() {
|
|
119
105
|
this._labelElement.style.transition = 'none';
|
|
@@ -128,16 +114,6 @@ export class UmFieldBase extends LitElement {
|
|
|
128
114
|
handleErrorTextSlotChange() {
|
|
129
115
|
this.hasErrorText = this.assignedErrorTexts.length > 0;
|
|
130
116
|
}
|
|
131
|
-
setLabelWidthProperties() {
|
|
132
|
-
const width = this._labelElement.offsetWidth;
|
|
133
|
-
this.style.setProperty('--u-field-label-width', `${width}px`);
|
|
134
|
-
this.style.setProperty('--u-field-label-half-width', `${width / 2}px`);
|
|
135
|
-
if (!width) {
|
|
136
|
-
this._container.classList.add('no-label');
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
this._container.classList.remove('no-label');
|
|
140
|
-
}
|
|
141
117
|
renderDefaultTrailingIcon() {
|
|
142
118
|
return nothing;
|
|
143
119
|
}
|
|
@@ -195,9 +171,9 @@ __decorate([
|
|
|
195
171
|
queryAssignedElements({ slot: 'error-text', flatten: true })
|
|
196
172
|
], UmFieldBase.prototype, "assignedErrorTexts", void 0);
|
|
197
173
|
__decorate([
|
|
198
|
-
query('.label')
|
|
174
|
+
query('.label', true)
|
|
199
175
|
], UmFieldBase.prototype, "_labelElement", void 0);
|
|
200
176
|
__decorate([
|
|
201
|
-
query('.container')
|
|
177
|
+
query('.container', true)
|
|
202
178
|
], UmFieldBase.prototype, "_container", void 0);
|
|
203
179
|
//# sourceMappingURL=field-base.js.map
|
package/field/field-base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-base.js","sourceRoot":"","sources":["../../src/field/field-base.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAW,eAAe,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAkB,MAAM,KAAK,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,MAAM,IA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9B,KAAK,CAAC,YAAY,CAAC;+CAAoC","sourcesContent":["import { consume, Context, ContextProvider } from '@lit/context';\nimport { CSSResultGroup } from '@lit/reactive-element/css-tag';\nimport { html, LitElement, nothing, TemplateResult } from 'lit';\nimport { property, query, queryAssignedElements, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nimport { styles as baseStyles } from '../shared/base.styles.js';\nimport { styles } from './field-base.styles.js';\n\nimport { fieldDefaultsContext } from './field-defaults-context.js';\nimport { UmFieldDefaults } from './field-defaults.js';\n\nexport abstract class UmFieldBase extends LitElement {\n static override styles: CSSResultGroup = [baseStyles, styles];\n\n @consume({ context: fieldDefaultsContext, subscribe: true })\n @state()\n private config: UmFieldDefaults | undefined;\n\n @property() variant: 'filled' | 'outlined' | undefined = 'filled';\n\n /**\n * The floating label for the field\n */\n @property() label: string | undefined;\n\n @state() protected _innerCounter: string | undefined;\n @property() counter: string | undefined;\n\n @property({ type: Boolean, attribute: 'hide-counter' }) hideCounter = false;\n\n /**\n * Supporting text conveys additional information about the field, such as how it will be used\n */\n @property({ attribute: 'supporting-text' }) supportingText: string | undefined;\n\n /**\n * For text fields that validate their content (such as passwords), replace supporting text with error text when applicable.\n * If `errorText` is not an empty string, changing the property `invalid` to `true` will show the `errorText` instead of `supportingText`\n */\n @property({ attribute: 'error-text' }) errorText: string | undefined;\n\n /**\n * Whether the field is empty or not. This changes the behavior of the floating label when the field is not focused.\n */\n @property({ type: Boolean, reflect: true }) empty = false;\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /**\n * Get or sets where or not the field is in a visually invalid state.\n */\n @property({ type: Boolean, reflect: true }) invalid = false;\n\n static setDefaults(\n contextRoot: HTMLElement,\n config: UmFieldDefaults,\n ): ContextProvider<Context<HTMLElement, UmFieldDefaults>> {\n return new ContextProvider(contextRoot, {\n context: fieldDefaultsContext,\n initialValue: config,\n });\n }\n\n /**\n * Whether the field has a leading icon or not\n *\n * _Note:_ Readonly\n */\n @property({ type: Boolean, attribute: 'has-leading-icon', reflect: true })\n hasLeadingIcon = false;\n\n /**\n * Whether the field has a trailing icon or not\n *\n * _Note:_ Readonly\n */\n @property({ type: Boolean, attribute: 'has-trailing-icon', reflect: true })\n hasTrailingIcon = false;\n\n /**\n * Whether the field has an error text or not\n *\n * _Note:_ Readonly\n */\n @property({ type: Boolean, attribute: 'has-error-text', reflect: true })\n hasErrorText = false;\n\n @queryAssignedElements({ slot: 'leading-icon', flatten: true })\n private readonly assignedLeadingIcons!: HTMLElement[];\n\n @queryAssignedElements({ slot: 'trailing-icon', flatten: true })\n private readonly assignedTrailingIcons!: HTMLElement[];\n\n @queryAssignedElements({ slot: 'error-text', flatten: true })\n private readonly assignedErrorTexts!: HTMLElement[];\n\n @query('.label') private _labelElement!: HTMLElement;\n @query('.container') protected _container!: HTMLElement;\n\n private labelSizeObserver: ResizeObserver | null = null;\n\n constructor() {\n super();\n this.variant = undefined;\n }\n\n protected override render(): TemplateResult {\n const variant = this.variant ?? this.config?.variant ?? 'filled';\n\n const classes = {\n [variant]: true,\n };\n\n const counter = html`\n <slot class=\"counter\" name=\"counter\">\n <div>${this.counter ?? this._innerCounter}</div>\n </slot>\n `;\n\n const outline = html`\n <div class=\"outline\">\n <div class=\"outline-start\"></div>\n <div class=\"outline-notch\">\n <div class=\"outline-notch-label\"></div>\n </div>\n <div class=\"outline-end\"></div>\n </div>\n `;\n\n return html`\n <div class=\"container ${classMap(classes)}\">\n ${variant === 'outlined' ? outline : nothing}\n <slot class=\"icon leading-icon\" name=\"leading-icon\" @slotchange=\"${this.handleLeadingIconSlotChange}\"></slot>\n <label class=\"label\" slot=\"label\" id=\"label\">\n <slot name=\"label\">${this.label}</slot>\n </label>\n <div class=\"input-wrapper\" part=\"wrapper\">${this.renderControl()}</div>\n <slot class=\"icon trailing-icon\" name=\"trailing-icon\" @slotchange=\"${this.handleTrailingIconSlotChange}\">\n <span>${this.renderDefaultTrailingIcon()}</span>\n </slot>\n </div>\n <div class=\"supporting-text\" id=\"supporting-text\">\n <slot class=\"error-text\" name=\"error-text\" @slotchange=\"${this.handleErrorTextSlotChange}\">\n <div>${this.errorText}</div>\n </slot>\n <slot name=\"supporting-text\" id=\"supporting-text\">\n <div>${this.supportingText}</div>\n </slot>\n ${this.hideCounter ? nothing : counter}\n </div>\n ${this.renderAfterContent()}\n `;\n }\n\n protected abstract renderControl(): TemplateResult;\n protected renderAfterContent(): TemplateResult {\n return html``;\n }\n\n override connectedCallback() {\n super.connectedCallback();\n this.hasLeadingIcon = !!this.assignedLeadingIcons.length;\n\n this.#attach();\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n\n this.labelSizeObserver?.disconnect();\n this.labelSizeObserver = null;\n }\n\n async #attach(): Promise<void> {\n await this.updateComplete;\n this.labelSizeObserver = new ResizeObserver(() => this.setLabelWidthProperties());\n this.labelSizeObserver.observe(this._labelElement);\n this.setLabelWidthProperties();\n }\n\n private handleLeadingIconSlotChange() {\n this._labelElement.style.transition = 'none';\n this.hasLeadingIcon = this.assignedLeadingIcons.length > 0;\n\n setTimeout(() => {\n this._labelElement.style.transition = '';\n });\n }\n\n private handleTrailingIconSlotChange() {\n this.hasTrailingIcon = this.assignedTrailingIcons.length > 0;\n }\n\n private handleErrorTextSlotChange() {\n this.hasErrorText = this.assignedErrorTexts.length > 0;\n }\n\n private setLabelWidthProperties() {\n const width = this._labelElement.offsetWidth;\n\n this.style.setProperty('--u-field-label-width', `${width}px`);\n this.style.setProperty('--u-field-label-half-width', `${width / 2}px`);\n\n if (!width) {\n this._container.classList.add('no-label');\n return;\n }\n\n this._container.classList.remove('no-label');\n }\n\n protected renderDefaultTrailingIcon(): TemplateResult | typeof nothing {\n return nothing;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"field-base.js","sourceRoot":"","sources":["../../src/field/field-base.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAW,eAAe,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,IAAI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AmB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDACnD;AAQxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iDACnD;AAGJ;IADhB,qBAAqB,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yDACT;AAGrC;IADhB,qBAAqB,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0DACT;AAGtC;IADhB,qBAAqB,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uDACT;AAErB;IAA9B,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC;kDAAqC;AACtB;IAApC,KAAK,CAAC,YAAY,EAAE,IAAI,CAAC;+CAAoC","sourcesContent":["import { consume, Context, ContextProvider } from '@lit/context';\nimport { CSSResultGroup } from '@lit/reactive-element/css-tag';\nimport { html, LitElement, nothing, TemplateResult } from 'lit';\nimport { property, query, queryAssignedElements, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nimport { styles as baseStyles } from '../shared/base.styles.js';\nimport { styles } from './field-base.styles.js';\n\nimport { fieldDefaultsContext } from './field-defaults-context.js';\nimport { UmFieldDefaults } from './field-defaults.js';\n\nexport abstract class UmFieldBase extends LitElement {\n static override styles: CSSResultGroup = [baseStyles, styles];\n\n @consume({ context: fieldDefaultsContext, subscribe: true })\n @state()\n private config: UmFieldDefaults | undefined;\n\n @property() variant: 'filled' | 'outlined' | undefined = 'filled';\n\n /**\n * The floating label for the field\n */\n @property()\n label: string | undefined;\n\n @state() protected _innerCounter: string | undefined;\n @property() counter: string | undefined;\n\n @property({ type: Boolean, attribute: 'hide-counter' }) hideCounter = false;\n\n /**\n * Supporting text conveys additional information about the field, such as how it will be used\n */\n @property({ attribute: 'supporting-text' }) supportingText: string | undefined;\n\n /**\n * For text fields that validate their content (such as passwords), replace supporting text with error text when applicable.\n * If `errorText` is not an empty string, changing the property `invalid` to `true` will show the `errorText` instead of `supportingText`\n */\n @property({ attribute: 'error-text' }) errorText: string | undefined;\n\n /**\n * Whether the field is empty or not. This changes the behavior of the floating label when the field is not focused.\n */\n @property({ type: Boolean, reflect: true }) empty = false;\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /**\n * Get or sets where or not the field is in a visually invalid state.\n */\n @property({ type: Boolean, reflect: true }) invalid = false;\n\n static setDefaults(\n contextRoot: HTMLElement,\n config: UmFieldDefaults,\n ): ContextProvider<Context<HTMLElement, UmFieldDefaults>> {\n return new ContextProvider(contextRoot, {\n context: fieldDefaultsContext,\n initialValue: config,\n });\n }\n\n /**\n * Whether the field has a leading icon or not\n *\n * _Note:_ Readonly\n */\n @property({ type: Boolean, attribute: 'has-leading-icon', reflect: true })\n hasLeadingIcon = false;\n\n /**\n * Whether the field has a trailing icon or not\n *\n * _Note:_ Readonly\n */\n @property({ type: Boolean, attribute: 'has-trailing-icon', reflect: true })\n hasTrailingIcon = false;\n\n /**\n * Whether the field has an error text or not\n *\n * _Note:_ Readonly\n */\n @property({ type: Boolean, attribute: 'has-error-text', reflect: true })\n hasErrorText = false;\n\n @queryAssignedElements({ slot: 'leading-icon', flatten: true })\n private readonly assignedLeadingIcons!: HTMLElement[];\n\n @queryAssignedElements({ slot: 'trailing-icon', flatten: true })\n private readonly assignedTrailingIcons!: HTMLElement[];\n\n @queryAssignedElements({ slot: 'error-text', flatten: true })\n private readonly assignedErrorTexts!: HTMLElement[];\n\n @query('.label', true) private _labelElement!: HTMLElement;\n @query('.container', true) protected _container!: HTMLElement;\n\n constructor() {\n super();\n this.variant = undefined;\n }\n\n protected override render(): TemplateResult {\n const variant = this.variant ?? this.config?.variant ?? 'filled';\n\n const classes = {\n [variant]: true,\n 'no-label': !this.label,\n };\n\n const counter = html`\n <slot class=\"counter\" name=\"counter\">\n <div>${this.counter ?? this._innerCounter}</div>\n </slot>\n `;\n\n const outline = html`\n <div class=\"outline\">\n <div class=\"outline-start\"></div>\n <div class=\"outline-notch\">\n <div class=\"outline-notch-label\">${this.label}</div>\n </div>\n <div class=\"outline-end\"></div>\n </div>\n `;\n\n return html`\n <div class=\"container ${classMap(classes)}\">\n ${variant === 'outlined' ? outline : nothing}\n <slot class=\"icon leading-icon\" name=\"leading-icon\" @slotchange=\"${this.handleLeadingIconSlotChange}\"></slot>\n <label class=\"label\" id=\"label\">${this.label}</label>\n <div class=\"input-wrapper\" part=\"wrapper\">${this.renderControl()}</div>\n <slot class=\"icon trailing-icon\" name=\"trailing-icon\" @slotchange=\"${this.handleTrailingIconSlotChange}\">\n <span>${this.renderDefaultTrailingIcon()}</span>\n </slot>\n </div>\n <div class=\"supporting-text\" id=\"supporting-text\">\n <slot class=\"error-text\" name=\"error-text\" @slotchange=\"${this.handleErrorTextSlotChange}\">\n <div>${this.errorText}</div>\n </slot>\n <slot name=\"supporting-text\" id=\"supporting-text\">\n <div>${this.supportingText}</div>\n </slot>\n ${this.hideCounter ? nothing : counter}\n </div>\n ${this.renderAfterContent()}\n `;\n }\n\n protected abstract renderControl(): TemplateResult;\n\n protected renderAfterContent(): TemplateResult {\n return html``;\n }\n\n override connectedCallback() {\n super.connectedCallback();\n this.hasLeadingIcon = !!this.assignedLeadingIcons.length;\n }\n\n private handleLeadingIconSlotChange() {\n this._labelElement.style.transition = 'none';\n this.hasLeadingIcon = this.assignedLeadingIcons.length > 0;\n\n setTimeout(() => {\n this._labelElement.style.transition = '';\n });\n }\n\n private handleTrailingIconSlotChange() {\n this.hasTrailingIcon = this.assignedTrailingIcons.length > 0;\n }\n\n private handleErrorTextSlotChange() {\n this.hasErrorText = this.assignedErrorTexts.length > 0;\n }\n\n protected renderDefaultTrailingIcon(): TemplateResult | typeof nothing {\n return nothing;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-base.styles.d.ts","sourceRoot":"","sources":["../../src/field/field-base.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"field-base.styles.d.ts","sourceRoot":"","sources":["../../src/field/field-base.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,yBAgXlB,CAAC"}
|
|
@@ -18,7 +18,8 @@ export const styles = css `
|
|
|
18
18
|
--_icon-size: var(--u-field-icon-size, 1.5rem);
|
|
19
19
|
--_icon-padding: var(--u-field-icon-padding, 12px);
|
|
20
20
|
--_icon-color: var(--u-icon-color, var(--u-color-on-surface-variant, rgb(73, 69, 79)));
|
|
21
|
-
--
|
|
21
|
+
--_border-width: var(--u-field-border-width, 1px);
|
|
22
|
+
--_border-color: var(--u-field-border-color, var(--u-color-on-surface-variant, rgb(73, 69, 79)));
|
|
22
23
|
--_field-control-leading-padding: var(--_field-control-inline-padding);
|
|
23
24
|
--_outlined-label-margin: var(--u-outlined-field-label-margin, 12px);
|
|
24
25
|
--_outlined-label-padding: var(--u-outlined-field-label-padding, 4px);
|
|
@@ -50,16 +51,16 @@ export const styles = css `
|
|
|
50
51
|
opacity: 0;
|
|
51
52
|
}
|
|
52
53
|
.container::after {
|
|
53
|
-
border-width: var(--
|
|
54
|
-
border-color: var(--
|
|
54
|
+
border-width: var(--_border-width);
|
|
55
|
+
border-color: var(--_border-color);
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
@media (hover: hover) {
|
|
58
59
|
:host(:not([disabled]):not([invalid]):hover) .container.filled::before {
|
|
59
60
|
opacity: var(--u-state-hover-opacity, 0.08);
|
|
60
61
|
}
|
|
61
|
-
:host(:not([disabled]):not([invalid]):not(:focus-within):hover)
|
|
62
|
-
|
|
62
|
+
:host(:not([disabled]):not([invalid]):not(:focus-within):hover) {
|
|
63
|
+
--_border-color: var(--u-field-hover-border-color, var(--u-color-on-surface, rgb(29, 27, 32)));
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
.icon {
|
|
@@ -84,6 +85,7 @@ export const styles = css `
|
|
|
84
85
|
margin-inline-end: var(--_icon-padding);
|
|
85
86
|
}
|
|
86
87
|
|
|
88
|
+
.outline-notch-label,
|
|
87
89
|
.label {
|
|
88
90
|
font-family: var(--u-font-family, var(--u-font-family, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"));
|
|
89
91
|
line-height: var(--u-field-label-line-height, var(--u-body-l-line-height, 1.5rem));
|
|
@@ -91,6 +93,9 @@ export const styles = css `
|
|
|
91
93
|
letter-spacing: var(--u-field-label-letter-spacing, var(--u-body-l-letter-spacing, 0.03125rem));
|
|
92
94
|
font-weight: var(--u-field-label-font-weight, var(--u-body-l-font-weight, var(--u-font-weight-regular, 400)));
|
|
93
95
|
font-size: var(--u-field-label-font-size, var(--u-body-s-font-size, 0.75rem));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.label {
|
|
94
99
|
display: block;
|
|
95
100
|
position: absolute;
|
|
96
101
|
inset-inline-start: var(--_field-control-leading-padding);
|
|
@@ -193,17 +198,15 @@ export const styles = css `
|
|
|
193
198
|
}
|
|
194
199
|
|
|
195
200
|
:host(:focus-within) {
|
|
196
|
-
--
|
|
197
|
-
|
|
198
|
-
:host(:focus-within) .container::after {
|
|
199
|
-
border-color: var(--u-field-focused-border-color, var(--_color-primary));
|
|
201
|
+
--_border-width: var(--u-text-field-focus-border-width, 2px);
|
|
202
|
+
--_border-color: var(--u-field-focused-border-color, var(--_color-primary));
|
|
200
203
|
}
|
|
201
204
|
:host(:focus-within) .label {
|
|
202
205
|
color: var(--u-field-label-focused-color, var(--_color-primary));
|
|
203
206
|
}
|
|
204
207
|
|
|
205
|
-
:host([invalid])
|
|
206
|
-
|
|
208
|
+
:host([invalid]) {
|
|
209
|
+
--_border-color: var(--u-field-error-border-color, var(--_color-error));
|
|
207
210
|
}
|
|
208
211
|
:host([invalid]) .label {
|
|
209
212
|
color: var(--u-field-label-error-color, var(--_color-error));
|
|
@@ -272,16 +275,12 @@ export const styles = css `
|
|
|
272
275
|
transition: color 150ms;
|
|
273
276
|
}
|
|
274
277
|
|
|
275
|
-
|
|
276
|
-
|
|
278
|
+
:host([disabled]) {
|
|
279
|
+
--_border-color: var(--u-field-disabled-border-color, var(--_disabled-color));
|
|
277
280
|
}
|
|
278
|
-
|
|
279
281
|
:host([disabled]) .container .filled {
|
|
280
282
|
background-color: var(--u-filled-field-disabled-bg-color, rgba(var(--u-color-on-surface-rgb, 29, 27, 32), var(--u-filled-field-background-disabled-opacity, 0.04)));
|
|
281
283
|
}
|
|
282
|
-
:host([disabled]) .container::after {
|
|
283
|
-
border-color: var(--u-field-disabled-border-color, var(--_disabled-color));
|
|
284
|
-
}
|
|
285
284
|
:host([disabled]) .supporting-text {
|
|
286
285
|
color: var(--u-field-supporting-text-disabled-color, var(--_disabled-color));
|
|
287
286
|
}
|
|
@@ -304,5 +303,69 @@ export const styles = css `
|
|
|
304
303
|
:host([disabled]) .leading-icon {
|
|
305
304
|
color: var(--u-field-leading-icon-disabled-color, var(--_disabled-color));
|
|
306
305
|
}
|
|
306
|
+
|
|
307
|
+
.outline {
|
|
308
|
+
position: absolute;
|
|
309
|
+
inset: 0;
|
|
310
|
+
display: flex;
|
|
311
|
+
border-radius: var(--u-outlined-field-shape-corder, var(--u-shape-corner-small, 8px));
|
|
312
|
+
pointer-events: none;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.outline-start,
|
|
316
|
+
.outline-end {
|
|
317
|
+
border: var(--_border-width) solid var(--_border-color);
|
|
318
|
+
border-radius: inherit;
|
|
319
|
+
flex-basis: var(--_outlined-label-margin);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.outline-start {
|
|
323
|
+
border-start-end-radius: 0;
|
|
324
|
+
border-end-end-radius: 0;
|
|
325
|
+
border-inline-end: none;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.outline-end {
|
|
329
|
+
flex: 1;
|
|
330
|
+
border-start-start-radius: 0;
|
|
331
|
+
border-end-start-radius: 0;
|
|
332
|
+
border-inline-start: none;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.outline-notch {
|
|
336
|
+
min-width: 0;
|
|
337
|
+
border-bottom: var(--_border-width) solid var(--_border-color);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.outline-notch-label {
|
|
341
|
+
position: relative;
|
|
342
|
+
color: transparent;
|
|
343
|
+
padding-inline: var(--_outlined-label-padding);
|
|
344
|
+
user-select: none;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.outline-notch-label::before,
|
|
348
|
+
.outline-notch-label::after {
|
|
349
|
+
content: "";
|
|
350
|
+
position: absolute;
|
|
351
|
+
border-top: var(--_border-width) solid var(--_border-color);
|
|
352
|
+
width: 50%;
|
|
353
|
+
transition: width 100ms;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
.outline-notch-label::before {
|
|
357
|
+
left: 0;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
.outline-notch-label::after {
|
|
361
|
+
right: 0;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.container:not(.no-label):focus-within .outline-notch-label::before,
|
|
365
|
+
.container:not(.no-label):focus-within .outline-notch-label::after,
|
|
366
|
+
:host(:not([empty])) .container:not(.no-label) .outline-notch-label::before,
|
|
367
|
+
:host(:not([empty])) .container:not(.no-label) .outline-notch-label::after {
|
|
368
|
+
width: 0;
|
|
369
|
+
}
|
|
307
370
|
`;
|
|
308
371
|
//# sourceMappingURL=field-base.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-base.styles.js","sourceRoot":"","sources":["../../src/field/field-base.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiTzB,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css `\n :host {\n --_control-line-height: var(--u-field-control-line-height, 1.5rem);\n --_label-line-height: var(--u-field-label-line-height, 1rem);\n --_field-icon-size: var(--u-field-icon-size, 1.5rem);\n --_field-control-padding: var(--u-field-control-padding, 16px);\n --_field-control-inline-padding: var(--u-field-control-inline-padding, var(--_field-control-padding));\n --_field-control-block-padding: var(--u-field-control-block-padding, var(--_field-control-padding));\n --_field-min-height: var(--u-field-min-height, 56px);\n --_field-placeholder-color: var(--u-field-placeholder-color, var(--u-color-on-surface-variant, rgb(73, 69, 79)));\n --_disabled-color: var(--u-field-disabled-color, rgba(var(--u-color-on-surface-rgb, 29, 27, 32), var(--u-field-disabled-opacity, .38)));\n --_disabled-bg-color: var(--u-filled-field-disabled-bg-color, rgba(var(--u-color-on-surface-rgb, ), var(--u-filled-field-background-disabled-opacity, .12)));\n --_color-primary: var(--u-color-primary, rgb(103, 80, 164));\n --_color-error: var(--u-field-error-color, var(--u-color-error, rgb(179, 38, 30)));\n --_active-indicator-opacity: 1;\n --_vertical-padding: var(--u-field-vertical-padding, 8px);\n --_icon-size: var(--u-field-icon-size, 1.5rem);\n --_icon-padding: var(--u-field-icon-padding, 12px);\n --_icon-color: var(--u-icon-color, var(--u-color-on-surface-variant, rgb(73, 69, 79)));\n --_focus-border-width: var(--u-text-field-focus-border-width, 2px);\n --_field-control-leading-padding: var(--_field-control-inline-padding);\n --_outlined-label-margin: var(--u-outlined-field-label-margin, 12px);\n --_outlined-label-padding: var(--u-outlined-field-label-padding, 4px);\n --u-label-input-start: auto;\n --u-label-input-span-leading-offset: 0;\n --u-label-input-span-trailing-offset: 0;\n --u-text-field-horizontal-padding: 12px;\n display: block;\n }\n\n .container {\n display: flex;\n align-items: center;\n position: relative;\n }\n .container::before, .container::after {\n content: \"\";\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n pointer-events: none;\n }\n .container::before {\n background: var(--u-color-on-surface, rgb(29, 27, 32));\n transition: opacity 150ms;\n opacity: 0;\n }\n .container::after {\n border-width: var(--u-field-border-width, 1px);\n border-color: var(--u-field-border-color, var(--u-color-on-surface-variant, rgb(73, 69, 79)));\n }\n\n @media (hover: hover) {\n :host(:not([disabled]):not([invalid]):hover) .container.filled::before {\n opacity: var(--u-state-hover-opacity, 0.08);\n }\n :host(:not([disabled]):not([invalid]):not(:focus-within):hover) .container::after {\n border-color: var(--u-field-hover-border-color, var(--u-color-on-surface, rgb(29, 27, 32)));\n }\n }\n .icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: var(--_icon-size);\n color: var(--_icon-color);\n font-size: var(--_icon-size);\n line-height: var(--_icon-size);\n }\n .icon::slotted(*) {\n flex-shrink: 0;\n }\n\n .leading-icon {\n margin-inline-start: var(--_icon-padding);\n }\n\n .trailing-icon {\n margin-inline-end: var(--_icon-padding);\n }\n\n .label {\n font-family: var(--u-font-family, var(--u-font-family, system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Noto Sans\", \"Liberation Sans\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"));\n line-height: var(--u-field-label-line-height, var(--u-body-l-line-height, 1.5rem));\n font-size: var(--u-field-label-font-size, var(--u-body-l-font-size, 1rem));\n letter-spacing: var(--u-field-label-letter-spacing, var(--u-body-l-letter-spacing, 0.03125rem));\n font-weight: var(--u-field-label-font-weight, var(--u-body-l-font-weight, var(--u-font-weight-regular, 400)));\n font-size: var(--u-field-label-font-size, var(--u-body-s-font-size, 0.75rem));\n display: block;\n position: absolute;\n inset-inline-start: var(--_field-control-leading-padding);\n margin-bottom: 0;\n line-height: var(--_label-line-height);\n color: var(--u-field-label-color, var(--u-color-on-surface-variant, rgb(73, 69, 79)));\n transition: inset 200ms, font-size 200ms;\n }\n\n .input-wrapper {\n display: flex;\n align-items: center;\n flex: 1;\n padding-block: var(--_vertical-padding);\n padding-inline: var(--_field-control-inline-padding);\n min-height: var(--_field-min-height);\n transition: opacity 150ms;\n }\n\n .input {\n color: var(--u-field-input-text-color, var(--u-color-on-surface, rgb(29, 27, 32)));\n flex: 1;\n }\n .input:focus {\n outline: 0;\n }\n .input textarea,\n .input select,\n .input input,\n .input ::slotted(*) {\n font-family: var(--u-font-family, var(--u-font-family, system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Noto Sans\", \"Liberation Sans\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"));\n line-height: var(--u-field-control-line-height, var(--u-body-l-line-height, 1.5rem));\n font-size: var(--u-field-control-font-size, var(--u-body-l-font-size, 1rem));\n letter-spacing: var(--u-field-control-letter-spacing, var(--u-body-l-letter-spacing, 0.03125rem));\n font-weight: var(--u-field-control-font-weight, var(--u-body-l-font-weight, var(--u-font-weight-regular, 400)));\n display: block;\n width: 100%;\n color: var(--u-field-input-text-color, var(--u-color-on-surface, rgb(29, 27, 32)));\n min-height: var(--_control-line-height);\n line-height: var(--_control-line-height);\n padding: 0;\n margin: 0;\n appearance: none;\n background: transparent;\n border: none;\n outline: 0 !important;\n caret-color: var(--_color-primary);\n }\n .input,\n .input textarea::placeholder,\n .input input::placeholder,\n .input ::slotted(select),\n .input ::slotted(:is(input, textarea))::placeholder {\n transition: color 150ms 100ms;\n }\n .input textarea::placeholder,\n .input input::placeholder,\n .input ::slotted(:is(input, textarea))::placeholder {\n color: var(--_field-placeholder-color);\n }\n\n .supporting-text {\n font-family: var(--u-font-family, var(--u-font-family, system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Noto Sans\", \"Liberation Sans\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"));\n line-height: var(--u-field-supporting-text-line-height, var(--u-body-s-line-height, 1rem));\n font-size: var(--u-field-supporting-text-font-size, var(--u-body-s-font-size, 0.75rem));\n letter-spacing: var(--u-field-supporting-text-letter-spacing, var(--u-body-s-letter-spacing, 0.0333333333rem));\n font-weight: var(--u-field-supporting-text-font-weight, var(--u-body-s-font-weight, var(--u-font-weight-regular, 400)));\n display: flex;\n color: var(--u-field-supporting-text, var(--u-color-on-surface-variant, rgb(73, 69, 79)));\n padding-inline: 16px;\n gap: 16px;\n }\n .supporting-text div:empty {\n display: none;\n }\n .supporting-text div,\n .supporting-text ::slotted(*) {\n display: inline-block;\n margin-top: 4px;\n }\n\n .error-text {\n display: none;\n }\n\n .counter div, .counter::slotted(*) {\n margin-inline-start: auto;\n }\n\n :host([has-leading-icon]) {\n --_field-control-leading-padding: calc(var(--_icon-padding) + var(--_icon-size) + var(--_field-control-inline-padding)) ;\n }\n\n :host(:not([has-leading-icon])) .leading-icon {\n display: none;\n }\n\n :host(:not([has-trailing-icon])) .container:has(slot[name=trailing-icon] span:empty) .trailing-icon {\n display: none;\n }\n\n :host(:focus-within) {\n --u-field-border-width: var(--_focus-border-width);\n }\n :host(:focus-within) .container::after {\n border-color: var(--u-field-focused-border-color, var(--_color-primary));\n }\n :host(:focus-within) .label {\n color: var(--u-field-label-focused-color, var(--_color-primary));\n }\n\n :host([invalid]) .container::after {\n border-color: var(--u-field-error-border-color, var(--_color-error));\n }\n :host([invalid]) .label {\n color: var(--u-field-label-error-color, var(--_color-error));\n }\n :host([invalid]) .supporting-text {\n color: var(--u-field-supporting-text-error-color, var(--_color-error));\n }\n :host([invalid]) .trailing-icon {\n color: var(--u-field-trailing-icon-error-color, var(--_color-error));\n }\n :host([invalid]) .leading-icon {\n color: var(--u-field-leading-icon-error-color, var(--_icon-color));\n }\n\n :host([invalid]) .supporting-text:has(.error-text div:not(:empty)) .error-text,\n :host([invalid][has-error-text]) .error-text {\n display: contents;\n }\n :host([invalid]) .supporting-text:has(.error-text div:not(:empty)) slot[name=supporting-text],\n :host([invalid][has-error-text]) slot[name=supporting-text] {\n display: none;\n }\n\n .container.filled {\n border-radius: var(--u-field-filled-border-radius, 4px 4px 0 0);\n background-color: var(--u-color-surface-container-highest, rgb(230, 224, 233));\n }\n .container.filled::after {\n border-bottom-style: solid;\n }\n .container.filled:not(.no-label) .input-wrapper {\n padding-top: calc(var(--_vertical-padding) + var(--_label-line-height));\n padding-bottom: var(--_vertical-padding);\n }\n .container.filled .label {\n top: var(--_vertical-padding);\n }\n .container.filled .input ::slotted(:is(input, textarea, select, button)) {\n display: block;\n }\n .container.outlined .label {\n top: calc(var(--_label-line-height) / -2);\n }\n\n .container.outlined:focus-within .label,\n :host(:not([empty])) .container.outlined .label {\n inset-inline-start: calc(var(--_outlined-label-margin) + var(--_outlined-label-padding));\n }\n\n :host([empty]) ::slotted(select) {\n color: var(--_field-placeholder-color);\n }\n\n :host([empty]:not(:focus-within)) .label {\n font-size: var(--u-field-label-font-size, var(--u-body-l-font-size, 1rem));\n pointer-events: none;\n top: calc(var(--_field-min-height) / 2 - var(--_label-line-height) / 2);\n }\n :host([empty]:not(:focus-within)) .container:not(.no-label) .input-wrapper,\n :host([empty]:not(:focus-within)) .container:not(.no-label) .input,\n :host([empty]:not(:focus-within)) .container:not(.no-label) .input input::placeholder,\n :host([empty]:not(:focus-within)) .container:not(.no-label) .input textarea::placeholder,\n :host([empty]:not(:focus-within)) .container:not(.no-label) ::slotted(:is(input, textarea))::placeholder,\n :host([empty]:not(:focus-within)) .container:not(.no-label) ::slotted(select) {\n color: transparent;\n transition: color 150ms;\n }\n\n .container.no-label::after {\n clip-path: none !important;\n }\n\n :host([disabled]) .container .filled {\n background-color: var(--u-filled-field-disabled-bg-color, rgba(var(--u-color-on-surface-rgb, 29, 27, 32), var(--u-filled-field-background-disabled-opacity, 0.04)));\n }\n :host([disabled]) .container::after {\n border-color: var(--u-field-disabled-border-color, var(--_disabled-color));\n }\n :host([disabled]) .supporting-text {\n color: var(--u-field-supporting-text-disabled-color, var(--_disabled-color));\n }\n :host([disabled]) .label {\n color: var(--u-field-label-disabled-color, var(--_disabled-color));\n }\n :host([disabled]) .input select,\n :host([disabled]) .input select::placeholder,\n :host([disabled]) .input textarea,\n :host([disabled]) .input textarea::placeholder,\n :host([disabled]) .input input,\n :host([disabled]) .input input::placeholder,\n :host([disabled]) .input ::slotted(*),\n :host([disabled]) .input ::slotted(:is(input, textarea))::placeholder {\n color: var(--u-field-input-disabled-color, var(--_disabled-color));\n }\n :host([disabled]) .trailing-icon {\n color: var(--u-field-trailing-icon-disabled-color, var(--_disabled-color));\n }\n :host([disabled]) .leading-icon {\n color: var(--u-field-leading-icon-disabled-color, var(--_disabled-color));\n }\n`;\n"]}
|
|
1
|
+
{"version":3,"file":"field-base.styles.js","sourceRoot":"","sources":["../../src/field/field-base.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgXzB,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css `\n :host {\n --_control-line-height: var(--u-field-control-line-height, 1.5rem);\n --_label-line-height: var(--u-field-label-line-height, 1rem);\n --_field-icon-size: var(--u-field-icon-size, 1.5rem);\n --_field-control-padding: var(--u-field-control-padding, 16px);\n --_field-control-inline-padding: var(--u-field-control-inline-padding, var(--_field-control-padding));\n --_field-control-block-padding: var(--u-field-control-block-padding, var(--_field-control-padding));\n --_field-min-height: var(--u-field-min-height, 56px);\n --_field-placeholder-color: var(--u-field-placeholder-color, var(--u-color-on-surface-variant, rgb(73, 69, 79)));\n --_disabled-color: var(--u-field-disabled-color, rgba(var(--u-color-on-surface-rgb, 29, 27, 32), var(--u-field-disabled-opacity, .38)));\n --_disabled-bg-color: var(--u-filled-field-disabled-bg-color, rgba(var(--u-color-on-surface-rgb, ), var(--u-filled-field-background-disabled-opacity, .12)));\n --_color-primary: var(--u-color-primary, rgb(103, 80, 164));\n --_color-error: var(--u-field-error-color, var(--u-color-error, rgb(179, 38, 30)));\n --_active-indicator-opacity: 1;\n --_vertical-padding: var(--u-field-vertical-padding, 8px);\n --_icon-size: var(--u-field-icon-size, 1.5rem);\n --_icon-padding: var(--u-field-icon-padding, 12px);\n --_icon-color: var(--u-icon-color, var(--u-color-on-surface-variant, rgb(73, 69, 79)));\n --_border-width: var(--u-field-border-width, 1px);\n --_border-color: var(--u-field-border-color, var(--u-color-on-surface-variant, rgb(73, 69, 79)));\n --_field-control-leading-padding: var(--_field-control-inline-padding);\n --_outlined-label-margin: var(--u-outlined-field-label-margin, 12px);\n --_outlined-label-padding: var(--u-outlined-field-label-padding, 4px);\n --u-label-input-start: auto;\n --u-label-input-span-leading-offset: 0;\n --u-label-input-span-trailing-offset: 0;\n --u-text-field-horizontal-padding: 12px;\n display: block;\n }\n\n .container {\n display: flex;\n align-items: center;\n position: relative;\n }\n .container::before, .container::after {\n content: \"\";\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n pointer-events: none;\n }\n .container::before {\n background: var(--u-color-on-surface, rgb(29, 27, 32));\n transition: opacity 150ms;\n opacity: 0;\n }\n .container::after {\n border-width: var(--_border-width);\n border-color: var(--_border-color);\n }\n\n @media (hover: hover) {\n :host(:not([disabled]):not([invalid]):hover) .container.filled::before {\n opacity: var(--u-state-hover-opacity, 0.08);\n }\n :host(:not([disabled]):not([invalid]):not(:focus-within):hover) {\n --_border-color: var(--u-field-hover-border-color, var(--u-color-on-surface, rgb(29, 27, 32)));\n }\n }\n .icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: var(--_icon-size);\n color: var(--_icon-color);\n font-size: var(--_icon-size);\n line-height: var(--_icon-size);\n }\n .icon::slotted(*) {\n flex-shrink: 0;\n }\n\n .leading-icon {\n margin-inline-start: var(--_icon-padding);\n }\n\n .trailing-icon {\n margin-inline-end: var(--_icon-padding);\n }\n\n .outline-notch-label,\n .label {\n font-family: var(--u-font-family, var(--u-font-family, system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Noto Sans\", \"Liberation Sans\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"));\n line-height: var(--u-field-label-line-height, var(--u-body-l-line-height, 1.5rem));\n font-size: var(--u-field-label-font-size, var(--u-body-l-font-size, 1rem));\n letter-spacing: var(--u-field-label-letter-spacing, var(--u-body-l-letter-spacing, 0.03125rem));\n font-weight: var(--u-field-label-font-weight, var(--u-body-l-font-weight, var(--u-font-weight-regular, 400)));\n font-size: var(--u-field-label-font-size, var(--u-body-s-font-size, 0.75rem));\n }\n\n .label {\n display: block;\n position: absolute;\n inset-inline-start: var(--_field-control-leading-padding);\n margin-bottom: 0;\n line-height: var(--_label-line-height);\n color: var(--u-field-label-color, var(--u-color-on-surface-variant, rgb(73, 69, 79)));\n transition: inset 200ms, font-size 200ms;\n }\n\n .input-wrapper {\n display: flex;\n align-items: center;\n flex: 1;\n padding-block: var(--_vertical-padding);\n padding-inline: var(--_field-control-inline-padding);\n min-height: var(--_field-min-height);\n transition: opacity 150ms;\n }\n\n .input {\n color: var(--u-field-input-text-color, var(--u-color-on-surface, rgb(29, 27, 32)));\n flex: 1;\n }\n .input:focus {\n outline: 0;\n }\n .input textarea,\n .input select,\n .input input,\n .input ::slotted(*) {\n font-family: var(--u-font-family, var(--u-font-family, system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Noto Sans\", \"Liberation Sans\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"));\n line-height: var(--u-field-control-line-height, var(--u-body-l-line-height, 1.5rem));\n font-size: var(--u-field-control-font-size, var(--u-body-l-font-size, 1rem));\n letter-spacing: var(--u-field-control-letter-spacing, var(--u-body-l-letter-spacing, 0.03125rem));\n font-weight: var(--u-field-control-font-weight, var(--u-body-l-font-weight, var(--u-font-weight-regular, 400)));\n display: block;\n width: 100%;\n color: var(--u-field-input-text-color, var(--u-color-on-surface, rgb(29, 27, 32)));\n min-height: var(--_control-line-height);\n line-height: var(--_control-line-height);\n padding: 0;\n margin: 0;\n appearance: none;\n background: transparent;\n border: none;\n outline: 0 !important;\n caret-color: var(--_color-primary);\n }\n .input,\n .input textarea::placeholder,\n .input input::placeholder,\n .input ::slotted(select),\n .input ::slotted(:is(input, textarea))::placeholder {\n transition: color 150ms 100ms;\n }\n .input textarea::placeholder,\n .input input::placeholder,\n .input ::slotted(:is(input, textarea))::placeholder {\n color: var(--_field-placeholder-color);\n }\n\n .supporting-text {\n font-family: var(--u-font-family, var(--u-font-family, system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Noto Sans\", \"Liberation Sans\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"));\n line-height: var(--u-field-supporting-text-line-height, var(--u-body-s-line-height, 1rem));\n font-size: var(--u-field-supporting-text-font-size, var(--u-body-s-font-size, 0.75rem));\n letter-spacing: var(--u-field-supporting-text-letter-spacing, var(--u-body-s-letter-spacing, 0.0333333333rem));\n font-weight: var(--u-field-supporting-text-font-weight, var(--u-body-s-font-weight, var(--u-font-weight-regular, 400)));\n display: flex;\n color: var(--u-field-supporting-text, var(--u-color-on-surface-variant, rgb(73, 69, 79)));\n padding-inline: 16px;\n gap: 16px;\n }\n .supporting-text div:empty {\n display: none;\n }\n .supporting-text div,\n .supporting-text ::slotted(*) {\n display: inline-block;\n margin-top: 4px;\n }\n\n .error-text {\n display: none;\n }\n\n .counter div, .counter::slotted(*) {\n margin-inline-start: auto;\n }\n\n :host([has-leading-icon]) {\n --_field-control-leading-padding: calc(var(--_icon-padding) + var(--_icon-size) + var(--_field-control-inline-padding)) ;\n }\n\n :host(:not([has-leading-icon])) .leading-icon {\n display: none;\n }\n\n :host(:not([has-trailing-icon])) .container:has(slot[name=trailing-icon] span:empty) .trailing-icon {\n display: none;\n }\n\n :host(:focus-within) {\n --_border-width: var(--u-text-field-focus-border-width, 2px);\n --_border-color: var(--u-field-focused-border-color, var(--_color-primary));\n }\n :host(:focus-within) .label {\n color: var(--u-field-label-focused-color, var(--_color-primary));\n }\n\n :host([invalid]) {\n --_border-color: var(--u-field-error-border-color, var(--_color-error));\n }\n :host([invalid]) .label {\n color: var(--u-field-label-error-color, var(--_color-error));\n }\n :host([invalid]) .supporting-text {\n color: var(--u-field-supporting-text-error-color, var(--_color-error));\n }\n :host([invalid]) .trailing-icon {\n color: var(--u-field-trailing-icon-error-color, var(--_color-error));\n }\n :host([invalid]) .leading-icon {\n color: var(--u-field-leading-icon-error-color, var(--_icon-color));\n }\n\n :host([invalid]) .supporting-text:has(.error-text div:not(:empty)) .error-text,\n :host([invalid][has-error-text]) .error-text {\n display: contents;\n }\n :host([invalid]) .supporting-text:has(.error-text div:not(:empty)) slot[name=supporting-text],\n :host([invalid][has-error-text]) slot[name=supporting-text] {\n display: none;\n }\n\n .container.filled {\n border-radius: var(--u-field-filled-border-radius, 4px 4px 0 0);\n background-color: var(--u-color-surface-container-highest, rgb(230, 224, 233));\n }\n .container.filled::after {\n border-bottom-style: solid;\n }\n .container.filled:not(.no-label) .input-wrapper {\n padding-top: calc(var(--_vertical-padding) + var(--_label-line-height));\n padding-bottom: var(--_vertical-padding);\n }\n .container.filled .label {\n top: var(--_vertical-padding);\n }\n .container.filled .input ::slotted(:is(input, textarea, select, button)) {\n display: block;\n }\n .container.outlined .label {\n top: calc(var(--_label-line-height) / -2);\n }\n\n .container.outlined:focus-within .label,\n :host(:not([empty])) .container.outlined .label {\n inset-inline-start: calc(var(--_outlined-label-margin) + var(--_outlined-label-padding));\n }\n\n :host([empty]) ::slotted(select) {\n color: var(--_field-placeholder-color);\n }\n\n :host([empty]:not(:focus-within)) .label {\n font-size: var(--u-field-label-font-size, var(--u-body-l-font-size, 1rem));\n pointer-events: none;\n top: calc(var(--_field-min-height) / 2 - var(--_label-line-height) / 2);\n }\n :host([empty]:not(:focus-within)) .container:not(.no-label) .input-wrapper,\n :host([empty]:not(:focus-within)) .container:not(.no-label) .input,\n :host([empty]:not(:focus-within)) .container:not(.no-label) .input input::placeholder,\n :host([empty]:not(:focus-within)) .container:not(.no-label) .input textarea::placeholder,\n :host([empty]:not(:focus-within)) .container:not(.no-label) ::slotted(:is(input, textarea))::placeholder,\n :host([empty]:not(:focus-within)) .container:not(.no-label) ::slotted(select) {\n color: transparent;\n transition: color 150ms;\n }\n\n :host([disabled]) {\n --_border-color: var(--u-field-disabled-border-color, var(--_disabled-color));\n }\n :host([disabled]) .container .filled {\n background-color: var(--u-filled-field-disabled-bg-color, rgba(var(--u-color-on-surface-rgb, 29, 27, 32), var(--u-filled-field-background-disabled-opacity, 0.04)));\n }\n :host([disabled]) .supporting-text {\n color: var(--u-field-supporting-text-disabled-color, var(--_disabled-color));\n }\n :host([disabled]) .label {\n color: var(--u-field-label-disabled-color, var(--_disabled-color));\n }\n :host([disabled]) .input select,\n :host([disabled]) .input select::placeholder,\n :host([disabled]) .input textarea,\n :host([disabled]) .input textarea::placeholder,\n :host([disabled]) .input input,\n :host([disabled]) .input input::placeholder,\n :host([disabled]) .input ::slotted(*),\n :host([disabled]) .input ::slotted(:is(input, textarea))::placeholder {\n color: var(--u-field-input-disabled-color, var(--_disabled-color));\n }\n :host([disabled]) .trailing-icon {\n color: var(--u-field-trailing-icon-disabled-color, var(--_disabled-color));\n }\n :host([disabled]) .leading-icon {\n color: var(--u-field-leading-icon-disabled-color, var(--_disabled-color));\n }\n\n .outline {\n position: absolute;\n inset: 0;\n display: flex;\n border-radius: var(--u-outlined-field-shape-corder, var(--u-shape-corner-small, 8px));\n pointer-events: none;\n }\n\n .outline-start,\n .outline-end {\n border: var(--_border-width) solid var(--_border-color);\n border-radius: inherit;\n flex-basis: var(--_outlined-label-margin);\n }\n\n .outline-start {\n border-start-end-radius: 0;\n border-end-end-radius: 0;\n border-inline-end: none;\n }\n\n .outline-end {\n flex: 1;\n border-start-start-radius: 0;\n border-end-start-radius: 0;\n border-inline-start: none;\n }\n\n .outline-notch {\n min-width: 0;\n border-bottom: var(--_border-width) solid var(--_border-color);\n }\n\n .outline-notch-label {\n position: relative;\n color: transparent;\n padding-inline: var(--_outlined-label-padding);\n user-select: none;\n }\n\n .outline-notch-label::before,\n .outline-notch-label::after {\n content: \"\";\n position: absolute;\n border-top: var(--_border-width) solid var(--_border-color);\n width: 50%;\n transition: width 100ms;\n }\n\n .outline-notch-label::before {\n left: 0;\n }\n\n .outline-notch-label::after {\n right: 0;\n }\n\n .container:not(.no-label):focus-within .outline-notch-label::before,\n .container:not(.no-label):focus-within .outline-notch-label::after,\n :host(:not([empty])) .container:not(.no-label) .outline-notch-label::before,\n :host(:not([empty])) .container:not(.no-label) .outline-notch-label::after {\n width: 0;\n }\n`;\n"]}
|
package/package.json
CHANGED
|
@@ -4,11 +4,13 @@ import '../../ripple/ripple.js';
|
|
|
4
4
|
export declare abstract class UmSelectionControl extends LitElement {
|
|
5
5
|
#private;
|
|
6
6
|
static readonly formAssociated = true;
|
|
7
|
+
static shadowRootOptions: ShadowRootInit;
|
|
7
8
|
protected readonly elementInternals: ElementInternals;
|
|
8
9
|
name: string | undefined;
|
|
9
10
|
disabled: boolean;
|
|
10
11
|
input: HTMLInputElement;
|
|
11
12
|
get form(): HTMLFormElement | null;
|
|
13
|
+
focus(options?: FocusOptions): void;
|
|
12
14
|
protected inputType: 'checkbox' | 'radio';
|
|
13
15
|
protected renderRipple: boolean;
|
|
14
16
|
protected abstract renderIndicator(): HTMLTemplateResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection-control.d.ts","sourceRoot":"","sources":["../../../src/shared/selection-control/selection-control.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAQ,kBAAkB,EAAE,UAAU,EAAW,MAAM,KAAK,CAAC;AAGpE,OAAO,wBAAwB,CAAC;AAEhC,8BAAsB,kBAAmB,SAAQ,UAAU;;IACzD,MAAM,CAAC,QAAQ,CAAC,cAAc,QAAQ;IAEtC,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"selection-control.d.ts","sourceRoot":"","sources":["../../../src/shared/selection-control/selection-control.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAQ,kBAAkB,EAAE,UAAU,EAAW,MAAM,KAAK,CAAC;AAGpE,OAAO,wBAAwB,CAAC;AAEhC,8BAAsB,kBAAmB,SAAQ,UAAU;;IACzD,MAAM,CAAC,QAAQ,CAAC,cAAc,QAAQ;IAEtC,OAAgB,iBAAiB,EAAE,cAAc,CAG/C;IAEF,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAEzB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAM;IACf,QAAQ,UAAS;IAC7C,KAAK,EAAG,gBAAgB,CAAC;IAEzC,IAAI,IAAI,IAAI,eAAe,GAAG,IAAI,CAEjC;IAEQ,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY;IAKrC,SAAS,CAAC,SAAS,EAAE,UAAU,GAAG,OAAO,CAAc;IACvD,SAAS,CAAC,YAAY,UAAQ;IAE9B,SAAS,CAAC,QAAQ,CAAC,eAAe,IAAI,kBAAkB;IAExD;;OAEG;IACS,KAAK,SAAQ;IAEzB,IACI,OAAO,IAGU,OAAO,CAD3B;IACD,IAAI,OAAO,CAAC,OAAO,EAAE,OAAO,EAQ3B;IAEkD,OAAO,CAAC,iBAAiB,CAAS;IAErF,SAAS;IAKA,YAAY,CAAC,iBAAiB,EAAE,cAAc;IAM9C,iBAAiB;IAMjB,oBAAoB;cAKV,MAAM,IAAI,kBAAkB;CA4BhD"}
|
|
@@ -9,9 +9,16 @@ import { property, query } from 'lit/decorators.js';
|
|
|
9
9
|
import '../../ripple/ripple.js';
|
|
10
10
|
export class UmSelectionControl extends LitElement {
|
|
11
11
|
static { this.formAssociated = true; }
|
|
12
|
+
static { this.shadowRootOptions = {
|
|
13
|
+
...LitElement.shadowRootOptions,
|
|
14
|
+
delegatesFocus: true,
|
|
15
|
+
}; }
|
|
12
16
|
get form() {
|
|
13
17
|
return this.elementInternals.form;
|
|
14
18
|
}
|
|
19
|
+
focus(options) {
|
|
20
|
+
this.input.focus(options);
|
|
21
|
+
}
|
|
15
22
|
#checked;
|
|
16
23
|
get checked() {
|
|
17
24
|
return this.input ? this.input.checked : this.#checked;
|
|
@@ -50,7 +57,9 @@ export class UmSelectionControl extends LitElement {
|
|
|
50
57
|
this.removeEventListener('click', this.#handleClick);
|
|
51
58
|
}
|
|
52
59
|
render() {
|
|
53
|
-
const ripple = html
|
|
60
|
+
const ripple = html `
|
|
61
|
+
<u-ripple ?disabled=${this.disabled}></u-ripple>
|
|
62
|
+
`;
|
|
54
63
|
return html `
|
|
55
64
|
<div class="container">
|
|
56
65
|
${this.renderRipple ? ripple : nothing}
|
|
@@ -61,7 +70,8 @@ export class UmSelectionControl extends LitElement {
|
|
|
61
70
|
.checked=${this._checkedAttribute}
|
|
62
71
|
.disabled=${this.disabled} />
|
|
63
72
|
<div class="indicator-container">${this.renderIndicator()}</div>
|
|
64
|
-
</div
|
|
73
|
+
</div>
|
|
74
|
+
`;
|
|
65
75
|
}
|
|
66
76
|
#handleClick(e) {
|
|
67
77
|
if (e.defaultPrevented) {
|
|
@@ -73,7 +83,7 @@ export class UmSelectionControl extends LitElement {
|
|
|
73
83
|
}
|
|
74
84
|
}
|
|
75
85
|
__decorate([
|
|
76
|
-
property()
|
|
86
|
+
property({ reflect: true })
|
|
77
87
|
], UmSelectionControl.prototype, "name", void 0);
|
|
78
88
|
__decorate([
|
|
79
89
|
property({ type: Boolean, reflect: true })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection-control.js","sourceRoot":"","sources":["../../../src/shared/selection-control/selection-control.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,IAAI,EAAsB,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,wBAAwB,CAAC;AAEhC,MAAM,OAAgB,kBAAmB,SAAQ,UAAU;aACzC,mBAAc,GAAG,IAAI,AAAP,CAAQ;
|
|
1
|
+
{"version":3,"file":"selection-control.js","sourceRoot":"","sources":["../../../src/shared/selection-control/selection-control.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,IAAI,EAAsB,UAAU,EAAE,OAAO,EAAE,M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E,IAAI,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC;;AAxF4B;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gDAA+B;AACf;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDAAkB;AAC7C;IAAf,KAAK,CAAC,OAAO,CAAC;iDAA0B;AAmB7B;IAAX,QAAQ,EAAE;iDAAc;AAGzB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iDAG3B;AAW0D;IAA1D,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;6DAAmC","sourcesContent":["import { PropertyValues } from '@lit/reactive-element';\nimport { html, HTMLTemplateResult, LitElement, nothing } from 'lit';\nimport { property, query } from 'lit/decorators.js';\n\nimport '../../ripple/ripple.js';\n\nexport abstract class UmSelectionControl extends LitElement {\n static readonly formAssociated = true;\n\n static override shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n protected readonly elementInternals: ElementInternals;\n\n @property({ reflect: true }) name: string | undefined = '';\n @property({ type: Boolean, reflect: true }) disabled = false;\n @query('input') input!: HTMLInputElement;\n\n get form(): HTMLFormElement | null {\n return this.elementInternals.form;\n }\n\n override focus(options?: FocusOptions) {\n this.input!.focus(options);\n }\n\n #checked = false;\n protected inputType: 'checkbox' | 'radio' = 'checkbox';\n protected renderRipple = true;\n\n protected abstract renderIndicator(): HTMLTemplateResult;\n\n /**\n * The element value to use in form submission when checked.\n */\n @property() value = 'on';\n\n @property({ type: Boolean })\n get checked() {\n return this.input ? this.input.checked : this.#checked;\n }\n set checked(checked: boolean) {\n this.#checked = checked;\n\n if (this.input) {\n this.input.checked = checked;\n }\n\n this.elementInternals.setFormValue(checked ? this.value : null);\n }\n\n @property({ type: Boolean, attribute: 'checked' }) private _checkedAttribute = false;\n\n protected constructor() {\n super();\n this.elementInternals = this.attachInternals();\n }\n\n override firstUpdated(changedProperties: PropertyValues) {\n super.firstUpdated(changedProperties);\n\n this.input.checked = this.#checked;\n }\n\n override connectedCallback() {\n super.connectedCallback();\n\n this.addEventListener('click', this.#handleClick);\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener('click', this.#handleClick);\n }\n\n protected override render(): HTMLTemplateResult {\n const ripple = html`\n <u-ripple ?disabled=${this.disabled}></u-ripple>\n `;\n\n return html`\n <div class=\"container\">\n ${this.renderRipple ? ripple : nothing}\n <input\n id=\"input\"\n type=${this.inputType}\n class=\"focus-ring\"\n .checked=${this._checkedAttribute}\n .disabled=${this.disabled} />\n <div class=\"indicator-container\">${this.renderIndicator()}</div>\n </div>\n `;\n }\n\n #handleClick(e: Event) {\n if (e.defaultPrevented) {\n return;\n }\n\n this.checked = this.inputType === 'radio' || !this.checked;\n this.dispatchEvent(new InputEvent('input', { bubbles: true, composed: true }));\n this.dispatchEvent(new Event('change', { bubbles: true }));\n }\n}\n"]}
|