@digital-realty/ix-select 1.0.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.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +91 -0
  3. package/demo/index.html +58 -0
  4. package/dist/src/IxSelect.d.ts +57 -0
  5. package/dist/src/IxSelect.js +215 -0
  6. package/dist/src/IxSelect.js.map +1 -0
  7. package/dist/src/index.d.ts +2 -0
  8. package/dist/src/index.js +3 -0
  9. package/dist/src/index.js.map +1 -0
  10. package/dist/src/ix-select.d.ts +1 -0
  11. package/dist/src/ix-select.js +3 -0
  12. package/dist/src/ix-select.js.map +1 -0
  13. package/dist/src/react/IxSelect.d.ts +4 -0
  14. package/dist/src/react/IxSelect.js +13 -0
  15. package/dist/src/react/IxSelect.js.map +1 -0
  16. package/dist/src/react/IxSelectOption.d.ts +4 -0
  17. package/dist/src/react/IxSelectOption.js +13 -0
  18. package/dist/src/react/IxSelectOption.js.map +1 -0
  19. package/dist/src/selectoption/IxSelectOption.d.ts +83 -0
  20. package/dist/src/selectoption/IxSelectOption.js +187 -0
  21. package/dist/src/selectoption/IxSelectOption.js.map +1 -0
  22. package/dist/src/selectoption/ix-select-option.d.ts +1 -0
  23. package/dist/src/selectoption/ix-select-option.js +3 -0
  24. package/dist/src/selectoption/ix-select-option.js.map +1 -0
  25. package/dist/src/selectoption/selectOptionController.d.ts +91 -0
  26. package/dist/src/selectoption/selectOptionController.js +118 -0
  27. package/dist/src/selectoption/selectOptionController.js.map +1 -0
  28. package/dist/test/ix-select.test.d.ts +1 -0
  29. package/dist/test/ix-select.test.js +58 -0
  30. package/dist/test/ix-select.test.js.map +1 -0
  31. package/dist/tsconfig.tsbuildinfo +1 -0
  32. package/package.json +97 -0
  33. package/src/IxSelect.ts +218 -0
  34. package/src/index.ts +2 -0
  35. package/src/ix-select.ts +3 -0
  36. package/src/react/IxSelect.ts +14 -0
  37. package/src/react/IxSelectOption.ts +14 -0
  38. package/src/selectoption/IxSelectOption.ts +192 -0
  39. package/src/selectoption/ix-select-option.ts +3 -0
  40. package/src/selectoption/selectOptionController.ts +179 -0
  41. package/test/ix-select.test.ts +79 -0
  42. package/tsconfig.json +21 -0
  43. package/web-dev-server.config.mjs +27 -0
  44. package/web-test-runner.config.mjs +41 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 ix-select
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # \<ix-select>
2
+
3
+ This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm i ix-select
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```html
14
+ <script type="module">
15
+ import 'ix-select/ix-select.js';
16
+ import 'ix-select/ix-select-option.js';
17
+ </script>
18
+
19
+ <ix-select>
20
+ <ix-select-option>
21
+ <div value="1">Option label</div>
22
+ </ix-select-option>
23
+ </ix-select>
24
+ ```
25
+
26
+ ```JS
27
+ import { IxSelect, IxSelectOption } from 'ix-select'
28
+
29
+ <IxSelect>
30
+ <IxSelectOption>
31
+ <div value="1">Option label</div>
32
+ </IxSelectOption>
33
+ </IxSelect>
34
+ ```
35
+
36
+ ## Linting and formatting
37
+
38
+ To scan the project for linting and formatting errors, run
39
+
40
+ ```bash
41
+ npm run lint
42
+ ```
43
+
44
+ To automatically fix linting and formatting errors, run
45
+
46
+ ```bash
47
+ npm run format
48
+ ```
49
+
50
+ ## Testing with Web Test Runner
51
+
52
+ To execute a single test run:
53
+
54
+ ```bash
55
+ npm run test
56
+ ```
57
+
58
+ To run the tests in interactive watch mode run:
59
+
60
+ ```bash
61
+ npm run test:watch
62
+ ```
63
+
64
+ ## Demoing with Storybook
65
+
66
+ To run a local instance of Storybook for your component, run
67
+
68
+ ```bash
69
+ npm run storybook
70
+ ```
71
+
72
+ To build a production version of Storybook, run
73
+
74
+ ```bash
75
+ npm run storybook:build
76
+ ```
77
+
78
+
79
+ ## Tooling configs
80
+
81
+ For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
82
+
83
+ If you customize the configuration a lot, you can consider moving them to individual files.
84
+
85
+ ## Local Demo with `web-dev-server`
86
+
87
+ ```bash
88
+ npm start
89
+ ```
90
+
91
+ To run a local development server that serves the basic demo located in `demo/index.html`
@@ -0,0 +1,58 @@
1
+ <!doctype html>
2
+ <html lang="en-GB">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <style>
6
+ body {
7
+ background: #fafafa;
8
+ }
9
+ </style>
10
+ </head>
11
+ <body>
12
+ <div id="demo"></div>
13
+
14
+ <script type="module">
15
+ import { html, render } from 'lit';
16
+ import '../dist/src/ix-select.js';
17
+
18
+ const handleSubmit = (e) => {
19
+ e.preventDefault();
20
+ }
21
+
22
+ render(
23
+ html`
24
+ <form @submit=${handleSubmit}>
25
+ <ix-select appearance="outlined" name="name" label="test" error error-text="There was an error!">
26
+ <ix-select-option aria-label="blank"></ix-select-option>
27
+ <ix-select-option value="1">
28
+ <div slot="headline">
29
+ Bye World
30
+ </div>
31
+ </ix-select-option>
32
+ <ix-select-option value="2">
33
+ <div slot="headline">
34
+ Hello World
35
+ </div>
36
+ </ix-select-option>
37
+ </ix-select>
38
+ <ix-select required appearance="outlined" name="name2" label="test" supporting-text="This is supporting text.">
39
+ <ix-select-option aria-label="blank"></ix-select-option>
40
+ <ix-select-option value="1">
41
+ <div slot="headline">
42
+ Bye World
43
+ </div>
44
+ </ix-select-option>
45
+ <ix-select-option value="2">
46
+ <div slot="headline">
47
+ Hello World
48
+ </div>
49
+ </ix-select-option>
50
+ </ix-select>
51
+ <button type="submit">Submit</button>
52
+ </form>
53
+ `,
54
+ document.querySelector('#demo')
55
+ );
56
+ </script>
57
+ </body>
58
+ </html>
@@ -0,0 +1,57 @@
1
+ import { LitElement, PropertyValues } from 'lit';
2
+ import { Select } from '@material/web/select/internal/select.js';
3
+ import '@material/web/select/filled-select.js';
4
+ import '@material/web/select/outlined-select.js';
5
+ import './selectoption/ix-select-option.js';
6
+ export declare const DEFAULT_TYPEAHEAD_BUFFER_TIME = 200;
7
+ export declare class IxSelect extends LitElement {
8
+ /** @nocollapse */
9
+ static readonly formAssociated = true;
10
+ private readonly field;
11
+ slotEl: HTMLSlotElement;
12
+ default: Select;
13
+ appearance: 'filled' | 'outlined';
14
+ label: String;
15
+ quick: boolean;
16
+ required: boolean;
17
+ disabled: boolean;
18
+ errorText: string;
19
+ supportingText: string;
20
+ error: boolean;
21
+ displayText: string;
22
+ /**
23
+ * Whether or not the underlying md-menu should be position: fixed to display
24
+ * in a top-level manner, or position: absolute.
25
+ *
26
+ * position:fixed is useful for cases where select is inside of another
27
+ * element with stacking context and hidden overflows such as `md-dialog`.
28
+ */
29
+ menuPositioning: 'absolute' | 'fixed';
30
+ /**
31
+ * The max time between the keystrokes of the typeahead select / menu behavior
32
+ * before it clears the typeahead buffer.
33
+ */
34
+ typeaheadDelay: number;
35
+ private nativeError;
36
+ private nativeErrorText;
37
+ private get hasError();
38
+ private readonly internals;
39
+ private customValidationMessage;
40
+ get form(): HTMLFormElement | null;
41
+ get labels(): NodeList;
42
+ get name(): string;
43
+ set name(name: string);
44
+ get validity(): ValidityState;
45
+ get value(): string;
46
+ get validationMessage(): string;
47
+ get materialRoot(): Select;
48
+ firstUpdated(): void;
49
+ protected updated(changed: PropertyValues<Select>): void;
50
+ render(): import("lit-html").TemplateResult<1> | undefined;
51
+ private getErrorText;
52
+ checkValidity(): boolean;
53
+ reportValidity(): boolean;
54
+ setCustomValidity(error: string): void;
55
+ private syncValidity;
56
+ private getRequiredValidationMessage;
57
+ }
@@ -0,0 +1,215 @@
1
+ import { __decorate } from "tslib";
2
+ import { html, LitElement, nothing } from 'lit';
3
+ import { property, query, state } from 'lit/decorators.js';
4
+ import '@material/web/select/filled-select.js';
5
+ import '@material/web/select/outlined-select.js';
6
+ import './selectoption/ix-select-option.js';
7
+ export const DEFAULT_TYPEAHEAD_BUFFER_TIME = 200;
8
+ export class IxSelect extends LitElement {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.appearance = 'outlined';
12
+ this.label = '';
13
+ this.quick = false;
14
+ this.required = false;
15
+ this.disabled = false;
16
+ this.errorText = '';
17
+ this.supportingText = '';
18
+ this.error = false;
19
+ this.displayText = '';
20
+ /**
21
+ * Whether or not the underlying md-menu should be position: fixed to display
22
+ * in a top-level manner, or position: absolute.
23
+ *
24
+ * position:fixed is useful for cases where select is inside of another
25
+ * element with stacking context and hidden overflows such as `md-dialog`.
26
+ */
27
+ this.menuPositioning = 'absolute';
28
+ /**
29
+ * The max time between the keystrokes of the typeahead select / menu behavior
30
+ * before it clears the typeahead buffer.
31
+ */
32
+ this.typeaheadDelay = DEFAULT_TYPEAHEAD_BUFFER_TIME;
33
+ this.nativeError = false;
34
+ this.nativeErrorText = '';
35
+ this.internals = this /* needed for closure */
36
+ .attachInternals();
37
+ this.customValidationMessage = '';
38
+ }
39
+ get hasError() {
40
+ return this.error || this.nativeError;
41
+ }
42
+ get form() {
43
+ return this.internals.form;
44
+ }
45
+ get labels() {
46
+ return this.internals.labels;
47
+ }
48
+ get name() {
49
+ var _a;
50
+ return (_a = this.getAttribute('name')) !== null && _a !== void 0 ? _a : '';
51
+ }
52
+ set name(name) {
53
+ this.setAttribute('name', name);
54
+ }
55
+ get validity() {
56
+ this.syncValidity();
57
+ return this.internals.validity;
58
+ }
59
+ get value() {
60
+ return this.materialRoot.value;
61
+ }
62
+ get validationMessage() {
63
+ this.syncValidity();
64
+ return this.internals.validationMessage;
65
+ }
66
+ get materialRoot() {
67
+ var _a, _b;
68
+ return (_b = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('md-filled-select')) !== null && _b !== void 0 ? _b : this.default;
69
+ }
70
+ firstUpdated() {
71
+ this.addEventListener('request-selection', () => {
72
+ this.internals.setFormValue(this.materialRoot.value);
73
+ });
74
+ }
75
+ updated(changed) {
76
+ if (changed.has('required')) {
77
+ this.syncValidity();
78
+ }
79
+ }
80
+ // eslint-disable-next-line consistent-return
81
+ render() {
82
+ if (this.appearance === 'outlined') {
83
+ return html ` <md-outlined-select
84
+ .aria-label=${this.ariaLabel || nothing}
85
+ .tabindex=${this.disabled ? '-1' : '0'}
86
+ .label=${this.label}
87
+ .populated=${!!this.displayText}
88
+ .disabled=${this.disabled}
89
+ .quick=${this.quick}
90
+ .menu-positioning=${this.menuPositioning}
91
+ .typeaheadDelay=${this.typeaheadDelay}
92
+ .error=${this.hasError}
93
+ .name=${this.name}
94
+ .required=${this.required}
95
+ supporting-text=${this.supportingText}
96
+ error-text=${this.getErrorText()}
97
+ >
98
+ <slot></slot>
99
+ </md-outlined-select>`;
100
+ }
101
+ if (this.appearance === 'filled') {
102
+ return html `
103
+ <md-filled-select
104
+ .aria-label=${this.ariaLabel || nothing}
105
+ .tabindex=${this.disabled ? '-1' : '0'}
106
+ .label=${this.label}
107
+ .populated=${!!this.displayText}
108
+ .disabled=${this.disabled}
109
+ .quick=${this.quick}
110
+ .positioning=${this.menuPositioning}
111
+ .typeaheadDelay=${this.typeaheadDelay}
112
+ .required=${this.required}
113
+ .error=${this.hasError}
114
+ supporting-text=${this.supportingText}
115
+ error-text=${this.getErrorText()}
116
+ >
117
+ <slot></slot>
118
+ </md-outlined-select>`;
119
+ }
120
+ }
121
+ getErrorText() {
122
+ return this.error ? this.errorText : this.nativeErrorText;
123
+ }
124
+ checkValidity() {
125
+ this.syncValidity();
126
+ return this.internals.checkValidity();
127
+ }
128
+ reportValidity() {
129
+ var _a;
130
+ let invalidEvent;
131
+ this.addEventListener('invalid', event => {
132
+ invalidEvent = event;
133
+ }, { once: true });
134
+ const valid = this.checkValidity();
135
+ if (invalidEvent === null || invalidEvent === void 0 ? void 0 : invalidEvent.defaultPrevented) {
136
+ return valid;
137
+ }
138
+ const prevMessage = this.getErrorText();
139
+ this.nativeError = !valid;
140
+ this.nativeErrorText = this.validationMessage;
141
+ if (prevMessage === this.getErrorText()) {
142
+ (_a = this.field) === null || _a === void 0 ? void 0 : _a.reannounceError();
143
+ }
144
+ return valid;
145
+ }
146
+ setCustomValidity(error) {
147
+ this.customValidationMessage = error;
148
+ this.syncValidity();
149
+ }
150
+ syncValidity() {
151
+ const valueMissing = this.required && !this.materialRoot.value;
152
+ const customError = !!this.customValidationMessage;
153
+ const validationMessage = this.customValidationMessage ||
154
+ (valueMissing && this.getRequiredValidationMessage()) ||
155
+ '';
156
+ this.internals.setValidity({ valueMissing, customError }, validationMessage);
157
+ }
158
+ // eslint-disable-next-line class-methods-use-this
159
+ getRequiredValidationMessage() {
160
+ const select = document.createElement('select');
161
+ select.required = true;
162
+ return select.validationMessage;
163
+ }
164
+ }
165
+ /** @nocollapse */
166
+ IxSelect.formAssociated = true;
167
+ __decorate([
168
+ query('.field')
169
+ ], IxSelect.prototype, "field", void 0);
170
+ __decorate([
171
+ query('slot')
172
+ ], IxSelect.prototype, "slotEl", void 0);
173
+ __decorate([
174
+ query('md-outlined-select')
175
+ ], IxSelect.prototype, "default", void 0);
176
+ __decorate([
177
+ property()
178
+ ], IxSelect.prototype, "appearance", void 0);
179
+ __decorate([
180
+ property()
181
+ ], IxSelect.prototype, "label", void 0);
182
+ __decorate([
183
+ property({ type: Boolean })
184
+ ], IxSelect.prototype, "quick", void 0);
185
+ __decorate([
186
+ property({ type: Boolean })
187
+ ], IxSelect.prototype, "required", void 0);
188
+ __decorate([
189
+ property({ type: Boolean, reflect: true })
190
+ ], IxSelect.prototype, "disabled", void 0);
191
+ __decorate([
192
+ property({ type: String, attribute: 'error-text' })
193
+ ], IxSelect.prototype, "errorText", void 0);
194
+ __decorate([
195
+ property({ type: String, attribute: 'supporting-text' })
196
+ ], IxSelect.prototype, "supportingText", void 0);
197
+ __decorate([
198
+ property({ type: Boolean, reflect: true })
199
+ ], IxSelect.prototype, "error", void 0);
200
+ __decorate([
201
+ property({ type: String, attribute: 'display-text' })
202
+ ], IxSelect.prototype, "displayText", void 0);
203
+ __decorate([
204
+ property({ attribute: 'menu-positioning' })
205
+ ], IxSelect.prototype, "menuPositioning", void 0);
206
+ __decorate([
207
+ property({ type: Number, attribute: 'typeahead-delay' })
208
+ ], IxSelect.prototype, "typeaheadDelay", void 0);
209
+ __decorate([
210
+ state()
211
+ ], IxSelect.prototype, "nativeError", void 0);
212
+ __decorate([
213
+ state()
214
+ ], IxSelect.prototype, "nativeErrorText", void 0);
215
+ //# sourceMappingURL=IxSelect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IxSelect.js","sourceRoot":"","sources":["../../src/IxSelect.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAkB,MAAM,KAAK,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAI3D,OAAO,uCAAuC,CAAC;AAC/C,OAAO,yCAAyC,CAAC;A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AA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAkB;AAER;IAApD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;2CAAgB;AAEV;IAAzD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;gDAAqB;AAElC;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uCAAe;AAEH;IAAtD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;6CAAkB;AAUxE;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;iDACO;AAOnD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;gDACV;AAEtC;IAAR,KAAK,EAAE;6CAA6B;AAE5B;IAAR,KAAK,EAAE;iDAA8B","sourcesContent":["import { html, LitElement, nothing, PropertyValues } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { Select } from '@material/web/select/internal/select.js';\nimport { Field } from '@material/web/field/internal/field';\nimport { ARIAMixinStrict } from '@material/web/internal/aria/aria.js';\nimport '@material/web/select/filled-select.js';\nimport '@material/web/select/outlined-select.js';\nimport './selectoption/ix-select-option.js';\n\nexport const DEFAULT_TYPEAHEAD_BUFFER_TIME = 200;\n\nexport class IxSelect extends LitElement {\n /** @nocollapse */\n static readonly formAssociated = true;\n\n @query('.field') private readonly field!: Field | null;\n\n @query('slot') slotEl!: HTMLSlotElement;\n\n @query('md-outlined-select') default!: Select;\n\n @property() appearance: 'filled' | 'outlined' = 'outlined';\n\n @property() label: String = '';\n\n @property({ type: Boolean }) quick = false;\n\n @property({ type: Boolean }) required = false;\n\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n @property({ type: String, attribute: 'error-text' }) errorText = '';\n\n @property({ type: String, attribute: 'supporting-text' }) supportingText = '';\n\n @property({ type: Boolean, reflect: true }) error = false;\n\n @property({ type: String, attribute: 'display-text' }) displayText = '';\n\n /**\n * Whether or not the underlying md-menu should be position: fixed to display\n * in a top-level manner, or position: absolute.\n *\n * position:fixed is useful for cases where select is inside of another\n * element with stacking context and hidden overflows such as `md-dialog`.\n */\n @property({ attribute: 'menu-positioning' })\n menuPositioning: 'absolute' | 'fixed' = 'absolute';\n\n /**\n * The max time between the keystrokes of the typeahead select / menu behavior\n * before it clears the typeahead buffer.\n */\n @property({ type: Number, attribute: 'typeahead-delay' })\n typeaheadDelay = DEFAULT_TYPEAHEAD_BUFFER_TIME;\n\n @state() private nativeError = false;\n\n @state() private nativeErrorText = '';\n\n private get hasError() {\n return this.error || this.nativeError;\n }\n\n private readonly internals = (this as HTMLElement) /* needed for closure */\n .attachInternals();\n\n private customValidationMessage = '';\n\n get form() {\n return this.internals.form;\n }\n\n get labels() {\n return this.internals.labels;\n }\n\n get name() {\n return this.getAttribute('name') ?? '';\n }\n\n set name(name: string) {\n this.setAttribute('name', name);\n }\n\n get validity() {\n this.syncValidity();\n return this.internals.validity;\n }\n\n get value() {\n return this.materialRoot.value;\n }\n\n get validationMessage() {\n this.syncValidity();\n return this.internals.validationMessage;\n }\n\n get materialRoot(): Select {\n return this.shadowRoot?.querySelector('md-filled-select') ?? this.default;\n }\n\n firstUpdated() {\n this.addEventListener('request-selection', () => {\n this.internals.setFormValue(this.materialRoot.value);\n });\n }\n\n protected override updated(changed: PropertyValues<Select>) {\n if (changed.has('required')) {\n this.syncValidity();\n }\n }\n\n // eslint-disable-next-line consistent-return\n render() {\n if (this.appearance === 'outlined') {\n return html` <md-outlined-select\n .aria-label=${(this as ARIAMixinStrict).ariaLabel || nothing}\n .tabindex=${this.disabled ? '-1' : '0'}\n .label=${this.label}\n .populated=${!!this.displayText}\n .disabled=${this.disabled}\n .quick=${this.quick}\n .menu-positioning=${this.menuPositioning}\n .typeaheadDelay=${this.typeaheadDelay}\n .error=${this.hasError}\n .name=${this.name}\n .required=${this.required}\n supporting-text=${this.supportingText}\n error-text=${this.getErrorText()}\n >\n <slot></slot>\n </md-outlined-select>`;\n }\n if (this.appearance === 'filled') {\n return html`\n <md-filled-select \n .aria-label=${(this as ARIAMixinStrict).ariaLabel || nothing}\n .tabindex=${this.disabled ? '-1' : '0'}\n .label=${this.label}\n .populated=${!!this.displayText}\n .disabled=${this.disabled}\n .quick=${this.quick}\n .positioning=${this.menuPositioning}\n .typeaheadDelay=${this.typeaheadDelay}\n .required=${this.required}\n .error=${this.hasError}\n supporting-text=${this.supportingText}\n error-text=${this.getErrorText()}\n >\n <slot></slot>\n </md-outlined-select>`;\n }\n }\n\n private getErrorText() {\n return this.error ? this.errorText : this.nativeErrorText;\n }\n\n checkValidity() {\n this.syncValidity();\n return this.internals.checkValidity();\n }\n\n reportValidity() {\n let invalidEvent: Event | undefined;\n this.addEventListener(\n 'invalid',\n event => {\n invalidEvent = event;\n },\n { once: true }\n );\n\n const valid = this.checkValidity();\n if (invalidEvent?.defaultPrevented) {\n return valid;\n }\n\n const prevMessage = this.getErrorText();\n this.nativeError = !valid;\n this.nativeErrorText = this.validationMessage;\n\n if (prevMessage === this.getErrorText()) {\n this.field?.reannounceError();\n }\n\n return valid;\n }\n\n setCustomValidity(error: string) {\n this.customValidationMessage = error;\n this.syncValidity();\n }\n\n private syncValidity() {\n const valueMissing = this.required && !this.materialRoot.value;\n const customError = !!this.customValidationMessage;\n const validationMessage =\n this.customValidationMessage ||\n (valueMissing && this.getRequiredValidationMessage()) ||\n '';\n\n this.internals.setValidity(\n { valueMissing, customError },\n validationMessage\n );\n }\n\n // eslint-disable-next-line class-methods-use-this\n private getRequiredValidationMessage() {\n const select = document.createElement('select');\n select.required = true;\n return select.validationMessage;\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export { IxSelect } from './IxSelect.js';
2
+ export { IxSelectOption } from './selectoption/IxSelectOption.js';
@@ -0,0 +1,3 @@
1
+ export { IxSelect } from './IxSelect.js';
2
+ export { IxSelectOption } from './selectoption/IxSelectOption.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC","sourcesContent":["export { IxSelect } from './IxSelect.js';\nexport { IxSelectOption } from './selectoption/IxSelectOption.js';\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { IxSelect } from './IxSelect.js';
2
+ window.customElements.define('ix-select', IxSelect);
3
+ //# sourceMappingURL=ix-select.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ix-select.js","sourceRoot":"","sources":["../../src/ix-select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["import { IxSelect } from './IxSelect.js';\n\nwindow.customElements.define('ix-select', IxSelect);\n"]}
@@ -0,0 +1,4 @@
1
+ import { IxSelect as IxSelectLit } from '../IxSelect.js';
2
+ export declare const IxSelect: import("@lit-labs/react").ReactWebComponent<IxSelectLit, {
3
+ onclick: string;
4
+ }>;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { createComponent } from '@lit-labs/react';
3
+ import { IxSelect as IxSelectLit } from '../IxSelect.js';
4
+ window.customElements.define('ix-select', IxSelectLit);
5
+ export const IxSelect = createComponent({
6
+ tagName: 'ix-select',
7
+ elementClass: IxSelectLit,
8
+ react: React,
9
+ events: {
10
+ onclick: 'onClick',
11
+ },
12
+ });
13
+ //# sourceMappingURL=IxSelect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IxSelect.js","sourceRoot":"","sources":["../../../src/react/IxSelect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,QAAQ,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEzD,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAEvD,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAe,CAAC;IACtC,OAAO,EAAE,WAAW;IACpB,YAAY,EAAE,WAAW;IACzB,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE;QACN,OAAO,EAAE,SAAS;KACnB;CACF,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { createComponent } from '@lit-labs/react';\nimport { IxSelect as IxSelectLit } from '../IxSelect.js';\n\nwindow.customElements.define('ix-select', IxSelectLit);\n\nexport const IxSelect = createComponent({\n tagName: 'ix-select',\n elementClass: IxSelectLit,\n react: React,\n events: {\n onclick: 'onClick',\n },\n});\n"]}
@@ -0,0 +1,4 @@
1
+ import { IxSelectOption as IxSelectOptionLit } from '../selectoption/IxSelectOption.js';
2
+ export declare const IxSelectOption: import("@lit-labs/react").ReactWebComponent<IxSelectOptionLit, {
3
+ onclick: string;
4
+ }>;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { createComponent } from '@lit-labs/react';
3
+ import { IxSelectOption as IxSelectOptionLit } from '../selectoption/IxSelectOption.js';
4
+ window.customElements.define('ix-select', IxSelectOptionLit);
5
+ export const IxSelectOption = createComponent({
6
+ tagName: 'ix-select',
7
+ elementClass: IxSelectOptionLit,
8
+ react: React,
9
+ events: {
10
+ onclick: 'onClick',
11
+ },
12
+ });
13
+ //# sourceMappingURL=IxSelectOption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IxSelectOption.js","sourceRoot":"","sources":["../../../src/react/IxSelectOption.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,cAAc,IAAI,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAExF,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;AAE7D,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;IAC5C,OAAO,EAAE,WAAW;IACpB,YAAY,EAAE,iBAAiB;IAC/B,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE;QACN,OAAO,EAAE,SAAS;KACnB;CACF,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { createComponent } from '@lit-labs/react';\nimport { IxSelectOption as IxSelectOptionLit } from '../selectoption/IxSelectOption.js';\n\nwindow.customElements.define('ix-select', IxSelectOptionLit);\n\nexport const IxSelectOption = createComponent({\n tagName: 'ix-select',\n elementClass: IxSelectOptionLit,\n react: React,\n events: {\n onclick: 'onClick',\n },\n});\n"]}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import '@material/web/ripple/ripple.js';
7
+ import '@material/web/focus/md-focus-ring.js';
8
+ import '@material/web/labs/item/item.js';
9
+ import { LitElement } from 'lit';
10
+ import { ClassInfo } from 'lit/directives/class-map.js';
11
+ import { SelectOption } from './selectOptionController.js';
12
+ /**
13
+ * @fires close-menu Closes the encapsulating menu on
14
+ * @fires request-selection Requests the parent md-select to select this element
15
+ * (and deselect others if single-selection) when `selected` changed to `true`.
16
+ * @fires request-deselection Requests the parent md-select to deselect this
17
+ * element when `selected` changed to `false`.
18
+ */
19
+ export declare class IxSelectOption extends LitElement implements SelectOption {
20
+ /** @nocollapse */
21
+ static shadowRootOptions: {
22
+ delegatesFocus: boolean;
23
+ mode: ShadowRootMode;
24
+ slotAssignment?: SlotAssignmentMode | undefined;
25
+ customElements?: CustomElementRegistry | undefined;
26
+ };
27
+ /**
28
+ * Disables the item and makes it non-selectable and non-interactive.
29
+ */
30
+ disabled: boolean;
31
+ /**
32
+ * READONLY: self-identifies as a menu item and sets its identifying attribute
33
+ */
34
+ isMenuItem: boolean;
35
+ /**
36
+ * Sets the item in the selected visual state when a submenu is opened.
37
+ */
38
+ selected: boolean;
39
+ /**
40
+ * Form value of the option.
41
+ */
42
+ value: string;
43
+ protected readonly listItemRoot: HTMLElement | null;
44
+ protected readonly headlineElements: HTMLElement[];
45
+ type: "option";
46
+ /**
47
+ * The text that is selectable via typeahead. If not set, defaults to the
48
+ * innerText of the item slotted into the `"headline"` slot.
49
+ */
50
+ get typeaheadText(): string;
51
+ set typeaheadText(text: string);
52
+ /**
53
+ * The text that is displayed in the select field when selected. If not set,
54
+ * defaults to the textContent of the item slotted into the `"headline"` slot.
55
+ */
56
+ get displayText(): string;
57
+ set displayText(text: string);
58
+ private readonly selectOptionController;
59
+ protected render(): import("lit-html").TemplateResult<1>;
60
+ /**
61
+ * Renders the root list item.
62
+ *
63
+ * @param content the child content of the list item.
64
+ */
65
+ protected renderListItem(content: unknown): import("lit-html").TemplateResult<1>;
66
+ /**
67
+ * Handles rendering of the ripple element.
68
+ */
69
+ protected renderRipple(): import("lit-html").TemplateResult<1>;
70
+ /**
71
+ * Handles rendering of the focus ring.
72
+ */
73
+ protected renderFocusRing(): import("lit-html").TemplateResult<1>;
74
+ /**
75
+ * Classes applied to the list item root.
76
+ */
77
+ protected getRenderClasses(): ClassInfo;
78
+ /**
79
+ * Handles rendering the headline and supporting text.
80
+ */
81
+ protected renderBody(): import("lit-html").TemplateResult<1>;
82
+ focus(): void;
83
+ }