@telperion/elements 4.0.1 → 4.2.0
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/.build-manifest.json +1 -1
- package/fesm/elements.mjs +65 -2
- package/fesm/elements.mjs.map +1 -1
- package/iife/elements.js +12 -7
- package/iife/elements.js.map +1 -1
- package/iife/select/index.js +24 -19
- package/iife/select/index.js.map +1 -1
- package/index.cjs +2 -0
- package/index.cjs.map +1 -1
- package/index.d.cts +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/select/index.cjs +2 -0
- package/select/index.cjs.map +1 -1
- package/select/index.d.cts +92 -14
- package/select/index.d.ts +92 -14
- package/select/index.js +1 -0
- package/select/index.js.map +1 -1
- package/select/select-change-event.cjs +30 -0
- package/select/select-change-event.cjs.map +1 -0
- package/select/select-change-event.js +28 -0
- package/select/select-change-event.js.map +1 -0
- package/select/select.element.cjs +38 -0
- package/select/select.element.cjs.map +1 -1
- package/select/select.element.js +38 -0
- package/select/select.element.js.map +1 -1
- package/select/selected-content.element.cjs +1 -1
- package/select/selected-content.element.cjs.map +1 -1
- package/select/selected-content.element.js +1 -1
- package/select/selected-content.element.js.map +1 -1
package/index.cjs
CHANGED
|
@@ -15,6 +15,7 @@ var popoverElement = require('./popover/popover-element.cjs');
|
|
|
15
15
|
var select_element = require('./select/select.element.cjs');
|
|
16
16
|
var option_element = require('./select/option.element.cjs');
|
|
17
17
|
var selectedContent_element = require('./select/selected-content.element.cjs');
|
|
18
|
+
var selectChangeEvent = require('./select/select-change-event.cjs');
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
|
|
@@ -75,4 +76,5 @@ Object.defineProperty(exports, "SelectedContentElement", {
|
|
|
75
76
|
enumerable: true,
|
|
76
77
|
get: function () { return selectedContent_element.SelectedContentElement; }
|
|
77
78
|
});
|
|
79
|
+
exports.SelectChangeEvent = selectChangeEvent.SelectChangeEvent;
|
|
78
80
|
//# sourceMappingURL=index.cjs.map
|
package/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ export { ThaRoute, ThaRouter, ThaRouterConfig, ThaRouterLink, ThaRouterOutlet, T
|
|
|
2
2
|
export { DragElement, DragElementEventTypes, DragHandleElement, DropElementEventTypes, DropZoneElement, ThaDragEvent, ThaDragEventTypes } from './drag-drop/index.cjs';
|
|
3
3
|
export { DetailsSetElement } from './details-set/index.cjs';
|
|
4
4
|
export { PopoverElement } from './popover/index.cjs';
|
|
5
|
-
export { OptionElement, SelectElement, SelectedContentElement } from './select/index.cjs';
|
|
5
|
+
export { OptionElement, SelectChangeEvent, SelectElement, SelectedContentElement } from './select/index.cjs';
|
|
6
6
|
import './_chunks/signal-watcher-lit-element-B9xodkLt.cjs';
|
|
7
7
|
import 'lit';
|
|
8
8
|
import '@lit-labs/signals';
|
package/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { ThaRoute, ThaRouter, ThaRouterConfig, ThaRouterLink, ThaRouterOutlet, T
|
|
|
2
2
|
export { DragElement, DragElementEventTypes, DragHandleElement, DropElementEventTypes, DropZoneElement, ThaDragEvent, ThaDragEventTypes } from './drag-drop/index.js';
|
|
3
3
|
export { DetailsSetElement } from './details-set/index.js';
|
|
4
4
|
export { PopoverElement } from './popover/index.js';
|
|
5
|
-
export { OptionElement, SelectElement, SelectedContentElement } from './select/index.js';
|
|
5
|
+
export { OptionElement, SelectChangeEvent, SelectElement, SelectedContentElement } from './select/index.js';
|
|
6
6
|
import './_chunks/signal-watcher-lit-element-B9xodkLt.js';
|
|
7
7
|
import 'lit';
|
|
8
8
|
import '@lit-labs/signals';
|
package/index.js
CHANGED
|
@@ -13,4 +13,5 @@ export { PopoverElement } from './popover/popover-element.js';
|
|
|
13
13
|
export { SelectElement } from './select/select.element.js';
|
|
14
14
|
export { OptionElement } from './select/option.element.js';
|
|
15
15
|
export { SelectedContentElement } from './select/selected-content.element.js';
|
|
16
|
+
export { SelectChangeEvent } from './select/select-change-event.js';
|
|
16
17
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telperion/elements",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Framework-agnostic web components built with Lit: Material Symbols / Simple Icons / theSVG icons, declarative client-side router, drag-and-drop primitives, details accordion with FIFO open caps, a CSS-anchored popover, and a form-associated selectbox with single/multi-select.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components",
|
package/select/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var select_element = require('./select.element.cjs');
|
|
4
4
|
var option_element = require('./option.element.cjs');
|
|
5
5
|
var selectedContent_element = require('./selected-content.element.cjs');
|
|
6
|
+
var selectChangeEvent = require('./select-change-event.cjs');
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
@@ -18,4 +19,5 @@ Object.defineProperty(exports, "SelectedContentElement", {
|
|
|
18
19
|
enumerable: true,
|
|
19
20
|
get: function () { return selectedContent_element.SelectedContentElement; }
|
|
20
21
|
});
|
|
22
|
+
exports.SelectChangeEvent = selectChangeEvent.SelectChangeEvent;
|
|
21
23
|
//# sourceMappingURL=index.cjs.map
|
package/select/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
|
package/select/index.d.cts
CHANGED
|
@@ -92,19 +92,54 @@ declare global {
|
|
|
92
92
|
* @attr required - Empty selection triggers `valueMissing`.
|
|
93
93
|
* @attr open - Reflects the popover's open state (read-only).
|
|
94
94
|
*
|
|
95
|
-
* @slot button
|
|
96
|
-
* @slot
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
95
|
+
* @slot button - Replaces the default trigger button.
|
|
96
|
+
* @slot indicator - Replaces the default open/close caret (`▾`) shown
|
|
97
|
+
* inside the trigger button. Rendered next to
|
|
98
|
+
* `<tp-selected-content>`; rotates 180° while the
|
|
99
|
+
* select is `open` (via the `[pseudo="indicator"]`
|
|
100
|
+
* styling).
|
|
101
|
+
* @slot popover - Replaces the default rendering of the host's children
|
|
102
|
+
* inside the panel. Use this when you want to keep the
|
|
103
|
+
* `<tp-option>`s registered in the select context — so
|
|
104
|
+
* selection, validation and form submission still work —
|
|
105
|
+
* but display something else in the popover (a message,
|
|
106
|
+
* a search field, a custom layout, …) instead of the
|
|
107
|
+
* default option list.
|
|
108
|
+
* @slot placeholder - Replaces the default placeholder span inside
|
|
109
|
+
* `<tp-selected-content>` when no option is selected.
|
|
110
|
+
* Forwarded by the light-DOM `<slot name="placeholder">`
|
|
111
|
+
* that `<tp-selected-content>` renders, so any direct
|
|
112
|
+
* child of `<tp-select>` carrying `slot="placeholder"`
|
|
113
|
+
* is projected as the empty-state label (icon + text,
|
|
114
|
+
* custom markup, etc.).
|
|
115
|
+
* @slot - Default slot inside the popover (where `<tp-option>`s go).
|
|
116
|
+
*
|
|
117
|
+
* @csspart button - The trigger wrapper.
|
|
118
|
+
* @csspart indicator - The default open/close caret (`▾`).
|
|
119
|
+
* Rotated 180° while the select is `open`.
|
|
120
|
+
* Suppressed when the `indicator` slot is
|
|
121
|
+
* filled.
|
|
122
|
+
* @csspart popover - The `<tp-popover>` panel.
|
|
123
|
+
* @csspart selected-content - The default `<tp-selected-content>`.
|
|
124
|
+
* @csspart placeholder - The `<span>` rendered by the default
|
|
125
|
+
* `<tp-selected-content>` when no option
|
|
126
|
+
* is selected (renders the `placeholder`
|
|
127
|
+
* attribute). Exposed because
|
|
128
|
+
* `<tp-selected-content>` is light-DOM
|
|
129
|
+
* and lives inside this element's shadow
|
|
130
|
+
* root by default.
|
|
131
|
+
* @csspart selected-content-option - Each cloned `<tp-option>` mirrored by
|
|
132
|
+
* the default `<tp-selected-content>`.
|
|
133
|
+
* Exposed for the same reason as
|
|
134
|
+
* `placeholder`. Set on the clones
|
|
135
|
+
* themselves — use
|
|
136
|
+
* `tp-select::part(selected-content-option)`
|
|
137
|
+
* to style them.
|
|
138
|
+
*
|
|
139
|
+
* @fires change - {@link SelectChangeEvent} dispatched when the selected
|
|
140
|
+
* option set changes. Bubbles, not composed (mirrors the
|
|
141
|
+
* native `<select>` `change` event). Not fired on initial
|
|
142
|
+
* mount or when the selection is re-set to the same value.
|
|
108
143
|
*/
|
|
109
144
|
"tp-select": SelectElement;
|
|
110
145
|
}
|
|
@@ -204,6 +239,19 @@ declare global {
|
|
|
204
239
|
* <tp-option value="apple">Apple</tp-option>
|
|
205
240
|
* </tp-select>
|
|
206
241
|
* ```
|
|
242
|
+
*
|
|
243
|
+
* Renders into its own light DOM, so it has no slots and exposes no CSS
|
|
244
|
+
* Shadow Parts of its own. The `part` attributes it stamps onto the rendered
|
|
245
|
+
* placeholder span and cloned `<tp-option>`s only become real Shadow Parts
|
|
246
|
+
* when this element happens to sit inside another shadow root — which is
|
|
247
|
+
* what happens by default inside `<tp-select>`, so those parts (`placeholder`,
|
|
248
|
+
* `selected-content-option`) are documented on `<tp-select>`.
|
|
249
|
+
*
|
|
250
|
+
* The empty-state markup is wrapped in `<slot name="placeholder">…</slot>`.
|
|
251
|
+
* Because this element renders into light DOM, that `<slot>` ends up sitting
|
|
252
|
+
* inside its host shadow root — so when used as the default content of a
|
|
253
|
+
* `<tp-select>`, any `slot="placeholder"` child of the `<tp-select>` is
|
|
254
|
+
* projected as the empty-state label.
|
|
207
255
|
*/
|
|
208
256
|
"tp-selected-content": SelectedContentElement;
|
|
209
257
|
}
|
|
@@ -216,4 +264,34 @@ declare class SelectedContentElement extends SignalWatcherLitElement {
|
|
|
216
264
|
protected render(): unknown;
|
|
217
265
|
}
|
|
218
266
|
|
|
219
|
-
|
|
267
|
+
interface SelectChangeEventInit {
|
|
268
|
+
value: string;
|
|
269
|
+
selectedOptions: readonly OptionElement[];
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Dispatched by `<tp-select>` whenever its selected option set changes.
|
|
273
|
+
*
|
|
274
|
+
* Mirrors the native `<select>` `change` event semantics:
|
|
275
|
+
* - type is `'change'`
|
|
276
|
+
* - `bubbles: true`, `composed: false`, `cancelable: false` by default
|
|
277
|
+
* - not fired on initial mount, nor when the selection is set to the
|
|
278
|
+
* same value it already had
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```ts
|
|
282
|
+
* select.addEventListener('change', e => {
|
|
283
|
+
* if (e instanceof SelectChangeEvent) {
|
|
284
|
+
* console.log(e.value, e.selectedOptions);
|
|
285
|
+
* }
|
|
286
|
+
* });
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
declare class SelectChangeEvent extends Event {
|
|
290
|
+
/** Joined value string of the new selection (same as `tp-select.value`). */
|
|
291
|
+
readonly value: string;
|
|
292
|
+
/** Snapshot of the currently selected `<tp-option>` elements. */
|
|
293
|
+
readonly selectedOptions: readonly OptionElement[];
|
|
294
|
+
constructor(init: SelectChangeEventInit, eventInit?: EventInit);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export { OptionElement, SelectChangeEvent, SelectElement, SelectedContentElement };
|
package/select/index.d.ts
CHANGED
|
@@ -92,19 +92,54 @@ declare global {
|
|
|
92
92
|
* @attr required - Empty selection triggers `valueMissing`.
|
|
93
93
|
* @attr open - Reflects the popover's open state (read-only).
|
|
94
94
|
*
|
|
95
|
-
* @slot button
|
|
96
|
-
* @slot
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
95
|
+
* @slot button - Replaces the default trigger button.
|
|
96
|
+
* @slot indicator - Replaces the default open/close caret (`▾`) shown
|
|
97
|
+
* inside the trigger button. Rendered next to
|
|
98
|
+
* `<tp-selected-content>`; rotates 180° while the
|
|
99
|
+
* select is `open` (via the `[pseudo="indicator"]`
|
|
100
|
+
* styling).
|
|
101
|
+
* @slot popover - Replaces the default rendering of the host's children
|
|
102
|
+
* inside the panel. Use this when you want to keep the
|
|
103
|
+
* `<tp-option>`s registered in the select context — so
|
|
104
|
+
* selection, validation and form submission still work —
|
|
105
|
+
* but display something else in the popover (a message,
|
|
106
|
+
* a search field, a custom layout, …) instead of the
|
|
107
|
+
* default option list.
|
|
108
|
+
* @slot placeholder - Replaces the default placeholder span inside
|
|
109
|
+
* `<tp-selected-content>` when no option is selected.
|
|
110
|
+
* Forwarded by the light-DOM `<slot name="placeholder">`
|
|
111
|
+
* that `<tp-selected-content>` renders, so any direct
|
|
112
|
+
* child of `<tp-select>` carrying `slot="placeholder"`
|
|
113
|
+
* is projected as the empty-state label (icon + text,
|
|
114
|
+
* custom markup, etc.).
|
|
115
|
+
* @slot - Default slot inside the popover (where `<tp-option>`s go).
|
|
116
|
+
*
|
|
117
|
+
* @csspart button - The trigger wrapper.
|
|
118
|
+
* @csspart indicator - The default open/close caret (`▾`).
|
|
119
|
+
* Rotated 180° while the select is `open`.
|
|
120
|
+
* Suppressed when the `indicator` slot is
|
|
121
|
+
* filled.
|
|
122
|
+
* @csspart popover - The `<tp-popover>` panel.
|
|
123
|
+
* @csspart selected-content - The default `<tp-selected-content>`.
|
|
124
|
+
* @csspart placeholder - The `<span>` rendered by the default
|
|
125
|
+
* `<tp-selected-content>` when no option
|
|
126
|
+
* is selected (renders the `placeholder`
|
|
127
|
+
* attribute). Exposed because
|
|
128
|
+
* `<tp-selected-content>` is light-DOM
|
|
129
|
+
* and lives inside this element's shadow
|
|
130
|
+
* root by default.
|
|
131
|
+
* @csspart selected-content-option - Each cloned `<tp-option>` mirrored by
|
|
132
|
+
* the default `<tp-selected-content>`.
|
|
133
|
+
* Exposed for the same reason as
|
|
134
|
+
* `placeholder`. Set on the clones
|
|
135
|
+
* themselves — use
|
|
136
|
+
* `tp-select::part(selected-content-option)`
|
|
137
|
+
* to style them.
|
|
138
|
+
*
|
|
139
|
+
* @fires change - {@link SelectChangeEvent} dispatched when the selected
|
|
140
|
+
* option set changes. Bubbles, not composed (mirrors the
|
|
141
|
+
* native `<select>` `change` event). Not fired on initial
|
|
142
|
+
* mount or when the selection is re-set to the same value.
|
|
108
143
|
*/
|
|
109
144
|
"tp-select": SelectElement;
|
|
110
145
|
}
|
|
@@ -204,6 +239,19 @@ declare global {
|
|
|
204
239
|
* <tp-option value="apple">Apple</tp-option>
|
|
205
240
|
* </tp-select>
|
|
206
241
|
* ```
|
|
242
|
+
*
|
|
243
|
+
* Renders into its own light DOM, so it has no slots and exposes no CSS
|
|
244
|
+
* Shadow Parts of its own. The `part` attributes it stamps onto the rendered
|
|
245
|
+
* placeholder span and cloned `<tp-option>`s only become real Shadow Parts
|
|
246
|
+
* when this element happens to sit inside another shadow root — which is
|
|
247
|
+
* what happens by default inside `<tp-select>`, so those parts (`placeholder`,
|
|
248
|
+
* `selected-content-option`) are documented on `<tp-select>`.
|
|
249
|
+
*
|
|
250
|
+
* The empty-state markup is wrapped in `<slot name="placeholder">…</slot>`.
|
|
251
|
+
* Because this element renders into light DOM, that `<slot>` ends up sitting
|
|
252
|
+
* inside its host shadow root — so when used as the default content of a
|
|
253
|
+
* `<tp-select>`, any `slot="placeholder"` child of the `<tp-select>` is
|
|
254
|
+
* projected as the empty-state label.
|
|
207
255
|
*/
|
|
208
256
|
"tp-selected-content": SelectedContentElement;
|
|
209
257
|
}
|
|
@@ -216,4 +264,34 @@ declare class SelectedContentElement extends SignalWatcherLitElement {
|
|
|
216
264
|
protected render(): unknown;
|
|
217
265
|
}
|
|
218
266
|
|
|
219
|
-
|
|
267
|
+
interface SelectChangeEventInit {
|
|
268
|
+
value: string;
|
|
269
|
+
selectedOptions: readonly OptionElement[];
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Dispatched by `<tp-select>` whenever its selected option set changes.
|
|
273
|
+
*
|
|
274
|
+
* Mirrors the native `<select>` `change` event semantics:
|
|
275
|
+
* - type is `'change'`
|
|
276
|
+
* - `bubbles: true`, `composed: false`, `cancelable: false` by default
|
|
277
|
+
* - not fired on initial mount, nor when the selection is set to the
|
|
278
|
+
* same value it already had
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```ts
|
|
282
|
+
* select.addEventListener('change', e => {
|
|
283
|
+
* if (e instanceof SelectChangeEvent) {
|
|
284
|
+
* console.log(e.value, e.selectedOptions);
|
|
285
|
+
* }
|
|
286
|
+
* });
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
declare class SelectChangeEvent extends Event {
|
|
290
|
+
/** Joined value string of the new selection (same as `tp-select.value`). */
|
|
291
|
+
readonly value: string;
|
|
292
|
+
/** Snapshot of the currently selected `<tp-option>` elements. */
|
|
293
|
+
readonly selectedOptions: readonly OptionElement[];
|
|
294
|
+
constructor(init: SelectChangeEventInit, eventInit?: EventInit);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export { OptionElement, SelectChangeEvent, SelectElement, SelectedContentElement };
|
package/select/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { SelectElement } from './select.element.js';
|
|
2
2
|
export { OptionElement } from './option.element.js';
|
|
3
3
|
export { SelectedContentElement } from './selected-content.element.js';
|
|
4
|
+
export { SelectChangeEvent } from './select-change-event.js';
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
package/select/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Dispatched by `<tp-select>` whenever its selected option set changes.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors the native `<select>` `change` event semantics:
|
|
7
|
+
* - type is `'change'`
|
|
8
|
+
* - `bubbles: true`, `composed: false`, `cancelable: false` by default
|
|
9
|
+
* - not fired on initial mount, nor when the selection is set to the
|
|
10
|
+
* same value it already had
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* select.addEventListener('change', e => {
|
|
15
|
+
* if (e instanceof SelectChangeEvent) {
|
|
16
|
+
* console.log(e.value, e.selectedOptions);
|
|
17
|
+
* }
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
class SelectChangeEvent extends Event {
|
|
22
|
+
constructor(init, eventInit) {
|
|
23
|
+
super("change", { bubbles: true, composed: false, cancelable: false, ...eventInit });
|
|
24
|
+
this.value = init.value;
|
|
25
|
+
this.selectedOptions = init.selectedOptions;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
exports.SelectChangeEvent = SelectChangeEvent;
|
|
30
|
+
//# sourceMappingURL=select-change-event.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-change-event.cjs","sources":["../../../../libs/elements/src/select/select-change-event.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAOA;;;;;;;;;;;;;;;;;AAiBG;AACG,MAAO,iBAAkB,SAAQ,KAAK,CAAA;IAO1C,WAAA,CAAY,IAA2B,EAAE,SAAqB,EAAA;QAC5D,KAAK,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,CAAC;AAEpF,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK;AACvB,QAAA,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe;IAC7C;AACD;;;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dispatched by `<tp-select>` whenever its selected option set changes.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the native `<select>` `change` event semantics:
|
|
5
|
+
* - type is `'change'`
|
|
6
|
+
* - `bubbles: true`, `composed: false`, `cancelable: false` by default
|
|
7
|
+
* - not fired on initial mount, nor when the selection is set to the
|
|
8
|
+
* same value it already had
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* select.addEventListener('change', e => {
|
|
13
|
+
* if (e instanceof SelectChangeEvent) {
|
|
14
|
+
* console.log(e.value, e.selectedOptions);
|
|
15
|
+
* }
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
class SelectChangeEvent extends Event {
|
|
20
|
+
constructor(init, eventInit) {
|
|
21
|
+
super("change", { bubbles: true, composed: false, cancelable: false, ...eventInit });
|
|
22
|
+
this.value = init.value;
|
|
23
|
+
this.selectedOptions = init.selectedOptions;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { SelectChangeEvent };
|
|
28
|
+
//# sourceMappingURL=select-change-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-change-event.js","sources":["../../../../libs/elements/src/select/select-change-event.ts"],"sourcesContent":[null],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;AAiBG;AACG,MAAO,iBAAkB,SAAQ,KAAK,CAAA;IAO1C,WAAA,CAAY,IAA2B,EAAE,SAAqB,EAAA;QAC5D,KAAK,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,CAAC;AAEpF,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK;AACvB,QAAA,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe;IAC7C;AACD;;;;"}
|
|
@@ -11,6 +11,7 @@ var selectContext = require('./select-context.cjs');
|
|
|
11
11
|
var selectedContent_element = require('./selected-content.element.cjs');
|
|
12
12
|
var option_element = require('./option.element.cjs');
|
|
13
13
|
var internalProps = require('./internal-props.cjs');
|
|
14
|
+
var selectChangeEvent = require('./select-change-event.cjs');
|
|
14
15
|
var defer = require('@telperion/js-utils/function/defer');
|
|
15
16
|
var signalWatcherLitElement = require('../utils/signal-watcher-lit-element.cjs');
|
|
16
17
|
|
|
@@ -47,6 +48,11 @@ exports.SelectElement = class SelectElement extends signalWatcherLitElement.Sign
|
|
|
47
48
|
cursor: pointer;
|
|
48
49
|
display: inline-flex;
|
|
49
50
|
align-items: center;
|
|
51
|
+
padding: 0.25em 0.5em;
|
|
52
|
+
|
|
53
|
+
tp-selected-content {
|
|
54
|
+
margin-inline-end: 0.5em;
|
|
55
|
+
}
|
|
50
56
|
}
|
|
51
57
|
|
|
52
58
|
[pseudo="indicator"] {
|
|
@@ -83,6 +89,12 @@ exports.SelectElement = class SelectElement extends signalWatcherLitElement.Sign
|
|
|
83
89
|
#internals;
|
|
84
90
|
/** Initial `value` captured at construction so `formResetCallback` can restore it. */
|
|
85
91
|
#initialValue;
|
|
92
|
+
/**
|
|
93
|
+
* Last `value` for which a `change` event was emitted (or considered for
|
|
94
|
+
* emission). `null` means "no sync has happened yet" — used to suppress
|
|
95
|
+
* the very first `willUpdate` so we don't emit a phantom change on mount.
|
|
96
|
+
*/
|
|
97
|
+
#lastEmittedValue;
|
|
86
98
|
constructor() {
|
|
87
99
|
super();
|
|
88
100
|
this.#options = new Set();
|
|
@@ -122,6 +134,12 @@ exports.SelectElement = class SelectElement extends signalWatcherLitElement.Sign
|
|
|
122
134
|
this.open = false;
|
|
123
135
|
/** Initial `value` captured at construction so `formResetCallback` can restore it. */
|
|
124
136
|
this.#initialValue = "";
|
|
137
|
+
/**
|
|
138
|
+
* Last `value` for which a `change` event was emitted (or considered for
|
|
139
|
+
* emission). `null` means "no sync has happened yet" — used to suppress
|
|
140
|
+
* the very first `willUpdate` so we don't emit a phantom change on mount.
|
|
141
|
+
*/
|
|
142
|
+
this.#lastEmittedValue = null;
|
|
125
143
|
this.#internals = this.attachInternals();
|
|
126
144
|
}
|
|
127
145
|
/** Live `ElementInternals` (validity, form, labels, etc.). */
|
|
@@ -204,6 +222,7 @@ exports.SelectElement = class SelectElement extends signalWatcherLitElement.Sign
|
|
|
204
222
|
*/
|
|
205
223
|
willUpdate(_changed) {
|
|
206
224
|
this.#syncForm();
|
|
225
|
+
this.#dispatchChange();
|
|
207
226
|
}
|
|
208
227
|
// -- Form-associated callbacks ------------------------------------------
|
|
209
228
|
formResetCallback() {
|
|
@@ -255,6 +274,25 @@ exports.SelectElement = class SelectElement extends signalWatcherLitElement.Sign
|
|
|
255
274
|
this.#internals.setValidity({});
|
|
256
275
|
}
|
|
257
276
|
}
|
|
277
|
+
/**
|
|
278
|
+
* Dispatch a `SelectChangeEvent` when the joined value has actually
|
|
279
|
+
* changed. Suppresses the very first sync so consumers don't see a
|
|
280
|
+
* phantom `change` on mount (matches native `<select>` behavior).
|
|
281
|
+
*/
|
|
282
|
+
#dispatchChange() {
|
|
283
|
+
const current = this.value;
|
|
284
|
+
if (current === this.#lastEmittedValue)
|
|
285
|
+
return;
|
|
286
|
+
const isInitialSync = this.#lastEmittedValue === null;
|
|
287
|
+
this.#lastEmittedValue = current;
|
|
288
|
+
if (isInitialSync)
|
|
289
|
+
return;
|
|
290
|
+
const selectedOptions = this.selectedOptions
|
|
291
|
+
.get()
|
|
292
|
+
.map(ref => ref.deref())
|
|
293
|
+
.filter(Boolean);
|
|
294
|
+
this.dispatchEvent(new selectChangeEvent.SelectChangeEvent({ value: current, selectedOptions }));
|
|
295
|
+
}
|
|
258
296
|
selectOption(option) {
|
|
259
297
|
const current = this.selectedOptions.get();
|
|
260
298
|
if (current.find(ref => ref.deref() === option))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.element.cjs","sources":["../../../../libs/elements/src/select/select.element.ts"],"sourcesContent":[null],"names":["SelectElement","SignalWatcherLitElement","OptionElement","css","defer","signal","computed","PopoverElement","SelectedContentElement","html","REGISTER_OPTION","UNREGISTER_OPTION","sliceBefore","__decorate","provide","selectContext","property","customElement"],"mappings":"
|
|
1
|
+
{"version":3,"file":"select.element.cjs","sources":["../../../../libs/elements/src/select/select.element.ts"],"sourcesContent":[null],"names":["SelectElement","SignalWatcherLitElement","OptionElement","css","defer","signal","computed","PopoverElement","SelectedContentElement","html","SelectChangeEvent","REGISTER_OPTION","UNREGISTER_OPTION","sliceBefore","__decorate","provide","selectContext","property","customElement"],"mappings":";;;;;;;;;;;;;;;;;;AAgHaA,qBAAa,GAAnB,MAAM,aAAc,SAAQC,+CAAuB,CAAA;;aACjD,IAAA,CAAA,cAAc,GAAG,IAAH,CAAQ;AAEd,IAAA,SAAA,IAAA,CAAA,uBAAuB,GAAG,CAACC,4BAAa,CAAC,CAAC;aAClD,IAAA,CAAA,MAAM,GAAGC,OAAG,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;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O,UAAU;AAC9C,gBAAA,OAAO,MAAM,CAAC,KAAK,CAAC;YACtB,CAAC;AACF,SAAA;KACF,CAAC;;AACc,CAAA,EAAAjB,qBAAA,CAAA,SAAA,EAAA,KAAA,EAAA,MAAA,CAAA;AAIhBc,gBAAA,CAAA;IADCG,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;AACf,CAAA,EAAAjB,qBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,MAAA,CAAA;AAI3Bc,gBAAA,CAAA;IADCG,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;AAC1B,CAAA,EAAAjB,qBAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAIjBc,gBAAA,CAAA;IADCG,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;AAC1B,CAAA,EAAAjB,qBAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAGjBc,gBAAA,CAAA;IADCG,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;AAC9B,CAAA,EAAAjB,qBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,MAAA,CAAA;AA/IFA,qBAAa,GAAA,eAAA,GAAAc,gBAAA,CAAA;IADzBI,2BAAa,CAAC,WAAW,CAAC;;AACd,CAAA,EAAAlB,qBAAa,CAiZzB;;"}
|
package/select/select.element.js
CHANGED
|
@@ -9,6 +9,7 @@ import { selectContext } from './select-context.js';
|
|
|
9
9
|
import { SelectedContentElement } from './selected-content.element.js';
|
|
10
10
|
import { OptionElement } from './option.element.js';
|
|
11
11
|
import { REGISTER_OPTION, UNREGISTER_OPTION } from './internal-props.js';
|
|
12
|
+
import { SelectChangeEvent } from './select-change-event.js';
|
|
12
13
|
import { defer } from '@telperion/js-utils/function/defer';
|
|
13
14
|
import { SignalWatcherLitElement } from '../utils/signal-watcher-lit-element.js';
|
|
14
15
|
|
|
@@ -45,6 +46,11 @@ let SelectElement = class SelectElement extends SignalWatcherLitElement {
|
|
|
45
46
|
cursor: pointer;
|
|
46
47
|
display: inline-flex;
|
|
47
48
|
align-items: center;
|
|
49
|
+
padding: 0.25em 0.5em;
|
|
50
|
+
|
|
51
|
+
tp-selected-content {
|
|
52
|
+
margin-inline-end: 0.5em;
|
|
53
|
+
}
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
[pseudo="indicator"] {
|
|
@@ -81,6 +87,12 @@ let SelectElement = class SelectElement extends SignalWatcherLitElement {
|
|
|
81
87
|
#internals;
|
|
82
88
|
/** Initial `value` captured at construction so `formResetCallback` can restore it. */
|
|
83
89
|
#initialValue;
|
|
90
|
+
/**
|
|
91
|
+
* Last `value` for which a `change` event was emitted (or considered for
|
|
92
|
+
* emission). `null` means "no sync has happened yet" — used to suppress
|
|
93
|
+
* the very first `willUpdate` so we don't emit a phantom change on mount.
|
|
94
|
+
*/
|
|
95
|
+
#lastEmittedValue;
|
|
84
96
|
constructor() {
|
|
85
97
|
super();
|
|
86
98
|
this.#options = new Set();
|
|
@@ -120,6 +132,12 @@ let SelectElement = class SelectElement extends SignalWatcherLitElement {
|
|
|
120
132
|
this.open = false;
|
|
121
133
|
/** Initial `value` captured at construction so `formResetCallback` can restore it. */
|
|
122
134
|
this.#initialValue = "";
|
|
135
|
+
/**
|
|
136
|
+
* Last `value` for which a `change` event was emitted (or considered for
|
|
137
|
+
* emission). `null` means "no sync has happened yet" — used to suppress
|
|
138
|
+
* the very first `willUpdate` so we don't emit a phantom change on mount.
|
|
139
|
+
*/
|
|
140
|
+
this.#lastEmittedValue = null;
|
|
123
141
|
this.#internals = this.attachInternals();
|
|
124
142
|
}
|
|
125
143
|
/** Live `ElementInternals` (validity, form, labels, etc.). */
|
|
@@ -202,6 +220,7 @@ let SelectElement = class SelectElement extends SignalWatcherLitElement {
|
|
|
202
220
|
*/
|
|
203
221
|
willUpdate(_changed) {
|
|
204
222
|
this.#syncForm();
|
|
223
|
+
this.#dispatchChange();
|
|
205
224
|
}
|
|
206
225
|
// -- Form-associated callbacks ------------------------------------------
|
|
207
226
|
formResetCallback() {
|
|
@@ -253,6 +272,25 @@ let SelectElement = class SelectElement extends SignalWatcherLitElement {
|
|
|
253
272
|
this.#internals.setValidity({});
|
|
254
273
|
}
|
|
255
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Dispatch a `SelectChangeEvent` when the joined value has actually
|
|
277
|
+
* changed. Suppresses the very first sync so consumers don't see a
|
|
278
|
+
* phantom `change` on mount (matches native `<select>` behavior).
|
|
279
|
+
*/
|
|
280
|
+
#dispatchChange() {
|
|
281
|
+
const current = this.value;
|
|
282
|
+
if (current === this.#lastEmittedValue)
|
|
283
|
+
return;
|
|
284
|
+
const isInitialSync = this.#lastEmittedValue === null;
|
|
285
|
+
this.#lastEmittedValue = current;
|
|
286
|
+
if (isInitialSync)
|
|
287
|
+
return;
|
|
288
|
+
const selectedOptions = this.selectedOptions
|
|
289
|
+
.get()
|
|
290
|
+
.map(ref => ref.deref())
|
|
291
|
+
.filter(Boolean);
|
|
292
|
+
this.dispatchEvent(new SelectChangeEvent({ value: current, selectedOptions }));
|
|
293
|
+
}
|
|
256
294
|
selectOption(option) {
|
|
257
295
|
const current = this.selectedOptions.get();
|
|
258
296
|
if (current.find(ref => ref.deref() === option))
|