@ryuzaki13/react-foundation-ui 1.0.3 → 1.0.5
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/advanced-search/index.js +90 -89
- package/dist/advanced-search/index.js.map +1 -1
- package/dist/chunks/Select-BJ5OqTe7.js +182 -0
- package/dist/chunks/Select-BJ5OqTe7.js.map +1 -0
- package/dist/chunks/{SerializableSelect-DkYeJtAO.js → SerializableSelect-CNe728Qa.js} +2 -2
- package/dist/chunks/{SerializableSelect-DkYeJtAO.js.map → SerializableSelect-CNe728Qa.js.map} +1 -1
- package/dist/chunks/{StateSelect-1jH3uLz9.js → StateSelect-ujAre258.js} +2 -2
- package/dist/chunks/{StateSelect-1jH3uLz9.js.map → StateSelect-ujAre258.js.map} +1 -1
- package/dist/chunks/multi-select-BYsbh2ca.js +126 -0
- package/dist/chunks/multi-select-BYsbh2ca.js.map +1 -0
- package/dist/chunks/{multi-select-BzYIviCU.js → odata-DSW7z3nh.js} +373 -569
- package/dist/chunks/odata-DSW7z3nh.js.map +1 -0
- package/dist/chunks/select-BkLc6dyx.js +81 -0
- package/dist/chunks/select-BkLc6dyx.js.map +1 -0
- package/dist/chunks/useODataSelectBase-BbeKdq6x.js +125 -0
- package/dist/chunks/useODataSelectBase-BbeKdq6x.js.map +1 -0
- package/dist/expandable-action-panel/stories/ExpandableActionPanel.stories.js +1 -1
- package/dist/multi-select/index.js +3 -3
- package/dist/preset-select/index.js +1 -1
- package/dist/preset-select/index.js.map +1 -1
- package/dist/select/Select.d.ts +10 -5
- package/dist/select/Select.d.ts.map +1 -1
- package/dist/select/index.d.ts +1 -0
- package/dist/select/index.d.ts.map +1 -1
- package/dist/select/index.js +4 -3
- package/dist/select/stories/Select.stories.d.ts +1 -1
- package/dist/select/stories/Select.stories.js +1 -1
- package/dist/select/stories/SerializableSelect.stories.js +1 -1
- package/dist/state-select/index.js +1 -1
- package/dist/state-select/stories/StateSelect.stories.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/tree-select/index.d.ts +2 -0
- package/dist/tree-select/index.d.ts.map +1 -1
- package/dist/tree-select/index.js +173 -4
- package/dist/tree-select/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/Select-CXeVjVKA.js +0 -182
- package/dist/chunks/Select-CXeVjVKA.js.map +0 -1
- package/dist/chunks/multi-select-BzYIviCU.js.map +0 -1
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { t as e } from "./ui.module-BisoTevy.js";
|
|
2
|
+
import { a as t, c as n, d as r, f as i, i as a, l as o, o as s, r as c, t as ee, u as te } from "./picker-Dg55Ss-B.js";
|
|
3
|
+
import { useRef as ne, useState as l } from "react";
|
|
4
|
+
import { cn as u } from "@ryuzaki13/react-foundation-lib/utils";
|
|
5
|
+
import { CheckIcon as re, XIcon as ie } from "lucide-react";
|
|
6
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
7
|
+
//#region src/select/lib/getOptionSearchText.ts
|
|
8
|
+
function m({ option: e, getOptionLabel: t, getOptionCode: n }) {
|
|
9
|
+
return [s(t(e)), s(n?.(e))].filter((e) => !!e).join(" ").toLowerCase();
|
|
10
|
+
}
|
|
11
|
+
function h(e, t, n) {
|
|
12
|
+
return e.find((e) => e.value === t) ?? n;
|
|
13
|
+
}
|
|
14
|
+
var g = {
|
|
15
|
+
inputWithOverlay: "aEEqH1",
|
|
16
|
+
valueOverlay: "_4HQKa7"
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/select/Select.tsx
|
|
20
|
+
function _(h) {
|
|
21
|
+
let { label: _, description: ae, disabled: v, placeholder: y, size: oe, options: b, value: x, onChange: S, getOptionKey: C, getOptionLabel: w, getOptionCode: T, getOptionDisabled: E, getOptionAriaLabel: se, getOptionClassName: ce, renderOption: D, renderValue: O, className: le, buttonClassName: ue, optionsClassName: de, optionsContentClassName: fe, searchable: k = !1, defaultFilter: pe = !0, query: me, defaultQuery: he, onQuery: ge, renderPopupHeader: A, emptyState: j, loadingState: M, errorState: N, placement: P = "bottom-start", clearable: F = !1 } = h, I = S, L = ne(null), [R, _e] = l(!1), z = k ? "search-single" : "display", B = x === void 0 ? void 0 : C(x), V = B === void 0 ? void 0 : b.find((e) => C(e) === B) ?? x, { query: H, setQuery: U } = c({
|
|
22
|
+
open: R,
|
|
23
|
+
query: me,
|
|
24
|
+
defaultQuery: he,
|
|
25
|
+
onQuery: ge,
|
|
26
|
+
triggerMode: z
|
|
27
|
+
}), W = t({
|
|
28
|
+
options: b,
|
|
29
|
+
query: H,
|
|
30
|
+
enabled: k && pe,
|
|
31
|
+
getSearchText: (e) => m({
|
|
32
|
+
option: e,
|
|
33
|
+
getOptionLabel: w,
|
|
34
|
+
getOptionCode: T
|
|
35
|
+
})
|
|
36
|
+
}), { activeIndex: ve, context: ye, floatingStyles: be, getFloatingProps: xe, setReference: Se, setFloating: Ce, setOptionRef: we, close: G, openList: Te, toggleOpen: Ee, selectOption: De, selectActiveOption: Oe, handleReferenceKeyDown: ke, handleFloatingKeyDown: Ae, getOptionId: je, getActiveOptionId: K } = a({
|
|
37
|
+
options: W,
|
|
38
|
+
selectedIndex: B === void 0 ? -1 : W.findIndex((e) => C(e) === B),
|
|
39
|
+
open: R,
|
|
40
|
+
onOpenChange: _e,
|
|
41
|
+
getOptionDisabled: E,
|
|
42
|
+
onSelect: I,
|
|
43
|
+
disabled: v,
|
|
44
|
+
placement: P,
|
|
45
|
+
triggerMode: z
|
|
46
|
+
}), q = W.length > 0, J = V === void 0 ? void 0 : w(V), Y = V === void 0 ? void 0 : O ? O(V) : J, Me = s(J), Ne = V === void 0 ? void 0 : s(T?.(V)), X = s(Y) ?? Me ?? Ne ?? (B === void 0 ? "" : String(B)), Z = k && (R || H.length > 0), Pe = Z ? H : V === void 0 ? "" : X, Q = V !== void 0 && Y !== void 0 && s(Y) === void 0 && !Z, $ = ee({
|
|
47
|
+
mode: z,
|
|
48
|
+
open: R,
|
|
49
|
+
currentQuery: H,
|
|
50
|
+
hasDisplayValue: V !== void 0,
|
|
51
|
+
inputRef: L,
|
|
52
|
+
setQuery: U,
|
|
53
|
+
openList: Te,
|
|
54
|
+
close: G,
|
|
55
|
+
toggleOpen: Ee
|
|
56
|
+
}), Fe = (e) => {
|
|
57
|
+
L.current = e;
|
|
58
|
+
}, Ie = () => {
|
|
59
|
+
F && I(void 0), U(""), G();
|
|
60
|
+
};
|
|
61
|
+
return /* @__PURE__ */ f(i, {
|
|
62
|
+
label: _,
|
|
63
|
+
description: ae,
|
|
64
|
+
disabled: v,
|
|
65
|
+
placeholder: y,
|
|
66
|
+
size: oe,
|
|
67
|
+
className: le,
|
|
68
|
+
children: ({ controlId: t, labelId: i, describedBy: a }) => {
|
|
69
|
+
let s = `${t}-listbox`;
|
|
70
|
+
return /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f(n, {
|
|
71
|
+
ref: Fe,
|
|
72
|
+
rootRef: Se,
|
|
73
|
+
id: t,
|
|
74
|
+
type: "text",
|
|
75
|
+
disabled: v,
|
|
76
|
+
readOnly: !k,
|
|
77
|
+
autoComplete: "off",
|
|
78
|
+
role: "combobox",
|
|
79
|
+
value: Pe,
|
|
80
|
+
placeholder: V === void 0 || Z ? y : void 0,
|
|
81
|
+
"aria-labelledby": i,
|
|
82
|
+
"aria-describedby": a,
|
|
83
|
+
"aria-haspopup": "listbox",
|
|
84
|
+
"aria-expanded": R,
|
|
85
|
+
"aria-controls": R ? s : void 0,
|
|
86
|
+
"aria-autocomplete": k ? "list" : "none",
|
|
87
|
+
"aria-activedescendant": R ? K(s) : void 0,
|
|
88
|
+
inputClassName: u(Q && g.inputWithOverlay, ue, "textOverflow"),
|
|
89
|
+
overlay: Q ? /* @__PURE__ */ f("div", {
|
|
90
|
+
className: g.valueOverlay,
|
|
91
|
+
children: Y
|
|
92
|
+
}) : void 0,
|
|
93
|
+
endAdornment: /* @__PURE__ */ f(o, {
|
|
94
|
+
open: R,
|
|
95
|
+
disabled: v,
|
|
96
|
+
onToggleMouseDown: $.handleToggleMouseDown,
|
|
97
|
+
onToggleClick: $.handleToggleClick,
|
|
98
|
+
children: F && V !== void 0 && !v ? /* @__PURE__ */ f("button", {
|
|
99
|
+
type: "button",
|
|
100
|
+
className: e.uiClearButton,
|
|
101
|
+
"data-ui": "select-clear-button",
|
|
102
|
+
"data-action": "clear-select",
|
|
103
|
+
onMouseDown: (e) => {
|
|
104
|
+
e.preventDefault(), e.stopPropagation();
|
|
105
|
+
},
|
|
106
|
+
onClick: (e) => {
|
|
107
|
+
e.preventDefault(), e.stopPropagation(), Ie();
|
|
108
|
+
},
|
|
109
|
+
"aria-label": "Очистить выбор",
|
|
110
|
+
children: /* @__PURE__ */ f(ie, {})
|
|
111
|
+
}) : null
|
|
112
|
+
}),
|
|
113
|
+
onChange: (e) => {
|
|
114
|
+
k && $.handleTriggerInputChange(e.target.value);
|
|
115
|
+
},
|
|
116
|
+
onClick: $.handleTriggerClick,
|
|
117
|
+
onFocus: (e) => {
|
|
118
|
+
$.handleTriggerFocus(e.currentTarget);
|
|
119
|
+
},
|
|
120
|
+
onKeyDown: (e) => {
|
|
121
|
+
ke(e), !e.defaultPrevented && $.handleTriggerKeyDown({
|
|
122
|
+
event: e,
|
|
123
|
+
onActivateWhenOpen: Oe,
|
|
124
|
+
enableSpaceActivation: !k
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}), /* @__PURE__ */ f(r, {
|
|
128
|
+
open: R,
|
|
129
|
+
context: ye,
|
|
130
|
+
floatingStyles: be,
|
|
131
|
+
listId: s,
|
|
132
|
+
labelId: i,
|
|
133
|
+
descriptionId: a,
|
|
134
|
+
activeOptionId: q ? K(s) : void 0,
|
|
135
|
+
setFloating: Ce,
|
|
136
|
+
getFloatingProps: xe,
|
|
137
|
+
onKeyDown: Ae,
|
|
138
|
+
className: u(e.uiPopupOptions, de),
|
|
139
|
+
header: A,
|
|
140
|
+
children: /* @__PURE__ */ f("div", {
|
|
141
|
+
className: u(fe, "h100 scrollable"),
|
|
142
|
+
children: q ? W.map((t, n) => {
|
|
143
|
+
let r = C(t), i = B !== void 0 && r === B, a = n === ve, o = E?.(t) ?? !1, c = {
|
|
144
|
+
active: a,
|
|
145
|
+
selected: i,
|
|
146
|
+
disabled: o
|
|
147
|
+
};
|
|
148
|
+
return /* @__PURE__ */ f("div", {
|
|
149
|
+
id: je(s, n),
|
|
150
|
+
ref: (e) => we(n, e),
|
|
151
|
+
role: "option",
|
|
152
|
+
"aria-selected": i,
|
|
153
|
+
"aria-disabled": o || void 0,
|
|
154
|
+
"aria-label": se?.(t),
|
|
155
|
+
className: u(e.uiPopupOption, o && e.disabled, a && e.uiPopupOptionActive, i && e.selected, ce?.(t, c)),
|
|
156
|
+
onClick: () => De(t),
|
|
157
|
+
children: D ? D(t, c) : /* @__PURE__ */ p(d, { children: [
|
|
158
|
+
f(i ? re : "span", { className: e.uiPopupOptionIcon }),
|
|
159
|
+
/* @__PURE__ */ f("div", {
|
|
160
|
+
className: e.uiOptionText,
|
|
161
|
+
children: w(t)
|
|
162
|
+
}),
|
|
163
|
+
T && /* @__PURE__ */ f("div", {
|
|
164
|
+
className: e.uiOptionCode,
|
|
165
|
+
children: T(t)
|
|
166
|
+
})
|
|
167
|
+
] })
|
|
168
|
+
}, r);
|
|
169
|
+
}) : /* @__PURE__ */ f(te, {
|
|
170
|
+
emptyState: j,
|
|
171
|
+
loadingState: M,
|
|
172
|
+
errorState: N
|
|
173
|
+
})
|
|
174
|
+
})
|
|
175
|
+
})] });
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
export { h as n, _ as t };
|
|
181
|
+
|
|
182
|
+
//# sourceMappingURL=Select-BJ5OqTe7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select-BJ5OqTe7.js","names":[],"sources":["../../src/select/lib/getOptionSearchText.ts","../../src/select/Select.module.scss","../../src/select/Select.tsx"],"sourcesContent":["import { ReactNode } from \"react\";\n\nimport { InputType } from \"@ryuzaki13/react-foundation-lib/types\";\n\nimport { extractPickerTextContent } from \"../../picker\";\n\nexport function getOptionSearchText<T extends InputType>({\n\toption,\n\tgetOptionLabel,\n\tgetOptionCode\n}: {\n\toption: T;\n\tgetOptionLabel: (option: T) => ReactNode;\n\tgetOptionCode?: (option: T) => ReactNode;\n}) {\n\treturn [extractPickerTextContent(getOptionLabel(option)), extractPickerTextContent(getOptionCode?.(option))]\n\t\t.filter((part): part is string => Boolean(part))\n\t\t.join(\" \")\n\t\t.toLowerCase();\n}\n\n/** Находит selected option по value и возвращает fallback, если значение еще не нормализовано. */\nexport function resolveSelectedOption<TOption extends { value: string }>(\n\toptions: readonly TOption[],\n\tvalue: string,\n\tfallback: TOption\n): TOption {\n\treturn options.find((option) => option.value === value) ?? fallback;\n}\n",".inputWithOverlay {\n\tcolor: transparent;\n\tcaret-color: transparent;\n}\n\n.valueOverlay {\n\tposition: absolute;\n\tinset: 0 calc(var(--control-height) + var(--space-xs)) 0 var(--space-md);\n\tdisplay: flex;\n\talign-items: center;\n\tpointer-events: none;\n\toverflow: hidden;\n}\n","import { ReactNode, useRef, useState } from \"react\";\n\nimport { Placement } from \"@floating-ui/react\";\nimport { InputType } from \"@ryuzaki13/react-foundation-lib/types\";\nimport { cn } from \"@ryuzaki13/react-foundation-lib/utils\";\nimport { CheckIcon, XIcon } from \"lucide-react\";\n\nimport {\n\textractPickerTextContent,\n\tPickerField,\n\tPickerPopup,\n\tPickerStatus,\n\tPickerTriggerActions,\n\tPickerTriggerInput,\n\tusePickerDefaultFilter,\n\tusePickerFloatingListbox,\n\tusePickerQuery,\n\tusePickerTriggerController\n} from \"../picker\";\nimport { ChangeHandler, UiBaseProps } from \"../types\";\nimport uiStyles from \"../ui.module.scss\";\n\nimport { getOptionSearchText } from \"./lib\";\nimport styles from \"./Select.module.scss\";\n\nexport type SelectOptionKey = string | number;\n\nexport type SelectOptionState = {\n\tactive: boolean;\n\tselected: boolean;\n\tdisabled: boolean;\n};\n\ntype SelectSharedProps<TOption extends InputType> = Omit<UiBaseProps<TOption, TOption | undefined>, \"onChange\"> & {\n\toptions: readonly TOption[];\n\tgetOptionKey: (option: TOption) => SelectOptionKey;\n\tgetOptionLabel: (option: TOption) => ReactNode;\n\tgetOptionCode?: (option: TOption) => ReactNode;\n\tgetOptionDisabled?: (option: TOption) => boolean;\n\tgetOptionAriaLabel?: (option: TOption) => string;\n\tgetOptionClassName?: (option: TOption, state: SelectOptionState) => string | undefined;\n\trenderOption?: (option: TOption, state: SelectOptionState) => ReactNode;\n\trenderValue?: (option: TOption) => ReactNode;\n\tclassName?: string;\n\tbuttonClassName?: string;\n\toptionsClassName?: string;\n\toptionsContentClassName?: string;\n\tsearchable?: boolean;\n\tquery?: string;\n\tdefaultQuery?: string;\n\tonQuery?: (value: string) => void;\n\tdefaultFilter?: boolean;\n\trenderPopupHeader?: ReactNode;\n\temptyState?: ReactNode;\n\tloadingState?: ReactNode;\n\terrorState?: ReactNode;\n\tplacement?: Placement;\n};\n\ntype SelectChangeValue<TOption extends InputType, TClearable extends boolean | undefined> = true extends TClearable\n\t? TOption | undefined\n\t: TOption;\n\nexport type SelectProps<TOption extends InputType, TClearable extends boolean | undefined = false> = SelectSharedProps<TOption> & {\n\tclearable?: TClearable;\n\tonChange: ChangeHandler<SelectChangeValue<TOption, TClearable>>;\n};\n\n/**\n * Выпадающий список выбора значения из набора опций. Подходит для форм, фильтров и простых справочников.\n */\nexport function Select<TOption extends InputType, TClearable extends boolean | undefined = false>(props: SelectProps<TOption, TClearable>) {\n\tconst {\n\t\tlabel,\n\t\tdescription,\n\t\tdisabled,\n\t\tplaceholder,\n\t\tsize,\n\t\toptions,\n\t\tvalue,\n\t\tonChange,\n\t\tgetOptionKey,\n\t\tgetOptionLabel,\n\t\tgetOptionCode,\n\t\tgetOptionDisabled,\n\t\tgetOptionAriaLabel,\n\t\tgetOptionClassName,\n\t\trenderOption,\n\t\trenderValue,\n\t\tclassName,\n\t\tbuttonClassName,\n\t\toptionsClassName,\n\t\toptionsContentClassName,\n\t\tsearchable = false,\n\t\tdefaultFilter = true,\n\t\tquery,\n\t\tdefaultQuery,\n\t\tonQuery,\n\t\trenderPopupHeader,\n\t\temptyState,\n\t\tloadingState,\n\t\terrorState,\n\t\tplacement = \"bottom-start\",\n\t\tclearable = false\n\t} = props;\n\tconst emitChange = onChange as ChangeHandler<TOption | undefined>;\n\n\tconst inputRef = useRef<HTMLInputElement | null>(null);\n\tconst [open, setOpen] = useState(false);\n\tconst triggerMode = searchable ? \"search-single\" : \"display\";\n\tconst selectedKey = value === undefined ? undefined : getOptionKey(value);\n\tconst selectedOption =\n\t\tselectedKey === undefined ? undefined : (options.find((option) => getOptionKey(option) === selectedKey) ?? value);\n\tconst { query: currentQuery, setQuery } = usePickerQuery({\n\t\topen,\n\t\tquery,\n\t\tdefaultQuery,\n\t\tonQuery,\n\t\ttriggerMode\n\t});\n\tconst visibleOptions = usePickerDefaultFilter({\n\t\toptions,\n\t\tquery: currentQuery,\n\t\tenabled: searchable && defaultFilter,\n\t\tgetSearchText: (option) =>\n\t\t\tgetOptionSearchText({\n\t\t\t\toption,\n\t\t\t\tgetOptionLabel,\n\t\t\t\tgetOptionCode\n\t\t\t})\n\t});\n\tconst selectedIndex = selectedKey === undefined ? -1 : visibleOptions.findIndex((option) => getOptionKey(option) === selectedKey);\n\tconst {\n\t\tactiveIndex,\n\t\tcontext,\n\t\tfloatingStyles,\n\t\tgetFloatingProps,\n\t\tsetReference,\n\t\tsetFloating,\n\t\tsetOptionRef,\n\t\tclose,\n\t\topenList,\n\t\ttoggleOpen,\n\t\tselectOption,\n\t\tselectActiveOption,\n\t\thandleReferenceKeyDown,\n\t\thandleFloatingKeyDown,\n\t\tgetOptionId,\n\t\tgetActiveOptionId\n\t} = usePickerFloatingListbox({\n\t\toptions: visibleOptions,\n\t\tselectedIndex,\n\t\topen,\n\t\tonOpenChange: setOpen,\n\t\tgetOptionDisabled,\n\t\tonSelect: emitChange,\n\t\tdisabled,\n\t\tplacement,\n\t\ttriggerMode\n\t});\n\n\tconst hasOptions = visibleOptions.length > 0;\n\tconst labelContent = selectedOption !== undefined ? getOptionLabel(selectedOption) : undefined;\n\tconst displayContent = selectedOption !== undefined ? (renderValue ? renderValue(selectedOption) : labelContent) : undefined;\n\tconst labelText = extractPickerTextContent(labelContent);\n\tconst codeText = selectedOption !== undefined ? extractPickerTextContent(getOptionCode?.(selectedOption)) : undefined;\n\tconst displayText =\n\t\textractPickerTextContent(displayContent) ?? labelText ?? codeText ?? (selectedKey !== undefined ? String(selectedKey) : \"\");\n\tconst showSearchValue = searchable && (open || currentQuery.length > 0);\n\tconst inputValue = showSearchValue ? currentQuery : selectedOption !== undefined ? displayText : \"\";\n\tconst showDisplayOverlay =\n\t\tselectedOption !== undefined &&\n\t\tdisplayContent !== undefined &&\n\t\textractPickerTextContent(displayContent) === undefined &&\n\t\t!showSearchValue;\n\tconst triggerController = usePickerTriggerController({\n\t\tmode: triggerMode,\n\t\topen,\n\t\tcurrentQuery,\n\t\thasDisplayValue: selectedOption !== undefined,\n\t\tinputRef,\n\t\tsetQuery,\n\t\topenList,\n\t\tclose,\n\t\ttoggleOpen\n\t});\n\tconst setInputNode = (node: HTMLInputElement | null) => {\n\t\tinputRef.current = node;\n\t};\n\tconst handleClear = () => {\n\t\tif (clearable) {\n\t\t\temitChange(undefined);\n\t\t}\n\n\t\tsetQuery(\"\");\n\t\tclose();\n\t};\n\n\treturn (\n\t\t<PickerField\n\t\t\tlabel={label}\n\t\t\tdescription={description}\n\t\t\tdisabled={disabled}\n\t\t\tplaceholder={placeholder}\n\t\t\tsize={size}\n\t\t\tclassName={className}>\n\t\t\t{({ controlId, labelId, describedBy }) => {\n\t\t\t\tconst listId = `${controlId}-listbox`;\n\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<PickerTriggerInput\n\t\t\t\t\t\t\tref={setInputNode}\n\t\t\t\t\t\t\trootRef={setReference}\n\t\t\t\t\t\t\tid={controlId}\n\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\treadOnly={!searchable}\n\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\trole=\"combobox\"\n\t\t\t\t\t\t\tvalue={inputValue}\n\t\t\t\t\t\t\tplaceholder={selectedOption === undefined || showSearchValue ? placeholder : undefined}\n\t\t\t\t\t\t\taria-labelledby={labelId}\n\t\t\t\t\t\t\taria-describedby={describedBy}\n\t\t\t\t\t\t\taria-haspopup=\"listbox\"\n\t\t\t\t\t\t\taria-expanded={open}\n\t\t\t\t\t\t\taria-controls={open ? listId : undefined}\n\t\t\t\t\t\t\taria-autocomplete={searchable ? \"list\" : \"none\"}\n\t\t\t\t\t\t\taria-activedescendant={open ? getActiveOptionId(listId) : undefined}\n\t\t\t\t\t\t\tinputClassName={cn(showDisplayOverlay && styles.inputWithOverlay, buttonClassName, \"textOverflow\")}\n\t\t\t\t\t\t\toverlay={showDisplayOverlay ? <div className={styles.valueOverlay}>{displayContent}</div> : undefined}\n\t\t\t\t\t\t\tendAdornment={\n\t\t\t\t\t\t\t\t<PickerTriggerActions\n\t\t\t\t\t\t\t\t\topen={open}\n\t\t\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\t\t\tonToggleMouseDown={triggerController.handleToggleMouseDown}\n\t\t\t\t\t\t\t\t\tonToggleClick={triggerController.handleToggleClick}>\n\t\t\t\t\t\t\t\t\t{clearable && selectedOption !== undefined && !disabled ? (\n\t\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\t\tclassName={uiStyles.uiClearButton}\n\t\t\t\t\t\t\t\t\t\t\tdata-ui=\"select-clear-button\"\n\t\t\t\t\t\t\t\t\t\t\tdata-action=\"clear-select\"\n\t\t\t\t\t\t\t\t\t\t\tonMouseDown={(event) => {\n\t\t\t\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\tonClick={(event) => {\n\t\t\t\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\t\thandleClear();\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\taria-label=\"Очистить выбор\">\n\t\t\t\t\t\t\t\t\t\t\t<XIcon />\n\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t</PickerTriggerActions>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonChange={(event) => {\n\t\t\t\t\t\t\t\tif (!searchable) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\ttriggerController.handleTriggerInputChange(event.target.value);\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tonClick={triggerController.handleTriggerClick}\n\t\t\t\t\t\t\tonFocus={(event) => {\n\t\t\t\t\t\t\t\ttriggerController.handleTriggerFocus(event.currentTarget);\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tonKeyDown={(event) => {\n\t\t\t\t\t\t\t\thandleReferenceKeyDown(event);\n\n\t\t\t\t\t\t\t\tif (event.defaultPrevented) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\ttriggerController.handleTriggerKeyDown({\n\t\t\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\t\t\tonActivateWhenOpen: selectActiveOption,\n\t\t\t\t\t\t\t\t\tenableSpaceActivation: !searchable\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t<PickerPopup\n\t\t\t\t\t\t\topen={open}\n\t\t\t\t\t\t\tcontext={context}\n\t\t\t\t\t\t\tfloatingStyles={floatingStyles}\n\t\t\t\t\t\t\tlistId={listId}\n\t\t\t\t\t\t\tlabelId={labelId}\n\t\t\t\t\t\t\tdescriptionId={describedBy}\n\t\t\t\t\t\t\tactiveOptionId={hasOptions ? getActiveOptionId(listId) : undefined}\n\t\t\t\t\t\t\tsetFloating={setFloating}\n\t\t\t\t\t\t\tgetFloatingProps={getFloatingProps}\n\t\t\t\t\t\t\tonKeyDown={handleFloatingKeyDown}\n\t\t\t\t\t\t\tclassName={cn(uiStyles.uiPopupOptions, optionsClassName)}\n\t\t\t\t\t\t\theader={renderPopupHeader}>\n\t\t\t\t\t\t\t<div className={cn(optionsContentClassName, \"h100 scrollable\")}>\n\t\t\t\t\t\t\t\t{hasOptions ? (\n\t\t\t\t\t\t\t\t\tvisibleOptions.map((option, index) => {\n\t\t\t\t\t\t\t\t\t\tconst optionKey = getOptionKey(option);\n\t\t\t\t\t\t\t\t\t\tconst selected = selectedKey !== undefined && optionKey === selectedKey;\n\t\t\t\t\t\t\t\t\t\tconst active = index === activeIndex;\n\t\t\t\t\t\t\t\t\t\tconst optionDisabled = getOptionDisabled?.(option) ?? false;\n\t\t\t\t\t\t\t\t\t\tconst optionState = { active, selected, disabled: optionDisabled };\n\n\t\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\tkey={optionKey}\n\t\t\t\t\t\t\t\t\t\t\t\tid={getOptionId(listId, index)}\n\t\t\t\t\t\t\t\t\t\t\t\tref={(node) => setOptionRef(index, node)}\n\t\t\t\t\t\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\t\t\t\t\t\taria-selected={selected}\n\t\t\t\t\t\t\t\t\t\t\t\taria-disabled={optionDisabled || undefined}\n\t\t\t\t\t\t\t\t\t\t\t\taria-label={getOptionAriaLabel?.(option)}\n\t\t\t\t\t\t\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\t\t\t\t\t\tuiStyles.uiPopupOption,\n\t\t\t\t\t\t\t\t\t\t\t\t\toptionDisabled && uiStyles.disabled,\n\t\t\t\t\t\t\t\t\t\t\t\t\tactive && uiStyles.uiPopupOptionActive,\n\t\t\t\t\t\t\t\t\t\t\t\t\tselected && uiStyles.selected,\n\t\t\t\t\t\t\t\t\t\t\t\t\tgetOptionClassName?.(option, optionState)\n\t\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t\t\tonClick={() => selectOption(option)}>\n\t\t\t\t\t\t\t\t\t\t\t\t{renderOption ? (\n\t\t\t\t\t\t\t\t\t\t\t\t\trenderOption(option, optionState)\n\t\t\t\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{selected ? (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<CheckIcon className={uiStyles.uiPopupOptionIcon} />\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span className={uiStyles.uiPopupOptionIcon} />\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div className={uiStyles.uiOptionText}>{getOptionLabel(option)}</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{getOptionCode && (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div className={uiStyles.uiOptionCode}>{getOptionCode(option)}</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<PickerStatus emptyState={emptyState} loadingState={loadingState} errorState={errorState} />\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</PickerPopup>\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t}}\n\t\t</PickerField>\n\t);\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,EAAyC,EACxD,WACA,mBACA,oBAKE;CACF,OAAO,CAAC,EAAyB,EAAe,CAAM,CAAC,GAAG,EAAyB,IAAgB,CAAM,CAAC,CAAC,CAAC,CAC1G,QAAQ,MAAyB,EAAQ,CAAK,CAAC,CAC/C,KAAK,GAAG,CAAC,CACT,YAAY;AACf;AAGA,SAAgB,EACf,GACA,GACA,GACU;CACV,OAAO,EAAQ,MAAM,MAAW,EAAO,UAAU,CAAK,KAAK;AAC5D;;;;;;;AE2CA,SAAgB,EAAkF,GAAyC;CAC1I,IAAM,EACL,UACA,iBACA,aACA,gBACA,UACA,YACA,UACA,aACA,iBACA,mBACA,kBACA,sBACA,wBACA,wBACA,iBACA,gBACA,eACA,qBACA,sBACA,6BACA,gBAAa,IACb,oBAAgB,IAChB,WACA,kBACA,aACA,sBACA,eACA,iBACA,eACA,eAAY,gBACZ,eAAY,OACT,GACE,IAAa,GAEb,IAAW,GAAgC,IAAI,GAC/C,CAAC,GAAM,MAAW,EAAS,EAAK,GAChC,IAAc,IAAa,kBAAkB,WAC7C,IAAc,MAAU,KAAA,IAAY,KAAA,IAAY,EAAa,CAAK,GAClE,IACL,MAAgB,KAAA,IAAY,KAAA,IAAa,EAAQ,MAAM,MAAW,EAAa,CAAM,MAAM,CAAW,KAAK,GACtG,EAAE,OAAO,GAAc,gBAAa,EAAe;EACxD;EACA;EACA;EACA;EACA;CACD,CAAC,GACK,IAAiB,EAAuB;EAC7C;EACA,OAAO;EACP,SAAS,KAAc;EACvB,gBAAgB,MACf,EAAoB;GACnB;GACA;GACA;EACD,CAAC;CACH,CAAC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gB,EAAgB;IACvD,QAAQ;cACR,kBAAC,OAAD;KAAK,WAAW,EAAG,IAAyB,iBAAiB;eAC3D,IACA,EAAe,KAAK,GAAQ,MAAU;MACrC,IAAM,IAAY,EAAa,CAAM,GAC/B,IAAW,MAAgB,KAAA,KAAa,MAAc,GACtD,IAAS,MAAU,IACnB,IAAiB,IAAoB,CAAM,KAAK,IAChD,IAAc;OAAE;OAAQ;OAAU,UAAU;MAAe;MAEjE,OACC,kBAAC,OAAD;OAEC,IAAI,GAAY,GAAQ,CAAK;OAC7B,MAAM,MAAS,GAAa,GAAO,CAAI;OACvC,MAAK;OACL,iBAAe;OACf,iBAAe,KAAkB,KAAA;OACjC,cAAY,KAAqB,CAAM;OACvC,WAAW,EACV,EAAS,eACT,KAAkB,EAAS,UAC3B,KAAU,EAAS,qBACnB,KAAY,EAAS,UACrB,KAAqB,GAAQ,CAAW,CACzC;OACA,eAAe,GAAa,CAAM;iBACjC,IACA,EAAa,GAAQ,CAAW,IAEhC,kBAAA,GAAA,EAAA,UAAA;QAEE,EADA,IACC,KAEA,QAFD,EAAW,WAAW,EAAS,kBAAoB,CAEL;QAE/C,kBAAC,OAAD;SAAK,WAAW,EAAS;mBAAe,EAAe,CAAM;QAAO,CAAA;QACnE,KACA,kBAAC,OAAD;SAAK,WAAW,EAAS;mBAAe,EAAc,CAAM;QAAO,CAAA;OAEnE,EAAA,CAAA;MAEC,GA9BC,CA8BD;KAEP,CAAC,IAED,kBAAC,IAAD;MAA0B;MAA0B;MAA0B;KAAa,CAAA;IAExF,CAAA;GACO,CAAA,CACZ,EAAA,CAAA;EAEJ;CACY,CAAA;AAEf"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./Select-
|
|
1
|
+
import { t as e } from "./Select-BJ5OqTe7.js";
|
|
2
2
|
import { jsx as t } from "react/jsx-runtime";
|
|
3
3
|
//#region src/select/SerializableSelect.tsx
|
|
4
4
|
function n(e, t) {
|
|
@@ -30,4 +30,4 @@ function i({ label: i, description: a, disabled: o, placeholder: s, size: c, opt
|
|
|
30
30
|
//#endregion
|
|
31
31
|
export { i as t };
|
|
32
32
|
|
|
33
|
-
//# sourceMappingURL=SerializableSelect-
|
|
33
|
+
//# sourceMappingURL=SerializableSelect-CNe728Qa.js.map
|
package/dist/chunks/{SerializableSelect-DkYeJtAO.js.map → SerializableSelect-CNe728Qa.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SerializableSelect-
|
|
1
|
+
{"version":3,"file":"SerializableSelect-CNe728Qa.js","names":[],"sources":["../../src/select/SerializableSelect.tsx"],"sourcesContent":["import { Select } from \"./Select\";\n\nimport type { UiBaseProps } from \"../types\";\nimport type { SelectOptionKey } from \"./Select\";\n\ntype SerializableOptionRecord = Record<string, unknown>;\n\ntype SerializableOptionKeyField<TOption extends SerializableOptionRecord> = {\n\t[K in keyof TOption]: Extract<TOption[K], SelectOptionKey> extends never ? never : K;\n}[keyof TOption];\n\ntype SerializableOptionValue<TOption extends SerializableOptionRecord, TOptionKey extends SerializableOptionKeyField<TOption>> = Extract<\n\tTOption[TOptionKey],\n\tSelectOptionKey\n>;\n\nexport interface SerializableSelectProps<\n\tTOption extends SerializableOptionRecord,\n\tTOptionKey extends SerializableOptionKeyField<TOption>,\n\tTOptionLabel extends keyof TOption\n> extends Omit<UiBaseProps<SerializableOptionValue<TOption, TOptionKey> | undefined>, \"onChange\"> {\n\toptions: readonly TOption[];\n\tonChange: (value: SerializableOptionValue<TOption, TOptionKey> | undefined) => void;\n\toptionKey: TOptionKey;\n\toptionLabel: TOptionLabel;\n\trenderCode?: true;\n\tclassName?: string;\n\tclearable?: boolean;\n}\n\nfunction getSerializableOptionKey<TOption extends SerializableOptionRecord, TOptionKey extends SerializableOptionKeyField<TOption>>(\n\toption: TOption,\n\toptionKey: TOptionKey\n): Extract<TOption[TOptionKey], SelectOptionKey> {\n\treturn option[optionKey] as Extract<TOption[TOptionKey], SelectOptionKey>;\n}\n\nfunction getSerializableOptionLabel<\n\tTOption extends SerializableOptionRecord,\n\tTOptionKey extends SerializableOptionKeyField<TOption>,\n\tTOptionLabel extends keyof TOption\n>(option: TOption, optionLabel: TOptionLabel, optionKey: TOptionKey): string | number {\n\tconst label = option[optionLabel];\n\n\tif (typeof label === \"string\" || typeof label === \"number\") {\n\t\treturn label;\n\t}\n\n\tconst key = getSerializableOptionKey(option, optionKey);\n\treturn typeof key === \"string\" || typeof key === \"number\" ? key : String(key);\n}\n\nexport function SerializableSelect<\n\tTOption extends SerializableOptionRecord,\n\tTOptionKey extends SerializableOptionKeyField<TOption>,\n\tTOptionLabel extends keyof TOption\n>({\n\tlabel,\n\tdescription,\n\tdisabled,\n\tplaceholder,\n\tsize,\n\toptions,\n\tvalue,\n\tonChange,\n\toptionKey,\n\toptionLabel,\n\trenderCode,\n\tclassName,\n\tclearable\n}: SerializableSelectProps<TOption, TOptionKey, TOptionLabel>) {\n\tconst selectedOption =\n\t\tvalue === undefined ? undefined : options.find((option) => getSerializableOptionKey(option, optionKey) === value);\n\n\treturn (\n\t\t<Select\n\t\t\tlabel={label}\n\t\t\tdescription={description}\n\t\t\tdisabled={disabled}\n\t\t\tplaceholder={placeholder}\n\t\t\tsize={size}\n\t\t\toptions={options}\n\t\t\tvalue={selectedOption}\n\t\t\tonChange={(option: TOption | undefined) => onChange(option ? getSerializableOptionKey(option, optionKey) : undefined)}\n\t\t\tgetOptionKey={(option: TOption) => getSerializableOptionKey(option, optionKey)}\n\t\t\tgetOptionLabel={(option: TOption) => getSerializableOptionLabel(option, optionLabel, optionKey)}\n\t\t\tgetOptionCode={renderCode ? (option: TOption) => getSerializableOptionKey(option, optionKey) : undefined}\n\t\t\tclassName={className}\n\t\t\tclearable={clearable}\n\t\t/>\n\t);\n}\n"],"mappings":";;;AA8BA,SAAS,EACR,GACA,GACgD;CAChD,OAAO,EAAO;AACf;AAEA,SAAS,EAIP,GAAiB,GAA2B,GAAwC;CACrF,IAAM,IAAQ,EAAO;CAErB,IAAI,OAAO,KAAU,YAAY,OAAO,KAAU,UACjD,OAAO;CAGR,IAAM,IAAM,EAAyB,GAAQ,CAAS;CACtD,OAAO,OAAO,KAAQ,YAAY,OAAO,KAAQ,WAAW,IAAM,OAAO,CAAG;AAC7E;AAEA,SAAgB,EAId,EACD,UACA,gBACA,aACA,gBACA,SACA,YACA,UACA,aACA,cACA,gBACA,eACA,cACA,gBAC8D;CAI9D,OACC,kBAAC,GAAD;EACQ;EACM;EACH;EACG;EACP;EACG;EACT,OAVD,MAAU,KAAA,IAAY,KAAA,IAAY,EAAQ,MAAM,MAAW,EAAyB,GAAQ,CAAS,MAAM,CAAK;EAW/G,WAAW,MAAgC,EAAS,IAAS,EAAyB,GAAQ,CAAS,IAAI,KAAA,CAAS;EACpH,eAAe,MAAoB,EAAyB,GAAQ,CAAS;EAC7E,iBAAiB,MAAoB,EAA2B,GAAQ,GAAa,CAAS;EAC9F,eAAe,KAAc,MAAoB,EAAyB,GAAQ,CAAS,IAAI,KAAA;EACpF;EACA;CACX,CAAA;AAEH"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./Select-
|
|
1
|
+
import { t as e } from "./Select-BJ5OqTe7.js";
|
|
2
2
|
import { useMemo as t } from "react";
|
|
3
3
|
import { cn as n } from "@ryuzaki13/react-foundation-lib/utils";
|
|
4
4
|
import { DEFAULT_VALUE_STATES as r, VALUE_STATE_COLOR_TOKENS as i } from "@ryuzaki13/react-foundation-lib/formatters";
|
|
@@ -75,4 +75,4 @@ function m({ label: i, description: m, disabled: h, placeholder: g, size: _, val
|
|
|
75
75
|
//#endregion
|
|
76
76
|
export { m as t };
|
|
77
77
|
|
|
78
|
-
//# sourceMappingURL=StateSelect-
|
|
78
|
+
//# sourceMappingURL=StateSelect-ujAre258.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateSelect-
|
|
1
|
+
{"version":3,"file":"StateSelect-ujAre258.js","names":[],"sources":["../../src/state-select/StateSelect.module.scss","../../src/state-select/StateSelect.tsx"],"sourcesContent":[".button {\n\tpadding-left: var(--space-sm);\n}\n\n.valueContainer {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: var(--space-sm);\n\twidth: 100%;\n\tmin-height: 1.5em;\n\tmin-width: 0;\n}\n\n.swatch {\n\t--state-color: transparent;\n\n\twidth: 1.25em;\n\theight: 1.25em;\n\tflex-shrink: 0;\n\tdisplay: inline-block;\n\tborder-radius: var(--radius-xs);\n\tborder: var(--border-width) solid var(--border-0);\n\tbackground-color: var(--state-color);\n\n\t&[data-empty] {\n\t\tbackground-color: var(--surface-0);\n\t\tbackground-image: repeating-linear-gradient(135deg, var(--border-0), var(--border-0) 0.25em, transparent 0.25em, transparent 0.5em);\n\t}\n}\n\n// .options {\n// \tpadding: var(--space-xs);\n// }\n\n.optionsPalette {\n\t--input-width: auto;\n\n\tdisplay: grid;\n\tgrid-template-columns: repeat(5, minmax(0, 1fr));\n\tgap: var(--space-xs);\n}\n\n.optionsDetailed {\n\t--input-width: 16em;\n}\n\n.option {\n\tborder-radius: var(--radius-sm);\n\toutline: none;\n\tuser-select: none;\n}\n\n.optionPalette {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tpadding: var(--space-sm);\n\tmin-width: 2.25em;\n}\n\n.optionDetailed {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: var(--space-sm);\n\tpadding: var(--space-xs) var(--space-sm);\n}\n\n.optionMeta {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tgap: var(--space-xs);\n\tmin-width: 0;\n}\n\n.optionMetaIcon {\n\tdisplay: inline-flex;\n\talign-items: center;\n}\n\n.optionMetaLabel {\n\tmin-width: 0;\n\twhite-space: nowrap;\n\ttext-overflow: ellipsis;\n\toverflow: hidden;\n}\n","import { CSSProperties, ReactNode, useMemo } from \"react\";\n\nimport { DEFAULT_VALUE_STATES, VALUE_STATE_COLOR_TOKENS } from \"@ryuzaki13/react-foundation-lib/formatters\";\nimport { State } from \"@ryuzaki13/react-foundation-lib/types\";\nimport { cn } from \"@ryuzaki13/react-foundation-lib/utils\";\n\nimport { Select, SelectProps } from \"../select\";\nimport { UiBaseProps } from \"../types\";\n\nimport styles from \"./StateSelect.module.scss\";\n\nexport type StateMeta = {\n\tlabel?: ReactNode;\n\ticon?: ReactNode;\n};\n\nexport interface StateSelectProps extends Omit<UiBaseProps<State | undefined>, \"placeholder\"> {\n\tplaceholder?: string;\n\toptions?: readonly State[];\n\tstateMeta?: Partial<Record<State, StateMeta>>;\n\tclassName?: string;\n\tclearable?: boolean;\n}\n\ninterface StateSwatchProps {\n\tstate: State;\n\tclassName?: string;\n}\n\nfunction StateSwatch({ state, className }: StateSwatchProps) {\n\treturn (\n\t\t<span\n\t\t\tclassName={cn(styles.swatch, className)}\n\t\t\tdata-empty={state === \"none\" ? \"\" : undefined}\n\t\t\tstyle={{ \"--state-color\": VALUE_STATE_COLOR_TOKENS[state] } as CSSProperties}\n\t\t/>\n\t);\n}\n\nfunction hasStateMeta(meta: StateMeta | undefined): boolean {\n\treturn Boolean(meta?.icon || meta?.label);\n}\n\nfunction resolveStateAriaLabel(state: State, meta: StateMeta | undefined): string {\n\tif (typeof meta?.label === \"string\" && meta.label.trim()) {\n\t\treturn meta.label;\n\t}\n\n\treturn state || \"empty\";\n}\n\nfunction renderStateMeta(meta: StateMeta | undefined) {\n\tif (!hasStateMeta(meta)) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<span className={styles.optionMeta}>\n\t\t\t{meta?.icon ? <span className={styles.optionMetaIcon}>{meta.icon}</span> : null}\n\t\t\t{meta?.label ? <span className={styles.optionMetaLabel}>{meta.label}</span> : null}\n\t\t</span>\n\t);\n}\n\nfunction renderStateValue(state: State, meta: StateMeta | undefined) {\n\treturn (\n\t\t<div className={styles.valueContainer}>\n\t\t\t<StateSwatch state={state} />\n\t\t\t{renderStateMeta(meta)}\n\t\t</div>\n\t);\n}\n\n/**\n * Специализированный селект для выбора цветового или статусного состояния. Используется там, где значению соответствует визуальный swatch.\n */\nexport function StateSelect({\n\tlabel,\n\tdescription,\n\tdisabled,\n\tplaceholder,\n\tsize,\n\tvalue,\n\tonChange,\n\toptions = DEFAULT_VALUE_STATES,\n\tstateMeta,\n\tclassName,\n\tclearable\n}: StateSelectProps) {\n\tconst stateOptions = useMemo(() => Array.from(new Set(options)), [options]);\n\tconst hasDetailedOptions = stateOptions.some((stateOption) => hasStateMeta(stateMeta?.[stateOption]));\n\n\tconst sharedSelectProps: Pick<\n\t\tSelectProps<State>,\n\t\t| \"getOptionKey\"\n\t\t| \"getOptionLabel\"\n\t\t| \"getOptionAriaLabel\"\n\t\t| \"renderValue\"\n\t\t| \"renderOption\"\n\t\t| \"buttonClassName\"\n\t\t| \"optionsContentClassName\"\n\t\t| \"getOptionClassName\"\n\t> = {\n\t\tgetOptionKey: (stateOption) => stateOption || \"__empty_state__\",\n\t\tgetOptionLabel: (stateOption) => stateMeta?.[stateOption]?.label ?? stateOption,\n\t\tgetOptionAriaLabel: (stateOption) => resolveStateAriaLabel(stateOption, stateMeta?.[stateOption]),\n\t\trenderValue: (stateOption) => renderStateValue(stateOption, stateMeta?.[stateOption]),\n\t\trenderOption: (stateOption) => (\n\t\t\t<>\n\t\t\t\t<StateSwatch state={stateOption} />\n\t\t\t\t{hasDetailedOptions ? renderStateMeta(stateMeta?.[stateOption]) : null}\n\t\t\t</>\n\t\t),\n\t\tbuttonClassName: styles.button,\n\t\toptionsContentClassName: cn(/*styles.options,*/ hasDetailedOptions ? styles.optionsDetailed : styles.optionsPalette),\n\t\tgetOptionClassName: () => cn(styles.option, hasDetailedOptions ? styles.optionDetailed : styles.optionPalette)\n\t};\n\n\treturn (\n\t\t<Select\n\t\t\tlabel={label}\n\t\t\tdescription={description}\n\t\t\tdisabled={disabled}\n\t\t\tplaceholder={placeholder}\n\t\t\tsize={size}\n\t\t\tvalue={value}\n\t\t\tonChange={onChange}\n\t\t\toptions={stateOptions}\n\t\t\tclassName={className}\n\t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Ae,MAAgB,KAAe;EAC9C,iBAAiB,MAAgB,IAAY,EAAY,EAAE,SAAS;EACpE,qBAAqB,MAAgB,EAAsB,GAAa,IAAY,EAAY;EAChG,cAAc,MAAgB,EAAiB,GAAa,IAAY,EAAY;EACpF,eAAe,MACd,kBAAA,GAAA,EAAA,UAAA,CACC,kBAAC,GAAD,EAAa,OAAO,EAAc,CAAA,GACjC,IAAqB,EAAgB,IAAY,EAAY,IAAI,IACjE,EAAA,CAAA;EAEH,iBAAiB,EAAO;EACxB,yBAAyB,EAAuB,IAAqB,EAAO,kBAAkB,EAAO,cAAc;EACnH,0BAA0B,EAAG,EAAO,QAAQ,IAAqB,EAAO,iBAAiB,EAAO,aAAa;CAgB5G,CAAA;AAEH"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { a as e, r as t } from "./odata-DSW7z3nh.js";
|
|
2
|
+
import { t as n } from "./MultiSelect-D1XYuwH1.js";
|
|
3
|
+
import { n as r, t as i } from "./useODataSelectBase-BbeKdq6x.js";
|
|
4
|
+
import { useCallback as a, useState as o } from "react";
|
|
5
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
6
|
+
//#region src/multi-select/model/useODataMultiSelect.ts
|
|
7
|
+
function c({ odata: e, segment: t, model: n, value: a, dependencies: o, onChange: s }) {
|
|
8
|
+
let c = r({
|
|
9
|
+
odata: e,
|
|
10
|
+
segment: t,
|
|
11
|
+
model: n,
|
|
12
|
+
value: a,
|
|
13
|
+
dependencies: o
|
|
14
|
+
}), l = (e) => {
|
|
15
|
+
s(i(e, c.selectionKey));
|
|
16
|
+
};
|
|
17
|
+
return {
|
|
18
|
+
...c,
|
|
19
|
+
handleChange: l
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/multi-select/ui/ODataMultiSelect.tsx
|
|
24
|
+
var l = ({ odata: t, segment: r, model: i, label: a, description: o, disabled: l, value: u, dependencies: d, onChange: f, size: p }) => {
|
|
25
|
+
let m = c({
|
|
26
|
+
odata: t,
|
|
27
|
+
segment: r,
|
|
28
|
+
model: e(i),
|
|
29
|
+
value: u,
|
|
30
|
+
dependencies: d,
|
|
31
|
+
onChange: f
|
|
32
|
+
});
|
|
33
|
+
return /* @__PURE__ */ s(n, {
|
|
34
|
+
label: a,
|
|
35
|
+
description: o,
|
|
36
|
+
size: p,
|
|
37
|
+
codeKey: m.codeKey,
|
|
38
|
+
textKey: m.textKey,
|
|
39
|
+
hideCode: r.hideCode ?? t.hideCode,
|
|
40
|
+
items: m.filteredItems,
|
|
41
|
+
value: m.selectedItems,
|
|
42
|
+
onChange: m.handleChange,
|
|
43
|
+
onQuery: m.setQuery,
|
|
44
|
+
query: m.query,
|
|
45
|
+
defaultFilter: !1,
|
|
46
|
+
highlightQuery: m.debouncedQuery,
|
|
47
|
+
disabled: l || m.isLoading,
|
|
48
|
+
placeholder: m.placeholder,
|
|
49
|
+
error: m.isError ? "Ошибка загрузки" : void 0
|
|
50
|
+
});
|
|
51
|
+
}, u = ({ item: e, values: t, onChange: n, width: r = 15 }) => {
|
|
52
|
+
let [i, c] = o({}), u = t ?? i, d = `calc(${r}em + var(--width-add))`, f = a((r) => {
|
|
53
|
+
let i = {
|
|
54
|
+
...u,
|
|
55
|
+
[e.id]: r
|
|
56
|
+
};
|
|
57
|
+
t || c(i), n?.(i);
|
|
58
|
+
}, [
|
|
59
|
+
e.id,
|
|
60
|
+
n,
|
|
61
|
+
u,
|
|
62
|
+
t
|
|
63
|
+
]);
|
|
64
|
+
return /* @__PURE__ */ s("div", {
|
|
65
|
+
style: {
|
|
66
|
+
maxWidth: d,
|
|
67
|
+
minWidth: d
|
|
68
|
+
},
|
|
69
|
+
children: /* @__PURE__ */ s(l, {
|
|
70
|
+
odata: e.odata,
|
|
71
|
+
segment: e.segment,
|
|
72
|
+
model: e.model,
|
|
73
|
+
dependencies: u,
|
|
74
|
+
value: u[e.id],
|
|
75
|
+
onChange: f
|
|
76
|
+
})
|
|
77
|
+
});
|
|
78
|
+
}, d = ({ width: e = 15, odata: n, segments: r, model: i, values: a, onChange: c }) => {
|
|
79
|
+
let [l, d] = o({}), f = a ?? l;
|
|
80
|
+
return t([{
|
|
81
|
+
odata: n,
|
|
82
|
+
segments: r,
|
|
83
|
+
model: i
|
|
84
|
+
}]).map((t) => /* @__PURE__ */ s(u, {
|
|
85
|
+
item: t,
|
|
86
|
+
values: f,
|
|
87
|
+
onChange: (e) => {
|
|
88
|
+
a || d(e), c?.(e);
|
|
89
|
+
},
|
|
90
|
+
width: e
|
|
91
|
+
}, t.id));
|
|
92
|
+
};
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/multi-select/ui/SerializableMultiSelect.tsx
|
|
95
|
+
function f(e, t) {
|
|
96
|
+
return e[t];
|
|
97
|
+
}
|
|
98
|
+
function p(e, t, n) {
|
|
99
|
+
let r = e[t];
|
|
100
|
+
if (typeof r == "string") return r;
|
|
101
|
+
let i = f(e, n);
|
|
102
|
+
return typeof i == "string" ? i : String(i);
|
|
103
|
+
}
|
|
104
|
+
function m({ label: e, description: t, disabled: r, placeholder: i, size: a, options: o, value: c, onChange: l, optionKey: u, optionLabel: d, renderCode: m }) {
|
|
105
|
+
let h = o.map((e) => ({
|
|
106
|
+
key: String(f(e, u)),
|
|
107
|
+
text: p(e, d, u)
|
|
108
|
+
})), g = new Set((c ?? []).map((e) => String(e))), _ = h.filter((e) => g.has(e.key));
|
|
109
|
+
return /* @__PURE__ */ s(n, {
|
|
110
|
+
label: e,
|
|
111
|
+
description: t,
|
|
112
|
+
disabled: r,
|
|
113
|
+
placeholder: i,
|
|
114
|
+
size: a,
|
|
115
|
+
items: h,
|
|
116
|
+
codeKey: "key",
|
|
117
|
+
textKey: "text",
|
|
118
|
+
hideCode: m ? void 0 : !0,
|
|
119
|
+
value: _,
|
|
120
|
+
onChange: (e) => l(e.map((e) => e.key))
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
export { l as i, d as n, u as r, m as t };
|
|
125
|
+
|
|
126
|
+
//# sourceMappingURL=multi-select-BYsbh2ca.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multi-select-BYsbh2ca.js","names":[],"sources":["../../src/multi-select/model/useODataMultiSelect.ts","../../src/multi-select/ui/ODataMultiSelect.tsx","../../src/multi-select/ui/ODataDependentSegmentMultiSelect.tsx","../../src/multi-select/ui/ODataDependentMultiSelect.tsx","../../src/multi-select/ui/SerializableMultiSelect.tsx"],"sourcesContent":["import { ODataCollectionModel, ODataSelectBaseProps } from \"@ryuzaki13/react-foundation-api/odata\";\nimport { CollectionItem } from \"@ryuzaki13/react-foundation-lib/odata\";\n\nimport { mapSelectedItemsToValues, useODataSelectBase } from \"../../select/model/useODataSelectBase\";\n\ninterface UseODataMultiSelectOptions extends Omit<ODataSelectBaseProps, \"model\"> {\n\tmodel: Required<ODataCollectionModel>;\n\tonChange: (keys: string[]) => void;\n}\n\nexport function useODataMultiSelect({ odata, segment, model, value, dependencies, onChange }: UseODataMultiSelectOptions) {\n\tconst odataModel = useODataSelectBase({\n\t\todata,\n\t\tsegment,\n\t\tmodel,\n\t\tvalue,\n\t\tdependencies\n\t});\n\n\tconst handleChange = (items: CollectionItem[]) => {\n\t\tonChange(mapSelectedItemsToValues(items, odataModel.selectionKey));\n\t};\n\n\treturn {\n\t\t...odataModel,\n\t\thandleChange\n\t};\n}\n","import React from \"react\";\n\nimport { ODataSelectBaseProps, useODataCollectionModel } from \"@ryuzaki13/react-foundation-api/odata\";\n\nimport { UiBaseProps } from \"../../types\";\nimport { useODataMultiSelect } from \"../model/useODataMultiSelect\";\n\nimport { MultiSelect } from \"./MultiSelect\";\n\ntype ODataMultiSelectProps = ODataSelectBaseProps & Omit<UiBaseProps<string[]>, \"placeholder\"> & {};\n\nexport const ODataMultiSelect: React.FC<ODataMultiSelectProps> = ({\n\todata,\n\tsegment,\n\tmodel: initialModel,\n\tlabel,\n\tdescription,\n\tdisabled,\n\tvalue,\n\tdependencies,\n\tonChange,\n\tsize\n}) => {\n\tconst model = useODataCollectionModel(initialModel);\n\tconst odataModel = useODataMultiSelect({\n\t\todata,\n\t\tsegment,\n\t\tmodel,\n\t\tvalue,\n\t\tdependencies,\n\t\tonChange\n\t});\n\n\treturn (\n\t\t<MultiSelect\n\t\t\tlabel={label}\n\t\t\tdescription={description}\n\t\t\tsize={size}\n\t\t\tcodeKey={odataModel.codeKey}\n\t\t\ttextKey={odataModel.textKey}\n\t\t\thideCode={segment.hideCode ?? odata.hideCode}\n\t\t\titems={odataModel.filteredItems}\n\t\t\tvalue={odataModel.selectedItems}\n\t\t\tonChange={odataModel.handleChange}\n\t\t\tonQuery={odataModel.setQuery}\n\t\t\tquery={odataModel.query}\n\t\t\tdefaultFilter={false}\n\t\t\thighlightQuery={odataModel.debouncedQuery}\n\t\t\tdisabled={disabled || odataModel.isLoading}\n\t\t\tplaceholder={odataModel.placeholder}\n\t\t\terror={odataModel.isError ? \"Ошибка загрузки\" : undefined}\n\t\t/>\n\t);\n};\n","import { useCallback, useState } from \"react\";\n\nimport { ODataMultiSelect } from \"./ODataMultiSelect\";\n\nimport type { ODataDependentSegmentItem } from \"@ryuzaki13/react-foundation-api/odata\";\n\ninterface ODataDependentSegmentMultiSelectProps {\n\titem: ODataDependentSegmentItem;\n\t/**\n\t * Выбранные значения (управляемый компонент)\n\t */\n\tvalues?: Record<string, string[]>;\n\t/**\n\t * Обработчик изменения выбранных значений\n\t */\n\tonChange?: (selected: Record<string, string[]>) => void;\n\t/**\n\t * Ширина одного элемента в `em` единицах.\n\t *\n\t * @default 15\n\t */\n\twidth?: number;\n}\n\nexport const ODataDependentSegmentMultiSelect: React.FC<ODataDependentSegmentMultiSelectProps> = ({\n\titem,\n\tvalues,\n\tonChange,\n\twidth = 15\n}) => {\n\tconst [internalSelectedValues, setInternalSelectedValues] = useState<Record<string, string[]>>({});\n\tconst selectedValues = values ?? internalSelectedValues;\n\tconst widthStyle = `calc(${width}em + var(--width-add))`;\n\n\tconst handleSelectionChange = useCallback(\n\t\t(keys: string[]) => {\n\t\t\tconst nextSelectedValues = {\n\t\t\t\t...selectedValues,\n\t\t\t\t[item.id]: keys\n\t\t\t};\n\n\t\t\tif (!values) {\n\t\t\t\tsetInternalSelectedValues(nextSelectedValues);\n\t\t\t}\n\n\t\t\tonChange?.(nextSelectedValues);\n\t\t},\n\t\t[item.id, onChange, selectedValues, values]\n\t);\n\n\treturn (\n\t\t<div style={{ maxWidth: widthStyle, minWidth: widthStyle }}>\n\t\t\t<ODataMultiSelect\n\t\t\t\todata={item.odata}\n\t\t\t\tsegment={item.segment}\n\t\t\t\tmodel={item.model}\n\t\t\t\tdependencies={selectedValues}\n\t\t\t\tvalue={selectedValues[item.id]}\n\t\t\t\tonChange={handleSelectionChange}\n\t\t\t/>\n\t\t</div>\n\t);\n};\n","import { useState } from \"react\";\n\nimport { flattenODataDependentServices, ODataDependentBaseProps } from \"@ryuzaki13/react-foundation-api/odata\";\n\nimport { ODataDependentSegmentMultiSelect } from \"./ODataDependentSegmentMultiSelect\";\n\ninterface ODataDependentMultiSelectProps extends ODataDependentBaseProps {\n\t/**\n\t * Выбранные значения (управляемый компонент)\n\t */\n\tvalues?: Record<string, string[]>;\n\n\t/**\n\t * Обработчик изменения выбранных значений\n\t */\n\tonChange?: (selected: Record<string, string[]>) => void;\n\n\t/**\n\t * Ширина одного элемента в `em` единицах.\n\t *\n\t * @default 15\n\t */\n\twidth?: number;\n}\n\nexport const ODataDependentMultiSelect: React.FC<ODataDependentMultiSelectProps> = ({\n\twidth = 15,\n\todata,\n\tsegments,\n\tmodel,\n\tvalues,\n\tonChange\n}) => {\n\tconst [internalSelectedValues, setInternalSelectedValues] = useState<Record<string, string[]>>({});\n\tconst selectedValues = values ?? internalSelectedValues;\n\tconst items = flattenODataDependentServices([\n\t\t{\n\t\t\todata,\n\t\t\tsegments,\n\t\t\tmodel\n\t\t}\n\t]);\n\n\treturn items.map((item) => (\n\t\t<ODataDependentSegmentMultiSelect\n\t\t\tkey={item.id}\n\t\t\titem={item}\n\t\t\tvalues={selectedValues}\n\t\t\tonChange={(nextSelectedValues) => {\n\t\t\t\tif (!values) {\n\t\t\t\t\tsetInternalSelectedValues(nextSelectedValues);\n\t\t\t\t}\n\n\t\t\t\tonChange?.(nextSelectedValues);\n\t\t\t}}\n\t\t\twidth={width}\n\t\t/>\n\t));\n};\n","import { MultiSelect } from \"./MultiSelect\";\n\nimport type { UiBaseProps } from \"../../types\";\nimport type { CollectionItem } from \"@ryuzaki13/react-foundation-lib/odata\";\n\ntype SerializableOptionRecord = Record<string, unknown>;\n\ntype SerializableOptionKeyField<TOption extends SerializableOptionRecord> = {\n\t[K in keyof TOption]: Extract<TOption[K], string> extends never ? never : K;\n}[keyof TOption];\n\nexport interface SerializableMultiSelectProps<\n\tTOption extends SerializableOptionRecord,\n\tTOptionKey extends SerializableOptionKeyField<TOption>,\n\tTOptionLabel extends keyof TOption\n> extends UiBaseProps<Extract<TOption[TOptionKey], string>[]> {\n\toptions: readonly TOption[];\n\toptionKey: TOptionKey;\n\toptionLabel: TOptionLabel;\n\trenderCode?: true;\n}\n\nfunction getSerializableOptionKey<TOption extends SerializableOptionRecord, TOptionKey extends SerializableOptionKeyField<TOption>>(\n\toption: TOption,\n\toptionKey: TOptionKey\n): Extract<TOption[TOptionKey], string> {\n\treturn option[optionKey] as Extract<TOption[TOptionKey], string>;\n}\n\nfunction getSerializableOptionLabel<\n\tTOption extends SerializableOptionRecord,\n\tTOptionKey extends SerializableOptionKeyField<TOption>,\n\tTOptionLabel extends keyof TOption\n>(option: TOption, optionLabel: TOptionLabel, optionKey: TOptionKey): string {\n\tconst label = option[optionLabel];\n\n\tif (typeof label === \"string\") {\n\t\treturn label;\n\t}\n\n\tconst key = getSerializableOptionKey(option, optionKey);\n\treturn typeof key === \"string\" ? key : String(key);\n}\n\nexport function SerializableMultiSelect<\n\tTOption extends SerializableOptionRecord,\n\tTOptionKey extends SerializableOptionKeyField<TOption>,\n\tTOptionLabel extends keyof TOption\n>({\n\tlabel,\n\tdescription,\n\tdisabled,\n\tplaceholder,\n\tsize,\n\toptions,\n\tvalue,\n\tonChange,\n\toptionKey,\n\toptionLabel,\n\trenderCode\n}: SerializableMultiSelectProps<TOption, TOptionKey, TOptionLabel>) {\n\t// Как будто можно не мемоизировать, нет смысла\n\tconst items = options.map<CollectionItem>((option) => ({\n\t\tkey: String(getSerializableOptionKey(option, optionKey)),\n\t\ttext: getSerializableOptionLabel(option, optionLabel, optionKey)\n\t}));\n\tconst selectedKeys = new Set((value ?? []).map((item) => String(item)));\n\tconst selectedItems = items.filter((item) => selectedKeys.has(item.key));\n\n\treturn (\n\t\t<MultiSelect\n\t\t\tlabel={label}\n\t\t\tdescription={description}\n\t\t\tdisabled={disabled}\n\t\t\tplaceholder={placeholder}\n\t\t\tsize={size}\n\t\t\titems={items}\n\t\t\tcodeKey=\"key\"\n\t\t\ttextKey=\"text\"\n\t\t\thideCode={renderCode ? undefined : true}\n\t\t\tvalue={selectedItems}\n\t\t\tonChange={(nextItems) => onChange(nextItems.map((item) => item.key) as Extract<TOption[TOptionKey], string>[])}\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;AAUA,SAAgB,EAAoB,EAAE,UAAO,YAAS,UAAO,UAAO,iBAAc,eAAwC;CACzH,IAAM,IAAa,EAAmB;EACrC;EACA;EACA;EACA;EACA;CACD,CAAC,GAEK,KAAgB,MAA4B;EACjD,EAAS,EAAyB,GAAO,EAAW,YAAY,CAAC;CAClE;CAEA,OAAO;EACN,GAAG;EACH;CACD;AACD;;;AChBA,IAAa,KAAqD,EACjE,UACA,YACA,OAAO,GACP,UACA,gBACA,aACA,UACA,iBACA,aACA,cACK;CAEL,IAAM,IAAa,EAAoB;EACtC;EACA;EACA,OAJa,EAAwB,CAIrC;EACA;EACA;EACA;CACD,CAAC;CAED,OACC,kBAAC,GAAD;EACQ;EACM;EACP;EACN,SAAS,EAAW;EACpB,SAAS,EAAW;EACpB,UAAU,EAA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