@rak200/ui 0.2.19 → 0.4.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/README.md +12 -23
- package/dist/checkbox.d.ts +250 -25
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/checkbox.js +368 -77
- package/dist/checkbox.js.map +1 -1
- package/dist/field.d.ts +8 -2
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +8 -2
- package/dist/field.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/input.d.ts +330 -33
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +355 -64
- package/dist/input.js.map +1 -1
- package/dist/radio.d.ts +2 -2
- package/dist/radio.js +2 -2
- package/dist/select.d.ts +220 -14
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +381 -26
- package/dist/select.js.map +1 -1
- package/dist/tooltip.js +1 -1
- package/package.json +1 -1
package/dist/select.d.ts
CHANGED
|
@@ -1,12 +1,117 @@
|
|
|
1
1
|
import { LitElement, type CSSResult, type TemplateResult } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* What {@link UiOption} and {@link UiOptgroup} have in common, which is that they draw
|
|
4
|
+
* nothing.
|
|
5
|
+
*
|
|
6
|
+
* **A declaration rather than a control**, and the first of its kind here: every other
|
|
7
|
+
* element in this package renders something a person can see. These two exist so that the
|
|
8
|
+
* choices a host writes stay markup, while the thing the platform actually needs — real
|
|
9
|
+
* `<option>` elements inside a real `<select>` — is built from them.
|
|
10
|
+
*
|
|
11
|
+
* They announce themselves on every update, and that is the half a `MutationObserver`
|
|
12
|
+
* cannot do: `option.selected = true` is a property write, and no observer reports one.
|
|
13
|
+
* Measured on the shape this replaced, where the control simply never moved. Because these
|
|
14
|
+
* are this package's own elements the property is reactive, so the announcement is the
|
|
15
|
+
* platform's own change detection rather than a watcher over somebody else's element.
|
|
16
|
+
*
|
|
17
|
+
* **Arriving and leaving are announced from the slot rather than from a callback**, and
|
|
18
|
+
* that is measured rather than chosen: an event dispatched from `disconnectedCallback` has
|
|
19
|
+
* no path left to bubble along — the option is already out of the tree, and the removal
|
|
20
|
+
* never reached the select. A slot reports both directions, which is the thing it exists
|
|
21
|
+
* to tell you.
|
|
22
|
+
*
|
|
23
|
+
* **Each declaration carries its own slot, and that is why**: a slot reports only the
|
|
24
|
+
* nodes assigned to *it*, so `<ui-select>`'s own slot sees a choice added or removed at the
|
|
25
|
+
* top level and sees nothing at all when one moves inside an `<ui-optgroup>`. Measured, as
|
|
26
|
+
* a removal from inside a group that left the control showing a choice that was gone.
|
|
27
|
+
*/
|
|
28
|
+
declare class UiDeclaration extends LitElement {
|
|
29
|
+
#private;
|
|
30
|
+
static readonly styles: CSSResult;
|
|
31
|
+
updated(): void;
|
|
32
|
+
render(): TemplateResult;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* One choice in a {@link UiSelect}.
|
|
36
|
+
*
|
|
37
|
+
* The text is what the reader sees; `value` is what a form submits. `selected` is the
|
|
38
|
+
* **default** — the choice the control starts on and returns to on reset — which is what
|
|
39
|
+
* `selected` means on a native `<option>`.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```html
|
|
43
|
+
* <ui-option value="brl">Real</ui-option>
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare class UiOption extends UiDeclaration {
|
|
47
|
+
static readonly properties: {
|
|
48
|
+
value: {
|
|
49
|
+
type: StringConstructor;
|
|
50
|
+
reflect: boolean;
|
|
51
|
+
};
|
|
52
|
+
selected: {
|
|
53
|
+
type: BooleanConstructor;
|
|
54
|
+
reflect: boolean;
|
|
55
|
+
};
|
|
56
|
+
disabled: {
|
|
57
|
+
type: BooleanConstructor;
|
|
58
|
+
reflect: boolean;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* What a form submits when this is the choice made.
|
|
63
|
+
*
|
|
64
|
+
* A plain field rather than the `accessor` keyword, for the reason `src/button.ts`
|
|
65
|
+
* gives beside its own.
|
|
66
|
+
*/
|
|
67
|
+
value: string;
|
|
68
|
+
/** Whether this is the choice the control starts on. */
|
|
69
|
+
selected: boolean;
|
|
70
|
+
/** Whether this choice can be made at all. */
|
|
71
|
+
disabled: boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A named set of choices, which the platform draws as a heading inside the list.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```html
|
|
78
|
+
* <ui-optgroup label="Americas">
|
|
79
|
+
* <ui-option value="brl">Real</ui-option>
|
|
80
|
+
* </ui-optgroup>
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare class UiOptgroup extends UiDeclaration {
|
|
84
|
+
static readonly properties: {
|
|
85
|
+
label: {
|
|
86
|
+
type: StringConstructor;
|
|
87
|
+
reflect: boolean;
|
|
88
|
+
};
|
|
89
|
+
disabled: {
|
|
90
|
+
type: BooleanConstructor;
|
|
91
|
+
reflect: boolean;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
/** The heading the platform draws above the set. */
|
|
95
|
+
label: string;
|
|
96
|
+
/** Whether every choice in the set is unavailable. */
|
|
97
|
+
disabled: boolean;
|
|
98
|
+
}
|
|
2
99
|
/**
|
|
3
100
|
* A native `<select>`, styled by the token layer rather than replaced.
|
|
4
101
|
*
|
|
5
|
-
* **The `<select>` is
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
102
|
+
* **The `<select>` is this element's**, rendered into its shadow root with its label, its
|
|
103
|
+
* help and its message, so the IDREFs resolve in one tree scope. What a host writes is the
|
|
104
|
+
* tag, its attributes, and the choices — as {@link UiOption} and {@link UiOptgroup}.
|
|
105
|
+
*
|
|
106
|
+
* **The choices could not stay as `<option>`s**, and that is measured rather than
|
|
107
|
+
* preferred: a `<slot>` inside a `<select>` assigns the nodes and the select sees none of
|
|
108
|
+
* them. `HTMLSelectElement.options` is built from its own children, not from the flattened
|
|
109
|
+
* tree — `options.length` was `0`, `value` empty and `selectedIndex` `-1`, with two options
|
|
110
|
+
* assigned. So the choices are declarations this package owns, and the `<option>` elements
|
|
111
|
+
* the platform needs are built from them.
|
|
112
|
+
*
|
|
113
|
+
* The element joins the form itself, through `ElementInternals`: a control in a shadow root
|
|
114
|
+
* has no form owner.
|
|
10
115
|
*
|
|
11
116
|
* **The native element is the decision, not a shortcut.** A custom listbox is an
|
|
12
117
|
* accessibility project of its own, and it would have to reimplement the platform picker
|
|
@@ -31,24 +136,125 @@ import { LitElement, type CSSResult, type TemplateResult } from 'lit';
|
|
|
31
136
|
*
|
|
32
137
|
* @example
|
|
33
138
|
* ```html
|
|
34
|
-
* <ui-
|
|
35
|
-
* <
|
|
36
|
-
* <ui-
|
|
37
|
-
*
|
|
38
|
-
* <option value="brl">Real</option>
|
|
39
|
-
* <option value="usd">Dollar</option>
|
|
40
|
-
* </select>
|
|
41
|
-
* </ui-select>
|
|
42
|
-
* </ui-field>
|
|
139
|
+
* <ui-select label="Currency" name="currency">
|
|
140
|
+
* <ui-option value="brl">Real</ui-option>
|
|
141
|
+
* <ui-option value="usd">Dollar</ui-option>
|
|
142
|
+
* </ui-select>
|
|
43
143
|
* ```
|
|
44
144
|
*/
|
|
45
145
|
export declare class UiSelect extends LitElement {
|
|
146
|
+
#private;
|
|
46
147
|
static readonly styles: CSSResult;
|
|
148
|
+
static readonly formAssociated = true;
|
|
149
|
+
/**
|
|
150
|
+
* Focus is delegated, so `focus()` and `reportValidity()` reach the control — the host
|
|
151
|
+
* is not a focusable element, and the second is what the browser calls itself when a
|
|
152
|
+
* form with an invalid control is submitted.
|
|
153
|
+
*/
|
|
154
|
+
static readonly shadowRootOptions: {
|
|
155
|
+
delegatesFocus: boolean;
|
|
156
|
+
clonable?: boolean;
|
|
157
|
+
customElementRegistry?: CustomElementRegistry | null;
|
|
158
|
+
mode: ShadowRootMode;
|
|
159
|
+
serializable?: boolean;
|
|
160
|
+
slotAssignment?: SlotAssignmentMode;
|
|
161
|
+
};
|
|
162
|
+
static readonly properties: {
|
|
163
|
+
label: {
|
|
164
|
+
type: StringConstructor;
|
|
165
|
+
reflect: boolean;
|
|
166
|
+
};
|
|
167
|
+
help: {
|
|
168
|
+
type: StringConstructor;
|
|
169
|
+
reflect: boolean;
|
|
170
|
+
};
|
|
171
|
+
error: {
|
|
172
|
+
type: StringConstructor;
|
|
173
|
+
reflect: boolean;
|
|
174
|
+
};
|
|
175
|
+
name: {
|
|
176
|
+
type: StringConstructor;
|
|
177
|
+
reflect: boolean;
|
|
178
|
+
};
|
|
179
|
+
value: {
|
|
180
|
+
type: StringConstructor;
|
|
181
|
+
};
|
|
182
|
+
required: {
|
|
183
|
+
type: BooleanConstructor;
|
|
184
|
+
reflect: boolean;
|
|
185
|
+
};
|
|
186
|
+
disabled: {
|
|
187
|
+
type: BooleanConstructor;
|
|
188
|
+
reflect: boolean;
|
|
189
|
+
};
|
|
190
|
+
multiple: {
|
|
191
|
+
type: BooleanConstructor;
|
|
192
|
+
reflect: boolean;
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* The accessible name, and the text above the control.
|
|
197
|
+
*
|
|
198
|
+
* A plain field rather than the `accessor` keyword, for the reason `src/button.ts`
|
|
199
|
+
* gives beside its own — and so for every property below.
|
|
200
|
+
*/
|
|
201
|
+
label: string;
|
|
202
|
+
/** Supporting text under the control, which survives an error rather than yielding. */
|
|
203
|
+
help: string;
|
|
204
|
+
/** The message, which paints the boundary and is announced with the control. */
|
|
205
|
+
error: string;
|
|
206
|
+
/**
|
|
207
|
+
* The name the value is submitted under.
|
|
208
|
+
*
|
|
209
|
+
* **Reflected, and that is a requirement rather than a convenience.** A form names a
|
|
210
|
+
* form-associated custom element's entry from the content attribute, so a host who set
|
|
211
|
+
* only the property would submit nothing at all — silently.
|
|
212
|
+
*/
|
|
213
|
+
name: string;
|
|
214
|
+
/**
|
|
215
|
+
* The choice currently made.
|
|
216
|
+
*
|
|
217
|
+
* **Empty means _the declared default_ rather than _nothing_**, which is what lets an
|
|
218
|
+
* `<ui-option selected>` mean what `<option selected>` means and a reset return to it.
|
|
219
|
+
* Not reflected, the way a native control's `value` IDL attribute is not.
|
|
220
|
+
*/
|
|
221
|
+
value: string;
|
|
222
|
+
/** Whether a form is invalid while no choice is made. */
|
|
223
|
+
required: boolean;
|
|
224
|
+
/** Whether the control refuses interaction, and submits nothing. */
|
|
225
|
+
disabled: boolean;
|
|
226
|
+
/** Whether the control is a list rather than a drop-down. */
|
|
227
|
+
multiple: boolean;
|
|
228
|
+
connectedCallback(): void;
|
|
229
|
+
/**
|
|
230
|
+
* The value and the validity, which move together here or disagree anywhere.
|
|
231
|
+
*
|
|
232
|
+
* **Iterated rather than asserted**, and there is exactly one control to iterate —
|
|
233
|
+
* `render()` puts it there unconditionally. A query and a null check would put a branch
|
|
234
|
+
* here that no test could reach, which is a coverage hole and an immortal mutant at
|
|
235
|
+
* once rather than safety. `src/input.ts` carries the same shape for the same reason.
|
|
236
|
+
*/
|
|
237
|
+
updated(): void;
|
|
238
|
+
/** A form reset, which returns to the choice the declarations name. */
|
|
239
|
+
formResetCallback(): void;
|
|
240
|
+
/** A `<fieldset disabled>` above this element, which reaches it and nothing below. */
|
|
241
|
+
formDisabledCallback(disabled: boolean): void;
|
|
242
|
+
/** Restoring after a back-navigation, where the browser hands the value back. */
|
|
243
|
+
formStateRestoreCallback(state: string | null): void;
|
|
244
|
+
/** The form this element participates in, for a host that needs it. */
|
|
245
|
+
get form(): HTMLFormElement | null;
|
|
246
|
+
/** Whether the control currently satisfies its constraints. */
|
|
247
|
+
get validity(): ValidityState;
|
|
248
|
+
/** The message a form would report for it, empty while the control is valid. */
|
|
249
|
+
get validationMessage(): string;
|
|
47
250
|
render(): TemplateResult;
|
|
48
251
|
}
|
|
49
252
|
declare global {
|
|
50
253
|
interface HTMLElementTagNameMap {
|
|
51
254
|
'ui-select': UiSelect;
|
|
255
|
+
'ui-option': UiOption;
|
|
256
|
+
'ui-optgroup': UiOptgroup;
|
|
52
257
|
}
|
|
53
258
|
}
|
|
259
|
+
export {};
|
|
54
260
|
//# sourceMappingURL=select.d.ts.map
|
package/dist/select.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../src/select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../src/select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAiC1F;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,cAAM,aAAc,SAAQ,UAAU;;IAClC,gBAAyB,MAAM,EAAE,SAAS,CAIxC;IAEO,OAAO,IAAI,IAAI;IAQf,MAAM,IAAI,cAAc;CAGpC;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,QAAS,SAAQ,aAAa;IACvC,gBAAyB,UAAU;;;;;;;;;;;;;MAIjC;IAEF;;;;;OAKG;IACH,KAAK,SAAM;IAEX,wDAAwD;IACxD,QAAQ,UAAS;IAEjB,8CAA8C;IAC9C,QAAQ,UAAS;CACpB;AAED;;;;;;;;;GASG;AACH,qBAAa,UAAW,SAAQ,aAAa;IACzC,gBAAyB,UAAU;;;;;;;;;MAGjC;IAEF,oDAAoD;IACpD,KAAK,SAAM;IAEX,sDAAsD;IACtD,QAAQ,UAAS;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,qBAAa,QAAS,SAAQ,UAAU;;IACpC,gBAAyB,MAAM,EAAE,SAAS,CA6HxC;IAEF,MAAM,CAAC,QAAQ,CAAC,cAAc,QAAQ;IAEtC;;;;OAIG;IACH,gBAAyB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