@oscarpalmer/oui 0.38.0 → 0.40.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 +1 -1
- package/dist/css/badge.css +11 -8
- package/dist/css/button.css +106 -14
- package/dist/css/color-picker.css +555 -73
- package/dist/css/color.css +86 -86
- package/dist/css/combobox.css +98 -4
- package/dist/css/content.css +7 -6
- package/dist/css/floatable.css +1 -3
- package/dist/css/form.css +99 -6
- package/dist/css/icon.css +99 -0
- package/dist/css/listbox.css +3 -0
- package/dist/css/message.css +4 -3
- package/dist/css/mixins/button.mixins.css +1 -0
- package/dist/css/reset.css +1 -1
- package/dist/css/tabs.css +95 -3
- package/dist/css/typography.css +90 -0
- package/dist/js/color-picker/color-picker.constants.d.mts +2 -0
- package/dist/js/color-picker/color-picker.constants.mjs +60 -0
- package/dist/js/color-picker/color-picker.dom.d.mts +8 -0
- package/dist/js/color-picker/color-picker.dom.mjs +191 -0
- package/dist/js/color-picker/color-picker.event.d.mts +9 -0
- package/dist/js/color-picker/color-picker.event.mjs +2 -0
- package/dist/js/color-picker/color-picker.form.d.mts +5 -0
- package/dist/js/color-picker/color-picker.form.mjs +27 -0
- package/dist/js/color-picker/color-picker.misc.d.mts +2 -0
- package/dist/js/color-picker/color-picker.misc.mjs +2 -0
- package/dist/js/color-picker/color-picker.model.d.mts +2 -0
- package/dist/js/color-picker/color-picker.model.mjs +24 -0
- package/dist/js/color-picker/color-picker.output.d.mts +8 -0
- package/dist/js/color-picker/color-picker.output.mjs +235 -0
- package/dist/js/color-picker/color-picker.state.d.mts +8 -0
- package/dist/js/color-picker/color-picker.state.mjs +2 -0
- package/dist/js/{color-picker.d.mts → color-picker/index.d.mts} +10 -43
- package/dist/js/color-picker/index.mjs +305 -0
- package/dist/js/color-picker.constants-D1mxw_Le.d.mts +179 -0
- package/dist/js/color-picker.event-Cksj5TvS.mjs +500 -0
- package/dist/js/color-picker.misc-CtsXGrOe.d.mts +27 -0
- package/dist/js/combobox/combobox.constants.d.mts +2 -0
- package/dist/js/combobox/{constants.combobox.mjs → combobox.constants.mjs} +21 -21
- package/dist/js/combobox/combobox.dom.d.mts +26 -0
- package/dist/js/combobox/{dom.combobox.mjs → combobox.dom.mjs} +44 -37
- package/dist/js/combobox/combobox.event.d.mts +22 -0
- package/dist/js/combobox/{event.combobox.mjs → combobox.event.mjs} +1 -1
- package/dist/js/combobox/combobox.misc.d.mts +2 -0
- package/dist/js/combobox/{misc.combobox.mjs → combobox.misc.mjs} +1 -1
- package/dist/js/combobox/combobox.model.d.mts +2 -0
- package/dist/js/combobox/combobox.state.d.mts +10 -0
- package/dist/js/combobox/combobox.state.mjs +2 -0
- package/dist/js/combobox/index.d.mts +163 -2
- package/dist/js/combobox/index.mjs +53 -52
- package/dist/js/combobox.constants-DZVkMP5g.d.mts +19 -0
- package/dist/js/combobox.misc-C1tPZZDi.d.mts +22 -0
- package/dist/js/{combobox/models.combobox.d.mts → combobox.model-oDV06XCN.d.mts} +6 -6
- package/dist/js/{state.combobox-Qm3FWzYW.mjs → combobox.state-BfJ3Hxg8.mjs} +96 -82
- package/dist/js/constants.listbox-C5Ap6Ag_.d.mts +9 -0
- package/dist/js/dialog/dialog.model.d.mts +2 -0
- package/dist/js/dialog/dialog.model.mjs +11 -0
- package/dist/js/dialog/index.d.mts +12 -0
- package/dist/js/dialog/index.mjs +123 -0
- package/dist/js/dialog.model-DX2mndMh.d.mts +45 -0
- package/dist/js/floatable/floatable.embedded.d.mts +2 -2
- package/dist/js/floatable/floatable.embedded.mjs +64 -92
- package/dist/js/floatable/floatable.model.d.mts +2 -0
- package/dist/js/floatable/floatable.model.mjs +23 -0
- package/dist/js/floatable/floatable.standalone.d.mts +2 -1
- package/dist/js/floatable.embedded-MeTyXjFn.d.mts +17 -0
- package/dist/js/floatable.model-DXsQgoU7.d.mts +62 -0
- package/dist/js/focus-trap/focus-trap.embedded.d.mts +2 -2
- package/dist/js/focus-trap/focus-trap.embedded.mjs +112 -134
- package/dist/js/focus-trap/focus-trap.model.d.mts +2 -0
- package/dist/js/focus-trap/focus-trap.model.mjs +15 -0
- package/dist/js/focus-trap/focus-trap.standalone.d.mts +2 -1
- package/dist/js/focus-trap.embedded-DIU05m1z.d.mts +13 -0
- package/dist/js/{focus-trap.embedded-DR8NpZfr.d.mts → focus-trap.model-BeX6UYlw.d.mts} +16 -18
- package/dist/js/index.d.mts +26 -14
- package/dist/js/index.mjs +18 -15
- package/dist/js/internal/attributable.d.mts +2 -3
- package/dist/js/internal/attributable.mjs +3 -2
- package/dist/js/internal/draggable/draggable.model.d.mts +2 -0
- package/dist/js/internal/draggable/draggable.model.mjs +37 -0
- package/dist/js/internal/draggable/index.d.mts +13 -0
- package/dist/js/internal/{draggable.mjs → draggable/index.mjs} +83 -114
- package/dist/js/internal/listbox/listbox.constants.d.mts +7 -10
- package/dist/js/internal/listbox/listbox.constants.mjs +15 -16
- package/dist/js/internal/listbox/listbox.data.d.mts +9 -10
- package/dist/js/internal/listbox/listbox.data.mjs +1 -1
- package/dist/js/internal/listbox/listbox.dom.d.mts +19 -20
- package/dist/js/internal/listbox/listbox.dom.mjs +1 -1
- package/dist/js/internal/listbox/listbox.event.d.mts +3 -4
- package/dist/js/internal/listbox/listbox.event.mjs +23 -20
- package/dist/js/internal/listbox/listbox.form.d.mts +4 -5
- package/dist/js/internal/listbox/listbox.form.mjs +15 -12
- package/dist/js/internal/listbox/listbox.misc.d.mts +10 -11
- package/dist/js/internal/listbox/listbox.misc.mjs +1 -1
- package/dist/js/internal/listbox/listbox.model.d.mts +2 -2
- package/dist/js/internal/listbox/listbox.state.d.mts +5 -6
- package/dist/js/internal/listbox/listbox.state.mjs +19 -20
- package/dist/js/internal/misc.d.mts +5 -4
- package/dist/js/internal/misc.mjs +7 -1
- package/dist/js/internal/navigable/index.d.mts +6 -0
- package/dist/js/internal/navigable/index.mjs +125 -0
- package/dist/js/internal/navigable/navigable.model.d.mts +2 -0
- package/dist/js/internal/navigable/navigable.model.mjs +18 -0
- package/dist/js/l10n/index.d.mts +9 -0
- package/dist/js/{l10n.mjs → l10n/index.mjs} +50 -23
- package/dist/js/l10n/l10n.model.d.mts +2 -0
- package/dist/js/l10n/l10n.model.mjs +9 -0
- package/dist/js/l10n.model-D6a9frgl.d.mts +26 -0
- package/dist/js/listbox/constants.listbox.d.mts +2 -2
- package/dist/js/listbox/constants.listbox.mjs +10 -14
- package/dist/js/listbox/event.listbox.d.mts +6 -7
- package/dist/js/listbox/event.listbox.mjs +47 -1
- package/dist/js/listbox/index.d.mts +8 -6
- package/dist/js/listbox/index.mjs +47 -49
- package/dist/js/listbox/misc.listbox.d.mts +1 -1
- package/dist/js/listbox/misc.listbox.mjs +1 -1
- package/dist/js/listbox/state.listbox.d.mts +8 -10
- package/dist/js/listbox/state.listbox.mjs +2 -2
- package/dist/js/{listbox.data-C7CRa5Ya.mjs → listbox.data-BQyZGKgr.mjs} +83 -66
- package/dist/js/{listbox.model-CRReGOmu.d.mts → listbox.model-CuBOj4qe.d.mts} +15 -11
- package/dist/js/menu/index.mjs +167 -0
- package/dist/js/menu/menu.model.d.mts +33 -0
- package/dist/js/menu/menu.model.mjs +15 -0
- package/dist/js/{misc.listbox-Cyz2CRDy.mjs → misc.listbox-CjfBUbHD.mjs} +27 -69
- package/dist/js/{misc.listbox-gnoJhrTr.d.mts → misc.listbox-CtoGvXQo.d.mts} +2 -2
- package/dist/js/movable/movable.embedded.d.mts +2 -2
- package/dist/js/movable/movable.embedded.mjs +60 -72
- package/dist/js/movable/movable.model.d.mts +2 -0
- package/dist/js/movable/movable.model.mjs +12 -0
- package/dist/js/movable/movable.standalone.d.mts +2 -1
- package/dist/js/movable.embedded-DoyXLegc.d.mts +11 -0
- package/dist/js/movable.model-BHaK_mKw.d.mts +186 -0
- package/dist/js/navigable.model-BPOM8DZk.d.mts +44 -0
- package/dist/js/popover/index.d.mts +12 -0
- package/dist/js/{popover.mjs → popover/index.mjs} +40 -50
- package/dist/js/popover/popover.model.d.mts +2 -0
- package/dist/js/popover/popover.model.mjs +12 -0
- package/dist/js/popover.model-ubKNG612.d.mts +38 -0
- package/dist/js/resizable/resizable.embedded.d.mts +2 -2
- package/dist/js/resizable/resizable.embedded.mjs +44 -59
- package/dist/js/resizable/resizable.model.d.mts +2 -0
- package/dist/js/resizable/resizable.model.mjs +21 -0
- package/dist/js/resizable/resizable.standalone.d.mts +2 -1
- package/dist/js/resizable.embedded-Bf1qBUdt.d.mts +11 -0
- package/dist/js/resizable.model-BwzJcTVJ.d.mts +46 -0
- package/dist/js/sortable/sortable.embedded.d.mts +2 -2
- package/dist/js/sortable/sortable.embedded.mjs +69 -82
- package/dist/js/sortable/sortable.model.d.mts +2 -0
- package/dist/js/sortable/sortable.model.mjs +24 -0
- package/dist/js/sortable/sortable.standalone.d.mts +2 -1
- package/dist/js/sortable.embedded-DzBKAwSG.d.mts +11 -0
- package/dist/js/{splitter.d.mts → splitter/index.d.mts} +8 -7
- package/dist/js/splitter/index.mjs +284 -0
- package/dist/js/splitter/splitter.model.d.mts +2 -0
- package/dist/js/splitter/splitter.model.mjs +37 -0
- package/dist/js/splitter.model-DOLNjLVS.d.mts +57 -0
- package/dist/js/{tabs.d.mts → tabs/index.d.mts} +7 -8
- package/dist/js/{tabs.mjs → tabs/index.mjs} +58 -58
- package/dist/js/tabs/tabs.model.d.mts +2 -0
- package/dist/js/tabs/tabs.model.mjs +18 -0
- package/dist/js/tabs.model-DRBX_JtI.d.mts +40 -0
- package/dist/js/toolbar/index.mjs +27 -0
- package/dist/js/toolbar/toolbar.model.d.mts +11 -0
- package/dist/js/toolbar/toolbar.model.mjs +7 -0
- package/dist/js/tooltip/index.d.mts +19 -0
- package/dist/js/{tooltip.mjs → tooltip/index.mjs} +60 -85
- package/dist/js/tooltip/tooltip.model.d.mts +2 -0
- package/dist/js/tooltip/tooltip.model.mjs +15 -0
- package/dist/js/tooltip.model-DRkY_BsL.d.mts +37 -0
- package/package.json +43 -37
- package/dist/js/color-picker.mjs +0 -924
- package/dist/js/combobox/constants.combobox.d.mts +0 -2
- package/dist/js/combobox/dom.combobox.d.mts +0 -27
- package/dist/js/combobox/event.combobox.d.mts +0 -23
- package/dist/js/combobox/misc.combobox.d.mts +0 -2
- package/dist/js/combobox/state.combobox.d.mts +0 -12
- package/dist/js/combobox/state.combobox.mjs +0 -2
- package/dist/js/constants.combobox-DmRAMC64.d.mts +0 -26
- package/dist/js/constants.listbox-DRsXUxd3.d.mts +0 -14
- package/dist/js/dialog.d.mts +0 -47
- package/dist/js/dialog.mjs +0 -131
- package/dist/js/draggable-a6w0J1OD.d.mts +0 -154
- package/dist/js/floatable.embedded-Bct4U5Dm.d.mts +0 -69
- package/dist/js/index-DJdFlTLm.d.mts +0 -177
- package/dist/js/internal/draggable.d.mts +0 -2
- package/dist/js/internal/navigable.d.mts +0 -37
- package/dist/js/internal/navigable.mjs +0 -135
- package/dist/js/l10n-Bn-7RcwR.d.mts +0 -20
- package/dist/js/l10n.d.mts +0 -2
- package/dist/js/menu.mjs +0 -172
- package/dist/js/popover.d.mts +0 -38
- package/dist/js/resizable.embedded-3qoR0Bjm.d.mts +0 -34
- package/dist/js/splitter.mjs +0 -322
- package/dist/js/toolbar.mjs +0 -31
- package/dist/js/tooltip.d.mts +0 -45
- package/src/css/a11y.scss +0 -13
- package/src/css/badge.scss +0 -62
- package/src/css/button.scss +0 -50
- package/src/css/color-picker.scss +0 -344
- package/src/css/color.scss +0 -113
- package/src/css/combobox.scss +0 -255
- package/src/css/content.scss +0 -181
- package/src/css/flex.scss +0 -107
- package/src/css/floatable.scss +0 -155
- package/src/css/form.scss +0 -575
- package/src/css/listbox.scss +0 -121
- package/src/css/message.scss +0 -74
- package/src/css/mixins/badge.mixins.scss +0 -53
- package/src/css/mixins/button.mixins.scss +0 -112
- package/src/css/mixins/input.mixins.scss +0 -114
- package/src/css/mixins/message.mixins.scss +0 -41
- package/src/css/mixins/misc.mixins.scss +0 -48
- package/src/css/mixins/shadow.mixins.scss +0 -57
- package/src/css/reset.scss +0 -392
- package/src/css/splitter.scss +0 -89
- package/src/css/table.scss +0 -107
- package/src/css/tabs.scss +0 -74
- package/src/js/color-picker.ts +0 -1653
- package/src/js/combobox/constants.combobox.ts +0 -83
- package/src/js/combobox/dom.combobox.ts +0 -411
- package/src/js/combobox/event.combobox.ts +0 -365
- package/src/js/combobox/index.ts +0 -382
- package/src/js/combobox/misc.combobox.ts +0 -104
- package/src/js/combobox/models.combobox.ts +0 -54
- package/src/js/combobox/state.combobox.ts +0 -246
- package/src/js/dialog.ts +0 -255
- package/src/js/floatable/floatable.embedded.ts +0 -336
- package/src/js/floatable/floatable.standalone.ts +0 -6
- package/src/js/focus-trap/focus-trap.embedded.ts +0 -411
- package/src/js/focus-trap/focus-trap.standalone.ts +0 -1
- package/src/js/index.ts +0 -16
- package/src/js/internal/attributable.ts +0 -73
- package/src/js/internal/draggable.ts +0 -657
- package/src/js/internal/listbox/listbox.constants.ts +0 -25
- package/src/js/internal/listbox/listbox.data.ts +0 -287
- package/src/js/internal/listbox/listbox.dom.ts +0 -446
- package/src/js/internal/listbox/listbox.event.ts +0 -129
- package/src/js/internal/listbox/listbox.form.ts +0 -125
- package/src/js/internal/listbox/listbox.misc.ts +0 -135
- package/src/js/internal/listbox/listbox.model.ts +0 -169
- package/src/js/internal/listbox/listbox.state.ts +0 -82
- package/src/js/internal/misc.ts +0 -27
- package/src/js/internal/navigable.ts +0 -317
- package/src/js/l10n.ts +0 -192
- package/src/js/listbox/constants.listbox.ts +0 -61
- package/src/js/listbox/event.listbox.ts +0 -106
- package/src/js/listbox/index.ts +0 -364
- package/src/js/listbox/misc.listbox.ts +0 -70
- package/src/js/listbox/state.listbox.ts +0 -194
- package/src/js/menu.ts +0 -348
- package/src/js/movable/movable.embedded.ts +0 -318
- package/src/js/movable/movable.standalone.ts +0 -2
- package/src/js/popover.ts +0 -229
- package/src/js/resizable/resizable.embedded.ts +0 -413
- package/src/js/resizable/resizable.standalone.ts +0 -5
- package/src/js/sortable/sortable.embedded.ts +0 -527
- package/src/js/sortable/sortable.standalone.ts +0 -2
- package/src/js/splitter.ts +0 -583
- package/src/js/tabs.ts +0 -441
- package/src/js/toolbar.ts +0 -63
- package/src/js/tooltip.ts +0 -367
- /package/dist/js/combobox/{models.combobox.mjs → combobox.model.mjs} +0 -0
- /package/dist/js/{menu.d.mts → menu/index.d.mts} +0 -0
- /package/dist/js/{toolbar.d.mts → toolbar/index.d.mts} +0 -0
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
OuiListboxAttributes,
|
|
3
|
-
OuiListboxAutoCompleteType,
|
|
4
|
-
} from '../internal/listbox/listbox.model';
|
|
5
|
-
|
|
6
|
-
// #region Variables
|
|
7
|
-
|
|
8
|
-
export const COMBOBOX_TAGNAME = 'oui-combobox';
|
|
9
|
-
|
|
10
|
-
export const COMBOBOX_ATTRIBUTE_ANCHOR = `${COMBOBOX_TAGNAME}-anchor`;
|
|
11
|
-
|
|
12
|
-
const attributeContent = `${COMBOBOX_TAGNAME}-content`;
|
|
13
|
-
|
|
14
|
-
const attributeFilter = `${COMBOBOX_TAGNAME}-filter`;
|
|
15
|
-
|
|
16
|
-
const attributeFilterInput = `${attributeFilter}-input`;
|
|
17
|
-
|
|
18
|
-
const attributeGroup = `${COMBOBOX_TAGNAME}-group`;
|
|
19
|
-
|
|
20
|
-
const attributeHeader = `${COMBOBOX_TAGNAME}-header`;
|
|
21
|
-
|
|
22
|
-
const attributeHidden = `${COMBOBOX_TAGNAME}-hidden`;
|
|
23
|
-
|
|
24
|
-
const attributeList = `${COMBOBOX_TAGNAME}-list`;
|
|
25
|
-
|
|
26
|
-
const attributeListEmpty = `${attributeList}-empty`;
|
|
27
|
-
|
|
28
|
-
const attributeMessage = `${COMBOBOX_TAGNAME}-message`;
|
|
29
|
-
|
|
30
|
-
const attributeOption = `${COMBOBOX_TAGNAME}-option`;
|
|
31
|
-
|
|
32
|
-
const attributeOptionActive = `${COMBOBOX_TAGNAME}-option-active`;
|
|
33
|
-
|
|
34
|
-
export const COMBOBOX_ATTRIBUTE_SELECTION = `${COMBOBOX_TAGNAME}-selection`;
|
|
35
|
-
|
|
36
|
-
export const COMBOBOX_ATTRIBUTE_SELECTION_ITEM = `${COMBOBOX_TAGNAME}-selection-item`;
|
|
37
|
-
|
|
38
|
-
export const COMBOBOX_AUTOCOMPLETES = new Set<OuiListboxAutoCompleteType>([
|
|
39
|
-
'both',
|
|
40
|
-
'inline',
|
|
41
|
-
'list',
|
|
42
|
-
'none',
|
|
43
|
-
]);
|
|
44
|
-
|
|
45
|
-
export const messageLabel = `<${COMBOBOX_TAGNAME}> must contain a <label> element for the <select> element`;
|
|
46
|
-
|
|
47
|
-
export const messageSelect = `<${COMBOBOX_TAGNAME}> must contain a valid <select> element`;
|
|
48
|
-
|
|
49
|
-
export const selectorAnchor = `[${COMBOBOX_ATTRIBUTE_ANCHOR}]`;
|
|
50
|
-
|
|
51
|
-
export const selectorContent = `[${attributeContent}]`;
|
|
52
|
-
|
|
53
|
-
export const selectorOption = `[${attributeOption}]`;
|
|
54
|
-
|
|
55
|
-
export const selectorSelectionItem = `[${COMBOBOX_ATTRIBUTE_SELECTION_ITEM}]`;
|
|
56
|
-
|
|
57
|
-
export const COMBOBOX_ATTRIBUTES: OuiListboxAttributes = {
|
|
58
|
-
active: attributeOptionActive,
|
|
59
|
-
content: attributeContent,
|
|
60
|
-
empty: attributeListEmpty,
|
|
61
|
-
filter: attributeFilter,
|
|
62
|
-
group: attributeGroup,
|
|
63
|
-
header: attributeHeader,
|
|
64
|
-
hidden: attributeHidden,
|
|
65
|
-
input: attributeFilterInput,
|
|
66
|
-
list: attributeList,
|
|
67
|
-
message: attributeMessage,
|
|
68
|
-
option: attributeOption,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const COMBOBOX_MESSAGES = {
|
|
72
|
-
label: messageLabel,
|
|
73
|
-
select: messageSelect,
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export const COMBOBOX_SELECTORS = {
|
|
77
|
-
anchor: selectorAnchor,
|
|
78
|
-
content: selectorContent,
|
|
79
|
-
selectionItem: selectorSelectionItem,
|
|
80
|
-
option: selectorOption,
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
// #endregion
|
|
@@ -1,411 +0,0 @@
|
|
|
1
|
-
import {setAria} from '@oscarpalmer/toretto/aria';
|
|
2
|
-
import {setAttribute} from '@oscarpalmer/toretto/attribute';
|
|
3
|
-
import {createElement} from '@oscarpalmer/toretto/create';
|
|
4
|
-
import {getData} from '@oscarpalmer/toretto/data';
|
|
5
|
-
import {
|
|
6
|
-
createListboxFilter,
|
|
7
|
-
createListboxInput,
|
|
8
|
-
createListboxList,
|
|
9
|
-
createListboxMessage,
|
|
10
|
-
createListboxValueLabel,
|
|
11
|
-
type CreateListboxContent,
|
|
12
|
-
type CreateListboxContentParameters,
|
|
13
|
-
} from '../internal/listbox/listbox.dom';
|
|
14
|
-
import type {OuiListboxPreview} from '../internal/listbox/listbox.model';
|
|
15
|
-
import {getLocalization, localize} from '../l10n';
|
|
16
|
-
import {
|
|
17
|
-
COMBOBOX_ATTRIBUTE_ANCHOR,
|
|
18
|
-
COMBOBOX_ATTRIBUTE_SELECTION,
|
|
19
|
-
COMBOBOX_ATTRIBUTE_SELECTION_ITEM,
|
|
20
|
-
} from './constants.combobox';
|
|
21
|
-
import type {
|
|
22
|
-
OuiComboboxSelection,
|
|
23
|
-
OuiComboboxSelectionItem,
|
|
24
|
-
OuiComboboxState,
|
|
25
|
-
} from './models.combobox';
|
|
26
|
-
|
|
27
|
-
// #region Types
|
|
28
|
-
|
|
29
|
-
type CreateAnchor = {
|
|
30
|
-
container?: HTMLElement;
|
|
31
|
-
element: HTMLElement;
|
|
32
|
-
selection?: OuiComboboxSelection;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
type CreateSelectionItemsParameters = {
|
|
36
|
-
container: HTMLElement;
|
|
37
|
-
items: OuiComboboxSelectionItem[];
|
|
38
|
-
options: HTMLElement[];
|
|
39
|
-
state?: OuiComboboxState;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// #endregion
|
|
43
|
-
|
|
44
|
-
// #region Functions
|
|
45
|
-
|
|
46
|
-
export function createComboboxAnchor(parameters: CreateListboxContentParameters): CreateAnchor {
|
|
47
|
-
const {select} = parameters;
|
|
48
|
-
|
|
49
|
-
let container: HTMLElement | undefined;
|
|
50
|
-
let element: HTMLElement;
|
|
51
|
-
let selection: OuiComboboxSelection | undefined;
|
|
52
|
-
|
|
53
|
-
if (parameters.type === 'autocomplete') {
|
|
54
|
-
element = createListboxInput(parameters, select.selectedOptions[0]?.textContent ?? '');
|
|
55
|
-
} else {
|
|
56
|
-
({container, element, selection} = createComboboxButton(parameters));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
setAttribute(container ?? element, COMBOBOX_ATTRIBUTE_ANCHOR, '');
|
|
60
|
-
|
|
61
|
-
return {container, element, selection};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function createComboboxButton(parameters: CreateListboxContentParameters): CreateAnchor {
|
|
65
|
-
const {id, label, multiple, select} = parameters;
|
|
66
|
-
|
|
67
|
-
const element = createElement('button', {
|
|
68
|
-
aria: {
|
|
69
|
-
controls: `${id}_content`,
|
|
70
|
-
expanded: false,
|
|
71
|
-
haspopup: 'listbox',
|
|
72
|
-
labelledby: `${label.id} ${id}_value`, // Non-input anchor, so no implicit value label, so we need to explicitly reference the value label
|
|
73
|
-
},
|
|
74
|
-
property: {
|
|
75
|
-
textContent: multiple ? '' : (select.selectedOptions[0]?.textContent ?? ''),
|
|
76
|
-
type: 'button',
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
if (!multiple) {
|
|
81
|
-
return {element};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const container = createElement('div');
|
|
85
|
-
const selection = createComboboxSelection(id, select);
|
|
86
|
-
|
|
87
|
-
container.append(selection.container, element);
|
|
88
|
-
|
|
89
|
-
return {container, element, selection};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function createComboboxContent(
|
|
93
|
-
parameters: CreateListboxContentParameters,
|
|
94
|
-
): CreateListboxContent {
|
|
95
|
-
const {id, label} = parameters;
|
|
96
|
-
|
|
97
|
-
const element = createElement('div', {
|
|
98
|
-
aria: {
|
|
99
|
-
labelledby: label.id,
|
|
100
|
-
},
|
|
101
|
-
attribute: {
|
|
102
|
-
[parameters.attributes.content]: '',
|
|
103
|
-
popover: '',
|
|
104
|
-
},
|
|
105
|
-
property: {
|
|
106
|
-
id: `${id}_content`,
|
|
107
|
-
tabIndex: -1,
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
const filter = createListboxFilter(parameters);
|
|
112
|
-
const list = createListboxList(parameters);
|
|
113
|
-
const message = createListboxMessage(parameters.attributes.message);
|
|
114
|
-
const value = createListboxValueLabel(parameters.id);
|
|
115
|
-
|
|
116
|
-
if (filter != null) {
|
|
117
|
-
element.append(filter.container);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
element.append(list.element, message, value);
|
|
121
|
-
|
|
122
|
-
return {element, filter, list, message, value};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export function createComboboxSelection(
|
|
126
|
-
id: string,
|
|
127
|
-
select: HTMLSelectElement,
|
|
128
|
-
): OuiComboboxSelection {
|
|
129
|
-
const container = createElement('ul', {
|
|
130
|
-
attribute: {
|
|
131
|
-
[COMBOBOX_ATTRIBUTE_SELECTION]: '',
|
|
132
|
-
},
|
|
133
|
-
property: {
|
|
134
|
-
id: `${id}_selection`,
|
|
135
|
-
},
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
const options = [...select.selectedOptions];
|
|
139
|
-
|
|
140
|
-
const items: OuiComboboxSelectionItem[] = [];
|
|
141
|
-
|
|
142
|
-
createComboboxSelectionItems({container, items, options});
|
|
143
|
-
|
|
144
|
-
const {button} = items[0] ?? {};
|
|
145
|
-
|
|
146
|
-
if (button != null) {
|
|
147
|
-
button.tabIndex = 0;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return {
|
|
151
|
-
items,
|
|
152
|
-
container: container,
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export function createComboboxSelectionItem(
|
|
157
|
-
option: HTMLElement,
|
|
158
|
-
state?: OuiComboboxState,
|
|
159
|
-
): OuiComboboxSelectionItem {
|
|
160
|
-
const optionLabel = option.textContent;
|
|
161
|
-
const optionValue = getData(option, 'value', false) ?? '';
|
|
162
|
-
|
|
163
|
-
const element = createElement('li');
|
|
164
|
-
|
|
165
|
-
const localization =
|
|
166
|
-
state == null
|
|
167
|
-
? option.textContent
|
|
168
|
-
: getLocalization(
|
|
169
|
-
state.localizations.global,
|
|
170
|
-
state.host,
|
|
171
|
-
'remove',
|
|
172
|
-
state.localizations.component,
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
const button = createElement('button', {
|
|
176
|
-
aria: {
|
|
177
|
-
label: localize(
|
|
178
|
-
localization,
|
|
179
|
-
{
|
|
180
|
-
label: optionLabel,
|
|
181
|
-
value: optionValue,
|
|
182
|
-
},
|
|
183
|
-
[optionLabel, optionValue],
|
|
184
|
-
),
|
|
185
|
-
},
|
|
186
|
-
attribute: {
|
|
187
|
-
[COMBOBOX_ATTRIBUTE_SELECTION_ITEM]: '',
|
|
188
|
-
tabindex: -1,
|
|
189
|
-
},
|
|
190
|
-
data: {
|
|
191
|
-
option: option.id,
|
|
192
|
-
},
|
|
193
|
-
property: {
|
|
194
|
-
type: 'button',
|
|
195
|
-
},
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
const icon = createElement('span', {
|
|
199
|
-
aria: {
|
|
200
|
-
hidden: true,
|
|
201
|
-
},
|
|
202
|
-
property: {
|
|
203
|
-
innerHTML: '×',
|
|
204
|
-
},
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
const label = createElement('span', {
|
|
208
|
-
property: {
|
|
209
|
-
textContent: option.textContent,
|
|
210
|
-
},
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
button.append(icon, label);
|
|
214
|
-
element.append(button);
|
|
215
|
-
|
|
216
|
-
return {
|
|
217
|
-
button,
|
|
218
|
-
element,
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export function createComboboxSelectionItems(parameters: CreateSelectionItemsParameters): void {
|
|
223
|
-
const {container, items, options, state} = parameters;
|
|
224
|
-
|
|
225
|
-
const {length} = options;
|
|
226
|
-
|
|
227
|
-
for (let index = 0; index < length; index += 1) {
|
|
228
|
-
const option = options[index];
|
|
229
|
-
|
|
230
|
-
const item = createComboboxSelectionItem(option, state);
|
|
231
|
-
|
|
232
|
-
container.append(item.element);
|
|
233
|
-
items.push(item);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
export function updateComboboxTabindices(state: OuiComboboxState, active?: HTMLElement): void {
|
|
238
|
-
if (active == null || state.selection == null) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
const next = state.selection.items.find(
|
|
243
|
-
item => getData(item.button, 'option', false) === active.id,
|
|
244
|
-
);
|
|
245
|
-
|
|
246
|
-
if (next == null) {
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
const {length} = state.selection.items;
|
|
251
|
-
|
|
252
|
-
for (let index = 0; index < length; index += 1) {
|
|
253
|
-
const item = state.selection.items[index];
|
|
254
|
-
|
|
255
|
-
item.button.tabIndex = item === next ? 0 : -1;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
next.button.focus();
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
export function updateComboboxAutocomplete(
|
|
262
|
-
preview: OuiListboxPreview,
|
|
263
|
-
state: OuiComboboxState,
|
|
264
|
-
active?: HTMLElement,
|
|
265
|
-
): void {
|
|
266
|
-
if (state.multiple) {
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
const content = active?.textContent ?? state.filter.element.value;
|
|
271
|
-
|
|
272
|
-
if (
|
|
273
|
-
preview === 'typed' &&
|
|
274
|
-
!content.toLocaleLowerCase().startsWith(state.filter.element.value.toLocaleLowerCase())
|
|
275
|
-
) {
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
if (state.anchor.element instanceof HTMLInputElement) {
|
|
280
|
-
const contentLength = content.length;
|
|
281
|
-
const filterLength = state.filter.element.value.length;
|
|
282
|
-
|
|
283
|
-
if (preview === 'set' || preview === 'typed') {
|
|
284
|
-
state.anchor.element.value = content;
|
|
285
|
-
|
|
286
|
-
state.anchor.element.setSelectionRange(
|
|
287
|
-
preview === 'typed' ? filterLength : contentLength,
|
|
288
|
-
contentLength,
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
} else {
|
|
292
|
-
state.anchor.element.textContent = content;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
export function updateComboboxSelection(
|
|
297
|
-
state: OuiComboboxState,
|
|
298
|
-
active: HTMLElement | undefined,
|
|
299
|
-
added: boolean,
|
|
300
|
-
selected?: HTMLElement[],
|
|
301
|
-
): void {
|
|
302
|
-
if (state.selection == null) {
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
let options = active == null ? [] : [active];
|
|
307
|
-
|
|
308
|
-
if (added && selected != null) {
|
|
309
|
-
options = selected;
|
|
310
|
-
|
|
311
|
-
const {length} = state.selection.items;
|
|
312
|
-
|
|
313
|
-
for (let index = 0; index < length; index += 1) {
|
|
314
|
-
state.selection.items[index].element.remove();
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
state.selection.items.splice(0);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
if (added) {
|
|
321
|
-
createComboboxSelectionItems({
|
|
322
|
-
options,
|
|
323
|
-
state,
|
|
324
|
-
container: state.selection.container,
|
|
325
|
-
items: state.selection.items,
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
let current = state.selection.items.findIndex(
|
|
332
|
-
item => getData(item.button, 'option', false) === active?.id,
|
|
333
|
-
);
|
|
334
|
-
|
|
335
|
-
if (current === -1) {
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
const item = state.selection.items[current];
|
|
340
|
-
|
|
341
|
-
item.element.remove();
|
|
342
|
-
|
|
343
|
-
state.selection.items.splice(current, 1);
|
|
344
|
-
|
|
345
|
-
if (state.selection.items.length === 0) {
|
|
346
|
-
state.anchor.element.focus();
|
|
347
|
-
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
const {length} = state.selection.items;
|
|
352
|
-
|
|
353
|
-
if (current < 0) {
|
|
354
|
-
current = 0;
|
|
355
|
-
} else if (current >= length) {
|
|
356
|
-
current = length - 1;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
for (let index = 0; index < length; index += 1) {
|
|
360
|
-
const {button} = state.selection.items[index];
|
|
361
|
-
|
|
362
|
-
button.tabIndex = index === current ? 0 : -1;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
state.selection.items[current].button.focus();
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
export function updateComboboxSelectionItems(state: OuiComboboxState): void {
|
|
369
|
-
if (state.selection == null) {
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
const localization = getLocalization(
|
|
374
|
-
state.localizations.global,
|
|
375
|
-
state.host,
|
|
376
|
-
'remove',
|
|
377
|
-
state.localizations.component,
|
|
378
|
-
);
|
|
379
|
-
|
|
380
|
-
const {length} = state.selection.items;
|
|
381
|
-
|
|
382
|
-
for (let index = 0; index < length; index += 1) {
|
|
383
|
-
const item = state.selection.items[index];
|
|
384
|
-
|
|
385
|
-
const option = state.options.selected.find(
|
|
386
|
-
option => option.id === getData(item.button, 'option', false),
|
|
387
|
-
);
|
|
388
|
-
|
|
389
|
-
if (option == null) {
|
|
390
|
-
continue;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
const optionLabel = option.textContent;
|
|
394
|
-
const optionValue = getData(option, 'value', false) ?? '';
|
|
395
|
-
|
|
396
|
-
setAria(
|
|
397
|
-
item.button,
|
|
398
|
-
'label',
|
|
399
|
-
localize(
|
|
400
|
-
localization,
|
|
401
|
-
{
|
|
402
|
-
label: optionLabel,
|
|
403
|
-
value: optionValue,
|
|
404
|
-
},
|
|
405
|
-
[optionLabel, optionValue],
|
|
406
|
-
),
|
|
407
|
-
);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
// #endregion
|