@c2n/select 0.0.6

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Nguyen Thai Vinh
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,15 @@
1
+ # @c2n/select
2
+
3
+ `c2-select` is a dropdown: a themeable trigger button plus a popover holding a `c2-list` of `c2-list-item` options.
4
+
5
+ ```html
6
+ <c2-select placeholder="Select a country" value="FR">
7
+ <c2-list-item value="US">United States</c2-list-item>
8
+ <c2-list-item value="FR">France</c2-list-item>
9
+ </c2-select>
10
+ ```
11
+
12
+ - The options are the `c2-list-item` children (`value`, optional `label` for a short trigger text, `disabled`).
13
+ - `multiple`, `required`, `disabled`, `readonly`, `fit-size`, `open`.
14
+ - `selection-change` fires with `detail.value` (array of selected values) and `detail.data`.
15
+ - Theming: `--c2-select__button--*` (trigger), `--c2-select__list--*` (dropdown), `--c2-list-item--*` (options). See the docs site for the full list.
package/dist/select.js ADDED
@@ -0,0 +1,182 @@
1
+ import { LitElement, html, svg, unsafeCSS } from "lit";
2
+ import { customElement, property, query, state } from "lit/decorators.js";
3
+ import { classMap } from "lit/directives/class-map.js";
4
+ import { ListItem } from "@c2n/list-item";
5
+ import { arrayPropertyConverter } from "@c2n/core/lit-helper.js";
6
+ import { redispatchEvent } from "@c2n/core/dom-helper.js";
7
+ import "@c2n/overlay";
8
+ import "@c2n/list";
9
+ //#region src/select.scss?inline
10
+ var select_default = "/* ex : var((width: 24px), width, c2-checkbox) returns var(--c2-checkbox-width, 24px) */\n:host {\n display: inline-flex;\n vertical-align: middle;\n}\n\n:host([hidden]) {\n display: none;\n}\n\n.c2-select {\n display: contents;\n}\n\n.button {\n display: flex;\n flex: 1;\n position: relative;\n box-sizing: border-box;\n width: 100%;\n min-width: 100%;\n max-width: 100%;\n min-height: var(--c2-select__button--min-height,36px);\n margin: 0;\n align-items: center;\n justify-content: space-between;\n appearance: none;\n user-select: none;\n cursor: pointer;\n text-transform: none;\n vertical-align: middle;\n outline: none;\n font-size: var(--c2-select__button--font-size,14px);\n font-weight: var(--c2-select__button--font-weight);\n font-style: var(--c2-select__button--font-style,normal);\n font-family: var(--c2-select__button--font-family);\n line-height: 1.4;\n background: var(--c2-select__button--background,#ffffff);\n gap: var(--c2-select__button--gap,8px);\n border-top: var(--c2-select__button--border-top,1px solid #bcbcc6);\n border-bottom: var(--c2-select__button--border-bottom,1px solid #bcbcc6);\n border-right: var(--c2-select__button--border-right,1px solid #bcbcc6);\n border-left: var(--c2-select__button--border-left,1px solid #bcbcc6);\n color: var(--c2-select__button--color,#18181b);\n padding: var(--c2-select__button--padding,6px 10px 6px 12px);\n border-top-left-radius: var(--c2-select__button--border-top-left-radius,6px);\n border-top-right-radius: var(--c2-select__button--border-top-right-radius,6px);\n border-bottom-left-radius: var(--c2-select__button--border-bottom-left-radius,6px);\n border-bottom-right-radius: var(--c2-select__button--border-bottom-right-radius,6px);\n will-change: background, color, border;\n transition: background 250ms cubic-bezier(0.2, 0, 0, 1), color 250ms cubic-bezier(0.2, 0, 0, 1), border 250ms cubic-bezier(0.2, 0, 0, 1);\n}\n.button:hover {\n border-top: var(--c2-select__button__hover--border-top,1px solid #a1a1aa);\n border-bottom: var(--c2-select__button__hover--border-bottom,1px solid #a1a1aa);\n border-right: var(--c2-select__button__hover--border-right,1px solid #a1a1aa);\n border-left: var(--c2-select__button__hover--border-left,1px solid #a1a1aa);\n background: var(--c2-select__button__hover--background,#fafafa);\n color: var(--c2-select__button__hover--color,#18181b);\n}\n.button:focus-visible {\n outline: var(--c2-select__button__focus--outline,2px solid rgba(71, 110, 249, 0.4));\n outline-offset: var(--c2-select__button__focus--outline-offset,1px);\n}\n.button:disabled {\n cursor: default;\n pointer-events: none;\n opacity: var(--c2-select__button__disabled--opacity,0.38);\n}\n.button ::slotted([slot=button-prefix-icon]) {\n flex: none;\n width: var(--c2-select__button__prefix-icon--width,16px);\n height: var(--c2-select__button__prefix-icon--height,16px);\n color: var(--c2-select__button__prefix-icon--color);\n --c2-feather-icon--size: var(--c2-select__button__prefix-icon--width,16px);\n --c2-mat-icon--font-size: var(--c2-select__button__prefix-icon--width,16px);\n}\n.button ::slotted([slot=button-suffix-icon]),\n.button .default-icon {\n flex: none;\n width: var(--c2-select__button__suffix-icon--width,16px);\n height: var(--c2-select__button__suffix-icon--height,16px);\n color: var(--c2-select__button__suffix-icon--color,#71717a);\n --c2-feather-icon--size: var(--c2-select__button__suffix-icon--width,16px);\n --c2-mat-icon--font-size: var(--c2-select__button__suffix-icon--width,16px);\n}\n.button .default-icon {\n transition: transform 250ms cubic-bezier(0.2, 0, 0, 1);\n}\n.button .placeholder {\n font-weight: var(--c2-select__placeholder--font-weight);\n font-style: var(--c2-select__placeholder--font-style);\n color: var(--c2-select__placeholder--color,#71717a);\n opacity: var(--c2-select__placeholder--opacity,1);\n}\n.button .button-content {\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n text-align: start;\n flex: 1;\n min-width: 0;\n}\n\n:host([open]) .button {\n border-top: var(--c2-select__button__open--border-top,1px solid #476ef9);\n border-bottom: var(--c2-select__button__open--border-bottom,1px solid #476ef9);\n border-right: var(--c2-select__button__open--border-right,1px solid #476ef9);\n border-left: var(--c2-select__button__open--border-left,1px solid #476ef9);\n}\n:host([open]) .button .default-icon {\n transform: rotate(180deg);\n}\n\n:host([readonly]) .button {\n cursor: default;\n}\n\n.list {\n --c2-list--background: var(--c2-select__list--background,#ffffff);\n --c2-list--border-top: var(--c2-select__list--border-top,1px solid #e4e4e7);\n --c2-list--border-right: var(--c2-select__list--border-right,1px solid #e4e4e7);\n --c2-list--border-bottom: var(--c2-select__list--border-bottom,1px solid #e4e4e7);\n --c2-list--border-left: var(--c2-select__list--border-left,1px solid #e4e4e7);\n --c2-list--border-top-left-radius: var(--c2-select__list--border-top-left-radius,8px);\n --c2-list--border-top-right-radius: var(--c2-select__list--border-top-right-radius,8px);\n --c2-list--border-bottom-left-radius: var(--c2-select__list--border-bottom-left-radius,8px);\n --c2-list--border-bottom-right-radius: var(--c2-select__list--border-bottom-right-radius,8px);\n --c2-list--box-shadow: var(--c2-select__list--box-shadow,0 8px 24px rgba(24, 24, 27, 0.08));\n --c2-list--padding-top: var(--c2-select__list--padding-top,4px);\n --c2-list--padding-right: var(--c2-select__list--padding-right,4px);\n --c2-list--padding-bottom: var(--c2-select__list--padding-bottom,4px);\n --c2-list--padding-left: var(--c2-select__list--padding-left,4px);\n --c2-list--max-height: var(--c2-select__list--max-height,280px);\n}";
11
+ //#endregion
12
+ //#region \0@oxc-project+runtime@0.148.0/helpers/esm/decorate.js
13
+ function __decorate(decorators, target, key, desc) {
14
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
15
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
16
+ 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;
17
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
18
+ }
19
+ //#endregion
20
+ //#region src/select.ts
21
+ var Select = class Select extends LitElement {
22
+ constructor(..._args) {
23
+ super(..._args);
24
+ this.open = false;
25
+ this.readonly = false;
26
+ this.disabled = false;
27
+ this.focused = false;
28
+ this.fitSize = false;
29
+ this.placeholder = "";
30
+ this.multiple = false;
31
+ this.required = false;
32
+ this.value = [];
33
+ this.displayText = "";
34
+ this.data = [];
35
+ this.onKeydown = (event) => {
36
+ this.focused = true;
37
+ if (event.code !== "ArrowDown" && event.code !== "ArrowUp") return;
38
+ event.preventDefault();
39
+ this.toggle(true);
40
+ };
41
+ }
42
+ static {
43
+ this.styles = unsafeCSS(select_default);
44
+ }
45
+ static {
46
+ this.shadowRootOptions = {
47
+ ...LitElement.shadowRootOptions,
48
+ delegatesFocus: true
49
+ };
50
+ }
51
+ onButtonBlur() {
52
+ this.focused = false;
53
+ this.button.removeEventListener("keydown", this.onKeydown);
54
+ }
55
+ toggle(value) {
56
+ if (this.readonly) return;
57
+ if (typeof value == "undefined") {
58
+ this.menu.togglePopover();
59
+ return;
60
+ }
61
+ if (value && !this.menu.matches(":popover-open")) return this.menu.showPopover();
62
+ if (value == false && this.menu.matches(":popover-open")) return this.menu.hidePopover();
63
+ }
64
+ onButtonFocus() {
65
+ this.button.addEventListener("keydown", this.onKeydown);
66
+ }
67
+ prepareGetDisplayText() {
68
+ const updates = [new Promise((res) => requestAnimationFrame(() => res(true)))];
69
+ if (this.listItemSlot) for (const slotItem of this.listItemSlot.assignedElements({ flatten: true })) {
70
+ const listItem = slotItem instanceof ListItem ? slotItem : slotItem.firstChild;
71
+ if (listItem instanceof ListItem && this.value.includes(listItem.value)) updates.push(listItem.updateComplete);
72
+ }
73
+ this.childItemsUpdated = Promise.all(updates);
74
+ }
75
+ async updateDisplayText() {
76
+ this.prepareGetDisplayText();
77
+ await this.updateComplete;
78
+ const displayText = [];
79
+ if (this.listItemSlot) for (const slotItem of this.listItemSlot.assignedElements({ flatten: true })) {
80
+ const listItem = slotItem instanceof ListItem ? slotItem : slotItem.firstChild;
81
+ if (listItem instanceof ListItem && this.value.includes(listItem.value)) displayText.push(listItem.displayText);
82
+ }
83
+ this.displayText = displayText.join(", ");
84
+ }
85
+ renderButtonContent() {
86
+ const buttonContentClasses = { placeholder: !this.displayText };
87
+ return html`<div class="button-content ${classMap(buttonContentClasses)}">${this.displayText || this.placeholder}</div>`;
88
+ }
89
+ renderButtonSuffixIcon() {
90
+ return svg`<svg class="default-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"></path></svg>`;
91
+ }
92
+ handleSelectionChange(event) {
93
+ this.value = event.detail.value;
94
+ this.data = event.detail.data;
95
+ if (!this.multiple) this.toggle(false);
96
+ redispatchEvent(this, event);
97
+ }
98
+ handleOverlayToggle(event) {
99
+ const toggleEvent = event;
100
+ this.open = toggleEvent.newState == "open";
101
+ }
102
+ willUpdate(changedProperties) {
103
+ if (changedProperties.has("value") && typeof this.value === "string") this.value = arrayPropertyConverter.fromAttribute(this.value);
104
+ }
105
+ updated(_changedProperties) {
106
+ if (_changedProperties.has("open")) this.toggle(this.open);
107
+ if (_changedProperties.has("value")) this.updateDisplayText();
108
+ }
109
+ async getUpdateComplete() {
110
+ const complete = await super.getUpdateComplete();
111
+ await this.childItemsUpdated;
112
+ return complete;
113
+ }
114
+ handleSlotChange() {
115
+ this.updateDisplayText();
116
+ }
117
+ render() {
118
+ return html`<div class="c2-select">
119
+ <button
120
+ type="button"
121
+ aria-haspopup="listbox"
122
+ aria-expanded=${this.open ? "true" : "false"}
123
+ id="button"
124
+ popovertarget="menu-overlay"
125
+ class="button"
126
+ @blur=${this.onButtonBlur}
127
+ @focus=${this.onButtonFocus}
128
+ ?disabled=${this.disabled}
129
+ >
130
+ <slot name="button-prefix-icon"></slot>
131
+ <slot name="button-content">${this.renderButtonContent()}</slot>
132
+ <slot name="button-suffix-icon">${this.renderButtonSuffixIcon()}</slot>
133
+ </button>
134
+ <c2-overlay id="menu-overlay" popover @toggle=${this.handleOverlayToggle} ?fit-anchor=${this.fitSize}>
135
+ <c2-list
136
+ id="list"
137
+ .value=${this.value}
138
+ class="list"
139
+ ?multiple=${this.multiple}
140
+ @selection-change=${this.handleSelectionChange}
141
+ ?required=${this.required}
142
+ >
143
+ <slot @slotchange=${this.handleSlotChange}></slot>
144
+ </c2-list>
145
+ </c2-overlay>
146
+ </div> `;
147
+ }
148
+ };
149
+ __decorate([property({
150
+ type: Boolean,
151
+ reflect: true
152
+ })], Select.prototype, "open", void 0);
153
+ __decorate([property({
154
+ type: Boolean,
155
+ reflect: true
156
+ })], Select.prototype, "readonly", void 0);
157
+ __decorate([property({
158
+ type: Boolean,
159
+ reflect: true
160
+ })], Select.prototype, "disabled", void 0);
161
+ __decorate([property({
162
+ type: Boolean,
163
+ reflect: true
164
+ })], Select.prototype, "focused", void 0);
165
+ __decorate([property({
166
+ type: Boolean,
167
+ attribute: "fit-size"
168
+ })], Select.prototype, "fitSize", void 0);
169
+ __decorate([property({ type: String })], Select.prototype, "placeholder", void 0);
170
+ __decorate([property({ type: Boolean })], Select.prototype, "multiple", void 0);
171
+ __decorate([property({ type: Boolean })], Select.prototype, "required", void 0);
172
+ __decorate([property({
173
+ converter: arrayPropertyConverter,
174
+ reflect: true
175
+ })], Select.prototype, "value", void 0);
176
+ __decorate([query("#button", true)], Select.prototype, "button", void 0);
177
+ __decorate([query("#menu-overlay", true)], Select.prototype, "menu", void 0);
178
+ __decorate([query("slot:not([name])", true)], Select.prototype, "listItemSlot", void 0);
179
+ __decorate([state()], Select.prototype, "displayText", void 0);
180
+ Select = __decorate([customElement("c2-select")], Select);
181
+ //#endregion
182
+ export { Select };
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@c2n/select",
3
+ "version": "0.0.6",
4
+ "type": "module",
5
+ "main": "dist/select.js",
6
+ "exports": {
7
+ ".": {
8
+ "default": "./dist/select.js",
9
+ "types": "./types/src/select.d.ts"
10
+ },
11
+ "./custom-elements.json": "./custom-elements.json"
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "types"
16
+ ],
17
+ "keywords": [
18
+ "select",
19
+ "web component",
20
+ "lit"
21
+ ],
22
+ "author": "code2nguyen@gmail.com",
23
+ "publishConfig": {
24
+ "registry": "https://registry.npmjs.org",
25
+ "access": "public"
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://github.com/code2nguyen/web-components.git"
30
+ },
31
+ "scripts": {
32
+ "dev": "vite",
33
+ "build": "wireit",
34
+ "type-check": "wireit"
35
+ },
36
+ "wireit": {
37
+ "type-check": {
38
+ "dependencies": [
39
+ "../../core:build",
40
+ "../overlay:build",
41
+ "../list:build"
42
+ ],
43
+ "command": "tsc -p tsconfig.lib.json --composite false"
44
+ },
45
+ "build": {
46
+ "dependencies": [
47
+ "type-check"
48
+ ],
49
+ "command": "vite build"
50
+ }
51
+ },
52
+ "dependencies": {
53
+ "@c2n/core": "0.0.6",
54
+ "@c2n/list": "0.0.6",
55
+ "@c2n/list-item": "0.0.6",
56
+ "@c2n/overlay": "0.0.6",
57
+ "lit": "3.3.3"
58
+ },
59
+ "devDependencies": {
60
+ "@c2n/config": "*"
61
+ },
62
+ "customElements": "custom-elements.json",
63
+ "gitHead": "2921054bc75299da66dad11c1e374246ff88a51e"
64
+ }
@@ -0,0 +1,147 @@
1
+ import { LitElement, type PropertyValueMap } from 'lit';
2
+ import '@c2n/overlay';
3
+ import '@c2n/list';
4
+ /**
5
+ * A dropdown built from a trigger button and a `c2-list` of `c2-list-item` rows inside a `c2-overlay` popover. The
6
+ * rows are the light-DOM children of the select, so they are themed with the `--c2-list-item--*` variables directly on
7
+ * the select (or on a wrapper); the dropdown container is themed through the `--c2-select__list--*` variables and the
8
+ * trigger through `--c2-select__button--*`. The select has no intrinsic width: give the host a `width` (or place it in
9
+ * a grid/flex cell) and the trigger fills it.
10
+ *
11
+ * @tag c2-select
12
+ *
13
+ * @slot default - The options: `c2-list-item` elements, each with a `value`.
14
+ * @slot button-prefix-icon - Icon shown at the start of the trigger: an inline SVG, a `c2-feather-*` icon or a `c2-mat-icon`.
15
+ * @slot button-suffix-icon - Icon shown at the end of the trigger. Defaults to a chevron that flips while open.
16
+ * @slot button-content - Replaces the trigger text entirely (selected labels or placeholder) with custom markup.
17
+ *
18
+ * @event {CustomEvent<SelectionChangeEventDetail>} selection-change - Fired after the user picks an option. `detail.value` is the array of selected values (one entry unless `multiple`), `detail.data` the `data` of each selected row.
19
+ *
20
+ * @cssproperty {pixel} [--c2-select__button--min-height=36px]
21
+ * @cssproperty {padding} [--c2-select__button--padding=6px 10px 6px 12px]
22
+ * @cssproperty {pixel} [--c2-select__button--gap=8px] - Space between the icons and the text.
23
+ * @cssproperty {color} [--c2-select__button--background=#ffffff]
24
+ * @cssproperty {color} [--c2-select__button--color=#18181b]
25
+ *
26
+ * @cssproperty {font-size} [--c2-select__button--font-size=14px]
27
+ * @cssproperty {font-weight} --c2-select__button--font-weight
28
+ * @cssproperty {font-style} [--c2-select__button--font-style=normal]
29
+ * @cssproperty {font-family} --c2-select__button--font-family
30
+ *
31
+ * @cssproperty {border-radius} [--c2-select__button--border-top-left-radius=6px]
32
+ * @cssproperty {border-radius} [--c2-select__button--border-top-right-radius=6px]
33
+ * @cssproperty {border-radius} [--c2-select__button--border-bottom-left-radius=6px]
34
+ * @cssproperty {border-radius} [--c2-select__button--border-bottom-right-radius=6px]
35
+ *
36
+ * @cssproperty {border} [--c2-select__button--border-top=1px solid #bcbcc6]
37
+ * @cssproperty {border} [--c2-select__button--border-right=1px solid #bcbcc6]
38
+ * @cssproperty {border} [--c2-select__button--border-bottom=1px solid #bcbcc6]
39
+ * @cssproperty {border} [--c2-select__button--border-left=1px solid #bcbcc6]
40
+ *
41
+ * @cssproperty {border} [--c2-select__button__hover--border-top=1px solid #a1a1aa]
42
+ * @cssproperty {border} [--c2-select__button__hover--border-right=1px solid #a1a1aa]
43
+ * @cssproperty {border} [--c2-select__button__hover--border-bottom=1px solid #a1a1aa]
44
+ * @cssproperty {border} [--c2-select__button__hover--border-left=1px solid #a1a1aa]
45
+ * @cssproperty {color} [--c2-select__button__hover--background=#fafafa]
46
+ * @cssproperty {color} [--c2-select__button__hover--color=#18181b]
47
+ *
48
+ * @cssproperty {border} [--c2-select__button__open--border-top=1px solid #476ef9]
49
+ * @cssproperty {border} [--c2-select__button__open--border-right=1px solid #476ef9]
50
+ * @cssproperty {border} [--c2-select__button__open--border-bottom=1px solid #476ef9]
51
+ * @cssproperty {border} [--c2-select__button__open--border-left=1px solid #476ef9]
52
+ *
53
+ * @cssproperty {outline} [--c2-select__button__focus--outline=2px solid rgba(71, 110, 249, 0.4)]
54
+ * @cssproperty {pixel} [--c2-select__button__focus--outline-offset=1px]
55
+ *
56
+ * @cssproperty {opacity} [--c2-select__button__disabled--opacity=0.38]
57
+ *
58
+ * @cssproperty {pixel} [--c2-select__button__prefix-icon--width=16px]
59
+ * @cssproperty {pixel} [--c2-select__button__prefix-icon--height=16px]
60
+ * @cssproperty {color} --c2-select__button__prefix-icon--color - Defaults to the trigger text colour.
61
+ *
62
+ * @cssproperty {pixel} [--c2-select__button__suffix-icon--width=16px]
63
+ * @cssproperty {pixel} [--c2-select__button__suffix-icon--height=16px]
64
+ * @cssproperty {color} [--c2-select__button__suffix-icon--color=#71717a]
65
+ *
66
+ * @cssproperty {font-weight} --c2-select__placeholder--font-weight
67
+ * @cssproperty {font-style} --c2-select__placeholder--font-style
68
+ * @cssproperty {color} [--c2-select__placeholder--color=#71717a]
69
+ * @cssproperty {opacity} [--c2-select__placeholder--opacity=1]
70
+ *
71
+ * @cssproperty {color} [--c2-select__list--background=#ffffff]
72
+ * @cssproperty {border} [--c2-select__list--border-top=1px solid #e4e4e7]
73
+ * @cssproperty {border} [--c2-select__list--border-right=1px solid #e4e4e7]
74
+ * @cssproperty {border} [--c2-select__list--border-bottom=1px solid #e4e4e7]
75
+ * @cssproperty {border} [--c2-select__list--border-left=1px solid #e4e4e7]
76
+ * @cssproperty {border-radius} [--c2-select__list--border-top-left-radius=8px]
77
+ * @cssproperty {border-radius} [--c2-select__list--border-top-right-radius=8px]
78
+ * @cssproperty {border-radius} [--c2-select__list--border-bottom-left-radius=8px]
79
+ * @cssproperty {border-radius} [--c2-select__list--border-bottom-right-radius=8px]
80
+ * @cssproperty {box-shadow} [--c2-select__list--box-shadow=0 8px 24px rgba(24, 24, 27, 0.08)]
81
+ * @cssproperty {padding} [--c2-select__list--padding-top=4px]
82
+ * @cssproperty {padding} [--c2-select__list--padding-right=4px]
83
+ * @cssproperty {padding} [--c2-select__list--padding-bottom=4px]
84
+ * @cssproperty {padding} [--c2-select__list--padding-left=4px]
85
+ * @cssproperty {pixel} [--c2-select__list--max-height=280px] - The dropdown scrolls past this height.
86
+ *
87
+ * @internalcomponent c2-list
88
+ * @internalcomponent c2-overlay
89
+ *
90
+ * @slotcomponent c2-list-item
91
+ */
92
+ export declare class Select extends LitElement {
93
+ static styles: import("lit").CSSResult;
94
+ static shadowRootOptions: {
95
+ delegatesFocus: boolean;
96
+ clonable?: boolean;
97
+ customElementRegistry?: CustomElementRegistry | null;
98
+ mode: ShadowRootMode;
99
+ serializable?: boolean;
100
+ slotAssignment?: SlotAssignmentMode;
101
+ };
102
+ /** Whether the dropdown is showing. Reflects the popover state; set it to open or close programmatically. */
103
+ open: boolean;
104
+ /** Shows the current value but never opens the dropdown. */
105
+ readonly: boolean;
106
+ /** Dims the trigger and ignores interaction. */
107
+ disabled: boolean;
108
+ /** True while the trigger has keyboard focus. */
109
+ focused: boolean;
110
+ /** Make the dropdown exactly as wide as the trigger instead of at least as wide. */
111
+ fitSize: boolean;
112
+ /** Text shown in the trigger while nothing is selected. */
113
+ placeholder: string;
114
+ /** Allow several options to be selected; the dropdown stays open after a pick and the trigger lists every label. */
115
+ multiple: boolean;
116
+ /** Keep at least one option selected: picking the only selected option again does not clear it. */
117
+ required: boolean;
118
+ /** Selected values. Written as `value="a;b"` in markup, read as `['a', 'b']` from the property. */
119
+ value: string[];
120
+ button: HTMLButtonElement;
121
+ menu: HTMLElement;
122
+ listItemSlot?: HTMLSlotElement;
123
+ private displayText;
124
+ protected childItemsUpdated: Promise<unknown[]>;
125
+ data: unknown[];
126
+ private onButtonBlur;
127
+ private onKeydown;
128
+ toggle(value?: boolean): void;
129
+ private onButtonFocus;
130
+ private prepareGetDisplayText;
131
+ private updateDisplayText;
132
+ private renderButtonContent;
133
+ private renderButtonSuffixIcon;
134
+ private handleSelectionChange;
135
+ private handleOverlayToggle;
136
+ protected willUpdate(changedProperties: PropertyValueMap<this>): void;
137
+ protected updated(_changedProperties: PropertyValueMap<this>): void;
138
+ protected getUpdateComplete(): Promise<boolean>;
139
+ private handleSlotChange;
140
+ render(): import("lit-html").TemplateResult<1>;
141
+ }
142
+ declare global {
143
+ interface HTMLElementTagNameMap {
144
+ 'c2-select': Select;
145
+ }
146
+ }
147
+ //# sourceMappingURL=select.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAwB,KAAK,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAS7E,OAAO,cAAc,CAAA;AACrB,OAAO,WAAW,CAAA;AAElB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuFG;AACH,qBACa,MAAO,SAAQ,UAAU;IACpC,OAAgB,MAAM,0BAAoB;IAE1C,OAAgB,iBAAiB;;;;;;;MAA4D;IAE7F,6GAA6G;IACjE,IAAI,UAAQ;IAExD,4DAA4D;IAChB,QAAQ,UAAQ;IAE5D,gDAAgD;IACJ,QAAQ,UAAQ;IAE5D,iDAAiD;IACL,OAAO,UAAQ;IAE3D,oFAAoF;IAChC,OAAO,UAAQ;IAEnE,2DAA2D;IAC/B,WAAW,SAAK;IAE5C,oHAAoH;IACvF,QAAQ,EAAE,OAAO,CAAQ;IAEtD,mGAAmG;IACtE,QAAQ,EAAE,OAAO,CAAQ;IAEtD,mGAAmG;IAKnG,KAAK,EAAE,MAAM,EAAE,CAAK;IAEW,MAAM,EAAG,iBAAiB,CAAA;IACpB,IAAI,EAAG,WAAW,CAAA;IACf,YAAY,CAAC,EAAE,eAAe,CAAA;IAE7D,OAAO,CAAC,WAAW,CAAK;IAEjC,SAAS,CAAC,iBAAiB,EAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IAEhD,IAAI,EAAE,OAAO,EAAE,CAAK;IAEpB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,SAAS,CAOhB;IAEM,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI;IAmBpC,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,qBAAqB;YAaf,iBAAiB;IAe/B,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,sBAAsB;IAI9B,OAAO,CAAC,qBAAqB;IAU7B,OAAO,CAAC,mBAAmB;cAKR,UAAU,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,IAAI,CAAC,GAAG,IAAI;cAO3D,OAAO,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,IAAI,CAAC,GAAG,IAAI;cASnD,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC;IAM9D,OAAO,CAAC,gBAAgB;IAIf,MAAM;CA+BhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,MAAM,CAAA;KACpB;CACF"}