@api-client/ui 0.5.24 → 0.5.26
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/.cursor/rules/lit-best-practices.mdc +12 -1
- package/.github/instructions/lit-best-practices.instructions.md +2 -0
- package/build/src/elements/navigation/internals/AppNavigationElement.d.ts.map +1 -1
- package/build/src/elements/navigation/internals/AppNavigationElement.js +1 -6
- package/build/src/elements/navigation/internals/AppNavigationElement.js.map +1 -1
- package/build/src/elements/navigation/internals/NavigationItem.d.ts +6 -0
- package/build/src/elements/navigation/internals/NavigationItem.d.ts.map +1 -1
- package/build/src/elements/navigation/internals/NavigationItem.js +26 -7
- package/build/src/elements/navigation/internals/NavigationItem.js.map +1 -1
- package/build/src/elements/navigation/internals/NavigationItem.styles.d.ts.map +1 -1
- package/build/src/elements/navigation/internals/NavigationItem.styles.js +18 -1
- package/build/src/elements/navigation/internals/NavigationItem.styles.js.map +1 -1
- package/build/src/md/dropdown-list/internals/UiDropdownList.d.ts.map +1 -1
- package/build/src/md/dropdown-list/internals/UiDropdownList.js +4 -3
- package/build/src/md/dropdown-list/internals/UiDropdownList.js.map +1 -1
- package/build/src/md/input/Input.d.ts +8 -4
- package/build/src/md/input/Input.d.ts.map +1 -1
- package/build/src/md/input/Input.js +8 -36
- package/build/src/md/input/Input.js.map +1 -1
- package/build/src/md/list/internals/List.d.ts +3 -1
- package/build/src/md/list/internals/List.d.ts.map +1 -1
- package/build/src/md/list/internals/List.js +9 -4
- package/build/src/md/list/internals/List.js.map +1 -1
- package/build/src/md/menu/internal/Menu.d.ts +8 -7
- package/build/src/md/menu/internal/Menu.d.ts.map +1 -1
- package/build/src/md/menu/internal/Menu.js +26 -29
- package/build/src/md/menu/internal/Menu.js.map +1 -1
- package/build/src/md/select/index.d.ts +4 -0
- package/build/src/md/select/index.d.ts.map +1 -0
- package/build/src/md/select/index.js +3 -0
- package/build/src/md/select/index.js.map +1 -0
- package/build/src/md/select/internals/Option.d.ts +125 -0
- package/build/src/md/select/internals/Option.d.ts.map +1 -0
- package/build/src/md/select/internals/Option.js +242 -0
- package/build/src/md/select/internals/Option.js.map +1 -0
- package/build/src/md/select/internals/Option.styles.d.ts +3 -0
- package/build/src/md/select/internals/Option.styles.d.ts.map +1 -0
- package/build/src/md/select/internals/Option.styles.js +139 -0
- package/build/src/md/select/internals/Option.styles.js.map +1 -0
- package/build/src/md/select/internals/Select.d.ts +250 -0
- package/build/src/md/select/internals/Select.d.ts.map +1 -0
- package/build/src/md/select/internals/Select.js +606 -0
- package/build/src/md/select/internals/Select.js.map +1 -0
- package/build/src/md/select/internals/Select.styles.d.ts +3 -0
- package/build/src/md/select/internals/Select.styles.d.ts.map +1 -0
- package/build/src/md/select/internals/Select.styles.js +22 -0
- package/build/src/md/select/internals/Select.styles.js.map +1 -0
- package/build/src/md/select/ui-option.d.ts +12 -0
- package/build/src/md/select/ui-option.d.ts.map +1 -0
- package/build/src/md/select/ui-option.js +29 -0
- package/build/src/md/select/ui-option.js.map +1 -0
- package/build/src/md/select/ui-select.d.ts +12 -0
- package/build/src/md/select/ui-select.d.ts.map +1 -0
- package/build/src/md/select/ui-select.js +27 -0
- package/build/src/md/select/ui-select.js.map +1 -0
- package/build/src/md/text-field/internals/TextField.d.ts.map +1 -1
- package/build/src/md/text-field/internals/TextField.js +1 -0
- package/build/src/md/text-field/internals/TextField.js.map +1 -1
- package/demo/elements/index.html +7 -4
- package/demo/elements/navigation/navigation-item.html +45 -0
- package/demo/elements/navigation/navigation-item.ts +112 -0
- package/demo/md/index.html +2 -0
- package/demo/md/inputs/input.ts +4 -0
- package/demo/md/select/index.html +16 -0
- package/demo/md/select/index.ts +202 -0
- package/package.json +1 -1
- package/src/elements/navigation/internals/AppNavigationElement.ts +1 -6
- package/src/elements/navigation/internals/NavigationItem.styles.ts +18 -1
- package/src/elements/navigation/internals/NavigationItem.ts +11 -5
- package/src/md/dropdown-list/internals/UiDropdownList.ts +4 -3
- package/src/md/input/Input.ts +8 -37
- package/src/md/list/internals/List.ts +12 -5
- package/src/md/menu/internal/Menu.ts +27 -18
- package/src/md/select/index.ts +3 -0
- package/src/md/select/internals/Option.styles.ts +139 -0
- package/src/md/select/internals/Option.ts +210 -0
- package/src/md/select/internals/Select.styles.ts +22 -0
- package/src/md/select/internals/Select.ts +534 -0
- package/src/md/select/ui-option.ts +18 -0
- package/src/md/select/ui-select.ts +17 -0
- package/src/md/text-field/internals/TextField.ts +1 -0
- package/test/md/menu/SubMenu.test.ts +2 -3
- package/test/md/select/Select.test.ts +667 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { property } from 'lit/decorators.js';
|
|
4
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
5
|
+
import UiListItem from '../../list/internals/ListItem.js';
|
|
6
|
+
import { nanoid } from 'nanoid';
|
|
7
|
+
let UiOption = (() => {
|
|
8
|
+
let _classSuper = UiListItem;
|
|
9
|
+
let _value_decorators;
|
|
10
|
+
let _value_initializers = [];
|
|
11
|
+
let _value_extraInitializers = [];
|
|
12
|
+
let _selected_decorators;
|
|
13
|
+
let _selected_initializers = [];
|
|
14
|
+
let _selected_extraInitializers = [];
|
|
15
|
+
return class UiOption extends _classSuper {
|
|
16
|
+
static {
|
|
17
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
18
|
+
_value_decorators = [property({ type: String, reflect: true })];
|
|
19
|
+
_selected_decorators = [property({ type: Boolean, reflect: true })];
|
|
20
|
+
__esDecorate(this, null, _value_decorators, { kind: "accessor", name: "value", static: false, private: false, access: { has: obj => "value" in obj, get: obj => obj.value, set: (obj, value) => { obj.value = value; } }, metadata: _metadata }, _value_initializers, _value_extraInitializers);
|
|
21
|
+
__esDecorate(this, null, _selected_decorators, { kind: "accessor", name: "selected", static: false, private: false, access: { has: obj => "selected" in obj, get: obj => obj.selected, set: (obj, value) => { obj.selected = value; } }, metadata: _metadata }, _selected_initializers, _selected_extraInitializers);
|
|
22
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
23
|
+
}
|
|
24
|
+
#value_accessor_storage = __runInitializers(this, _value_initializers, void 0);
|
|
25
|
+
/**
|
|
26
|
+
* The value associated with this option. Used to identify the option when selected.
|
|
27
|
+
* This value is what gets set on the parent select element when this option is chosen.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```html
|
|
31
|
+
* <ui-option value="apple">Apple</ui-option>
|
|
32
|
+
* <ui-option value="banana">Banana</ui-option>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
get value() { return this.#value_accessor_storage; }
|
|
36
|
+
set value(value) { this.#value_accessor_storage = value; }
|
|
37
|
+
#selected_accessor_storage = (__runInitializers(this, _value_extraInitializers), __runInitializers(this, _selected_initializers, false
|
|
38
|
+
/**
|
|
39
|
+
* Returns the text representation of this option for display purposes.
|
|
40
|
+
* This method extracts and combines text content from all child nodes,
|
|
41
|
+
* including special handling for ui-icon elements.
|
|
42
|
+
*
|
|
43
|
+
* @readonly
|
|
44
|
+
* @returns {string} The rendered text value of the option
|
|
45
|
+
* @example
|
|
46
|
+
* ```javascript
|
|
47
|
+
* const option = document.querySelector('ui-option');
|
|
48
|
+
* console.log('Option text:', option.renderValue);
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
));
|
|
52
|
+
/**
|
|
53
|
+
* Whether this option is currently selected. This is typically managed automatically
|
|
54
|
+
* by the parent select component, but can be set manually for styling purposes.
|
|
55
|
+
*
|
|
56
|
+
* @default false
|
|
57
|
+
* @example
|
|
58
|
+
* ```html
|
|
59
|
+
* <ui-option value="apple" selected>Apple</ui-option>
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
get selected() { return this.#selected_accessor_storage; }
|
|
63
|
+
set selected(value) { this.#selected_accessor_storage = value; }
|
|
64
|
+
/**
|
|
65
|
+
* Returns the text representation of this option for display purposes.
|
|
66
|
+
* This method extracts and combines text content from all child nodes,
|
|
67
|
+
* including special handling for ui-icon elements.
|
|
68
|
+
*
|
|
69
|
+
* @readonly
|
|
70
|
+
* @returns {string} The rendered text value of the option
|
|
71
|
+
* @example
|
|
72
|
+
* ```javascript
|
|
73
|
+
* const option = document.querySelector('ui-option');
|
|
74
|
+
* console.log('Option text:', option.renderValue);
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
get renderValue() {
|
|
78
|
+
const slot = this.shadowRoot?.querySelector('slot:not([name])');
|
|
79
|
+
if (!slot)
|
|
80
|
+
return this.value || '';
|
|
81
|
+
const nodes = slot.assignedNodes({ flatten: true });
|
|
82
|
+
const content = [];
|
|
83
|
+
for (const node of nodes) {
|
|
84
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
85
|
+
content.push(node.textContent || '');
|
|
86
|
+
}
|
|
87
|
+
else if (node.nodeType === Node.ELEMENT_NODE) {
|
|
88
|
+
const element = node;
|
|
89
|
+
if (element.tagName.toLowerCase() === 'ui-icon') {
|
|
90
|
+
content.push(element.getAttribute('icon') || '');
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
content.push(element.textContent || '');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return content.join(' ').trim() || this.value || '';
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Initializes the option when it's connected to the DOM. Sets up ARIA attributes
|
|
101
|
+
* and generates a unique ID if one isn't provided.
|
|
102
|
+
*
|
|
103
|
+
* @protected
|
|
104
|
+
*/
|
|
105
|
+
connectedCallback() {
|
|
106
|
+
super.connectedCallback();
|
|
107
|
+
this.setAttribute('role', 'option');
|
|
108
|
+
if (!this.id) {
|
|
109
|
+
this.id = `option-${nanoid(6)}`;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Handles property updates and triggers appropriate side effects.
|
|
114
|
+
* Currently monitors the `selected` property to update selection state.
|
|
115
|
+
*
|
|
116
|
+
* @param {PropertyValues<this>} changedProperties - Map of changed properties
|
|
117
|
+
* @protected
|
|
118
|
+
*/
|
|
119
|
+
updated(changedProperties) {
|
|
120
|
+
super.updated(changedProperties);
|
|
121
|
+
if (changedProperties.has('selected')) {
|
|
122
|
+
this.updateSelectionState();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Updates the visual and accessibility state when selection changes.
|
|
127
|
+
* Adds/removes CSS classes and ARIA attributes based on selection state.
|
|
128
|
+
*
|
|
129
|
+
* @protected
|
|
130
|
+
* @example
|
|
131
|
+
* ```javascript
|
|
132
|
+
* // This is called automatically when the selected property changes
|
|
133
|
+
* option.selected = true; // Will trigger updateSelectionState()
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
updateSelectionState() {
|
|
137
|
+
if (this.selected) {
|
|
138
|
+
this.classList.add('selected');
|
|
139
|
+
this.setAttribute('aria-selected', 'true');
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
this.classList.remove('selected');
|
|
143
|
+
this.setAttribute('aria-selected', 'false');
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Handles click events on the option. Prevents default behavior and dispatches
|
|
148
|
+
* a custom 'select' event that the parent select component can listen to.
|
|
149
|
+
*
|
|
150
|
+
* @param {MouseEvent} e - The click event
|
|
151
|
+
* @protected
|
|
152
|
+
* @fires select - Custom event with option details in event.detail
|
|
153
|
+
* @example
|
|
154
|
+
* ```javascript
|
|
155
|
+
* // Listen for option selection
|
|
156
|
+
* option.addEventListener('select', (e) => {
|
|
157
|
+
* console.log('Selected option:', e.detail.item);
|
|
158
|
+
* console.log('Selected value:', e.detail.value);
|
|
159
|
+
* });
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
handleClick(e) {
|
|
163
|
+
e.preventDefault();
|
|
164
|
+
if (this.disabled) {
|
|
165
|
+
e.stopPropagation();
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
// Let the parent handle the selection
|
|
169
|
+
this.dispatchEvent(new CustomEvent('select', {
|
|
170
|
+
detail: {
|
|
171
|
+
item: this,
|
|
172
|
+
value: this.value,
|
|
173
|
+
},
|
|
174
|
+
bubbles: true,
|
|
175
|
+
composed: true,
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Renders the option's template. Creates the main structure with focus ring,
|
|
180
|
+
* ripple effect, and content areas.
|
|
181
|
+
*
|
|
182
|
+
* @returns {TemplateResult} The rendered template
|
|
183
|
+
* @protected
|
|
184
|
+
*/
|
|
185
|
+
render() {
|
|
186
|
+
const surfaceClasses = classMap({
|
|
187
|
+
surface: true,
|
|
188
|
+
selected: this.selected,
|
|
189
|
+
});
|
|
190
|
+
return html `
|
|
191
|
+
${this.renderFocusRing()} ${this.renderRipple()}
|
|
192
|
+
<div class="${surfaceClasses}">${this.renderStart()} ${this.renderBody()} ${this.renderEnd()}</div>
|
|
193
|
+
`;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Renders the end section of the option, including the selection check icon
|
|
197
|
+
* when the option is selected.
|
|
198
|
+
*/
|
|
199
|
+
renderEnd() {
|
|
200
|
+
return html `
|
|
201
|
+
<div class="end">
|
|
202
|
+
${this.selected ? html `<ui-icon icon="check" class="selection-icon"></ui-icon>` : ''}
|
|
203
|
+
<slot name="end" @slotchange=${this.handleSlotChange}></slot>
|
|
204
|
+
<slot name="end-text" class="trailing-supporting-text"></slot>
|
|
205
|
+
</div>
|
|
206
|
+
`;
|
|
207
|
+
}
|
|
208
|
+
constructor() {
|
|
209
|
+
super(...arguments);
|
|
210
|
+
__runInitializers(this, _selected_extraInitializers);
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
})();
|
|
214
|
+
/**
|
|
215
|
+
* Material Design 3 Select Option component.
|
|
216
|
+
*
|
|
217
|
+
* The `ui-option` component represents a selectable item within a `ui-select` dropdown.
|
|
218
|
+
* It extends `UiListItem` to provide consistent styling and behavior with other list components.
|
|
219
|
+
*
|
|
220
|
+
* @slot - The option content (label, icon, etc.)
|
|
221
|
+
* @slot start - Content to display at the start of the option (icon, avatar, etc.)
|
|
222
|
+
* @slot end - Content to display at the end of the option
|
|
223
|
+
* @slot supporting-text - Supporting text below the main content
|
|
224
|
+
* @fires select - Dispatched when the option is selected. Contains `{ item: UiOption, value: string }` in detail
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* Basic option
|
|
228
|
+
* ```html
|
|
229
|
+
* <ui-option value="apple">Apple</ui-option>
|
|
230
|
+
* ```
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* Option with supporting text
|
|
234
|
+
* ```html
|
|
235
|
+
* <ui-option value="john" lines="two">
|
|
236
|
+
* John Doe
|
|
237
|
+
* <span slot="supporting-text">john@example.com</span>
|
|
238
|
+
* </ui-option>
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
export default UiOption;
|
|
242
|
+
//# sourceMappingURL=Option.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Option.js","sourceRoot":"","sources":["../../../../../src/md/select/internals/Option.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAkC,MAAM,KAAK,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,UAAU,MAAM,kCAAkC,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;;sBA6BO,UAAU;;;;;;;iBAA3B,QAAS,SAAQ,WAAU;;;iCAW7C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oCAYzC,Q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AAE,CAAA;gBACnB,OAAM;YACR,CAAC;YAED,sCAAsC;YACtC,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,QAAQ,EAAE;gBACxB,MAAM,EAAE;oBACN,IAAI,EAAE,IAAI;oBACV,KAAK,EAAE,IAAI,CAAC,KAAK;iBAClB;gBACD,OAAO,EAAE,IAAI;gBACb,QAAQ,EAAE,IAAI;aACf,CAAC,CACH,CAAA;QACH,CAAC;QAED;;;;;;WAMG;QACgB,MAAM;YACvB,MAAM,cAAc,GAAG,QAAQ,CAAC;gBAC9B,OAAO,EAAE,IAAI;gBACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACxB,CAAC,CAAA;YAEF,OAAO,IAAI,CAAA;QACP,IAAI,CAAC,eAAe,EAAE,IAAI,IAAI,CAAC,YAAY,EAAE;oBACjC,cAAc,KAAK,IAAI,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE,IAAI,IAAI,CAAC,SAAS,EAAE;KAC7F,CAAA;QACH,CAAC;QAED;;;WAGG;QACgB,SAAS;YAC1B,OAAO,IAAI,CAAA;;UAEL,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAA,yDAAyD,CAAC,CAAC,CAAC,EAAE;uCACrD,IAAI,CAAC,gBAAgB;;;KAGvD,CAAA;QACH,CAAC;;;;;;;AA1MH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAgLC","sourcesContent":["import { html, PropertyValues, TemplateResult } from 'lit'\nimport { property } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport UiListItem from '../../list/internals/ListItem.js'\nimport { nanoid } from 'nanoid'\n\n/**\n * Material Design 3 Select Option component.\n *\n * The `ui-option` component represents a selectable item within a `ui-select` dropdown.\n * It extends `UiListItem` to provide consistent styling and behavior with other list components.\n *\n * @slot - The option content (label, icon, etc.)\n * @slot start - Content to display at the start of the option (icon, avatar, etc.)\n * @slot end - Content to display at the end of the option\n * @slot supporting-text - Supporting text below the main content\n * @fires select - Dispatched when the option is selected. Contains `{ item: UiOption, value: string }` in detail\n *\n * @example\n * Basic option\n * ```html\n * <ui-option value=\"apple\">Apple</ui-option>\n * ```\n *\n * @example\n * Option with supporting text\n * ```html\n * <ui-option value=\"john\" lines=\"two\">\n * John Doe\n * <span slot=\"supporting-text\">john@example.com</span>\n * </ui-option>\n * ```\n */\nexport default class UiOption extends UiListItem {\n /**\n * The value associated with this option. Used to identify the option when selected.\n * This value is what gets set on the parent select element when this option is chosen.\n *\n * @example\n * ```html\n * <ui-option value=\"apple\">Apple</ui-option>\n * <ui-option value=\"banana\">Banana</ui-option>\n * ```\n */\n @property({ type: String, reflect: true }) accessor value: string | undefined\n\n /**\n * Whether this option is currently selected. This is typically managed automatically\n * by the parent select component, but can be set manually for styling purposes.\n *\n * @default false\n * @example\n * ```html\n * <ui-option value=\"apple\" selected>Apple</ui-option>\n * ```\n */\n @property({ type: Boolean, reflect: true }) accessor selected = false\n\n /**\n * Returns the text representation of this option for display purposes.\n * This method extracts and combines text content from all child nodes,\n * including special handling for ui-icon elements.\n *\n * @readonly\n * @returns {string} The rendered text value of the option\n * @example\n * ```javascript\n * const option = document.querySelector('ui-option');\n * console.log('Option text:', option.renderValue);\n * ```\n */\n get renderValue(): string {\n const slot = this.shadowRoot?.querySelector<HTMLSlotElement>('slot:not([name])')\n if (!slot) return this.value || ''\n const nodes = slot.assignedNodes({ flatten: true })\n const content: string[] = []\n for (const node of nodes) {\n if (node.nodeType === Node.TEXT_NODE) {\n content.push(node.textContent || '')\n } else if (node.nodeType === Node.ELEMENT_NODE) {\n const element = node as HTMLElement\n if (element.tagName.toLowerCase() === 'ui-icon') {\n content.push(element.getAttribute('icon') || '')\n } else {\n content.push(element.textContent || '')\n }\n }\n }\n return content.join(' ').trim() || this.value || ''\n }\n\n /**\n * Initializes the option when it's connected to the DOM. Sets up ARIA attributes\n * and generates a unique ID if one isn't provided.\n *\n * @protected\n */\n override connectedCallback(): void {\n super.connectedCallback()\n this.setAttribute('role', 'option')\n if (!this.id) {\n this.id = `option-${nanoid(6)}`\n }\n }\n\n /**\n * Handles property updates and triggers appropriate side effects.\n * Currently monitors the `selected` property to update selection state.\n *\n * @param {PropertyValues<this>} changedProperties - Map of changed properties\n * @protected\n */\n protected override updated(changedProperties: PropertyValues<this>): void {\n super.updated(changedProperties)\n\n if (changedProperties.has('selected')) {\n this.updateSelectionState()\n }\n }\n\n /**\n * Updates the visual and accessibility state when selection changes.\n * Adds/removes CSS classes and ARIA attributes based on selection state.\n *\n * @protected\n * @example\n * ```javascript\n * // This is called automatically when the selected property changes\n * option.selected = true; // Will trigger updateSelectionState()\n * ```\n */\n protected updateSelectionState(): void {\n if (this.selected) {\n this.classList.add('selected')\n this.setAttribute('aria-selected', 'true')\n } else {\n this.classList.remove('selected')\n this.setAttribute('aria-selected', 'false')\n }\n }\n\n /**\n * Handles click events on the option. Prevents default behavior and dispatches\n * a custom 'select' event that the parent select component can listen to.\n *\n * @param {MouseEvent} e - The click event\n * @protected\n * @fires select - Custom event with option details in event.detail\n * @example\n * ```javascript\n * // Listen for option selection\n * option.addEventListener('select', (e) => {\n * console.log('Selected option:', e.detail.item);\n * console.log('Selected value:', e.detail.value);\n * });\n * ```\n */\n override handleClick(e: MouseEvent): void {\n e.preventDefault()\n if (this.disabled) {\n e.stopPropagation()\n return\n }\n\n // Let the parent handle the selection\n this.dispatchEvent(\n new CustomEvent('select', {\n detail: {\n item: this,\n value: this.value,\n },\n bubbles: true,\n composed: true,\n })\n )\n }\n\n /**\n * Renders the option's template. Creates the main structure with focus ring,\n * ripple effect, and content areas.\n *\n * @returns {TemplateResult} The rendered template\n * @protected\n */\n protected override render(): TemplateResult {\n const surfaceClasses = classMap({\n surface: true,\n selected: this.selected,\n })\n\n return html`\n ${this.renderFocusRing()} ${this.renderRipple()}\n <div class=\"${surfaceClasses}\">${this.renderStart()} ${this.renderBody()} ${this.renderEnd()}</div>\n `\n }\n\n /**\n * Renders the end section of the option, including the selection check icon\n * when the option is selected.\n */\n protected override renderEnd(): TemplateResult {\n return html`\n <div class=\"end\">\n ${this.selected ? html`<ui-icon icon=\"check\" class=\"selection-icon\"></ui-icon>` : ''}\n <slot name=\"end\" @slotchange=${this.handleSlotChange}></slot>\n <slot name=\"end-text\" class=\"trailing-supporting-text\"></slot>\n </div>\n `\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Option.styles.d.ts","sourceRoot":"","sources":["../../../../../src/md/select/internals/Option.styles.ts"],"names":[],"mappings":";AAEA,wBAwIC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export default css `
|
|
3
|
+
:host {
|
|
4
|
+
display: block;
|
|
5
|
+
height: 56px;
|
|
6
|
+
outline: none;
|
|
7
|
+
cursor: default;
|
|
8
|
+
position: relative;
|
|
9
|
+
|
|
10
|
+
--md-focus-ring-shape-end-end: 0px;
|
|
11
|
+
--md-focus-ring-shape-end-start: 0px;
|
|
12
|
+
--md-focus-ring-shape-start-end: 0px;
|
|
13
|
+
--md-focus-ring-shape-start-start: 0px;
|
|
14
|
+
|
|
15
|
+
color: var(--md-sys-color-on-surface);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
:host([disabled]) {
|
|
19
|
+
cursor: not-allowed;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
:host([hidden]) {
|
|
23
|
+
display: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.surface {
|
|
27
|
+
height: inherit;
|
|
28
|
+
box-sizing: border-box;
|
|
29
|
+
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
overflow: hidden;
|
|
33
|
+
|
|
34
|
+
padding: 8px 16px 8px 16px;
|
|
35
|
+
gap: 12px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.surface.selected {
|
|
39
|
+
background-color: var(--md-sys-color-secondary-container);
|
|
40
|
+
color: var(--md-sys-color-on-secondary-container);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.ripple {
|
|
44
|
+
z-index: 3;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.headline {
|
|
48
|
+
font-family: var(--md-sys-typescale-body-large-font);
|
|
49
|
+
font-weight: var(--md-sys-typescale-body-large-weight);
|
|
50
|
+
font-size: var(--md-sys-typescale-body-large-size);
|
|
51
|
+
letter-spacing: var(--md-sys-typescale-body-large-tracking);
|
|
52
|
+
line-height: var(--md-sys-typescale-body-large-height);
|
|
53
|
+
|
|
54
|
+
overflow: hidden;
|
|
55
|
+
text-overflow: ellipsis;
|
|
56
|
+
white-space: nowrap;
|
|
57
|
+
|
|
58
|
+
display: flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.supporting-text {
|
|
63
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
64
|
+
|
|
65
|
+
font-family: var(--md-sys-typescale-body-medium-font);
|
|
66
|
+
font-weight: var(--md-sys-typescale-body-medium-weight);
|
|
67
|
+
font-size: var(--md-sys-typescale-body-medium-size);
|
|
68
|
+
letter-spacing: var(--md-sys-typescale-body-medium-tracking);
|
|
69
|
+
line-height: var(--md-sys-typescale-body-medium-height);
|
|
70
|
+
|
|
71
|
+
overflow: hidden;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.supporting-text ::slotted(*),
|
|
75
|
+
slot[name='end-text']::slotted(*) {
|
|
76
|
+
margin: 0;
|
|
77
|
+
padding: 0;
|
|
78
|
+
overflow: hidden;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
slot[name='end-text']::slotted(*) {
|
|
82
|
+
margin-right: 8px;
|
|
83
|
+
margin-left: 16px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
:host slot[name='end']::slotted(*) {
|
|
87
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
88
|
+
fill: var(--md-sys-color-on-surface-variant);
|
|
89
|
+
margin-left: 16px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
:host slot[name='start']::slotted(*) {
|
|
93
|
+
display: block;
|
|
94
|
+
margin-right: 16px;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
:host([image='icon']) slot[name='start']::slotted(*) {
|
|
98
|
+
width: 24px;
|
|
99
|
+
height: 24px;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
:host([image='avatar']) slot[name='start']::slotted(*) {
|
|
103
|
+
width: 40px;
|
|
104
|
+
height: 40px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
:host([image='image']) slot[name='start']::slotted(*) {
|
|
108
|
+
width: 56px;
|
|
109
|
+
height: 56px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
:host([image='video']) slot[name='start']::slotted(*) {
|
|
113
|
+
width: 114px;
|
|
114
|
+
height: 64px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.body {
|
|
118
|
+
flex: 1;
|
|
119
|
+
overflow: hidden;
|
|
120
|
+
display: flex;
|
|
121
|
+
flex-direction: column;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.end {
|
|
125
|
+
display: flex;
|
|
126
|
+
align-items: center;
|
|
127
|
+
gap: 8px;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.selection-icon {
|
|
131
|
+
color: var(--md-sys-color-on-surface);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
:host(.highlight) .surface {
|
|
135
|
+
background-color: var(--md-sys-color-tertiary-container);
|
|
136
|
+
color: var(--md-sys-color-on-tertiary-container);
|
|
137
|
+
}
|
|
138
|
+
`;
|
|
139
|
+
//# sourceMappingURL=Option.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Option.styles.js","sourceRoot":"","sources":["../../../../../src/md/select/internals/Option.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,eAAe,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwIjB,CAAA","sourcesContent":["import { css } from 'lit'\n\nexport default css`\n :host {\n display: block;\n height: 56px;\n outline: none;\n cursor: default;\n position: relative;\n\n --md-focus-ring-shape-end-end: 0px;\n --md-focus-ring-shape-end-start: 0px;\n --md-focus-ring-shape-start-end: 0px;\n --md-focus-ring-shape-start-start: 0px;\n\n color: var(--md-sys-color-on-surface);\n }\n\n :host([disabled]) {\n cursor: not-allowed;\n }\n\n :host([hidden]) {\n display: none;\n }\n\n .surface {\n height: inherit;\n box-sizing: border-box;\n\n display: flex;\n align-items: center;\n overflow: hidden;\n\n padding: 8px 16px 8px 16px;\n gap: 12px;\n }\n\n .surface.selected {\n background-color: var(--md-sys-color-secondary-container);\n color: var(--md-sys-color-on-secondary-container);\n }\n\n .ripple {\n z-index: 3;\n }\n\n .headline {\n font-family: var(--md-sys-typescale-body-large-font);\n font-weight: var(--md-sys-typescale-body-large-weight);\n font-size: var(--md-sys-typescale-body-large-size);\n letter-spacing: var(--md-sys-typescale-body-large-tracking);\n line-height: var(--md-sys-typescale-body-large-height);\n\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n\n display: flex;\n align-items: center;\n }\n\n .supporting-text {\n color: var(--md-sys-color-on-surface-variant);\n\n font-family: var(--md-sys-typescale-body-medium-font);\n font-weight: var(--md-sys-typescale-body-medium-weight);\n font-size: var(--md-sys-typescale-body-medium-size);\n letter-spacing: var(--md-sys-typescale-body-medium-tracking);\n line-height: var(--md-sys-typescale-body-medium-height);\n\n overflow: hidden;\n }\n\n .supporting-text ::slotted(*),\n slot[name='end-text']::slotted(*) {\n margin: 0;\n padding: 0;\n overflow: hidden;\n }\n\n slot[name='end-text']::slotted(*) {\n margin-right: 8px;\n margin-left: 16px;\n }\n\n :host slot[name='end']::slotted(*) {\n color: var(--md-sys-color-on-surface-variant);\n fill: var(--md-sys-color-on-surface-variant);\n margin-left: 16px;\n }\n\n :host slot[name='start']::slotted(*) {\n display: block;\n margin-right: 16px;\n }\n\n :host([image='icon']) slot[name='start']::slotted(*) {\n width: 24px;\n height: 24px;\n }\n\n :host([image='avatar']) slot[name='start']::slotted(*) {\n width: 40px;\n height: 40px;\n }\n\n :host([image='image']) slot[name='start']::slotted(*) {\n width: 56px;\n height: 56px;\n }\n\n :host([image='video']) slot[name='start']::slotted(*) {\n width: 114px;\n height: 64px;\n }\n\n .body {\n flex: 1;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n }\n\n .end {\n display: flex;\n align-items: center;\n gap: 8px;\n }\n\n .selection-icon {\n color: var(--md-sys-color-on-surface);\n }\n\n :host(.highlight) .surface {\n background-color: var(--md-sys-color-tertiary-container);\n color: var(--md-sys-color-on-tertiary-container);\n }\n`\n"]}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { LitElement, PropertyValues, TemplateResult } from 'lit';
|
|
2
|
+
import type UiOption from './Option.js';
|
|
3
|
+
import type { UiMenuElement } from '../../menu/ui-menu.js';
|
|
4
|
+
import '../../text-field/ui-outlined-text-field.js';
|
|
5
|
+
import '../../menu/ui-menu.js';
|
|
6
|
+
import '../../icons/ui-icon.js';
|
|
7
|
+
import '@material/web/focus/md-focus-ring.js';
|
|
8
|
+
export interface UiSelectChangeEvent {
|
|
9
|
+
value: string | undefined;
|
|
10
|
+
item: UiOption | null;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Material Design 3 Select component that behaves like an outlined text field with dropdown.
|
|
14
|
+
*
|
|
15
|
+
* @fires change - Dispatched when the selection changes. The event is non-bubbling and non-cancelable.
|
|
16
|
+
* The `event.detail` object contains the `value` and `item` properties.
|
|
17
|
+
* @fires open - Dispatched when the dropdown opens
|
|
18
|
+
* @fires close - Dispatched when the dropdown closes
|
|
19
|
+
*/
|
|
20
|
+
export default class UiSelect extends LitElement {
|
|
21
|
+
#private;
|
|
22
|
+
static readonly formAssociated = true;
|
|
23
|
+
/**
|
|
24
|
+
* The currently selected value. Corresponds to the `value` attribute of the selected `ui-option`.
|
|
25
|
+
* When set programmatically, it will update the selected option if a matching option exists.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```html
|
|
29
|
+
* <ui-select value="apple">
|
|
30
|
+
* <ui-option value="apple">Apple</ui-option>
|
|
31
|
+
* <ui-option value="banana">Banana</ui-option>
|
|
32
|
+
* </ui-select>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
get value(): string | undefined;
|
|
36
|
+
set value(newValue: string | undefined);
|
|
37
|
+
/**
|
|
38
|
+
* The name attribute for form submission. This value will be used as the key
|
|
39
|
+
* when the form is submitted.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```html
|
|
43
|
+
* <ui-select name="country" value="us">
|
|
44
|
+
* <ui-option value="us">United States</ui-option>
|
|
45
|
+
* </ui-select>
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
accessor name: string | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* The label text displayed in the select field. Provides accessible labeling
|
|
51
|
+
* and is shown as the floating label in the outlined text field.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```html
|
|
55
|
+
* <ui-select label="Select a country">
|
|
56
|
+
* <ui-option value="us">United States</ui-option>
|
|
57
|
+
* </ui-select>
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
accessor label: string | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Whether the select is required for form validation. When true, the select
|
|
63
|
+
* must have a value selected for the form to be valid.
|
|
64
|
+
*
|
|
65
|
+
* @default false
|
|
66
|
+
* @example
|
|
67
|
+
* ```html
|
|
68
|
+
* <ui-select required label="Required field">
|
|
69
|
+
* <ui-option value="option1">Option 1</ui-option>
|
|
70
|
+
* </ui-select>
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
accessor required: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Whether the select is in an invalid state. This is typically set automatically
|
|
76
|
+
* during validation, but can be set manually to indicate validation errors.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```html
|
|
80
|
+
* <ui-select invalid invalidText="Please select a valid option">
|
|
81
|
+
* <ui-option value="option1">Option 1</ui-option>
|
|
82
|
+
* </ui-select>
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
accessor invalid: boolean | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* The error message to display when the select is invalid. This text is shown
|
|
88
|
+
* below the select field when `invalid` is true.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```html
|
|
92
|
+
* <ui-select invalid invalidText="This field is required">
|
|
93
|
+
* <ui-option value="option1">Option 1</ui-option>
|
|
94
|
+
* </ui-select>
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
accessor invalidText: string | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Whether the select is disabled. When disabled, the select cannot be interacted
|
|
100
|
+
* with and will not receive focus or respond to user input.
|
|
101
|
+
*
|
|
102
|
+
* @default false
|
|
103
|
+
* @example
|
|
104
|
+
* ```html
|
|
105
|
+
* <ui-select disabled label="Disabled select">
|
|
106
|
+
* <ui-option value="option1">Option 1</ui-option>
|
|
107
|
+
* </ui-select>
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
accessor disabled: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Whether the dropdown menu is currently open. This property reflects the
|
|
113
|
+
* current state of the dropdown and can be set programmatically to open/close it.
|
|
114
|
+
*
|
|
115
|
+
* @default false
|
|
116
|
+
* @example
|
|
117
|
+
* ```javascript
|
|
118
|
+
* // Open the dropdown programmatically
|
|
119
|
+
* selectElement.open = true;
|
|
120
|
+
*
|
|
121
|
+
* // Close the dropdown
|
|
122
|
+
* selectElement.open = false;
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
accessor open: boolean;
|
|
126
|
+
accessor selectedOption: UiOption | null;
|
|
127
|
+
accessor ariaActiveDescendant: string | undefined;
|
|
128
|
+
accessor menu: UiMenuElement;
|
|
129
|
+
/**
|
|
130
|
+
* Returns the currently selected option element. This provides access to the
|
|
131
|
+
* full `ui-option` element, not just its value.
|
|
132
|
+
*
|
|
133
|
+
* @readonly
|
|
134
|
+
* @example
|
|
135
|
+
* ```javascript
|
|
136
|
+
* const select = document.querySelector('ui-select');
|
|
137
|
+
* const selectedItem = select.selectedItem;
|
|
138
|
+
* if (selectedItem) {
|
|
139
|
+
* console.log('Selected option:', selectedItem.textContent);
|
|
140
|
+
* }
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
get selectedItem(): UiOption | null;
|
|
144
|
+
/**
|
|
145
|
+
* Returns the text content that should be displayed in the select field.
|
|
146
|
+
* This is the rendered value of the currently selected option.
|
|
147
|
+
*
|
|
148
|
+
* @readonly
|
|
149
|
+
* @example
|
|
150
|
+
* ```javascript
|
|
151
|
+
* const select = document.querySelector('ui-select');
|
|
152
|
+
* console.log('Display text:', select.renderValue);
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
get renderValue(): string;
|
|
156
|
+
/**
|
|
157
|
+
* Returns the form element that contains this select, if any.
|
|
158
|
+
* Part of the form-associated custom element API.
|
|
159
|
+
*
|
|
160
|
+
* @readonly
|
|
161
|
+
*/
|
|
162
|
+
get form(): HTMLFormElement | null;
|
|
163
|
+
/**
|
|
164
|
+
* Returns the validity state of the select element.
|
|
165
|
+
* Part of the form-associated custom element API.
|
|
166
|
+
*
|
|
167
|
+
* @readonly
|
|
168
|
+
*/
|
|
169
|
+
get validity(): ValidityState;
|
|
170
|
+
/**
|
|
171
|
+
* Returns the validation message for the select element.
|
|
172
|
+
* Part of the form-associated custom element API.
|
|
173
|
+
*
|
|
174
|
+
* @readonly
|
|
175
|
+
*/
|
|
176
|
+
get validationMessage(): string;
|
|
177
|
+
/**
|
|
178
|
+
* Returns whether the select element will be validated when the form is submitted.
|
|
179
|
+
* Part of the form-associated custom element API.
|
|
180
|
+
*
|
|
181
|
+
* @readonly
|
|
182
|
+
*/
|
|
183
|
+
get willValidate(): boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Checks the validity of the select element and returns true if valid.
|
|
186
|
+
* Part of the form-associated custom element API.
|
|
187
|
+
*
|
|
188
|
+
* @returns {boolean} True if the element is valid, false otherwise
|
|
189
|
+
* @example
|
|
190
|
+
* ```javascript
|
|
191
|
+
* const select = document.querySelector('ui-select');
|
|
192
|
+
* if (!select.checkValidity()) {
|
|
193
|
+
* console.log('Select is invalid:', select.validationMessage);
|
|
194
|
+
* }
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
checkValidity(): boolean;
|
|
198
|
+
constructor();
|
|
199
|
+
connectedCallback(): void;
|
|
200
|
+
/**
|
|
201
|
+
* Resets the select to its initial state. Called automatically when the parent
|
|
202
|
+
* form is reset. Part of the form-associated custom element API.
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```javascript
|
|
206
|
+
* const select = document.querySelector('ui-select');
|
|
207
|
+
* select.formResetCallback(); // Clears the selection
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
formResetCallback(): void;
|
|
211
|
+
/**
|
|
212
|
+
* Restores the select's state from saved form data. Called automatically when
|
|
213
|
+
* the browser restores form state. Part of the form-associated custom element API.
|
|
214
|
+
*
|
|
215
|
+
* @param {string | null} state - The saved state to restore
|
|
216
|
+
*/
|
|
217
|
+
formStateRestoreCallback(state: string | null): void;
|
|
218
|
+
/**
|
|
219
|
+
* Validates the select element and updates its validity state. This is called
|
|
220
|
+
* automatically during property changes, but can be called manually to trigger validation.
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```javascript
|
|
224
|
+
* const select = document.querySelector('ui-select');
|
|
225
|
+
* select.validate();
|
|
226
|
+
* if (select.invalid) {
|
|
227
|
+
* console.log('Validation failed:', select.invalidText);
|
|
228
|
+
* }
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
validate(): void;
|
|
232
|
+
protected willUpdate(changedProperties: PropertyValues<this>): void;
|
|
233
|
+
protected setCurrentOption(): Promise<void>;
|
|
234
|
+
protected handleKeydown(e: KeyboardEvent): void;
|
|
235
|
+
protected handleBlur(e: FocusEvent): void;
|
|
236
|
+
protected handleClick(e: Event): void;
|
|
237
|
+
protected handleOpenChange(): Promise<void>;
|
|
238
|
+
handleSelect(e: CustomEvent<{
|
|
239
|
+
item: UiOption;
|
|
240
|
+
}>): void;
|
|
241
|
+
handleHighlightChange(e: CustomEvent<{
|
|
242
|
+
item: UiOption | null;
|
|
243
|
+
}>): void;
|
|
244
|
+
handleMenuClose(): void;
|
|
245
|
+
render(): TemplateResult;
|
|
246
|
+
protected renderInput(): TemplateResult;
|
|
247
|
+
protected renderMenu(): TemplateResult;
|
|
248
|
+
protected renderFocusRing(): TemplateResult;
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=Select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../../src/md/select/internals/Select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AAItE,OAAO,KAAK,QAAQ,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D,OAAO,4CAA4C,CAAA;AACnD,OAAO,uBAAuB,CAAA;AAC9B,OAAO,wBAAwB,CAAA;AAC/B,OAAO,sCAAsC,CAAA;AAE7C,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,IAAI,E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