@remix-run/ui 0.0.0 → 0.1.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/LICENSE +21 -0
- package/README.md +195 -2
- package/dist/animation/animate-layout-mixin.d.ts +12 -0
- package/dist/animation/animate-layout-mixin.js +214 -0
- package/dist/animation/animate-layout-mixin.js.map +1 -0
- package/dist/animation/animate-mixins.d.ts +29 -0
- package/dist/animation/animate-mixins.js +235 -0
- package/dist/animation/animate-mixins.js.map +1 -0
- package/dist/animation/index.d.ts +6 -0
- package/dist/animation/index.js +5 -0
- package/dist/animation/index.js.map +1 -0
- package/dist/animation/spring.d.ts +75 -0
- package/dist/animation/spring.js +183 -0
- package/dist/animation/spring.js.map +1 -0
- package/dist/animation/tween.d.ts +70 -0
- package/dist/animation/tween.js +93 -0
- package/dist/animation/tween.js.map +1 -0
- package/dist/components/accordion/accordion.d.ts +92 -0
- package/dist/components/accordion/accordion.js +337 -0
- package/dist/components/accordion/accordion.js.map +1 -0
- package/dist/components/anchor/anchor.d.ts +13 -0
- package/dist/components/anchor/anchor.js +558 -0
- package/dist/components/anchor/anchor.js.map +1 -0
- package/dist/components/breadcrumbs/breadcrumbs.d.ts +11 -0
- package/dist/components/breadcrumbs/breadcrumbs.js +78 -0
- package/dist/components/breadcrumbs/breadcrumbs.js.map +1 -0
- package/dist/components/button/button.d.ts +23 -0
- package/dist/components/button/button.js +147 -0
- package/dist/components/button/button.js.map +1 -0
- package/dist/components/combobox/combobox.d.ts +101 -0
- package/dist/components/combobox/combobox.js +708 -0
- package/dist/components/combobox/combobox.js.map +1 -0
- package/dist/components/glyph/glyph.d.ts +14 -0
- package/dist/components/glyph/glyph.js +65 -0
- package/dist/components/glyph/glyph.js.map +1 -0
- package/dist/components/listbox/listbox.d.ts +67 -0
- package/dist/components/listbox/listbox.js +340 -0
- package/dist/components/listbox/listbox.js.map +1 -0
- package/dist/components/menu/hover-aim.d.ts +5 -0
- package/dist/components/menu/hover-aim.js +308 -0
- package/dist/components/menu/hover-aim.js.map +1 -0
- package/dist/components/menu/menu.d.ts +164 -0
- package/dist/components/menu/menu.js +1106 -0
- package/dist/components/menu/menu.js.map +1 -0
- package/dist/components/popover/popover.d.ts +35 -0
- package/dist/components/popover/popover.js +138 -0
- package/dist/components/popover/popover.js.map +1 -0
- package/dist/components/select/select.d.ts +67 -0
- package/dist/components/select/select.js +397 -0
- package/dist/components/select/select.js.map +1 -0
- package/dist/components/separator/separator.d.ts +2 -0
- package/dist/components/separator/separator.js +15 -0
- package/dist/components/separator/separator.js.map +1 -0
- package/dist/components/tabs/tabs.d.ts +78 -0
- package/dist/components/tabs/tabs.js +341 -0
- package/dist/components/tabs/tabs.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/interactions/keydown/keydown.d.ts +1 -0
- package/dist/interactions/keydown/keydown.js +8 -0
- package/dist/interactions/keydown/keydown.js.map +1 -0
- package/dist/interactions/outside-click/outside-click-mixin.d.ts +2 -0
- package/dist/interactions/outside-click/outside-click-mixin.js +29 -0
- package/dist/interactions/outside-click/outside-click-mixin.js.map +1 -0
- package/dist/interactions/typeahead/typeahead-mixin.d.ts +8 -0
- package/dist/interactions/typeahead/typeahead-mixin.js +59 -0
- package/dist/interactions/typeahead/typeahead-mixin.js.map +1 -0
- package/dist/jsx-runtime.d.ts +2 -0
- package/dist/jsx-runtime.js +3 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/runtime/client-entries.d.ts +91 -0
- package/dist/runtime/client-entries.js +40 -0
- package/dist/runtime/client-entries.js.map +1 -0
- package/dist/runtime/component.d.ts +223 -0
- package/dist/runtime/component.js +152 -0
- package/dist/runtime/component.js.map +1 -0
- package/dist/runtime/create-element.d.ts +10 -0
- package/dist/runtime/create-element.js +29 -0
- package/dist/runtime/create-element.js.map +1 -0
- package/dist/runtime/diff-dom.d.ts +2 -0
- package/dist/runtime/diff-dom.js +364 -0
- package/dist/runtime/diff-dom.js.map +1 -0
- package/dist/runtime/diff-props.d.ts +9 -0
- package/dist/runtime/diff-props.js +195 -0
- package/dist/runtime/diff-props.js.map +1 -0
- package/dist/runtime/document-state.d.ts +11 -0
- package/dist/runtime/document-state.js +106 -0
- package/dist/runtime/document-state.js.map +1 -0
- package/dist/runtime/dom.d.ts +3189 -0
- package/dist/runtime/dom.js +2 -0
- package/dist/runtime/dom.js.map +1 -0
- package/dist/runtime/error-event.d.ts +20 -0
- package/dist/runtime/error-event.js +19 -0
- package/dist/runtime/error-event.js.map +1 -0
- package/dist/runtime/event-listeners.d.ts +50 -0
- package/dist/runtime/event-listeners.js +31 -0
- package/dist/runtime/event-listeners.js.map +1 -0
- package/dist/runtime/frame.d.ts +119 -0
- package/dist/runtime/frame.js +915 -0
- package/dist/runtime/frame.js.map +1 -0
- package/dist/runtime/invariant.d.ts +23 -0
- package/dist/runtime/invariant.js +33 -0
- package/dist/runtime/invariant.js.map +1 -0
- package/dist/runtime/jsx.d.ts +320 -0
- package/dist/runtime/jsx.js +31 -0
- package/dist/runtime/jsx.js.map +1 -0
- package/dist/runtime/mixins/attrs-mixin.d.ts +9 -0
- package/dist/runtime/mixins/attrs-mixin.js +23 -0
- package/dist/runtime/mixins/attrs-mixin.js.map +1 -0
- package/dist/runtime/mixins/link-mixin.d.ts +17 -0
- package/dist/runtime/mixins/link-mixin.js +101 -0
- package/dist/runtime/mixins/link-mixin.js.map +1 -0
- package/dist/runtime/mixins/mixin.d.ts +145 -0
- package/dist/runtime/mixins/mixin.js +570 -0
- package/dist/runtime/mixins/mixin.js.map +1 -0
- package/dist/runtime/mixins/on-mixin.d.ts +16 -0
- package/dist/runtime/mixins/on-mixin.js +49 -0
- package/dist/runtime/mixins/on-mixin.js.map +1 -0
- package/dist/runtime/mixins/ref-mixin.d.ts +9 -0
- package/dist/runtime/mixins/ref-mixin.js +21 -0
- package/dist/runtime/mixins/ref-mixin.js.map +1 -0
- package/dist/runtime/navigation.d.ts +22 -0
- package/dist/runtime/navigation.js +102 -0
- package/dist/runtime/navigation.js.map +1 -0
- package/dist/runtime/reconcile.d.ts +11 -0
- package/dist/runtime/reconcile.js +1240 -0
- package/dist/runtime/reconcile.js.map +1 -0
- package/dist/runtime/render.d.ts +54 -0
- package/dist/runtime/render.js +50 -0
- package/dist/runtime/render.js.map +1 -0
- package/dist/runtime/run.d.ts +45 -0
- package/dist/runtime/run.js +68 -0
- package/dist/runtime/run.js.map +1 -0
- package/dist/runtime/scheduler.d.ts +30 -0
- package/dist/runtime/scheduler.js +185 -0
- package/dist/runtime/scheduler.js.map +1 -0
- package/dist/runtime/svg-attributes.d.ts +5 -0
- package/dist/runtime/svg-attributes.js +124 -0
- package/dist/runtime/svg-attributes.js.map +1 -0
- package/dist/runtime/to-vnode.d.ts +3 -0
- package/dist/runtime/to-vnode.js +43 -0
- package/dist/runtime/to-vnode.js.map +1 -0
- package/dist/runtime/typed-event-target.d.ts +50 -0
- package/dist/runtime/typed-event-target.js +6 -0
- package/dist/runtime/typed-event-target.js.map +1 -0
- package/dist/runtime/vdom.d.ts +55 -0
- package/dist/runtime/vdom.js +198 -0
- package/dist/runtime/vdom.js.map +1 -0
- package/dist/runtime/vnode.d.ts +79 -0
- package/dist/runtime/vnode.js +38 -0
- package/dist/runtime/vnode.js.map +1 -0
- package/dist/server/stream.d.ts +57 -0
- package/dist/server/stream.js +1007 -0
- package/dist/server/stream.js.map +1 -0
- package/dist/style/css-mixin.d.ts +8 -0
- package/dist/style/css-mixin.js +54 -0
- package/dist/style/css-mixin.js.map +1 -0
- package/dist/style/index.d.ts +5 -0
- package/dist/style/index.js +4 -0
- package/dist/style/index.js.map +1 -0
- package/dist/style/style.d.ts +24 -0
- package/dist/style/style.js +269 -0
- package/dist/style/style.js.map +1 -0
- package/dist/style/stylesheet.d.ts +11 -0
- package/dist/style/stylesheet.js +174 -0
- package/dist/style/stylesheet.js.map +1 -0
- package/dist/test.d.ts +2 -0
- package/dist/test.js +2 -0
- package/dist/test.js.map +1 -0
- package/dist/theme/contract.d.ts +259 -0
- package/dist/theme/contract.js +131 -0
- package/dist/theme/contract.js.map +1 -0
- package/dist/theme/glyph-contract.d.ts +13 -0
- package/dist/theme/glyph-contract.js +34 -0
- package/dist/theme/glyph-contract.js.map +1 -0
- package/dist/theme/presets/rmx-01/glyphs.d.ts +2 -0
- package/dist/theme/presets/rmx-01/glyphs.js +252 -0
- package/dist/theme/presets/rmx-01/glyphs.js.map +1 -0
- package/dist/theme/presets/rmx-01/index.d.ts +2 -0
- package/dist/theme/presets/rmx-01/index.js +119 -0
- package/dist/theme/presets/rmx-01/index.js.map +1 -0
- package/dist/theme/runtime.d.ts +2 -0
- package/dist/theme/runtime.js +81 -0
- package/dist/theme/runtime.js.map +1 -0
- package/dist/theme/theme.d.ts +6 -0
- package/dist/theme/theme.js +5 -0
- package/dist/theme/theme.js.map +1 -0
- package/dist/utils/flash-attribute.d.ts +1 -0
- package/dist/utils/flash-attribute.js +11 -0
- package/dist/utils/flash-attribute.js.map +1 -0
- package/dist/utils/scroll-lock.d.ts +3 -0
- package/dist/utils/scroll-lock.js +69 -0
- package/dist/utils/scroll-lock.js.map +1 -0
- package/dist/utils/wait-for-css-transition.d.ts +1 -0
- package/dist/utils/wait-for-css-transition.js +58 -0
- package/dist/utils/wait-for-css-transition.js.map +1 -0
- package/dist/utils/wait.d.ts +1 -0
- package/dist/utils/wait.js +6 -0
- package/dist/utils/wait.js.map +1 -0
- package/package.json +125 -5
- package/src/animation/animate-layout-mixin.ts +266 -0
- package/src/animation/animate-mixins.ts +292 -0
- package/src/animation/index.ts +6 -0
- package/src/animation/spring.ts +299 -0
- package/src/animation/tween.ts +134 -0
- package/src/components/accordion/accordion.tsx +565 -0
- package/src/components/anchor/anchor.ts +904 -0
- package/src/components/breadcrumbs/breadcrumbs.tsx +124 -0
- package/src/components/button/README.md +44 -0
- package/src/components/button/button.tsx +188 -0
- package/src/components/combobox/README.md +145 -0
- package/src/components/combobox/combobox.tsx +1014 -0
- package/src/components/glyph/glyph.tsx +110 -0
- package/src/components/listbox/listbox.ts +447 -0
- package/src/components/menu/hover-aim.ts +428 -0
- package/src/components/menu/menu.tsx +1547 -0
- package/src/components/popover/README.md +122 -0
- package/src/components/popover/popover.ts +201 -0
- package/src/components/select/select.tsx +585 -0
- package/src/components/separator/separator.ts +19 -0
- package/src/components/tabs/README.md +105 -0
- package/src/components/tabs/tabs.tsx +499 -0
- package/src/index.ts +72 -0
- package/src/interactions/keydown/keydown.ts +14 -0
- package/src/interactions/outside-click/outside-click-mixin.ts +55 -0
- package/src/interactions/typeahead/typeahead-mixin.ts +89 -0
- package/src/jsx-runtime.ts +2 -0
- package/src/runtime/client-entries.ts +137 -0
- package/src/runtime/component.ts +402 -0
- package/src/runtime/create-element.ts +38 -0
- package/src/runtime/diff-dom.ts +404 -0
- package/src/runtime/diff-props.ts +209 -0
- package/src/runtime/document-state.ts +130 -0
- package/src/runtime/dom.ts +3971 -0
- package/src/runtime/error-event.ts +26 -0
- package/src/runtime/event-listeners.ts +171 -0
- package/src/runtime/frame.ts +1211 -0
- package/src/runtime/invariant.ts +31 -0
- package/src/runtime/jsx.ts +398 -0
- package/src/runtime/mixins/attrs-mixin.ts +35 -0
- package/src/runtime/mixins/link-mixin.ts +131 -0
- package/src/runtime/mixins/mixin.ts +908 -0
- package/src/runtime/mixins/on-mixin.ts +89 -0
- package/src/runtime/mixins/ref-mixin.ts +32 -0
- package/src/runtime/navigation.ts +136 -0
- package/src/runtime/reconcile.ts +1722 -0
- package/src/runtime/render.ts +101 -0
- package/src/runtime/run.ts +100 -0
- package/src/runtime/scheduler.ts +262 -0
- package/src/runtime/svg-attributes.ts +133 -0
- package/src/runtime/to-vnode.ts +50 -0
- package/src/runtime/typed-event-target.ts +67 -0
- package/src/runtime/vdom.ts +295 -0
- package/src/runtime/vnode.ts +137 -0
- package/src/server/stream.ts +1342 -0
- package/src/style/css-mixin.ts +82 -0
- package/src/style/index.ts +10 -0
- package/src/style/style.ts +312 -0
- package/src/style/stylesheet.ts +209 -0
- package/src/test/setup.ts +7 -0
- package/src/test/utils.ts +45 -0
- package/src/test.ts +2 -0
- package/src/theme/contract.ts +183 -0
- package/src/theme/glyph-contract.ts +57 -0
- package/src/theme/presets/rmx-01/glyphs.tsx +308 -0
- package/src/theme/presets/rmx-01/index.ts +121 -0
- package/src/theme/runtime.ts +116 -0
- package/src/theme/theme.ts +15 -0
- package/src/utils/flash-attribute.ts +11 -0
- package/src/utils/scroll-lock.ts +97 -0
- package/src/utils/wait-for-css-transition.ts +66 -0
- package/src/utils/wait.ts +5 -0
|
@@ -0,0 +1,708 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@remix-run/ui/jsx-runtime";
|
|
2
|
+
// @jsxRuntime classic
|
|
3
|
+
// @jsx createElement
|
|
4
|
+
import { attrs, css, createElement, createMixin, on, ref, } from '@remix-run/ui';
|
|
5
|
+
import { Glyph } from "../glyph/glyph.js";
|
|
6
|
+
import * as listbox from "../listbox/listbox.js";
|
|
7
|
+
import * as popover from "../popover/popover.js";
|
|
8
|
+
import { theme } from "../../theme/theme.js";
|
|
9
|
+
import {} from "../../interactions/typeahead/typeahead-mixin.js";
|
|
10
|
+
import { waitForCssTransition } from "../../utils/wait-for-css-transition.js";
|
|
11
|
+
import { wait } from "../../utils/wait.js";
|
|
12
|
+
const COMBOBOX_CHANGE_EVENT = 'rmx:combobox-change';
|
|
13
|
+
const INPUT_COMMIT_DELAY_MS = 50;
|
|
14
|
+
const comboboxPopoverCss = css({
|
|
15
|
+
opacity: 0,
|
|
16
|
+
'&:popover-open': {
|
|
17
|
+
opacity: 1,
|
|
18
|
+
},
|
|
19
|
+
'&:not(:popover-open)': {
|
|
20
|
+
pointerEvents: 'none',
|
|
21
|
+
},
|
|
22
|
+
'&[data-show-reason="nav"]:not(:popover-open)': {
|
|
23
|
+
transition: 'opacity 180ms ease-in, overlay 180ms ease-in, display 180ms ease-in',
|
|
24
|
+
transitionBehavior: 'allow-discrete',
|
|
25
|
+
},
|
|
26
|
+
'&[data-show-reason="hint"]:not(:popover-open)': {
|
|
27
|
+
transition: 'none',
|
|
28
|
+
transitionBehavior: 'normal',
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
const comboboxInputCss = css({
|
|
32
|
+
minHeight: theme.control.height.sm,
|
|
33
|
+
width: '100%',
|
|
34
|
+
paddingInline: theme.space.sm,
|
|
35
|
+
border: `0.5px solid ${theme.colors.border.default}`,
|
|
36
|
+
borderRadius: theme.radius.md,
|
|
37
|
+
backgroundColor: theme.surface.lvl0,
|
|
38
|
+
color: theme.colors.text.primary,
|
|
39
|
+
fontFamily: theme.fontFamily.sans,
|
|
40
|
+
fontSize: theme.fontSize.sm,
|
|
41
|
+
lineHeight: theme.lineHeight.normal,
|
|
42
|
+
boxShadow: 'inset 0 1px 0 rgb(255 255 255 / 0.7)',
|
|
43
|
+
'&:focus-visible': {
|
|
44
|
+
outline: `2px solid ${theme.colors.focus.ring}`,
|
|
45
|
+
outlineOffset: theme.space.none,
|
|
46
|
+
},
|
|
47
|
+
'&[data-surface-visible="true"][aria-activedescendant]:focus-visible': {
|
|
48
|
+
outline: 'none',
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
export const inputStyle = comboboxInputCss;
|
|
52
|
+
export const popoverStyle = comboboxPopoverCss;
|
|
53
|
+
export class ComboboxChangeEvent extends Event {
|
|
54
|
+
label;
|
|
55
|
+
optionId;
|
|
56
|
+
value;
|
|
57
|
+
constructor({ label, optionId, value, }) {
|
|
58
|
+
super(COMBOBOX_CHANGE_EVENT, { bubbles: true });
|
|
59
|
+
this.label = label;
|
|
60
|
+
this.optionId = optionId;
|
|
61
|
+
this.value = value;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function getSearchValues(value) {
|
|
65
|
+
return Array.isArray(value) ? value : [value];
|
|
66
|
+
}
|
|
67
|
+
function matchesSearchValue(value, text) {
|
|
68
|
+
if (text === '') {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
let normalizedText = text.toLowerCase();
|
|
72
|
+
return getSearchValues(value).some((candidate) => candidate.toLowerCase().startsWith(normalizedText));
|
|
73
|
+
}
|
|
74
|
+
function matchesExactSearchValue(value, text) {
|
|
75
|
+
if (text === '') {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
let normalizedText = text.toLowerCase();
|
|
79
|
+
return getSearchValues(value).some((candidate) => candidate.toLowerCase() === normalizedText);
|
|
80
|
+
}
|
|
81
|
+
function getOptionSearchValue(option) {
|
|
82
|
+
return option.searchValue ?? option.textValue ?? option.label;
|
|
83
|
+
}
|
|
84
|
+
function ComboboxProvider(handle) {
|
|
85
|
+
let inputRef;
|
|
86
|
+
let listboxRef;
|
|
87
|
+
let surfaceRef;
|
|
88
|
+
let hasInitialized = false;
|
|
89
|
+
let hasProvidedRef = false;
|
|
90
|
+
let activeValue = null;
|
|
91
|
+
let activeId = undefined;
|
|
92
|
+
let value = null;
|
|
93
|
+
let selectedId = undefined;
|
|
94
|
+
let selectedLabel = '';
|
|
95
|
+
let inputText = '';
|
|
96
|
+
let filterText = '';
|
|
97
|
+
let open = false;
|
|
98
|
+
let surfaceVisible = false;
|
|
99
|
+
let showReason = 'nav';
|
|
100
|
+
let pendingInputValue = null;
|
|
101
|
+
let pendingChange = null;
|
|
102
|
+
let selectInputAfterClose = false;
|
|
103
|
+
let closeSequenceId = 0;
|
|
104
|
+
let listId = `${handle.id}-combobox-list`;
|
|
105
|
+
function getOptions() {
|
|
106
|
+
return listboxRef?.options ?? [];
|
|
107
|
+
}
|
|
108
|
+
function getSelectedOption() {
|
|
109
|
+
return getOptions().find((option) => option.value === value);
|
|
110
|
+
}
|
|
111
|
+
function getMatchingOptions(text) {
|
|
112
|
+
if (text === '') {
|
|
113
|
+
return getOptions();
|
|
114
|
+
}
|
|
115
|
+
return getOptions().filter((option) => matchesSearchValue(option.textValue ?? option.label, text));
|
|
116
|
+
}
|
|
117
|
+
function getEnabledMatchingOptions(text) {
|
|
118
|
+
return getMatchingOptions(text).filter((option) => !option.disabled);
|
|
119
|
+
}
|
|
120
|
+
function getExactInputMatch(text = inputText) {
|
|
121
|
+
return (getOptions().find((option) => !option.disabled && matchesExactSearchValue(option.textValue ?? option.label, text)) ?? null);
|
|
122
|
+
}
|
|
123
|
+
function getOpenFilterText() {
|
|
124
|
+
if (inputText === '') {
|
|
125
|
+
return '';
|
|
126
|
+
}
|
|
127
|
+
if (getExactInputMatch(inputText)) {
|
|
128
|
+
return '';
|
|
129
|
+
}
|
|
130
|
+
if (getMatchingOptions(inputText).length === 0) {
|
|
131
|
+
return '';
|
|
132
|
+
}
|
|
133
|
+
return inputText;
|
|
134
|
+
}
|
|
135
|
+
function resolveOpenOption(strategy, nextFilterText) {
|
|
136
|
+
let enabledMatchingOptions = getEnabledMatchingOptions(nextFilterText);
|
|
137
|
+
if (enabledMatchingOptions.length === 0) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
if (strategy === 'selected-or-none') {
|
|
141
|
+
let selectedOption = getSelectedOption();
|
|
142
|
+
if (selectedOption &&
|
|
143
|
+
!selectedOption.disabled &&
|
|
144
|
+
matchesSearchValue(selectedOption.textValue ?? selectedOption.label, nextFilterText)) {
|
|
145
|
+
return selectedOption;
|
|
146
|
+
}
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
if (strategy === 'selected') {
|
|
150
|
+
let exactInputMatch = getExactInputMatch(inputText);
|
|
151
|
+
if (exactInputMatch &&
|
|
152
|
+
matchesSearchValue(exactInputMatch.textValue ?? exactInputMatch.label, nextFilterText)) {
|
|
153
|
+
return exactInputMatch;
|
|
154
|
+
}
|
|
155
|
+
let selectedOption = getSelectedOption();
|
|
156
|
+
if (selectedOption &&
|
|
157
|
+
!selectedOption.disabled &&
|
|
158
|
+
matchesSearchValue(selectedOption.textValue ?? selectedOption.label, nextFilterText)) {
|
|
159
|
+
return selectedOption;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return strategy === 'last'
|
|
163
|
+
? enabledMatchingOptions[enabledMatchingOptions.length - 1]
|
|
164
|
+
: enabledMatchingOptions[0];
|
|
165
|
+
}
|
|
166
|
+
function setInputValue(nextValue) {
|
|
167
|
+
if (!inputRef || inputRef.value === nextValue) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
inputRef.value = nextValue;
|
|
171
|
+
}
|
|
172
|
+
function clearInputSelection() {
|
|
173
|
+
if (!inputRef || inputRef.selectionStart === null || inputRef.selectionEnd === null) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
let cursor = inputRef.value.length;
|
|
177
|
+
if (inputRef.selectionStart === cursor && inputRef.selectionEnd === cursor) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
inputRef.setSelectionRange(cursor, cursor);
|
|
181
|
+
}
|
|
182
|
+
function syncPopoverMinWidth() {
|
|
183
|
+
if (!surfaceRef || !inputRef) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
let width = inputRef.offsetWidth;
|
|
187
|
+
if (width <= 0) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
surfaceRef.style.minWidth = `${width}px`;
|
|
191
|
+
}
|
|
192
|
+
function dispatchChange(selection) {
|
|
193
|
+
let target = inputRef ?? surfaceRef;
|
|
194
|
+
target?.dispatchEvent(new ComboboxChangeEvent({
|
|
195
|
+
label: selection.label,
|
|
196
|
+
optionId: selection.optionId,
|
|
197
|
+
value: selection.value,
|
|
198
|
+
}));
|
|
199
|
+
}
|
|
200
|
+
function clearCommittedSelection() {
|
|
201
|
+
let selectionChanged = value !== null || selectedId !== undefined;
|
|
202
|
+
value = null;
|
|
203
|
+
selectedId = undefined;
|
|
204
|
+
selectedLabel = '';
|
|
205
|
+
return selectionChanged;
|
|
206
|
+
}
|
|
207
|
+
function clearInputAndSelection() {
|
|
208
|
+
closeSequenceId++;
|
|
209
|
+
pendingInputValue = null;
|
|
210
|
+
pendingChange = null;
|
|
211
|
+
selectInputAfterClose = false;
|
|
212
|
+
inputText = '';
|
|
213
|
+
activeValue = null;
|
|
214
|
+
activeId = undefined;
|
|
215
|
+
if (!open) {
|
|
216
|
+
filterText = '';
|
|
217
|
+
}
|
|
218
|
+
let selectionChanged = clearCommittedSelection();
|
|
219
|
+
setInputValue('');
|
|
220
|
+
if (selectionChanged) {
|
|
221
|
+
dispatchChange({ label: null, optionId: null, value: null });
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
async function closePopover() {
|
|
225
|
+
if (!open) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
let closeId = ++closeSequenceId;
|
|
229
|
+
let shouldWaitForTransition = showReason === 'nav';
|
|
230
|
+
open = false;
|
|
231
|
+
if (!shouldWaitForTransition) {
|
|
232
|
+
surfaceVisible = false;
|
|
233
|
+
filterText = '';
|
|
234
|
+
activeValue = null;
|
|
235
|
+
activeId = undefined;
|
|
236
|
+
await handle.update();
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
let signal = await handle.update();
|
|
240
|
+
if (signal.aborted || closeId !== closeSequenceId || open) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (surfaceRef?.isConnected) {
|
|
244
|
+
await waitForCssTransition(surfaceRef, signal);
|
|
245
|
+
}
|
|
246
|
+
if (signal.aborted || closeId !== closeSequenceId || open) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
surfaceVisible = false;
|
|
250
|
+
filterText = '';
|
|
251
|
+
activeValue = null;
|
|
252
|
+
activeId = undefined;
|
|
253
|
+
signal = await handle.update();
|
|
254
|
+
if (signal.aborted || closeId !== closeSequenceId || open) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if (pendingInputValue !== null) {
|
|
258
|
+
let nextValue = pendingInputValue;
|
|
259
|
+
await wait(INPUT_COMMIT_DELAY_MS);
|
|
260
|
+
if (signal.aborted ||
|
|
261
|
+
closeId !== closeSequenceId ||
|
|
262
|
+
open ||
|
|
263
|
+
pendingInputValue !== nextValue) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
setInputValue(nextValue);
|
|
267
|
+
pendingInputValue = null;
|
|
268
|
+
}
|
|
269
|
+
if (selectInputAfterClose && inputRef?.isConnected && document.activeElement === inputRef) {
|
|
270
|
+
inputRef.select();
|
|
271
|
+
}
|
|
272
|
+
selectInputAfterClose = false;
|
|
273
|
+
}
|
|
274
|
+
async function openPopover(strategy = 'selected', nextShowReason = 'nav') {
|
|
275
|
+
if (handle.props.disabled) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
if (pendingInputValue !== null) {
|
|
279
|
+
setInputValue(pendingInputValue);
|
|
280
|
+
pendingInputValue = null;
|
|
281
|
+
}
|
|
282
|
+
closeSequenceId++;
|
|
283
|
+
selectInputAfterClose = false;
|
|
284
|
+
let nextFilterText = getOpenFilterText();
|
|
285
|
+
let matchingOptions = getMatchingOptions(nextFilterText);
|
|
286
|
+
if (matchingOptions.length === 0) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
let activeOption = resolveOpenOption(strategy, nextFilterText);
|
|
290
|
+
filterText = nextFilterText;
|
|
291
|
+
showReason = nextShowReason;
|
|
292
|
+
open = true;
|
|
293
|
+
surfaceVisible = true;
|
|
294
|
+
activeValue = activeOption?.value ?? null;
|
|
295
|
+
activeId = activeOption?.id;
|
|
296
|
+
let signal = await handle.update();
|
|
297
|
+
if (signal.aborted) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
listboxRef?.scrollActiveOptionIntoView();
|
|
301
|
+
}
|
|
302
|
+
function beginSelection(nextValue, option) {
|
|
303
|
+
if (!option) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
let selectionChanged = value !== nextValue;
|
|
307
|
+
value = nextValue;
|
|
308
|
+
selectedId = option.id;
|
|
309
|
+
selectedLabel = option.label;
|
|
310
|
+
activeValue = nextValue;
|
|
311
|
+
activeId = option.id;
|
|
312
|
+
inputText = option.label;
|
|
313
|
+
showReason = 'nav';
|
|
314
|
+
pendingInputValue = inputRef?.value === option.label ? null : option.label;
|
|
315
|
+
pendingChange = selectionChanged
|
|
316
|
+
? {
|
|
317
|
+
label: option.label,
|
|
318
|
+
optionId: option.id,
|
|
319
|
+
value: option.value,
|
|
320
|
+
}
|
|
321
|
+
: null;
|
|
322
|
+
selectInputAfterClose = true;
|
|
323
|
+
void handle.update();
|
|
324
|
+
}
|
|
325
|
+
async function finishSelection() {
|
|
326
|
+
let change = pendingChange;
|
|
327
|
+
pendingChange = null;
|
|
328
|
+
if (change) {
|
|
329
|
+
dispatchChange(change);
|
|
330
|
+
}
|
|
331
|
+
await closePopover();
|
|
332
|
+
}
|
|
333
|
+
async function setInputText(nextText) {
|
|
334
|
+
closeSequenceId++;
|
|
335
|
+
pendingInputValue = null;
|
|
336
|
+
pendingChange = null;
|
|
337
|
+
selectInputAfterClose = false;
|
|
338
|
+
let selectionChanged = clearCommittedSelection();
|
|
339
|
+
inputText = nextText;
|
|
340
|
+
showReason = 'hint';
|
|
341
|
+
activeValue = null;
|
|
342
|
+
activeId = undefined;
|
|
343
|
+
let nextFilterText = nextText !== '' || !open ? nextText : filterText;
|
|
344
|
+
let matchingOptions = getMatchingOptions(nextText);
|
|
345
|
+
filterText = nextFilterText;
|
|
346
|
+
if (selectionChanged) {
|
|
347
|
+
dispatchChange({ label: null, optionId: null, value: null });
|
|
348
|
+
}
|
|
349
|
+
if (nextText === '' || matchingOptions.length === 0) {
|
|
350
|
+
if (open) {
|
|
351
|
+
open = false;
|
|
352
|
+
surfaceVisible = false;
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
filterText = '';
|
|
356
|
+
}
|
|
357
|
+
await handle.update();
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
open = true;
|
|
361
|
+
surfaceVisible = true;
|
|
362
|
+
await handle.update();
|
|
363
|
+
}
|
|
364
|
+
function handleBlur() {
|
|
365
|
+
let exactMatch = getExactInputMatch(inputText);
|
|
366
|
+
if (!exactMatch) {
|
|
367
|
+
clearInputAndSelection();
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
let selectionChanged = value !== exactMatch.value;
|
|
371
|
+
value = exactMatch.value;
|
|
372
|
+
selectedId = exactMatch.id;
|
|
373
|
+
selectedLabel = exactMatch.label;
|
|
374
|
+
activeValue = exactMatch.value;
|
|
375
|
+
activeId = exactMatch.id;
|
|
376
|
+
if (selectionChanged) {
|
|
377
|
+
dispatchChange({
|
|
378
|
+
label: exactMatch.label,
|
|
379
|
+
optionId: exactMatch.id,
|
|
380
|
+
value: exactMatch.value,
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
void closePopover();
|
|
385
|
+
}
|
|
386
|
+
function handleEscape() {
|
|
387
|
+
if (!getExactInputMatch(inputText)) {
|
|
388
|
+
clearInputAndSelection();
|
|
389
|
+
}
|
|
390
|
+
if (open) {
|
|
391
|
+
void closePopover();
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
function openFromArrow(direction) {
|
|
395
|
+
let strategy = getExactInputMatch(inputText) ? 'selected' : direction;
|
|
396
|
+
clearInputSelection();
|
|
397
|
+
return openPopover(strategy);
|
|
398
|
+
}
|
|
399
|
+
function openFromInputActivation() {
|
|
400
|
+
clearInputSelection();
|
|
401
|
+
return openPopover('selected-or-none');
|
|
402
|
+
}
|
|
403
|
+
function navigateNext() {
|
|
404
|
+
clearInputSelection();
|
|
405
|
+
listboxRef?.navigateNext();
|
|
406
|
+
}
|
|
407
|
+
function navigatePrevious() {
|
|
408
|
+
clearInputSelection();
|
|
409
|
+
listboxRef?.navigatePrevious();
|
|
410
|
+
}
|
|
411
|
+
function selectActive() {
|
|
412
|
+
return listboxRef?.selectActive() ?? Promise.resolve();
|
|
413
|
+
}
|
|
414
|
+
function registerInput(node) {
|
|
415
|
+
inputRef = node;
|
|
416
|
+
setInputValue(inputText);
|
|
417
|
+
}
|
|
418
|
+
function unregisterInput(node) {
|
|
419
|
+
if (inputRef === node) {
|
|
420
|
+
inputRef = undefined;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
function registerSurface(node) {
|
|
424
|
+
surfaceRef = node;
|
|
425
|
+
}
|
|
426
|
+
function unregisterSurface(node) {
|
|
427
|
+
if (surfaceRef === node) {
|
|
428
|
+
surfaceRef = undefined;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
let publicHandle = {
|
|
432
|
+
get activeOptionId() {
|
|
433
|
+
return activeId ?? null;
|
|
434
|
+
},
|
|
435
|
+
get id() {
|
|
436
|
+
return listId;
|
|
437
|
+
},
|
|
438
|
+
get inputText() {
|
|
439
|
+
return inputText;
|
|
440
|
+
},
|
|
441
|
+
get isOpen() {
|
|
442
|
+
return open;
|
|
443
|
+
},
|
|
444
|
+
get label() {
|
|
445
|
+
return selectedLabel || null;
|
|
446
|
+
},
|
|
447
|
+
get value() {
|
|
448
|
+
return value;
|
|
449
|
+
},
|
|
450
|
+
close() {
|
|
451
|
+
void closePopover();
|
|
452
|
+
},
|
|
453
|
+
open(strategy = 'selected') {
|
|
454
|
+
return openPopover(strategy);
|
|
455
|
+
},
|
|
456
|
+
};
|
|
457
|
+
handle.context.set({
|
|
458
|
+
get activeId() {
|
|
459
|
+
return activeId;
|
|
460
|
+
},
|
|
461
|
+
get disabled() {
|
|
462
|
+
return handle.props.disabled === true;
|
|
463
|
+
},
|
|
464
|
+
get filterText() {
|
|
465
|
+
return filterText;
|
|
466
|
+
},
|
|
467
|
+
get inputText() {
|
|
468
|
+
return inputText;
|
|
469
|
+
},
|
|
470
|
+
get isOpen() {
|
|
471
|
+
return open;
|
|
472
|
+
},
|
|
473
|
+
get listId() {
|
|
474
|
+
return listId;
|
|
475
|
+
},
|
|
476
|
+
get name() {
|
|
477
|
+
return handle.props.name;
|
|
478
|
+
},
|
|
479
|
+
get showReason() {
|
|
480
|
+
return showReason;
|
|
481
|
+
},
|
|
482
|
+
get surfaceVisible() {
|
|
483
|
+
return surfaceVisible;
|
|
484
|
+
},
|
|
485
|
+
get value() {
|
|
486
|
+
return value;
|
|
487
|
+
},
|
|
488
|
+
clearInputSelection,
|
|
489
|
+
close() {
|
|
490
|
+
void closePopover();
|
|
491
|
+
},
|
|
492
|
+
handleBlur,
|
|
493
|
+
handleEscape,
|
|
494
|
+
navigateNext,
|
|
495
|
+
navigatePrevious,
|
|
496
|
+
open(strategy = 'selected') {
|
|
497
|
+
return openPopover(strategy);
|
|
498
|
+
},
|
|
499
|
+
openFromArrow,
|
|
500
|
+
openFromInputActivation,
|
|
501
|
+
registerInput,
|
|
502
|
+
registerSurface,
|
|
503
|
+
setInputText,
|
|
504
|
+
selectActive,
|
|
505
|
+
syncPopoverMinWidth,
|
|
506
|
+
unregisterInput,
|
|
507
|
+
unregisterSurface,
|
|
508
|
+
});
|
|
509
|
+
return () => {
|
|
510
|
+
if (!hasInitialized) {
|
|
511
|
+
value = handle.props.defaultValue ?? null;
|
|
512
|
+
inputText = handle.props.defaultValue ?? '';
|
|
513
|
+
hasInitialized = true;
|
|
514
|
+
}
|
|
515
|
+
handle.queueTask(() => {
|
|
516
|
+
let selectedOption = getSelectedOption();
|
|
517
|
+
if (selectedOption) {
|
|
518
|
+
selectedId = selectedOption.id;
|
|
519
|
+
selectedLabel = selectedOption.label;
|
|
520
|
+
}
|
|
521
|
+
else if (value === null) {
|
|
522
|
+
selectedId = undefined;
|
|
523
|
+
selectedLabel = '';
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
if (!hasProvidedRef) {
|
|
527
|
+
handle.queueTask(() => {
|
|
528
|
+
handle.props.ref?.(publicHandle);
|
|
529
|
+
});
|
|
530
|
+
hasProvidedRef = true;
|
|
531
|
+
}
|
|
532
|
+
return (_jsx(popover.Context, { children: _jsx(listbox.Context, { activeValue: activeValue, flashSelection: true, onHighlight: (nextActiveValue, option) => {
|
|
533
|
+
if (!open) {
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
activeValue = nextActiveValue;
|
|
537
|
+
activeId = option?.id;
|
|
538
|
+
if (option) {
|
|
539
|
+
showReason = 'nav';
|
|
540
|
+
}
|
|
541
|
+
void handle.update();
|
|
542
|
+
}, onSelect: beginSelection, onSelectSettled: finishSelection, ref: (ref) => {
|
|
543
|
+
listboxRef = ref;
|
|
544
|
+
}, selectionFlashAttribute: "data-combobox-flash", value: value, children: handle.props.children }) }));
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
function getComboboxContext(handle) {
|
|
548
|
+
return handle.context.get(ComboboxProvider);
|
|
549
|
+
}
|
|
550
|
+
const inputMixin = createMixin((handle) => {
|
|
551
|
+
let context = getComboboxContext(handle);
|
|
552
|
+
return (props) => [
|
|
553
|
+
attrs({
|
|
554
|
+
'aria-activedescendant': context.activeId,
|
|
555
|
+
'aria-autocomplete': 'list',
|
|
556
|
+
'aria-controls': context.listId,
|
|
557
|
+
'aria-expanded': context.isOpen ? 'true' : 'false',
|
|
558
|
+
'aria-haspopup': 'listbox',
|
|
559
|
+
autocomplete: props.autocomplete ?? 'off',
|
|
560
|
+
'data-surface-visible': context.surfaceVisible ? 'true' : undefined,
|
|
561
|
+
disabled: context.disabled ? true : props.disabled,
|
|
562
|
+
role: 'combobox',
|
|
563
|
+
type: props.type ?? 'text',
|
|
564
|
+
}),
|
|
565
|
+
ref((node, signal) => {
|
|
566
|
+
context.registerInput(node);
|
|
567
|
+
signal.addEventListener('abort', () => {
|
|
568
|
+
context.unregisterInput(node);
|
|
569
|
+
});
|
|
570
|
+
}),
|
|
571
|
+
popover.anchor({ placement: 'bottom-start' }),
|
|
572
|
+
on('click', () => {
|
|
573
|
+
if (context.isOpen) {
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
void context.openFromInputActivation();
|
|
577
|
+
}),
|
|
578
|
+
on('input', (event) => {
|
|
579
|
+
void context.setInputText(event.currentTarget.value);
|
|
580
|
+
}),
|
|
581
|
+
on('keydown', (event) => {
|
|
582
|
+
switch (event.key) {
|
|
583
|
+
case 'ArrowDown':
|
|
584
|
+
event.preventDefault();
|
|
585
|
+
if (context.isOpen) {
|
|
586
|
+
context.navigateNext();
|
|
587
|
+
}
|
|
588
|
+
else {
|
|
589
|
+
void context.openFromArrow('first');
|
|
590
|
+
}
|
|
591
|
+
return;
|
|
592
|
+
case 'ArrowUp':
|
|
593
|
+
event.preventDefault();
|
|
594
|
+
if (context.isOpen) {
|
|
595
|
+
context.navigatePrevious();
|
|
596
|
+
}
|
|
597
|
+
else {
|
|
598
|
+
void context.openFromArrow('last');
|
|
599
|
+
}
|
|
600
|
+
return;
|
|
601
|
+
case 'Enter':
|
|
602
|
+
if (!context.isOpen) {
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
event.preventDefault();
|
|
606
|
+
void context.selectActive();
|
|
607
|
+
return;
|
|
608
|
+
case 'Escape':
|
|
609
|
+
if (!context.isOpen && context.inputText === '') {
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
event.preventDefault();
|
|
613
|
+
context.handleEscape();
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
}),
|
|
617
|
+
on('blur', () => {
|
|
618
|
+
context.handleBlur();
|
|
619
|
+
}),
|
|
620
|
+
];
|
|
621
|
+
});
|
|
622
|
+
const popoverMixin = createMixin((handle) => {
|
|
623
|
+
let context = getComboboxContext(handle);
|
|
624
|
+
return () => [
|
|
625
|
+
attrs({ 'data-show-reason': context.showReason }),
|
|
626
|
+
ref((node, signal) => {
|
|
627
|
+
context.registerSurface(node);
|
|
628
|
+
signal.addEventListener('abort', () => {
|
|
629
|
+
context.unregisterSurface(node);
|
|
630
|
+
});
|
|
631
|
+
}),
|
|
632
|
+
popover.surface({
|
|
633
|
+
open: context.isOpen,
|
|
634
|
+
onHide() {
|
|
635
|
+
context.close();
|
|
636
|
+
},
|
|
637
|
+
closeOnAnchorClick: false,
|
|
638
|
+
}),
|
|
639
|
+
on('beforetoggle', (event) => {
|
|
640
|
+
if (event.newState === 'open') {
|
|
641
|
+
context.syncPopoverMinWidth();
|
|
642
|
+
}
|
|
643
|
+
}),
|
|
644
|
+
];
|
|
645
|
+
});
|
|
646
|
+
const listMixin = createMixin((handle) => {
|
|
647
|
+
let context = getComboboxContext(handle);
|
|
648
|
+
return () => [attrs({ id: context.listId }), listbox.list()];
|
|
649
|
+
});
|
|
650
|
+
const hiddenInputMixin = createMixin((handle) => {
|
|
651
|
+
let context = getComboboxContext(handle);
|
|
652
|
+
return () => attrs({
|
|
653
|
+
disabled: context.disabled ? true : undefined,
|
|
654
|
+
name: context.name,
|
|
655
|
+
type: 'hidden',
|
|
656
|
+
value: context.value ?? '',
|
|
657
|
+
});
|
|
658
|
+
});
|
|
659
|
+
const optionMixin = createMixin((handle) => {
|
|
660
|
+
let context = getComboboxContext(handle);
|
|
661
|
+
return (options) => {
|
|
662
|
+
let hidden = !matchesSearchValue(getOptionSearchValue(options), context.filterText);
|
|
663
|
+
return [
|
|
664
|
+
attrs({ hidden: hidden ? true : undefined }),
|
|
665
|
+
on('pointerdown', (event) => {
|
|
666
|
+
if (event.button === 0) {
|
|
667
|
+
event.preventDefault();
|
|
668
|
+
}
|
|
669
|
+
}),
|
|
670
|
+
listbox.option({
|
|
671
|
+
disabled: options.disabled,
|
|
672
|
+
label: options.label,
|
|
673
|
+
textValue: options.searchValue,
|
|
674
|
+
value: options.value,
|
|
675
|
+
}),
|
|
676
|
+
];
|
|
677
|
+
};
|
|
678
|
+
});
|
|
679
|
+
export const Context = ComboboxProvider;
|
|
680
|
+
export const hiddenInput = hiddenInputMixin;
|
|
681
|
+
export const input = inputMixin;
|
|
682
|
+
export const list = listMixin;
|
|
683
|
+
export const option = optionMixin;
|
|
684
|
+
export { popoverMixin as popover };
|
|
685
|
+
const combobox = {
|
|
686
|
+
Context,
|
|
687
|
+
hiddenInput,
|
|
688
|
+
input,
|
|
689
|
+
list,
|
|
690
|
+
option,
|
|
691
|
+
popover: popoverMixin,
|
|
692
|
+
};
|
|
693
|
+
export function onComboboxChange(handler, captureBoolean) {
|
|
694
|
+
return on(COMBOBOX_CHANGE_EVENT, handler, captureBoolean);
|
|
695
|
+
}
|
|
696
|
+
export function Combobox(handle) {
|
|
697
|
+
return () => {
|
|
698
|
+
let { children, defaultValue, disabled, inputId, name, placeholder, ...divProps } = handle.props;
|
|
699
|
+
return (_jsx(combobox.Context, { defaultValue: defaultValue, disabled: disabled, name: name, children: _jsxs("div", { ...divProps, children: [_jsx("input", { defaultValue: defaultValue ?? undefined, id: inputId, mix: [inputStyle, combobox.input()], placeholder: placeholder }), _jsx("div", { mix: [popover.surfaceStyle, popoverStyle, combobox.popover()], children: _jsx("div", { mix: [popover.contentStyle, listbox.listStyle, combobox.list()], children: children }) }), name && _jsx("input", { mix: combobox.hiddenInput() })] }) }));
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
export function ComboboxOption(handle) {
|
|
703
|
+
return () => {
|
|
704
|
+
let { children, disabled, label, mix, searchValue, value, ...divProps } = handle.props;
|
|
705
|
+
return (_jsxs("div", { ...divProps, mix: [listbox.optionStyle, combobox.option({ disabled, label, searchValue, value }), mix], children: [_jsx(Glyph, { mix: listbox.glyphStyle, name: "check" }), _jsx("span", { mix: listbox.labelStyle, children: children ?? label })] }));
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
//# sourceMappingURL=combobox.js.map
|