@tcn/ui 0.10.0 → 0.12.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/feedback/index.d.ts +1 -0
- package/dist/feedback/index.d.ts.map +1 -1
- package/dist/feedback/index.js +6 -4
- package/dist/feedback/index.js.map +1 -1
- package/dist/feedback/progress/progress.d.ts +7 -0
- package/dist/feedback/progress/progress.d.ts.map +1 -0
- package/dist/feedback/progress/progress.js +38 -0
- package/dist/feedback/progress/progress.js.map +1 -0
- package/dist/feedback/progress/progress_bar.d.ts +0 -1
- package/dist/feedback/progress/progress_bar.d.ts.map +1 -1
- package/dist/feedback/progress/progress_bar.js +6 -46
- package/dist/feedback/progress/progress_bar.js.map +1 -1
- package/dist/form/field/common/status_input/status_input.js +4 -3
- package/dist/form/field/common/status_input/status_input.js.map +1 -1
- package/dist/form/field/h_field/h_field.d.ts.map +1 -1
- package/dist/form/field/h_field/h_field.js +33 -35
- package/dist/form/field/h_field/h_field.js.map +1 -1
- package/dist/form/field/v_field/v_field.d.ts.map +1 -1
- package/dist/form/field/v_field/v_field.js +34 -36
- package/dist/form/field/v_field/v_field.js.map +1 -1
- package/dist/frame.css +1 -1
- package/dist/inputs/color_input/color_input.d.ts.map +1 -1
- package/dist/inputs/color_input/color_input.js +47 -46
- package/dist/inputs/color_input/color_input.js.map +1 -1
- package/dist/inputs/combo_box/combo_box.d.ts.map +1 -1
- package/dist/inputs/combo_box/combo_box.js +61 -58
- package/dist/inputs/combo_box/combo_box.js.map +1 -1
- package/dist/inputs/index.d.ts +1 -0
- package/dist/inputs/index.d.ts.map +1 -1
- package/dist/inputs/index.js +34 -31
- package/dist/inputs/index.js.map +1 -1
- package/dist/inputs/input/input.js +9 -9
- package/dist/inputs/input/input.js.map +1 -1
- package/dist/inputs/input_group/input_group.d.ts +5 -0
- package/dist/inputs/input_group/input_group.d.ts.map +1 -0
- package/dist/inputs/input_group/input_group.js +20 -0
- package/dist/inputs/input_group/input_group.js.map +1 -0
- package/dist/inputs/phone_number_input/countries_phone_information.d.ts +2 -2
- package/dist/inputs/phone_number_input/countries_phone_information.d.ts.map +1 -1
- package/dist/inputs/phone_number_input/countries_phone_information.js +5 -353
- package/dist/inputs/phone_number_input/countries_phone_information.js.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_context.d.ts +24 -0
- package/dist/inputs/phone_number_input/phone_number_context.d.ts.map +1 -0
- package/dist/inputs/phone_number_input/phone_number_context.js +23 -0
- package/dist/inputs/phone_number_input/phone_number_context.js.map +1 -0
- package/dist/inputs/phone_number_input/phone_number_country_select_adapter.d.ts +19 -0
- package/dist/inputs/phone_number_input/phone_number_country_select_adapter.d.ts.map +1 -0
- package/dist/inputs/phone_number_input/phone_number_country_select_adapter.js +77 -0
- package/dist/inputs/phone_number_input/phone_number_country_select_adapter.js.map +1 -0
- package/dist/inputs/phone_number_input/phone_number_input.d.ts +16 -14
- package/dist/inputs/phone_number_input/phone_number_input.d.ts.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_input.js +104 -274
- package/dist/inputs/phone_number_input/phone_number_input.js.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_input_adapter.d.ts +6 -0
- package/dist/inputs/phone_number_input/phone_number_input_adapter.d.ts.map +1 -0
- package/dist/inputs/phone_number_input/phone_number_input_adapter.js +95 -0
- package/dist/inputs/phone_number_input/phone_number_input_adapter.js.map +1 -0
- package/dist/inputs/phone_number_input/sip_input.d.ts +12 -0
- package/dist/inputs/phone_number_input/sip_input.d.ts.map +1 -0
- package/dist/inputs/phone_number_input/sip_input.js +111 -0
- package/dist/inputs/phone_number_input/sip_input.js.map +1 -0
- package/dist/inputs/select/select.d.ts.map +1 -1
- package/dist/inputs/select/select.js +3 -2
- package/dist/inputs/select/select.js.map +1 -1
- package/dist/inputs/suggestions/suggestion_list.d.ts +4 -1
- package/dist/inputs/suggestions/suggestion_list.d.ts.map +1 -1
- package/dist/inputs/suggestions/suggestion_list.js +148 -121
- package/dist/inputs/suggestions/suggestion_list.js.map +1 -1
- package/dist/inputs/textarea/textarea.js +8 -8
- package/dist/inputs/textarea/textarea.js.map +1 -1
- package/dist/inputs/unit_input/unit_input.d.ts.map +1 -1
- package/dist/inputs/unit_input/unit_input.js +39 -39
- package/dist/inputs/unit_input/unit_input.js.map +1 -1
- package/dist/overlay/frame/frame.d.ts +8 -4
- package/dist/overlay/frame/frame.d.ts.map +1 -1
- package/dist/overlay/frame/frame.js +88 -24
- package/dist/overlay/frame/frame.js.map +1 -1
- package/dist/overlay/popper/base/dismissal_decorator.js.map +1 -1
- package/dist/overlay/popper/legacy/popper.d.ts.map +1 -1
- package/dist/overlay/popper/legacy/popper.js +52 -50
- package/dist/overlay/popper/legacy/popper.js.map +1 -1
- package/dist/phone_number_input.css +1 -1
- package/dist/progress_bar-CPP0Jyv-.js +38 -0
- package/dist/progress_bar-CPP0Jyv-.js.map +1 -0
- package/dist/progress_bar.css +1 -1
- package/dist/stacks/box/bottom_resize_handle.d.ts +2 -8
- package/dist/stacks/box/bottom_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/bottom_resize_handle.js.map +1 -1
- package/dist/stacks/box/box.d.ts +2 -2
- package/dist/stacks/box/box.d.ts.map +1 -1
- package/dist/stacks/box/box.js.map +1 -1
- package/dist/stacks/box/end_resize_handle.d.ts +2 -8
- package/dist/stacks/box/end_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/end_resize_handle.js.map +1 -1
- package/dist/stacks/box/left_resize_handle.d.ts +2 -8
- package/dist/stacks/box/left_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/left_resize_handle.js.map +1 -1
- package/dist/stacks/box/resize_handlers.d.ts +3 -2
- package/dist/stacks/box/resize_handlers.d.ts.map +1 -1
- package/dist/stacks/box/resize_handlers.js +41 -37
- package/dist/stacks/box/resize_handlers.js.map +1 -1
- package/dist/stacks/box/right_resize_handle.d.ts +2 -8
- package/dist/stacks/box/right_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/right_resize_handle.js.map +1 -1
- package/dist/stacks/box/start_resize_handle.d.ts +2 -8
- package/dist/stacks/box/start_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/start_resize_handle.js +4 -4
- package/dist/stacks/box/start_resize_handle.js.map +1 -1
- package/dist/stacks/box/top_resize_handle.d.ts +2 -8
- package/dist/stacks/box/top_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/top_resize_handle.js +4 -4
- package/dist/stacks/box/top_resize_handle.js.map +1 -1
- package/dist/stacks/box/types.d.ts +18 -0
- package/dist/stacks/box/types.d.ts.map +1 -0
- package/dist/stacks/h_collapsible_box.js +25 -25
- package/dist/stacks/h_collapsible_box.js.map +1 -1
- package/dist/stacks/index.d.ts +1 -0
- package/dist/stacks/index.d.ts.map +1 -1
- package/dist/stacks/v_collapsible_box.js +25 -25
- package/dist/stacks/v_collapsible_box.js.map +1 -1
- package/dist/suggestion_list.css +1 -1
- package/dist/surfaces/modal/modal.d.ts +3 -4
- package/dist/surfaces/modal/modal.d.ts.map +1 -1
- package/dist/surfaces/modal/modal.js +10 -8
- package/dist/surfaces/modal/modal.js.map +1 -1
- package/dist/surfaces/window/window.d.ts +3 -4
- package/dist/surfaces/window/window.d.ts.map +1 -1
- package/dist/surfaces/window/window.js +26 -14
- package/dist/surfaces/window/window.js.map +1 -1
- package/dist/themes/stylesheets/reset.css +1 -1
- package/dist/themes/stylesheets/reset.js +8 -1
- package/dist/themes/stylesheets/reset.js.map +1 -1
- package/dist/themes/themes/ergo/ergo_theme.css +1 -1
- package/dist/themes/themes/ergo/ergo_theme.js +186 -19
- package/dist/themes/themes/ergo/ergo_theme.js.map +1 -1
- package/dist/typography/body_text/body_text.d.ts.map +1 -1
- package/dist/typography/body_text/body_text.js +12 -10
- package/dist/typography/body_text/body_text.js.map +1 -1
- package/dist/utils/dnd/hooks/use_drag_container.d.ts.map +1 -1
- package/dist/utils/dnd/hooks/use_drag_container.js +22 -19
- package/dist/utils/dnd/hooks/use_drag_container.js.map +1 -1
- package/package.json +4 -2
- package/src/feedback/index.ts +1 -0
- package/src/feedback/progress/progress.module.css +5 -0
- package/src/feedback/progress/progress.stories.tsx +48 -0
- package/src/feedback/progress/progress.tsx +39 -0
- package/src/feedback/progress/progress_bar.module.css +4 -28
- package/src/feedback/progress/progress_bar.stories.tsx +1 -1
- package/src/feedback/progress/progress_bar.tsx +14 -26
- package/src/form/field/h_field/h_field.tsx +0 -4
- package/src/form/field/v_field/v_field.stories.tsx +8 -0
- package/src/form/field/v_field/v_field.tsx +1 -4
- package/src/form/field_set/field_set.stories.tsx +2 -1
- package/src/inputs/__docs__/inputs.mdx +81 -0
- package/src/inputs/__docs__/inputs.stories.tsx +268 -0
- package/src/inputs/color_input/color_input.tsx +17 -17
- package/src/inputs/combo_box/combo_box.tsx +17 -13
- package/src/inputs/index.ts +2 -0
- package/src/inputs/input/input.tsx +1 -1
- package/src/inputs/input_group/input_group.tsx +26 -0
- package/src/inputs/phone_number_input/countries_phone_information.ts +6 -353
- package/src/inputs/phone_number_input/phone_number_context.tsx +32 -0
- package/src/inputs/phone_number_input/phone_number_country_select_adapter.tsx +126 -0
- package/src/inputs/phone_number_input/phone_number_input.module.css +5 -63
- package/src/inputs/phone_number_input/phone_number_input.stories.tsx +180 -150
- package/src/inputs/phone_number_input/phone_number_input.tsx +133 -400
- package/src/inputs/phone_number_input/phone_number_input_adapter.tsx +123 -0
- package/src/inputs/phone_number_input/sip_input.tsx +147 -0
- package/src/inputs/select/select.stories.tsx +23 -2
- package/src/inputs/select/select.tsx +13 -14
- package/src/inputs/suggestions/suggestion_list.module.css +1 -0
- package/src/inputs/suggestions/suggestion_list.stories.tsx +12 -8
- package/src/inputs/suggestions/suggestion_list.tsx +82 -42
- package/src/inputs/textarea/textarea.tsx +1 -1
- package/src/inputs/unit_input/unit_input.tsx +17 -17
- package/src/overlay/frame/frame.module.css +2 -4
- package/src/overlay/frame/frame.stories.tsx +13 -10
- package/src/overlay/frame/frame.tsx +121 -15
- package/src/overlay/popper/base/dismissal_decorator.tsx +1 -1
- package/src/overlay/popper/legacy/popper.tsx +5 -1
- package/src/stacks/box/bottom_resize_handle.tsx +2 -8
- package/src/stacks/box/box.tsx +14 -2
- package/src/stacks/box/end_resize_handle.tsx +3 -8
- package/src/stacks/box/left_resize_handle.tsx +3 -8
- package/src/stacks/box/resize_handlers.ts +28 -12
- package/src/stacks/box/right_resize_handle.tsx +2 -8
- package/src/stacks/box/start_resize_handle.tsx +4 -9
- package/src/stacks/box/top_resize_handle.tsx +4 -8
- package/src/stacks/box/types.ts +44 -0
- package/src/stacks/h_collapsible_box.tsx +2 -2
- package/src/stacks/index.ts +1 -0
- package/src/stacks/v_collapsible_box.tsx +2 -2
- package/src/surfaces/modal/modal.tsx +6 -4
- package/src/surfaces/window/window.stories.tsx +9 -1
- package/src/surfaces/window/window.tsx +19 -7
- package/src/themes/stories/controls_fieldset.tsx +1 -1
- package/src/themes/stylesheets/reset.css +8 -1
- package/src/themes/themes/ergo/ergo_theme.css +186 -19
- package/src/typography/body_text/body_text.tsx +2 -0
- package/src/utils/dnd/__stories__/draggable.stories.tsx +14 -8
- package/src/utils/dnd/hooks/use_drag_container.ts +13 -3
- package/src/inputs/phone_number_input/__tests__/utils.test.ts +0 -52
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { jsxs as h, Fragment as v, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import g, { useLayoutEffect as F } from "react";
|
|
3
|
+
import { NotebookIcon as L } from "@tcn/icons/notebook_icon.js";
|
|
4
|
+
import { Input as R } from "../input/input.js";
|
|
5
|
+
import "../../actions/button/base_button/base_button.js";
|
|
6
|
+
import "../../actions/button/button_group/button_group.js";
|
|
7
|
+
import "../../actions/button/slim_button/slim_button.js";
|
|
8
|
+
import { Button as j } from "../../actions/button/button/button.js";
|
|
9
|
+
import "../../actions/button/select_group/select_group.js";
|
|
10
|
+
import "../../actions/button/select_group/single_select_group.js";
|
|
11
|
+
import "../../actions/toggle/toggle.js";
|
|
12
|
+
import { InputGroup as y } from "../input_group/input_group.js";
|
|
13
|
+
import z from "clsx";
|
|
14
|
+
import { usePhoneContext as V } from "./phone_number_context.js";
|
|
15
|
+
import { PhoneNumberCountrySelectAdapter as _ } from "./phone_number_country_select_adapter.js";
|
|
16
|
+
import { SuggestionList as q } from "../suggestions/suggestion_list.js";
|
|
17
|
+
function eo({
|
|
18
|
+
disabled: n,
|
|
19
|
+
countries: k,
|
|
20
|
+
name: B,
|
|
21
|
+
"aria-label": S,
|
|
22
|
+
autoFocus: P,
|
|
23
|
+
placeholder: b
|
|
24
|
+
}) {
|
|
25
|
+
const u = g.useRef(null), [i, t] = g.useState(null), l = i != null, {
|
|
26
|
+
phoneBook: s,
|
|
27
|
+
setValue: r,
|
|
28
|
+
setCountry: d,
|
|
29
|
+
ariaPhoneBookButtonLabel: I,
|
|
30
|
+
sipAddress: p,
|
|
31
|
+
setSipAddress: m,
|
|
32
|
+
focusNumberInput: c,
|
|
33
|
+
setFocusNumberInput: a
|
|
34
|
+
} = V(), C = s.length > 0;
|
|
35
|
+
function N(o) {
|
|
36
|
+
t(l ? null : o.currentTarget);
|
|
37
|
+
}
|
|
38
|
+
function f() {
|
|
39
|
+
t(null);
|
|
40
|
+
}
|
|
41
|
+
function x(o) {
|
|
42
|
+
f(), a(!0), r(o);
|
|
43
|
+
}
|
|
44
|
+
const A = k?.map((o) => ({
|
|
45
|
+
value: o,
|
|
46
|
+
label: o
|
|
47
|
+
})) || [];
|
|
48
|
+
function E(o) {
|
|
49
|
+
o !== "SIP" && (m(p), a(!0), r(""), d(o || "US"));
|
|
50
|
+
}
|
|
51
|
+
function O(o) {
|
|
52
|
+
m(o), r(`sip:${o}`);
|
|
53
|
+
}
|
|
54
|
+
return F(() => {
|
|
55
|
+
const o = u.current;
|
|
56
|
+
o == null || !c || requestAnimationFrame(() => {
|
|
57
|
+
o.value.length > 0 ? o.select() : o.focus();
|
|
58
|
+
});
|
|
59
|
+
}, [c]), /* @__PURE__ */ h(v, { children: [
|
|
60
|
+
/* @__PURE__ */ h(y, { children: [
|
|
61
|
+
/* @__PURE__ */ e(
|
|
62
|
+
_,
|
|
63
|
+
{
|
|
64
|
+
value: "SIP",
|
|
65
|
+
onChange: E,
|
|
66
|
+
options: A,
|
|
67
|
+
disabled: n
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
/* @__PURE__ */ e(
|
|
71
|
+
R,
|
|
72
|
+
{
|
|
73
|
+
ref: u,
|
|
74
|
+
value: p,
|
|
75
|
+
disabled: n,
|
|
76
|
+
onChange: O,
|
|
77
|
+
name: B,
|
|
78
|
+
"aria-label": S,
|
|
79
|
+
autoFocus: P,
|
|
80
|
+
placeholder: b
|
|
81
|
+
}
|
|
82
|
+
),
|
|
83
|
+
C && /* @__PURE__ */ e(
|
|
84
|
+
j,
|
|
85
|
+
{
|
|
86
|
+
disabled: n,
|
|
87
|
+
className: z("tcn-input-group-slot", "tcn-phone-number-phone-book"),
|
|
88
|
+
"aria-label": I,
|
|
89
|
+
onClick: N,
|
|
90
|
+
size: "md",
|
|
91
|
+
children: /* @__PURE__ */ e(L, { size: "md" })
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
] }),
|
|
95
|
+
/* @__PURE__ */ e(
|
|
96
|
+
q,
|
|
97
|
+
{
|
|
98
|
+
open: l,
|
|
99
|
+
anchorElement: i,
|
|
100
|
+
onOptionSelect: x,
|
|
101
|
+
onClose: f,
|
|
102
|
+
noSuggestionMessage: "No phone numbers found",
|
|
103
|
+
children: s
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
] });
|
|
107
|
+
}
|
|
108
|
+
export {
|
|
109
|
+
eo as SipInput
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=sip_input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sip_input.js","sources":["../../../src/inputs/phone_number_input/sip_input.tsx"],"sourcesContent":["import React, { useLayoutEffect } from 'react';\nimport { NotebookIcon } from '@tcn/icons/notebook_icon.js';\nimport { Input } from '../input/input.js';\nimport { Button } from '../../actions/index.js';\nimport { InputGroup } from '../input_group/input_group.js';\nimport clsx from 'clsx';\nimport { usePhoneContext } from './phone_number_context.js';\nimport type { CountryCode } from 'libphonenumber-js';\nimport {\n PhoneNumberCountrySelectAdapter,\n type CountryOption,\n} from './phone_number_country_select_adapter.js';\nimport { SuggestionList } from '../suggestions/suggestion_list.js';\n\nexport interface SipInputProps {\n onChange: (value: string) => void;\n countries?: CountryCode[];\n disabled?: boolean;\n name?: string;\n 'aria-label'?: string;\n autoFocus?: boolean;\n placeholder?: string;\n}\n\nexport function SipInput({\n disabled,\n countries,\n name,\n 'aria-label': ariaLabel,\n autoFocus,\n placeholder,\n}: SipInputProps) {\n const inputRef = React.useRef<HTMLInputElement>(null);\n const [phoneBookElement, setPhoneBookElement] =\n React.useState<HTMLButtonElement | null>(null);\n const isPhoneBookOpen = phoneBookElement != null;\n\n const {\n phoneBook: phoneBookOptions,\n setValue,\n setCountry,\n ariaPhoneBookButtonLabel,\n sipAddress,\n setSipAddress,\n focusNumberInput,\n setFocusNumberInput,\n } = usePhoneContext();\n\n const showPhoneBook = phoneBookOptions.length > 0;\n\n function togglePhoneBook(e: React.MouseEvent<HTMLButtonElement>) {\n if (isPhoneBookOpen) {\n setPhoneBookElement(null);\n } else {\n setPhoneBookElement(e.currentTarget);\n }\n }\n\n function closePhoneBook() {\n setPhoneBookElement(null);\n }\n\n function handlePhoneBookOptionSelect(value: string) {\n closePhoneBook();\n setFocusNumberInput(true);\n setValue(value);\n }\n\n const options: CountryOption[] =\n countries?.map(country => ({\n value: country,\n label: country,\n })) || [];\n\n function selectCountry(countryCode?: string) {\n if (countryCode !== 'SIP') {\n setSipAddress(sipAddress);\n setFocusNumberInput(true);\n setValue('');\n setCountry((countryCode as CountryCode) || 'US');\n }\n }\n\n function updateSipValue(value: string) {\n setSipAddress(value);\n setValue(`sip:${value}`);\n }\n\n useLayoutEffect(() => {\n const input = inputRef.current;\n\n if (input == null || !focusNumberInput) {\n return;\n }\n\n requestAnimationFrame(() => {\n if (input.value.length > 0) {\n input.select();\n } else {\n input.focus();\n }\n });\n }, [focusNumberInput]);\n\n return (\n <>\n <InputGroup>\n <PhoneNumberCountrySelectAdapter\n value=\"SIP\"\n onChange={selectCountry}\n options={options}\n disabled={disabled}\n />\n <Input\n ref={inputRef}\n value={sipAddress}\n disabled={disabled}\n onChange={updateSipValue}\n name={name}\n aria-label={ariaLabel}\n autoFocus={autoFocus}\n placeholder={placeholder}\n />\n {showPhoneBook && (\n <Button\n disabled={disabled}\n className={clsx('tcn-input-group-slot', 'tcn-phone-number-phone-book')}\n aria-label={ariaPhoneBookButtonLabel}\n onClick={togglePhoneBook}\n size=\"md\"\n >\n <NotebookIcon size=\"md\" />\n </Button>\n )}\n </InputGroup>\n <SuggestionList\n open={isPhoneBookOpen}\n anchorElement={phoneBookElement}\n onOptionSelect={handlePhoneBookOptionSelect}\n onClose={closePhoneBook}\n noSuggestionMessage=\"No phone numbers found\"\n >\n {phoneBookOptions}\n </SuggestionList>\n </>\n );\n}\n"],"names":["SipInput","disabled","countries","name","ariaLabel","autoFocus","placeholder","inputRef","React","phoneBookElement","setPhoneBookElement","isPhoneBookOpen","phoneBookOptions","setValue","setCountry","ariaPhoneBookButtonLabel","sipAddress","setSipAddress","focusNumberInput","setFocusNumberInput","usePhoneContext","showPhoneBook","togglePhoneBook","e","closePhoneBook","handlePhoneBookOptionSelect","value","options","country","selectCountry","countryCode","updateSipValue","useLayoutEffect","input","jsxs","Fragment","InputGroup","jsx","PhoneNumberCountrySelectAdapter","Input","Button","clsx","NotebookIcon","SuggestionList"],"mappings":";;;;;;;;;;;;;;;;AAwBO,SAASA,GAAS;AAAA,EACvB,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,MAAAC;AAAA,EACA,cAAcC;AAAA,EACd,WAAAC;AAAA,EACA,aAAAC;AACF,GAAkB;AAChB,QAAMC,IAAWC,EAAM,OA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AAC,EAAE,GAAG,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IAC/E,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../src/inputs/select/select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAOlE,MAAM,WAAW,WACf,SAAQ,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;IAC5D,QAAQ,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,GAAG,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IAC/E,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,eAAO,MAAM,MAAM,oGA0IjB,CAAC"}
|
|
@@ -77,7 +77,7 @@ const he = F.forwardRef(function({
|
|
|
77
77
|
W,
|
|
78
78
|
{
|
|
79
79
|
ref: B,
|
|
80
|
-
className: L(T, "tcn-select", O.select),
|
|
80
|
+
className: L(T, "tcn-select", "tcn-control", O.select),
|
|
81
81
|
width: "100%",
|
|
82
82
|
...D,
|
|
83
83
|
hAlign: "start",
|
|
@@ -89,9 +89,10 @@ const he = F.forwardRef(function({
|
|
|
89
89
|
children: /* @__PURE__ */ u("span", { className: L(O.selectedLabel, "tcn-select-selected-label"), children: k })
|
|
90
90
|
}
|
|
91
91
|
),
|
|
92
|
-
|
|
92
|
+
/* @__PURE__ */ u(
|
|
93
93
|
Q,
|
|
94
94
|
{
|
|
95
|
+
open: y,
|
|
95
96
|
anchorElement: q,
|
|
96
97
|
onClose: N,
|
|
97
98
|
value: "",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","sources":["../../../src/inputs/select/select.tsx"],"sourcesContent":["import { useForkRef } from '../../utils/index.js';\nimport { clsx } from 'clsx';\nimport React, { useRef, useState } from 'react';\nimport { SuggestionList } from '../suggestions/suggestion_list.js';\nimport { OptionProps } from '../options/option.js';\nimport { Button, type ButtonProps } from '../../actions/index.js';\nimport styles from './select.module.css';\n\nfunction findOptionFromValue(options: React.ReactElement<OptionProps>[], value: string) {\n return options.find(option => option.props.value === value);\n}\n\nexport interface SelectProps\n extends Omit<ButtonProps, 'children' | 'onChange' | 'value'> {\n children?: React.ReactElement<OptionProps>[] | React.ReactElement<OptionProps>;\n onChange?: (value: string) => void;\n value?: string | null;\n placeholder?: string;\n noOptionMatchedMessage?: React.ReactNode;\n trimCustomInput?: boolean;\n}\n\nexport const Select = React.forwardRef(function Select(\n {\n children = [],\n onKeyDown,\n onKeyUp,\n value,\n placeholder = '-- Select --',\n noOptionMatchedMessage,\n trimCustomInput = false,\n className,\n onMouseDown,\n onMouseUp,\n onChange,\n ...props\n }: SelectProps,\n ref: React.Ref<HTMLButtonElement>\n) {\n const safeChildren = React.Children.toArray(\n children\n ) as React.ReactElement<OptionProps>[];\n const keyPressedDownRef = useRef('');\n const isAlreadyFocusedRef = useRef(false);\n const isClosingRef = useRef(false);\n const [anchorElement, setAnchorElement] = useState<HTMLButtonElement | null>(null);\n const internalButtonRef = useRef<HTMLButtonElement | null>(null);\n const [isSuggestionsOpen, setIsSuggestionsOpen] = useState(false);\n const forkedRef = useForkRef(ref, internalButtonRef);\n const selectedOption = findOptionFromValue(safeChildren, value || '');\n const selectedLabel =\n selectedOption == null ? placeholder || '' : selectedOption.props.label;\n\n function openSuggestions() {\n setIsSuggestionsOpen(true);\n }\n\n function closeSuggestions() {\n setIsSuggestionsOpen(false);\n }\n\n function handleClose() {\n const button = internalButtonRef.current;\n\n if (button != null) {\n requestAnimationFrame(() => {\n button.focus();\n });\n }\n\n closeSuggestions();\n }\n\n function handleSelection(value: string, _: string | undefined, isSuggestion: boolean) {\n const button = internalButtonRef.current;\n\n if (button != null) {\n requestAnimationFrame(() => {\n if (isSuggestion) {\n onChange && onChange(value);\n }\n button.focus();\n });\n }\n\n closeSuggestions();\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLButtonElement>) {\n const key = event.key;\n keyPressedDownRef.current = key;\n onKeyDown && onKeyDown(event);\n }\n\n function handleKeyUp(event: React.KeyboardEvent<HTMLButtonElement>) {\n setAnchorElement(event.currentTarget);\n const isSameKey = (keyPressedDownRef.current = event.key);\n\n keyPressedDownRef.current = '';\n const key = event.key;\n\n if (isSameKey && (key === 'Enter' || key === ' ')) {\n if (isSuggestionsOpen) {\n closeSuggestions();\n } else {\n openSuggestions();\n }\n }\n\n onKeyUp && onKeyUp(event);\n }\n\n function handlMouseDown(event: React.MouseEvent<HTMLButtonElement>) {\n setAnchorElement(event.currentTarget);\n isAlreadyFocusedRef.current = document.activeElement === event.currentTarget;\n onMouseDown && onMouseDown(event);\n }\n\n function handleMouseUp(event: React.MouseEvent<HTMLButtonElement>) {\n if (isClosingRef.current) {\n isClosingRef.current = false;\n closeSuggestions();\n }\n\n openSuggestions();\n onMouseUp && onMouseUp(event);\n }\n\n return (\n <>\n <Button\n ref={forkedRef}\n className={clsx(className, 'tcn-select', styles.select)}\n width=\"100%\"\n {...props}\n hAlign=\"start\"\n value={selectedLabel}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n onMouseDown={handlMouseDown}\n onMouseUp={handleMouseUp}\n >\n <span className={clsx(styles.selectedLabel, 'tcn-select-selected-label')}>\n {selectedLabel}\n </span>\n </Button>\n {isSuggestionsOpen
|
|
1
|
+
{"version":3,"file":"select.js","sources":["../../../src/inputs/select/select.tsx"],"sourcesContent":["import { useForkRef } from '../../utils/index.js';\nimport { clsx } from 'clsx';\nimport React, { useRef, useState } from 'react';\nimport { SuggestionList } from '../suggestions/suggestion_list.js';\nimport { OptionProps } from '../options/option.js';\nimport { Button, type ButtonProps } from '../../actions/index.js';\nimport styles from './select.module.css';\n\nfunction findOptionFromValue(options: React.ReactElement<OptionProps>[], value: string) {\n return options.find(option => option.props.value === value);\n}\n\nexport interface SelectProps\n extends Omit<ButtonProps, 'children' | 'onChange' | 'value'> {\n children?: React.ReactElement<OptionProps>[] | React.ReactElement<OptionProps>;\n onChange?: (value: string) => void;\n value?: string | null;\n placeholder?: string;\n noOptionMatchedMessage?: React.ReactNode;\n trimCustomInput?: boolean;\n}\n\nexport const Select = React.forwardRef(function Select(\n {\n children = [],\n onKeyDown,\n onKeyUp,\n value,\n placeholder = '-- Select --',\n noOptionMatchedMessage,\n trimCustomInput = false,\n className,\n onMouseDown,\n onMouseUp,\n onChange,\n ...props\n }: SelectProps,\n ref: React.Ref<HTMLButtonElement>\n) {\n const safeChildren = React.Children.toArray(\n children\n ) as React.ReactElement<OptionProps>[];\n const keyPressedDownRef = useRef('');\n const isAlreadyFocusedRef = useRef(false);\n const isClosingRef = useRef(false);\n const [anchorElement, setAnchorElement] = useState<HTMLButtonElement | null>(null);\n const internalButtonRef = useRef<HTMLButtonElement | null>(null);\n const [isSuggestionsOpen, setIsSuggestionsOpen] = useState(false);\n const forkedRef = useForkRef(ref, internalButtonRef);\n const selectedOption = findOptionFromValue(safeChildren, value || '');\n const selectedLabel =\n selectedOption == null ? placeholder || '' : selectedOption.props.label;\n\n function openSuggestions() {\n setIsSuggestionsOpen(true);\n }\n\n function closeSuggestions() {\n setIsSuggestionsOpen(false);\n }\n\n function handleClose() {\n const button = internalButtonRef.current;\n\n if (button != null) {\n requestAnimationFrame(() => {\n button.focus();\n });\n }\n\n closeSuggestions();\n }\n\n function handleSelection(value: string, _: string | undefined, isSuggestion: boolean) {\n const button = internalButtonRef.current;\n\n if (button != null) {\n requestAnimationFrame(() => {\n if (isSuggestion) {\n onChange && onChange(value);\n }\n button.focus();\n });\n }\n\n closeSuggestions();\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLButtonElement>) {\n const key = event.key;\n keyPressedDownRef.current = key;\n onKeyDown && onKeyDown(event);\n }\n\n function handleKeyUp(event: React.KeyboardEvent<HTMLButtonElement>) {\n setAnchorElement(event.currentTarget);\n const isSameKey = (keyPressedDownRef.current = event.key);\n\n keyPressedDownRef.current = '';\n const key = event.key;\n\n if (isSameKey && (key === 'Enter' || key === ' ')) {\n if (isSuggestionsOpen) {\n closeSuggestions();\n } else {\n openSuggestions();\n }\n }\n\n onKeyUp && onKeyUp(event);\n }\n\n function handlMouseDown(event: React.MouseEvent<HTMLButtonElement>) {\n setAnchorElement(event.currentTarget);\n isAlreadyFocusedRef.current = document.activeElement === event.currentTarget;\n onMouseDown && onMouseDown(event);\n }\n\n function handleMouseUp(event: React.MouseEvent<HTMLButtonElement>) {\n if (isClosingRef.current) {\n isClosingRef.current = false;\n closeSuggestions();\n }\n\n openSuggestions();\n onMouseUp && onMouseUp(event);\n }\n\n return (\n <>\n <Button\n ref={forkedRef}\n className={clsx(className, 'tcn-select', 'tcn-control', styles.select)}\n width=\"100%\"\n {...props}\n hAlign=\"start\"\n value={selectedLabel}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n onMouseDown={handlMouseDown}\n onMouseUp={handleMouseUp}\n >\n <span className={clsx(styles.selectedLabel, 'tcn-select-selected-label')}>\n {selectedLabel}\n </span>\n </Button>\n <SuggestionList\n open={isSuggestionsOpen}\n anchorElement={anchorElement}\n onClose={handleClose}\n value={''}\n scrollToValue={value || ''}\n trimCustomInput={trimCustomInput}\n onOptionSelect={handleSelection}\n noSuggestionMessage={noOptionMatchedMessage}\n >\n {children}\n </SuggestionList>\n </>\n );\n});\n"],"names":["findOptionFromValue","options","value","option","Select","React","children","onKeyDown","onKeyUp","placeholder","noOptionMatchedMessage","trimCustomInput","className","onMouseDown","onMouseUp","onChange","props","ref","safeChildren","keyPressedDownRef","useRef","isAlreadyFocusedRef","isClosingRef","anchorElement","setAnchorElement","useState","internalButtonRef","isSuggestionsOpen","setIsSuggestionsOpen","forkedRef","useForkRef","selectedOption","selectedLabel","openSuggestions","closeSuggestions","handleClose","button","handleSelection","_","isSuggestion","handleKeyDown","event","key","handleKeyUp","isSameKey","handlMouseDown","handleMouseUp","jsxs","Fragment","jsx","Button","clsx","styles","SuggestionList"],"mappings":";;;;;;;;;;;;;;;;;;;AAQA,SAASA,EAAoBC,GAA4CC,GAAe;AACtF,SAAOD,EAAQ,KAAK,CAAAE,MAAUA,EAAO,MAAM,UAAUD,CAAK;AAC5D;AAYO,MAAME,KAASC,EAAM,WAAW,SACrC;AAAA,EACE,UAAAC,IAAW,CAAA;AAAA,EACX,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,OAAAN;AAAA,EACA,aAAAO,IAAc;AAAA,EACd,wBAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACL,GACAC,GACA;AACA,QAAMC,IAAeb,EAAM,SAAS;AAAA,IAClCC;AAAA,EAAA,GAEIa,IAAoBC,EAAO,EAAE,GAC7BC,IAAsBD,EAAO,EAAK,GAClCE,IAAeF,EAAO,EAAK,GAC3B,CAACG,GAAeC,CAAgB,IAAIC,EAAmC,IAAI,GAC3EC,IAAoBN,EAAiC,IAAI,GACzD,CAACO,GAAmBC,CAAoB,IAAIH,EAAS,EAA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EAAa,YACfA,EAAa,UAAU,IACvBY,EAAA,IAGFD,EAAA,GACAnB,KAAaA,EAAU2B,CAAK;AAAA,EAC9B;AAEA,SACE,gBAAAM,EAAAC,GAAA,EACE,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,KAAKrB;AAAA,QACL,WAAWsB,EAAKvC,GAAW,cAAc,eAAewC,EAAO,MAAM;AAAA,QACrE,OAAM;AAAA,QACL,GAAGpC;AAAA,QACJ,QAAO;AAAA,QACP,OAAOgB;AAAA,QACP,WAAWQ;AAAA,QACX,SAASG;AAAA,QACT,aAAaE;AAAA,QACb,WAAWC;AAAA,QAEX,UAAA,gBAAAG,EAAC,UAAK,WAAWE,EAAKC,EAAO,eAAe,2BAA2B,GACpE,UAAApB,EAAA,CACH;AAAA,MAAA;AAAA,IAAA;AAAA,IAEF,gBAAAiB;AAAA,MAACI;AAAA,MAAA;AAAA,QACC,MAAM1B;AAAA,QACN,eAAAJ;AAAA,QACA,SAASY;AAAA,QACT,OAAO;AAAA,QACP,eAAejC,KAAS;AAAA,QACxB,iBAAAS;AAAA,QACA,gBAAgB0B;AAAA,QAChB,qBAAqB3B;AAAA,QAEpB,UAAAJ;AAAA,MAAA;AAAA,IAAA;AAAA,EACH,GACF;AAEJ,CAAC;"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
export interface SuggestionListProps extends Omit<React.HTMLAttributes<HTMLInputElement>, 'onChange'> {
|
|
3
3
|
value?: string;
|
|
4
|
+
initialSearchValue?: string;
|
|
4
5
|
scrollToValue?: string;
|
|
5
6
|
anchorElement: HTMLElement | null;
|
|
7
|
+
open?: boolean;
|
|
6
8
|
children?: React.ReactNode;
|
|
7
9
|
onChange?: (value: string) => void;
|
|
8
10
|
onOptionSelect?: (value: string, label: string | undefined, isSuggestion: boolean, obfuscate: boolean) => void;
|
|
9
11
|
noSuggestionMessage?: React.ReactNode;
|
|
10
12
|
trimCustomInput?: boolean;
|
|
11
13
|
haveValueAsOption?: boolean;
|
|
14
|
+
restoreFocus?: boolean;
|
|
12
15
|
onClose?: (inputValue: string, cursorStartPosition: number | null, cursorEndPosition: number | null) => void;
|
|
13
16
|
}
|
|
14
|
-
export declare function SuggestionList({ value, scrollToValue, anchorElement, children, onOptionSelect, noSuggestionMessage, onClose, onChange, onKeyUp, onKeyDown, trimCustomInput, haveValueAsOption, ...props }: SuggestionListProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function SuggestionList({ value, initialSearchValue: searchValue, scrollToValue, anchorElement, open, children, onOptionSelect, noSuggestionMessage, onClose, onChange, onKeyUp, onKeyDown, trimCustomInput, haveValueAsOption, restoreFocus, ...props }: SuggestionListProps): import("react/jsx-runtime").JSX.Element;
|
|
15
18
|
//# sourceMappingURL=suggestion_list.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggestion_list.d.ts","sourceRoot":"","sources":["../../../src/inputs/suggestions/suggestion_list.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAazE,MAAM,WAAW,mBACf,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,WAAW,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,cAAc,CAAC,EAAE,CACf,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,YAAY,EAAE,OAAO,EACrB,SAAS,EAAE,OAAO,KACf,IAAI,CAAC;IACV,mBAAmB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACtC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,OAAO,CAAC,EAAE,CACR,UAAU,EAAE,MAAM,EAClB,mBAAmB,EAAE,MAAM,GAAG,IAAI,EAClC,iBAAiB,EAAE,MAAM,GAAG,IAAI,KAC7B,IAAI,CAAC;CACX;AAED,wBAAgB,cAAc,CAAC,EAC7B,KAAU,EACV,aAAa,EACb,aAAa,EACb,QAAQ,EACR,cAAc,EACd,mBAAwC,EACxC,OAAO,EACP,QAAQ,EACR,OAAO,EACP,SAAS,EACT,eAAuB,EACvB,iBAAyB,EACzB,GAAG,KAAK,EACT,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"suggestion_list.d.ts","sourceRoot":"","sources":["../../../src/inputs/suggestions/suggestion_list.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAazE,MAAM,WAAW,mBACf,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,WAAW,GAAG,IAAI,CAAC;IAClC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,cAAc,CAAC,EAAE,CACf,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,YAAY,EAAE,OAAO,EACrB,SAAS,EAAE,OAAO,KACf,IAAI,CAAC;IACV,mBAAmB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACtC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,CACR,UAAU,EAAE,MAAM,EAClB,mBAAmB,EAAE,MAAM,GAAG,IAAI,EAClC,iBAAiB,EAAE,MAAM,GAAG,IAAI,KAC7B,IAAI,CAAC;CACX;AAED,wBAAgB,cAAc,CAAC,EAC7B,KAAU,EACV,kBAAkB,EAAE,WAAW,EAC/B,aAAa,EACb,aAAa,EACb,IAAY,EACZ,QAAQ,EACR,cAAc,EACd,mBAAwC,EACxC,OAAO,EACP,QAAQ,EACR,OAAO,EACP,SAAS,EACT,eAAuB,EACvB,iBAAyB,EACzB,YAAmB,EACnB,GAAG,KAAK,EACT,EAAE,mBAAmB,2CA4ZrB"}
|
|
@@ -1,106 +1,115 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
2
|
-
import { BodyText as
|
|
1
|
+
import { jsx as r, jsxs as j, Fragment as de } from "react/jsx-runtime";
|
|
2
|
+
import { BodyText as ge } from "../../typography/body_text/body_text.js";
|
|
3
3
|
import "../../typography/callout/callout.js";
|
|
4
4
|
import "../../typography/caption/caption.js";
|
|
5
5
|
import "../../typography/footnote/footnote.js";
|
|
6
6
|
import "../../typography/headline/headline.js";
|
|
7
7
|
import "../../typography/subheadline/subheadline.js";
|
|
8
8
|
import "../../typography/title/title.js";
|
|
9
|
-
import { VStack as
|
|
10
|
-
import { ZStack as
|
|
11
|
-
import { clsx as
|
|
12
|
-
import { Children as
|
|
9
|
+
import { VStack as q } from "../../stacks/v_stack.js";
|
|
10
|
+
import { ZStack as he } from "../../stacks/z_stack.js";
|
|
11
|
+
import { clsx as H } from "clsx";
|
|
12
|
+
import Z, { Children as me, isValidElement as we, useState as a, useRef as B, useLayoutEffect as h } from "react";
|
|
13
13
|
import "../../utils/click_away_listener.js";
|
|
14
|
-
import { FocusRedirect as
|
|
14
|
+
import { FocusRedirect as be } from "../../utils/focus_redirect.js";
|
|
15
15
|
import "../../utils/scroll_away_listener.js";
|
|
16
16
|
import "../../utils/hooks/use_resize_observer.js";
|
|
17
17
|
import "../../utils/dnd/context.js";
|
|
18
18
|
import "../../draggable.module-BgelQsuJ.js";
|
|
19
|
-
import { SuggestionItem as
|
|
20
|
-
import { Option as
|
|
19
|
+
import { SuggestionItem as xe } from "./suggestion_item.js";
|
|
20
|
+
import { Option as X } from "../options/option.js";
|
|
21
21
|
import "../../actions/button/base_button/base_button.js";
|
|
22
22
|
import "../../actions/button/button_group/button_group.js";
|
|
23
23
|
import "../../actions/button/slim_button/slim_button.js";
|
|
24
|
-
import { Button as
|
|
24
|
+
import { Button as ke } from "../../actions/button/button/button.js";
|
|
25
25
|
import "../../actions/button/select_group/select_group.js";
|
|
26
26
|
import "../../actions/button/select_group/single_select_group.js";
|
|
27
27
|
import "../../actions/toggle/toggle.js";
|
|
28
|
-
import { Popper as
|
|
29
|
-
import '../../suggestion_list.css';const
|
|
30
|
-
function
|
|
31
|
-
value:
|
|
32
|
-
|
|
28
|
+
import { Popper as Le } from "../../overlay/popper/legacy/popper.js";
|
|
29
|
+
import '../../suggestion_list.css';const ye = "_suggestion-list_711fb17", Se = "_input_a0df060", K = { "suggestion-list": ye, input: Se }, C = 50, Me = 50;
|
|
30
|
+
function Ye({
|
|
31
|
+
value: R = "",
|
|
32
|
+
initialSearchValue: E,
|
|
33
|
+
scrollToValue: m,
|
|
33
34
|
anchorElement: l,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
open: v = !1,
|
|
36
|
+
children: N,
|
|
37
|
+
onOptionSelect: w,
|
|
38
|
+
noSuggestionMessage: z = "-- No Matches --",
|
|
39
|
+
onClose: L,
|
|
40
|
+
onChange: O,
|
|
41
|
+
onKeyUp: T,
|
|
42
|
+
onKeyDown: U,
|
|
43
|
+
trimCustomInput: G = !1,
|
|
44
|
+
haveValueAsOption: P = !1,
|
|
45
|
+
restoreFocus: J = !0,
|
|
46
|
+
...Q
|
|
44
47
|
}) {
|
|
45
|
-
const
|
|
46
|
-
(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
const b = Z.useMemo(
|
|
49
|
+
() => me.toArray(N).filter(
|
|
50
|
+
(e) => we(e) && e.type === X
|
|
51
|
+
),
|
|
52
|
+
[N]
|
|
53
|
+
), [y, Y] = a(() => {
|
|
54
|
+
if (m != null) {
|
|
55
|
+
const e = b.findIndex((o) => o.props.value === m);
|
|
50
56
|
if (e !== -1)
|
|
51
57
|
return e;
|
|
52
58
|
}
|
|
53
59
|
return -1;
|
|
54
|
-
}),
|
|
55
|
-
() =>
|
|
56
|
-
), [
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
}), A = B(""), _ = B(!1), [ee, V] = a(C), [d, S] = a(y), [x, W] = a(R), c = B(null), [te, se] = a(b.length), [n, D] = a(
|
|
61
|
+
() => []
|
|
62
|
+
), [ne, oe] = a(), [ie, re] = a();
|
|
63
|
+
function le(e) {
|
|
64
|
+
if (!_.current)
|
|
65
|
+
return;
|
|
66
|
+
_.current = !1;
|
|
67
|
+
const o = e.key, t = e.currentTarget, s = A.current = o;
|
|
68
|
+
if (A.current = "", s)
|
|
60
69
|
switch (o) {
|
|
61
70
|
case "Enter": {
|
|
62
|
-
if (n[
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
71
|
+
if (n[d] == null) {
|
|
72
|
+
const u = G ? t.value.trim() : t.value;
|
|
73
|
+
if (u === "")
|
|
65
74
|
return;
|
|
66
|
-
const
|
|
67
|
-
(
|
|
68
|
-
),
|
|
75
|
+
const k = u.toLocaleLowerCase(), g = b.find(
|
|
76
|
+
(F) => F.props.value.toLocaleLowerCase() === k || F.props.label != null && F.props.label.toLocaleLowerCase() === k
|
|
77
|
+
), p = g != null, $ = g?.props.label || u, f = g?.props.value || u;
|
|
69
78
|
requestAnimationFrame(() => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
w && w(
|
|
80
|
+
f,
|
|
81
|
+
$,
|
|
82
|
+
p,
|
|
83
|
+
g?.props.obfuscate ?? !1
|
|
75
84
|
);
|
|
76
85
|
});
|
|
77
86
|
break;
|
|
78
87
|
}
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
88
|
+
const i = n[d].props;
|
|
89
|
+
if (i.disabled)
|
|
81
90
|
break;
|
|
82
91
|
requestAnimationFrame(() => {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
92
|
+
w && w(
|
|
93
|
+
i.value,
|
|
94
|
+
i.label,
|
|
86
95
|
!0,
|
|
87
|
-
|
|
96
|
+
i.obfuscate ?? !1
|
|
88
97
|
);
|
|
89
98
|
});
|
|
90
99
|
break;
|
|
91
100
|
}
|
|
92
101
|
case "Escape": {
|
|
93
|
-
|
|
102
|
+
L && L(t.value, t.selectionStart, t.selectionEnd);
|
|
94
103
|
break;
|
|
95
104
|
}
|
|
96
105
|
}
|
|
97
|
-
|
|
106
|
+
T && T(e);
|
|
98
107
|
}
|
|
99
|
-
function
|
|
108
|
+
function ce(e) {
|
|
100
109
|
const o = e.key;
|
|
101
|
-
switch (
|
|
110
|
+
switch (A.current = o, _.current = !0, o) {
|
|
102
111
|
case "ArrowDown": {
|
|
103
|
-
let t =
|
|
112
|
+
let t = d + 1;
|
|
104
113
|
for (; t < n.length && n[t]?.props.disabled; )
|
|
105
114
|
t++;
|
|
106
115
|
if (t === n.length) {
|
|
@@ -108,13 +117,13 @@ function Xe({
|
|
|
108
117
|
t++;
|
|
109
118
|
t === n.length && (t = -1);
|
|
110
119
|
}
|
|
111
|
-
|
|
120
|
+
S(t), e.preventDefault();
|
|
112
121
|
break;
|
|
113
122
|
}
|
|
114
123
|
case "Tab": {
|
|
115
124
|
let t = 1;
|
|
116
125
|
e.shiftKey && (t = -1);
|
|
117
|
-
let s =
|
|
126
|
+
let s = d + t;
|
|
118
127
|
if (t > 0)
|
|
119
128
|
for (; s < n.length && n[s]?.props.disabled; )
|
|
120
129
|
s++;
|
|
@@ -130,11 +139,11 @@ function Xe({
|
|
|
130
139
|
s--;
|
|
131
140
|
s === -1 && (s = -1);
|
|
132
141
|
}
|
|
133
|
-
|
|
142
|
+
S(s), e.preventDefault();
|
|
134
143
|
break;
|
|
135
144
|
}
|
|
136
145
|
case "ArrowUp": {
|
|
137
|
-
let t =
|
|
146
|
+
let t = d - 1;
|
|
138
147
|
for (; t >= 0 && n[t]?.props.disabled; )
|
|
139
148
|
t--;
|
|
140
149
|
if (t === -1) {
|
|
@@ -142,112 +151,130 @@ function Xe({
|
|
|
142
151
|
t--;
|
|
143
152
|
t === -1 && (t = -1);
|
|
144
153
|
}
|
|
145
|
-
|
|
154
|
+
S(t), e.preventDefault();
|
|
146
155
|
break;
|
|
147
156
|
}
|
|
148
157
|
}
|
|
149
|
-
|
|
158
|
+
U && U(e);
|
|
150
159
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
const M = Z.useCallback(
|
|
161
|
+
function(o, t) {
|
|
162
|
+
const s = b.filter((I) => {
|
|
163
|
+
const i = I.props, u = String(i.label).toLocaleLowerCase(), k = i.keywords?.map((f) => f.toLocaleLowerCase()) || [], g = String(i.value).toLocaleLowerCase(), p = o.toLocaleLowerCase();
|
|
164
|
+
return i.obfuscate ?? !1 ? u.includes(p) || k.some((f) => f.includes(p)) : u.includes(p) || k.some((f) => f.includes(p)) || g.includes(p);
|
|
165
|
+
});
|
|
166
|
+
return P && o.trim().length > 0 && !s.some((I) => I.props.value === o) && s.unshift(
|
|
167
|
+
/* @__PURE__ */ r(X, { value: o, label: o, keywords: [o], children: o }, "value")
|
|
168
|
+
), se(s.length), s.slice(0, t);
|
|
169
|
+
},
|
|
170
|
+
[b, P]
|
|
171
|
+
);
|
|
172
|
+
function ae() {
|
|
161
173
|
const e = c.current;
|
|
162
174
|
e?.focus();
|
|
163
175
|
}
|
|
164
|
-
function
|
|
176
|
+
function ue() {
|
|
165
177
|
const e = c.current;
|
|
166
|
-
e != null &&
|
|
178
|
+
e != null && L && L(e.value, e.selectionStart, e.selectionEnd);
|
|
167
179
|
}
|
|
168
|
-
function
|
|
180
|
+
function pe(e) {
|
|
169
181
|
const o = e.currentTarget;
|
|
170
|
-
|
|
171
|
-
const t =
|
|
172
|
-
|
|
182
|
+
V(C), W(e.target.value);
|
|
183
|
+
const t = M(o.value, C);
|
|
184
|
+
D(t), O && O(e.target.value);
|
|
173
185
|
}
|
|
174
|
-
function
|
|
175
|
-
const e =
|
|
176
|
-
|
|
177
|
-
const o =
|
|
178
|
-
|
|
186
|
+
function fe() {
|
|
187
|
+
const e = ee + Me;
|
|
188
|
+
V(e);
|
|
189
|
+
const o = M(x, e);
|
|
190
|
+
D(o);
|
|
179
191
|
}
|
|
180
|
-
return
|
|
192
|
+
return h(() => {
|
|
181
193
|
const e = c.current;
|
|
182
|
-
e != null && e.value.length > 0 ? e.select() : e?.focus();
|
|
183
|
-
}, []),
|
|
194
|
+
v && (e != null && e.value.length > 0 ? e.select() : e?.focus());
|
|
195
|
+
}, [v]), h(() => {
|
|
184
196
|
if (l != null) {
|
|
185
197
|
const e = l.getBoundingClientRect();
|
|
186
|
-
|
|
198
|
+
oe(`${e.width}px`), re(`${e.height}px`), c.current != null && l instanceof HTMLInputElement && (c.current.value = l.value, c.current.selectionStart = l.selectionStart, c.current.selectionEnd = l.selectionEnd);
|
|
187
199
|
}
|
|
188
|
-
}, [l]),
|
|
189
|
-
if (
|
|
200
|
+
}, [l]), h(() => {
|
|
201
|
+
if (m != null) {
|
|
190
202
|
const e = n.findIndex(
|
|
191
|
-
(o) => o.props.value ===
|
|
203
|
+
(o) => o.props.value === m
|
|
192
204
|
);
|
|
193
|
-
|
|
205
|
+
Y(e);
|
|
194
206
|
}
|
|
195
|
-
}, [n,
|
|
196
|
-
|
|
197
|
-
}, [
|
|
198
|
-
|
|
207
|
+
}, [n, m]), h(() => {
|
|
208
|
+
S(x === "" ? y : -1);
|
|
209
|
+
}, [x, y]), h(() => {
|
|
210
|
+
W(E ?? "");
|
|
211
|
+
}, [E]), h(() => {
|
|
212
|
+
const e = M(R, C);
|
|
213
|
+
D(e);
|
|
214
|
+
}, [R, M]), /* @__PURE__ */ r(
|
|
215
|
+
Le,
|
|
199
216
|
{
|
|
200
|
-
open:
|
|
217
|
+
open: v,
|
|
201
218
|
anchorElement: l,
|
|
202
|
-
onClose:
|
|
219
|
+
onClose: ue,
|
|
203
220
|
verticalAnchor: "top",
|
|
204
221
|
verticalOrigin: "top",
|
|
205
222
|
verticalOffset: -4,
|
|
206
|
-
|
|
207
|
-
|
|
223
|
+
restoreFocus: J,
|
|
224
|
+
children: /* @__PURE__ */ j(
|
|
225
|
+
q,
|
|
208
226
|
{
|
|
209
|
-
minHeight: `calc(${
|
|
227
|
+
minHeight: `calc(${ie}, 8px)`,
|
|
210
228
|
maxHeight: "300px",
|
|
211
|
-
minWidth:
|
|
229
|
+
minWidth: ne,
|
|
212
230
|
width: "auto",
|
|
213
231
|
hAlign: "start",
|
|
214
|
-
className:
|
|
232
|
+
className: H(K["suggestion-list"], "tcn-suggestion-list"),
|
|
215
233
|
children: [
|
|
216
234
|
/* @__PURE__ */ r(
|
|
217
235
|
"input",
|
|
218
236
|
{
|
|
219
237
|
ref: c,
|
|
220
|
-
value:
|
|
221
|
-
onKeyUp:
|
|
222
|
-
onKeyDown:
|
|
223
|
-
onChange:
|
|
224
|
-
className:
|
|
225
|
-
...
|
|
238
|
+
value: x,
|
|
239
|
+
onKeyUp: le,
|
|
240
|
+
onKeyDown: ce,
|
|
241
|
+
onChange: pe,
|
|
242
|
+
className: H(K.input, "tcn-suggestion-list-search-input"),
|
|
243
|
+
...Q
|
|
226
244
|
},
|
|
227
245
|
-1
|
|
228
246
|
),
|
|
229
|
-
/* @__PURE__ */
|
|
247
|
+
/* @__PURE__ */ j(q, { children: [
|
|
230
248
|
n.map((e, o) => /* @__PURE__ */ r(
|
|
231
|
-
|
|
249
|
+
xe,
|
|
232
250
|
{
|
|
233
251
|
option: e,
|
|
234
|
-
isSelected: o ===
|
|
235
|
-
isFocused: o ===
|
|
236
|
-
onClick:
|
|
252
|
+
isSelected: o === y && x !== "",
|
|
253
|
+
isFocused: o === d,
|
|
254
|
+
onClick: w
|
|
237
255
|
},
|
|
238
256
|
o
|
|
239
257
|
)),
|
|
240
|
-
|
|
258
|
+
te > n.length && /* @__PURE__ */ r(de, { children: /* @__PURE__ */ r(
|
|
259
|
+
ke,
|
|
260
|
+
{
|
|
261
|
+
marginBlock: "8px",
|
|
262
|
+
hierarchy: "tertiary",
|
|
263
|
+
onClick: fe,
|
|
264
|
+
children: "Show More"
|
|
265
|
+
},
|
|
266
|
+
"show-more"
|
|
267
|
+
) })
|
|
241
268
|
] }),
|
|
242
269
|
n.length === 0 && /* @__PURE__ */ r(
|
|
243
|
-
|
|
270
|
+
he,
|
|
244
271
|
{
|
|
245
272
|
padding: "8px",
|
|
246
|
-
className:
|
|
247
|
-
children: /* @__PURE__ */ r(
|
|
273
|
+
className: H(K["no-results"], "tcn-suggestion-list-no-results"),
|
|
274
|
+
children: /* @__PURE__ */ r(ge, { children: z })
|
|
248
275
|
}
|
|
249
276
|
),
|
|
250
|
-
/* @__PURE__ */ r(
|
|
277
|
+
/* @__PURE__ */ r(be, { onRedirect: ae }, n.length + 1)
|
|
251
278
|
]
|
|
252
279
|
}
|
|
253
280
|
)
|
|
@@ -255,6 +282,6 @@ function Xe({
|
|
|
255
282
|
);
|
|
256
283
|
}
|
|
257
284
|
export {
|
|
258
|
-
|
|
285
|
+
Ye as SuggestionList
|
|
259
286
|
};
|
|
260
287
|
//# sourceMappingURL=suggestion_list.js.map
|