@parallelworks/ui 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/editor.worker-CuBRIwi-.js +14776 -0
- package/dist/assets/json.worker-8ytS02vz.js +22161 -0
- package/dist/assets/yaml.worker-DJC-VUcv.js +48367 -0
- package/dist/chunks/CodePreviewEditor-CSPRILMp.js +61 -0
- package/dist/chunks/Indicator-hBSIxOPK.js +39 -0
- package/dist/chunks/Loader-DQiZ75fa.js +25 -0
- package/dist/chunks/Markdown-C5Re2ezs.js +101 -0
- package/dist/chunks/MarkdownImpl-Bq4QhrtA.js +33 -0
- package/dist/chunks/Modal-sOUEwebV.js +121 -0
- package/dist/chunks/Monaco-CC4ak1JG.js +717 -0
- package/dist/chunks/Provider-DvVvScTQ.js +391 -0
- package/dist/chunks/StatusBadge-DXp4zkSd.js +46 -0
- package/dist/chunks/SwitchToggle-2uRw8ZeJ.js +725 -0
- package/dist/chunks/SwitchToggleSmall-FcsaYSTs.js +14 -0
- package/dist/chunks/Table-C5z6qWjM.js +91 -0
- package/dist/chunks/Tooltip-WgbiC_nd.js +71 -0
- package/dist/chunks/editor-D55tumuZ.js +372 -0
- package/dist/chunks/lib-DTgL8klR.js +191 -0
- package/dist/chunks/list-7PyDF1tz.js +465 -0
- package/dist/components/CollapsiblePanel.d.ts +27 -0
- package/dist/components/CopyToClipboard.d.ts +17 -0
- package/dist/components/Dropdown.d.ts +24 -0
- package/dist/components/Indicator.d.ts +4 -0
- package/dist/components/Listbox.d.ts +18 -0
- package/dist/components/Markdown.d.ts +7 -0
- package/dist/components/MarkdownImpl.d.ts +2 -0
- package/dist/components/MultiSelect.d.ts +19 -0
- package/dist/components/Overview.d.ts +12 -0
- package/dist/components/Provider.d.ts +438 -0
- package/dist/components/SectionHeader.d.ts +6 -0
- package/dist/components/SwitchToggle.d.ts +12 -0
- package/dist/components/SwitchToggleSmall.d.ts +6 -0
- package/dist/components/dropdownUtils.d.ts +18 -0
- package/dist/editor/Editor.d.ts +2 -0
- package/dist/editor/EditorField.d.ts +11 -0
- package/dist/editor/FormCodePanel.d.ts +8 -0
- package/dist/editor/Monaco.d.ts +31 -0
- package/dist/editor/index.d.ts +7 -0
- package/dist/editor/index.js +2 -0
- package/dist/editor/themes.d.ts +4 -0
- package/dist/editor/useCssIsDark.d.ts +6 -0
- package/dist/editor/workers.d.ts +6 -0
- package/dist/file-explorer/FileExplorer.d.ts +23 -0
- package/dist/file-explorer/FileExplorerContext.d.ts +17 -0
- package/dist/file-explorer/FilePreview/CodePreviewEditor.d.ts +6 -0
- package/dist/file-explorer/FilePreview/Inline.d.ts +13 -0
- package/dist/file-explorer/FilePreview/StreamedBadge.d.ts +1 -0
- package/dist/file-explorer/FilePreview/Viewer.d.ts +15 -0
- package/dist/file-explorer/FilePreview/index.d.ts +15 -0
- package/dist/file-explorer/FilePreview/parse.d.ts +24 -0
- package/dist/file-explorer/FilePreview/previewCache.d.ts +26 -0
- package/dist/file-explorer/FilePreview/previewType.d.ts +21 -0
- package/dist/file-explorer/FilePreview/readCappedBytes.d.ts +37 -0
- package/dist/file-explorer/FilePreview/useObjectBlobUrl.d.ts +16 -0
- package/dist/file-explorer/FilePreview/useObjectText.d.ts +23 -0
- package/dist/file-explorer/FilePreview/usePresignedUrl.d.ts +12 -0
- package/dist/file-explorer/FileRow.d.ts +35 -0
- package/dist/file-explorer/FileRowsWindow.d.ts +43 -0
- package/dist/file-explorer/FileTable.d.ts +26 -0
- package/dist/file-explorer/FileTableHeaders.d.ts +13 -0
- package/dist/file-explorer/LoadMoreRow.d.ts +15 -0
- package/dist/file-explorer/TreeView.d.ts +28 -0
- package/dist/file-explorer/helpers.d.ts +47 -0
- package/dist/file-explorer/index.d.ts +10 -0
- package/dist/file-explorer/index.js +5646 -0
- package/dist/file-explorer/lib/batch.d.ts +3 -0
- package/dist/file-explorer/lib/errors.d.ts +3 -0
- package/dist/file-explorer/lib/fileExplorer.d.ts +32 -0
- package/dist/file-explorer/lib/paging.d.ts +93 -0
- package/dist/file-explorer/lib/types.d.ts +92 -0
- package/dist/file-explorer/lib/utils.d.ts +37 -0
- package/dist/file-explorer/toasts.d.ts +9 -0
- package/dist/file-explorer/treeRows.d.ts +35 -0
- package/dist/file-explorer/useNearEnd.d.ts +7 -0
- package/dist/form/FieldWrapper.d.ts +10 -0
- package/dist/form/Fields/BooleanField.d.ts +12 -0
- package/dist/form/Fields/BucketReadOnlyField.d.ts +7 -0
- package/dist/form/Fields/CheckboxGroupField.d.ts +18 -0
- package/dist/form/Fields/ColorField.d.ts +8 -0
- package/dist/form/Fields/DropdownField.d.ts +24 -0
- package/dist/form/Fields/DurationField.d.ts +13 -0
- package/dist/form/Fields/LabelField.d.ts +9 -0
- package/dist/form/Fields/MultiDropdownField.d.ts +18 -0
- package/dist/form/Fields/NumberField.d.ts +13 -0
- package/dist/form/Fields/ObjectField.d.ts +8 -0
- package/dist/form/Fields/RadioField.d.ts +9 -0
- package/dist/form/Fields/RangeField.d.ts +11 -0
- package/dist/form/Fields/ResourceOptionIcon.d.ts +11 -0
- package/dist/form/Fields/StepField.d.ts +3 -0
- package/dist/form/Fields/StringField.d.ts +17 -0
- package/dist/form/Fields/TextAreaField.d.ts +8 -0
- package/dist/form/Fields/durationValidity.d.ts +2 -0
- package/dist/form/Form.d.ts +105 -0
- package/dist/form/SpecialTypes/DropdownWrapper.d.ts +14 -0
- package/dist/form/SpecialTypes/FormikCustomDropdown.d.ts +53 -0
- package/dist/form/SpecialTypes/FormikCustomInput.d.ts +17 -0
- package/dist/form/SpecialTypes/FormikMultiSelectDropdown.d.ts +13 -0
- package/dist/form/SpecialTypes/FormikNumericInput.d.ts +9 -0
- package/dist/form/SpecialTypes/index.d.ts +3 -0
- package/dist/form/Wizard/WizardContainer.d.ts +5 -0
- package/dist/form/Wizard/WizardNavigation.d.ts +2 -0
- package/dist/form/Wizard/WizardStepContent.d.ts +8 -0
- package/dist/form/Wizard/WizardStepIndicator.d.ts +2 -0
- package/dist/form/Wizard/types.d.ts +171 -0
- package/dist/form/Wizard/useWizardState.d.ts +28 -0
- package/dist/form/Wizard/utils.d.ts +2 -0
- package/dist/form/fieldRegistry.d.ts +7 -0
- package/dist/form/index.d.ts +16 -0
- package/dist/form/index.js +2319 -0
- package/dist/form/lib.d.ts +15 -0
- package/dist/form/types/fieldComponentTypes.d.ts +32 -0
- package/dist/form/types/fieldTypes.d.ts +80 -0
- package/dist/form/types/workflow-schema.d.ts +1107 -0
- package/dist/form/useParsedOpts.d.ts +5 -0
- package/dist/form/usePrevious.d.ts +1 -0
- package/dist/form/utils/checkShowIfObject.d.ts +1 -0
- package/dist/form/utils/getParentValue.d.ts +1 -0
- package/dist/form/utils/getPlaceholder.d.ts +2 -0
- package/dist/form/utils/getValueUsingPath.d.ts +1 -0
- package/dist/form/utils/pwResolver.d.ts +18 -0
- package/dist/form/utils/secondaryField.d.ts +8 -0
- package/dist/form/utils/slurmDuration.d.ts +15 -0
- package/dist/icons.d.ts +1 -1
- package/dist/icons.js +2 -2
- package/dist/index.d.ts +17 -0
- package/dist/index.js +42 -350
- package/dist/list/ListTable.d.ts +63 -0
- package/dist/list/RowContextMenu.d.ts +113 -0
- package/dist/list/index.d.ts +2 -0
- package/dist/list/index.js +2 -0
- package/dist/logviewer/LogViewer.d.ts +18 -0
- package/dist/logviewer/index.d.ts +1 -0
- package/dist/logviewer/index.js +534 -0
- package/dist/logviewer/logviewer.css +70 -0
- package/dist/styles/theme.css +30 -0
- package/dist/styles.css +1 -1
- package/dist/workflow/AnnotationBanner.d.ts +5 -0
- package/dist/workflow/Collapse.d.ts +6 -0
- package/dist/workflow/DependencyGraph.d.ts +15 -0
- package/dist/workflow/JobSummary.d.ts +38 -0
- package/dist/workflow/MatrixGroup.d.ts +41 -0
- package/dist/workflow/Reveal.d.ts +7 -0
- package/dist/workflow/TreeView.d.ts +42 -0
- package/dist/workflow/index.d.ts +1 -0
- package/dist/workflow/index.js +2331 -0
- package/package.json +71 -6
|
@@ -0,0 +1,725 @@
|
|
|
1
|
+
import { AngleDownIcon, AngleRightIcon, CaretDownIcon } from "../icons.js";
|
|
2
|
+
import { c as useStrings } from "./Provider-DvVvScTQ.js";
|
|
3
|
+
import { n as TOOLTIP_ID } from "./Tooltip-WgbiC_nd.js";
|
|
4
|
+
import cx from "classnames";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
7
|
+
import { createPortal } from "react-dom";
|
|
8
|
+
import { Combobox, ComboboxButton, ComboboxInput, ComboboxOption, ComboboxOptions, Listbox, ListboxButton, ListboxOption, ListboxOptions, Switch, Transition } from "@headlessui/react";
|
|
9
|
+
import deepEqual from "fast-deep-equal";
|
|
10
|
+
import { usePopper } from "react-popper";
|
|
11
|
+
import AnimateHeight from "react-animate-height";
|
|
12
|
+
//#region src/components/dropdownUtils.tsx
|
|
13
|
+
function isCategory(option) {
|
|
14
|
+
return typeof option === "object" && option !== null && option !== void 0 && "options" in option;
|
|
15
|
+
}
|
|
16
|
+
function isOption(option) {
|
|
17
|
+
return typeof option === "object" && "label" in option && "value" in option && !("category" in option);
|
|
18
|
+
}
|
|
19
|
+
function normalizeOption(option) {
|
|
20
|
+
if (typeof option === "string") return {
|
|
21
|
+
label: option,
|
|
22
|
+
value: option
|
|
23
|
+
};
|
|
24
|
+
if (typeof option === "object" && option !== null && option !== void 0 && "options" in option) return {
|
|
25
|
+
category: option.category,
|
|
26
|
+
options: Array.isArray(option.options) ? option.options : []
|
|
27
|
+
};
|
|
28
|
+
return option;
|
|
29
|
+
}
|
|
30
|
+
function flattenOptions(options) {
|
|
31
|
+
const result = [];
|
|
32
|
+
for (const opt of options) {
|
|
33
|
+
const normalized = normalizeOption(opt);
|
|
34
|
+
if (isCategory(normalized)) {
|
|
35
|
+
const children = Array.isArray(normalized.options) ? normalized.options : [];
|
|
36
|
+
result.push(normalized);
|
|
37
|
+
result.push(...children);
|
|
38
|
+
} else result.push(normalized);
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
function filterOption(option, query) {
|
|
43
|
+
if (query === "") return true;
|
|
44
|
+
const q = String(query ?? "").toLowerCase().replace(/(-)/gm, "");
|
|
45
|
+
const label = String(option.label ?? "").toLowerCase().replace(/(-)/gm, "");
|
|
46
|
+
const secondary = option.secondaryValue !== void 0 ? String(option.secondaryValue).toLowerCase().replace(/(-)/gm, "") : "";
|
|
47
|
+
return label.includes(q) || secondary.includes(q);
|
|
48
|
+
}
|
|
49
|
+
function DropdownCaret() {
|
|
50
|
+
return /* @__PURE__ */ jsx(CaretDownIcon, { className: "text-neutral-400 absolute top-1/2 -translate-y-1/2 right-0 mr-3 inset-y-0 flex items-center rounded-r-md focus:outline-hidden" });
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/components/Dropdown.tsx
|
|
54
|
+
var checkEquals = (val, opt) => {
|
|
55
|
+
if (typeof val === "object" && !Array.isArray(val)) return deepEqual(val, opt);
|
|
56
|
+
return val === opt;
|
|
57
|
+
};
|
|
58
|
+
function getOptionFromValue(value, options) {
|
|
59
|
+
if (value === void 0) return {
|
|
60
|
+
label: "",
|
|
61
|
+
value: ""
|
|
62
|
+
};
|
|
63
|
+
const found = options?.find((option) => {
|
|
64
|
+
if (typeof option === "string") return checkEquals(value, option);
|
|
65
|
+
else if (isCategory(option)) return option.options.find((opt) => checkEquals(value, opt.value));
|
|
66
|
+
else return checkEquals(value, option.value);
|
|
67
|
+
});
|
|
68
|
+
if (found) if (typeof found === "string") return {
|
|
69
|
+
label: found,
|
|
70
|
+
value: found
|
|
71
|
+
};
|
|
72
|
+
else if (isCategory(found)) return found.options.find((opt) => checkEquals(value, opt.value)) || {
|
|
73
|
+
label: JSON.stringify(value),
|
|
74
|
+
value
|
|
75
|
+
};
|
|
76
|
+
else return found;
|
|
77
|
+
const isResourceObject = value && typeof value === "object" && "name" in value && (value.$type === "computeResource" || value.type === "computeResource" || value.type === "bucket");
|
|
78
|
+
const fallbackLabel = typeof value === "string" ? value : isResourceObject ? value.name : JSON.stringify(value);
|
|
79
|
+
return {
|
|
80
|
+
label: fallbackLabel,
|
|
81
|
+
value: isResourceObject ? value : fallbackLabel
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function Dropdown(props) {
|
|
85
|
+
const { onChange, value, options = [], ...others } = props;
|
|
86
|
+
const val = useMemo(() => {
|
|
87
|
+
return getOptionFromValue(value, options);
|
|
88
|
+
}, [value, options]);
|
|
89
|
+
const wrapperOnchange = (value) => {
|
|
90
|
+
if (onChange) onChange(value?.value);
|
|
91
|
+
};
|
|
92
|
+
return /* @__PURE__ */ jsx(DropdownHelper, {
|
|
93
|
+
value: val,
|
|
94
|
+
onChange: wrapperOnchange,
|
|
95
|
+
options: useMemo(() => {
|
|
96
|
+
if (!options || options.length === 0) return [];
|
|
97
|
+
return options.map((item) => {
|
|
98
|
+
if (isCategory(item)) return {
|
|
99
|
+
...item,
|
|
100
|
+
options: item.options.map((opt) => {
|
|
101
|
+
if (typeof opt === "string") return {
|
|
102
|
+
label: opt,
|
|
103
|
+
value: opt
|
|
104
|
+
};
|
|
105
|
+
return opt;
|
|
106
|
+
})
|
|
107
|
+
};
|
|
108
|
+
else if (typeof item === "string") return {
|
|
109
|
+
label: item,
|
|
110
|
+
value: item
|
|
111
|
+
};
|
|
112
|
+
return item;
|
|
113
|
+
});
|
|
114
|
+
}, [options]),
|
|
115
|
+
...others
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function ActiveWatcher({ active, onChange }) {
|
|
119
|
+
const prev = useRef(null);
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
if (prev.current !== active) {
|
|
122
|
+
onChange?.(active?.value);
|
|
123
|
+
prev.current = active;
|
|
124
|
+
}
|
|
125
|
+
}, [active, onChange]);
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
function DropdownHelper({ wrapperClassName = "w-full", className, textBoxClassName = "w-full", options = [], onChange, onActiveChange, value, id, ariaLabel, disabled = false, placeholder = "", loading = false, allowCustomValue = false, customValueLabel = "Use", portalEl }) {
|
|
129
|
+
const DEBOUNCE_MS = 500;
|
|
130
|
+
const [query, setQuery] = useState("");
|
|
131
|
+
const [referenceElement, setReferenceElement] = useState(null);
|
|
132
|
+
const [popperElement, setPopperElement] = useState(null);
|
|
133
|
+
const [boundaryEl, setBoundaryEl] = useState(null);
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
if (!referenceElement) {
|
|
136
|
+
setBoundaryEl(null);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const ref = referenceElement;
|
|
140
|
+
const dialog = ref.closest("[role=\"dialog\"]");
|
|
141
|
+
if (!dialog) {
|
|
142
|
+
setBoundaryEl(null);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
let node = ref.parentElement;
|
|
146
|
+
while (node) {
|
|
147
|
+
const style = getComputedStyle(node);
|
|
148
|
+
if (/(auto|scroll|hidden)/.test(`${style.overflowX} ${style.overflowY}`)) {
|
|
149
|
+
setBoundaryEl(node);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (node === dialog) break;
|
|
153
|
+
node = node.parentElement;
|
|
154
|
+
}
|
|
155
|
+
setBoundaryEl(dialog);
|
|
156
|
+
}, [referenceElement]);
|
|
157
|
+
const sameWidthModifier = useMemo(() => ({
|
|
158
|
+
name: "sameWidth",
|
|
159
|
+
enabled: true,
|
|
160
|
+
phase: "beforeWrite",
|
|
161
|
+
requires: ["computeStyles"],
|
|
162
|
+
fn: ({ state }) => {
|
|
163
|
+
state.styles.popper.width = `${state.rects.reference.width}px`;
|
|
164
|
+
},
|
|
165
|
+
effect: ({ state }) => {
|
|
166
|
+
state.elements.popper.style.width = `${state.elements.reference.offsetWidth}px`;
|
|
167
|
+
}
|
|
168
|
+
}), []);
|
|
169
|
+
const { styles, attributes } = usePopper(referenceElement, popperElement, {
|
|
170
|
+
strategy: "fixed",
|
|
171
|
+
modifiers: useMemo(() => boundaryEl ? [
|
|
172
|
+
sameWidthModifier,
|
|
173
|
+
{
|
|
174
|
+
name: "flip",
|
|
175
|
+
options: { boundary: boundaryEl }
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: "preventOverflow",
|
|
179
|
+
options: { boundary: boundaryEl }
|
|
180
|
+
}
|
|
181
|
+
] : [sameWidthModifier], [boundaryEl, sameWidthModifier])
|
|
182
|
+
});
|
|
183
|
+
const debounceRef = useRef(null);
|
|
184
|
+
const buttonRef = useRef(null);
|
|
185
|
+
const flushCustomValue = useCallback((val) => {
|
|
186
|
+
onChange({
|
|
187
|
+
label: val,
|
|
188
|
+
value: val
|
|
189
|
+
});
|
|
190
|
+
}, [onChange]);
|
|
191
|
+
const onQueryChange = (val) => {
|
|
192
|
+
setQuery(val);
|
|
193
|
+
if (allowCustomValue) {
|
|
194
|
+
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
195
|
+
debounceRef.current = setTimeout(() => {
|
|
196
|
+
flushCustomValue(val);
|
|
197
|
+
debounceRef.current = null;
|
|
198
|
+
}, DEBOUNCE_MS);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
const onInputBlur = () => {
|
|
202
|
+
if (allowCustomValue && debounceRef.current) {
|
|
203
|
+
clearTimeout(debounceRef.current);
|
|
204
|
+
debounceRef.current = null;
|
|
205
|
+
flushCustomValue(query);
|
|
206
|
+
}
|
|
207
|
+
setQuery("");
|
|
208
|
+
};
|
|
209
|
+
const onComboboxChange = (val) => {
|
|
210
|
+
if (debounceRef.current) {
|
|
211
|
+
clearTimeout(debounceRef.current);
|
|
212
|
+
debounceRef.current = null;
|
|
213
|
+
}
|
|
214
|
+
onChange(val);
|
|
215
|
+
};
|
|
216
|
+
const flattenedOptions = useMemo(() => {
|
|
217
|
+
const flatOptions = options.flatMap((option) => {
|
|
218
|
+
if (isCategory(option)) {
|
|
219
|
+
const filteredOptions = option.options.filter((opt) => filterOption(opt, query));
|
|
220
|
+
if (filteredOptions.length === 0) return [];
|
|
221
|
+
return [{
|
|
222
|
+
label: option.category || "",
|
|
223
|
+
value: option.category || "",
|
|
224
|
+
disabled: true,
|
|
225
|
+
category: true
|
|
226
|
+
}, ...filteredOptions];
|
|
227
|
+
}
|
|
228
|
+
if (filterOption(option, query)) return option;
|
|
229
|
+
return [];
|
|
230
|
+
});
|
|
231
|
+
if (allowCustomValue) {
|
|
232
|
+
const customValue = query || value?.value || "";
|
|
233
|
+
flatOptions.unshift({
|
|
234
|
+
label: `${customValueLabel} "${customValue}"`,
|
|
235
|
+
value: customValue
|
|
236
|
+
});
|
|
237
|
+
} else if (flatOptions.length === 0) return [{
|
|
238
|
+
label: "No options found",
|
|
239
|
+
value: "",
|
|
240
|
+
disabled: true
|
|
241
|
+
}];
|
|
242
|
+
return flatOptions;
|
|
243
|
+
}, [
|
|
244
|
+
options,
|
|
245
|
+
query,
|
|
246
|
+
value,
|
|
247
|
+
allowCustomValue,
|
|
248
|
+
customValueLabel
|
|
249
|
+
]);
|
|
250
|
+
const comboOptions = /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(ComboboxOptions, {
|
|
251
|
+
ref: setPopperElement,
|
|
252
|
+
style: styles.popper,
|
|
253
|
+
className: "bg-(--theme-input-bg) border-(--theme-border) text-(--theme-app) max-h-60! empty:invisible border overflow-auto rounded-md shadow-lg focus:outline-hidden sm:text-sm z-9999 data-[popper-reference-hidden=true]:invisible data-[popper-reference-hidden=true]:pointer-events-none",
|
|
254
|
+
...attributes.popper,
|
|
255
|
+
children: ({ option }) => {
|
|
256
|
+
const optionLabel = typeof option === "string" ? option : option.label;
|
|
257
|
+
const optionDescription = typeof option !== "string" ? option.description : void 0;
|
|
258
|
+
const isCategoryRow = typeof option !== "string" && Boolean(option.category);
|
|
259
|
+
return /* @__PURE__ */ jsx(ComboboxOption, {
|
|
260
|
+
"data-testid": "combobox-option",
|
|
261
|
+
value: option,
|
|
262
|
+
className: cx("w-full group relative flex", optionDescription ? "min-h-10 py-2" : "h-10", isCategoryRow ? "text-[14px] font-bold pl-1 items-center" : "data-disabled:text-(--theme-muted-text-color) data-disabled:bg-(--theme-muted-panel-bg) data-disabled:cursor-not-allowed cursor-pointer items-center pr-9 pl-3 leading-5 data-focus:bg-(--theme-muted-panel-bg) data-focus:text-(--theme-app) data-focus:outline-hidden", "data-selected:border-l-2 data-selected:border-(--theme-link) data-selected:bg-(--theme-muted-panel-bg) data-selected:text-(--theme-app)"),
|
|
263
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
264
|
+
className: cx("flex gap-1.5", optionDescription ? "items-start min-w-0" : "items-center truncate"),
|
|
265
|
+
"data-tooltip-id": TOOLTIP_ID,
|
|
266
|
+
onMouseEnter: (e) => {
|
|
267
|
+
const inner = e.currentTarget.lastElementChild;
|
|
268
|
+
if (inner && inner.scrollWidth > inner.clientWidth) e.currentTarget.setAttribute("data-tooltip-content", optionLabel);
|
|
269
|
+
else e.currentTarget.removeAttribute("data-tooltip-content");
|
|
270
|
+
},
|
|
271
|
+
children: [typeof option !== "string" && option.icon, optionDescription ? /* @__PURE__ */ jsxs("span", {
|
|
272
|
+
className: "flex flex-col min-w-0",
|
|
273
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
274
|
+
className: "truncate",
|
|
275
|
+
children: optionLabel
|
|
276
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
277
|
+
className: "text-(--theme-muted-text-color) text-xs leading-snug",
|
|
278
|
+
children: optionDescription
|
|
279
|
+
})]
|
|
280
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
281
|
+
className: "truncate",
|
|
282
|
+
children: optionLabel
|
|
283
|
+
})]
|
|
284
|
+
})
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
}) });
|
|
288
|
+
return /* @__PURE__ */ jsx("div", {
|
|
289
|
+
className: cx("relative rounded-md flex items-center", wrapperClassName),
|
|
290
|
+
children: /* @__PURE__ */ jsx(Combobox, {
|
|
291
|
+
"data-testid": "combobox",
|
|
292
|
+
className: cx("relative w-full", className),
|
|
293
|
+
as: "div",
|
|
294
|
+
by: checkEquals,
|
|
295
|
+
value,
|
|
296
|
+
onChange: onComboboxChange,
|
|
297
|
+
onClose: () => setQuery(""),
|
|
298
|
+
immediate: true,
|
|
299
|
+
virtual: {
|
|
300
|
+
options: flattenedOptions,
|
|
301
|
+
disabled: (option) => Boolean(option.disabled)
|
|
302
|
+
},
|
|
303
|
+
disabled,
|
|
304
|
+
children: ({ activeOption, open }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
305
|
+
onActiveChange && /* @__PURE__ */ jsx(ActiveWatcher, {
|
|
306
|
+
active: activeOption,
|
|
307
|
+
onChange: onActiveChange
|
|
308
|
+
}),
|
|
309
|
+
/* @__PURE__ */ jsx(ComboboxInput, {
|
|
310
|
+
id,
|
|
311
|
+
"aria-label": ariaLabel || void 0,
|
|
312
|
+
placeholder: loading ? "Loading..." : placeholder,
|
|
313
|
+
onBlur: onInputBlur,
|
|
314
|
+
ref: setReferenceElement,
|
|
315
|
+
onClick: () => {
|
|
316
|
+
if (!open) buttonRef.current?.click();
|
|
317
|
+
},
|
|
318
|
+
className: cx("placeholder:text-xs bg-(--theme-input-bg) border-(--theme-border) text-(--theme-app) focus:border-(--theme-element) focus:outline-none focus:ring-1 focus:ring-(--theme-element) w-full h-full text-ellipsis pr-8", "disabled:bg-(--theme-input-disabled-bg) disabled:text-(--theme-input-disabled-text) disabled:cursor-not-allowed", textBoxClassName),
|
|
319
|
+
autoComplete: "off",
|
|
320
|
+
onChange: (event) => onQueryChange(event.target.value),
|
|
321
|
+
displayValue: (opt) => {
|
|
322
|
+
return opt?.label?.replaceAll("\"", "") || query || "";
|
|
323
|
+
},
|
|
324
|
+
disabled
|
|
325
|
+
}),
|
|
326
|
+
/* @__PURE__ */ jsx(ComboboxButton, {
|
|
327
|
+
ref: buttonRef,
|
|
328
|
+
className: "absolute inset-y-0 right-0 flex items-center pr-3 disabled:cursor-not-allowed",
|
|
329
|
+
"data-testid": "combobox-button",
|
|
330
|
+
disabled,
|
|
331
|
+
children: /* @__PURE__ */ jsx(DropdownCaret, {})
|
|
332
|
+
}),
|
|
333
|
+
typeof document !== "undefined" && createPortal(comboOptions, portalEl ?? document.querySelector(".ds-root") ?? document.body)
|
|
334
|
+
] })
|
|
335
|
+
})
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
//#endregion
|
|
339
|
+
//#region src/components/Listbox.tsx
|
|
340
|
+
function CustomListbox({ options = [], handleOptionSelected, type, allowSearch = false, closeOnSelect = true, className = "", invalid = false }) {
|
|
341
|
+
const { dropdown: strings } = useStrings();
|
|
342
|
+
const [filter, setFilter] = useState("");
|
|
343
|
+
const [controlledOpen, setControlledOpen] = useState(false);
|
|
344
|
+
const optionsToShow = options.filter((option) => !option.selected && option.label && option.label.toLowerCase().includes(filter.toLowerCase()));
|
|
345
|
+
function useOutsideAlerter(ref) {
|
|
346
|
+
useEffect(() => {
|
|
347
|
+
function handleClickOutside(event) {
|
|
348
|
+
if (ref.current && event.target instanceof Node && !ref.current.contains(event.target)) {
|
|
349
|
+
setControlledOpen(false);
|
|
350
|
+
setFilter("");
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
354
|
+
return () => {
|
|
355
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
356
|
+
};
|
|
357
|
+
}, [ref]);
|
|
358
|
+
}
|
|
359
|
+
const wrapperRef = useRef(null);
|
|
360
|
+
useOutsideAlerter(wrapperRef);
|
|
361
|
+
const optionsElement = /* @__PURE__ */ jsxs(ListboxOptions, {
|
|
362
|
+
static: true,
|
|
363
|
+
className: "absolute w-full py-1 z-50 theme-input rounded-md",
|
|
364
|
+
children: [allowSearch && /* @__PURE__ */ jsx("div", {
|
|
365
|
+
className: "pl-2 pr-4 mb-1",
|
|
366
|
+
children: /* @__PURE__ */ jsx("input", {
|
|
367
|
+
autoComplete: "off",
|
|
368
|
+
type: "search",
|
|
369
|
+
autoFocus: true,
|
|
370
|
+
onChange: (e) => setFilter(e.target.value),
|
|
371
|
+
value: filter,
|
|
372
|
+
className: "w-full p-1 theme-input",
|
|
373
|
+
onKeyDown: (e) => {
|
|
374
|
+
if (![
|
|
375
|
+
"ArrowUp",
|
|
376
|
+
"ArrowDown",
|
|
377
|
+
"Enter",
|
|
378
|
+
"Home",
|
|
379
|
+
"End",
|
|
380
|
+
"Escape"
|
|
381
|
+
].includes(e.key)) e.stopPropagation();
|
|
382
|
+
}
|
|
383
|
+
})
|
|
384
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
385
|
+
className: "overflow-auto max-h-60 theme-panel",
|
|
386
|
+
children: optionsToShow.length > 0 ? optionsToShow.map((option, index) => /* @__PURE__ */ jsx(ListboxOption, {
|
|
387
|
+
className: "relative hover:theme-hover select-none pl-2 pr-4",
|
|
388
|
+
value: option.value,
|
|
389
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
390
|
+
className: "w-full flex flex-row",
|
|
391
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
392
|
+
className: "w-3/4 py-2 flex items-center",
|
|
393
|
+
children: [
|
|
394
|
+
/* @__PURE__ */ jsx("div", {
|
|
395
|
+
className: "w-4 h-6 btn btn-info text-xl line-height-0 mr-2",
|
|
396
|
+
children: "+"
|
|
397
|
+
}),
|
|
398
|
+
option.icon && /* @__PURE__ */ jsx("span", {
|
|
399
|
+
className: "mr-2 flex items-center",
|
|
400
|
+
children: option.icon
|
|
401
|
+
}),
|
|
402
|
+
/* @__PURE__ */ jsx("span", {
|
|
403
|
+
className: "mr-2",
|
|
404
|
+
children: option.label
|
|
405
|
+
}),
|
|
406
|
+
/* @__PURE__ */ jsx("span", {
|
|
407
|
+
className: "italic",
|
|
408
|
+
children: option.secondaryLabel
|
|
409
|
+
})
|
|
410
|
+
]
|
|
411
|
+
})
|
|
412
|
+
}, index)
|
|
413
|
+
}, index)) : /* @__PURE__ */ jsx("div", {
|
|
414
|
+
className: "w-full flex flex-row",
|
|
415
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
416
|
+
className: "w-3/4 py-2 pl-2 capitalize flex items-center",
|
|
417
|
+
children: filter === "" ? `All ${type} Added` : `No ${type} Found`
|
|
418
|
+
})
|
|
419
|
+
})
|
|
420
|
+
})]
|
|
421
|
+
});
|
|
422
|
+
return /* @__PURE__ */ jsxs(Listbox, {
|
|
423
|
+
as: "div",
|
|
424
|
+
className: cx("relative mt-1 theme-input border theme-border rounded-md", className),
|
|
425
|
+
ref: wrapperRef,
|
|
426
|
+
onChange: handleOptionSelected,
|
|
427
|
+
children: [/* @__PURE__ */ jsxs(ListboxButton, {
|
|
428
|
+
onClick: () => setControlledOpen((prev) => !prev),
|
|
429
|
+
className: cx("relative w-full py-2 pl-3 text-left", invalid && "border-red-600 focus:border-red-600 focus:ring-red-500"),
|
|
430
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
431
|
+
className: "block truncate",
|
|
432
|
+
children: strings.select(type)
|
|
433
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
434
|
+
className: "pointer-events-none absolute inset-y-0 right-0 flex items-center justify-items-center",
|
|
435
|
+
children: /* @__PURE__ */ jsx(AngleDownIcon, {
|
|
436
|
+
className: "h-5 w-8",
|
|
437
|
+
"aria-hidden": "true"
|
|
438
|
+
})
|
|
439
|
+
})]
|
|
440
|
+
}), closeOnSelect ? /* @__PURE__ */ jsx(Transition, {
|
|
441
|
+
leave: "transition ease-in duration-100",
|
|
442
|
+
leaveFrom: "opacity-100",
|
|
443
|
+
leaveTo: "opacity-0",
|
|
444
|
+
children: optionsElement || null
|
|
445
|
+
}) : /* @__PURE__ */ jsx(Fragment, { children: controlledOpen && optionsElement })]
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
//#endregion
|
|
449
|
+
//#region src/components/MultiSelect.tsx
|
|
450
|
+
function MultiSelectDropdown({ options, value, onChange, id, className, wrapperClassName = "w-full", textBoxClassName, disabled = false, placeholder, loading = false, searchable = true, maxTagCount = 2, compareBy }) {
|
|
451
|
+
const strings = useStrings();
|
|
452
|
+
const [query, setQuery] = useState("");
|
|
453
|
+
const [referenceEl, setReferenceEl] = useState(null);
|
|
454
|
+
const [popperEl, setPopperEl] = useState(null);
|
|
455
|
+
const { styles, attributes } = usePopper(referenceEl, popperEl, {
|
|
456
|
+
placement: "bottom-start",
|
|
457
|
+
modifiers: [{
|
|
458
|
+
name: "offset",
|
|
459
|
+
options: { offset: [0, 4] }
|
|
460
|
+
}]
|
|
461
|
+
});
|
|
462
|
+
const allOptions = useMemo(() => flattenOptions(options), [options]);
|
|
463
|
+
const compare = compareBy ?? ((a, b) => a === b);
|
|
464
|
+
const selectedOptions = useMemo(() => {
|
|
465
|
+
const result = [];
|
|
466
|
+
for (const val of value) {
|
|
467
|
+
const found = allOptions.find((opt) => isOption(opt) && compare(opt.value, val));
|
|
468
|
+
if (found) result.push(found);
|
|
469
|
+
}
|
|
470
|
+
return result;
|
|
471
|
+
}, [
|
|
472
|
+
value,
|
|
473
|
+
allOptions,
|
|
474
|
+
compare
|
|
475
|
+
]);
|
|
476
|
+
const filteredOptions = useMemo(() => {
|
|
477
|
+
if (!searchable || query.trim() === "") return allOptions;
|
|
478
|
+
const result = [];
|
|
479
|
+
for (const opt of allOptions) if (isCategory(opt)) {
|
|
480
|
+
const matchedChildren = (Array.isArray(opt.options) ? opt.options : []).filter((o) => filterOption(o, query));
|
|
481
|
+
if (matchedChildren.length > 0) result.push(opt, ...matchedChildren);
|
|
482
|
+
} else if (isOption(opt) && filterOption(opt, query)) result.push(opt);
|
|
483
|
+
return result;
|
|
484
|
+
}, [
|
|
485
|
+
allOptions,
|
|
486
|
+
query,
|
|
487
|
+
searchable
|
|
488
|
+
]);
|
|
489
|
+
const display = useMemo(() => {
|
|
490
|
+
const shown = selectedOptions.slice(0, maxTagCount);
|
|
491
|
+
return {
|
|
492
|
+
label: shown.map((o) => o.label).join(", "),
|
|
493
|
+
overflow: selectedOptions.length - shown.length
|
|
494
|
+
};
|
|
495
|
+
}, [selectedOptions, maxTagCount]);
|
|
496
|
+
const handleChange = useCallback((newValues) => {
|
|
497
|
+
if (!Array.isArray(newValues)) return;
|
|
498
|
+
onChange(newValues);
|
|
499
|
+
}, [onChange]);
|
|
500
|
+
const isDisabled = disabled || loading;
|
|
501
|
+
const isEmpty = filteredOptions.length === 0;
|
|
502
|
+
return /* @__PURE__ */ jsx(Combobox, {
|
|
503
|
+
multiple: true,
|
|
504
|
+
value: Array.isArray(value) ? value : [],
|
|
505
|
+
onChange: handleChange,
|
|
506
|
+
disabled: isDisabled,
|
|
507
|
+
onClose: () => setQuery(""),
|
|
508
|
+
by: compare,
|
|
509
|
+
children: ({ open }) => /* @__PURE__ */ jsxs("div", {
|
|
510
|
+
ref: setReferenceEl,
|
|
511
|
+
className: cx("relative", wrapperClassName),
|
|
512
|
+
children: [
|
|
513
|
+
/* @__PURE__ */ jsx(ComboboxButton, {
|
|
514
|
+
as: "div",
|
|
515
|
+
id,
|
|
516
|
+
className: cx("theme-input flex items-center cursor-pointer rounded border text-[14px] w-full px-2 pr-8 py-1 min-h-[30px] overflow-hidden", isDisabled && "opacity-50 cursor-not-allowed", textBoxClassName, className),
|
|
517
|
+
children: loading ? /* @__PURE__ */ jsx("span", {
|
|
518
|
+
className: "theme-muted-text",
|
|
519
|
+
children: strings.loading
|
|
520
|
+
}) : selectedOptions.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
521
|
+
className: "min-w-0 truncate",
|
|
522
|
+
children: display.label
|
|
523
|
+
}), display.overflow > 0 && /* @__PURE__ */ jsxs("span", {
|
|
524
|
+
className: "ml-1 shrink-0 theme-muted-text",
|
|
525
|
+
children: ["+", display.overflow]
|
|
526
|
+
})] }) : /* @__PURE__ */ jsx("span", {
|
|
527
|
+
className: "theme-muted-text truncate",
|
|
528
|
+
children: placeholder
|
|
529
|
+
})
|
|
530
|
+
}),
|
|
531
|
+
/* @__PURE__ */ jsx(DropdownCaret, {}),
|
|
532
|
+
open && /* @__PURE__ */ jsxs(ComboboxOptions, {
|
|
533
|
+
ref: setPopperEl,
|
|
534
|
+
static: true,
|
|
535
|
+
"data-testid": "msd-list",
|
|
536
|
+
style: styles.popper,
|
|
537
|
+
...attributes.popper,
|
|
538
|
+
className: "theme-panel z-10 max-h-60 w-full overflow-auto rounded-md shadow-lg focus:outline-none",
|
|
539
|
+
children: [searchable && /* @__PURE__ */ jsx("div", {
|
|
540
|
+
className: "sticky top-0 theme-panel p-2 border-b z-10",
|
|
541
|
+
children: /* @__PURE__ */ jsx("input", {
|
|
542
|
+
placeholder,
|
|
543
|
+
"data-1p-ignore": true,
|
|
544
|
+
autoComplete: "off",
|
|
545
|
+
type: "text",
|
|
546
|
+
className: "theme-input w-full",
|
|
547
|
+
value: query,
|
|
548
|
+
onChange: (e) => setQuery(e.target.value),
|
|
549
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
550
|
+
autoFocus: true
|
|
551
|
+
})
|
|
552
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
553
|
+
className: "py-1",
|
|
554
|
+
children: isEmpty ? /* @__PURE__ */ jsx("div", {
|
|
555
|
+
className: "px-4 py-2 text-sm theme-muted-text",
|
|
556
|
+
children: strings.dropdown.noOptionsFound
|
|
557
|
+
}) : filteredOptions.map((opt, index) => {
|
|
558
|
+
if (isCategory(opt)) return /* @__PURE__ */ jsx("li", {
|
|
559
|
+
role: "presentation",
|
|
560
|
+
className: "px-4 py-2 text-sm font-bold theme-muted-text",
|
|
561
|
+
children: opt.category
|
|
562
|
+
}, `category-${opt.category ?? "uncat"}-${index}`);
|
|
563
|
+
const option = opt;
|
|
564
|
+
return /* @__PURE__ */ jsx(ComboboxOption, {
|
|
565
|
+
value: option.value,
|
|
566
|
+
disabled: option.disabled,
|
|
567
|
+
"data-testid": `msd-option-${String(option.value)}`,
|
|
568
|
+
className: ({ focus }) => cx("relative cursor-pointer select-none py-2 pl-10 pr-4 text-sm", focus && "theme-hover", option.disabled && "cursor-not-allowed opacity-50"),
|
|
569
|
+
children: ({ selected }) => /* @__PURE__ */ jsxs("div", {
|
|
570
|
+
className: "flex items-center",
|
|
571
|
+
children: [
|
|
572
|
+
/* @__PURE__ */ jsx("span", {
|
|
573
|
+
className: "absolute inset-y-0 left-0 flex items-center pl-3",
|
|
574
|
+
children: /* @__PURE__ */ jsx("input", {
|
|
575
|
+
autoComplete: "off",
|
|
576
|
+
type: "checkbox",
|
|
577
|
+
checked: selected,
|
|
578
|
+
readOnly: true,
|
|
579
|
+
className: "h-4 w-4 cursor-pointer",
|
|
580
|
+
"aria-hidden": "true"
|
|
581
|
+
})
|
|
582
|
+
}),
|
|
583
|
+
option.icon && /* @__PURE__ */ jsx("span", {
|
|
584
|
+
className: "mr-2 flex items-center",
|
|
585
|
+
children: option.icon
|
|
586
|
+
}),
|
|
587
|
+
/* @__PURE__ */ jsx("div", {
|
|
588
|
+
className: "flex flex-col",
|
|
589
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
590
|
+
className: "block truncate",
|
|
591
|
+
children: option.label
|
|
592
|
+
})
|
|
593
|
+
})
|
|
594
|
+
]
|
|
595
|
+
})
|
|
596
|
+
}, `option-${String(option.value)}`);
|
|
597
|
+
})
|
|
598
|
+
})]
|
|
599
|
+
})
|
|
600
|
+
]
|
|
601
|
+
})
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
//#endregion
|
|
605
|
+
//#region src/components/CollapsiblePanel.tsx
|
|
606
|
+
var noop = () => {};
|
|
607
|
+
function ControlledCollapsiblePanel({ title = "", children, open, setOpen, onClick = noop, wrapperElement, customizedButton = null, className }) {
|
|
608
|
+
const toggleOpen = useCallback(() => {
|
|
609
|
+
if (onClick) onClick();
|
|
610
|
+
setOpen?.((open) => !open);
|
|
611
|
+
}, [setOpen, onClick]);
|
|
612
|
+
const Wrapper = wrapperElement ? wrapperElement : React.Fragment;
|
|
613
|
+
return React.isValidElement(title) ? /* @__PURE__ */ jsxs(Fragment, { children: [title, /* @__PURE__ */ jsx(Wrapper, { children: /* @__PURE__ */ jsx(AnimateHeight, {
|
|
614
|
+
duration: 300,
|
|
615
|
+
height: open ? "auto" : 0,
|
|
616
|
+
children
|
|
617
|
+
}) })] }) : /* @__PURE__ */ jsxs("div", {
|
|
618
|
+
className: cx("border border-solid rounded-2xl border-(--theme-border) bg-(--theme-panel-bg) text-(--theme-panel) mb-1 w-full", className),
|
|
619
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
620
|
+
className: cx(!open && "text-(--theme-muted-text-color)", "w-full flex items-center justify-between transform ease-in transition text-sm py-3 px-2 cursor-pointer"),
|
|
621
|
+
onClick: toggleOpen,
|
|
622
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
623
|
+
className: "flex items-center w-full",
|
|
624
|
+
children: [/* @__PURE__ */ jsx(AngleRightIcon, { className: cx(open && "transform rotate-90", "px-1 ml-1 text-[1.25rem] transition ease-in") }), /* @__PURE__ */ jsx("span", {
|
|
625
|
+
className: "px-2 font-bold select-none",
|
|
626
|
+
children: title?.toString()
|
|
627
|
+
})]
|
|
628
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
629
|
+
onClick: (e) => {
|
|
630
|
+
e.stopPropagation();
|
|
631
|
+
},
|
|
632
|
+
children: customizedButton
|
|
633
|
+
})]
|
|
634
|
+
}), /* @__PURE__ */ jsx(AnimateHeight, {
|
|
635
|
+
duration: 300,
|
|
636
|
+
height: open ? "auto" : 0,
|
|
637
|
+
children
|
|
638
|
+
})]
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
function UncontrolledCollapsiblePanel({ title, children, onClick, wrapperElement, initialState = true, className, customizedButton = null }) {
|
|
642
|
+
const [open, setOpen] = React.useState(initialState);
|
|
643
|
+
return /* @__PURE__ */ jsx(ControlledCollapsiblePanel, {
|
|
644
|
+
title: typeof title === "function" ? title(open, setOpen) : title,
|
|
645
|
+
open,
|
|
646
|
+
setOpen,
|
|
647
|
+
onClick,
|
|
648
|
+
wrapperElement,
|
|
649
|
+
className,
|
|
650
|
+
customizedButton,
|
|
651
|
+
children
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
function MaybeCollapsible({ className, initialState, children, title, customizedButton, collapsible }) {
|
|
655
|
+
if (collapsible) return /* @__PURE__ */ jsx(UncontrolledCollapsiblePanel, {
|
|
656
|
+
className,
|
|
657
|
+
initialState,
|
|
658
|
+
title,
|
|
659
|
+
customizedButton,
|
|
660
|
+
children
|
|
661
|
+
});
|
|
662
|
+
return /* @__PURE__ */ jsx("div", {
|
|
663
|
+
className,
|
|
664
|
+
children
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
//#endregion
|
|
668
|
+
//#region src/components/SectionHeader.tsx
|
|
669
|
+
function SectionHeader({ children, className = "" }) {
|
|
670
|
+
return /* @__PURE__ */ jsx("div", {
|
|
671
|
+
className: cx("w-full text-lg font-semibold", className),
|
|
672
|
+
children
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
//#endregion
|
|
676
|
+
//#region src/components/SwitchToggle.tsx
|
|
677
|
+
function SwitchToggle({ onChange, value = void 0, yesLabel = "Yes", noLabel = "No", disabled = false, datatip = "", invalid = false }) {
|
|
678
|
+
const [enabled, setEnabled] = useState(value ?? false);
|
|
679
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
680
|
+
const setIsEnabled = (e) => {
|
|
681
|
+
setEnabled(e);
|
|
682
|
+
onChange(e);
|
|
683
|
+
};
|
|
684
|
+
useEffect(() => {
|
|
685
|
+
if (value !== void 0) setEnabled(value);
|
|
686
|
+
}, [value]);
|
|
687
|
+
const checked = value ?? enabled;
|
|
688
|
+
return /* @__PURE__ */ jsx("div", {
|
|
689
|
+
"data-tooltip-content": datatip || void 0,
|
|
690
|
+
"data-tooltip-id": datatip ? TOOLTIP_ID : void 0,
|
|
691
|
+
className: cx("w-[198px] h-[30px] overflow-hidden shadow-sm rounded-md cursor-pointer ring-(--theme-border) ring-1", invalid && "border-red-600 focus:border-red-600 focus:ring-red-500 ring-1 ring-red-500", !invalid && isFocused && "ring-1 ring-[rgba(82,168,236,.8)] drop-shadow-[0_1px_2px_rgba(82,168,236,0.8)]"),
|
|
692
|
+
children: /* @__PURE__ */ jsx(Switch, {
|
|
693
|
+
checked,
|
|
694
|
+
onChange: setIsEnabled,
|
|
695
|
+
className: "text-white text-sm shadow-sm rounded-md cursor-pointer",
|
|
696
|
+
onClick: (e) => e.stopPropagation(),
|
|
697
|
+
onFocus: () => setIsFocused(true),
|
|
698
|
+
onBlur: () => setIsFocused(false),
|
|
699
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
700
|
+
className: cx(checked ? "translate-x-0" : "-translate-x-[100px]", "relative transform flex flex-row ease-in-out duration-500", disabled && "cursor-not-allowed opacity-50"),
|
|
701
|
+
children: [
|
|
702
|
+
/* @__PURE__ */ jsx("div", {
|
|
703
|
+
className: "inline text-center capitalize px-2 py-1 w-[99px] border-0",
|
|
704
|
+
style: {
|
|
705
|
+
background: `linear-gradient(
|
|
706
|
+
to bottom,
|
|
707
|
+
var(--theme-element, #04c) 0%,
|
|
708
|
+
var(--theme-element, #08c) 100%
|
|
709
|
+
)`,
|
|
710
|
+
color: "var(--theme-element-text, #ffffff)"
|
|
711
|
+
},
|
|
712
|
+
children: yesLabel
|
|
713
|
+
}),
|
|
714
|
+
/* @__PURE__ */ jsx("div", { className: "inline px-2 py-1 h-8 w-[99px] bg-linear-to-b from-white to-[#e6e6e6]" }),
|
|
715
|
+
/* @__PURE__ */ jsx("div", {
|
|
716
|
+
className: "inline text-center capitalize px-2 py-1 w-[99px] bg-linear-to-b from-[#e6e6e6] to-white bg-[#04c] text-black",
|
|
717
|
+
children: noLabel
|
|
718
|
+
})
|
|
719
|
+
]
|
|
720
|
+
})
|
|
721
|
+
})
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
//#endregion
|
|
725
|
+
export { UncontrolledCollapsiblePanel as a, Dropdown as c, flattenOptions as d, isCategory as f, MaybeCollapsible as i, DropdownCaret as l, SectionHeader as n, MultiSelectDropdown as o, isOption as p, ControlledCollapsiblePanel as r, CustomListbox as s, SwitchToggle as t, filterOption as u };
|