@oscarpalmer/oui 0.35.0 → 0.37.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/dist/css/badge.css +18 -15
- package/dist/css/button.css +35 -31
- package/dist/css/color.css +20 -20
- package/dist/css/combobox.css +134 -35
- package/dist/css/content.css +29 -10
- package/dist/css/floatable.css +10 -10
- package/dist/css/form.css +393 -129
- package/dist/css/listbox.css +176 -0
- package/dist/css/message.css +13 -10
- package/dist/css/reset.css +29 -88
- package/dist/css/splitter.css +2 -2
- package/dist/css/tabs.css +103 -0
- package/dist/js/combobox/constants.combobox.d.mts +2 -2
- package/dist/js/combobox/constants.combobox.mjs +40 -33
- package/dist/js/combobox/dom.combobox.d.mts +8 -91
- package/dist/js/combobox/dom.combobox.mjs +204 -2
- package/dist/js/combobox/event.combobox.d.mts +14 -8
- package/dist/js/combobox/event.combobox.mjs +2 -2
- package/dist/js/combobox/index.d.mts +1 -1
- package/dist/js/combobox/index.mjs +20 -18
- package/dist/js/combobox/misc.combobox.d.mts +2 -2
- package/dist/js/combobox/misc.combobox.mjs +2 -2
- package/dist/js/combobox/models.combobox.d.mts +44 -2
- package/dist/js/combobox/state.combobox.d.mts +9 -10
- package/dist/js/combobox/state.combobox.mjs +2 -2
- package/dist/js/constants.combobox-DmRAMC64.d.mts +26 -0
- package/dist/js/constants.listbox-DRsXUxd3.d.mts +14 -0
- package/dist/js/focus-trap/focus-trap.embedded.mjs +6 -10
- package/dist/js/index-EfkUSals.d.mts +139 -0
- package/dist/js/index.d.mts +5 -2
- package/dist/js/index.mjs +5 -2
- package/dist/js/internal/attributable.mjs +4 -3
- package/dist/js/internal/draggable.mjs +16 -22
- package/dist/js/internal/listbox/listbox.constants.d.mts +11 -0
- package/dist/js/internal/listbox/listbox.constants.mjs +23 -0
- package/dist/js/internal/listbox/listbox.data.d.mts +20 -0
- package/dist/js/internal/listbox/listbox.data.mjs +2 -0
- package/dist/js/internal/listbox/listbox.dom.d.mts +66 -0
- package/dist/js/internal/listbox/listbox.dom.mjs +2 -0
- package/dist/js/internal/listbox/listbox.event.d.mts +5 -0
- package/dist/js/internal/listbox/listbox.event.mjs +63 -0
- package/dist/js/internal/listbox/listbox.form.d.mts +6 -0
- package/dist/js/internal/listbox/listbox.form.mjs +52 -0
- package/dist/js/internal/listbox/listbox.misc.d.mts +12 -0
- package/dist/js/internal/listbox/listbox.misc.mjs +2 -0
- package/dist/js/internal/listbox/listbox.model.d.mts +2 -0
- package/dist/js/internal/listbox/listbox.model.mjs +1 -0
- package/dist/js/internal/listbox/listbox.state.d.mts +7 -0
- package/dist/js/internal/listbox/listbox.state.mjs +40 -0
- package/dist/js/internal/misc.d.mts +6 -0
- package/dist/js/internal/misc.mjs +13 -0
- package/dist/js/internal/navigable.d.mts +11 -5
- package/dist/js/internal/navigable.mjs +44 -18
- package/dist/js/l10n-Bn-7RcwR.d.mts +20 -0
- package/dist/js/l10n.d.mts +2 -20
- package/dist/js/listbox/constants.listbox.d.mts +2 -0
- package/dist/js/listbox/constants.listbox.mjs +40 -0
- package/dist/js/listbox/event.listbox.d.mts +8 -0
- package/dist/js/listbox/event.listbox.mjs +2 -0
- package/dist/js/listbox/index.d.mts +116 -0
- package/dist/js/listbox/index.mjs +189 -0
- package/dist/js/listbox/misc.listbox.d.mts +2 -0
- package/dist/js/listbox/misc.listbox.mjs +2 -0
- package/dist/js/listbox/state.listbox.d.mts +11 -0
- package/dist/js/listbox/state.listbox.mjs +2 -0
- package/dist/js/listbox.data-BWd0PCy7.mjs +424 -0
- package/dist/js/listbox.model-CRReGOmu.d.mts +125 -0
- package/dist/js/misc.listbox-BI-XsTOf.mjs +197 -0
- package/dist/js/misc.listbox-gnoJhrTr.d.mts +20 -0
- package/dist/js/movable/movable.embedded.mjs +3 -6
- package/dist/js/resizable/resizable.embedded.mjs +16 -26
- package/dist/js/sortable/sortable.embedded.mjs +4 -2
- package/dist/js/splitter.mjs +15 -12
- package/dist/js/state.combobox-4xq0FPCF.mjs +365 -0
- package/dist/js/tabs.d.mts +25 -0
- package/dist/js/tabs.mjs +240 -0
- package/dist/js/tooltip.mjs +13 -12
- package/package.json +7 -3
- package/src/css/badge.scss +6 -18
- package/src/css/button.scss +6 -45
- package/src/css/color.scss +20 -20
- package/src/css/combobox.scss +21 -52
- package/src/css/content.scss +30 -3
- package/src/css/floatable.scss +17 -17
- package/src/css/form.scss +84 -72
- package/src/css/listbox.scss +120 -0
- package/src/css/message.scss +13 -28
- package/src/css/mixins.scss +253 -28
- package/src/css/reset.scss +37 -86
- package/src/css/splitter.scss +2 -2
- package/src/css/tabs.scss +85 -0
- package/src/js/combobox/constants.combobox.ts +46 -25
- package/src/js/combobox/dom.combobox.ts +36 -454
- package/src/js/combobox/event.combobox.ts +129 -218
- package/src/js/combobox/index.ts +37 -30
- package/src/js/combobox/misc.combobox.ts +30 -114
- package/src/js/combobox/models.combobox.ts +7 -47
- package/src/js/combobox/state.combobox.ts +126 -127
- package/src/js/focus-trap/focus-trap.embedded.ts +11 -19
- package/src/js/index.ts +2 -0
- package/src/js/internal/draggable.ts +29 -33
- package/src/js/internal/listbox/listbox.constants.ts +25 -0
- package/src/js/{combobox/data.combobox.ts → internal/listbox/listbox.data.ts} +94 -43
- package/src/js/internal/listbox/listbox.dom.ts +445 -0
- package/src/js/internal/listbox/listbox.event.ts +129 -0
- package/src/js/{combobox/form.combobox.ts → internal/listbox/listbox.form.ts} +13 -14
- package/src/js/internal/listbox/listbox.misc.ts +135 -0
- package/src/js/internal/listbox/listbox.model.ts +169 -0
- package/src/js/internal/listbox/listbox.state.ts +82 -0
- package/src/js/internal/misc.ts +27 -0
- package/src/js/internal/navigable.ts +80 -23
- package/src/js/l10n.ts +8 -8
- package/src/js/listbox/constants.listbox.ts +61 -0
- package/src/js/listbox/event.listbox.ts +106 -0
- package/src/js/listbox/index.ts +302 -0
- package/src/js/listbox/misc.listbox.ts +70 -0
- package/src/js/listbox/state.listbox.ts +196 -0
- package/src/js/movable/movable.embedded.ts +11 -13
- package/src/js/resizable/resizable.embedded.ts +25 -39
- package/src/js/splitter.ts +21 -18
- package/src/js/tabs.ts +447 -0
- package/src/js/tooltip.ts +20 -17
- package/dist/js/combobox/data.combobox.d.mts +0 -18
- package/dist/js/combobox/data.combobox.mjs +0 -2
- package/dist/js/combobox/form.combobox.d.mts +0 -6
- package/dist/js/combobox/form.combobox.mjs +0 -2
- package/dist/js/constants.combobox-h_kyDegw.d.mts +0 -248
- package/dist/js/data.combobox-B8HMkDOh.mjs +0 -1030
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
|
|
2
|
+
:where(oui-tabs) {
|
|
3
|
+
display: flex;
|
|
4
|
+
}
|
|
5
|
+
:where(oui-tabs[orientation=horizontal i]) {
|
|
6
|
+
flex-flow: column nowrap;
|
|
7
|
+
}
|
|
8
|
+
:where(oui-tabs[orientation=vertical i]) {
|
|
9
|
+
flex-flow: row nowrap;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
:where([oui-tabs-content]) {
|
|
13
|
+
padding: 1em;
|
|
14
|
+
flex: 1;
|
|
15
|
+
background-color: var(--oui-absolute);
|
|
16
|
+
}
|
|
17
|
+
:where(oui-tabs[orientation=horizontal i] > [oui-tabs-content]) {
|
|
18
|
+
border-radius: 0 0 0.5em 0.5em;
|
|
19
|
+
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.125), inset 0 1px 2px -0.5px rgba(0, 0, 0, 0.05), inset 0 2px 4px -1px rgba(0, 0, 0, 0.05);
|
|
20
|
+
}
|
|
21
|
+
:where(oui-tabs[orientation=vertical i] > [oui-tabs-content]) {
|
|
22
|
+
border-radius: 0 0.5em 0.5em 0;
|
|
23
|
+
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.125), inset 1px 1px 2px -0.5px rgba(0, 0, 0, 0.05), inset 2px 2px 4px -1px rgba(0, 0, 0, 0.05);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
:where([oui-tabs-tab]) {
|
|
27
|
+
--oui-background-percentage: 25%;
|
|
28
|
+
--oui-background-value: var(--oui-gray-2);
|
|
29
|
+
--oui-foreground-percentage: 0%;
|
|
30
|
+
--oui-foreground-value: var(--oui-gray-8);
|
|
31
|
+
--oui-outline-percentage: 100%;
|
|
32
|
+
--oui-outline-value: var(--oui-gray-6);
|
|
33
|
+
--oui-shadow-inset: color-mix(in oklab, var(--oui-absolute), transparent 75%);
|
|
34
|
+
--oui-shadow-percentage: 82.5%;
|
|
35
|
+
--oui-shadow-value: color-mix(
|
|
36
|
+
in oklab,
|
|
37
|
+
var(--oui-outline-value),
|
|
38
|
+
transparent var(--oui-shadow-percentage)
|
|
39
|
+
);
|
|
40
|
+
box-shadow: inset 0 1px 0 0 var(--oui-shadow-inset), 0 0 0 1px var(--oui-shadow-value), 0 1px 2px -0.5px var(--oui-shadow-value), 0 2px 4px -1px var(--oui-shadow-value), 0 4px 8px -2px var(--oui-shadow-value);
|
|
41
|
+
padding: 0.5em 0.75em;
|
|
42
|
+
display: inline-flex;
|
|
43
|
+
flex-flow: row wrap;
|
|
44
|
+
gap: 0.75em;
|
|
45
|
+
align-items: center;
|
|
46
|
+
border-radius: 0.25em;
|
|
47
|
+
background-color: color-mix(in oklab, var(--oui-background-value), transparent var(--oui-background-percentage));
|
|
48
|
+
outline: 4px solid color-mix(in oklab, var(--oui-outline-value), transparent var(--oui-outline-percentage));
|
|
49
|
+
border: none;
|
|
50
|
+
color: color-mix(in oklab, var(--oui-foreground-value), transparent var(--oui-foreground-percentage));
|
|
51
|
+
line-height: 1.25;
|
|
52
|
+
transition: 0.125s ease-in-out;
|
|
53
|
+
transition-property: background, outline, box-shadow, color;
|
|
54
|
+
}
|
|
55
|
+
:where([oui-tabs-tab]):focus-visible {
|
|
56
|
+
--oui-outline-percentage: 75%;
|
|
57
|
+
}
|
|
58
|
+
@media (hover: hover) {
|
|
59
|
+
:where([oui-tabs-tab]):not([disabled], [aria-disabled=true i]):hover {
|
|
60
|
+
--oui-background-percentage: 50%;
|
|
61
|
+
--oui-foreground-percentage: 25%;
|
|
62
|
+
--oui-shadow-percentage: 90%;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
:where([oui-tabs-tab]):not([disabled], [aria-disabled=true i]):active {
|
|
66
|
+
box-shadow: 0 0 0 1px var(--oui-shadow-value), inset 0 1px 2px 0 var(--oui-shadow-value), inset 0 2px 4px 0 var(--oui-shadow-value);
|
|
67
|
+
}
|
|
68
|
+
:where([oui-tabs-tab])[disabled], :where([oui-tabs-tab])[aria-disabled=true i] {
|
|
69
|
+
--oui-background-percentage: 80%;
|
|
70
|
+
--oui-foreground-percentage: 25%;
|
|
71
|
+
--oui-shadow-percentage: 92.5%;
|
|
72
|
+
font-style: italic;
|
|
73
|
+
}
|
|
74
|
+
:where([oui-tabs-tab]) {
|
|
75
|
+
--oui-background-value: var(--oui-blue-3);
|
|
76
|
+
--oui-foreground-value: var(--oui-blue-8);
|
|
77
|
+
--oui-outline-value: var(--oui-blue-6);
|
|
78
|
+
font-size: 0.875rem;
|
|
79
|
+
align-self: flex-end;
|
|
80
|
+
}
|
|
81
|
+
:where([oui-tabs-tab][aria-selected=true i]) {
|
|
82
|
+
--oui-background-percentage: 80%;
|
|
83
|
+
box-shadow: 0 0 0 1px var(--oui-shadow-value), inset 0 1px 2px -0.5px var(--oui-shadow-value), inset 0 2px 4px -1px var(--oui-shadow-value);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
:where([oui-tabs-tablist]) {
|
|
87
|
+
display: flex;
|
|
88
|
+
gap: 0.5em;
|
|
89
|
+
}
|
|
90
|
+
:where([oui-tabs-tablist][aria-orientation=horizontal i]) {
|
|
91
|
+
flex-flow: row nowrap;
|
|
92
|
+
}
|
|
93
|
+
:where([oui-tabs-tablist][aria-orientation=horizontal i] > [oui-tabs-tab]) {
|
|
94
|
+
border-radius: 0.25em 0.25em 0 0;
|
|
95
|
+
}
|
|
96
|
+
:where([oui-tabs-tablist][aria-orientation=vertical i]) {
|
|
97
|
+
flex-flow: column nowrap;
|
|
98
|
+
}
|
|
99
|
+
:where([oui-tabs-tablist][aria-orientation=vertical i] > [oui-tabs-tab]) {
|
|
100
|
+
border-radius: 0.25em 0 0 0.25em;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { a as COMBOBOX_AUTOCOMPLETES, c as COMBOBOX_TAGNAME, d as selectorAnchor, f as selectorContent, i as COMBOBOX_ATTRIBUTE_SELECTION_ITEM, l as messageLabel, m as selectorSelectionItem, n as COMBOBOX_ATTRIBUTE_ANCHOR, o as COMBOBOX_MESSAGES, p as selectorOption, r as COMBOBOX_ATTRIBUTE_SELECTION, s as COMBOBOX_SELECTORS, t as COMBOBOX_ATTRIBUTES, u as messageSelect } from "../constants.combobox-DmRAMC64.mjs";
|
|
2
|
+
export { COMBOBOX_ATTRIBUTES, COMBOBOX_ATTRIBUTE_ANCHOR, COMBOBOX_ATTRIBUTE_SELECTION, COMBOBOX_ATTRIBUTE_SELECTION_ITEM, COMBOBOX_AUTOCOMPLETES, COMBOBOX_MESSAGES, COMBOBOX_SELECTORS, COMBOBOX_TAGNAME, messageLabel, messageSelect, selectorAnchor, selectorContent, selectorOption, selectorSelectionItem };
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
//#region src/js/combobox/constants.combobox.ts
|
|
2
2
|
const COMBOBOX_TAGNAME = "oui-combobox";
|
|
3
3
|
const COMBOBOX_ATTRIBUTE_ANCHOR = `${COMBOBOX_TAGNAME}-anchor`;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
4
|
+
const attributeContent = `${COMBOBOX_TAGNAME}-content`;
|
|
5
|
+
const attributeFilter = `${COMBOBOX_TAGNAME}-filter`;
|
|
6
|
+
const attributeFilterInput = `${attributeFilter}-input`;
|
|
7
|
+
const attributeGroup = `${COMBOBOX_TAGNAME}-group`;
|
|
8
|
+
const attributeHeader = `${COMBOBOX_TAGNAME}-header`;
|
|
9
|
+
const attributeHidden = `${COMBOBOX_TAGNAME}-hidden`;
|
|
10
|
+
const attributeList = `${COMBOBOX_TAGNAME}-list`;
|
|
11
|
+
const attributeListEmpty = `${attributeList}-empty`;
|
|
12
|
+
const attributeMessage = `${COMBOBOX_TAGNAME}-message`;
|
|
13
|
+
const attributeOption = `${COMBOBOX_TAGNAME}-option`;
|
|
14
|
+
const attributeOptionActive = `${COMBOBOX_TAGNAME}-option-active`;
|
|
13
15
|
const COMBOBOX_ATTRIBUTE_SELECTION = `${COMBOBOX_TAGNAME}-selection`;
|
|
14
16
|
const COMBOBOX_ATTRIBUTE_SELECTION_ITEM = `${COMBOBOX_TAGNAME}-selection-item`;
|
|
15
17
|
const COMBOBOX_AUTOCOMPLETES = /* @__PURE__ */ new Set([
|
|
@@ -18,29 +20,34 @@ const COMBOBOX_AUTOCOMPLETES = /* @__PURE__ */ new Set([
|
|
|
18
20
|
"list",
|
|
19
21
|
"none"
|
|
20
22
|
]);
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
]
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
23
|
+
const messageLabel = `<${COMBOBOX_TAGNAME}> must contain a <label> element for the <select> element`;
|
|
24
|
+
const messageSelect = `<${COMBOBOX_TAGNAME}> must contain a valid <select> element`;
|
|
25
|
+
const selectorAnchor = `[${COMBOBOX_ATTRIBUTE_ANCHOR}]`;
|
|
26
|
+
const selectorContent = `[${attributeContent}]`;
|
|
27
|
+
const selectorOption = `[${attributeOption}]`;
|
|
28
|
+
const selectorSelectionItem = `[${COMBOBOX_ATTRIBUTE_SELECTION_ITEM}]`;
|
|
29
|
+
const COMBOBOX_ATTRIBUTES = {
|
|
30
|
+
active: attributeOptionActive,
|
|
31
|
+
content: attributeContent,
|
|
32
|
+
empty: attributeListEmpty,
|
|
33
|
+
filter: attributeFilter,
|
|
34
|
+
group: attributeGroup,
|
|
35
|
+
header: attributeHeader,
|
|
36
|
+
hidden: attributeHidden,
|
|
37
|
+
input: attributeFilterInput,
|
|
38
|
+
list: attributeList,
|
|
39
|
+
message: attributeMessage,
|
|
40
|
+
option: attributeOption
|
|
41
|
+
};
|
|
42
|
+
const COMBOBOX_MESSAGES = {
|
|
43
|
+
label: messageLabel,
|
|
44
|
+
select: messageSelect
|
|
45
|
+
};
|
|
46
|
+
const COMBOBOX_SELECTORS = {
|
|
47
|
+
anchor: selectorAnchor,
|
|
48
|
+
content: selectorContent,
|
|
49
|
+
selectionItem: selectorSelectionItem,
|
|
50
|
+
option: selectorOption
|
|
44
51
|
};
|
|
45
52
|
//#endregion
|
|
46
|
-
export {
|
|
53
|
+
export { COMBOBOX_ATTRIBUTES, COMBOBOX_ATTRIBUTE_ANCHOR, COMBOBOX_ATTRIBUTE_SELECTION, COMBOBOX_ATTRIBUTE_SELECTION_ITEM, COMBOBOX_AUTOCOMPLETES, COMBOBOX_MESSAGES, COMBOBOX_SELECTORS, COMBOBOX_TAGNAME, messageLabel, messageSelect, selectorAnchor, selectorContent, selectorOption, selectorSelectionItem };
|
|
@@ -1,110 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as OuiListboxPreview } from "../listbox.model-CRReGOmu.mjs";
|
|
2
|
+
import { CreateListboxContent, CreateListboxContentParameters } from "../internal/listbox/listbox.dom.mjs";
|
|
3
|
+
import { OuiComboboxSelection, OuiComboboxSelectionItem, OuiComboboxState } from "./models.combobox.mjs";
|
|
2
4
|
//#region src/js/combobox/dom.combobox.d.ts
|
|
3
5
|
type CreateAnchor = {
|
|
4
6
|
container?: HTMLElement;
|
|
5
7
|
element: HTMLElement;
|
|
6
8
|
selection?: OuiComboboxSelection;
|
|
7
9
|
};
|
|
8
|
-
type CreatAnchorParameters = {
|
|
9
|
-
autocomplete: OuiComboboxAutoComplete;
|
|
10
|
-
id: string;
|
|
11
|
-
label: HTMLLabelElement;
|
|
12
|
-
multiple: boolean;
|
|
13
|
-
select: HTMLSelectElement;
|
|
14
|
-
type: OuiComboboxType;
|
|
15
|
-
};
|
|
16
|
-
type CreateContent = {
|
|
17
|
-
element: HTMLElement;
|
|
18
|
-
filter?: CreateFilter;
|
|
19
|
-
list: CreateList;
|
|
20
|
-
message: HTMLElement;
|
|
21
|
-
};
|
|
22
|
-
type CreateContentParameters = {
|
|
23
|
-
autocomplete: OuiComboboxAutoComplete;
|
|
24
|
-
id: string;
|
|
25
|
-
label: HTMLLabelElement;
|
|
26
|
-
multiple: boolean;
|
|
27
|
-
select: HTMLSelectElement;
|
|
28
|
-
type: OuiComboboxType;
|
|
29
|
-
};
|
|
30
|
-
type CreateFilter = {
|
|
31
|
-
container: HTMLElement;
|
|
32
|
-
element: HTMLInputElement;
|
|
33
|
-
};
|
|
34
|
-
type CreateFilterParameters = {
|
|
35
|
-
autocomplete: OuiComboboxAutoCompleteType;
|
|
36
|
-
id: string;
|
|
37
|
-
label: HTMLLabelElement;
|
|
38
|
-
type: OuiComboboxType;
|
|
39
|
-
};
|
|
40
|
-
type CreateGroupParameters = {
|
|
41
|
-
autocomplete: OuiComboboxAutoComplete;
|
|
42
|
-
group: HTMLOptGroupElement;
|
|
43
|
-
groupOptions: HTMLOptionElement[];
|
|
44
|
-
selected: HTMLElement[];
|
|
45
|
-
};
|
|
46
|
-
type CreateInputParameters = {
|
|
47
|
-
autocomplete: OuiComboboxAutoCompleteType;
|
|
48
|
-
id: string;
|
|
49
|
-
label: HTMLLabelElement;
|
|
50
|
-
type: OuiComboboxType;
|
|
51
|
-
value: string;
|
|
52
|
-
};
|
|
53
|
-
type CreateList = {
|
|
54
|
-
element: HTMLElement;
|
|
55
|
-
groups?: OuiComboboxGroup[];
|
|
56
|
-
options: HTMLElement[];
|
|
57
|
-
selected: HTMLElement[];
|
|
58
|
-
};
|
|
59
|
-
type CreateListParameters = {
|
|
60
|
-
autocomplete: OuiComboboxAutoComplete;
|
|
61
|
-
id: string;
|
|
62
|
-
label: HTMLLabelElement;
|
|
63
|
-
multiple: boolean;
|
|
64
|
-
select: HTMLSelectElement;
|
|
65
|
-
};
|
|
66
|
-
type CreateOptionParameters = {
|
|
67
|
-
autocomplete: OuiComboboxAutoComplete;
|
|
68
|
-
group?: string;
|
|
69
|
-
index: number;
|
|
70
|
-
option: HTMLOptionElement;
|
|
71
|
-
};
|
|
72
|
-
type CreateOptionsParameters = {
|
|
73
|
-
autocomplete: OuiComboboxAutoComplete;
|
|
74
|
-
group?: string;
|
|
75
|
-
list: HTMLElement;
|
|
76
|
-
options: HTMLOptionElement[];
|
|
77
|
-
selected: HTMLElement[];
|
|
78
|
-
};
|
|
79
10
|
type CreateSelectionItemsParameters = {
|
|
80
11
|
container: HTMLElement;
|
|
81
12
|
items: OuiComboboxSelectionItem[];
|
|
82
13
|
options: HTMLElement[];
|
|
83
14
|
state?: OuiComboboxState;
|
|
84
15
|
};
|
|
85
|
-
declare function createComboboxAnchor(parameters:
|
|
86
|
-
declare function createComboboxButton(parameters:
|
|
87
|
-
declare function createComboboxContent(parameters:
|
|
88
|
-
declare function createComboboxFilter(parameters: CreateFilterParameters): CreateFilter | undefined;
|
|
89
|
-
declare function createComboboxGroup(parameters: CreateGroupParameters): OuiComboboxGroup;
|
|
90
|
-
declare function createComboboxHeader(group: HTMLOptGroupElement): HTMLElement;
|
|
91
|
-
declare function createComboboxInput(parameters: CreateInputParameters): HTMLInputElement;
|
|
92
|
-
declare function createComboboxList(parameters: CreateListParameters): CreateList;
|
|
93
|
-
declare function createComboboxMessage(): HTMLElement;
|
|
94
|
-
declare function createComboboxOption(parameters: CreateOptionParameters): HTMLElement;
|
|
95
|
-
declare function createComboboxOptions(parameters: CreateOptionsParameters): HTMLElement[];
|
|
16
|
+
declare function createComboboxAnchor(parameters: CreateListboxContentParameters): CreateAnchor;
|
|
17
|
+
declare function createComboboxButton(parameters: CreateListboxContentParameters): CreateAnchor;
|
|
18
|
+
declare function createComboboxContent(parameters: CreateListboxContentParameters): CreateListboxContent;
|
|
96
19
|
declare function createComboboxSelection(id: string, select: HTMLSelectElement): OuiComboboxSelection;
|
|
97
20
|
declare function createComboboxSelectionItem(option: HTMLElement, state?: OuiComboboxState): OuiComboboxSelectionItem;
|
|
98
21
|
declare function createComboboxSelectionItems(parameters: CreateSelectionItemsParameters): void;
|
|
99
|
-
declare function setComboboxDisabled(state: OuiComboboxState, value: boolean): void;
|
|
100
|
-
declare function setComboboxReadonly(state: OuiComboboxState, value: boolean): void;
|
|
101
|
-
declare function setComboboxRequired(state: OuiComboboxState, value: boolean): void;
|
|
102
22
|
declare function updateComboboxTabindices(state: OuiComboboxState, active?: HTMLElement): void;
|
|
103
|
-
declare function
|
|
104
|
-
declare function updateComboboxAutocomplete(preview: OuiComboboxPreview, state: OuiComboboxState, active?: HTMLElement): void;
|
|
105
|
-
declare function updateComboboxMessage(state: OuiComboboxState, visible: number): void;
|
|
106
|
-
declare function updateComboboxPreview(preview: OuiComboboxPreview, state: OuiComboboxState, active?: HTMLElement): void;
|
|
23
|
+
declare function updateComboboxAutocomplete(preview: OuiListboxPreview, state: OuiComboboxState, active?: HTMLElement): void;
|
|
107
24
|
declare function updateComboboxSelection(state: OuiComboboxState, active: HTMLElement | undefined, added: boolean, selected?: HTMLElement[]): void;
|
|
108
25
|
declare function updateComboboxSelectionItems(state: OuiComboboxState): void;
|
|
109
26
|
//#endregion
|
|
110
|
-
export { createComboboxAnchor, createComboboxButton, createComboboxContent,
|
|
27
|
+
export { createComboboxAnchor, createComboboxButton, createComboboxContent, createComboboxSelection, createComboboxSelectionItem, createComboboxSelectionItems, updateComboboxAutocomplete, updateComboboxSelection, updateComboboxSelectionItems, updateComboboxTabindices };
|
|
@@ -1,2 +1,204 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { getLocalization, localize } from "../l10n.mjs";
|
|
2
|
+
import { _ as createListboxValueLabel, f as createListboxInput, l as createListboxFilter, m as createListboxMessage, p as createListboxList } from "../listbox.data-BWd0PCy7.mjs";
|
|
3
|
+
import { COMBOBOX_ATTRIBUTE_ANCHOR, COMBOBOX_ATTRIBUTE_SELECTION, COMBOBOX_ATTRIBUTE_SELECTION_ITEM } from "./constants.combobox.mjs";
|
|
4
|
+
import { setAria } from "@oscarpalmer/toretto/aria";
|
|
5
|
+
import { setAttribute } from "@oscarpalmer/toretto/attribute";
|
|
6
|
+
import { getData } from "@oscarpalmer/toretto/data";
|
|
7
|
+
import { createElement } from "@oscarpalmer/toretto/create";
|
|
8
|
+
//#region src/js/combobox/dom.combobox.ts
|
|
9
|
+
function createComboboxAnchor(parameters) {
|
|
10
|
+
const { select } = parameters;
|
|
11
|
+
let container;
|
|
12
|
+
let element;
|
|
13
|
+
let selection;
|
|
14
|
+
if (parameters.type === "autocomplete") element = createListboxInput(parameters, select.selectedOptions[0]?.textContent ?? "");
|
|
15
|
+
else ({container, element, selection} = createComboboxButton(parameters));
|
|
16
|
+
setAttribute(container ?? element, COMBOBOX_ATTRIBUTE_ANCHOR, "");
|
|
17
|
+
return {
|
|
18
|
+
container,
|
|
19
|
+
element,
|
|
20
|
+
selection
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function createComboboxButton(parameters) {
|
|
24
|
+
const { id, label, multiple, select } = parameters;
|
|
25
|
+
const element = createElement("button", {
|
|
26
|
+
aria: {
|
|
27
|
+
controls: `${id}_content`,
|
|
28
|
+
expanded: false,
|
|
29
|
+
haspopup: "listbox",
|
|
30
|
+
labelledby: `${label.id} ${id}_value`
|
|
31
|
+
},
|
|
32
|
+
property: { textContent: multiple ? "" : select.selectedOptions[0]?.textContent ?? "" }
|
|
33
|
+
});
|
|
34
|
+
if (!multiple) return { element };
|
|
35
|
+
const container = createElement("div");
|
|
36
|
+
const selection = createComboboxSelection(id, select);
|
|
37
|
+
container.append(selection.container, element);
|
|
38
|
+
return {
|
|
39
|
+
container,
|
|
40
|
+
element,
|
|
41
|
+
selection
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function createComboboxContent(parameters) {
|
|
45
|
+
const { id, label } = parameters;
|
|
46
|
+
const element = createElement("div", {
|
|
47
|
+
aria: { labelledby: label.id },
|
|
48
|
+
attribute: {
|
|
49
|
+
[parameters.attributes.content]: "",
|
|
50
|
+
popover: ""
|
|
51
|
+
},
|
|
52
|
+
property: {
|
|
53
|
+
id: `${id}_content`,
|
|
54
|
+
tabIndex: -1
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const filter = createListboxFilter(parameters);
|
|
58
|
+
const list = createListboxList(parameters);
|
|
59
|
+
const message = createListboxMessage(parameters.attributes.message);
|
|
60
|
+
const value = createListboxValueLabel(parameters.id);
|
|
61
|
+
if (filter != null) element.append(filter.container);
|
|
62
|
+
element.append(list.element, message, value);
|
|
63
|
+
return {
|
|
64
|
+
element,
|
|
65
|
+
filter,
|
|
66
|
+
list,
|
|
67
|
+
message,
|
|
68
|
+
value
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function createComboboxSelection(id, select) {
|
|
72
|
+
const container = createElement("ul", {
|
|
73
|
+
attribute: { [COMBOBOX_ATTRIBUTE_SELECTION]: "" },
|
|
74
|
+
property: { id: `${id}_selection` }
|
|
75
|
+
});
|
|
76
|
+
const options = [...select.selectedOptions];
|
|
77
|
+
const items = [];
|
|
78
|
+
createComboboxSelectionItems({
|
|
79
|
+
container,
|
|
80
|
+
items,
|
|
81
|
+
options
|
|
82
|
+
});
|
|
83
|
+
const { button } = items[0] ?? {};
|
|
84
|
+
if (button != null) button.tabIndex = 0;
|
|
85
|
+
return {
|
|
86
|
+
items,
|
|
87
|
+
container
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function createComboboxSelectionItem(option, state) {
|
|
91
|
+
const optionLabel = option.textContent;
|
|
92
|
+
const optionValue = getData(option, "value", false) ?? "";
|
|
93
|
+
const element = createElement("li");
|
|
94
|
+
const localization = state == null ? option.textContent : getLocalization(state.localizations.global, state.host, "remove", state.localizations.component);
|
|
95
|
+
const button = createElement("button", {
|
|
96
|
+
aria: { label: localize(localization, {
|
|
97
|
+
label: optionLabel,
|
|
98
|
+
value: optionValue
|
|
99
|
+
}, [optionLabel, optionValue]) },
|
|
100
|
+
attribute: {
|
|
101
|
+
[COMBOBOX_ATTRIBUTE_SELECTION_ITEM]: "",
|
|
102
|
+
tabindex: -1
|
|
103
|
+
},
|
|
104
|
+
data: { option: option.id }
|
|
105
|
+
});
|
|
106
|
+
const icon = createElement("span", {
|
|
107
|
+
aria: { hidden: true },
|
|
108
|
+
property: { innerHTML: "×" }
|
|
109
|
+
});
|
|
110
|
+
const label = createElement("span", { property: { textContent: option.textContent } });
|
|
111
|
+
button.append(icon, label);
|
|
112
|
+
element.append(button);
|
|
113
|
+
return {
|
|
114
|
+
button,
|
|
115
|
+
element
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function createComboboxSelectionItems(parameters) {
|
|
119
|
+
const { container, items, options, state } = parameters;
|
|
120
|
+
const { length } = options;
|
|
121
|
+
for (let index = 0; index < length; index += 1) {
|
|
122
|
+
const option = options[index];
|
|
123
|
+
const item = createComboboxSelectionItem(option, state);
|
|
124
|
+
container.append(item.element);
|
|
125
|
+
items.push(item);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function updateComboboxTabindices(state, active) {
|
|
129
|
+
if (active == null || state.selection == null) return;
|
|
130
|
+
const next = state.selection.items.find((item) => getData(item.button, "option", false) === active.id);
|
|
131
|
+
if (next == null) return;
|
|
132
|
+
const { length } = state.selection.items;
|
|
133
|
+
for (let index = 0; index < length; index += 1) {
|
|
134
|
+
const item = state.selection.items[index];
|
|
135
|
+
item.button.tabIndex = item === next ? 0 : -1;
|
|
136
|
+
}
|
|
137
|
+
next.button.focus();
|
|
138
|
+
}
|
|
139
|
+
function updateComboboxAutocomplete(preview, state, active) {
|
|
140
|
+
if (state.multiple) return;
|
|
141
|
+
const content = active?.textContent ?? state.filter.element.value;
|
|
142
|
+
if (preview === "typed" && !content.toLocaleLowerCase().startsWith(state.filter.element.value.toLocaleLowerCase())) return;
|
|
143
|
+
if (state.anchor.element instanceof HTMLInputElement) {
|
|
144
|
+
const contentLength = content.length;
|
|
145
|
+
const filterLength = state.filter.element.value.length;
|
|
146
|
+
if (preview === "set" || preview === "typed") {
|
|
147
|
+
state.anchor.element.value = content;
|
|
148
|
+
state.anchor.element.setSelectionRange(preview === "typed" ? filterLength : contentLength, contentLength);
|
|
149
|
+
}
|
|
150
|
+
} else state.anchor.element.textContent = content;
|
|
151
|
+
}
|
|
152
|
+
function updateComboboxSelection(state, active, added, selected) {
|
|
153
|
+
if (state.selection == null) return;
|
|
154
|
+
let options = active == null ? [] : [active];
|
|
155
|
+
if (added && selected != null) {
|
|
156
|
+
options = selected;
|
|
157
|
+
const { length } = state.selection.items;
|
|
158
|
+
for (let index = 0; index < length; index += 1) state.selection.items[index].element.remove();
|
|
159
|
+
state.selection.items.splice(0);
|
|
160
|
+
}
|
|
161
|
+
if (added) {
|
|
162
|
+
createComboboxSelectionItems({
|
|
163
|
+
options,
|
|
164
|
+
state,
|
|
165
|
+
container: state.selection.container,
|
|
166
|
+
items: state.selection.items
|
|
167
|
+
});
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
let current = state.selection.items.findIndex((item) => getData(item.button, "option", false) === active?.id);
|
|
171
|
+
if (current === -1) return;
|
|
172
|
+
state.selection.items[current].element.remove();
|
|
173
|
+
state.selection.items.splice(current, 1);
|
|
174
|
+
if (state.selection.items.length === 0) {
|
|
175
|
+
state.anchor.element.focus();
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const { length } = state.selection.items;
|
|
179
|
+
if (current < 0) current = 0;
|
|
180
|
+
else if (current >= length) current = length - 1;
|
|
181
|
+
for (let index = 0; index < length; index += 1) {
|
|
182
|
+
const { button } = state.selection.items[index];
|
|
183
|
+
button.tabIndex = index === current ? 0 : -1;
|
|
184
|
+
}
|
|
185
|
+
state.selection.items[current].button.focus();
|
|
186
|
+
}
|
|
187
|
+
function updateComboboxSelectionItems(state) {
|
|
188
|
+
if (state.selection == null) return;
|
|
189
|
+
const localization = getLocalization(state.localizations.global, state.host, "remove", state.localizations.component);
|
|
190
|
+
const { length } = state.selection.items;
|
|
191
|
+
for (let index = 0; index < length; index += 1) {
|
|
192
|
+
const item = state.selection.items[index];
|
|
193
|
+
const option = state.options.selected.find((option) => option.id === getData(item.button, "option", false));
|
|
194
|
+
if (option == null) continue;
|
|
195
|
+
const optionLabel = option.textContent;
|
|
196
|
+
const optionValue = getData(option, "value", false) ?? "";
|
|
197
|
+
setAria(item.button, "label", localize(localization, {
|
|
198
|
+
label: optionLabel,
|
|
199
|
+
value: optionValue
|
|
200
|
+
}, [optionLabel, optionValue]));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
//#endregion
|
|
204
|
+
export { createComboboxAnchor, createComboboxButton, createComboboxContent, createComboboxSelection, createComboboxSelectionItem, createComboboxSelectionItems, updateComboboxAutocomplete, updateComboboxSelection, updateComboboxSelectionItems, updateComboboxTabindices };
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as OuiListboxPreview } from "../listbox.model-CRReGOmu.mjs";
|
|
2
|
+
import { OuiComboboxState } from "./models.combobox.mjs";
|
|
2
3
|
//#region src/js/combobox/event.combobox.d.ts
|
|
3
|
-
declare function
|
|
4
|
-
declare function
|
|
4
|
+
declare function onComboboxActivation(state: OuiComboboxState): void;
|
|
5
|
+
declare function onComboboxApply(state: OuiComboboxState, option: HTMLElement | undefined, _: string[], added: boolean, selected?: HTMLElement[]): void;
|
|
6
|
+
declare function onComboboxClickContent(event: PointerEvent, state: OuiComboboxState): void;
|
|
5
7
|
declare function onComboboxEnter(state: OuiComboboxState): void;
|
|
6
8
|
declare function onComboboxEscape(state: OuiComboboxState): void;
|
|
7
|
-
declare function onComboboxFilter(
|
|
8
|
-
declare function onComboboxFocusout(
|
|
9
|
+
declare function onComboboxFilter(preview: OuiListboxPreview, state: OuiComboboxState, update: boolean, active?: HTMLElement, emit?: boolean): void;
|
|
10
|
+
declare function onComboboxFocusout(event: FocusEvent): void;
|
|
9
11
|
declare function onComboboxInput(event: InputEvent): void;
|
|
10
12
|
declare function onComboboxKeydown(event: KeyboardEvent): void;
|
|
11
13
|
declare function onComboboxKeydownSelection(event: KeyboardEvent, state: OuiComboboxState, item: HTMLElement): void;
|
|
12
|
-
declare function
|
|
14
|
+
declare function onComboboxPreview(preview: OuiListboxPreview, state: OuiComboboxState, active?: HTMLElement): void;
|
|
13
15
|
declare function onComboboxRemoveSelection(state: OuiComboboxState, item: HTMLElement): void;
|
|
14
|
-
declare function
|
|
16
|
+
declare function onComboboxNavigation(preview: OuiListboxPreview, state: OuiComboboxState, active?: HTMLElement): void;
|
|
17
|
+
declare function onComboboxSelection(state: OuiComboboxState, hasSelection?: boolean): void;
|
|
15
18
|
declare function onComboboxTab(state: OuiComboboxState): void;
|
|
19
|
+
declare function onComboboxToggle(state: OuiComboboxState): void;
|
|
20
|
+
declare function preventComboboxActivation(state: OuiComboboxState): boolean;
|
|
21
|
+
declare function skipComboboxNavigation(state: OuiComboboxState): boolean;
|
|
16
22
|
//#endregion
|
|
17
|
-
export {
|
|
23
|
+
export { onComboboxActivation, onComboboxApply, onComboboxClickContent, onComboboxEnter, onComboboxEscape, onComboboxFilter, onComboboxFocusout, onComboboxInput, onComboboxKeydown, onComboboxKeydownSelection, onComboboxNavigation, onComboboxPreview, onComboboxRemoveSelection, onComboboxSelection, onComboboxTab, onComboboxToggle, preventComboboxActivation, skipComboboxNavigation };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { C as skipComboboxNavigation, S as preventComboboxActivation, _ as onComboboxPreview, b as onComboboxTab, c as onComboboxClickContent, d as onComboboxFilter, f as onComboboxFocusout, g as onComboboxNavigation, h as onComboboxKeydownSelection, l as onComboboxEnter, m as onComboboxKeydown, o as onComboboxActivation, p as onComboboxInput, s as onComboboxApply, u as onComboboxEscape, v as onComboboxRemoveSelection, x as onComboboxToggle, y as onComboboxSelection } from "../state.combobox-4xq0FPCF.mjs";
|
|
2
|
+
export { onComboboxActivation, onComboboxApply, onComboboxClickContent, onComboboxEnter, onComboboxEscape, onComboboxFilter, onComboboxFocusout, onComboboxInput, onComboboxKeydown, onComboboxKeydownSelection, onComboboxNavigation, onComboboxPreview, onComboboxRemoveSelection, onComboboxSelection, onComboboxTab, onComboboxToggle, preventComboboxActivation, skipComboboxNavigation };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as setComboboxLocalizations, t as OuiComboboxElement } from "../index-EfkUSals.mjs";
|
|
2
2
|
export { OuiComboboxElement, setComboboxLocalizations };
|