@politiet/sheriff-web-components 2.6.0 → 2.6.1
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 +1270 -978
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mixins/index.d.ts +3 -0
- package/dist/mixins/index.d.ts.map +1 -1
- package/dist/mixins/index.js +3 -0
- package/dist/mixins/index.js.map +1 -1
- package/dist/mixins/sds-dialog-target-mixin.d.ts +11 -0
- package/dist/mixins/sds-dialog-target-mixin.d.ts.map +1 -0
- package/dist/mixins/sds-dialog-target-mixin.js +95 -0
- package/dist/mixins/sds-dialog-target-mixin.js.map +1 -0
- package/dist/mixins/sds-form-control-mixin.d.ts +14 -0
- package/dist/mixins/sds-form-control-mixin.d.ts.map +1 -0
- package/dist/mixins/sds-form-control-mixin.js +40 -0
- package/dist/mixins/sds-form-control-mixin.js.map +1 -0
- package/dist/sds-button/sds-button.component.d.ts +3 -1
- package/dist/sds-button/sds-button.component.d.ts.map +1 -1
- package/dist/sds-button/sds-button.component.js +13 -3
- package/dist/sds-button/sds-button.component.js.map +1 -1
- package/dist/sds-checkbox/sds-checkbox.d.ts +8 -16
- package/dist/sds-checkbox/sds-checkbox.d.ts.map +1 -1
- package/dist/sds-checkbox/sds-checkbox.js +38 -51
- package/dist/sds-checkbox/sds-checkbox.js.map +1 -1
- package/dist/sds-checkbox/sds-checkbox.styles.d.ts.map +1 -1
- package/dist/sds-checkbox/sds-checkbox.styles.js +1 -0
- package/dist/sds-checkbox/sds-checkbox.styles.js.map +1 -1
- package/dist/sds-chip/sds-chip.d.ts +7 -15
- package/dist/sds-chip/sds-chip.d.ts.map +1 -1
- package/dist/sds-chip/sds-chip.js +16 -29
- package/dist/sds-chip/sds-chip.js.map +1 -1
- package/dist/sds-chip/sds-chip.styles.js +1 -1
- package/dist/sds-chip/sds-chip.styles.js.map +1 -1
- package/dist/sds-dialog/sds-dialog.component.d.ts +56 -0
- package/dist/sds-dialog/sds-dialog.component.d.ts.map +1 -0
- package/dist/sds-dialog/sds-dialog.component.js +181 -0
- package/dist/sds-dialog/sds-dialog.component.js.map +1 -0
- package/dist/sds-dialog/sds-dialog.d.ts +2 -52
- package/dist/sds-dialog/sds-dialog.d.ts.map +1 -1
- package/dist/sds-dialog/sds-dialog.js +2 -163
- package/dist/sds-dialog/sds-dialog.js.map +1 -1
- package/dist/sds-dialog/sds-dialog.spec.d.ts +2 -0
- package/dist/sds-dialog/sds-dialog.spec.d.ts.map +1 -0
- package/dist/sds-dialog/sds-dialog.spec.js +50 -0
- package/dist/sds-dialog/sds-dialog.spec.js.map +1 -0
- package/dist/sds-dialog/sds-dialog.styles.d.ts.map +1 -1
- package/dist/sds-dialog/sds-dialog.styles.js +1 -3
- package/dist/sds-dialog/sds-dialog.styles.js.map +1 -1
- package/dist/sds-radio/sds-radio.d.ts +14 -17
- package/dist/sds-radio/sds-radio.d.ts.map +1 -1
- package/dist/sds-radio/sds-radio.js +45 -61
- package/dist/sds-radio/sds-radio.js.map +1 -1
- package/dist/sds-select/sds-select.component.d.ts +54 -0
- package/dist/sds-select/sds-select.component.d.ts.map +1 -0
- package/dist/sds-select/sds-select.component.js +290 -0
- package/dist/sds-select/sds-select.component.js.map +1 -0
- package/dist/sds-select/sds-select.d.ts +2 -61
- package/dist/sds-select/sds-select.d.ts.map +1 -1
- package/dist/sds-select/sds-select.js +2 -298
- package/dist/sds-select/sds-select.js.map +1 -1
- package/dist/sds-select/sds-select.styles.js +1 -1
- package/dist/sds-select/sds-select.styles.js.map +1 -1
- package/dist/sds-stepper/sds-stepper.d.ts +0 -1
- package/dist/sds-stepper/sds-stepper.d.ts.map +1 -1
- package/dist/sds-stepper/sds-stepper.js +2 -3
- package/dist/sds-stepper/sds-stepper.js.map +1 -1
- package/dist/sds-stepper/sds-stepper.styles.d.ts.map +1 -1
- package/dist/sds-stepper/sds-stepper.styles.js +2 -1
- package/dist/sds-stepper/sds-stepper.styles.js.map +1 -1
- package/dist/sds-stepper-step/sds-stepper-step.styles.d.ts.map +1 -1
- package/dist/sds-stepper-step/sds-stepper-step.styles.js +7 -5
- package/dist/sds-stepper-step/sds-stepper-step.styles.js.map +1 -1
- package/dist/sds-switch/sds-switch.d.ts +5 -14
- package/dist/sds-switch/sds-switch.d.ts.map +1 -1
- package/dist/sds-switch/sds-switch.js +13 -26
- package/dist/sds-switch/sds-switch.js.map +1 -1
- package/dist/sds-switch/sds-switch.styles.js +1 -1
- package/dist/sds-switch/sds-switch.styles.js.map +1 -1
- package/dist/sds-textarea/sds-textarea.d.ts +12 -21
- package/dist/sds-textarea/sds-textarea.d.ts.map +1 -1
- package/dist/sds-textarea/sds-textarea.js +3 -20
- package/dist/sds-textarea/sds-textarea.js.map +1 -1
- package/dist/sds-textarea/sds-textarea.styles.d.ts.map +1 -1
- package/dist/sds-textarea/sds-textarea.styles.js +8 -5
- package/dist/sds-textarea/sds-textarea.styles.js.map +1 -1
- package/dist/sds-textfield/sds-textfield.d.ts +11 -20
- package/dist/sds-textfield/sds-textfield.d.ts.map +1 -1
- package/dist/sds-textfield/sds-textfield.js +4 -21
- package/dist/sds-textfield/sds-textfield.js.map +1 -1
- package/dist/sds-textfield/sds-textfield.styles.d.ts.map +1 -1
- package/dist/sds-textfield/sds-textfield.styles.js +5 -1
- package/dist/sds-textfield/sds-textfield.styles.js.map +1 -1
- package/dist/sheriff-web-components.js +186 -177
- package/package.json +1 -1
- package/web-types.json +1000 -853
|
@@ -10,52 +10,16 @@ import { ifDefined } from 'lit/directives/if-defined.js';
|
|
|
10
10
|
import { classMap } from 'lit/directives/class-map.js';
|
|
11
11
|
import { guardedCustomElement } from '../utils/guarded-custom-element';
|
|
12
12
|
import { styles } from './sds-radio.styles';
|
|
13
|
-
import { SDSDelegateInteractionMixin, SDSEventDispatcherMixin } from '../mixins';
|
|
14
|
-
let SDSRadio = class SDSRadio extends SDSDelegateInteractionMixin(SDSEventDispatcherMixin(LitElement)) {
|
|
15
|
-
get disabled() {
|
|
16
|
-
return this._disabled;
|
|
17
|
-
}
|
|
18
|
-
set disabled(value) {
|
|
19
|
-
const newVal = value ?? false;
|
|
20
|
-
const oldVal = this._disabled;
|
|
21
|
-
if (oldVal === newVal)
|
|
22
|
-
return;
|
|
23
|
-
this._disabled = newVal;
|
|
24
|
-
this.requestUpdate('disabled', oldVal);
|
|
25
|
-
if (!this._settingDisabledFromParent) {
|
|
26
|
-
this._disabledIsAuthorControlled = newVal;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* parentRequestDisabled:
|
|
31
|
-
* - Set by SDSRadioGroup to request disabled/enabled.
|
|
32
|
-
* - Only applied if SDSRadio is NOT self-controlled.
|
|
33
|
-
*/
|
|
34
|
-
get parentRequestDisabled() {
|
|
35
|
-
return this._parentRequestDisabled;
|
|
36
|
-
}
|
|
37
|
-
set parentRequestDisabled(value) {
|
|
38
|
-
const newVal = value ?? false;
|
|
39
|
-
const oldVal = this._parentRequestDisabled;
|
|
40
|
-
if (oldVal === newVal)
|
|
41
|
-
return;
|
|
42
|
-
this._parentRequestDisabled = newVal;
|
|
43
|
-
this.requestUpdate('parentRequestDisabled', oldVal);
|
|
44
|
-
if (this._disabledIsAuthorControlled)
|
|
45
|
-
return;
|
|
46
|
-
this._settingDisabledFromParent = true;
|
|
47
|
-
this.disabled = newVal;
|
|
48
|
-
this._settingDisabledFromParent = false;
|
|
49
|
-
}
|
|
13
|
+
import { SDSDelegateInteractionMixin, SDSEventDispatcherMixin, SDSFormControlMixin } from '../mixins';
|
|
14
|
+
let SDSRadio = class SDSRadio extends SDSDelegateInteractionMixin(SDSEventDispatcherMixin(SDSFormControlMixin(LitElement))) {
|
|
50
15
|
constructor() {
|
|
51
|
-
super();
|
|
16
|
+
super(...arguments);
|
|
52
17
|
this.required = false;
|
|
53
18
|
this.label = '';
|
|
54
19
|
this.hideLabel = false;
|
|
55
20
|
this.value = 'on';
|
|
56
21
|
this.checked = false;
|
|
57
22
|
this.error = false;
|
|
58
|
-
this.readOnly = false;
|
|
59
23
|
this.size = 'md';
|
|
60
24
|
this._disabled = false;
|
|
61
25
|
this._disabledIsAuthorControlled = false;
|
|
@@ -110,7 +74,47 @@ let SDSRadio = class SDSRadio extends SDSDelegateInteractionMixin(SDSEventDispat
|
|
|
110
74
|
event.stopImmediatePropagation();
|
|
111
75
|
this.dispatchSheriffEvent('blur');
|
|
112
76
|
};
|
|
113
|
-
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* disabled:
|
|
80
|
+
* - If set directly (prop/attr), this radio becomes "self-controlled"
|
|
81
|
+
* and ignores parentRequestDisabled.
|
|
82
|
+
* - If not self-controlled, this follows parentRequestDisabled (group/form).
|
|
83
|
+
*/
|
|
84
|
+
get disabled() {
|
|
85
|
+
return this._disabled;
|
|
86
|
+
}
|
|
87
|
+
set disabled(value) {
|
|
88
|
+
const newVal = value ?? false;
|
|
89
|
+
const oldVal = this._disabled;
|
|
90
|
+
if (oldVal === newVal)
|
|
91
|
+
return;
|
|
92
|
+
this._disabled = newVal;
|
|
93
|
+
this.requestUpdate('disabled', oldVal);
|
|
94
|
+
if (!this._settingDisabledFromParent) {
|
|
95
|
+
this._disabledIsAuthorControlled = newVal;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* parentRequestDisabled:
|
|
100
|
+
* - Set by SDSRadioGroup to request disabled/enabled.
|
|
101
|
+
* - Only applied if SDSRadio is NOT self-controlled.
|
|
102
|
+
*/
|
|
103
|
+
get parentRequestDisabled() {
|
|
104
|
+
return this._parentRequestDisabled;
|
|
105
|
+
}
|
|
106
|
+
set parentRequestDisabled(value) {
|
|
107
|
+
const newVal = value ?? false;
|
|
108
|
+
const oldVal = this._parentRequestDisabled;
|
|
109
|
+
if (oldVal === newVal)
|
|
110
|
+
return;
|
|
111
|
+
this._parentRequestDisabled = newVal;
|
|
112
|
+
this.requestUpdate('parentRequestDisabled', oldVal);
|
|
113
|
+
if (this._disabledIsAuthorControlled)
|
|
114
|
+
return;
|
|
115
|
+
this._settingDisabledFromParent = true;
|
|
116
|
+
this.disabled = newVal;
|
|
117
|
+
this._settingDisabledFromParent = false;
|
|
114
118
|
}
|
|
115
119
|
connectedCallback() {
|
|
116
120
|
super.connectedCallback();
|
|
@@ -188,9 +192,6 @@ let SDSRadio = class SDSRadio extends SDSDelegateInteractionMixin(SDSEventDispat
|
|
|
188
192
|
}
|
|
189
193
|
}
|
|
190
194
|
}
|
|
191
|
-
get form() {
|
|
192
|
-
return this.internals.form;
|
|
193
|
-
}
|
|
194
195
|
get type() {
|
|
195
196
|
return 'radio';
|
|
196
197
|
}
|
|
@@ -254,11 +255,6 @@ let SDSRadio = class SDSRadio extends SDSDelegateInteractionMixin(SDSEventDispat
|
|
|
254
255
|
};
|
|
255
256
|
// Styling
|
|
256
257
|
SDSRadio.styles = [styles];
|
|
257
|
-
SDSRadio.formAssociated = true;
|
|
258
|
-
SDSRadio.shadowRootOptions = {
|
|
259
|
-
...LitElement.shadowRootOptions,
|
|
260
|
-
delegatesFocus: true,
|
|
261
|
-
};
|
|
262
258
|
__decorate([
|
|
263
259
|
property({ type: Boolean, reflect: true })
|
|
264
260
|
], SDSRadio.prototype, "required", void 0);
|
|
@@ -268,9 +264,6 @@ __decorate([
|
|
|
268
264
|
__decorate([
|
|
269
265
|
property({ type: Boolean, reflect: true, attribute: 'hide-label' })
|
|
270
266
|
], SDSRadio.prototype, "hideLabel", void 0);
|
|
271
|
-
__decorate([
|
|
272
|
-
property({ type: String, reflect: true })
|
|
273
|
-
], SDSRadio.prototype, "name", void 0);
|
|
274
267
|
__decorate([
|
|
275
268
|
property({ type: String })
|
|
276
269
|
], SDSRadio.prototype, "value", void 0);
|
|
@@ -280,9 +273,6 @@ __decorate([
|
|
|
280
273
|
__decorate([
|
|
281
274
|
property({ type: Boolean, reflect: true })
|
|
282
275
|
], SDSRadio.prototype, "error", void 0);
|
|
283
|
-
__decorate([
|
|
284
|
-
property({ type: Boolean, attribute: 'readonly', reflect: true })
|
|
285
|
-
], SDSRadio.prototype, "readOnly", void 0);
|
|
286
276
|
__decorate([
|
|
287
277
|
property({ type: String, reflect: true })
|
|
288
278
|
], SDSRadio.prototype, "size", void 0);
|
|
@@ -290,13 +280,7 @@ __decorate([
|
|
|
290
280
|
property({ type: String, attribute: 'help-text' })
|
|
291
281
|
], SDSRadio.prototype, "helpText", void 0);
|
|
292
282
|
__decorate([
|
|
293
|
-
property({ type: Boolean
|
|
294
|
-
/**
|
|
295
|
-
* disabled:
|
|
296
|
-
* - If set directly (prop/attr), this radio becomes "self-controlled"
|
|
297
|
-
* and ignores parentRequestDisabled.
|
|
298
|
-
* - If not self-controlled, this follows parentRequestDisabled (group/form).
|
|
299
|
-
*/
|
|
283
|
+
property({ type: Boolean })
|
|
300
284
|
], SDSRadio.prototype, "disabled", null);
|
|
301
285
|
__decorate([
|
|
302
286
|
property({ type: Boolean, attribute: false })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sds-radio.js","sourceRoot":"","sources":["../../src/sds-radio/sds-radio.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAkB,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAoB1E,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,2BAA2B,CAAC,uBAAuB,CAAC,UAAU,CAAC,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MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;0CAAuC;AAS1F;IARC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAE3C;;;;;OAKG;wCAGF;AAqBD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;qDAG7C;AAiBkB;IAAlB,KAAK,CAAC,UAAU,CAAC;yCAA4B;AAxElC,QAAQ;IADpB,oBAAoB,CAAC,WAAW,CAAC;GACrB,QAAQ,CA0SpB","sourcesContent":["import { LitElement, PropertyValues, html, nothing } from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { guardedCustomElement } from '../utils/guarded-custom-element';\nimport { styles } from './sds-radio.styles';\nimport { SDS_SIZES } from '../types';\nimport { SDSDelegateInteractionMixin, SDSEventDispatcherMixin } from '../mixins';\n\ntype RadioSize = Extract<SDS_SIZES, 'lg' | 'md' | 'sm'>;\n\nexport interface SDSRadioProps {\n\tdisabled?: boolean;\n\trequired?: boolean;\n\tlabel?: string;\n\t'hide-label'?: boolean;\n\tname?: string;\n\tvalue?: string;\n\tchecked?: boolean;\n\terror?: boolean;\n\treadonly?: boolean;\n\tsize?: RadioSize;\n\t'help-text'?: string;\n\tparentRequestDisabled?: boolean;\n}\n\n@guardedCustomElement('sds-radio')\nexport class SDSRadio extends SDSDelegateInteractionMixin(SDSEventDispatcherMixin(LitElement)) {\n\t// Styling\n\tstatic override styles = [styles];\n\n\tstatic formAssociated = true;\n\tpublic readonly internals: ElementInternals;\n\n\tstatic override shadowRootOptions: ShadowRootInit = {\n\t\t...LitElement.shadowRootOptions,\n\t\tdelegatesFocus: true,\n\t};\n\n\t@property({ type: Boolean, reflect: true }) required: SDSRadioProps['required'] = false;\n\t@property({ type: String, reflect: true }) label: SDSRadioProps['label'] = '';\n\t@property({ type: Boolean, reflect: true, attribute: 'hide-label' }) hideLabel: SDSRadioProps['hide-label'] = false;\n\t@property({ type: String, reflect: true }) name?: SDSRadioProps['name'];\n\t@property({ type: String }) value: SDSRadioProps['value'] = 'on';\n\t@property({ type: Boolean, reflect: true }) checked: SDSRadioProps['checked'] = false;\n\t@property({ type: Boolean, reflect: true }) error: SDSRadioProps['error'] = false;\n\t@property({ type: Boolean, attribute: 'readonly', reflect: true }) readOnly: SDSRadioProps['readonly'] = false;\n\t@property({ type: String, reflect: true }) size: SDSRadioProps['size'] = 'md';\n\t@property({ type: String, attribute: 'help-text' }) helpText?: SDSRadioProps['help-text'];\n\t@property({ type: Boolean, reflect: true })\n\n\t/**\n\t * disabled:\n\t * - If set directly (prop/attr), this radio becomes \"self-controlled\"\n\t * and ignores parentRequestDisabled.\n\t * - If not self-controlled, this follows parentRequestDisabled (group/form).\n\t */\n\tget disabled(): SDSRadioProps['disabled'] {\n\t\treturn this._disabled;\n\t}\n\tset disabled(value: SDSRadioProps['disabled']) {\n\t\tconst newVal = value ?? false;\n\t\tconst oldVal = this._disabled;\n\n\t\tif (oldVal === newVal) return;\n\n\t\tthis._disabled = newVal;\n\t\tthis.requestUpdate('disabled', oldVal);\n\n\t\tif (!this._settingDisabledFromParent) {\n\t\t\tthis._disabledIsAuthorControlled = newVal;\n\t\t}\n\t}\n\n\t/**\n\t * parentRequestDisabled:\n\t * - Set by SDSRadioGroup to request disabled/enabled.\n\t * - Only applied if SDSRadio is NOT self-controlled.\n\t */\n\t@property({ type: Boolean, attribute: false })\n\tget parentRequestDisabled(): SDSRadioProps['parentRequestDisabled'] {\n\t\treturn this._parentRequestDisabled;\n\t}\n\tset parentRequestDisabled(value: SDSRadioProps['parentRequestDisabled']) {\n\t\tconst newVal = value ?? false;\n\t\tconst oldVal = this._parentRequestDisabled;\n\n\t\tif (oldVal === newVal) return;\n\n\t\tthis._parentRequestDisabled = newVal;\n\t\tthis.requestUpdate('parentRequestDisabled', oldVal);\n\n\t\tif (this._disabledIsAuthorControlled) return;\n\n\t\tthis._settingDisabledFromParent = true;\n\t\tthis.disabled = newVal;\n\t\tthis._settingDisabledFromParent = false;\n\t}\n\n\t@query('#control') control!: HTMLInputElement;\n\n\tprivate _disabled: SDSRadioProps['disabled'] = false;\n\tprivate _disabledIsAuthorControlled: boolean = false;\n\tprivate _settingDisabledFromParent: boolean = false;\n\tprivate _parentRequestDisabled: SDSRadioProps['parentRequestDisabled'] = false;\n\tprivate _initialChecked: boolean = false;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.internals = this.attachInternals();\n\t}\n\n\toverride connectedCallback() {\n\t\tsuper.connectedCallback();\n\t\tthis.internals.role = 'radio';\n\t\tif (!this._initialChecked) {\n\t\t\tthis._initialChecked = this.checked ?? false;\n\t\t}\n\t\tthis.addEventListener('keydown', this._handleKeydown);\n\t}\n\n\toverride disconnectedCallback() {\n\t\tsuper.disconnectedCallback();\n\t\tthis.removeEventListener('keydown', this._handleKeydown);\n\t}\n\n\toverride firstUpdated(_changedProperties: PropertyValues): void {\n\t\tsuper.firstUpdated(_changedProperties);\n\t\tthis._updateGroupValidation();\n\t}\n\n\toverride updated(changedProperties: Map<string | number | symbol, unknown>) {\n\t\tsuper.updated(changedProperties);\n\n\t\tif (changedProperties.has('checked')) {\n\t\t\tif (this.checked) {\n\t\t\t\tthis._uncheckSiblings();\n\t\t\t\tthis.internals.setFormValue(this.value ?? null);\n\t\t\t} else {\n\t\t\t\tthis.internals.setFormValue(null);\n\t\t\t}\n\t\t\tthis._updateGroupValidation();\n\t\t}\n\n\t\tif (changedProperties.has('required') && this.control) {\n\t\t\tthis.control.required = this.required ?? false;\n\t\t}\n\n\t\tif (!this._disabledIsAuthorControlled && this.disabled !== this._parentRequestDisabled) {\n\t\t\tthis._settingDisabledFromParent = true;\n\t\t\tthis.disabled = this._parentRequestDisabled ?? false;\n\t\t\tthis._settingDisabledFromParent = false;\n\t\t}\n\t}\n\n\tprivate _getGroupRadios(): SDSRadio[] {\n\t\tif (!this.name) return [this];\n\t\tconst root = this.getRootNode() as Document | ShadowRoot;\n\t\tconst radioGroup = Array.from(root.querySelectorAll<SDSRadio>(`sds-radio[name=\"${this.name}\"]`));\n\t\treturn radioGroup;\n\t}\n\n\tprivate _updateGroupValidation() {\n\t\tconst group: Array<SDSRadio> = this._getGroupRadios();\n\t\tconst isAnyChecked = group.some((radio) => radio.checked);\n\t\tconst isAnyRequired = group.some((radio) => radio.required);\n\t\tgroup.forEach((radio) => {\n\t\t\tif (!radio.control) return;\n\t\t\tif (isAnyRequired) {\n\t\t\t\tradio.internals.setValidity(isAnyChecked ? {} : { valueMissing: true }, isAnyChecked ? '' : radio.control.validationMessage, radio.control);\n\t\t\t} else {\n\t\t\t\tradio.internals.setValidity({});\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate readonly _handleKeydown = (event: KeyboardEvent) => {\n\t\tif (!this.name || this.disabled || this.readOnly) return;\n\n\t\tconst root = this.getRootNode() as Document | ShadowRoot;\n\t\tconst radios = Array.from(root.querySelectorAll<SDSRadio>(`sds-radio[name=\"${this.name}\"]`));\n\t\tconst currentIndex = radios.indexOf(this);\n\n\t\tif (currentIndex === -1) return;\n\n\t\tlet targetIndex: number | null = null;\n\n\t\tswitch (event.key) {\n\t\t\tcase 'ArrowUp':\n\t\t\tcase 'ArrowLeft':\n\t\t\t\ttargetIndex = currentIndex > 0 ? currentIndex - 1 : radios.length - 1;\n\t\t\t\tbreak;\n\t\t\tcase 'ArrowDown':\n\t\t\tcase 'ArrowRight':\n\t\t\t\ttargetIndex = currentIndex < radios.length - 1 ? currentIndex + 1 : 0;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\treturn;\n\t\t}\n\n\t\tconst targetRadio = radios[targetIndex];\n\t\ttargetRadio?.focus();\n\t\ttargetRadio?.click();\n\t\tevent.preventDefault();\n\t};\n\n\tformResetCallback() {\n\t\tthis.checked = this._initialChecked;\n\t\tthis.control.checked = this._initialChecked;\n\t\tthis.internals.setFormValue(this.checked ? this.value ?? 'on' : null);\n\t\tthis._updateGroupValidation();\n\t}\n\n\tprivate _uncheckSiblings() {\n\t\tif (!this.name) return;\n\t\tconst radios: Array<SDSRadio> = this._getGroupRadios();\n\n\t\tfor (const radio of radios) {\n\t\t\tif (radio !== this && radio.checked) {\n\t\t\t\tradio.checked = false;\n\t\t\t\tradio.internals.setFormValue(null);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate readonly _handleChange = (event: Event) => {\n\t\tif (this.disabled || this.readOnly) {\n\t\t\t(event.target as HTMLInputElement).checked = this.checked ?? false;\n\t\t\tevent.preventDefault();\n\t\t\treturn;\n\t\t}\n\n\t\tconst elem = event.target as HTMLInputElement;\n\t\tthis.checked = elem.checked;\n\t\tif (this.checked) {\n\t\t\tthis._uncheckSiblings();\n\t\t}\n\t\tthis._updateGroupValidation();\n\t\tthis.dispatchSheriffEvent('change');\n\t};\n\n\tprivate readonly _handleFocus = (event: Event) => {\n\t\tevent.stopImmediatePropagation();\n\t\tthis.dispatchSheriffEvent('focus');\n\t};\n\n\tprivate readonly _handleBlur = (event: Event) => {\n\t\tevent.stopImmediatePropagation();\n\t\tthis.dispatchSheriffEvent('blur');\n\t};\n\n\tget form() {\n\t\treturn this.internals.form;\n\t}\n\n\tget type(): string {\n\t\treturn 'radio';\n\t}\n\n\tget validity() {\n\t\treturn this.internals.validity;\n\t}\n\n\tget validationMessage() {\n\t\treturn this.internals.validationMessage;\n\t}\n\n\tget willValidate() {\n\t\treturn this.internals.willValidate;\n\t}\n\n\tcheckValidity(): boolean {\n\t\treturn this.internals.checkValidity();\n\t}\n\n\treportValidity(): boolean {\n\t\treturn this.internals.reportValidity();\n\t}\n\n\tsetCustomValidity(message: string): void {\n\t\tthis.internals.setValidity({ customError: !!message }, message);\n\t}\n\n\tformDisabledCallback(disabled: boolean): void {\n\t\tthis._settingDisabledFromParent = true;\n\t\tthis.disabled = disabled;\n\t\tthis._settingDisabledFromParent = false;\n\n\t\tif (this.control) this.control.disabled = disabled;\n\t}\n\n\toverride render() {\n\t\tconst radioClasses = {\n\t\t\t'sds-radio': true,\n\t\t\t'sds-radio--error': Boolean(this.error),\n\t\t};\n\n\t\tconst inputClasses = {\n\t\t\t'sds-radio__input': true,\n\t\t\t'sds-radio__input--error': Boolean(this.error),\n\t\t};\n\n\t\treturn html`\n\t\t\t<div class=\"${classMap(radioClasses)}\">\n\t\t\t\t<input\n\t\t\t\t\tid=\"control\"\n\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\tname=\"${ifDefined(this.name)}\"\n\t\t\t\t\tvalue=\"${ifDefined(this.value)}\"\n\t\t\t\t\t?checked=\"${this.checked ?? false}\"\n\t\t\t\t\t.checked=\"${this.checked ?? false}\"\n\t\t\t\t\t?disabled=\"${this.disabled ?? false}\"\n\t\t\t\t\t.disabled=\"${this.disabled ?? false}\"\n\t\t\t\t\t?required=\"${this.required}\"\n\t\t\t\t\t?readonly=\"${this.readOnly}\"\n\t\t\t\t\t@change=\"${this._handleChange}\"\n\t\t\t\t\t@focus=\"${this._handleFocus}\"\n\t\t\t\t\t@blur=\"${this._handleBlur}\"\n\t\t\t\t\tclass=\"${classMap(inputClasses)}\"\n\t\t\t\t/>\n\t\t\t\t${this.label ? html`<label class=\"sds-radio__label\" for=\"control\">${this.label}</label>` : nothing}\n\t\t\t\t${this.helpText ? html`<span class=\"sds-radio__help-text\">${this.helpText}</span>` : nothing}\n\t\t\t</div>\n\t\t`;\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'sds-radio': SDSRadio;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sds-radio.js","sourceRoot":"","sources":["../../src/sds-radio/sds-radio.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAkB,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,E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EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;qDAG7C;AAiBkB;IAAlB,KAAK,CAAC,UAAU,CAAC;yCAA4B;AA9DlC,QAAQ;IADpB,oBAAoB,CAAC,WAAW,CAAC;GACrB,QAAQ,CAsRpB","sourcesContent":["import { LitElement, PropertyValues, html, nothing } from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { guardedCustomElement } from '../utils/guarded-custom-element';\nimport { styles } from './sds-radio.styles';\nimport { SDS_SIZES } from '../types';\nimport { SDSDelegateInteractionMixin, SDSEventDispatcherMixin, SDSFormControlMixin } from '../mixins';\nimport type { SDSFormControlProps } from '../mixins/sds-form-control-mixin';\n\ntype RadioSize = Extract<SDS_SIZES, 'lg' | 'md' | 'sm'>;\n\nexport interface SDSRadioProps extends SDSFormControlProps {\n\tchecked?: boolean;\n\terror?: boolean;\n\t'help-text'?: string;\n\t'hide-label'?: boolean;\n\tlabel?: string;\n\tparentRequestDisabled?: boolean;\n\trequired?: boolean;\n\tsize?: RadioSize;\n\tvalue?: string;\n}\n\n@guardedCustomElement('sds-radio')\nexport class SDSRadio extends SDSDelegateInteractionMixin(SDSEventDispatcherMixin(SDSFormControlMixin(LitElement))) {\n\t// Styling\n\tstatic override styles = [styles];\n\n\t@property({ type: Boolean, reflect: true }) required: SDSRadioProps['required'] = false;\n\t@property({ type: String, reflect: true }) label: SDSRadioProps['label'] = '';\n\t@property({ type: Boolean, reflect: true, attribute: 'hide-label' }) hideLabel: SDSRadioProps['hide-label'] = false;\n\t@property({ type: String }) value: SDSRadioProps['value'] = 'on';\n\t@property({ type: Boolean, reflect: true }) checked: SDSRadioProps['checked'] = false;\n\t@property({ type: Boolean, reflect: true }) error: SDSRadioProps['error'] = false;\n\t@property({ type: String, reflect: true }) size: SDSRadioProps['size'] = 'md';\n\t@property({ type: String, attribute: 'help-text' }) helpText?: SDSRadioProps['help-text'];\n\n\t/**\n\t * disabled:\n\t * - If set directly (prop/attr), this radio becomes \"self-controlled\"\n\t * and ignores parentRequestDisabled.\n\t * - If not self-controlled, this follows parentRequestDisabled (group/form).\n\t*/\n\t@property({ type: Boolean })\n\toverride get disabled(): SDSRadioProps['disabled'] {\n\t\treturn this._disabled;\n\t}\n\toverride set disabled(value: SDSRadioProps['disabled']) {\n\t\tconst newVal = value ?? false;\n\t\tconst oldVal = this._disabled;\n\n\t\tif (oldVal === newVal) return;\n\n\t\tthis._disabled = newVal;\n\t\tthis.requestUpdate('disabled', oldVal);\n\n\t\tif (!this._settingDisabledFromParent) {\n\t\t\tthis._disabledIsAuthorControlled = newVal;\n\t\t}\n\t}\n\n\t/**\n\t * parentRequestDisabled:\n\t * - Set by SDSRadioGroup to request disabled/enabled.\n\t * - Only applied if SDSRadio is NOT self-controlled.\n\t */\n\t@property({ type: Boolean, attribute: false })\n\tget parentRequestDisabled(): SDSRadioProps['parentRequestDisabled'] {\n\t\treturn this._parentRequestDisabled;\n\t}\n\tset parentRequestDisabled(value: SDSRadioProps['parentRequestDisabled']) {\n\t\tconst newVal = value ?? false;\n\t\tconst oldVal = this._parentRequestDisabled;\n\n\t\tif (oldVal === newVal) return;\n\n\t\tthis._parentRequestDisabled = newVal;\n\t\tthis.requestUpdate('parentRequestDisabled', oldVal);\n\n\t\tif (this._disabledIsAuthorControlled) return;\n\n\t\tthis._settingDisabledFromParent = true;\n\t\tthis.disabled = newVal;\n\t\tthis._settingDisabledFromParent = false;\n\t}\n\n\t@query('#control') control!: HTMLInputElement;\n\n\tprivate _disabled: boolean = false;\n\tprivate _disabledIsAuthorControlled: boolean = false;\n\tprivate _settingDisabledFromParent: boolean = false;\n\tprivate _parentRequestDisabled: SDSRadioProps['parentRequestDisabled'] = false;\n\tprivate _initialChecked: boolean = false;\n\n\toverride connectedCallback() {\n\t\tsuper.connectedCallback();\n\t\tthis.internals.role = 'radio';\n\t\tif (!this._initialChecked) {\n\t\t\tthis._initialChecked = this.checked ?? false;\n\t\t}\n\t\tthis.addEventListener('keydown', this._handleKeydown);\n\t}\n\n\toverride disconnectedCallback() {\n\t\tsuper.disconnectedCallback();\n\t\tthis.removeEventListener('keydown', this._handleKeydown);\n\t}\n\n\toverride firstUpdated(_changedProperties: PropertyValues): void {\n\t\tsuper.firstUpdated(_changedProperties);\n\t\tthis._updateGroupValidation();\n\t}\n\n\toverride updated(changedProperties: Map<string | number | symbol, unknown>) {\n\t\tsuper.updated(changedProperties);\n\n\t\tif (changedProperties.has('checked')) {\n\t\t\tif (this.checked) {\n\t\t\t\tthis._uncheckSiblings();\n\t\t\t\tthis.internals.setFormValue(this.value ?? null);\n\t\t\t} else {\n\t\t\t\tthis.internals.setFormValue(null);\n\t\t\t}\n\t\t\tthis._updateGroupValidation();\n\t\t}\n\n\t\tif (changedProperties.has('required') && this.control) {\n\t\t\tthis.control.required = this.required ?? false;\n\t\t}\n\n\t\tif (!this._disabledIsAuthorControlled && this.disabled !== this._parentRequestDisabled) {\n\t\t\tthis._settingDisabledFromParent = true;\n\t\t\tthis.disabled = this._parentRequestDisabled ?? false;\n\t\t\tthis._settingDisabledFromParent = false;\n\t\t}\n\t}\n\n\tprivate _getGroupRadios(): SDSRadio[] {\n\t\tif (!this.name) return [this];\n\t\tconst root = this.getRootNode() as Document | ShadowRoot;\n\t\tconst radioGroup = Array.from(root.querySelectorAll<SDSRadio>(`sds-radio[name=\"${this.name}\"]`));\n\t\treturn radioGroup;\n\t}\n\n\tprivate _updateGroupValidation() {\n\t\tconst group: Array<SDSRadio> = this._getGroupRadios();\n\t\tconst isAnyChecked = group.some((radio) => radio.checked);\n\t\tconst isAnyRequired = group.some((radio) => radio.required);\n\t\tgroup.forEach((radio) => {\n\t\t\tif (!radio.control) return;\n\t\t\tif (isAnyRequired) {\n\t\t\t\tradio.internals.setValidity(isAnyChecked ? {} : { valueMissing: true }, isAnyChecked ? '' : radio.control.validationMessage, radio.control);\n\t\t\t} else {\n\t\t\t\tradio.internals.setValidity({});\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate readonly _handleKeydown = (event: KeyboardEvent) => {\n\t\tif (!this.name || this.disabled || this.readOnly) return;\n\n\t\tconst root = this.getRootNode() as Document | ShadowRoot;\n\t\tconst radios = Array.from(root.querySelectorAll<SDSRadio>(`sds-radio[name=\"${this.name}\"]`));\n\t\tconst currentIndex = radios.indexOf(this);\n\n\t\tif (currentIndex === -1) return;\n\n\t\tlet targetIndex: number | null = null;\n\n\t\tswitch (event.key) {\n\t\t\tcase 'ArrowUp':\n\t\t\tcase 'ArrowLeft':\n\t\t\t\ttargetIndex = currentIndex > 0 ? currentIndex - 1 : radios.length - 1;\n\t\t\t\tbreak;\n\t\t\tcase 'ArrowDown':\n\t\t\tcase 'ArrowRight':\n\t\t\t\ttargetIndex = currentIndex < radios.length - 1 ? currentIndex + 1 : 0;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\treturn;\n\t\t}\n\n\t\tconst targetRadio = radios[targetIndex];\n\t\ttargetRadio?.focus();\n\t\ttargetRadio?.click();\n\t\tevent.preventDefault();\n\t};\n\n\tformResetCallback() {\n\t\tthis.checked = this._initialChecked;\n\t\tthis.control.checked = this._initialChecked;\n\t\tthis.internals.setFormValue(this.checked ? this.value ?? 'on' : null);\n\t\tthis._updateGroupValidation();\n\t}\n\n\tprivate _uncheckSiblings() {\n\t\tif (!this.name) return;\n\t\tconst radios: Array<SDSRadio> = this._getGroupRadios();\n\n\t\tfor (const radio of radios) {\n\t\t\tif (radio !== this && radio.checked) {\n\t\t\t\tradio.checked = false;\n\t\t\t\tradio.internals.setFormValue(null);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate readonly _handleChange = (event: Event) => {\n\t\tif (this.disabled || this.readOnly) {\n\t\t\t(event.target as HTMLInputElement).checked = this.checked ?? false;\n\t\t\tevent.preventDefault();\n\t\t\treturn;\n\t\t}\n\n\t\tconst elem = event.target as HTMLInputElement;\n\t\tthis.checked = elem.checked;\n\t\tif (this.checked) {\n\t\t\tthis._uncheckSiblings();\n\t\t}\n\t\tthis._updateGroupValidation();\n\t\tthis.dispatchSheriffEvent('change');\n\t};\n\n\tprivate readonly _handleFocus = (event: Event) => {\n\t\tevent.stopImmediatePropagation();\n\t\tthis.dispatchSheriffEvent('focus');\n\t};\n\n\tprivate readonly _handleBlur = (event: Event) => {\n\t\tevent.stopImmediatePropagation();\n\t\tthis.dispatchSheriffEvent('blur');\n\t};\n\n\tget type(): string {\n\t\treturn 'radio';\n\t}\n\n\tget validity() {\n\t\treturn this.internals.validity;\n\t}\n\n\tget validationMessage() {\n\t\treturn this.internals.validationMessage;\n\t}\n\n\tget willValidate() {\n\t\treturn this.internals.willValidate;\n\t}\n\n\tcheckValidity(): boolean {\n\t\treturn this.internals.checkValidity();\n\t}\n\n\treportValidity(): boolean {\n\t\treturn this.internals.reportValidity();\n\t}\n\n\tsetCustomValidity(message: string): void {\n\t\tthis.internals.setValidity({ customError: !!message }, message);\n\t}\n\n\toverride formDisabledCallback(disabled: boolean): void {\n\t\tthis._settingDisabledFromParent = true;\n\t\tthis.disabled = disabled;\n\t\tthis._settingDisabledFromParent = false;\n\t\tif (this.control) this.control.disabled = disabled;\n\t}\n\n\toverride render() {\n\t\tconst radioClasses = {\n\t\t\t'sds-radio': true,\n\t\t\t'sds-radio--error': Boolean(this.error),\n\t\t};\n\n\t\tconst inputClasses = {\n\t\t\t'sds-radio__input': true,\n\t\t\t'sds-radio__input--error': Boolean(this.error),\n\t\t};\n\n\t\treturn html`\n\t\t\t<div class=\"${classMap(radioClasses)}\">\n\t\t\t\t<input\n\t\t\t\t\tid=\"control\"\n\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\tname=\"${ifDefined(this.name)}\"\n\t\t\t\t\tvalue=\"${ifDefined(this.value)}\"\n\t\t\t\t\t?checked=\"${this.checked ?? false}\"\n\t\t\t\t\t.checked=\"${this.checked ?? false}\"\n\t\t\t\t\t?disabled=\"${this.disabled ?? false}\"\n\t\t\t\t\t.disabled=\"${this.disabled ?? false}\"\n\t\t\t\t\t?required=\"${this.required}\"\n\t\t\t\t\t?readonly=\"${this.readOnly}\"\n\t\t\t\t\t@change=\"${this._handleChange}\"\n\t\t\t\t\t@focus=\"${this._handleFocus}\"\n\t\t\t\t\t@blur=\"${this._handleBlur}\"\n\t\t\t\t\tclass=\"${classMap(inputClasses)}\"\n\t\t\t\t/>\n\t\t\t\t${this.label ? html`<label class=\"sds-radio__label\" for=\"control\">${this.label}</label>` : nothing}\n\t\t\t\t${this.helpText ? html`<span class=\"sds-radio__help-text\">${this.helpText}</span>` : nothing}\n\t\t\t</div>\n\t\t`;\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'sds-radio': SDSRadio;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import type { SDSFormControlProps } from '../mixins/sds-form-control-mixin';
|
|
3
|
+
import { SDS_SIZES } from '../types';
|
|
4
|
+
type SelectSize = Extract<SDS_SIZES, 'lg' | 'md' | 'sm'>;
|
|
5
|
+
export interface SDSSelectProps extends SDSFormControlProps {
|
|
6
|
+
'default-value'?: string;
|
|
7
|
+
'error-message'?: string;
|
|
8
|
+
'help-text'?: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
size?: SelectSize;
|
|
12
|
+
value?: string;
|
|
13
|
+
}
|
|
14
|
+
declare const SDSSelectComponent_base: import("../mixins/types").Constructable<import("../mixins/sds-delegate-interaction-mixin").DelegateInteractionMixinInterface> & import("../mixins/types").Constructable<import("../mixins/sds-event-dispatcher-mixin").SDSEventDispatcherMixinInterface> & import("../mixins/types").Constructable<import("../mixins/sds-form-control-mixin").SDSFormControlMixinInterface> & typeof LitElement;
|
|
15
|
+
export declare class SDSSelectComponent extends SDSSelectComponent_base {
|
|
16
|
+
static styles: import("lit").CSSResult[];
|
|
17
|
+
label?: SDSSelectProps['label'];
|
|
18
|
+
value?: SDSSelectProps['value'];
|
|
19
|
+
defaultValue?: SDSSelectProps['default-value'];
|
|
20
|
+
helpText?: SDSSelectProps['help-text'];
|
|
21
|
+
errorMessage?: SDSSelectProps['error-message'];
|
|
22
|
+
required: SDSSelectProps['required'];
|
|
23
|
+
size: SDSSelectProps['size'];
|
|
24
|
+
private control;
|
|
25
|
+
private _defaultValue;
|
|
26
|
+
private _lightDomObserver?;
|
|
27
|
+
private _pendingLightDomSync;
|
|
28
|
+
connectedCallback(): void;
|
|
29
|
+
disconnectedCallback(): void;
|
|
30
|
+
firstUpdated(): void;
|
|
31
|
+
updated(changed: Map<PropertyKey, unknown>): void;
|
|
32
|
+
private _setFormValue;
|
|
33
|
+
private _scheduleLightDomSync;
|
|
34
|
+
private _startObservingLightDom;
|
|
35
|
+
private _stopObservingLightDom;
|
|
36
|
+
/**
|
|
37
|
+
* Called whenever light DOM children change (options/optgroups/hr added/removed).
|
|
38
|
+
* slotchange won't fire for in-place mutations, so we also use a MutationObserver.
|
|
39
|
+
*/
|
|
40
|
+
private readonly _handleSlotChange;
|
|
41
|
+
private updateValidity;
|
|
42
|
+
private getLightDomSelectedValue;
|
|
43
|
+
formResetCallback(): void;
|
|
44
|
+
private readonly _handleChange;
|
|
45
|
+
private readonly _handleFocus;
|
|
46
|
+
private readonly _handleBlur;
|
|
47
|
+
private readonly _handleKeyDown;
|
|
48
|
+
private renderFromLightDom;
|
|
49
|
+
private renderOption;
|
|
50
|
+
private renderOptgroup;
|
|
51
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=sds-select.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sds-select.component.d.ts","sourceRoot":"","sources":["../../src/sds-select/sds-select.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAiB,MAAM,KAAK,CAAC;AAMhD,OAAO,KAAK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O,CAAC,qBAAqB;IA0B7B,OAAO,CAAC,uBAAuB;IAoC/B,OAAO,CAAC,sBAAsB;IAM9B;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAShC;IAEF,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,wBAAwB;IAOhC,iBAAiB;IAajB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAiB5B;IAEF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAG3B;IAEF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAI1B;IAEF,OAAO,CAAC,QAAQ,CAAC,cAAc,CAS7B;IAGF,OAAO,CAAC,kBAAkB;IAkB1B,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,cAAc;IAQb,MAAM;CA2Cf"}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement, html, nothing } from 'lit';
|
|
8
|
+
import { property, query } from 'lit/decorators.js';
|
|
9
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
10
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
11
|
+
import { styles } from './sds-select.styles';
|
|
12
|
+
import { SDSDelegateInteractionMixin, SDSEventDispatcherMixin, SDSFormControlMixin } from '../mixins';
|
|
13
|
+
export class SDSSelectComponent extends SDSDelegateInteractionMixin(SDSEventDispatcherMixin(SDSFormControlMixin(LitElement))) {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.required = false;
|
|
17
|
+
this.size = 'md';
|
|
18
|
+
this._defaultValue = null;
|
|
19
|
+
this._pendingLightDomSync = false;
|
|
20
|
+
/**
|
|
21
|
+
* Called whenever light DOM children change (options/optgroups/hr added/removed).
|
|
22
|
+
* slotchange won't fire for in-place mutations, so we also use a MutationObserver.
|
|
23
|
+
*/
|
|
24
|
+
this._handleSlotChange = () => {
|
|
25
|
+
if (this.value == null) {
|
|
26
|
+
const selectedValue = this.getLightDomSelectedValue();
|
|
27
|
+
if (selectedValue != null) {
|
|
28
|
+
this.value = selectedValue;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
this._scheduleLightDomSync();
|
|
32
|
+
};
|
|
33
|
+
// Event handlers
|
|
34
|
+
this._handleChange = (event) => {
|
|
35
|
+
event.stopImmediatePropagation();
|
|
36
|
+
if (!(event.target instanceof HTMLSelectElement))
|
|
37
|
+
return;
|
|
38
|
+
if (this.disabled || this.readOnly) {
|
|
39
|
+
event.target.value = this.value ?? '';
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
this.value = event.target.value;
|
|
43
|
+
this._setFormValue(this.value);
|
|
44
|
+
this.updateValidity();
|
|
45
|
+
this.dispatchSheriffEvent('input');
|
|
46
|
+
this.dispatchSheriffEvent('change');
|
|
47
|
+
};
|
|
48
|
+
this._handleFocus = (event) => {
|
|
49
|
+
event.stopImmediatePropagation();
|
|
50
|
+
this.dispatchSheriffEvent('focus');
|
|
51
|
+
};
|
|
52
|
+
this._handleBlur = (event) => {
|
|
53
|
+
event.stopImmediatePropagation();
|
|
54
|
+
this.updateValidity();
|
|
55
|
+
this.dispatchSheriffEvent('blur');
|
|
56
|
+
};
|
|
57
|
+
this._handleKeyDown = (event) => {
|
|
58
|
+
if (!this.readOnly)
|
|
59
|
+
return;
|
|
60
|
+
const keysThatChange = new Set(['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Home', 'End', 'PageUp', 'PageDown', ' ', 'Enter']);
|
|
61
|
+
if (keysThatChange.has(event.key)) {
|
|
62
|
+
event.preventDefault();
|
|
63
|
+
event.stopImmediatePropagation();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
connectedCallback() {
|
|
68
|
+
super.connectedCallback();
|
|
69
|
+
if (this.value == null) {
|
|
70
|
+
const selected = Array.from(this.querySelectorAll('option')).find((option) => option.hasAttribute('selected') || option.defaultSelected);
|
|
71
|
+
if (selected) {
|
|
72
|
+
this.value = selected.value;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
this._startObservingLightDom();
|
|
76
|
+
}
|
|
77
|
+
disconnectedCallback() {
|
|
78
|
+
this._stopObservingLightDom();
|
|
79
|
+
super.disconnectedCallback();
|
|
80
|
+
}
|
|
81
|
+
firstUpdated() {
|
|
82
|
+
// Let the native <select> decide first (covers <option selected>)
|
|
83
|
+
const controlValue = this.control?.value ?? '';
|
|
84
|
+
// Resolution order:
|
|
85
|
+
// 1. value (controlled)
|
|
86
|
+
// 2. default-value
|
|
87
|
+
// 3. native control value
|
|
88
|
+
this.value = this.value ?? this.defaultValue ?? controlValue;
|
|
89
|
+
// Sync native control
|
|
90
|
+
this.control.value = this.value ?? '';
|
|
91
|
+
// Store default for form reset
|
|
92
|
+
this._defaultValue = this.value ?? null;
|
|
93
|
+
this.internals.setFormValue(this._defaultValue);
|
|
94
|
+
this.updateValidity();
|
|
95
|
+
}
|
|
96
|
+
updated(changed) {
|
|
97
|
+
super.updated(changed);
|
|
98
|
+
if (!this.control)
|
|
99
|
+
return;
|
|
100
|
+
if (changed.has('value')) {
|
|
101
|
+
this.control.value = this.value ?? '';
|
|
102
|
+
this._setFormValue(this.value);
|
|
103
|
+
this.updateValidity();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
_setFormValue(value) {
|
|
107
|
+
this.internals.setFormValue(value == null ? null : value);
|
|
108
|
+
}
|
|
109
|
+
_scheduleLightDomSync() {
|
|
110
|
+
if (this._pendingLightDomSync)
|
|
111
|
+
return;
|
|
112
|
+
this._pendingLightDomSync = true;
|
|
113
|
+
queueMicrotask(() => {
|
|
114
|
+
this._pendingLightDomSync = false;
|
|
115
|
+
// If light DOM indicates a selected option, treat it as source of truth.
|
|
116
|
+
const selectedFromLightDom = this.getLightDomSelectedValue();
|
|
117
|
+
if (selectedFromLightDom !== undefined && selectedFromLightDom !== this.value) {
|
|
118
|
+
this.value = selectedFromLightDom;
|
|
119
|
+
}
|
|
120
|
+
this.requestUpdate();
|
|
121
|
+
this.updateComplete.then(() => {
|
|
122
|
+
if (!this.control)
|
|
123
|
+
return;
|
|
124
|
+
this.control.value = this.value ?? '';
|
|
125
|
+
this._setFormValue(this.value);
|
|
126
|
+
this.updateValidity();
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
_startObservingLightDom() {
|
|
131
|
+
if (this._lightDomObserver)
|
|
132
|
+
return;
|
|
133
|
+
this._lightDomObserver = new MutationObserver((mutations) => {
|
|
134
|
+
for (const m of mutations) {
|
|
135
|
+
if (m.type === 'childList') {
|
|
136
|
+
this._scheduleLightDomSync();
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (m.type === 'characterData') {
|
|
140
|
+
this._scheduleLightDomSync();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (m.type === 'attributes') {
|
|
144
|
+
const target = m.target;
|
|
145
|
+
if (!(target instanceof HTMLElement))
|
|
146
|
+
continue;
|
|
147
|
+
const tag = target.tagName;
|
|
148
|
+
if (tag === 'OPTION' || tag === 'OPTGROUP' || tag === 'HR') {
|
|
149
|
+
this._scheduleLightDomSync();
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
this._lightDomObserver.observe(this, {
|
|
156
|
+
subtree: true,
|
|
157
|
+
childList: true,
|
|
158
|
+
attributes: true,
|
|
159
|
+
characterData: true,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
_stopObservingLightDom() {
|
|
163
|
+
this._lightDomObserver?.disconnect();
|
|
164
|
+
this._lightDomObserver = undefined;
|
|
165
|
+
this._pendingLightDomSync = false;
|
|
166
|
+
}
|
|
167
|
+
updateValidity() {
|
|
168
|
+
if (!this.control)
|
|
169
|
+
return;
|
|
170
|
+
if (this.control.checkValidity()) {
|
|
171
|
+
this.internals.setValidity({});
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
this.internals.setValidity({ customError: true }, this.control.validationMessage, this.control);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
getLightDomSelectedValue() {
|
|
178
|
+
// First selected option wins (matches typical native parsing behavior for single-select)
|
|
179
|
+
const selected = Array.from(this.querySelectorAll('option')).find((option) => option.hasAttribute('selected') || option.defaultSelected);
|
|
180
|
+
return selected?.value;
|
|
181
|
+
}
|
|
182
|
+
// Form-associated lifecycle
|
|
183
|
+
formResetCallback() {
|
|
184
|
+
this.internals.setFormValue(this._defaultValue);
|
|
185
|
+
const newValue = this._defaultValue ?? '';
|
|
186
|
+
if (this.control) {
|
|
187
|
+
this.control.value = newValue;
|
|
188
|
+
}
|
|
189
|
+
this.value = this._defaultValue ?? '';
|
|
190
|
+
this.updateValidity();
|
|
191
|
+
}
|
|
192
|
+
// Rendering helpers: mirror light DOM structure into the internal <select>
|
|
193
|
+
renderFromLightDom() {
|
|
194
|
+
const nodes = this.children ?? [];
|
|
195
|
+
const children = Array.from(nodes).filter((node) => node instanceof HTMLElement);
|
|
196
|
+
return children.map((node) => {
|
|
197
|
+
switch (node.tagName) {
|
|
198
|
+
case 'OPTION':
|
|
199
|
+
return this.renderOption(node);
|
|
200
|
+
case 'OPTGROUP':
|
|
201
|
+
return this.renderOptgroup(node);
|
|
202
|
+
case 'HR':
|
|
203
|
+
return html `<hr />`;
|
|
204
|
+
default:
|
|
205
|
+
return nothing;
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
renderOption(option) {
|
|
210
|
+
const attrValue = option.getAttribute('value');
|
|
211
|
+
const optionValueForSelect = option.value;
|
|
212
|
+
const isSelected = this.value != null && optionValueForSelect === this.value;
|
|
213
|
+
return html ` <option value=${ifDefined(attrValue === null ? undefined : attrValue)} ?disabled=${option.disabled} .selected=${isSelected}>${option.text}</option> `;
|
|
214
|
+
}
|
|
215
|
+
renderOptgroup(group) {
|
|
216
|
+
const options = Array.from(group.querySelectorAll('option'));
|
|
217
|
+
return html ` <optgroup label=${ifDefined(group.label || undefined)} ?disabled=${group.disabled}>${options.map((opt) => this.renderOption(opt))}</optgroup> `;
|
|
218
|
+
}
|
|
219
|
+
// Render
|
|
220
|
+
// Hidden slot: holds light DOM <option>/<optgroup>/<hr> and triggers slotchange
|
|
221
|
+
render() {
|
|
222
|
+
const selectClasses = {
|
|
223
|
+
'sds-select': true,
|
|
224
|
+
'sds-select--error': Boolean(this.errorMessage),
|
|
225
|
+
};
|
|
226
|
+
return html `
|
|
227
|
+
<div class="${classMap(selectClasses)}">
|
|
228
|
+
${this.label
|
|
229
|
+
? html ` <label for="control" class="sds-select__label"> ${this.readOnly ? html `<sds-icon name="lock-material-filled" size="m"></sds-icon>` : nothing} ${this.label} </label> `
|
|
230
|
+
: nothing}
|
|
231
|
+
${this.helpText ? html `<p class="sds-select__help-text">${this.helpText}</p>` : nothing}
|
|
232
|
+
|
|
233
|
+
<div hidden>
|
|
234
|
+
<slot @slotchange=${this._handleSlotChange}></slot>
|
|
235
|
+
</div>
|
|
236
|
+
|
|
237
|
+
<select
|
|
238
|
+
id="control"
|
|
239
|
+
class="sds-select__control"
|
|
240
|
+
name=${ifDefined(this.name)}
|
|
241
|
+
?disabled=${this.disabled}
|
|
242
|
+
?required=${this.required}
|
|
243
|
+
aria-readonly=${ifDefined(this.readOnly)}
|
|
244
|
+
aria-invalid=${this.errorMessage ? 'true' : 'false'}
|
|
245
|
+
@keydown=${this._handleKeyDown}
|
|
246
|
+
@change=${this._handleChange}
|
|
247
|
+
@focus=${this._handleFocus}
|
|
248
|
+
@blur=${this._handleBlur}
|
|
249
|
+
>
|
|
250
|
+
${this.renderFromLightDom()}
|
|
251
|
+
</select>
|
|
252
|
+
|
|
253
|
+
${this.errorMessage
|
|
254
|
+
? html `
|
|
255
|
+
<sds-alert variant="secondary" data-palette="danger">
|
|
256
|
+
<p slot="message">${this.errorMessage}</p>
|
|
257
|
+
</sds-alert>
|
|
258
|
+
`
|
|
259
|
+
: nothing}
|
|
260
|
+
</div>
|
|
261
|
+
`;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
// Styling
|
|
265
|
+
SDSSelectComponent.styles = [styles];
|
|
266
|
+
__decorate([
|
|
267
|
+
property({ type: String, reflect: true })
|
|
268
|
+
], SDSSelectComponent.prototype, "label", void 0);
|
|
269
|
+
__decorate([
|
|
270
|
+
property({ type: String, attribute: false })
|
|
271
|
+
], SDSSelectComponent.prototype, "value", void 0);
|
|
272
|
+
__decorate([
|
|
273
|
+
property({ type: String, attribute: 'default-value' })
|
|
274
|
+
], SDSSelectComponent.prototype, "defaultValue", void 0);
|
|
275
|
+
__decorate([
|
|
276
|
+
property({ type: String, attribute: 'help-text', reflect: true })
|
|
277
|
+
], SDSSelectComponent.prototype, "helpText", void 0);
|
|
278
|
+
__decorate([
|
|
279
|
+
property({ type: String, attribute: 'error-message', reflect: true })
|
|
280
|
+
], SDSSelectComponent.prototype, "errorMessage", void 0);
|
|
281
|
+
__decorate([
|
|
282
|
+
property({ type: Boolean, reflect: true })
|
|
283
|
+
], SDSSelectComponent.prototype, "required", void 0);
|
|
284
|
+
__decorate([
|
|
285
|
+
property({ type: String, reflect: true })
|
|
286
|
+
], SDSSelectComponent.prototype, "size", void 0);
|
|
287
|
+
__decorate([
|
|
288
|
+
query('#control')
|
|
289
|
+
], SDSSelectComponent.prototype, "control", void 0);
|
|
290
|
+
//# sourceMappingURL=sds-select.component.js.map
|
|
@@ -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AAC7B;IAA7C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;iDAAiC;AACtB;IAAvD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;wDAAgD;AACpC;IAAlE,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDAAwC;AACnC;IAAtE,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wDAAgD;AAC1E;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDAA8C;AAC9C;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gDAAqC;AAEpD;IAA1B,KAAK,CAAC,UAAU,CAAC;mDAAqC","sourcesContent":["import { LitElement, html, nothing } from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { styles } from './sds-select.styles';\nimport { SDSDelegateInteractionMixin, SDSEventDispatcherMixin, SDSFormControlMixin } from '../mixins';\nimport type { SDSFormControlProps } from '../mixins/sds-form-control-mixin';\nimport { SDS_SIZES } from '../types';\n\ntype SelectSize = Extract<SDS_SIZES, 'lg' | 'md' | 'sm'>;\n\nexport interface SDSSelectProps extends SDSFormControlProps {\n\t'default-value'?: string;\n\t'error-message'?: string;\n\t'help-text'?: string;\n\tlabel?: string;\n\trequired?: boolean;\n\tsize?: SelectSize;\n\tvalue?: string;\n}\n\nexport class SDSSelectComponent extends SDSDelegateInteractionMixin(SDSEventDispatcherMixin(SDSFormControlMixin(LitElement))) {\n\t// Styling\n\tstatic override styles = [styles];\n\n\t// Props\n\t@property({ type: String, reflect: true }) label?: SDSSelectProps['label'];\n\t@property({ type: String, attribute: false }) value?: SDSSelectProps['value'];\n\t@property({ type: String, attribute: 'default-value' }) defaultValue?: SDSSelectProps['default-value'];\n\t@property({ type: String, attribute: 'help-text', reflect: true }) helpText?: SDSSelectProps['help-text'];\n\t@property({ type: String, attribute: 'error-message', reflect: true }) errorMessage?: SDSSelectProps['error-message'];\n\t@property({ type: Boolean, reflect: true }) required: SDSSelectProps['required'] = false;\n\t@property({ type: String, reflect: true }) size: SDSSelectProps['size'] = 'md';\n\n\t@query('#control') private control!: HTMLSelectElement;\n\n\tprivate _defaultValue: string | null = null;\n\n\t// Observe in-place mutations to existing <option>/<optgroup> (text/attrs)\n\tprivate _lightDomObserver?: MutationObserver;\n\tprivate _pendingLightDomSync = false;\n\n\toverride connectedCallback(): void {\n\t\tsuper.connectedCallback();\n\n\t\tif (this.value == null) {\n\t\t\tconst selected = Array.from(this.querySelectorAll('option')).find((option) => option.hasAttribute('selected') || option.defaultSelected);\n\n\t\t\tif (selected) {\n\t\t\t\tthis.value = selected.value;\n\t\t\t}\n\t\t}\n\n\t\tthis._startObservingLightDom();\n\t}\n\n\toverride disconnectedCallback(): void {\n\t\tthis._stopObservingLightDom();\n\t\tsuper.disconnectedCallback();\n\t}\n\n\toverride firstUpdated() {\n\t\t// Let the native <select> decide first (covers <option selected>)\n\t\tconst controlValue = this.control?.value ?? '';\n\n\t\t// Resolution order:\n\t\t// 1. value (controlled)\n\t\t// 2. default-value\n\t\t// 3. native control value\n\t\tthis.value = this.value ?? this.defaultValue ?? controlValue;\n\n\t\t// Sync native control\n\t\tthis.control.value = this.value ?? '';\n\n\t\t// Store default for form reset\n\t\tthis._defaultValue = this.value ?? null;\n\n\t\tthis.internals.setFormValue(this._defaultValue);\n\t\tthis.updateValidity();\n\t}\n\n\toverride updated(changed: Map<PropertyKey, unknown>) {\n\t\tsuper.updated(changed);\n\n\t\tif (!this.control) return;\n\n\t\tif (changed.has('value')) {\n\t\t\tthis.control.value = this.value ?? '';\n\t\t\tthis._setFormValue(this.value);\n\t\t\tthis.updateValidity();\n\t\t}\n\t}\n\n\tprivate _setFormValue(value: string | undefined) {\n\t\tthis.internals.setFormValue(value == null ? null : value);\n\t}\n\n\tprivate _scheduleLightDomSync() {\n\t\tif (this._pendingLightDomSync) return;\n\t\tthis._pendingLightDomSync = true;\n\n\t\tqueueMicrotask(() => {\n\t\t\tthis._pendingLightDomSync = false;\n\n\t\t\t// If light DOM indicates a selected option, treat it as source of truth.\n\t\t\tconst selectedFromLightDom = this.getLightDomSelectedValue();\n\t\t\tif (selectedFromLightDom !== undefined && selectedFromLightDom !== this.value) {\n\t\t\t\tthis.value = selectedFromLightDom;\n\t\t\t}\n\n\t\t\tthis.requestUpdate();\n\n\t\t\tthis.updateComplete.then(() => {\n\t\t\t\tif (!this.control) return;\n\n\t\t\t\tthis.control.value = this.value ?? '';\n\n\t\t\t\tthis._setFormValue(this.value);\n\t\t\t\tthis.updateValidity();\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate _startObservingLightDom() {\n\t\tif (this._lightDomObserver) return;\n\n\t\tthis._lightDomObserver = new MutationObserver((mutations) => {\n\t\t\tfor (const m of mutations) {\n\t\t\t\tif (m.type === 'childList') {\n\t\t\t\t\tthis._scheduleLightDomSync();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (m.type === 'characterData') {\n\t\t\t\t\tthis._scheduleLightDomSync();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (m.type === 'attributes') {\n\t\t\t\t\tconst target = m.target;\n\t\t\t\t\tif (!(target instanceof HTMLElement)) continue;\n\n\t\t\t\t\tconst tag = target.tagName;\n\t\t\t\t\tif (tag === 'OPTION' || tag === 'OPTGROUP' || tag === 'HR') {\n\t\t\t\t\t\tthis._scheduleLightDomSync();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis._lightDomObserver.observe(this, {\n\t\t\tsubtree: true,\n\t\t\tchildList: true,\n\t\t\tattributes: true,\n\t\t\tcharacterData: true,\n\t\t});\n\t}\n\n\tprivate _stopObservingLightDom() {\n\t\tthis._lightDomObserver?.disconnect();\n\t\tthis._lightDomObserver = undefined;\n\t\tthis._pendingLightDomSync = false;\n\t}\n\n\t/**\n\t * Called whenever light DOM children change (options/optgroups/hr added/removed).\n\t * slotchange won't fire for in-place mutations, so we also use a MutationObserver.\n\t */\n\tprivate readonly _handleSlotChange = () => {\n\t\tif (this.value == null) {\n\t\t\tconst selectedValue = this.getLightDomSelectedValue();\n\t\t\tif (selectedValue != null) {\n\t\t\t\tthis.value = selectedValue;\n\t\t\t}\n\t\t}\n\n\t\tthis._scheduleLightDomSync();\n\t};\n\n\tprivate updateValidity() {\n\t\tif (!this.control) return;\n\n\t\tif (this.control.checkValidity()) {\n\t\t\tthis.internals.setValidity({});\n\t\t} else {\n\t\t\tthis.internals.setValidity({ customError: true }, this.control.validationMessage, this.control);\n\t\t}\n\t}\n\n\tprivate getLightDomSelectedValue(): string | undefined {\n\t\t// First selected option wins (matches typical native parsing behavior for single-select)\n\t\tconst selected = Array.from(this.querySelectorAll('option')).find((option) => option.hasAttribute('selected') || option.defaultSelected);\n\t\treturn selected?.value;\n\t}\n\n\t// Form-associated lifecycle\n\tformResetCallback() {\n\t\tthis.internals.setFormValue(this._defaultValue);\n\n\t\tconst newValue = this._defaultValue ?? '';\n\t\tif (this.control) {\n\t\t\tthis.control.value = newValue;\n\t\t}\n\t\tthis.value = this._defaultValue ?? '';\n\n\t\tthis.updateValidity();\n\t}\n\n\t// Event handlers\n\tprivate readonly _handleChange = (event: Event) => {\n\t\tevent.stopImmediatePropagation();\n\n\t\tif (!(event.target instanceof HTMLSelectElement)) return;\n\n\t\tif (this.disabled || this.readOnly) {\n\t\t\tevent.target.value = this.value ?? '';\n\t\t\treturn;\n\t\t}\n\n\t\tthis.value = event.target.value;\n\n\t\tthis._setFormValue(this.value);\n\t\tthis.updateValidity();\n\n\t\tthis.dispatchSheriffEvent('input');\n\t\tthis.dispatchSheriffEvent('change');\n\t};\n\n\tprivate readonly _handleFocus = (event: FocusEvent) => {\n\t\tevent.stopImmediatePropagation();\n\t\tthis.dispatchSheriffEvent('focus');\n\t};\n\n\tprivate readonly _handleBlur = (event: FocusEvent) => {\n\t\tevent.stopImmediatePropagation();\n\t\tthis.updateValidity();\n\t\tthis.dispatchSheriffEvent('blur');\n\t};\n\n\tprivate readonly _handleKeyDown = (event: KeyboardEvent) => {\n\t\tif (!this.readOnly) return;\n\n\t\tconst keysThatChange = new Set(['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Home', 'End', 'PageUp', 'PageDown', ' ', 'Enter']);\n\n\t\tif (keysThatChange.has(event.key)) {\n\t\t\tevent.preventDefault();\n\t\t\tevent.stopImmediatePropagation();\n\t\t}\n\t};\n\n\t// Rendering helpers: mirror light DOM structure into the internal <select>\n\tprivate renderFromLightDom() {\n\t\tconst nodes = this.children ?? [];\n\t\tconst children: HTMLElement[] = Array.from(nodes).filter((node): node is HTMLElement => node instanceof HTMLElement);\n\n\t\treturn children.map((node) => {\n\t\t\tswitch (node.tagName) {\n\t\t\t\tcase 'OPTION':\n\t\t\t\t\treturn this.renderOption(node as HTMLOptionElement);\n\t\t\t\tcase 'OPTGROUP':\n\t\t\t\t\treturn this.renderOptgroup(node as HTMLOptGroupElement);\n\t\t\t\tcase 'HR':\n\t\t\t\t\treturn html`<hr />`;\n\t\t\t\tdefault:\n\t\t\t\t\treturn nothing;\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate renderOption(option: HTMLOptionElement) {\n\t\tconst attrValue = option.getAttribute('value');\n\t\tconst optionValueForSelect = option.value;\n\t\tconst isSelected = this.value != null && optionValueForSelect === this.value;\n\n\t\treturn html` <option value=${ifDefined(attrValue === null ? undefined : attrValue)} ?disabled=${option.disabled} .selected=${isSelected}>${option.text}</option> `;\n\t}\n\n\tprivate renderOptgroup(group: HTMLOptGroupElement) {\n\t\tconst options = Array.from(group.querySelectorAll('option'));\n\n\t\treturn html` <optgroup label=${ifDefined(group.label || undefined)} ?disabled=${group.disabled}>${options.map((opt) => this.renderOption(opt))}</optgroup> `;\n\t}\n\n\t// Render\n\t// Hidden slot: holds light DOM <option>/<optgroup>/<hr> and triggers slotchange\n\toverride render() {\n\t\tconst selectClasses = {\n\t\t\t'sds-select': true,\n\t\t\t'sds-select--error': Boolean(this.errorMessage),\n\t\t};\n\n\t\treturn html`\n\t\t\t<div class=\"${classMap(selectClasses)}\">\n\t\t\t\t${this.label\n\t\t\t\t\t? html` <label for=\"control\" class=\"sds-select__label\"> ${this.readOnly ? html`<sds-icon name=\"lock-material-filled\" size=\"m\"></sds-icon>` : nothing} ${this.label} </label> `\n\t\t\t\t\t: nothing}\n\t\t\t\t${this.helpText ? html`<p class=\"sds-select__help-text\">${this.helpText}</p>` : nothing}\n\n\t\t\t\t<div hidden>\n\t\t\t\t\t<slot @slotchange=${this._handleSlotChange}></slot>\n\t\t\t\t</div>\n\n\t\t\t\t<select\n\t\t\t\t\tid=\"control\"\n\t\t\t\t\tclass=\"sds-select__control\"\n\t\t\t\t\tname=${ifDefined(this.name)}\n\t\t\t\t\t?disabled=${this.disabled}\n\t\t\t\t\t?required=${this.required}\n\t\t\t\t\taria-readonly=${ifDefined(this.readOnly)}\n\t\t\t\t\taria-invalid=${this.errorMessage ? 'true' : 'false'}\n\t\t\t\t\t@keydown=${this._handleKeyDown}\n\t\t\t\t\t@change=${this._handleChange}\n\t\t\t\t\t@focus=${this._handleFocus}\n\t\t\t\t\t@blur=${this._handleBlur}\n\t\t\t\t>\n\t\t\t\t\t${this.renderFromLightDom()}\n\t\t\t\t</select>\n\n\t\t\t\t${this.errorMessage\n\t\t\t\t\t? html`\n\t\t\t\t\t\t\t<sds-alert variant=\"secondary\" data-palette=\"danger\">\n\t\t\t\t\t\t\t\t<p slot=\"message\">${this.errorMessage}</p>\n\t\t\t\t\t\t\t</sds-alert>\n\t\t\t\t\t\t`\n\t\t\t\t\t: nothing}\n\t\t\t</div>\n\t\t`;\n\t}\n}\n"]}
|