@telperion/elements 3.0.3 → 4.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.
- package/.build-manifest.json +12 -1
- package/README.md +45 -0
- package/_chunks/signal-watcher-lit-element-B9xodkLt.d.cts +29 -0
- package/_chunks/signal-watcher-lit-element-B9xodkLt.d.ts +29 -0
- package/drag-drop/drag-handle-element.cjs +1 -1
- package/drag-drop/drag-handle-element.js +1 -1
- package/fesm/elements.mjs +547 -30
- package/fesm/elements.mjs.map +1 -1
- package/iife/elements.js +187 -21
- package/iife/elements.js.map +1 -1
- package/iife/popover/index.js +44 -6
- package/iife/popover/index.js.map +1 -1
- package/iife/router/index.js.map +1 -1
- package/iife/select/index.js +273 -0
- package/iife/select/index.js.map +1 -0
- package/index.cjs +15 -0
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -0
- package/index.d.ts +2 -0
- package/index.js +3 -0
- package/index.js.map +1 -1
- package/package.json +32 -5
- package/popover/index.d.cts +1 -1
- package/popover/index.d.ts +1 -1
- package/popover/popover-element.cjs +28 -18
- package/popover/popover-element.cjs.map +1 -1
- package/popover/popover-element.js +29 -19
- package/popover/popover-element.js.map +1 -1
- package/router/index.d.cts +2 -26
- package/router/index.d.ts +2 -26
- package/router/tha-router-config.cjs +2 -2
- package/router/tha-router-config.cjs.map +1 -1
- package/router/tha-router-config.js +2 -2
- package/router/tha-router-config.js.map +1 -1
- package/router/tha-router-link.cjs +1 -1
- package/router/tha-router-link.js +1 -1
- package/router/tha-router-outlet.cjs +1 -1
- package/router/tha-router-outlet.js +1 -1
- package/router/tha-router-param.cjs +1 -1
- package/router/tha-router-param.js +1 -1
- package/router/tha-router.cjs +1 -1
- package/router/tha-router.js +1 -1
- package/select/index.cjs +21 -0
- package/select/index.cjs.map +1 -0
- package/select/index.d.cts +219 -0
- package/select/index.d.ts +219 -0
- package/select/index.js +4 -0
- package/select/index.js.map +1 -0
- package/select/internal-props.cjs +10 -0
- package/select/internal-props.cjs.map +1 -0
- package/select/internal-props.js +6 -0
- package/select/internal-props.js.map +1 -0
- package/select/option.element.cjs +88 -0
- package/select/option.element.cjs.map +1 -0
- package/select/option.element.js +88 -0
- package/select/option.element.js.map +1 -0
- package/select/select-context.cjs +14 -0
- package/select/select-context.cjs.map +1 -0
- package/select/select-context.js +12 -0
- package/select/select-context.js.map +1 -0
- package/select/select.element.cjs +376 -0
- package/select/select.element.cjs.map +1 -0
- package/select/select.element.js +376 -0
- package/select/select.element.js.map +1 -0
- package/select/selected-content.element.cjs +65 -0
- package/select/selected-content.element.cjs.map +1 -0
- package/select/selected-content.element.js +65 -0
- package/select/selected-content.element.js.map +1 -0
- package/utils/signal-watcher-lit-element.cjs.map +1 -0
- package/utils/signal-watcher-lit-element.js.map +1 -0
- package/router/signal-watcher-lit-element.cjs.map +0 -1
- package/router/signal-watcher-lit-element.js.map +0 -1
- /package/{router → utils}/signal-watcher-lit-element.cjs +0 -0
- /package/{router → utils}/signal-watcher-lit-element.js +0 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { PropertyValues } from 'lit';
|
|
2
|
+
import { S as SignalWatcherLitElement } from '../_chunks/signal-watcher-lit-element-B9xodkLt.js';
|
|
3
|
+
|
|
4
|
+
declare const REGISTER_OPTION: unique symbol;
|
|
5
|
+
declare const UNREGISTER_OPTION: unique symbol;
|
|
6
|
+
declare const SHOULD_REGISTER_TO_SELECT: unique symbol;
|
|
7
|
+
|
|
8
|
+
declare global {
|
|
9
|
+
interface HTMLElementTagNameMap {
|
|
10
|
+
/**
|
|
11
|
+
* A single selectable item inside a `<tp-select>`.
|
|
12
|
+
*
|
|
13
|
+
* Discovers its host `<tp-select>` via `@lit/context`, registers itself
|
|
14
|
+
* on connect, and reflects its own selected state through the
|
|
15
|
+
* `selected` attribute (read-only — set selection by clicking, by
|
|
16
|
+
* mutating `tp-select.value`, or by calling
|
|
17
|
+
* `selectOption()`/`deselectOption()`/`toggleOption()` on the host).
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```html
|
|
21
|
+
* <tp-select>
|
|
22
|
+
* <tp-option value="apple">Apple</tp-option>
|
|
23
|
+
* <tp-option value="banana">Banana</tp-option>
|
|
24
|
+
* </tp-select>
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @attr value - The submitted value when this option is selected.
|
|
28
|
+
* @attr selected - Reflects current selection state (do not set manually).
|
|
29
|
+
*
|
|
30
|
+
* @slot - Visible label for the option.
|
|
31
|
+
*/
|
|
32
|
+
"tp-option": OptionElement;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
declare class OptionElement extends SignalWatcherLitElement {
|
|
36
|
+
static styles: any;
|
|
37
|
+
private select?;
|
|
38
|
+
[SHOULD_REGISTER_TO_SELECT]: boolean;
|
|
39
|
+
value: string;
|
|
40
|
+
connectedCallback(): void;
|
|
41
|
+
disconnectedCallback(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Reflect `selected` state by reading the parent's signal during the
|
|
44
|
+
* normal Lit update. `SignalWatcher` auto-tracks signal access here, so
|
|
45
|
+
* the option will re-render whenever the selection changes — without
|
|
46
|
+
* the disposal-race that `updateEffect` exposes.
|
|
47
|
+
*/
|
|
48
|
+
protected willUpdate(_changed: PropertyValues): void;
|
|
49
|
+
protected createRenderRoot(): this;
|
|
50
|
+
protected render(): any;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
declare global {
|
|
54
|
+
interface HTMLElementTagNameMap {
|
|
55
|
+
/**
|
|
56
|
+
* A form-associated, framework-agnostic selectbox.
|
|
57
|
+
*
|
|
58
|
+
* Composes `<tp-popover>` for placement and `<tp-option>` for items.
|
|
59
|
+
* Single-select by default; switches to multi-select via `max`.
|
|
60
|
+
*
|
|
61
|
+
* @example Single-select
|
|
62
|
+
* ```html
|
|
63
|
+
* <tp-select name="fruit" required>
|
|
64
|
+
* <tp-option value="apple">Apple</tp-option>
|
|
65
|
+
* <tp-option value="banana">Banana</tp-option>
|
|
66
|
+
* </tp-select>
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @example Multi-select with eviction limit
|
|
70
|
+
* ```html
|
|
71
|
+
* <tp-select name="tags" max="3">…</tp-select>
|
|
72
|
+
* <tp-select name="tags" max="infinite">…</tp-select>
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @example Custom trigger button
|
|
76
|
+
* ```html
|
|
77
|
+
* <tp-select>
|
|
78
|
+
* <button slot="button">Open</button>
|
|
79
|
+
* <tp-option value="a">A</tp-option>
|
|
80
|
+
* </tp-select>
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @attr value - Comma-joined list of selected `<tp-option>` values
|
|
84
|
+
* (read-only; derived from `selectedOptions`).
|
|
85
|
+
* @attr placeholder - Text shown by `<tp-selected-content>` when no
|
|
86
|
+
* option is selected.
|
|
87
|
+
* @attr max - `1` (default) for single-select, any positive integer
|
|
88
|
+
* for multi-select with FIFO eviction, or `infinite`
|
|
89
|
+
* for unbounded selection.
|
|
90
|
+
* @attr name - Form field name.
|
|
91
|
+
* @attr disabled - Non-interactive; excluded from form submission.
|
|
92
|
+
* @attr required - Empty selection triggers `valueMissing`.
|
|
93
|
+
* @attr open - Reflects the popover's open state (read-only).
|
|
94
|
+
*
|
|
95
|
+
* @slot button - Replaces the default trigger button.
|
|
96
|
+
* @slot popover - Replaces the default rendering of the host's children
|
|
97
|
+
* inside the panel. Use this when you want to keep the
|
|
98
|
+
* `<tp-option>`s registered in the select context — so
|
|
99
|
+
* selection, validation and form submission still work —
|
|
100
|
+
* but display something else in the popover (a message,
|
|
101
|
+
* a search field, a custom layout, …) instead of the
|
|
102
|
+
* default option list.
|
|
103
|
+
* @slot - Default slot inside the popover (where `<tp-option>`s go).
|
|
104
|
+
*
|
|
105
|
+
* @csspart button - The trigger wrapper.
|
|
106
|
+
* @csspart popover - The `<tp-popover>` panel.
|
|
107
|
+
* @csspart selected-content - The default `<tp-selected-content>`.
|
|
108
|
+
*/
|
|
109
|
+
"tp-select": SelectElement;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
declare class SelectElement extends SignalWatcherLitElement {
|
|
113
|
+
#private;
|
|
114
|
+
static formAssociated: boolean;
|
|
115
|
+
private static ALLOWED_OPTION_ELEMENTS;
|
|
116
|
+
static styles: any;
|
|
117
|
+
/**
|
|
118
|
+
* Provides this `<tp-select>` instance to descendants via `@lit/context`,
|
|
119
|
+
* so consumers (e.g. `<tp-selected-content>`) can find it across any
|
|
120
|
+
* number of shadow DOM boundaries — not just light-DOM ancestors.
|
|
121
|
+
*/
|
|
122
|
+
readonly self: SelectElement;
|
|
123
|
+
readonly selectedOptions: Signal.State<T>;
|
|
124
|
+
get value(): string;
|
|
125
|
+
set value(next: string);
|
|
126
|
+
get placeholder(): string;
|
|
127
|
+
set placeholder(next: string);
|
|
128
|
+
/**
|
|
129
|
+
* Maximum number of options that can be selected at once.
|
|
130
|
+
*
|
|
131
|
+
* Defaults to `1` (single-select). Any positive integer enables
|
|
132
|
+
* multi-select up to that many entries. Use the literal string
|
|
133
|
+
* `"infinite"` in HTML to allow an unbounded
|
|
134
|
+
* selection — the converter normalises it to `Number.POSITIVE_INFINITY`.
|
|
135
|
+
*
|
|
136
|
+
* When the limit is reached and a new option is selected, the oldest
|
|
137
|
+
* entry in `selectedOptions` is dropped (FIFO) so the new selection can
|
|
138
|
+
* fit. Setting `max` to a smaller number trims the current selection
|
|
139
|
+
* down to size from the end.
|
|
140
|
+
*/
|
|
141
|
+
max: number;
|
|
142
|
+
/** Form field name. Submitted with the owning `<form>`. */
|
|
143
|
+
name: string | null;
|
|
144
|
+
/** When true, the element is non-interactive and excluded from form submission. */
|
|
145
|
+
disabled: boolean;
|
|
146
|
+
/** When true, an empty selection makes the element invalid (`valueMissing`). */
|
|
147
|
+
required: boolean;
|
|
148
|
+
open: boolean;
|
|
149
|
+
constructor();
|
|
150
|
+
/** Live `ElementInternals` (validity, form, labels, etc.). */
|
|
151
|
+
get internals(): ElementInternals;
|
|
152
|
+
/** Owning `<form>` element, or `null` when not associated. */
|
|
153
|
+
get form(): HTMLFormElement | null;
|
|
154
|
+
/** Native validity state of this control. */
|
|
155
|
+
get validity(): ValidityState;
|
|
156
|
+
get validationMessage(): string;
|
|
157
|
+
get willValidate(): boolean;
|
|
158
|
+
checkValidity(): boolean;
|
|
159
|
+
reportValidity(): boolean;
|
|
160
|
+
protected createRenderRoot(): ShadowRoot;
|
|
161
|
+
connectedCallback(): void;
|
|
162
|
+
disconnectedCallback(): void;
|
|
163
|
+
protected render(): unknown;
|
|
164
|
+
protected updated(changed: Map<string, unknown>): void;
|
|
165
|
+
/**
|
|
166
|
+
* Keep `ElementInternals` in sync with the current value and validity.
|
|
167
|
+
* Reading `this.value` here transitively reads `selectedOptions`, so the
|
|
168
|
+
* `SignalWatcher` base auto-tracks it and re-runs `willUpdate` whenever
|
|
169
|
+
* the selection changes — no `updateEffect` (and no microtask race) needed.
|
|
170
|
+
*/
|
|
171
|
+
protected willUpdate(_changed: Map<string, unknown>): void;
|
|
172
|
+
formResetCallback(): void;
|
|
173
|
+
formDisabledCallback(disabled: boolean): void;
|
|
174
|
+
formStateRestoreCallback(state: File | string | FormData | null): void;
|
|
175
|
+
selectOption(option: OptionElement): void;
|
|
176
|
+
deselectOption(option: OptionElement): void;
|
|
177
|
+
toggleOption(option: OptionElement): void;
|
|
178
|
+
[REGISTER_OPTION](option: OptionElement): void;
|
|
179
|
+
[UNREGISTER_OPTION](option: OptionElement): void;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
declare global {
|
|
183
|
+
interface HTMLElementTagNameMap {
|
|
184
|
+
/**
|
|
185
|
+
* Mirrors the currently-selected `<tp-option>`(s) of an ancestor
|
|
186
|
+
* `<tp-select>`, falling back to the host's `placeholder` text when
|
|
187
|
+
* the selection is empty.
|
|
188
|
+
*
|
|
189
|
+
* Discovers its host via `@lit/context`, so it can live anywhere in
|
|
190
|
+
* the descendant composed tree — including across nested shadow DOM
|
|
191
|
+
* boundaries. Selected options are deeply cloned and projected into
|
|
192
|
+
* this element's light DOM; clones are inert (they don't register
|
|
193
|
+
* back to the select) and carry `part="selected-content-option"`.
|
|
194
|
+
*
|
|
195
|
+
* Used as the default content of the `<tp-select>` trigger button,
|
|
196
|
+
* but can be placed anywhere a label-style mirror is useful.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```html
|
|
200
|
+
* <tp-select>
|
|
201
|
+
* <button slot="button">
|
|
202
|
+
* <tp-selected-content></tp-selected-content>
|
|
203
|
+
* </button>
|
|
204
|
+
* <tp-option value="apple">Apple</tp-option>
|
|
205
|
+
* </tp-select>
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
"tp-selected-content": SelectedContentElement;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
declare class SelectedContentElement extends SignalWatcherLitElement {
|
|
212
|
+
#private;
|
|
213
|
+
static styles: any;
|
|
214
|
+
private select?;
|
|
215
|
+
protected createRenderRoot(): this;
|
|
216
|
+
protected render(): unknown;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export { OptionElement, SelectElement, SelectedContentElement };
|
package/select/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const REGISTER_OPTION = Symbol("select:register-option");
|
|
4
|
+
const UNREGISTER_OPTION = Symbol("select:unregister-option");
|
|
5
|
+
const SHOULD_REGISTER_TO_SELECT = Symbol("option:should-register-to-select");
|
|
6
|
+
|
|
7
|
+
exports.REGISTER_OPTION = REGISTER_OPTION;
|
|
8
|
+
exports.SHOULD_REGISTER_TO_SELECT = SHOULD_REGISTER_TO_SELECT;
|
|
9
|
+
exports.UNREGISTER_OPTION = UNREGISTER_OPTION;
|
|
10
|
+
//# sourceMappingURL=internal-props.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-props.cjs","sources":["../../../../libs/elements/src/select/internal-props.ts"],"sourcesContent":[null],"names":[],"mappings":";;MAAa,eAAe,GAAG,MAAM,CAAC,wBAAwB;MACjD,iBAAiB,GAAG,MAAM,CAAC,0BAA0B;MACrD,yBAAyB,GAAG,MAAM,CAAC,kCAAkC;;;;;;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const REGISTER_OPTION = Symbol("select:register-option");
|
|
2
|
+
const UNREGISTER_OPTION = Symbol("select:unregister-option");
|
|
3
|
+
const SHOULD_REGISTER_TO_SELECT = Symbol("option:should-register-to-select");
|
|
4
|
+
|
|
5
|
+
export { REGISTER_OPTION, SHOULD_REGISTER_TO_SELECT, UNREGISTER_OPTION };
|
|
6
|
+
//# sourceMappingURL=internal-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-props.js","sources":["../../../../libs/elements/src/select/internal-props.ts"],"sourcesContent":[null],"names":[],"mappings":"MAAa,eAAe,GAAG,MAAM,CAAC,wBAAwB;MACjD,iBAAiB,GAAG,MAAM,CAAC,0BAA0B;MACrD,yBAAyB,GAAG,MAAM,CAAC,kCAAkC;;;;"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var lit = require('lit');
|
|
5
|
+
var decorators_js = require('lit/decorators.js');
|
|
6
|
+
var context = require('@lit/context');
|
|
7
|
+
var internalProps = require('./internal-props.cjs');
|
|
8
|
+
var selectContext = require('./select-context.cjs');
|
|
9
|
+
var signalWatcherLitElement = require('../utils/signal-watcher-lit-element.cjs');
|
|
10
|
+
|
|
11
|
+
var _a;
|
|
12
|
+
exports.OptionElement = class OptionElement extends signalWatcherLitElement.SignalWatcherLitElement {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this[_a] = true;
|
|
16
|
+
this.value = "";
|
|
17
|
+
}
|
|
18
|
+
static { _a = internalProps.SHOULD_REGISTER_TO_SELECT; }
|
|
19
|
+
static { this.styles = (() => {
|
|
20
|
+
const style = lit.css `
|
|
21
|
+
tp-option:not([part="selected-content-option"]) {
|
|
22
|
+
display: block;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
background: var(--tp-select-option-color, white);
|
|
25
|
+
|
|
26
|
+
&:hover {
|
|
27
|
+
background: color-mix(in xyz, var(--tp-select-option-color, white) calc(100% - var(--tp-select-highlight-percent, 20%)), black var(--tp-select-highlight-percent, 20%));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&[selected] {
|
|
31
|
+
background: var(--tp-select-selection-color, #0078d4);
|
|
32
|
+
color: var(--tp-select-selection-contrast-color, white);
|
|
33
|
+
|
|
34
|
+
&:hover {
|
|
35
|
+
background: color-mix(in xyz, var(--tp-select-selection-color, #0078d4) calc(100% - var(--tp-select-highlight-percent, 20%)), black var(--tp-select-highlight-percent, 20%));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
document.adoptedStyleSheets = [...document.adoptedStyleSheets, style.styleSheet];
|
|
41
|
+
return style;
|
|
42
|
+
})(); }
|
|
43
|
+
connectedCallback() {
|
|
44
|
+
super.connectedCallback();
|
|
45
|
+
if (!this[internalProps.SHOULD_REGISTER_TO_SELECT])
|
|
46
|
+
return;
|
|
47
|
+
this.select?.[internalProps.REGISTER_OPTION](this);
|
|
48
|
+
}
|
|
49
|
+
disconnectedCallback() {
|
|
50
|
+
super.disconnectedCallback();
|
|
51
|
+
if (!this[internalProps.SHOULD_REGISTER_TO_SELECT])
|
|
52
|
+
return;
|
|
53
|
+
this.select?.[internalProps.UNREGISTER_OPTION](this);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Reflect `selected` state by reading the parent's signal during the
|
|
57
|
+
* normal Lit update. `SignalWatcher` auto-tracks signal access here, so
|
|
58
|
+
* the option will re-render whenever the selection changes — without
|
|
59
|
+
* the disposal-race that `updateEffect` exposes.
|
|
60
|
+
*/
|
|
61
|
+
willUpdate(_changed) {
|
|
62
|
+
if (!this[internalProps.SHOULD_REGISTER_TO_SELECT])
|
|
63
|
+
return;
|
|
64
|
+
const next = this.select?.selectedOptions
|
|
65
|
+
.get()
|
|
66
|
+
.some((ref) => ref.deref() === this) ?? false;
|
|
67
|
+
this.toggleAttribute("selected", next);
|
|
68
|
+
}
|
|
69
|
+
createRenderRoot() {
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
render() {
|
|
73
|
+
return lit.html ``;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
tslib.__decorate([
|
|
77
|
+
context.consume({ context: selectContext.selectContext, subscribe: true }),
|
|
78
|
+
decorators_js.state(),
|
|
79
|
+
tslib.__metadata("design:type", Function)
|
|
80
|
+
], exports.OptionElement.prototype, "select", void 0);
|
|
81
|
+
tslib.__decorate([
|
|
82
|
+
decorators_js.property({ type: String, reflect: true }),
|
|
83
|
+
tslib.__metadata("design:type", Object)
|
|
84
|
+
], exports.OptionElement.prototype, "value", void 0);
|
|
85
|
+
exports.OptionElement = tslib.__decorate([
|
|
86
|
+
decorators_js.customElement("tp-option")
|
|
87
|
+
], exports.OptionElement);
|
|
88
|
+
//# sourceMappingURL=option.element.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"option.element.cjs","sources":["../../../../libs/elements/src/select/option.element.ts"],"sourcesContent":[null],"names":["OptionElement","SignalWatcherLitElement","SHOULD_REGISTER_TO_SELECT","css","REGISTER_OPTION","UNREGISTER_OPTION","html","__decorate","consume","selectContext","state","property","customElement"],"mappings":";;;;;;;;;;;AAsCaA,qBAAa,GAAnB,MAAM,aAAc,SAAQC,+CAAuB,CAAA;AAAnD,IAAA,WAAA,GAAA;;QAgCL,IAAA,CAAA,EAAA,CAA2B,GAAG,IAAI;QAGlC,IAAA,CAAA,KAAK,GAAG,EAAE;IAyCZ;kBA5CGC,uCAAyB,CAAA;aA/BnB,IAAA,CAAA,MAAM,GAAG,CAAC,MAAK;QACpB,MAAM,KAAK,GAAGC,OAAG,CAAA,CAAA;;;;;;;;;;;;;;;;;;;KAmBhB;AAED,QAAA,QAAQ,CAAC,kBAAkB,GAAG,CAAC,GAAG,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC,UAAW,CAAC;AAEjF,QAAA,OAAO,KAAK;IACd,CAAC,GAzBY,CAyBR;IAWI,iBAAiB,GAAA;QACxB,KAAK,CAAC,iBAAiB,EAAE;AAEzB,QAAA,IAAI,CAAC,IAAI,CAACD,uCAAyB,CAAC;YAAE;QAEtC,IAAI,CAAC,MAAM,GAAGE,6BAAe,CAAC,CAAC,IAAI,CAAC;IACtC;IAES,oBAAoB,GAAA;QAC3B,KAAK,CAAC,oBAAoB,EAAE;AAE5B,QAAA,IAAI,CAAC,IAAI,CAACF,uCAAyB,CAAC;YAAE;QAEtC,IAAI,CAAC,MAAM,GAAGG,+BAAiB,CAAC,CAAC,IAAI,CAAC;IACxC;AAEA;;;;;AAKG;AACgB,IAAA,UAAU,CAAC,QAAwB,EAAA;AACpD,QAAA,IAAI,CAAC,IAAI,CAACH,uCAAyB,CAAC;YAAE;AAEtC,QAAA,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE;AACvB,aAAA,GAAG;AACH,aAAA,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,EAAE,KAAK,IAAI,CAAC,IAAI,KAAK;AAE/C,QAAA,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC;IACxC;IAEmB,gBAAgB,GAAA;AACjC,QAAA,OAAO,IAAI;IACb;IAEmB,MAAM,GAAA;QACvB,OAAOI,QAAI,CAAA,CAAA,CAAE;IACf;;AA7CQC,gBAAA,CAAA;IAFPC,eAAO,CAAC,EAAE,OAAO,EAAEC,2BAAa,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACpD,IAAAC,mBAAK,EAAE;;AACuB,CAAA,EAAAV,qBAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AAK/BO,gBAAA,CAAA;IADCI,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;AAC/B,CAAA,EAAAX,qBAAA,CAAA,SAAA,EAAA,OAAA,EAAA,MAAA,CAAA;AAnCAA,qBAAa,GAAAO,gBAAA,CAAA;IADzBK,2BAAa,CAAC,WAAW;AACb,CAAA,EAAAZ,qBAAa,CA4EzB;;"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { __decorate, __metadata } from 'tslib';
|
|
2
|
+
import { css, html } from 'lit';
|
|
3
|
+
import { state, property, customElement } from 'lit/decorators.js';
|
|
4
|
+
import { consume } from '@lit/context';
|
|
5
|
+
import { SHOULD_REGISTER_TO_SELECT, REGISTER_OPTION, UNREGISTER_OPTION } from './internal-props.js';
|
|
6
|
+
import { selectContext } from './select-context.js';
|
|
7
|
+
import { SignalWatcherLitElement } from '../utils/signal-watcher-lit-element.js';
|
|
8
|
+
|
|
9
|
+
var _a;
|
|
10
|
+
let OptionElement = class OptionElement extends SignalWatcherLitElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this[_a] = true;
|
|
14
|
+
this.value = "";
|
|
15
|
+
}
|
|
16
|
+
static { _a = SHOULD_REGISTER_TO_SELECT; }
|
|
17
|
+
static { this.styles = (() => {
|
|
18
|
+
const style = css `
|
|
19
|
+
tp-option:not([part="selected-content-option"]) {
|
|
20
|
+
display: block;
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
background: var(--tp-select-option-color, white);
|
|
23
|
+
|
|
24
|
+
&:hover {
|
|
25
|
+
background: color-mix(in xyz, var(--tp-select-option-color, white) calc(100% - var(--tp-select-highlight-percent, 20%)), black var(--tp-select-highlight-percent, 20%));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&[selected] {
|
|
29
|
+
background: var(--tp-select-selection-color, #0078d4);
|
|
30
|
+
color: var(--tp-select-selection-contrast-color, white);
|
|
31
|
+
|
|
32
|
+
&:hover {
|
|
33
|
+
background: color-mix(in xyz, var(--tp-select-selection-color, #0078d4) calc(100% - var(--tp-select-highlight-percent, 20%)), black var(--tp-select-highlight-percent, 20%));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
document.adoptedStyleSheets = [...document.adoptedStyleSheets, style.styleSheet];
|
|
39
|
+
return style;
|
|
40
|
+
})(); }
|
|
41
|
+
connectedCallback() {
|
|
42
|
+
super.connectedCallback();
|
|
43
|
+
if (!this[SHOULD_REGISTER_TO_SELECT])
|
|
44
|
+
return;
|
|
45
|
+
this.select?.[REGISTER_OPTION](this);
|
|
46
|
+
}
|
|
47
|
+
disconnectedCallback() {
|
|
48
|
+
super.disconnectedCallback();
|
|
49
|
+
if (!this[SHOULD_REGISTER_TO_SELECT])
|
|
50
|
+
return;
|
|
51
|
+
this.select?.[UNREGISTER_OPTION](this);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Reflect `selected` state by reading the parent's signal during the
|
|
55
|
+
* normal Lit update. `SignalWatcher` auto-tracks signal access here, so
|
|
56
|
+
* the option will re-render whenever the selection changes — without
|
|
57
|
+
* the disposal-race that `updateEffect` exposes.
|
|
58
|
+
*/
|
|
59
|
+
willUpdate(_changed) {
|
|
60
|
+
if (!this[SHOULD_REGISTER_TO_SELECT])
|
|
61
|
+
return;
|
|
62
|
+
const next = this.select?.selectedOptions
|
|
63
|
+
.get()
|
|
64
|
+
.some((ref) => ref.deref() === this) ?? false;
|
|
65
|
+
this.toggleAttribute("selected", next);
|
|
66
|
+
}
|
|
67
|
+
createRenderRoot() {
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
render() {
|
|
71
|
+
return html ``;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
__decorate([
|
|
75
|
+
consume({ context: selectContext, subscribe: true }),
|
|
76
|
+
state(),
|
|
77
|
+
__metadata("design:type", Function)
|
|
78
|
+
], OptionElement.prototype, "select", void 0);
|
|
79
|
+
__decorate([
|
|
80
|
+
property({ type: String, reflect: true }),
|
|
81
|
+
__metadata("design:type", Object)
|
|
82
|
+
], OptionElement.prototype, "value", void 0);
|
|
83
|
+
OptionElement = __decorate([
|
|
84
|
+
customElement("tp-option")
|
|
85
|
+
], OptionElement);
|
|
86
|
+
|
|
87
|
+
export { OptionElement };
|
|
88
|
+
//# sourceMappingURL=option.element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"option.element.js","sources":["../../../../libs/elements/src/select/option.element.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AAsCO,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,uBAAuB,CAAA;AAAnD,IAAA,WAAA,GAAA;;QAgCL,IAAA,CAAA,EAAA,CAA2B,GAAG,IAAI;QAGlC,IAAA,CAAA,KAAK,GAAG,EAAE;IAyCZ;kBA5CG,yBAAyB,CAAA;aA/BnB,IAAA,CAAA,MAAM,GAAG,CAAC,MAAK;QACpB,MAAM,KAAK,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;;;;;;;;KAmBhB;AAED,QAAA,QAAQ,CAAC,kBAAkB,GAAG,CAAC,GAAG,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC,UAAW,CAAC;AAEjF,QAAA,OAAO,KAAK;IACd,CAAC,GAzBY,CAyBR;IAWI,iBAAiB,GAAA;QACxB,KAAK,CAAC,iBAAiB,EAAE;AAEzB,QAAA,IAAI,CAAC,IAAI,CAAC,yBAAyB,CAAC;YAAE;QAEtC,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC,CAAC,IAAI,CAAC;IACtC;IAES,oBAAoB,GAAA;QAC3B,KAAK,CAAC,oBAAoB,EAAE;AAE5B,QAAA,IAAI,CAAC,IAAI,CAAC,yBAAyB,CAAC;YAAE;QAEtC,IAAI,CAAC,MAAM,GAAG,iBAAiB,CAAC,CAAC,IAAI,CAAC;IACxC;AAEA;;;;;AAKG;AACgB,IAAA,UAAU,CAAC,QAAwB,EAAA;AACpD,QAAA,IAAI,CAAC,IAAI,CAAC,yBAAyB,CAAC;YAAE;AAEtC,QAAA,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE;AACvB,aAAA,GAAG;AACH,aAAA,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,EAAE,KAAK,IAAI,CAAC,IAAI,KAAK;AAE/C,QAAA,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC;IACxC;IAEmB,gBAAgB,GAAA;AACjC,QAAA,OAAO,IAAI;IACb;IAEmB,MAAM,GAAA;QACvB,OAAO,IAAI,CAAA,CAAA,CAAE;IACf;;AA7CQ,UAAA,CAAA;IAFP,OAAO,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACpD,IAAA,KAAK,EAAE;;AACuB,CAAA,EAAA,aAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AAK/B,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;AAC/B,CAAA,EAAA,aAAA,CAAA,SAAA,EAAA,OAAA,EAAA,MAAA,CAAA;AAnCA,aAAa,GAAA,UAAA,CAAA;IADzB,aAAa,CAAC,WAAW;AACb,CAAA,EAAA,aAAa,CA4EzB;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var context = require('@lit/context');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Context key carrying the host `<tp-select>` element down through the
|
|
7
|
+
* composed tree. Using `@lit/context` means consumers can be nested inside
|
|
8
|
+
* any number of shadow DOM boundaries and still find their `<tp-select>`
|
|
9
|
+
* via the bubbling, composed `context-request` event.
|
|
10
|
+
*/
|
|
11
|
+
const selectContext = context.createContext(Symbol("tp-select"));
|
|
12
|
+
|
|
13
|
+
exports.selectContext = selectContext;
|
|
14
|
+
//# sourceMappingURL=select-context.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-context.cjs","sources":["../../../../libs/elements/src/select/select-context.ts"],"sourcesContent":[null],"names":["createContext"],"mappings":";;;;AAIA;;;;;AAKG;AACI,MAAM,aAAa,GAAGA,qBAAa,CACxC,MAAM,CAAC,WAAW,CAAC;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createContext } from '@lit/context';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Context key carrying the host `<tp-select>` element down through the
|
|
5
|
+
* composed tree. Using `@lit/context` means consumers can be nested inside
|
|
6
|
+
* any number of shadow DOM boundaries and still find their `<tp-select>`
|
|
7
|
+
* via the bubbling, composed `context-request` event.
|
|
8
|
+
*/
|
|
9
|
+
const selectContext = createContext(Symbol("tp-select"));
|
|
10
|
+
|
|
11
|
+
export { selectContext };
|
|
12
|
+
//# sourceMappingURL=select-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-context.js","sources":["../../../../libs/elements/src/select/select-context.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAIA;;;;;AAKG;AACI,MAAM,aAAa,GAAG,aAAa,CACxC,MAAM,CAAC,WAAW,CAAC;;;;"}
|