@parallelworks/ui 0.19.0 → 0.19.1
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/{chunks/memoryStore-CC91S5LP.js → ai/adapter/memoryStore.js} +2 -2
- package/dist/ai/adapter/mock/index.js +2 -80
- package/dist/ai/adapter/mock/mockAdapter.js +81 -0
- package/dist/ai/adapter/openai/createOpenAIStream.js +33 -0
- package/dist/ai/adapter/openai/errors.js +37 -0
- package/dist/ai/adapter/openai/index.js +5 -333
- package/dist/ai/adapter/openai/openaiAdapter.js +54 -0
- package/dist/ai/adapter/openai/responses.js +108 -0
- package/dist/ai/adapter/openai/sse.js +112 -0
- package/dist/{chunks/types-Yy0NrerF.js → ai/adapter/types.js} +1 -1
- package/dist/ai/agent/classifier.js +12 -0
- package/dist/ai/agent/diff.js +223 -0
- package/dist/ai/agent/diffHighlight.js +101 -0
- package/dist/ai/agent/permissions.js +29 -0
- package/dist/ai/agent/toolfmt.js +383 -0
- package/dist/ai/agent/transcript.js +127 -0
- package/dist/ai/components/AllocationSelector.js +56 -0
- package/dist/ai/components/AttachmentManager.js +144 -0
- package/dist/ai/components/AttachmentUpload.js +179 -0
- package/dist/ai/components/BlockedGroupBanner.js +29 -0
- package/dist/ai/components/BranchNavigator.js +57 -0
- package/dist/ai/components/ChatEmptyState.js +171 -0
- package/dist/ai/components/ChatInput.js +265 -0
- package/dist/ai/components/ChatLayout.js +15 -0
- package/dist/ai/components/ChatMessage.js +338 -0
- package/dist/ai/components/ChatMessageList.js +301 -0
- package/dist/ai/components/ChatSidebar.js +345 -0
- package/dist/ai/components/ChatThread.js +198 -0
- package/dist/ai/components/ComposerChrome.js +50 -0
- package/dist/ai/components/ComposerFrame.js +33 -0
- package/dist/ai/components/DragOverlay.js +20 -0
- package/dist/ai/components/ModelSelector.js +343 -0
- package/dist/ai/components/ShareDialog.js +260 -0
- package/dist/ai/components/SlashMenu.js +91 -0
- package/dist/ai/components/agent/ActivityLine.js +151 -0
- package/dist/ai/components/agent/AgentMessageParts.js +721 -0
- package/dist/ai/components/agent/PermissionPicker.js +38 -0
- package/dist/ai/components/attachmentKeys.js +10 -0
- package/dist/ai/core/ChatProvider.js +848 -0
- package/dist/ai/core/KeyboardShortcutsProvider.js +9 -0
- package/dist/ai/core/chatReducer.js +223 -0
- package/dist/ai/core/config.js +45 -0
- package/dist/ai/core/events.js +4 -0
- package/dist/ai/core/exportConversation.js +42 -0
- package/dist/ai/core/greeting.js +38 -0
- package/dist/ai/core/parts.js +84 -0
- package/dist/ai/core/useDragDrop.js +36 -0
- package/dist/ai/core/useKeyboardShortcuts.js +77 -0
- package/dist/ai/core/useSSEStream.js +98 -0
- package/dist/ai/index.js +43 -6644
- package/dist/ai/strings.js +175 -0
- package/dist/ai/ui/Avatar.js +35 -0
- package/dist/ai/ui/Dropdown.js +110 -0
- package/dist/ai/ui/Markdown.js +79 -0
- package/dist/ai/ui/Notice.js +77 -0
- package/dist/ai/ui/codeBreaks.js +36 -0
- package/dist/ai/ui/prose.js +13 -0
- package/dist/ai/ui/sidebar.js +148 -0
- package/dist/ai/utils.js +23 -0
- package/dist/components/AddMenu.js +46 -0
- package/dist/components/Avatar.js +46 -0
- package/dist/{chunks/BareModal-BtRiQezg.js → components/BareModal.js} +1 -1
- package/dist/components/Breadcrumbs.js +83 -0
- package/dist/components/Button.js +83 -0
- package/dist/components/Callout.js +23 -0
- package/dist/components/Card.js +31 -0
- package/dist/components/CollapsiblePanel.js +77 -0
- package/dist/{chunks/ConfirmModal-aOR4O1QE.js → components/ConfirmModal.js} +4 -9
- package/dist/components/CopyToClipboard.js +81 -0
- package/dist/{chunks/Markdown-CM-FenNE.js → components/CreateModal.js} +9 -116
- package/dist/components/DescriptionList.js +42 -0
- package/dist/components/Dropdown.js +349 -0
- package/dist/components/EmptyState.js +27 -0
- package/dist/components/Filter.js +32 -0
- package/dist/components/FilterPill.js +13 -0
- package/dist/components/IconButton.js +34 -0
- package/dist/{chunks/Indicator-hBSIxOPK.js → components/Indicator.js} +1 -1
- package/dist/components/Input.js +88 -0
- package/dist/components/LetterBadge.js +13 -0
- package/dist/components/Listbox.js +123 -0
- package/dist/{chunks/Loader-BXoXTZGc.js → components/Loader.js} +1 -1
- package/dist/components/Markdown.js +15 -0
- package/dist/components/MultiSelect.js +171 -0
- package/dist/components/Overview.js +39 -0
- package/dist/components/PageHeader.js +194 -0
- package/dist/components/Pagination.js +35 -0
- package/dist/{chunks/Provider-CDYurraE.js → components/Provider.js} +1 -1
- package/dist/{chunks/RequiredMark-DfLdYbYZ.js → components/RequiredMark.js} +1 -1
- package/dist/components/SectionHeader.js +11 -0
- package/dist/components/SettingModeOption.js +30 -0
- package/dist/components/SettingRow.js +35 -0
- package/dist/components/SettingsCard.js +31 -0
- package/dist/components/SettingsGroup.js +17 -0
- package/dist/components/Sort.js +42 -0
- package/dist/components/StatusBadge.js +63 -0
- package/dist/components/SwitchToggle.js +59 -0
- package/dist/{chunks/SwitchToggleSmall-FcsaYSTs.js → components/SwitchToggleSmall.js} +1 -1
- package/dist/{chunks/Table-DU2MW8xz.js → components/Table.js} +3 -3
- package/dist/components/Toggle.js +20 -0
- package/dist/{chunks/Tooltip-K5HJr4_p.js → components/Tooltip.js} +2 -27
- package/dist/{chunks/StatusBadge-C1Blx_cW.js → components/dropdownUtils.js} +2 -63
- package/dist/{chunks/focus-D_iZJTW1.js → components/focus.js} +1 -1
- package/dist/components/ghostButton.js +7 -0
- package/dist/components/inputClasses.js +4 -0
- package/dist/components/keys.js +27 -0
- package/dist/components/relativeTime.js +32 -0
- package/dist/{chunks/useCssIsDark-DHr05dG2.js → components/useCssIsDark.js} +1 -1
- package/dist/{chunks/duration-BOv8Phl8.js → duration.js} +1 -1
- package/dist/editor/Editor.js +13 -0
- package/dist/editor/EditorField.js +53 -0
- package/dist/editor/FormCodePanel.js +173 -0
- package/dist/{chunks/Monaco-DJ8MW-Dq.js → editor/Monaco.js} +4 -2
- package/dist/editor/index.js +6 -1
- package/dist/editor/themes.js +91 -0
- package/dist/editor/workers.js +29 -0
- package/dist/editor/yaml.js +15 -0
- package/dist/file-explorer/FileExplorer.js +1402 -0
- package/dist/file-explorer/FileExplorerContext.js +370 -0
- package/dist/{chunks/CodePreviewEditor-YqQBz1YL.js → file-explorer/FilePreview/CodePreviewEditor.js} +3 -2
- package/dist/file-explorer/FilePreview/Inline.js +45 -0
- package/dist/file-explorer/FilePreview/StreamedBadge.js +16 -0
- package/dist/file-explorer/FilePreview/Viewer.js +526 -0
- package/dist/file-explorer/FilePreview/index.js +266 -0
- package/dist/file-explorer/FilePreview/parse.js +63 -0
- package/dist/file-explorer/FilePreview/previewCache.js +98 -0
- package/dist/file-explorer/FilePreview/previewType.js +151 -0
- package/dist/file-explorer/FilePreview/readCappedBytes.js +196 -0
- package/dist/file-explorer/FilePreview/useObjectBlobUrl.js +95 -0
- package/dist/file-explorer/FilePreview/useObjectText.js +109 -0
- package/dist/file-explorer/FilePreview/usePresignedUrl.js +73 -0
- package/dist/file-explorer/FileRow.js +165 -0
- package/dist/file-explorer/FileRowsWindow.js +92 -0
- package/dist/file-explorer/FileTable.js +172 -0
- package/dist/file-explorer/FileTableHeaders.js +49 -0
- package/dist/file-explorer/LoadMoreRow.js +46 -0
- package/dist/file-explorer/TreeView.js +376 -0
- package/dist/file-explorer/helpers.js +537 -0
- package/dist/file-explorer/index.js +7 -5671
- package/dist/file-explorer/lib/batch.js +39 -0
- package/dist/file-explorer/lib/errors.js +9 -0
- package/dist/file-explorer/lib/paging.js +124 -0
- package/dist/file-explorer/lib/utils.js +322 -0
- package/dist/file-explorer/toasts.js +400 -0
- package/dist/file-explorer/treeRows.js +73 -0
- package/dist/file-explorer/useNearEnd.js +27 -0
- package/dist/form/FieldWrapper.js +54 -0
- package/dist/form/Fields/BooleanField.js +51 -0
- package/dist/form/Fields/CheckboxGroupField.js +72 -0
- package/dist/form/Fields/ColorField.js +33 -0
- package/dist/form/Fields/DropdownField.js +49 -0
- package/dist/form/Fields/DurationField.js +130 -0
- package/dist/form/Fields/LabelField.js +19 -0
- package/dist/form/Fields/MultiDropdownField.js +40 -0
- package/dist/form/Fields/NumberField.js +51 -0
- package/dist/form/Fields/ObjectField.js +54 -0
- package/dist/form/Fields/RadioField.js +49 -0
- package/dist/form/Fields/RangeField.js +58 -0
- package/dist/form/Fields/ResourceOptionIcon.js +21 -0
- package/dist/form/Fields/StepField.js +6 -0
- package/dist/form/Fields/StringField.js +37 -0
- package/dist/form/Fields/TextAreaField.js +31 -0
- package/dist/form/Fields/durationValidity.js +11 -0
- package/dist/form/Form.js +643 -0
- package/dist/form/SpecialTypes/DropdownWrapper.js +30 -0
- package/dist/form/SpecialTypes/FormikCustomDropdown.js +122 -0
- package/dist/form/SpecialTypes/FormikCustomInput.js +111 -0
- package/dist/form/SpecialTypes/FormikMultiSelectDropdown.js +31 -0
- package/dist/form/SpecialTypes/FormikNumericInput.js +60 -0
- package/dist/form/Wizard/WizardContainer.js +138 -0
- package/dist/form/Wizard/WizardNavigation.js +92 -0
- package/dist/form/Wizard/WizardStepContent.js +35 -0
- package/dist/form/Wizard/WizardStepIndicator.js +108 -0
- package/dist/form/Wizard/useWizardState.js +118 -0
- package/dist/form/Wizard/utils.js +34 -0
- package/dist/form/fieldContext.js +26 -0
- package/dist/form/fieldRegistry.js +50 -0
- package/dist/form/index.js +17 -2321
- package/dist/{chunks/FieldWrapper-Cszwg-4B.js → form/lib.js} +2 -97
- package/dist/form/useParsedOpts.js +62 -0
- package/dist/form/usePrevious.js +11 -0
- package/dist/form/utils/checkShowIfObject.js +14 -0
- package/dist/form/utils/duration.js +69 -0
- package/dist/form/utils/getParentValue.js +23 -0
- package/dist/form/utils/getPlaceholder.js +9 -0
- package/dist/form/utils/getValueUsingPath.js +23 -0
- package/dist/form/utils/secondaryField.js +22 -0
- package/dist/graph/AnnotationBanner.js +141 -0
- package/dist/graph/Collapse.js +41 -0
- package/dist/graph/DependencyGraph.js +1398 -0
- package/dist/graph/JobSummary.js +104 -0
- package/dist/graph/MatrixGroup.js +107 -0
- package/dist/graph/Reveal.js +57 -0
- package/dist/graph/TreeView.js +711 -0
- package/dist/graph/index.js +1 -2519
- package/dist/graph/types.js +6 -0
- package/dist/index.js +46 -599
- package/dist/list/ActionToolbar.js +184 -0
- package/dist/list/HoverCard.js +73 -0
- package/dist/list/ListPage.js +145 -0
- package/dist/list/ListPager.js +59 -0
- package/dist/list/ListTable.js +163 -0
- package/dist/list/ListViewControls.js +372 -0
- package/dist/list/RowContextMenu.js +350 -0
- package/dist/list/UserHoverCard.js +117 -0
- package/dist/list/index.js +11 -2
- package/dist/list/listSearch.js +137 -0
- package/dist/list/listView.js +210 -0
- package/dist/list/textEntry.js +10 -0
- package/dist/{chunks/logviewer-BTKuQWzw.js → logviewer/LogViewer.js} +4 -82
- package/dist/logviewer/index.js +2 -1
- package/dist/logviewer/segments.js +80 -0
- package/package.json +1 -1
- package/dist/chunks/PageHeader-0kG_iypP.js +0 -692
- package/dist/chunks/SwitchToggle-DShNdcao.js +0 -758
- package/dist/chunks/editor-Dk1rbV75.js +0 -361
- package/dist/chunks/list-CJm875m7.js +0 -1418
- /package/dist/{chunks/MarkdownImpl-CyeTVvSt.js → components/MarkdownImpl.js} +0 -0
|
@@ -1,758 +0,0 @@
|
|
|
1
|
-
import { u as useStrings } from "./Provider-CDYurraE.js";
|
|
2
|
-
import { AngleDownIcon, AngleRightIcon, CaretDownIcon } from "../icons.js";
|
|
3
|
-
import { a as truncationTooltipProps, n as TOOLTIP_ID, o as keyedByContent } from "./Tooltip-K5HJr4_p.js";
|
|
4
|
-
import { a as filterOption, c as isCategory, i as DropdownCaret, l as isOption, o as flattenDisplayOptions, s as flattenOptions, u as toggleSetMember } from "./StatusBadge-C1Blx_cW.js";
|
|
5
|
-
import { t as focusOnMount } from "./focus-D_iZJTW1.js";
|
|
6
|
-
import { Combobox, ComboboxButton, ComboboxInput, ComboboxOption, ComboboxOptions, Listbox, ListboxButton, ListboxOption, ListboxOptions, Switch, Transition } from "@headlessui/react";
|
|
7
|
-
import cx from "classnames";
|
|
8
|
-
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
9
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import { createPortal } from "react-dom";
|
|
11
|
-
import AnimateHeight from "react-animate-height";
|
|
12
|
-
import deepEqual from "fast-deep-equal";
|
|
13
|
-
import { usePopper } from "react-popper";
|
|
14
|
-
//#region src/components/CollapsiblePanel.tsx
|
|
15
|
-
var noop = () => {};
|
|
16
|
-
function ControlledCollapsiblePanel({ title = "", children, open, setOpen, onClick = noop, wrapperElement, customizedButton = null, titleAction, className }) {
|
|
17
|
-
const toggleOpen = useCallback(() => {
|
|
18
|
-
if (onClick) onClick();
|
|
19
|
-
setOpen?.((open) => !open);
|
|
20
|
-
}, [setOpen, onClick]);
|
|
21
|
-
const contentId = React.useId();
|
|
22
|
-
const Wrapper = wrapperElement ? wrapperElement : React.Fragment;
|
|
23
|
-
return React.isValidElement(title) ? /* @__PURE__ */ jsxs(Fragment$1, { children: [title, /* @__PURE__ */ jsx(Wrapper, { children: /* @__PURE__ */ jsx(AnimateHeight, {
|
|
24
|
-
duration: 300,
|
|
25
|
-
height: open ? "auto" : 0,
|
|
26
|
-
children
|
|
27
|
-
}) })] }) : /* @__PURE__ */ jsxs("div", {
|
|
28
|
-
className: cx("border border-solid rounded-2xl border-(--theme-border) bg-(--theme-panel-bg) text-(--theme-panel) mb-1 w-full", className),
|
|
29
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
30
|
-
className: cx(!open && "text-(--theme-muted-text-color)", "w-full flex items-center transform ease-in transition text-sm py-3 px-2 cursor-pointer"),
|
|
31
|
-
children: [
|
|
32
|
-
/* @__PURE__ */ jsxs("button", {
|
|
33
|
-
type: "button",
|
|
34
|
-
"aria-expanded": !!open,
|
|
35
|
-
"aria-controls": contentId,
|
|
36
|
-
className: cx("flex items-center text-left cursor-pointer", !titleAction && "w-full"),
|
|
37
|
-
onClick: toggleOpen,
|
|
38
|
-
children: [/* @__PURE__ */ jsx(AngleRightIcon, { className: cx(open && "transform rotate-90", "px-1 ml-1 text-[1.25rem] transition ease-in") }), /* @__PURE__ */ jsx("span", {
|
|
39
|
-
className: "px-2 font-bold select-none",
|
|
40
|
-
children: title?.toString()
|
|
41
|
-
})]
|
|
42
|
-
}),
|
|
43
|
-
titleAction,
|
|
44
|
-
/* @__PURE__ */ jsx("div", {
|
|
45
|
-
className: "ml-auto",
|
|
46
|
-
children: customizedButton
|
|
47
|
-
})
|
|
48
|
-
]
|
|
49
|
-
}), /* @__PURE__ */ jsx(AnimateHeight, {
|
|
50
|
-
id: contentId,
|
|
51
|
-
duration: 300,
|
|
52
|
-
height: open ? "auto" : 0,
|
|
53
|
-
children
|
|
54
|
-
})]
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
function UncontrolledCollapsiblePanel({ title, children, onClick, wrapperElement, initialState = true, className, customizedButton = null }) {
|
|
58
|
-
const [open, setOpen] = React.useState(initialState);
|
|
59
|
-
const passTitle = typeof title === "function" ? title(open, setOpen) : title;
|
|
60
|
-
return /* @__PURE__ */ jsx(ControlledCollapsiblePanel, {
|
|
61
|
-
title: passTitle,
|
|
62
|
-
open,
|
|
63
|
-
setOpen,
|
|
64
|
-
onClick,
|
|
65
|
-
wrapperElement,
|
|
66
|
-
className,
|
|
67
|
-
customizedButton,
|
|
68
|
-
children
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
function MaybeCollapsible({ className, initialState, children, title, customizedButton, collapsible }) {
|
|
72
|
-
if (collapsible) return /* @__PURE__ */ jsx(UncontrolledCollapsiblePanel, {
|
|
73
|
-
className,
|
|
74
|
-
initialState,
|
|
75
|
-
title,
|
|
76
|
-
customizedButton,
|
|
77
|
-
children
|
|
78
|
-
});
|
|
79
|
-
return /* @__PURE__ */ jsx("div", {
|
|
80
|
-
className,
|
|
81
|
-
children
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region src/components/Dropdown.tsx
|
|
86
|
-
var defaultCollapsedLabel = (count) => `${count} more`;
|
|
87
|
-
function isNamedValue(value) {
|
|
88
|
-
return typeof value === "object" && value !== null && "name" in value && typeof value.name === "string";
|
|
89
|
-
}
|
|
90
|
-
var checkEquals = (val, opt) => {
|
|
91
|
-
if (typeof val === "object" && !Array.isArray(val)) return deepEqual(val, opt);
|
|
92
|
-
return val === opt;
|
|
93
|
-
};
|
|
94
|
-
function getOptionFromValue(value, options) {
|
|
95
|
-
if (value === void 0) return {
|
|
96
|
-
label: "",
|
|
97
|
-
value: ""
|
|
98
|
-
};
|
|
99
|
-
const found = options?.find((option) => {
|
|
100
|
-
if (typeof option === "string") return checkEquals(value, option);
|
|
101
|
-
else if (isCategory(option)) return option.options.find((opt) => checkEquals(value, opt.value));
|
|
102
|
-
else return checkEquals(value, option.value);
|
|
103
|
-
});
|
|
104
|
-
if (found) {
|
|
105
|
-
if (typeof found === "string") return {
|
|
106
|
-
label: found,
|
|
107
|
-
value: found
|
|
108
|
-
};
|
|
109
|
-
else if (isCategory(found)) return found.options.find((opt) => checkEquals(value, opt.value)) || {
|
|
110
|
-
label: JSON.stringify(value),
|
|
111
|
-
value
|
|
112
|
-
};
|
|
113
|
-
else return found;
|
|
114
|
-
}
|
|
115
|
-
const isNamedObject = isNamedValue(value);
|
|
116
|
-
const fallbackLabel = typeof value === "string" ? value : isNamedObject ? value.name : JSON.stringify(value);
|
|
117
|
-
return {
|
|
118
|
-
label: fallbackLabel,
|
|
119
|
-
value: isNamedObject ? value : fallbackLabel
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
function Dropdown(props) {
|
|
123
|
-
const { onChange, value, options = [], ...others } = props;
|
|
124
|
-
const val = useMemo(() => {
|
|
125
|
-
return getOptionFromValue(value, options);
|
|
126
|
-
}, [value, options]);
|
|
127
|
-
const wrapperOnchange = (value) => {
|
|
128
|
-
if (onChange) onChange(value?.value);
|
|
129
|
-
};
|
|
130
|
-
const transformedOptions = useMemo(() => {
|
|
131
|
-
if (!options || options.length === 0) return [];
|
|
132
|
-
return options.map((item) => {
|
|
133
|
-
if (isCategory(item)) return {
|
|
134
|
-
...item,
|
|
135
|
-
options: item.options.map((opt) => {
|
|
136
|
-
if (typeof opt === "string") return {
|
|
137
|
-
label: opt,
|
|
138
|
-
value: opt
|
|
139
|
-
};
|
|
140
|
-
return opt;
|
|
141
|
-
})
|
|
142
|
-
};
|
|
143
|
-
else if (typeof item === "string") return {
|
|
144
|
-
label: item,
|
|
145
|
-
value: item
|
|
146
|
-
};
|
|
147
|
-
return item;
|
|
148
|
-
});
|
|
149
|
-
}, [options]);
|
|
150
|
-
return /* @__PURE__ */ jsx(DropdownHelper, {
|
|
151
|
-
value: val,
|
|
152
|
-
onChange: wrapperOnchange,
|
|
153
|
-
options: transformedOptions,
|
|
154
|
-
...others
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
function ActiveWatcher({ active, onChange }) {
|
|
158
|
-
const prev = useRef(null);
|
|
159
|
-
useEffect(() => {
|
|
160
|
-
if (prev.current !== active) {
|
|
161
|
-
onChange?.(active?.value);
|
|
162
|
-
prev.current = active;
|
|
163
|
-
}
|
|
164
|
-
}, [active, onChange]);
|
|
165
|
-
return null;
|
|
166
|
-
}
|
|
167
|
-
function OptionContent({ label, description, icon }) {
|
|
168
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
169
|
-
className: cx("flex gap-1.5", description ? "items-start min-w-0" : "items-center truncate"),
|
|
170
|
-
...truncationTooltipProps(label, (anchor) => anchor.lastElementChild),
|
|
171
|
-
children: [icon, description ? /* @__PURE__ */ jsxs("span", {
|
|
172
|
-
className: "flex flex-col min-w-0",
|
|
173
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
174
|
-
className: "truncate",
|
|
175
|
-
children: label
|
|
176
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
177
|
-
className: "text-(--theme-muted-text-color) text-xs leading-snug",
|
|
178
|
-
children: description
|
|
179
|
-
})]
|
|
180
|
-
}) : /* @__PURE__ */ jsx("span", {
|
|
181
|
-
className: "truncate",
|
|
182
|
-
children: label
|
|
183
|
-
})]
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
function ToggleOption({ option, category, expanded, onToggle, ...virtualRowProps }) {
|
|
187
|
-
return /* @__PURE__ */ jsx(ComboboxOption, {
|
|
188
|
-
...virtualRowProps,
|
|
189
|
-
"data-testid": "combobox-toggle",
|
|
190
|
-
value: option,
|
|
191
|
-
className: "w-full h-10 flex items-center pl-3",
|
|
192
|
-
children: /* @__PURE__ */ jsxs("button", {
|
|
193
|
-
type: "button",
|
|
194
|
-
"aria-expanded": expanded,
|
|
195
|
-
className: "flex items-center gap-1.5 cursor-pointer text-(--theme-muted-text-color) hover:text-(--theme-app)",
|
|
196
|
-
onMouseDown: (e) => e.preventDefault(),
|
|
197
|
-
onClick: (e) => {
|
|
198
|
-
e.preventDefault();
|
|
199
|
-
e.stopPropagation();
|
|
200
|
-
onToggle(category);
|
|
201
|
-
},
|
|
202
|
-
children: [/* @__PURE__ */ jsx(CaretDownIcon, { className: cx("w-3 h-3", !expanded && "-rotate-90") }), option.label]
|
|
203
|
-
})
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
function DropdownHelper({ wrapperClassName = "w-full", className, textBoxClassName = "w-full", options = [], onChange, onActiveChange, value, id, ariaLabel, "aria-describedby": describedBy, required, disabled = false, placeholder = "", loading = false, allowCustomValue = false, customValueLabel = "Use", collapsedLabel = defaultCollapsedLabel, portalEl, compact = false }) {
|
|
207
|
-
const DEBOUNCE_MS = 500;
|
|
208
|
-
const t = useStrings().dropdown;
|
|
209
|
-
const [query, setQuery] = useState("");
|
|
210
|
-
const [selectedIconWidth, setSelectedIconWidth] = useState(0);
|
|
211
|
-
const selectedIconRef = useCallback((node) => {
|
|
212
|
-
setSelectedIconWidth(node?.offsetWidth ?? 0);
|
|
213
|
-
}, []);
|
|
214
|
-
const selectedIcon = query === "" ? value?.icon : void 0;
|
|
215
|
-
const [referenceElement, setReferenceElement] = useState(null);
|
|
216
|
-
const [popperElement, setPopperElement] = useState(null);
|
|
217
|
-
const [boundaryEl, setBoundaryEl] = useState(null);
|
|
218
|
-
useEffect(() => {
|
|
219
|
-
if (!referenceElement) {
|
|
220
|
-
setBoundaryEl(null);
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
const ref = referenceElement;
|
|
224
|
-
const dialog = ref.closest("[role=\"dialog\"]");
|
|
225
|
-
if (!dialog) {
|
|
226
|
-
setBoundaryEl(null);
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
let node = ref.parentElement;
|
|
230
|
-
while (node) {
|
|
231
|
-
const style = getComputedStyle(node);
|
|
232
|
-
if (/(auto|scroll|hidden)/.test(`${style.overflowX} ${style.overflowY}`)) {
|
|
233
|
-
setBoundaryEl(node);
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
if (node === dialog) break;
|
|
237
|
-
node = node.parentElement;
|
|
238
|
-
}
|
|
239
|
-
setBoundaryEl(dialog);
|
|
240
|
-
}, [referenceElement]);
|
|
241
|
-
const sameWidthModifier = useMemo(() => ({
|
|
242
|
-
name: "sameWidth",
|
|
243
|
-
enabled: true,
|
|
244
|
-
phase: "beforeWrite",
|
|
245
|
-
requires: ["computeStyles"],
|
|
246
|
-
fn: ({ state }) => {
|
|
247
|
-
const popperStyles = state.styles["popper"];
|
|
248
|
-
if (popperStyles) popperStyles.width = `${state.rects.reference.width}px`;
|
|
249
|
-
},
|
|
250
|
-
effect: ({ state }) => {
|
|
251
|
-
const { popper, reference } = state.elements;
|
|
252
|
-
if (reference instanceof HTMLElement) popper.style.width = `${reference.offsetWidth}px`;
|
|
253
|
-
}
|
|
254
|
-
}), []);
|
|
255
|
-
const popperModifiers = useMemo(() => boundaryEl ? [
|
|
256
|
-
sameWidthModifier,
|
|
257
|
-
{
|
|
258
|
-
name: "flip",
|
|
259
|
-
options: { boundary: boundaryEl }
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
name: "preventOverflow",
|
|
263
|
-
options: { boundary: boundaryEl }
|
|
264
|
-
}
|
|
265
|
-
] : [sameWidthModifier], [boundaryEl, sameWidthModifier]);
|
|
266
|
-
const { styles, attributes } = usePopper(referenceElement, popperElement, {
|
|
267
|
-
strategy: "fixed",
|
|
268
|
-
modifiers: popperModifiers
|
|
269
|
-
});
|
|
270
|
-
const debounceRef = useRef(null);
|
|
271
|
-
const buttonRef = useRef(null);
|
|
272
|
-
const [expandedCategories, setExpandedCategories] = useState(/* @__PURE__ */ new Set());
|
|
273
|
-
const selectedCategory = useMemo(() => options.find((o) => isCategory(o) && o.options.some((opt) => checkEquals(value.value, opt.value)))?.category, [options, value]);
|
|
274
|
-
const lastAutoExpandedValue = useRef(void 0);
|
|
275
|
-
useEffect(() => {
|
|
276
|
-
if (!selectedCategory || checkEquals(lastAutoExpandedValue.current, value.value)) return;
|
|
277
|
-
lastAutoExpandedValue.current = value.value;
|
|
278
|
-
setExpandedCategories((prev) => prev.size === 1 && prev.has(selectedCategory) ? prev : /* @__PURE__ */ new Set([selectedCategory]));
|
|
279
|
-
}, [selectedCategory, value]);
|
|
280
|
-
const toggleCategory = (category) => setExpandedCategories((prev) => toggleSetMember(prev, category));
|
|
281
|
-
const flushCustomValue = useCallback((val) => {
|
|
282
|
-
onChange({
|
|
283
|
-
label: val,
|
|
284
|
-
value: val
|
|
285
|
-
});
|
|
286
|
-
}, [onChange]);
|
|
287
|
-
const onQueryChange = (val) => {
|
|
288
|
-
setQuery(val);
|
|
289
|
-
if (allowCustomValue) {
|
|
290
|
-
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
291
|
-
debounceRef.current = setTimeout(() => {
|
|
292
|
-
flushCustomValue(val);
|
|
293
|
-
debounceRef.current = null;
|
|
294
|
-
}, DEBOUNCE_MS);
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
const onInputBlur = () => {
|
|
298
|
-
if (allowCustomValue && debounceRef.current) {
|
|
299
|
-
clearTimeout(debounceRef.current);
|
|
300
|
-
debounceRef.current = null;
|
|
301
|
-
flushCustomValue(query);
|
|
302
|
-
}
|
|
303
|
-
setQuery("");
|
|
304
|
-
};
|
|
305
|
-
const onComboboxChange = (val) => {
|
|
306
|
-
if (debounceRef.current) {
|
|
307
|
-
clearTimeout(debounceRef.current);
|
|
308
|
-
debounceRef.current = null;
|
|
309
|
-
}
|
|
310
|
-
onChange(val);
|
|
311
|
-
};
|
|
312
|
-
const flattenedOptions = useMemo(() => flattenDisplayOptions({
|
|
313
|
-
options,
|
|
314
|
-
query,
|
|
315
|
-
expandedCategories,
|
|
316
|
-
collapsedLabel,
|
|
317
|
-
selectedValue: value?.value,
|
|
318
|
-
allowCustomValue,
|
|
319
|
-
customValueLabel
|
|
320
|
-
}), [
|
|
321
|
-
options,
|
|
322
|
-
query,
|
|
323
|
-
expandedCategories,
|
|
324
|
-
collapsedLabel,
|
|
325
|
-
value,
|
|
326
|
-
allowCustomValue,
|
|
327
|
-
customValueLabel
|
|
328
|
-
]);
|
|
329
|
-
const comboOptions = /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(ComboboxOptions, {
|
|
330
|
-
modal: false,
|
|
331
|
-
ref: setPopperElement,
|
|
332
|
-
style: styles["popper"],
|
|
333
|
-
className: cx("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 z-9999 data-[popper-reference-hidden=true]:invisible data-[popper-reference-hidden=true]:pointer-events-none", compact ? "text-xs" : "sm:text-sm"),
|
|
334
|
-
...attributes["popper"],
|
|
335
|
-
children: ({ option }) => {
|
|
336
|
-
const optionLabel = typeof option === "string" ? option : option.label;
|
|
337
|
-
const optionDescription = typeof option !== "string" ? option.description : void 0;
|
|
338
|
-
const isCategoryRow = typeof option !== "string" && Boolean(option.category);
|
|
339
|
-
const toggleTarget = typeof option !== "string" ? option.toggle : void 0;
|
|
340
|
-
const isPinned = typeof option !== "string" && Boolean(option.pinned);
|
|
341
|
-
if (toggleTarget !== void 0) return /* @__PURE__ */ jsx(ToggleOption, {
|
|
342
|
-
option,
|
|
343
|
-
category: toggleTarget,
|
|
344
|
-
expanded: expandedCategories.has(toggleTarget),
|
|
345
|
-
onToggle: toggleCategory
|
|
346
|
-
});
|
|
347
|
-
return /* @__PURE__ */ jsx(ComboboxOption, {
|
|
348
|
-
"data-testid": "combobox-option",
|
|
349
|
-
value: option,
|
|
350
|
-
className: cx("w-full group relative flex", optionDescription ? "min-h-10 py-2" : compact ? "h-8" : "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)", isPinned && "border-t border-(--theme-border) font-medium"),
|
|
351
|
-
children: /* @__PURE__ */ jsx(OptionContent, {
|
|
352
|
-
label: optionLabel,
|
|
353
|
-
description: optionDescription,
|
|
354
|
-
icon: typeof option !== "string" && option.icon
|
|
355
|
-
})
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
}) });
|
|
359
|
-
return /* @__PURE__ */ jsx("div", {
|
|
360
|
-
className: cx("relative rounded-md flex items-center", wrapperClassName),
|
|
361
|
-
children: /* @__PURE__ */ jsx(Combobox, {
|
|
362
|
-
"data-testid": "combobox",
|
|
363
|
-
className: cx("relative w-full", className),
|
|
364
|
-
as: "div",
|
|
365
|
-
by: checkEquals,
|
|
366
|
-
value,
|
|
367
|
-
onChange: onComboboxChange,
|
|
368
|
-
onClose: () => {
|
|
369
|
-
setQuery("");
|
|
370
|
-
setExpandedCategories(new Set(selectedCategory ? [selectedCategory] : []));
|
|
371
|
-
},
|
|
372
|
-
immediate: true,
|
|
373
|
-
virtual: {
|
|
374
|
-
options: flattenedOptions,
|
|
375
|
-
disabled: (option) => Boolean(option.disabled)
|
|
376
|
-
},
|
|
377
|
-
disabled,
|
|
378
|
-
children: ({ activeOption, open }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
379
|
-
onActiveChange && /* @__PURE__ */ jsx(ActiveWatcher, {
|
|
380
|
-
active: activeOption,
|
|
381
|
-
onChange: onActiveChange
|
|
382
|
-
}),
|
|
383
|
-
selectedIcon && /* @__PURE__ */ jsx("span", {
|
|
384
|
-
ref: selectedIconRef,
|
|
385
|
-
className: "pointer-events-none absolute inset-y-0 left-3 z-10 flex items-center",
|
|
386
|
-
children: selectedIcon
|
|
387
|
-
}, value.label),
|
|
388
|
-
/* @__PURE__ */ jsx(ComboboxInput, {
|
|
389
|
-
id,
|
|
390
|
-
"aria-label": ariaLabel || void 0,
|
|
391
|
-
"aria-describedby": describedBy,
|
|
392
|
-
"aria-required": required || void 0,
|
|
393
|
-
placeholder: loading ? "Loading..." : placeholder,
|
|
394
|
-
onBlur: onInputBlur,
|
|
395
|
-
ref: setReferenceElement,
|
|
396
|
-
onClick: () => {
|
|
397
|
-
if (!open) buttonRef.current?.click();
|
|
398
|
-
},
|
|
399
|
-
style: selectedIcon && selectedIconWidth > 0 ? { paddingLeft: selectedIconWidth + 18 } : void 0,
|
|
400
|
-
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),
|
|
401
|
-
autoComplete: "off",
|
|
402
|
-
onChange: (event) => onQueryChange(event.target.value),
|
|
403
|
-
displayValue: (opt) => {
|
|
404
|
-
return opt?.label?.replaceAll("\"", "") || query || "";
|
|
405
|
-
},
|
|
406
|
-
disabled
|
|
407
|
-
}),
|
|
408
|
-
/* @__PURE__ */ jsx(ComboboxButton, {
|
|
409
|
-
ref: buttonRef,
|
|
410
|
-
"aria-label": t.showOptions,
|
|
411
|
-
className: "absolute inset-y-0 right-0 flex items-center pr-3 disabled:cursor-not-allowed",
|
|
412
|
-
"data-testid": "combobox-button",
|
|
413
|
-
disabled,
|
|
414
|
-
children: /* @__PURE__ */ jsx(DropdownCaret, {})
|
|
415
|
-
}),
|
|
416
|
-
typeof document !== "undefined" && createPortal(comboOptions, portalEl ?? document.querySelector(".ds-root") ?? document.body)
|
|
417
|
-
] })
|
|
418
|
-
})
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
//#endregion
|
|
422
|
-
//#region src/components/Listbox.tsx
|
|
423
|
-
function CustomListbox({ options = [], handleOptionSelected, type, allowSearch = false, closeOnSelect = true, className = "", invalid = false, required = false, id, "aria-describedby": describedBy }) {
|
|
424
|
-
const { dropdown: strings } = useStrings();
|
|
425
|
-
const [filter, setFilter] = useState("");
|
|
426
|
-
const [controlledOpen, setControlledOpen] = useState(false);
|
|
427
|
-
const optionsToShow = options.filter((option) => !option.selected && option.label && option.label.toLowerCase().includes(filter.toLowerCase()));
|
|
428
|
-
function useOutsideAlerter(ref) {
|
|
429
|
-
useEffect(() => {
|
|
430
|
-
function handleClickOutside(event) {
|
|
431
|
-
if (ref.current && event.target instanceof Node && !ref.current.contains(event.target)) {
|
|
432
|
-
setControlledOpen(false);
|
|
433
|
-
setFilter("");
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
437
|
-
return () => {
|
|
438
|
-
document.removeEventListener("mousedown", handleClickOutside);
|
|
439
|
-
};
|
|
440
|
-
}, [ref]);
|
|
441
|
-
}
|
|
442
|
-
const wrapperRef = useRef(null);
|
|
443
|
-
useOutsideAlerter(wrapperRef);
|
|
444
|
-
const optionsElement = /* @__PURE__ */ jsxs(ListboxOptions, {
|
|
445
|
-
modal: false,
|
|
446
|
-
static: true,
|
|
447
|
-
className: "absolute w-full py-1 z-50 theme-input rounded-md",
|
|
448
|
-
children: [allowSearch && /* @__PURE__ */ jsx("div", {
|
|
449
|
-
className: "pl-2 pr-4 mb-1",
|
|
450
|
-
children: /* @__PURE__ */ jsx("input", {
|
|
451
|
-
autoComplete: "off",
|
|
452
|
-
type: "search",
|
|
453
|
-
ref: focusOnMount,
|
|
454
|
-
onChange: (e) => setFilter(e.target.value),
|
|
455
|
-
value: filter,
|
|
456
|
-
className: "w-full p-1 theme-input",
|
|
457
|
-
onKeyDown: (e) => {
|
|
458
|
-
if (![
|
|
459
|
-
"ArrowUp",
|
|
460
|
-
"ArrowDown",
|
|
461
|
-
"Enter",
|
|
462
|
-
"Home",
|
|
463
|
-
"End",
|
|
464
|
-
"Escape"
|
|
465
|
-
].includes(e.key)) e.stopPropagation();
|
|
466
|
-
}
|
|
467
|
-
})
|
|
468
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
469
|
-
className: "overflow-auto max-h-60 theme-panel",
|
|
470
|
-
children: optionsToShow.length > 0 ? keyedByContent(optionsToShow, (o) => String(o.value)).map(({ key, item: option }) => /* @__PURE__ */ jsx(ListboxOption, {
|
|
471
|
-
className: "relative hover:theme-hover select-none pl-2 pr-4",
|
|
472
|
-
value: option.value,
|
|
473
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
474
|
-
className: "w-full flex flex-row",
|
|
475
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
476
|
-
className: "w-3/4 py-2 flex items-center",
|
|
477
|
-
children: [
|
|
478
|
-
/* @__PURE__ */ jsx("div", {
|
|
479
|
-
className: "w-4 h-6 btn btn-info text-xl line-height-0 mr-2",
|
|
480
|
-
children: "+"
|
|
481
|
-
}),
|
|
482
|
-
option.icon && /* @__PURE__ */ jsx("span", {
|
|
483
|
-
className: "mr-2 flex items-center",
|
|
484
|
-
children: option.icon
|
|
485
|
-
}),
|
|
486
|
-
/* @__PURE__ */ jsx("span", {
|
|
487
|
-
className: "mr-2",
|
|
488
|
-
children: option.label
|
|
489
|
-
}),
|
|
490
|
-
/* @__PURE__ */ jsx("span", {
|
|
491
|
-
className: "italic",
|
|
492
|
-
children: option.secondaryLabel
|
|
493
|
-
})
|
|
494
|
-
]
|
|
495
|
-
})
|
|
496
|
-
})
|
|
497
|
-
}, key)) : /* @__PURE__ */ jsx("div", {
|
|
498
|
-
className: "w-full flex flex-row",
|
|
499
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
500
|
-
className: "w-3/4 py-2 pl-2 capitalize flex items-center",
|
|
501
|
-
children: filter === "" ? `All ${type} Added` : `No ${type} Found`
|
|
502
|
-
})
|
|
503
|
-
})
|
|
504
|
-
})]
|
|
505
|
-
});
|
|
506
|
-
return /* @__PURE__ */ jsxs(Listbox, {
|
|
507
|
-
as: "div",
|
|
508
|
-
className: cx("relative mt-1 theme-input border theme-border rounded-md", className),
|
|
509
|
-
ref: wrapperRef,
|
|
510
|
-
onChange: handleOptionSelected,
|
|
511
|
-
children: [/* @__PURE__ */ jsxs(ListboxButton, {
|
|
512
|
-
id,
|
|
513
|
-
"aria-describedby": describedBy,
|
|
514
|
-
"aria-required": required || void 0,
|
|
515
|
-
onClick: () => setControlledOpen((prev) => !prev),
|
|
516
|
-
className: cx("relative w-full py-2 pl-3 text-left", invalid && "border-red-600 focus:border-red-600 focus:ring-red-500"),
|
|
517
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
518
|
-
className: "block truncate",
|
|
519
|
-
children: strings.select(type)
|
|
520
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
521
|
-
className: "pointer-events-none absolute inset-y-0 right-0 flex items-center justify-items-center",
|
|
522
|
-
children: /* @__PURE__ */ jsx(AngleDownIcon, {
|
|
523
|
-
className: "h-5 w-8",
|
|
524
|
-
"aria-hidden": "true"
|
|
525
|
-
})
|
|
526
|
-
})]
|
|
527
|
-
}), closeOnSelect ? /* @__PURE__ */ jsx(Transition, {
|
|
528
|
-
leave: "transition ease-in duration-100",
|
|
529
|
-
leaveFrom: "opacity-100",
|
|
530
|
-
leaveTo: "opacity-0",
|
|
531
|
-
children: optionsElement || null
|
|
532
|
-
}) : /* @__PURE__ */ jsx(Fragment$1, { children: controlledOpen && optionsElement })]
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
//#endregion
|
|
536
|
-
//#region src/components/MultiSelect.tsx
|
|
537
|
-
function MultiSelectDropdown({ options, value, onChange, id, "aria-labelledby": labelledBy, "aria-describedby": describedBy, required, className, wrapperClassName = "w-full", textBoxClassName, disabled = false, placeholder, loading = false, searchable = true, maxTagCount = 2, compareBy }) {
|
|
538
|
-
const strings = useStrings();
|
|
539
|
-
const [query, setQuery] = useState("");
|
|
540
|
-
const [referenceEl, setReferenceEl] = useState(null);
|
|
541
|
-
const [popperEl, setPopperEl] = useState(null);
|
|
542
|
-
const { styles, attributes } = usePopper(referenceEl, popperEl, {
|
|
543
|
-
placement: "bottom-start",
|
|
544
|
-
modifiers: [{
|
|
545
|
-
name: "offset",
|
|
546
|
-
options: { offset: [0, 4] }
|
|
547
|
-
}]
|
|
548
|
-
});
|
|
549
|
-
const allOptions = useMemo(() => flattenOptions(options), [options]);
|
|
550
|
-
const compare = compareBy ?? ((a, b) => a === b);
|
|
551
|
-
const selectedOptions = useMemo(() => {
|
|
552
|
-
const result = [];
|
|
553
|
-
for (const val of value) {
|
|
554
|
-
const found = allOptions.find((opt) => isOption(opt) && compare(opt.value, val));
|
|
555
|
-
if (found) result.push(found);
|
|
556
|
-
}
|
|
557
|
-
return result;
|
|
558
|
-
}, [
|
|
559
|
-
value,
|
|
560
|
-
allOptions,
|
|
561
|
-
compare
|
|
562
|
-
]);
|
|
563
|
-
const filteredOptions = useMemo(() => {
|
|
564
|
-
if (!searchable || query.trim() === "") return allOptions;
|
|
565
|
-
const result = [];
|
|
566
|
-
for (const opt of allOptions) if (isCategory(opt)) {
|
|
567
|
-
const matchedChildren = (Array.isArray(opt.options) ? opt.options : []).filter((o) => filterOption(o, query));
|
|
568
|
-
if (matchedChildren.length > 0) result.push(opt, ...matchedChildren);
|
|
569
|
-
} else if (isOption(opt) && filterOption(opt, query)) result.push(opt);
|
|
570
|
-
return result;
|
|
571
|
-
}, [
|
|
572
|
-
allOptions,
|
|
573
|
-
query,
|
|
574
|
-
searchable
|
|
575
|
-
]);
|
|
576
|
-
const display = useMemo(() => {
|
|
577
|
-
const shown = selectedOptions.slice(0, maxTagCount);
|
|
578
|
-
return {
|
|
579
|
-
label: shown.map((o) => o.label).join(", "),
|
|
580
|
-
overflow: selectedOptions.length - shown.length
|
|
581
|
-
};
|
|
582
|
-
}, [selectedOptions, maxTagCount]);
|
|
583
|
-
const handleChange = useCallback((newValues) => {
|
|
584
|
-
if (!Array.isArray(newValues)) return;
|
|
585
|
-
onChange(newValues);
|
|
586
|
-
}, [onChange]);
|
|
587
|
-
const isDisabled = disabled || loading;
|
|
588
|
-
const isEmpty = filteredOptions.length === 0;
|
|
589
|
-
return /* @__PURE__ */ jsx(Combobox, {
|
|
590
|
-
multiple: true,
|
|
591
|
-
value: Array.isArray(value) ? value : [],
|
|
592
|
-
onChange: handleChange,
|
|
593
|
-
disabled: isDisabled,
|
|
594
|
-
onClose: () => setQuery(""),
|
|
595
|
-
by: compare,
|
|
596
|
-
children: ({ open }) => /* @__PURE__ */ jsxs("div", {
|
|
597
|
-
ref: setReferenceEl,
|
|
598
|
-
className: cx("relative", wrapperClassName),
|
|
599
|
-
children: [
|
|
600
|
-
/* @__PURE__ */ jsx(ComboboxButton, {
|
|
601
|
-
as: "div",
|
|
602
|
-
id,
|
|
603
|
-
"aria-labelledby": labelledBy,
|
|
604
|
-
"aria-describedby": describedBy,
|
|
605
|
-
"aria-required": required || void 0,
|
|
606
|
-
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),
|
|
607
|
-
children: loading ? /* @__PURE__ */ jsx("span", {
|
|
608
|
-
className: "theme-muted-text",
|
|
609
|
-
children: strings.loading
|
|
610
|
-
}) : selectedOptions.length > 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
611
|
-
className: "min-w-0 truncate",
|
|
612
|
-
children: display.label
|
|
613
|
-
}), display.overflow > 0 && /* @__PURE__ */ jsxs("span", {
|
|
614
|
-
className: "ml-1 shrink-0 theme-muted-text",
|
|
615
|
-
children: ["+", display.overflow]
|
|
616
|
-
})] }) : /* @__PURE__ */ jsx("span", {
|
|
617
|
-
className: "theme-muted-text truncate",
|
|
618
|
-
children: placeholder
|
|
619
|
-
})
|
|
620
|
-
}),
|
|
621
|
-
/* @__PURE__ */ jsx(DropdownCaret, {}),
|
|
622
|
-
open && /* @__PURE__ */ jsxs(ComboboxOptions, {
|
|
623
|
-
modal: false,
|
|
624
|
-
ref: setPopperEl,
|
|
625
|
-
static: true,
|
|
626
|
-
"data-testid": "msd-list",
|
|
627
|
-
style: styles["popper"],
|
|
628
|
-
...attributes["popper"],
|
|
629
|
-
className: "theme-panel z-10 max-h-60 w-full overflow-auto rounded-md shadow-lg focus:outline-none",
|
|
630
|
-
children: [searchable && /* @__PURE__ */ jsx("div", {
|
|
631
|
-
className: "sticky top-0 theme-panel p-2 border-b z-10",
|
|
632
|
-
children: /* @__PURE__ */ jsx("input", {
|
|
633
|
-
placeholder,
|
|
634
|
-
"data-1p-ignore": true,
|
|
635
|
-
autoComplete: "off",
|
|
636
|
-
type: "text",
|
|
637
|
-
className: "theme-input w-full",
|
|
638
|
-
value: query,
|
|
639
|
-
onChange: (e) => setQuery(e.target.value),
|
|
640
|
-
onKeyDown: (e) => e.stopPropagation(),
|
|
641
|
-
ref: focusOnMount
|
|
642
|
-
})
|
|
643
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
644
|
-
className: "py-1",
|
|
645
|
-
children: isEmpty ? /* @__PURE__ */ jsx("div", {
|
|
646
|
-
className: "px-4 py-2 text-sm theme-muted-text",
|
|
647
|
-
children: strings.dropdown.noOptionsFound
|
|
648
|
-
}) : keyedByContent(filteredOptions, (o) => isCategory(o) ? `category-${o.category ?? "uncat"}` : `option-${String(o.value)}`).map(({ key, item: opt }) => {
|
|
649
|
-
if (isCategory(opt)) return /* @__PURE__ */ jsx("li", {
|
|
650
|
-
role: "presentation",
|
|
651
|
-
className: "px-4 py-2 text-sm font-bold theme-muted-text",
|
|
652
|
-
children: opt.category
|
|
653
|
-
}, key);
|
|
654
|
-
const option = opt;
|
|
655
|
-
return /* @__PURE__ */ jsx(ComboboxOption, {
|
|
656
|
-
value: option.value,
|
|
657
|
-
disabled: option.disabled ?? false,
|
|
658
|
-
"data-testid": `msd-option-${String(option.value)}`,
|
|
659
|
-
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"),
|
|
660
|
-
children: ({ selected }) => /* @__PURE__ */ jsxs("div", {
|
|
661
|
-
className: "flex items-center",
|
|
662
|
-
children: [
|
|
663
|
-
/* @__PURE__ */ jsx("span", {
|
|
664
|
-
className: "absolute inset-y-0 left-0 flex items-center pl-3",
|
|
665
|
-
children: /* @__PURE__ */ jsx("input", {
|
|
666
|
-
autoComplete: "off",
|
|
667
|
-
type: "checkbox",
|
|
668
|
-
checked: selected,
|
|
669
|
-
readOnly: true,
|
|
670
|
-
tabIndex: -1,
|
|
671
|
-
className: "h-4 w-4 cursor-pointer",
|
|
672
|
-
"aria-hidden": "true"
|
|
673
|
-
})
|
|
674
|
-
}),
|
|
675
|
-
option.icon && /* @__PURE__ */ jsx("span", {
|
|
676
|
-
className: "mr-2 flex items-center",
|
|
677
|
-
children: option.icon
|
|
678
|
-
}),
|
|
679
|
-
/* @__PURE__ */ jsx("div", {
|
|
680
|
-
className: "flex flex-col",
|
|
681
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
682
|
-
className: "block truncate",
|
|
683
|
-
children: option.label
|
|
684
|
-
})
|
|
685
|
-
})
|
|
686
|
-
]
|
|
687
|
-
})
|
|
688
|
-
}, key);
|
|
689
|
-
})
|
|
690
|
-
})]
|
|
691
|
-
})
|
|
692
|
-
]
|
|
693
|
-
})
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
//#endregion
|
|
697
|
-
//#region src/components/SectionHeader.tsx
|
|
698
|
-
function SectionHeader({ children, className = "", size = "md" }) {
|
|
699
|
-
return /* @__PURE__ */ jsx("div", {
|
|
700
|
-
className: cx("w-full font-semibold", size === "sm" ? "mb-2 text-sm theme-text" : "text-lg", className),
|
|
701
|
-
children
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
|
-
//#endregion
|
|
705
|
-
//#region src/components/SwitchToggle.tsx
|
|
706
|
-
function SwitchToggle({ onChange, id, "aria-describedby": describedBy, value = void 0, yesLabel = "Yes", noLabel = "No", disabled = false, datatip = "", invalid = false }) {
|
|
707
|
-
const [enabled, setEnabled] = useState(value ?? false);
|
|
708
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
709
|
-
const setIsEnabled = (e) => {
|
|
710
|
-
setEnabled(e);
|
|
711
|
-
onChange(e);
|
|
712
|
-
};
|
|
713
|
-
useEffect(() => {
|
|
714
|
-
if (value !== void 0) setEnabled(value);
|
|
715
|
-
}, [value]);
|
|
716
|
-
const checked = value ?? enabled;
|
|
717
|
-
return /* @__PURE__ */ jsx("div", {
|
|
718
|
-
...datatip ? {
|
|
719
|
-
"data-tooltip-content": datatip,
|
|
720
|
-
"data-tooltip-id": TOOLTIP_ID
|
|
721
|
-
} : {},
|
|
722
|
-
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)]"),
|
|
723
|
-
children: /* @__PURE__ */ jsx(Switch, {
|
|
724
|
-
id,
|
|
725
|
-
"aria-describedby": describedBy,
|
|
726
|
-
checked,
|
|
727
|
-
onChange: setIsEnabled,
|
|
728
|
-
className: "text-white text-sm shadow-sm rounded-md cursor-pointer",
|
|
729
|
-
onClick: (e) => e.stopPropagation(),
|
|
730
|
-
onFocus: () => setIsFocused(true),
|
|
731
|
-
onBlur: () => setIsFocused(false),
|
|
732
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
733
|
-
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"),
|
|
734
|
-
children: [
|
|
735
|
-
/* @__PURE__ */ jsx("div", {
|
|
736
|
-
className: "inline text-center capitalize px-2 py-1 w-[99px] border-0",
|
|
737
|
-
style: {
|
|
738
|
-
background: `linear-gradient(
|
|
739
|
-
to bottom,
|
|
740
|
-
var(--theme-element, #04c) 0%,
|
|
741
|
-
var(--theme-element, #08c) 100%
|
|
742
|
-
)`,
|
|
743
|
-
color: "var(--theme-element-text, #ffffff)"
|
|
744
|
-
},
|
|
745
|
-
children: yesLabel
|
|
746
|
-
}),
|
|
747
|
-
/* @__PURE__ */ jsx("div", { className: "inline px-2 py-1 h-8 w-[99px] bg-linear-to-b from-white to-[#e6e6e6]" }),
|
|
748
|
-
/* @__PURE__ */ jsx("div", {
|
|
749
|
-
className: "inline text-center capitalize px-2 py-1 w-[99px] bg-linear-to-b from-[#e6e6e6] to-white bg-[#04c] text-black",
|
|
750
|
-
children: noLabel
|
|
751
|
-
})
|
|
752
|
-
]
|
|
753
|
-
})
|
|
754
|
-
})
|
|
755
|
-
});
|
|
756
|
-
}
|
|
757
|
-
//#endregion
|
|
758
|
-
export { Dropdown as a, UncontrolledCollapsiblePanel as c, CustomListbox as i, SectionHeader as n, ControlledCollapsiblePanel as o, MultiSelectDropdown as r, MaybeCollapsible as s, SwitchToggle as t };
|