xmlui 0.9.90 → 0.9.93
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/lib/{index-Bs4hp2dn.mjs → index-C4FeLQEv.mjs} +7988 -7791
- package/dist/lib/index.css +1 -1
- package/dist/lib/{initMock-DwAYhsKb.mjs → initMock-DwQKZ8T4.mjs} +1 -1
- package/dist/lib/language-server-web-worker.mjs +1 -1
- package/dist/lib/language-server.mjs +1 -1
- package/dist/lib/{metadata-utils-DJhOKFL6.mjs → metadata-utils-PjrGUxZN.mjs} +47 -49
- package/dist/lib/{server-common-CIqrGYx-.mjs → server-common-BbjTO8TH.mjs} +4446 -4476
- package/dist/lib/{transform-bUuxPyao.mjs → transform-CDSgqN5L.mjs} +1240 -1202
- package/dist/lib/xmlui-parser.d.ts +3 -1
- package/dist/lib/xmlui-parser.mjs +2 -2
- package/dist/lib/{xmlui-serializer-BLFl30t9.mjs → xmlui-serializer-D6rtRMNI.mjs} +1 -1
- package/dist/lib/xmlui.d.ts +17 -12
- package/dist/lib/xmlui.mjs +2 -2
- package/dist/metadata/{collectedComponentMetadata-fh2ak2QN.mjs → collectedComponentMetadata-CTFECKPI.mjs} +8885 -8651
- package/dist/metadata/{initMock-8hLEm7iV.mjs → initMock-DUtrSCpH.mjs} +1 -1
- package/dist/metadata/style.css +1 -1
- package/dist/metadata/xmlui-metadata.mjs +1 -1
- package/dist/metadata/xmlui-metadata.umd.js +102 -98
- package/dist/scripts/package.json +2 -1
- package/dist/scripts/src/components/AutoComplete/AutoComplete.js +5 -2
- package/dist/scripts/src/components/AutoComplete/AutoCompleteContext.js +1 -2
- package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +9 -12
- package/dist/scripts/src/components/Bookmark/Bookmark.js +1 -1
- package/dist/scripts/src/components/ComponentProvider.js +2 -2
- package/dist/scripts/src/{components-core → components/Fragment}/Fragment.js +2 -2
- package/dist/scripts/src/components/Option/Option.js +11 -11
- package/dist/scripts/src/components/Select/HiddenOption.js +2 -2
- package/dist/scripts/src/components/Select/Select.js +5 -9
- package/dist/scripts/src/components/Select/SelectNative.js +95 -45
- package/dist/scripts/src/{components-core → components/Slot}/Slot.js +2 -2
- package/dist/scripts/src/components/SlotItem.js +1 -0
- package/dist/scripts/src/components/Spinner/SpinnerNative.js +3 -4
- package/dist/scripts/src/components/Tabs/TabItem.js +12 -1
- package/dist/scripts/src/components/Tabs/TabItemNative.js +4 -3
- package/dist/scripts/src/components/Tabs/Tabs.js +1 -1
- package/dist/scripts/src/components/Tabs/TabsNative.js +22 -43
- package/dist/scripts/src/components/TextArea/TextArea.js +1 -2
- package/dist/scripts/src/components/Toggle/Toggle.js +34 -10
- package/dist/scripts/src/components/abstractions.js +25 -6
- package/dist/scripts/src/components/container-helpers.js +2 -1
- package/dist/scripts/src/components-core/rendering/ComponentAdapter.js +4 -5
- package/dist/scripts/src/components-core/rendering/ComponentWrapper.js +2 -1
- package/dist/scripts/src/components-core/xmlui-parser.js +365 -196
- package/dist/scripts/src/parsers/xmlui-parser/diagnostics.js +1 -1
- package/dist/scripts/src/parsers/xmlui-parser/parser.js +69 -1
- package/dist/standalone/xmlui-standalone.es.d.ts +18 -12
- package/dist/standalone/xmlui-standalone.umd.js +252 -248
- package/package.json +2 -1
- package/dist/scripts/src/abstractions/scripting/modules.js +0 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xmlui",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.93",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start-test-bed": "cd src/testing/infrastructure && xmlui start",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"test:e2e-non-smoke": "playwright test --project non-smoke",
|
|
14
14
|
"test:e2e-smoke": "playwright test --project smoke",
|
|
15
15
|
"test:e2e-ui": "playwright test --ui",
|
|
16
|
+
"test:e2e-summary": "node scripts/e2e-test-summary.js",
|
|
16
17
|
"lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .",
|
|
17
18
|
"prepublishOnly": "clean-package",
|
|
18
19
|
"postpublish": "clean-package restore",
|
|
@@ -90,8 +90,11 @@ exports.AutoCompleteMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
90
90
|
});
|
|
91
91
|
exports.autoCompleteComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.AutoCompleteMd, ({ node, state, updateState, extractValue, renderChild, lookupEventHandler, layoutCss, registerComponentApi, }) => {
|
|
92
92
|
return ((0, jsx_runtime_1.jsx)(AutoCompleteNative_1.AutoComplete, { multi: extractValue.asOptionalBoolean(node.props.multi), style: layoutCss, updateState: updateState, initialValue: extractValue(node.props.initialValue), value: state === null || state === void 0 ? void 0 : state.value, creatable: extractValue.asOptionalBoolean(node.props.creatable), label: extractValue(node.props.label), labelPosition: extractValue(node.props.labelPosition), labelWidth: extractValue(node.props.labelWidth), labelBreak: extractValue.asOptionalBoolean(node.props.labelBreak), autoFocus: extractValue.asOptionalBoolean(node.props.autoFocus), enabled: extractValue.asOptionalBoolean(node.props.enabled), placeholder: extractValue.asOptionalString(node.props.placeholder), validationStatus: extractValue(node.props.validationStatus), onDidChange: lookupEventHandler("didChange"), onFocus: lookupEventHandler("gotFocus"), onBlur: lookupEventHandler("lostFocus"), registerComponentApi: registerComponentApi, emptyListTemplate: renderChild(node.props.emptyListTemplate), dropdownHeight: extractValue(node.props.dropdownHeight), readOnly: extractValue.asOptionalBoolean(node.props.readOnly), optionRenderer: node.props.optionTemplate
|
|
93
|
-
? (item) => {
|
|
94
|
-
return ((0, jsx_runtime_1.jsx)(container_helpers_1.MemoizedItem, { node: node.props.optionTemplate, item: item,
|
|
93
|
+
? (item, val, inTrigger) => {
|
|
94
|
+
return ((0, jsx_runtime_1.jsx)(container_helpers_1.MemoizedItem, { node: node.props.optionTemplate, item: item, context: {
|
|
95
|
+
$selectedValue: val,
|
|
96
|
+
$inTrigger: inTrigger,
|
|
97
|
+
}, renderChild: renderChild }));
|
|
95
98
|
}
|
|
96
99
|
: undefined, children: renderChild(node.children) }));
|
|
97
100
|
});
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AutoCompleteContext = void 0;
|
|
4
4
|
exports.useAutoComplete = useAutoComplete;
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
5
|
const react_1 = require("react");
|
|
7
6
|
exports.AutoCompleteContext = (0, react_1.createContext)({
|
|
8
7
|
value: null,
|
|
9
8
|
onChange: (selectedValue) => { },
|
|
10
|
-
optionRenderer: (option) => (0, jsx_runtime_1.jsx)("div", { children: option.label }),
|
|
11
9
|
inputValue: "",
|
|
12
10
|
options: new Set(),
|
|
13
11
|
open: false,
|
|
14
12
|
setOpen: (open) => { },
|
|
13
|
+
optionRenderer: (option, selectedValue, inTrigger) => null,
|
|
15
14
|
});
|
|
16
15
|
function useAutoComplete() {
|
|
17
16
|
return (0, react_1.useContext)(exports.AutoCompleteContext);
|
|
@@ -19,9 +19,6 @@ const ThemeContext_1 = require("../../components-core/theming/ThemeContext");
|
|
|
19
19
|
const react_popover_1 = require("@radix-ui/react-popover");
|
|
20
20
|
const ItemWithLabel_1 = require("../FormItem/ItemWithLabel");
|
|
21
21
|
const HiddenOption_1 = require("../Select/HiddenOption");
|
|
22
|
-
function defaultRenderer(item) {
|
|
23
|
-
return (0, jsx_runtime_1.jsx)("div", { children: item.label });
|
|
24
|
-
}
|
|
25
22
|
function isOptionsExist(options, newOptions) {
|
|
26
23
|
return newOptions.some((option) => Array.from(options).some((o) => o.value === option.value || o.label === option.label));
|
|
27
24
|
}
|
|
@@ -33,13 +30,12 @@ exports.defaultProps = {
|
|
|
33
30
|
required: false,
|
|
34
31
|
validationStatus: "none",
|
|
35
32
|
creatable: false,
|
|
36
|
-
optionRenderer: defaultRenderer,
|
|
37
33
|
updateState: constants_1.noop,
|
|
38
34
|
onDidChange: constants_1.noop,
|
|
39
35
|
onFocus: constants_1.noop,
|
|
40
36
|
onBlur: constants_1.noop,
|
|
41
37
|
};
|
|
42
|
-
exports.AutoComplete = (0, react_1.forwardRef)(function AutoComplete({ id, initialValue, value, enabled = exports.defaultProps.enabled, placeholder, updateState = exports.defaultProps.updateState, validationStatus = exports.defaultProps.validationStatus, onDidChange = exports.defaultProps.onDidChange, onFocus = exports.defaultProps.onFocus, onBlur = exports.defaultProps.onBlur, registerComponentApi,
|
|
38
|
+
exports.AutoComplete = (0, react_1.forwardRef)(function AutoComplete({ id, initialValue, value, enabled = exports.defaultProps.enabled, placeholder, updateState = exports.defaultProps.updateState, validationStatus = exports.defaultProps.validationStatus, onDidChange = exports.defaultProps.onDidChange, onFocus = exports.defaultProps.onFocus, onBlur = exports.defaultProps.onBlur, registerComponentApi, emptyListTemplate, style, children, readOnly = exports.defaultProps.readOnly, autoFocus = exports.defaultProps.autoFocus, dropdownHeight, multi = exports.defaultProps.multi, label, labelPosition, labelWidth, labelBreak, required = exports.defaultProps.required, creatable = exports.defaultProps.creatable, optionRenderer, }, forwardedRef) {
|
|
43
39
|
const [referenceElement, setReferenceElement] = (0, react_1.useState)(null);
|
|
44
40
|
const inputRef = (0, react_1.useRef)(null);
|
|
45
41
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
@@ -154,14 +150,14 @@ exports.AutoComplete = (0, react_1.forwardRef)(function AutoComplete({ id, initi
|
|
|
154
150
|
multi,
|
|
155
151
|
value,
|
|
156
152
|
onChange: toggleOption,
|
|
157
|
-
optionRenderer,
|
|
158
153
|
options,
|
|
159
154
|
inputValue,
|
|
160
155
|
open,
|
|
161
156
|
setOpen,
|
|
157
|
+
optionRenderer,
|
|
162
158
|
};
|
|
163
|
-
}, [inputValue, multi,
|
|
164
|
-
return ((0, jsx_runtime_1.jsx)(AutoCompleteContext_1.AutoCompleteContext.Provider, { value: autoCompleteContextValue, children: (0, jsx_runtime_1.jsx)(
|
|
159
|
+
}, [inputValue, multi, options, toggleOption, value, open, setOpen, optionRenderer]);
|
|
160
|
+
return ((0, jsx_runtime_1.jsx)(AutoCompleteContext_1.AutoCompleteContext.Provider, { value: autoCompleteContextValue, children: (0, jsx_runtime_1.jsx)(OptionContext_1.OptionContext.Provider, { value: optionContextValue, children: (0, jsx_runtime_1.jsxs)(OptionTypeProvider_1.default, { Component: HiddenOption_1.HiddenOption, children: [(0, jsx_runtime_1.jsx)(ItemWithLabel_1.ItemWithLabel, { id: inputId, ref: forwardedRef, labelPosition: labelPosition, label: label, labelWidth: labelWidth, labelBreak: labelBreak, required: required, enabled: enabled, onFocus: onFocus, onBlur: onBlur, style: style, children: (0, jsx_runtime_1.jsx)(react_popover_1.Popover, { open: open, onOpenChange: (isOpen) => {
|
|
165
161
|
if (readOnly)
|
|
166
162
|
return;
|
|
167
163
|
setOpen(isOpen);
|
|
@@ -243,11 +239,12 @@ function CreatableItem() {
|
|
|
243
239
|
}
|
|
244
240
|
return (0, jsx_runtime_1.jsx)("span", { style: { display: "none" } });
|
|
245
241
|
}
|
|
246
|
-
function AutoCompleteOption(
|
|
242
|
+
function AutoCompleteOption(option) {
|
|
243
|
+
const { value, label, enabled = true, keywords, readOnly, children } = option;
|
|
247
244
|
const id = (0, react_1.useId)();
|
|
248
|
-
const { value: selectedValue, onChange,
|
|
245
|
+
const { value: selectedValue, onChange, multi, setOpen, optionRenderer } = (0, AutoCompleteContext_1.useAutoComplete)();
|
|
249
246
|
const selected = multi ? selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.includes(value) : selectedValue === value;
|
|
250
|
-
return ((0, jsx_runtime_1.
|
|
247
|
+
return ((0, jsx_runtime_1.jsx)(cmdk_1.CommandItem, { id: id, disabled: !enabled, value: `${value}`, className: (0, classnames_1.default)(AutoComplete_module_scss_1.default.autoCompleteOption, {
|
|
251
248
|
[AutoComplete_module_scss_1.default.disabledOption]: !enabled,
|
|
252
249
|
}), onMouseDown: (e) => {
|
|
253
250
|
e.preventDefault();
|
|
@@ -256,5 +253,5 @@ function AutoCompleteOption({ value, label, enabled = true, keywords, readOnly }
|
|
|
256
253
|
if (!readOnly && enabled)
|
|
257
254
|
onChange(value);
|
|
258
255
|
setOpen(false);
|
|
259
|
-
}, "data-state": enabled ? (selected ? "checked" : undefined) : "disabled", keywords: keywords, children: [optionRenderer({ label, value }), selected && (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "checkmark" })] }, id));
|
|
256
|
+
}, "data-state": enabled ? (selected ? "checked" : undefined) : "disabled", keywords: keywords, children: children ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: AutoComplete_module_scss_1.default.autoCompleteOptionContent, children: children }), selected && (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "checkmark" })] })) : optionRenderer ? (optionRenderer({ label, value, enabled }, selectedValue, false)) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: AutoComplete_module_scss_1.default.autoCompleteOptionContent, children: label }), selected && (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "checkmark" })] })) }, id));
|
|
260
257
|
}
|
|
@@ -12,7 +12,7 @@ exports.BookmarkMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
12
12
|
"component has an \`id\` that you can use in links to navigate (scroll to) the bookmark's location.",
|
|
13
13
|
opaque: true,
|
|
14
14
|
props: {
|
|
15
|
-
|
|
15
|
+
id: {
|
|
16
16
|
description: "The unique identifier of the bookmark. You can use this identifier in links " +
|
|
17
17
|
"to navigate to this component's location. If this identifier is not set, you cannot " +
|
|
18
18
|
"programmatically visit this bookmark.",
|
|
@@ -15,7 +15,7 @@ const Button_1 = require("./Button/Button");
|
|
|
15
15
|
const HelloWorld_1 = require("./HelloWorld/HelloWorld");
|
|
16
16
|
const Heading_1 = require("./Heading/Heading");
|
|
17
17
|
const Text_1 = require("./Text/Text");
|
|
18
|
-
const Fragment_1 = require("
|
|
18
|
+
const Fragment_1 = require("./Fragment/Fragment");
|
|
19
19
|
const Table_1 = require("./Table/Table");
|
|
20
20
|
const StickyBox_1 = require("./StickyBox/StickyBox");
|
|
21
21
|
const Badge_1 = require("./Badge/Badge");
|
|
@@ -53,7 +53,7 @@ const Footer_1 = require("./Footer/Footer");
|
|
|
53
53
|
const NavGroup_1 = require("./NavGroup/NavGroup");
|
|
54
54
|
const Logo_1 = require("./Logo/Logo");
|
|
55
55
|
const RadioGroup_1 = require("./RadioGroup/RadioGroup");
|
|
56
|
-
const Slot_1 = require("
|
|
56
|
+
const Slot_1 = require("./Slot/Slot");
|
|
57
57
|
const FileInput_1 = require("./FileInput/FileInput");
|
|
58
58
|
const Spinner_1 = require("./Spinner/Spinner");
|
|
59
59
|
const Markdown_1 = require("./Markdown/Markdown");
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.fragmentComponentRenderer = exports.FragmentMd = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const renderers_1 = require("
|
|
7
|
-
const metadata_helpers_1 = require("../
|
|
6
|
+
const renderers_1 = require("../../components-core/renderers");
|
|
7
|
+
const metadata_helpers_1 = require("../metadata-helpers");
|
|
8
8
|
const COMP = "Fragment";
|
|
9
9
|
exports.FragmentMd = (0, metadata_helpers_1.createMetadata)({
|
|
10
10
|
status: "stable",
|
|
@@ -17,26 +17,26 @@ exports.OptionMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
17
17
|
props: {
|
|
18
18
|
label: (0, metadata_helpers_1.d)(`This property defines the text to display for the option. If \`label\` is not defined, ` +
|
|
19
19
|
`\`Option\` will use the \`value\` as the label.`),
|
|
20
|
-
value: (0, metadata_helpers_1.d)("This property defines the value of the option. If
|
|
21
|
-
"
|
|
20
|
+
value: (0, metadata_helpers_1.d)("This property defines the value of the option. If `value` is not defined, " +
|
|
21
|
+
"`Option` will use the `label` as the value. If neither is defined, " +
|
|
22
22
|
"the option is not displayed."),
|
|
23
23
|
enabled: {
|
|
24
24
|
description: "This boolean property indicates whether the option is enabled or disabled.",
|
|
25
25
|
valueType: "boolean",
|
|
26
26
|
defaultValue: OptionNative_1.defaultProps.enabled,
|
|
27
27
|
},
|
|
28
|
-
optionTemplate: (0, metadata_helpers_1.d)("This property is used to define a custom option template"),
|
|
29
28
|
},
|
|
30
|
-
childrenAsTemplate: "optionTemplate",
|
|
31
29
|
});
|
|
32
30
|
exports.optionComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.OptionMd, ({ node, extractValue, layoutCss, renderChild, layoutContext }) => {
|
|
33
|
-
|
|
34
|
-
const label = extractValue.asOptionalString(node.props.label)
|
|
35
|
-
const value = extractValue.asOptionalString(node.props.value)
|
|
36
|
-
if (label === undefined) {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
const label = extractValue.asOptionalString(node.props.label);
|
|
33
|
+
const value = extractValue.asOptionalString(node.props.value);
|
|
34
|
+
if (label === undefined && value === undefined) {
|
|
37
35
|
return null;
|
|
38
36
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
const hasTextNodeChild = ((_a = node.children) === null || _a === void 0 ? void 0 : _a.length) === 1 && (node.children[0].type === "TextNode" || node.children[0].type === "TextNodeCData");
|
|
38
|
+
const textNodeChild = hasTextNodeChild ? renderChild(node.children) : undefined;
|
|
39
|
+
return ((0, jsx_runtime_1.jsx)(OptionNative_1.OptionNative, { label: label || textNodeChild, value: value || label, enabled: extractValue.asOptionalBoolean(node.props.enabled), style: layoutCss, optionRenderer: ((_b = node.children) === null || _b === void 0 ? void 0 : _b.length) > 0
|
|
40
|
+
? !hasTextNodeChild ? (contextVars) => ((0, jsx_runtime_1.jsx)(container_helpers_1.MemoizedItem, { node: node.children, renderChild: renderChild, contextVars: contextVars, layoutContext: layoutContext })) : undefined
|
|
41
|
+
: undefined, children: !hasTextNodeChild && renderChild(node.children) }));
|
|
42
42
|
});
|
|
@@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const OptionContext_1 = require("./OptionContext");
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
function HiddenOption(option) {
|
|
8
|
-
const {
|
|
8
|
+
const { label } = option;
|
|
9
9
|
const { onOptionRemove, onOptionAdd } = (0, OptionContext_1.useOption)();
|
|
10
10
|
const [node, setNode] = (0, react_1.useState)(null);
|
|
11
11
|
const opt = (0, react_1.useMemo)(() => {
|
|
@@ -16,5 +16,5 @@ function HiddenOption(option) {
|
|
|
16
16
|
onOptionAdd(opt);
|
|
17
17
|
return () => onOptionRemove(opt);
|
|
18
18
|
}, [opt, onOptionAdd, onOptionRemove]);
|
|
19
|
-
return ((0, jsx_runtime_1.jsx)("div", { ref: (el) => setNode(el), style: { display: "none" }, children:
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: (el) => setNode(el), style: { display: "none" }, children: option.children }));
|
|
20
20
|
}
|
|
@@ -111,9 +111,11 @@ exports.SelectMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
111
111
|
exports.selectComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.SelectMd, ({ node, state, updateState, extractValue, renderChild, lookupEventHandler, layoutCss, registerComponentApi, }) => {
|
|
112
112
|
const multiSelect = extractValue.asOptionalBoolean(node.props.multiSelect);
|
|
113
113
|
const searchable = extractValue.asOptionalBoolean(node.props.searchable);
|
|
114
|
-
return ((0, jsx_runtime_1.jsx)(SelectNative_1.Select, { multiSelect: multiSelect, style: layoutCss, inProgress: extractValue.asOptionalBoolean(node.props.inProgress), inProgressNotificationMessage: extractValue.asOptionalString(node.props.inProgressNotificationMessage), readOnly: extractValue.asOptionalBoolean(node.props.readOnly), updateState: updateState, searchable: searchable, initialValue: extractValue(node.props.initialValue), value: state === null || state === void 0 ? void 0 : state.value, autoFocus: extractValue.asOptionalBoolean(node.props.autoFocus), enabled: extractValue.asOptionalBoolean(node.props.enabled), placeholder: extractValue.asOptionalString(node.props.placeholder), validationStatus: extractValue(node.props.validationStatus), onDidChange: lookupEventHandler("didChange"), onFocus: lookupEventHandler("gotFocus"), onBlur: lookupEventHandler("lostFocus"), registerComponentApi: registerComponentApi, emptyListTemplate: renderChild(node.props.emptyListTemplate), dropdownHeight: extractValue(node.props.dropdownHeight), label: extractValue(node.props.label), labelPosition: extractValue(node.props.labelPosition), labelWidth: extractValue(node.props.labelWidth), labelBreak: extractValue.asOptionalBoolean(node.props.labelBreak), required: extractValue.asOptionalBoolean(node.props.required),
|
|
115
|
-
? (item) => {
|
|
116
|
-
return ((0, jsx_runtime_1.jsx)(container_helpers_1.MemoizedItem, {
|
|
114
|
+
return ((0, jsx_runtime_1.jsx)(SelectNative_1.Select, { multiSelect: multiSelect, style: layoutCss, inProgress: extractValue.asOptionalBoolean(node.props.inProgress), inProgressNotificationMessage: extractValue.asOptionalString(node.props.inProgressNotificationMessage), readOnly: extractValue.asOptionalBoolean(node.props.readOnly), updateState: updateState, searchable: searchable, initialValue: extractValue(node.props.initialValue), value: state === null || state === void 0 ? void 0 : state.value, autoFocus: extractValue.asOptionalBoolean(node.props.autoFocus), enabled: extractValue.asOptionalBoolean(node.props.enabled), placeholder: extractValue.asOptionalString(node.props.placeholder), validationStatus: extractValue(node.props.validationStatus), onDidChange: lookupEventHandler("didChange"), onFocus: lookupEventHandler("gotFocus"), onBlur: lookupEventHandler("lostFocus"), registerComponentApi: registerComponentApi, emptyListTemplate: renderChild(node.props.emptyListTemplate), dropdownHeight: extractValue(node.props.dropdownHeight), label: extractValue(node.props.label), labelPosition: extractValue(node.props.labelPosition), labelWidth: extractValue(node.props.labelWidth), labelBreak: extractValue.asOptionalBoolean(node.props.labelBreak), required: extractValue.asOptionalBoolean(node.props.required), valueRenderer: node.props.valueTemplate
|
|
115
|
+
? (item, removeItem) => {
|
|
116
|
+
return ((0, jsx_runtime_1.jsx)(container_helpers_1.MemoizedItem, { contextVars: {
|
|
117
|
+
$itemContext: { removeItem },
|
|
118
|
+
}, node: node.props.valueTemplate, item: item, renderChild: renderChild }));
|
|
117
119
|
}
|
|
118
120
|
: undefined, optionRenderer: node.props.optionTemplate
|
|
119
121
|
? (item, val, inTrigger) => {
|
|
@@ -122,11 +124,5 @@ exports.selectComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP,
|
|
|
122
124
|
$inTrigger: inTrigger,
|
|
123
125
|
}, renderChild: (...args) => multiSelect || searchable ? (renderChild(...args)) : ((0, jsx_runtime_1.jsx)(react_select_1.SelectItemText, { children: renderChild(...args) })) }));
|
|
124
126
|
}
|
|
125
|
-
: undefined, valueRenderer: node.props.valueTemplate
|
|
126
|
-
? (item, removeItem) => {
|
|
127
|
-
return ((0, jsx_runtime_1.jsx)(container_helpers_1.MemoizedItem, { contextVars: {
|
|
128
|
-
$itemContext: { removeItem },
|
|
129
|
-
}, node: node.props.valueTemplate, item: item, renderChild: renderChild }));
|
|
130
|
-
}
|
|
131
127
|
: undefined, children: renderChild(node.children) }));
|
|
132
128
|
});
|
|
@@ -71,32 +71,60 @@ exports.defaultProps = {
|
|
|
71
71
|
};
|
|
72
72
|
const SimpleSelect = (0, react_1.forwardRef)(function SimpleSelect(props, forwardedRef) {
|
|
73
73
|
const { root } = (0, ThemeContext_1.useTheme)();
|
|
74
|
-
const { enabled, onBlur, autoFocus, onValueChange, validationStatus, value, height, style, placeholder, id, triggerRef, onFocus,
|
|
74
|
+
const { enabled, onBlur, autoFocus, onValueChange, validationStatus, value, height, style, placeholder, id, triggerRef, onFocus, width, children, readOnly, emptyListNode, } = props;
|
|
75
|
+
// Compose refs for proper forwarding
|
|
75
76
|
const ref = forwardedRef ? (0, react_compose_refs_1.composeRefs)(triggerRef, forwardedRef) : triggerRef;
|
|
77
|
+
const { options } = (0, SelectContext_1.useSelect)();
|
|
78
|
+
// Convert value to string for Radix UI compatibility
|
|
76
79
|
const stringValue = (0, react_1.useMemo)(() => {
|
|
77
|
-
return value != undefined ? value
|
|
80
|
+
return value != undefined ? String(value) : undefined;
|
|
78
81
|
}, [value]);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const onValChange = (0, react_1.useCallback)((val) => {
|
|
83
|
-
var _a;
|
|
84
|
-
if (readOnly) {
|
|
82
|
+
// Handle value changes with proper type conversion
|
|
83
|
+
const handleValueChange = (0, react_1.useCallback)((val) => {
|
|
84
|
+
if (readOnly)
|
|
85
85
|
return;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
onValueChange(val);
|
|
87
|
+
}, [onValueChange, readOnly]);
|
|
88
|
+
// Generate trigger class names based on validation status
|
|
89
|
+
const triggerClassName = (0, classnames_1.default)(Select_module_scss_1.default.selectTrigger, {
|
|
90
|
+
[Select_module_scss_1.default.error]: validationStatus === "error",
|
|
91
|
+
[Select_module_scss_1.default.warning]: validationStatus === "warning",
|
|
92
|
+
[Select_module_scss_1.default.valid]: validationStatus === "valid",
|
|
93
|
+
});
|
|
94
|
+
const optionsArray = (0, react_1.useMemo)(() => Array.from(options), [options]);
|
|
95
|
+
const selectedOption = (0, react_1.useMemo)(() => {
|
|
96
|
+
return optionsArray.find((option) => String(option.value) === String(value));
|
|
97
|
+
}, [optionsArray, value]);
|
|
98
|
+
return ((0, jsx_runtime_1.jsxs)(react_select_1.Root, { value: stringValue, onValueChange: handleValueChange, children: [(0, jsx_runtime_1.jsxs)(react_select_1.Trigger, { id: id, "aria-haspopup": "listbox", style: style, onFocus: onFocus, onBlur: onBlur, disabled: !enabled, className: (0, classnames_1.default)(Select_module_scss_1.default.selectTrigger, {
|
|
91
99
|
[Select_module_scss_1.default.error]: validationStatus === "error",
|
|
92
100
|
[Select_module_scss_1.default.warning]: validationStatus === "warning",
|
|
93
101
|
[Select_module_scss_1.default.valid]: validationStatus === "valid",
|
|
94
|
-
}),
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
102
|
+
}), onClick: (event) => {
|
|
103
|
+
// Prevent event propagation to parent elements (e.g., DropdownMenu)
|
|
104
|
+
// This ensures that clicking the Select trigger doesn't close the containing DropdownMenu
|
|
105
|
+
event.stopPropagation();
|
|
106
|
+
}, ref: ref, autoFocus: autoFocus, children: [(0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(Select_module_scss_1.default.selectValue, {
|
|
107
|
+
[Select_module_scss_1.default.selectValue]: value !== undefined,
|
|
108
|
+
[Select_module_scss_1.default.placeholder]: value === undefined,
|
|
109
|
+
}), children: selectedOption ? selectedOption.label : readOnly ? "" : placeholder }), (0, jsx_runtime_1.jsx)(react_select_1.Icon, { asChild: true, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" }) })] }), (0, jsx_runtime_1.jsx)(react_select_1.Portal, { container: root, children: (0, jsx_runtime_1.jsxs)(react_select_1.Content, { className: Select_module_scss_1.default.selectContent, position: "popper", style: { maxHeight: height, minWidth: width }, children: [(0, jsx_runtime_1.jsx)(react_select_1.ScrollUpButton, { className: Select_module_scss_1.default.selectScrollUpButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevronup" }) }), (0, jsx_runtime_1.jsxs)(react_select_1.SelectViewport, { className: Select_module_scss_1.default.selectViewport, role: "listbox", children: [children, optionsArray.length === 0 && emptyListNode] }), (0, jsx_runtime_1.jsx)(react_select_1.ScrollDownButton, { className: Select_module_scss_1.default.selectScrollDownButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" }) })] }) })] }));
|
|
98
110
|
});
|
|
99
|
-
exports.Select = (0, react_1.forwardRef)(function Select({
|
|
111
|
+
exports.Select = (0, react_1.forwardRef)(function Select({
|
|
112
|
+
// Basic props
|
|
113
|
+
id, initialValue, value, enabled = exports.defaultProps.enabled, placeholder = exports.defaultProps.placeholder, autoFocus = exports.defaultProps.autoFocus, readOnly = false, required = exports.defaultProps.required,
|
|
114
|
+
// Styling
|
|
115
|
+
style, dropdownHeight,
|
|
116
|
+
// Validation
|
|
117
|
+
validationStatus = exports.defaultProps.validationStatus,
|
|
118
|
+
// Event handlers
|
|
119
|
+
onDidChange = constants_1.noop, onFocus = constants_1.noop, onBlur = constants_1.noop,
|
|
120
|
+
// Multi-select and search
|
|
121
|
+
searchable = exports.defaultProps.searchable, multiSelect = exports.defaultProps.multiSelect, emptyListTemplate, valueRenderer, optionRenderer,
|
|
122
|
+
// Progress state
|
|
123
|
+
inProgress = exports.defaultProps.inProgress, inProgressNotificationMessage = exports.defaultProps.inProgressNotificationMessage,
|
|
124
|
+
// Label configuration
|
|
125
|
+
label, labelPosition, labelWidth, labelBreak = exports.defaultProps.labelBreak,
|
|
126
|
+
// Internal
|
|
127
|
+
updateState = constants_1.noop, registerComponentApi, children, }, ref) {
|
|
100
128
|
var _a;
|
|
101
129
|
const [referenceElement, setReferenceElement] = (0, react_1.useState)(null);
|
|
102
130
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
@@ -131,11 +159,11 @@ exports.Select = (0, react_1.forwardRef)(function Select({ id, initialValue, val
|
|
|
131
159
|
const toggleOption = (0, react_1.useCallback)((selectedValue) => {
|
|
132
160
|
const newSelectedValue = multiSelect
|
|
133
161
|
? Array.isArray(value)
|
|
134
|
-
? value.includes(selectedValue)
|
|
135
|
-
? value.filter((v) => v !== selectedValue)
|
|
162
|
+
? value.map((v) => String(v)).includes(String(selectedValue))
|
|
163
|
+
? value.filter((v) => String(v) !== String(selectedValue))
|
|
136
164
|
: [...value, selectedValue]
|
|
137
165
|
: [selectedValue]
|
|
138
|
-
: selectedValue === value
|
|
166
|
+
: String(selectedValue) === String(value)
|
|
139
167
|
? null
|
|
140
168
|
: selectedValue;
|
|
141
169
|
updateState({ value: newSelectedValue });
|
|
@@ -192,12 +220,17 @@ exports.Select = (0, react_1.forwardRef)(function Select({ id, initialValue, val
|
|
|
192
220
|
const selectContextValue = (0, react_1.useMemo)(() => ({
|
|
193
221
|
multiSelect,
|
|
194
222
|
value,
|
|
195
|
-
optionLabelRenderer,
|
|
196
|
-
optionRenderer,
|
|
197
223
|
onChange: toggleOption,
|
|
198
224
|
setOpen,
|
|
199
|
-
|
|
200
|
-
|
|
225
|
+
options,
|
|
226
|
+
optionRenderer,
|
|
227
|
+
}), [multiSelect, toggleOption, value, options]);
|
|
228
|
+
return ((0, jsx_runtime_1.jsx)(SelectContext_1.SelectContext.Provider, { value: selectContextValue, children: (0, jsx_runtime_1.jsx)(OptionContext_1.OptionContext.Provider, { value: optionContextValue, children: (0, jsx_runtime_1.jsx)(ItemWithLabel_1.ItemWithLabel, { ref: ref, id: inputId, labelPosition: labelPosition, label: label, labelWidth: labelWidth, labelBreak: labelBreak, required: required, enabled: enabled, onFocus: onFocus, onBlur: onBlur, style: style, children: searchable || multiSelect ? ((0, jsx_runtime_1.jsxs)(OptionTypeProvider_1.default, { Component: HiddenOption_1.HiddenOption, children: [(0, jsx_runtime_1.jsxs)(react_popover_1.Popover, { open: open, onOpenChange: setOpen, modal: false, children: [(0, jsx_runtime_1.jsxs)(react_popover_1.PopoverTrigger, { id: inputId, "aria-haspopup": "listbox", style: style, ref: setReferenceElement, onFocus: onFocus, onBlur: onBlur, disabled: !enabled, "aria-expanded": open, onClick: (event) => {
|
|
229
|
+
// Prevent event propagation to parent elements (e.g., DropdownMenu)
|
|
230
|
+
// This ensures that clicking the Select trigger doesn't close the containing DropdownMenu
|
|
231
|
+
event.stopPropagation();
|
|
232
|
+
setOpen((prev) => !prev);
|
|
233
|
+
}, className: (0, classnames_1.default)(Select_module_scss_1.default.selectTrigger, Select_module_scss_1.default[validationStatus], {
|
|
201
234
|
[Select_module_scss_1.default.disabled]: !enabled,
|
|
202
235
|
[Select_module_scss_1.default.multi]: multiSelect,
|
|
203
236
|
}), autoFocus: autoFocus, children: [multiSelect ? (Array.isArray(value) && value.length > 0 ? ((0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.badgeListContainer, children: (0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.badgeList, children: value.map((v) => {
|
|
@@ -211,7 +244,7 @@ exports.Select = (0, react_1.forwardRef)(function Select({ id, initialValue, val
|
|
|
211
244
|
}) }) })) : ((0, jsx_runtime_1.jsx)("span", { placeholder: placeholder, className: Select_module_scss_1.default.placeholder, children: placeholder }))) : value !== undefined && value !== null ? ((0, jsx_runtime_1.jsx)("div", { children: (_a = Array.from(options).find((o) => o.value === value)) === null || _a === void 0 ? void 0 : _a.label })) : ((0, jsx_runtime_1.jsx)("span", { "aria-placeholder": placeholder, className: Select_module_scss_1.default.placeholder, children: placeholder || "" })), (0, jsx_runtime_1.jsxs)("div", { className: Select_module_scss_1.default.actions, children: [multiSelect && Array.isArray(value) && value.length > 0 && ((0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "close", onClick: (event) => {
|
|
212
245
|
event.stopPropagation();
|
|
213
246
|
clearValue();
|
|
214
|
-
} })), (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" })] })] }), open && ((0, jsx_runtime_1.jsx)(
|
|
247
|
+
} })), (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" })] })] }), open && ((0, jsx_runtime_1.jsx)(react_popover_1.Portal, { container: root, children: (0, jsx_runtime_1.jsx)(react_focus_scope_1.FocusScope, { asChild: true, loop: true, trapped: true, children: (0, jsx_runtime_1.jsx)(react_popover_1.PopoverContent, { style: { minWidth: width, height: dropdownHeight }, className: Select_module_scss_1.default.selectContent, children: (0, jsx_runtime_1.jsxs)(cmdk_1.Command, { className: Select_module_scss_1.default.command, shouldFilter: searchable, filter: (_, search, keywords) => {
|
|
215
248
|
const lowSearch = search.toLowerCase();
|
|
216
249
|
for (const kw of keywords) {
|
|
217
250
|
if (kw.toLowerCase().includes(lowSearch))
|
|
@@ -220,16 +253,16 @@ exports.Select = (0, react_1.forwardRef)(function Select({ id, initialValue, val
|
|
|
220
253
|
return 0;
|
|
221
254
|
}, children: [searchable ? ((0, jsx_runtime_1.jsxs)("div", { className: Select_module_scss_1.default.commandInputContainer, children: [(0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "search" }), (0, jsx_runtime_1.jsx)(cmdk_1.CommandInput, { className: (0, classnames_1.default)(Select_module_scss_1.default.commandInput), placeholder: "Search..." })] })) : (
|
|
222
255
|
// https://github.com/pacocoursey/cmdk/issues/322#issuecomment-2444703817
|
|
223
|
-
(0, jsx_runtime_1.jsx)("button", { autoFocus: true, "aria-hidden": "true", className: Select_module_scss_1.default.srOnly })), (0, jsx_runtime_1.jsxs)(cmdk_1.CommandList, { className: Select_module_scss_1.default.commandList, children: [inProgress && ((0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.loading, children: inProgressNotificationMessage })), Array.from(options).map(({ value, label, enabled, keywords }) => ((0, jsx_runtime_1.jsx)(exports.ComboboxOption, { readOnly: readOnly, value: value, label: label, enabled: enabled, keywords: keywords }, value))), !inProgress && (0, jsx_runtime_1.jsx)(cmdk_1.CommandEmpty, { children: emptyListNode })] })] }) }) }) }))] })) : ((0, jsx_runtime_1.jsx)(SimpleSelect, { readOnly: !!readOnly, ref: ref, value: value,
|
|
256
|
+
(0, jsx_runtime_1.jsx)("button", { autoFocus: true, "aria-hidden": "true", className: Select_module_scss_1.default.srOnly })), (0, jsx_runtime_1.jsxs)(cmdk_1.CommandList, { className: Select_module_scss_1.default.commandList, children: [inProgress && ((0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.loading, children: inProgressNotificationMessage })), Array.from(options).map(({ value, label, enabled, keywords }) => ((0, jsx_runtime_1.jsx)(exports.ComboboxOption, { readOnly: readOnly, value: value, label: label, enabled: enabled, keywords: keywords }, value))), !inProgress && (0, jsx_runtime_1.jsx)(cmdk_1.CommandEmpty, { children: emptyListNode })] })] }) }) }) }))] }), children] })) : ((0, jsx_runtime_1.jsx)(OptionTypeProvider_1.default, { Component: SelectOption, children: (0, jsx_runtime_1.jsx)(SimpleSelect, { readOnly: !!readOnly, ref: ref, value: value, onValueChange: toggleOption, id: inputId, style: style, onFocus: onFocus, onBlur: onBlur, enabled: enabled, validationStatus: validationStatus, triggerRef: setReferenceElement, autoFocus: autoFocus, placeholder: placeholder, height: dropdownHeight, width: width, emptyListNode: emptyListNode, children: children }, isInForm ? (value ? `status-${value}` : "status-initial") : undefined) })) }) }) }));
|
|
224
257
|
});
|
|
225
258
|
exports.ComboboxOption = (0, react_1.forwardRef)(function Combobox(option, forwardedRef) {
|
|
226
259
|
const id = (0, react_1.useId)();
|
|
227
|
-
const { label, value, enabled = true, keywords, readOnly } = option;
|
|
228
|
-
const { value: selectedValue, onChange, multiSelect,
|
|
260
|
+
const { label, value, enabled = true, keywords, readOnly, children } = option;
|
|
261
|
+
const { value: selectedValue, onChange, multiSelect, setOpen, optionRenderer } = (0, SelectContext_1.useSelect)();
|
|
229
262
|
const selected = (0, react_1.useMemo)(() => {
|
|
230
263
|
return Array.isArray(selectedValue) && multiSelect
|
|
231
|
-
? selectedValue.includes(value)
|
|
232
|
-
: selectedValue === value;
|
|
264
|
+
? selectedValue.map((v) => String(v)).includes(value)
|
|
265
|
+
: String(selectedValue) === String(value);
|
|
233
266
|
}, [selectedValue, value, multiSelect]);
|
|
234
267
|
return ((0, jsx_runtime_1.jsx)(cmdk_1.CommandItem, { id: id, ref: forwardedRef, disabled: !enabled, value: value, className: Select_module_scss_1.default.multiComboboxOption, onSelect: () => {
|
|
235
268
|
if (readOnly) {
|
|
@@ -237,21 +270,38 @@ exports.ComboboxOption = (0, react_1.forwardRef)(function Combobox(option, forwa
|
|
|
237
270
|
return;
|
|
238
271
|
}
|
|
239
272
|
onChange(value);
|
|
240
|
-
},
|
|
273
|
+
}, onClick: (event) => {
|
|
274
|
+
event.stopPropagation();
|
|
275
|
+
}, "data-state": selected ? "checked" : undefined, keywords: [...keywords, label], children: (0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.multiComboboxOptionContent, children: optionRenderer ? (optionRenderer({ label, value, enabled, keywords }, selectedValue, false)) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [children || label, selected && (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "checkmark" })] })) }) }, id));
|
|
241
276
|
});
|
|
242
277
|
const SelectOption = react_1.default.forwardRef((option, ref) => {
|
|
243
|
-
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
278
|
+
var _a;
|
|
279
|
+
const visibleContentRef = (0, react_1.useRef)(null);
|
|
280
|
+
const { value, label, enabled = true, children } = option;
|
|
281
|
+
const { value: selectedValue, optionRenderer } = (0, SelectContext_1.useSelect)();
|
|
282
|
+
const { onOptionRemove, onOptionAdd } = (0, OptionContext_1.useOption)();
|
|
283
|
+
const opt = (0, react_1.useMemo)(() => {
|
|
284
|
+
var _a, _b, _c, _d;
|
|
285
|
+
return Object.assign(Object.assign({}, option), { label: (_b = label !== null && label !== void 0 ? label : (_a = visibleContentRef.current) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : "", keywords: [(_d = label !== null && label !== void 0 ? label : (_c = visibleContentRef.current) === null || _c === void 0 ? void 0 : _c.textContent) !== null && _d !== void 0 ? _d : ""] });
|
|
286
|
+
}, [option, label, visibleContentRef.current]);
|
|
287
|
+
(0, react_1.useEffect)(() => {
|
|
288
|
+
onOptionAdd(opt);
|
|
289
|
+
return () => onOptionRemove(opt);
|
|
290
|
+
}, [opt, onOptionAdd, onOptionRemove]);
|
|
291
|
+
return ((0, jsx_runtime_1.jsxs)(react_select_1.Item, { ref: ref, className: Select_module_scss_1.default.selectItem, value: value + "", textValue: label || ((_a = visibleContentRef.current) === null || _a === void 0 ? void 0 : _a.textContent), disabled: !enabled, onClick: (event) => {
|
|
292
|
+
event.stopPropagation();
|
|
293
|
+
}, onMouseEnter: (event) => {
|
|
294
|
+
// Ensure hover state is applied even in DropdownMenu context
|
|
295
|
+
const target = event.currentTarget;
|
|
296
|
+
target.setAttribute("data-highlighted", "");
|
|
297
|
+
}, onMouseLeave: (event) => {
|
|
298
|
+
// Remove hover state when mouse leaves
|
|
299
|
+
const target = event.currentTarget;
|
|
300
|
+
target.removeAttribute("data-highlighted");
|
|
301
|
+
}, "data-state": selectedValue === value && "checked", children: [(0, jsx_runtime_1.jsx)("span", { style: { display: "none" }, children: (0, jsx_runtime_1.jsx)(react_select_1.ItemText, { children: label }) }), children ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.selectItemContent, ref: visibleContentRef, children: children }), selectedValue === value && ((0, jsx_runtime_1.jsx)(react_select_1.ItemIndicator, { className: Select_module_scss_1.default.selectItemIndicator, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "checkmark" }) }))] })) : optionRenderer ? ((0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.selectItemContent, ref: visibleContentRef, children: optionRenderer({
|
|
302
|
+
label,
|
|
303
|
+
value,
|
|
304
|
+
enabled,
|
|
305
|
+
}, selectedValue, false) })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.selectItemContent, ref: visibleContentRef, children: label }), selectedValue === value && ((0, jsx_runtime_1.jsx)(react_select_1.ItemIndicator, { className: Select_module_scss_1.default.selectItemIndicator, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "checkmark" }) }))] }))] }));
|
|
250
306
|
});
|
|
251
307
|
SelectOption.displayName = "SelectOption";
|
|
252
|
-
function renderOptionsOrDefault(options, default_) {
|
|
253
|
-
if (options.size === 0) {
|
|
254
|
-
return default_;
|
|
255
|
-
}
|
|
256
|
-
return Array.from(options).map((option) => ((0, jsx_runtime_1.jsx)(SelectOption, { value: option.value, label: option.label, enabled: option.enabled }, option.value)));
|
|
257
|
-
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SlotHolder = exports.SlotMd = void 0;
|
|
4
|
-
const metadata_helpers_1 = require("../
|
|
5
|
-
const renderers_1 = require("
|
|
4
|
+
const metadata_helpers_1 = require("../metadata-helpers");
|
|
5
|
+
const renderers_1 = require("../../components-core/renderers");
|
|
6
6
|
const COMP = "Slot";
|
|
7
7
|
exports.SlotMd = (0, metadata_helpers_1.createMetadata)({
|
|
8
8
|
status: "experimental",
|
|
@@ -29,3 +29,4 @@ exports.SlotItem = (0, react_1.memo)(({ node, renderChild, layoutContext, slotPr
|
|
|
29
29
|
// --- Render the slot content
|
|
30
30
|
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: renderChild(nodeWithItem, layoutContext) });
|
|
31
31
|
});
|
|
32
|
+
exports.SlotItem.displayName = "SlotItem";
|
|
@@ -9,7 +9,7 @@ const react_1 = require("react");
|
|
|
9
9
|
const Spinner_module_scss_1 = __importDefault(require("./Spinner.module.scss"));
|
|
10
10
|
exports.defaultProps = {
|
|
11
11
|
delay: 400,
|
|
12
|
-
fullScreen: false
|
|
12
|
+
fullScreen: false,
|
|
13
13
|
};
|
|
14
14
|
// source https://loading.io/css/
|
|
15
15
|
exports.Spinner = (0, react_1.forwardRef)(function Spinner({ delay = exports.defaultProps.delay, fullScreen = exports.defaultProps.fullScreen, style }, forwardedRef) {
|
|
@@ -22,14 +22,13 @@ exports.Spinner = (0, react_1.forwardRef)(function Spinner({ delay = exports.def
|
|
|
22
22
|
clearTimeout(timeout);
|
|
23
23
|
};
|
|
24
24
|
}, [delay]);
|
|
25
|
-
const spinner = ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { className: Spinner_module_scss_1.default["lds-ring"], style: style, ref: forwardedRef, children: [(0, jsx_runtime_1.jsx)("div", {}), (0, jsx_runtime_1.jsx)("div", {}), (0, jsx_runtime_1.jsx)("div", {}), (0, jsx_runtime_1.jsx)("div", {})] }) }));
|
|
26
25
|
if (!pastDelay) {
|
|
27
26
|
return null;
|
|
28
27
|
}
|
|
29
28
|
else {
|
|
30
29
|
if (fullScreen) {
|
|
31
|
-
return (0, jsx_runtime_1.jsx)("div", { className: Spinner_module_scss_1.default.fullScreenSpinnerWrapper, children:
|
|
30
|
+
return ((0, jsx_runtime_1.jsx)("div", { role: "status", "aria-label": "Loading", className: Spinner_module_scss_1.default.fullScreenSpinnerWrapper, children: (0, jsx_runtime_1.jsxs)("div", { className: Spinner_module_scss_1.default["lds-ring"], style: style, ref: forwardedRef, children: [(0, jsx_runtime_1.jsx)("div", {}), (0, jsx_runtime_1.jsx)("div", {}), (0, jsx_runtime_1.jsx)("div", {}), (0, jsx_runtime_1.jsx)("div", {})] }) }));
|
|
32
31
|
}
|
|
33
|
-
return
|
|
32
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: Spinner_module_scss_1.default["lds-ring"], role: "status", "aria-label": "Loading", style: style, ref: forwardedRef, children: [(0, jsx_runtime_1.jsx)("div", {}), (0, jsx_runtime_1.jsx)("div", {}), (0, jsx_runtime_1.jsx)("div", {}), (0, jsx_runtime_1.jsx)("div", {})] }));
|
|
34
33
|
}
|
|
35
34
|
});
|
|
@@ -5,6 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const renderers_1 = require("../../components-core/renderers");
|
|
6
6
|
const TabItemNative_1 = require("./TabItemNative");
|
|
7
7
|
const metadata_helpers_1 = require("../metadata-helpers");
|
|
8
|
+
const container_helpers_1 = require("../container-helpers");
|
|
8
9
|
const COMP = "TabItem";
|
|
9
10
|
exports.TabItemMd = (0, metadata_helpers_1.createMetadata)({
|
|
10
11
|
status: "stable",
|
|
@@ -15,9 +16,19 @@ exports.TabItemMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
15
16
|
docFolder: "Tabs",
|
|
16
17
|
props: {
|
|
17
18
|
label: (0, metadata_helpers_1.dLabel)(),
|
|
19
|
+
labelTemplate: (0, metadata_helpers_1.dComponent)("This property allows the customization of the TabItem label."),
|
|
20
|
+
},
|
|
21
|
+
contextVars: {
|
|
22
|
+
$item: (0, metadata_helpers_1.d)("This context value represents an item when you define a tab item template."),
|
|
18
23
|
},
|
|
19
24
|
});
|
|
20
25
|
exports.tabItemComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.TabItemMd, (rendererContext) => {
|
|
21
26
|
const { node, renderChild, extractValue } = rendererContext;
|
|
22
|
-
return ((0, jsx_runtime_1.jsx)(TabItemNative_1.TabItemComponent, { label: extractValue(node.props.label),
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)(TabItemNative_1.TabItemComponent, { label: extractValue(node.props.label), labelRenderer: node.props.labelTemplate
|
|
28
|
+
? (item) => {
|
|
29
|
+
return ((0, jsx_runtime_1.jsx)(container_helpers_1.MemoizedItem, { node: node.props.labelTemplate, item: item, context: {
|
|
30
|
+
$item: item,
|
|
31
|
+
}, renderChild: renderChild }));
|
|
32
|
+
}
|
|
33
|
+
: undefined, children: renderChild(node.children) }));
|
|
23
34
|
});
|
|
@@ -8,16 +8,17 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const react_tabs_1 = require("@radix-ui/react-tabs");
|
|
10
10
|
const Tabs_module_scss_1 = __importDefault(require("../Tabs/Tabs.module.scss"));
|
|
11
|
-
const TabContext_1 = require("
|
|
12
|
-
exports.TabItemComponent = (0, react_1.forwardRef)(function TabItemComponent({ children, label, style }, forwardedRef) {
|
|
11
|
+
const TabContext_1 = require("./TabContext");
|
|
12
|
+
exports.TabItemComponent = (0, react_1.forwardRef)(function TabItemComponent({ children, label, labelRenderer, style }, forwardedRef) {
|
|
13
13
|
const id = (0, react_1.useId)();
|
|
14
14
|
const { register, unRegister, activeTabId } = (0, TabContext_1.useTabContext)();
|
|
15
15
|
(0, react_1.useEffect)(() => {
|
|
16
16
|
register({
|
|
17
17
|
label,
|
|
18
|
+
labelRenderer,
|
|
18
19
|
id,
|
|
19
20
|
});
|
|
20
|
-
}, [id, label, register]);
|
|
21
|
+
}, [id, label, labelRenderer, register]);
|
|
21
22
|
(0, react_1.useEffect)(() => {
|
|
22
23
|
return () => {
|
|
23
24
|
unRegister(id);
|
|
@@ -53,7 +53,7 @@ exports.TabsMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
53
53
|
});
|
|
54
54
|
exports.tabsComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.TabsMd, ({ extractValue, node, renderChild, layoutCss, registerComponentApi }) => {
|
|
55
55
|
var _a, _b, _c;
|
|
56
|
-
return ((0, jsx_runtime_1.jsx)(TabsNative_1.Tabs, { style: layoutCss, tabRenderer: !!((_a = node === null || node === void 0 ? void 0 : node.props) === null || _a === void 0 ? void 0 : _a.tabTemplate)
|
|
56
|
+
return ((0, jsx_runtime_1.jsx)(TabsNative_1.Tabs, { id: node === null || node === void 0 ? void 0 : node.uid, style: layoutCss, tabRenderer: !!((_a = node === null || node === void 0 ? void 0 : node.props) === null || _a === void 0 ? void 0 : _a.tabTemplate)
|
|
57
57
|
? (item) => ((0, jsx_runtime_1.jsx)(container_helpers_1.MemoizedItem, { node: node.props.tabTemplate, item: item, renderChild: renderChild }))
|
|
58
58
|
: undefined, activeTab: extractValue((_b = node.props) === null || _b === void 0 ? void 0 : _b.activeTab), orientation: extractValue((_c = node.props) === null || _c === void 0 ? void 0 : _c.orientation), registerComponentApi: registerComponentApi, children: renderChild(node.children) }));
|
|
59
59
|
});
|