@parallelworks/ui 0.18.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/README.md +86 -6
- package/dist/ai/adapter/memoryStore.d.ts +8 -0
- package/dist/ai/adapter/memoryStore.js +152 -0
- package/dist/ai/adapter/mock/index.d.ts +2 -0
- package/dist/ai/adapter/mock/index.js +3 -0
- package/dist/ai/adapter/mock/mockAdapter.d.ts +4 -0
- package/dist/ai/adapter/mock/mockAdapter.js +81 -0
- package/dist/ai/adapter/openai/createOpenAIStream.d.ts +9 -0
- package/dist/ai/adapter/openai/createOpenAIStream.js +33 -0
- package/dist/ai/adapter/openai/errors.d.ts +3 -0
- package/dist/ai/adapter/openai/errors.js +37 -0
- package/dist/ai/adapter/openai/index.d.ts +6 -0
- package/dist/ai/adapter/openai/index.js +6 -0
- package/dist/ai/adapter/openai/openaiAdapter.d.ts +9 -0
- package/dist/ai/adapter/openai/openaiAdapter.js +54 -0
- package/dist/ai/adapter/openai/responses.d.ts +4 -0
- package/dist/ai/adapter/openai/responses.js +108 -0
- package/dist/ai/adapter/openai/sse.d.ts +24 -0
- package/dist/ai/adapter/openai/sse.js +112 -0
- package/dist/ai/adapter/openai/wire.d.ts +40 -0
- package/dist/ai/adapter/types.d.ts +131 -0
- package/dist/ai/adapter/types.js +11 -0
- package/dist/ai/agent/classifier.d.ts +2 -0
- package/dist/ai/agent/classifier.js +12 -0
- package/dist/ai/agent/diff.d.ts +35 -0
- package/dist/ai/agent/diff.js +223 -0
- package/dist/ai/agent/diffHighlight.d.ts +6 -0
- package/dist/ai/agent/diffHighlight.js +101 -0
- package/dist/ai/agent/index.d.ts +6 -0
- package/dist/ai/agent/permissions.d.ts +11 -0
- package/dist/ai/agent/permissions.js +29 -0
- package/dist/ai/agent/toolfmt.d.ts +18 -0
- package/dist/ai/agent/toolfmt.js +383 -0
- package/dist/ai/agent/transcript.d.ts +38 -0
- package/dist/ai/agent/transcript.js +127 -0
- package/dist/ai/ai.css +325 -0
- package/dist/ai/components/AllocationSelector.d.ts +4 -0
- package/dist/ai/components/AllocationSelector.js +56 -0
- package/dist/ai/components/AttachmentManager.d.ts +1 -0
- package/dist/ai/components/AttachmentManager.js +144 -0
- package/dist/ai/components/AttachmentUpload.d.ts +24 -0
- package/dist/ai/components/AttachmentUpload.js +179 -0
- package/dist/ai/components/BlockedGroupBanner.d.ts +1 -0
- package/dist/ai/components/BlockedGroupBanner.js +29 -0
- package/dist/ai/components/BranchNavigator.d.ts +8 -0
- package/dist/ai/components/BranchNavigator.js +57 -0
- package/dist/ai/components/ChatEmptyState.d.ts +3 -0
- package/dist/ai/components/ChatEmptyState.js +171 -0
- package/dist/ai/components/ChatInput.d.ts +45 -0
- package/dist/ai/components/ChatInput.js +265 -0
- package/dist/ai/components/ChatLayout.d.ts +5 -0
- package/dist/ai/components/ChatLayout.js +15 -0
- package/dist/ai/components/ChatMessage.d.ts +24 -0
- package/dist/ai/components/ChatMessage.js +338 -0
- package/dist/ai/components/ChatMessageList.d.ts +35 -0
- package/dist/ai/components/ChatMessageList.js +301 -0
- package/dist/ai/components/ChatSidebar.d.ts +5 -0
- package/dist/ai/components/ChatSidebar.js +345 -0
- package/dist/ai/components/ChatThread.d.ts +3 -0
- package/dist/ai/components/ChatThread.js +198 -0
- package/dist/ai/components/ComposerChrome.d.ts +18 -0
- package/dist/ai/components/ComposerChrome.js +50 -0
- package/dist/ai/components/ComposerFrame.d.ts +16 -0
- package/dist/ai/components/ComposerFrame.js +33 -0
- package/dist/ai/components/DragOverlay.d.ts +5 -0
- package/dist/ai/components/DragOverlay.js +20 -0
- package/dist/ai/components/ModelSelector.d.ts +6 -0
- package/dist/ai/components/ModelSelector.js +343 -0
- package/dist/ai/components/ShareDialog.d.ts +11 -0
- package/dist/ai/components/ShareDialog.js +260 -0
- package/dist/ai/components/SlashMenu.d.ts +28 -0
- package/dist/ai/components/SlashMenu.js +91 -0
- package/dist/ai/components/agent/ActivityLine.d.ts +21 -0
- package/dist/ai/components/agent/ActivityLine.js +151 -0
- package/dist/ai/components/agent/AgentMessageParts.d.ts +54 -0
- package/dist/ai/components/agent/AgentMessageParts.js +721 -0
- package/dist/ai/components/agent/PermissionPicker.d.ts +11 -0
- package/dist/ai/components/agent/PermissionPicker.js +38 -0
- package/dist/ai/components/attachmentKeys.d.ts +4 -0
- package/dist/ai/components/attachmentKeys.js +10 -0
- package/dist/ai/core/ChatProvider.d.ts +66 -0
- package/dist/ai/core/ChatProvider.js +848 -0
- package/dist/ai/core/KeyboardShortcutsProvider.d.ts +5 -0
- package/dist/ai/core/KeyboardShortcutsProvider.js +9 -0
- package/dist/ai/core/chatReducer.d.ts +114 -0
- package/dist/ai/core/chatReducer.js +223 -0
- package/dist/ai/core/config.d.ts +47 -0
- package/dist/ai/core/config.js +45 -0
- package/dist/ai/core/events.d.ts +1 -0
- package/dist/ai/core/events.js +4 -0
- package/dist/ai/core/exportConversation.d.ts +4 -0
- package/dist/ai/core/exportConversation.js +42 -0
- package/dist/ai/core/greeting.d.ts +3 -0
- package/dist/ai/core/greeting.js +38 -0
- package/dist/ai/core/parts.d.ts +11 -0
- package/dist/ai/core/parts.js +84 -0
- package/dist/ai/core/useDragDrop.d.ts +14 -0
- package/dist/ai/core/useDragDrop.js +36 -0
- package/dist/ai/core/useKeyboardShortcuts.d.ts +12 -0
- package/dist/ai/core/useKeyboardShortcuts.js +77 -0
- package/dist/ai/core/useSSEStream.d.ts +34 -0
- package/dist/ai/core/useSSEStream.js +98 -0
- package/dist/ai/index.d.ts +40 -0
- package/dist/ai/index.js +44 -0
- package/dist/ai/strings.d.ts +167 -0
- package/dist/ai/strings.js +175 -0
- package/dist/ai/types.d.ts +236 -0
- package/dist/ai/ui/Avatar.d.ts +8 -0
- package/dist/ai/ui/Avatar.js +35 -0
- package/dist/ai/ui/Dropdown.d.ts +31 -0
- package/dist/ai/ui/Dropdown.js +110 -0
- package/dist/ai/ui/Markdown.d.ts +8 -0
- package/dist/ai/ui/Markdown.js +79 -0
- package/dist/ai/ui/Notice.d.ts +21 -0
- package/dist/ai/ui/Notice.js +77 -0
- package/dist/ai/ui/buttons.d.ts +1 -0
- package/dist/ai/ui/codeBreaks.d.ts +16 -0
- package/dist/ai/ui/codeBreaks.js +36 -0
- package/dist/ai/ui/prose.d.ts +1 -0
- package/dist/ai/ui/prose.js +13 -0
- package/dist/ai/ui/sidebar.d.ts +81 -0
- package/dist/ai/ui/sidebar.js +148 -0
- package/dist/ai/utils.d.ts +4 -0
- package/dist/ai/utils.js +23 -0
- package/dist/assets/{editor.worker-CuBRIwi-.js → editor.worker-BmHUIVG4.js} +194 -163
- package/dist/assets/{json.worker-8ytS02vz.js → json.worker-D8bJ92nw.js} +384 -338
- package/dist/assets/{yaml.worker-DJC-VUcv.js → yaml.worker-C4gyGAko.js} +15657 -13823
- package/dist/components/AddMenu.js +46 -0
- package/dist/components/Avatar.d.ts +1 -1
- package/dist/components/Avatar.js +46 -0
- package/dist/{chunks/BareModal-BtRiQezg.js → components/BareModal.js} +1 -1
- package/dist/components/Breadcrumbs.d.ts +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/components/ConfirmModal.js +74 -0
- package/dist/components/CopyToClipboard.js +81 -0
- package/dist/{chunks/CreateModal-BY6DLmur.js → components/CreateModal.js} +10 -189
- package/dist/components/DescriptionList.js +42 -0
- package/dist/components/Dropdown.d.ts +1 -1
- package/dist/components/Dropdown.js +349 -0
- package/dist/components/EmptyState.d.ts +1 -1
- 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/components/Indicator.d.ts +2 -2
- package/dist/{chunks/Indicator-hBSIxOPK.js → components/Indicator.js} +1 -1
- package/dist/components/Input.d.ts +1 -1
- package/dist/components/Input.js +88 -0
- package/dist/components/LetterBadge.d.ts +1 -1
- 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/MarkdownImpl.d.ts +1 -1
- 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/components/Provider.d.ts +16 -65
- package/dist/{chunks/Provider-Ghua9PkN.js → components/Provider.js} +54 -20
- 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.d.ts +1 -1
- package/dist/components/SettingRow.js +35 -0
- package/dist/components/SettingsCard.js +31 -0
- package/dist/components/SettingsGroup.d.ts +1 -1
- 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-4OHjdKdO.js → components/Table.js} +7 -5
- package/dist/components/Toggle.js +20 -0
- package/dist/{chunks/Tooltip-Crxo_eU_.js → components/Tooltip.js} +6 -4
- package/dist/{chunks/StatusBadge-C1Blx_cW.js → components/dropdownUtils.js} +2 -63
- package/dist/components/focus.d.ts +2 -0
- package/dist/components/focus.js +7 -0
- package/dist/components/ghostButton.js +7 -0
- package/dist/components/inputClasses.js +4 -0
- package/dist/components/keys.d.ts +12 -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/duration.d.ts +3 -0
- package/dist/duration.js +17 -0
- package/dist/editor/Editor.js +13 -0
- package/dist/editor/EditorField.js +53 -0
- package/dist/editor/FormCodePanel.js +173 -0
- package/dist/editor/Monaco.d.ts +1 -20
- package/dist/editor/Monaco.js +112 -0
- package/dist/editor/index.d.ts +2 -1
- package/dist/editor/index.js +7 -2
- package/dist/editor/themes.js +91 -0
- package/dist/editor/workers.js +29 -0
- package/dist/editor/yaml.d.ts +5 -0
- package/dist/editor/yaml.js +15 -0
- package/dist/engine.d.ts +98 -0
- package/dist/file-explorer/FileExplorer.d.ts +11 -2
- package/dist/file-explorer/FileExplorer.js +1402 -0
- package/dist/file-explorer/FileExplorerContext.d.ts +1 -1
- package/dist/file-explorer/FileExplorerContext.js +370 -0
- package/dist/file-explorer/FilePreview/CodePreviewEditor.d.ts +1 -1
- package/dist/{chunks/CodePreviewEditor-4lx3kE-w.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.d.ts +1 -1
- 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.d.ts +1 -1
- 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.d.ts +4 -4
- package/dist/file-explorer/helpers.js +537 -0
- package/dist/file-explorer/index.d.ts +3 -3
- package/dist/file-explorer/index.js +7 -5705
- 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/types.d.ts +6 -1
- package/dist/file-explorer/lib/utils.d.ts +1 -3
- 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.d.ts +1 -1
- package/dist/file-explorer/useNearEnd.js +27 -0
- package/dist/form/FieldWrapper.d.ts +2 -2
- 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.d.ts +1 -1
- 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.d.ts +4 -21
- 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.d.ts +11 -12
- package/dist/form/index.js +18 -2445
- package/dist/form/lib.d.ts +6 -1
- package/dist/{chunks/FieldWrapper-Bef01EWO.js → form/lib.js} +5 -104
- package/dist/form/types/fieldComponentTypes.d.ts +3 -2
- package/dist/form/types/fieldTypes.d.ts +6 -20
- package/dist/form/useParsedOpts.d.ts +1 -1
- 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/{slurmDuration.d.ts → duration.d.ts} +2 -2
- 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/{workflow/index.js → graph/DependencyGraph.js} +76 -1163
- package/dist/graph/JobSummary.js +104 -0
- package/dist/{workflow → graph}/MatrixGroup.d.ts +2 -2
- package/dist/graph/MatrixGroup.js +107 -0
- package/dist/graph/Reveal.js +57 -0
- package/dist/graph/TreeView.js +711 -0
- package/dist/{workflow → graph}/index.d.ts +1 -1
- package/dist/graph/index.js +2 -0
- package/dist/{workflow → graph}/types.d.ts +3 -3
- package/dist/graph/types.js +6 -0
- package/dist/icons.d.ts +20 -21
- package/dist/index.d.ts +38 -40
- package/dist/index.js +47 -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.d.ts +1 -1
- package/dist/list/ListTable.js +163 -0
- package/dist/list/ListViewControls.d.ts +2 -2
- 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.d.ts +9 -9
- 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/logviewer/LogViewer.d.ts +1 -1
- package/dist/logviewer/LogViewer.js +750 -0
- package/dist/logviewer/index.d.ts +1 -0
- package/dist/logviewer/index.js +3 -742
- package/dist/logviewer/segments.d.ts +9 -0
- package/dist/logviewer/segments.js +80 -0
- package/dist/styles/fonts.css +4 -4
- package/dist/styles/theme.css +6 -4
- package/dist/styles.css +1 -1
- package/dist/theme/index.js +2 -2
- package/package.json +38 -14
- package/LICENSE +0 -202
- package/dist/chunks/Monaco-C1POOdVv.js +0 -1046
- package/dist/chunks/PageHeader-l49p1nM9.js +0 -690
- package/dist/chunks/SwitchToggle-CHPP8uZQ.js +0 -755
- package/dist/chunks/editor-9_uVtUyy.js +0 -347
- package/dist/chunks/list-qrojZZNv.js +0 -1411
- package/dist/editor/usesGitlab.d.ts +0 -97
- package/dist/form/Fields/BucketReadOnlyField.d.ts +0 -7
- package/dist/form/types/workflow-schema.d.ts +0 -1145
- package/dist/form/utils/pwResolver.d.ts +0 -18
- package/dist/{chunks/MarkdownImpl-Bq4QhrtA.js → components/MarkdownImpl.js} +1 -1
- /package/dist/{workflow → graph}/AnnotationBanner.d.ts +0 -0
- /package/dist/{workflow → graph}/Collapse.d.ts +0 -0
- /package/dist/{workflow → graph}/DependencyGraph.d.ts +0 -0
- /package/dist/{workflow → graph}/JobSummary.d.ts +0 -0
- /package/dist/{workflow → graph}/Reveal.d.ts +0 -0
- /package/dist/{workflow → graph}/TreeView.d.ts +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import cx from "classnames";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/SettingsGroup.tsx
|
|
4
|
+
function SettingsGroup({ title, children, className }) {
|
|
5
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
6
|
+
className: cx("mt-8 first:mt-0", className),
|
|
7
|
+
children: [title && /* @__PURE__ */ jsx("h2", {
|
|
8
|
+
className: "text-[11px] font-semibold uppercase tracking-wider theme-muted-text mb-2 px-1",
|
|
9
|
+
children: title
|
|
10
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
11
|
+
className: "panel divide-y divide-(--theme-border)",
|
|
12
|
+
children
|
|
13
|
+
})]
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { SettingsGroup as default };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useStrings } from "./Provider.js";
|
|
2
|
+
import { SortDownIcon, SortUnsortedIcon, SortUpIcon } from "../icons.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/Sort.tsx
|
|
5
|
+
var SortIcon = ({ currentlySorted, currentDirection, name }) => {
|
|
6
|
+
const style = { transform: "translateY(2px)" };
|
|
7
|
+
if (currentlySorted === name) {
|
|
8
|
+
if (currentDirection === "ascending") return /* @__PURE__ */ jsx(SortDownIcon, { style });
|
|
9
|
+
else if (currentDirection === "descending") return /* @__PURE__ */ jsx(SortUpIcon, { style });
|
|
10
|
+
} else return /* @__PURE__ */ jsx(SortUnsortedIcon, { style });
|
|
11
|
+
return null;
|
|
12
|
+
};
|
|
13
|
+
function Sort({ currentlySorted, name, setCurrentDirection, setCurrentlySorted, currentDirection }) {
|
|
14
|
+
const t = useStrings().common;
|
|
15
|
+
const sort = (sorted, direction) => {
|
|
16
|
+
if (sorted === name) {
|
|
17
|
+
if (direction === "ascending") setCurrentDirection("descending");
|
|
18
|
+
else if (direction === "descending") {
|
|
19
|
+
setCurrentDirection("unsorted");
|
|
20
|
+
setCurrentlySorted("");
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
setCurrentDirection("ascending");
|
|
24
|
+
setCurrentlySorted(name);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
return /* @__PURE__ */ jsx("div", {
|
|
28
|
+
className: "inline",
|
|
29
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
30
|
+
type: "button",
|
|
31
|
+
"aria-label": t.sort,
|
|
32
|
+
onClick: () => sort(currentlySorted, currentDirection),
|
|
33
|
+
children: /* @__PURE__ */ jsx(SortIcon, {
|
|
34
|
+
currentDirection,
|
|
35
|
+
currentlySorted,
|
|
36
|
+
name
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { Sort as default };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import cx from "classnames";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/StatusBadge.tsx
|
|
4
|
+
var variantStyles = {
|
|
5
|
+
default: "bg-(--theme-muted-panel-bg) text-(--theme-app) border-(--theme-border)",
|
|
6
|
+
success: "bg-emerald-500/10 text-emerald-800 dark:text-emerald-400 border-emerald-500/20",
|
|
7
|
+
warning: "bg-amber-500/10 text-amber-800 dark:text-amber-400 border-amber-500/20",
|
|
8
|
+
error: "bg-red-500/10 text-red-800 dark:text-red-400 border-red-500/20",
|
|
9
|
+
info: "bg-blue-500/10 text-blue-800 dark:text-blue-400 border-blue-500/20",
|
|
10
|
+
muted: "bg-(--theme-muted-panel-bg)/50 text-(--theme-muted-text-color) border-(--theme-border)"
|
|
11
|
+
};
|
|
12
|
+
var pulseColors = {
|
|
13
|
+
default: "bg-(--theme-app)",
|
|
14
|
+
success: "bg-emerald-500",
|
|
15
|
+
warning: "bg-amber-500",
|
|
16
|
+
error: "bg-red-500",
|
|
17
|
+
info: "bg-blue-500",
|
|
18
|
+
muted: "bg-(--theme-muted-text-color)"
|
|
19
|
+
};
|
|
20
|
+
var textColors = {
|
|
21
|
+
default: "text-(--theme-app)",
|
|
22
|
+
success: "text-emerald-600 dark:text-emerald-400",
|
|
23
|
+
warning: "text-amber-600 dark:text-amber-400",
|
|
24
|
+
error: "text-red-600 dark:text-red-400",
|
|
25
|
+
info: "text-blue-600 dark:text-blue-400",
|
|
26
|
+
muted: "text-(--theme-muted-text-color)"
|
|
27
|
+
};
|
|
28
|
+
/** A line of text in a variant's colour, for a status that stands beside a
|
|
29
|
+
* dot rather than inside a badge. */
|
|
30
|
+
function statusTextClass(variant) {
|
|
31
|
+
return textColors[variant];
|
|
32
|
+
}
|
|
33
|
+
function StatusBadge({ children, variant = "default", pulse = false, dot = false, size = "sm", className }) {
|
|
34
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
35
|
+
className: cx("inline-flex items-center gap-1.5 rounded-full border font-medium", size === "sm" && "px-2 py-0.5 text-[10px]", size === "md" && "px-2.5 py-1 text-xs", variantStyles[variant], className),
|
|
36
|
+
children: [
|
|
37
|
+
pulse && /* @__PURE__ */ jsxs("span", {
|
|
38
|
+
className: "relative flex h-2 w-2",
|
|
39
|
+
children: [/* @__PURE__ */ jsx("span", { className: cx("absolute inline-flex h-full w-full animate-ping rounded-full opacity-75", pulseColors[variant]) }), /* @__PURE__ */ jsx("span", { className: cx("relative inline-flex h-2 w-2 rounded-full", pulseColors[variant]) })]
|
|
40
|
+
}),
|
|
41
|
+
dot && !pulse && /* @__PURE__ */ jsx("span", { className: cx("inline-flex h-1.5 w-1.5 rounded-full", pulseColors[variant]) }),
|
|
42
|
+
children
|
|
43
|
+
]
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function StatusDot({ variant = "default", pulse = false, size = 8, className }) {
|
|
47
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
48
|
+
className: cx("relative inline-flex", className),
|
|
49
|
+
style: {
|
|
50
|
+
width: size,
|
|
51
|
+
height: size
|
|
52
|
+
},
|
|
53
|
+
children: [pulse && /* @__PURE__ */ jsx("span", { className: cx("absolute inline-flex h-full w-full animate-ping rounded-full opacity-75", pulseColors[variant]) }), /* @__PURE__ */ jsx("span", {
|
|
54
|
+
className: cx("relative inline-flex rounded-full", pulseColors[variant]),
|
|
55
|
+
style: {
|
|
56
|
+
width: size,
|
|
57
|
+
height: size
|
|
58
|
+
}
|
|
59
|
+
})]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { StatusBadge, StatusDot, statusTextClass };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { TOOLTIP_ID } from "./Tooltip.js";
|
|
2
|
+
import { Switch } from "@headlessui/react";
|
|
3
|
+
import cx from "classnames";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/SwitchToggle.tsx
|
|
7
|
+
function SwitchToggle({ onChange, id, "aria-describedby": describedBy, value = void 0, yesLabel = "Yes", noLabel = "No", disabled = false, datatip = "", invalid = false }) {
|
|
8
|
+
const [enabled, setEnabled] = useState(value ?? false);
|
|
9
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
10
|
+
const setIsEnabled = (e) => {
|
|
11
|
+
setEnabled(e);
|
|
12
|
+
onChange(e);
|
|
13
|
+
};
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (value !== void 0) setEnabled(value);
|
|
16
|
+
}, [value]);
|
|
17
|
+
const checked = value ?? enabled;
|
|
18
|
+
return /* @__PURE__ */ jsx("div", {
|
|
19
|
+
...datatip ? {
|
|
20
|
+
"data-tooltip-content": datatip,
|
|
21
|
+
"data-tooltip-id": TOOLTIP_ID
|
|
22
|
+
} : {},
|
|
23
|
+
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)]"),
|
|
24
|
+
children: /* @__PURE__ */ jsx(Switch, {
|
|
25
|
+
id,
|
|
26
|
+
"aria-describedby": describedBy,
|
|
27
|
+
checked,
|
|
28
|
+
onChange: setIsEnabled,
|
|
29
|
+
className: "text-white text-sm shadow-sm rounded-md cursor-pointer",
|
|
30
|
+
onClick: (e) => e.stopPropagation(),
|
|
31
|
+
onFocus: () => setIsFocused(true),
|
|
32
|
+
onBlur: () => setIsFocused(false),
|
|
33
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
34
|
+
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"),
|
|
35
|
+
children: [
|
|
36
|
+
/* @__PURE__ */ jsx("div", {
|
|
37
|
+
className: "inline text-center capitalize px-2 py-1 w-[99px] border-0",
|
|
38
|
+
style: {
|
|
39
|
+
background: `linear-gradient(
|
|
40
|
+
to bottom,
|
|
41
|
+
var(--theme-element, #04c) 0%,
|
|
42
|
+
var(--theme-element, #08c) 100%
|
|
43
|
+
)`,
|
|
44
|
+
color: "var(--theme-element-text, #ffffff)"
|
|
45
|
+
},
|
|
46
|
+
children: yesLabel
|
|
47
|
+
}),
|
|
48
|
+
/* @__PURE__ */ jsx("div", { className: "inline px-2 py-1 h-8 w-[99px] bg-linear-to-b from-white to-[#e6e6e6]" }),
|
|
49
|
+
/* @__PURE__ */ jsx("div", {
|
|
50
|
+
className: "inline text-center capitalize px-2 py-1 w-[99px] bg-linear-to-b from-[#e6e6e6] to-white bg-[#04c] text-black",
|
|
51
|
+
children: noLabel
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
export { SwitchToggle as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { useStrings } from "./Provider.js";
|
|
2
|
+
import Loader from "./Loader.js";
|
|
3
3
|
import cx from "classnames";
|
|
4
4
|
import React from "react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -49,9 +49,10 @@ function Table({ borderless = false, panel = true, className = "", wrapperClassN
|
|
|
49
49
|
const { loading } = useStrings();
|
|
50
50
|
const ChildrenArr = React.Children.toArray(children);
|
|
51
51
|
const Headers = getHeaders(ChildrenArr);
|
|
52
|
+
const hasOverflow = wrapperClassName.split(" ").some((cls) => cls.startsWith("overflow-"));
|
|
52
53
|
return /* @__PURE__ */ jsx("div", {
|
|
53
54
|
"aria-busy": isLoading,
|
|
54
|
-
className: cx("flex flex-col w-full", !
|
|
55
|
+
className: cx("flex flex-col w-full", !hasOverflow && "overflow-hidden", wrapperClassName),
|
|
55
56
|
children: isLoading ? /* @__PURE__ */ jsxs("div", {
|
|
56
57
|
role: "status",
|
|
57
58
|
"aria-label": loading,
|
|
@@ -79,8 +80,9 @@ function Table({ borderless = false, panel = true, className = "", wrapperClassN
|
|
|
79
80
|
function CompactTable({ wrapperClassName = "", className = "", tbodyClassName = "divide-y", children, roundedTop = false, rounded = false, roundedBottom = false }) {
|
|
80
81
|
const ChildrenArr = React.Children.toArray(children);
|
|
81
82
|
const Headers = getHeaders(ChildrenArr);
|
|
83
|
+
const hasOverflow = wrapperClassName.split(" ").some((cls) => cls.startsWith("overflow-"));
|
|
82
84
|
return /* @__PURE__ */ jsx("div", {
|
|
83
|
-
className: cx("flex flex-col w-full", !
|
|
85
|
+
className: cx("flex flex-col w-full", !hasOverflow && "overflow-hidden", wrapperClassName),
|
|
84
86
|
children: /* @__PURE__ */ jsx("div", {
|
|
85
87
|
className: cx("theme-panel inline-block min-w-full align-middle overflow-x-auto", rounded && "rounded-2xl", roundedBottom && "rounded-b-2xl pb-1", roundedTop && "rounded-t-2xl"),
|
|
86
88
|
children: /* @__PURE__ */ jsxs("table", {
|
|
@@ -104,4 +106,4 @@ Table.Item = Item;
|
|
|
104
106
|
CompactTable.Header = Header;
|
|
105
107
|
CompactTable.Item = CompactItem;
|
|
106
108
|
//#endregion
|
|
107
|
-
export {
|
|
109
|
+
export { CompactTable, Table };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import cx from "classnames";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/Toggle.tsx
|
|
4
|
+
function Toggle({ checked, onChange, disabled, label }) {
|
|
5
|
+
return /* @__PURE__ */ jsxs("label", {
|
|
6
|
+
role: "none",
|
|
7
|
+
onClick: (e) => e.stopPropagation(),
|
|
8
|
+
className: cx("relative inline-flex items-center", disabled ? "cursor-not-allowed opacity-60" : "cursor-pointer"),
|
|
9
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
10
|
+
type: "checkbox",
|
|
11
|
+
className: "peer sr-only",
|
|
12
|
+
checked,
|
|
13
|
+
onChange: (e) => onChange(e.target.checked),
|
|
14
|
+
disabled,
|
|
15
|
+
"aria-label": label
|
|
16
|
+
}), /* @__PURE__ */ jsx("div", { className: "h-6 w-11 rounded-full bg-(--theme-muted-panel-bg) transition-colors peer-checked:bg-(--theme-element) peer-focus-visible:ring-2 peer-focus-visible:ring-[color-mix(in_srgb,var(--theme-element)_25%,transparent)] after:absolute after:start-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:bg-white after:shadow-sm after:transition-transform after:content-[\"\"] motion-reduce:after:transition-none peer-checked:after:translate-x-5" })]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { Toggle };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TooltipIcon } from "../icons.js";
|
|
2
|
+
import { keyedByContent } from "./keys.js";
|
|
2
3
|
import { Fragment } from "react";
|
|
3
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
5
|
import { Tooltip } from "react-tooltip";
|
|
@@ -39,18 +40,19 @@ function formatLine(line) {
|
|
|
39
40
|
function formatTooltipContent(content) {
|
|
40
41
|
if (typeof content !== "string") return content || null;
|
|
41
42
|
if (!content) return null;
|
|
42
|
-
return content.split(/<br\s*\/?>|\n/i).map((line, idx) => /* @__PURE__ */ jsxs(Fragment, { children: [idx > 0 && /* @__PURE__ */ jsx("br", {}), formatLine(line)] },
|
|
43
|
+
return keyedByContent(content.split(/<br\s*\/?>|\n/i), (l) => l).map(({ key, item: line }, idx) => /* @__PURE__ */ jsxs(Fragment, { children: [idx > 0 && /* @__PURE__ */ jsx("br", {}), formatLine(line)] }, key));
|
|
43
44
|
}
|
|
44
45
|
function KbdShortcut({ keys }) {
|
|
46
|
+
const parts = keys.split("+").map((part) => part.trim()).filter(Boolean);
|
|
45
47
|
return /* @__PURE__ */ jsx("span", {
|
|
46
48
|
className: "inline-flex items-center gap-1 align-middle",
|
|
47
|
-
children:
|
|
49
|
+
children: keyedByContent(parts, (p) => p).map(({ key, item: part }, idx) => /* @__PURE__ */ jsxs(Fragment, { children: [idx > 0 && /* @__PURE__ */ jsx("span", {
|
|
48
50
|
className: "opacity-60 text-[11px]",
|
|
49
51
|
children: "+"
|
|
50
52
|
}), /* @__PURE__ */ jsx("kbd", {
|
|
51
53
|
className: "inline-flex items-center justify-center min-w-[18px] h-[18px] px-1 rounded border border-white/30 bg-white/10 font-sans text-[11px] font-semibold leading-none",
|
|
52
54
|
children: part
|
|
53
|
-
})] },
|
|
55
|
+
})] }, key))
|
|
54
56
|
});
|
|
55
57
|
}
|
|
56
58
|
var globalCloseEvents = { escape: true };
|
|
@@ -93,4 +95,4 @@ function TooltipInfo({ text, className = "", children, place = "top", tabIndex }
|
|
|
93
95
|
});
|
|
94
96
|
}
|
|
95
97
|
//#endregion
|
|
96
|
-
export {
|
|
98
|
+
export { GlobalTooltip, TOOLTIP_ID, TooltipInfo, formatTooltipContent, truncationTooltipProps };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CaretDownIcon } from "../icons.js";
|
|
2
|
-
import
|
|
3
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
3
|
//#region src/components/dropdownUtils.tsx
|
|
5
4
|
function isCategory(option) {
|
|
6
5
|
return typeof option === "object" && option !== null && option !== void 0 && "options" in option;
|
|
@@ -98,64 +97,4 @@ function DropdownCaret() {
|
|
|
98
97
|
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" });
|
|
99
98
|
}
|
|
100
99
|
//#endregion
|
|
101
|
-
|
|
102
|
-
var variantStyles = {
|
|
103
|
-
default: "bg-(--theme-muted-panel-bg) text-(--theme-app) border-(--theme-border)",
|
|
104
|
-
success: "bg-emerald-500/10 text-emerald-800 dark:text-emerald-400 border-emerald-500/20",
|
|
105
|
-
warning: "bg-amber-500/10 text-amber-800 dark:text-amber-400 border-amber-500/20",
|
|
106
|
-
error: "bg-red-500/10 text-red-800 dark:text-red-400 border-red-500/20",
|
|
107
|
-
info: "bg-blue-500/10 text-blue-800 dark:text-blue-400 border-blue-500/20",
|
|
108
|
-
muted: "bg-(--theme-muted-panel-bg)/50 text-(--theme-muted-text-color) border-(--theme-border)"
|
|
109
|
-
};
|
|
110
|
-
var pulseColors = {
|
|
111
|
-
default: "bg-(--theme-app)",
|
|
112
|
-
success: "bg-emerald-500",
|
|
113
|
-
warning: "bg-amber-500",
|
|
114
|
-
error: "bg-red-500",
|
|
115
|
-
info: "bg-blue-500",
|
|
116
|
-
muted: "bg-(--theme-muted-text-color)"
|
|
117
|
-
};
|
|
118
|
-
var textColors = {
|
|
119
|
-
default: "text-(--theme-app)",
|
|
120
|
-
success: "text-emerald-600 dark:text-emerald-400",
|
|
121
|
-
warning: "text-amber-600 dark:text-amber-400",
|
|
122
|
-
error: "text-red-600 dark:text-red-400",
|
|
123
|
-
info: "text-blue-600 dark:text-blue-400",
|
|
124
|
-
muted: "text-(--theme-muted-text-color)"
|
|
125
|
-
};
|
|
126
|
-
/** A line of text in a variant's colour, for a status that stands beside a
|
|
127
|
-
* dot rather than inside a badge. */
|
|
128
|
-
function statusTextClass(variant) {
|
|
129
|
-
return textColors[variant];
|
|
130
|
-
}
|
|
131
|
-
function StatusBadge({ children, variant = "default", pulse = false, dot = false, size = "sm", className }) {
|
|
132
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
133
|
-
className: cx("inline-flex items-center gap-1.5 rounded-full border font-medium", size === "sm" && "px-2 py-0.5 text-[10px]", size === "md" && "px-2.5 py-1 text-xs", variantStyles[variant], className),
|
|
134
|
-
children: [
|
|
135
|
-
pulse && /* @__PURE__ */ jsxs("span", {
|
|
136
|
-
className: "relative flex h-2 w-2",
|
|
137
|
-
children: [/* @__PURE__ */ jsx("span", { className: cx("absolute inline-flex h-full w-full animate-ping rounded-full opacity-75", pulseColors[variant]) }), /* @__PURE__ */ jsx("span", { className: cx("relative inline-flex h-2 w-2 rounded-full", pulseColors[variant]) })]
|
|
138
|
-
}),
|
|
139
|
-
dot && !pulse && /* @__PURE__ */ jsx("span", { className: cx("inline-flex h-1.5 w-1.5 rounded-full", pulseColors[variant]) }),
|
|
140
|
-
children
|
|
141
|
-
]
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
function StatusDot({ variant = "default", pulse = false, size = 8, className }) {
|
|
145
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
146
|
-
className: cx("relative inline-flex", className),
|
|
147
|
-
style: {
|
|
148
|
-
width: size,
|
|
149
|
-
height: size
|
|
150
|
-
},
|
|
151
|
-
children: [pulse && /* @__PURE__ */ jsx("span", { className: cx("absolute inline-flex h-full w-full animate-ping rounded-full opacity-75", pulseColors[variant]) }), /* @__PURE__ */ jsx("span", {
|
|
152
|
-
className: cx("relative inline-flex rounded-full", pulseColors[variant]),
|
|
153
|
-
style: {
|
|
154
|
-
width: size,
|
|
155
|
-
height: size
|
|
156
|
-
}
|
|
157
|
-
})]
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
//#endregion
|
|
161
|
-
export { filterOption as a, isCategory as c, DropdownCaret as i, isOption as l, StatusDot as n, flattenDisplayOptions as o, statusTextClass as r, flattenOptions as s, StatusBadge as t, toggleSetMember as u };
|
|
100
|
+
export { DropdownCaret, filterOption, flattenDisplayOptions, flattenOptions, isCategory, isOption, toggleSetMember };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/components/ghostButton.ts
|
|
2
|
+
var ghostButtonClasses = "inline-flex cursor-pointer items-center gap-1.5 h-8 px-3 rounded-md text-sm text-(--theme-muted-text-color) hover:text-(--theme-app) hover:bg-(--theme-muted-panel-bg) transition-colors";
|
|
3
|
+
var primaryButtonClasses = "inline-flex cursor-pointer items-center gap-1.5 h-7 px-2.5 rounded-md text-[12.5px] font-medium bg-(--theme-element) text-(--theme-element-text) hover:opacity-90 transition-opacity";
|
|
4
|
+
/** Filled destructive button for confirming irreversible actions in ds modals. */
|
|
5
|
+
var dangerButtonClasses = "inline-flex cursor-pointer items-center gap-1.5 h-7 px-2.5 rounded-md text-[12.5px] font-medium bg-red-600 text-white hover:bg-red-700 transition-colors";
|
|
6
|
+
//#endregion
|
|
7
|
+
export { dangerButtonClasses, ghostButtonClasses, primaryButtonClasses };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Pairs each item with a React key from its content, suffixing repeats so keys stay unique. */
|
|
2
|
+
export declare function keyedByContent<T>(items: readonly T[], toKey: (item: T) => string): {
|
|
3
|
+
key: string;
|
|
4
|
+
item: T;
|
|
5
|
+
}[];
|
|
6
|
+
/** Keys for a list whose position is its identity, such as placeholder rows or a fixed grid. */
|
|
7
|
+
export declare function positionKeys(count: number, prefix?: string): string[];
|
|
8
|
+
/** Pairs each item of a list that never reorders with a key from its position. */
|
|
9
|
+
export declare function withPositionKeys<T>(items: readonly T[], prefix?: string): {
|
|
10
|
+
key: string;
|
|
11
|
+
item: T;
|
|
12
|
+
}[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/components/keys.ts
|
|
2
|
+
/** Pairs each item with a React key from its content, suffixing repeats so keys stay unique. */
|
|
3
|
+
function keyedByContent(items, toKey) {
|
|
4
|
+
const seen = /* @__PURE__ */ new Map();
|
|
5
|
+
return items.map((item) => {
|
|
6
|
+
const base = toKey(item);
|
|
7
|
+
const count = (seen.get(base) ?? 0) + 1;
|
|
8
|
+
seen.set(base, count);
|
|
9
|
+
return {
|
|
10
|
+
key: count === 1 ? base : `${base}#${count}`,
|
|
11
|
+
item
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/** Keys for a list whose position is its identity, such as placeholder rows or a fixed grid. */
|
|
16
|
+
function positionKeys(count, prefix = "position") {
|
|
17
|
+
return Array.from({ length: count }, (_, position) => `${prefix}-${position}`);
|
|
18
|
+
}
|
|
19
|
+
/** Pairs each item of a list that never reorders with a key from its position. */
|
|
20
|
+
function withPositionKeys(items, prefix = "position") {
|
|
21
|
+
return items.map((item, position) => ({
|
|
22
|
+
key: `${prefix}-${position}`,
|
|
23
|
+
item
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { keyedByContent, positionKeys, withPositionKeys };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useStrings } from "./Provider.js";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { DateTime } from "luxon";
|
|
4
|
+
//#region src/components/relativeTime.ts
|
|
5
|
+
var TICK_MS = 3e4;
|
|
6
|
+
function compactRelativeMinutes(minutes, t) {
|
|
7
|
+
if (!Number.isFinite(minutes) || minutes < 1) return t.now;
|
|
8
|
+
if (minutes < 60) return t.minutes(minutes);
|
|
9
|
+
const hours = Math.floor(minutes / 60);
|
|
10
|
+
if (hours < 24) return t.hours(hours);
|
|
11
|
+
const days = Math.floor(hours / 24);
|
|
12
|
+
if (days < 365) return t.days(days);
|
|
13
|
+
return t.years(Math.floor(days / 365));
|
|
14
|
+
}
|
|
15
|
+
/** A clock that re-reads itself, so "5m" ages while the page sits open, with
|
|
16
|
+
* the abbreviated form a row has room for. */
|
|
17
|
+
function useRelativeTime() {
|
|
18
|
+
const t = useStrings().time;
|
|
19
|
+
const [now, setNow] = useState(() => DateTime.now());
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const id = setInterval(() => setNow(DateTime.now()), TICK_MS);
|
|
22
|
+
return () => clearInterval(id);
|
|
23
|
+
}, []);
|
|
24
|
+
const compactMinutes = (minutes) => compactRelativeMinutes(minutes, t);
|
|
25
|
+
return {
|
|
26
|
+
now,
|
|
27
|
+
compactMinutes,
|
|
28
|
+
compact: (iso) => iso ? compactMinutes(Math.floor(now.diff(DateTime.fromISO(iso)).as("minutes"))) : ""
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { compactRelativeMinutes, useRelativeTime };
|
package/dist/duration.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Duration } from "luxon";
|
|
2
|
+
//#region src/duration.ts
|
|
3
|
+
var UnitDisplay = { ja: "short" };
|
|
4
|
+
function durationToAbsHumanDuration(d) {
|
|
5
|
+
const duration = d.shiftTo("days", "hours", "minutes", "seconds").toObject();
|
|
6
|
+
if ("seconds" in duration) duration.seconds = Math.round(duration.seconds);
|
|
7
|
+
const cleanedDuration = Object.fromEntries(Object.entries(duration).filter(([, value]) => value !== 0).map(([key, value]) => [key, Math.abs(value)]));
|
|
8
|
+
if (Object.keys(cleanedDuration).length === 0) cleanedDuration.seconds = 0;
|
|
9
|
+
const human = Duration.fromObject(cleanedDuration);
|
|
10
|
+
const unitDisplay = UnitDisplay[human.locale] || "narrow";
|
|
11
|
+
return human.toHuman({ unitDisplay }).replaceAll(/[,、]/g, "");
|
|
12
|
+
}
|
|
13
|
+
function toAbsHumanDuration(start, end) {
|
|
14
|
+
return durationToAbsHumanDuration(end.diff(start));
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { durationToAbsHumanDuration, toAbsHumanDuration };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Loader from "../components/Loader.js";
|
|
2
|
+
import { Suspense, lazy } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/editor/Editor.tsx
|
|
5
|
+
var MonacoEditor = lazy(() => import("./Monaco.js"));
|
|
6
|
+
function Editor({ ...props }) {
|
|
7
|
+
return /* @__PURE__ */ jsx(Suspense, {
|
|
8
|
+
fallback: /* @__PURE__ */ jsx(Loader, { text: "Loading editor..." }),
|
|
9
|
+
children: /* @__PURE__ */ jsx(MonacoEditor, { ...props })
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { Editor as default };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import Editor from "./Editor.js";
|
|
2
|
+
import { FieldWrapper } from "../form/FieldWrapper.js";
|
|
3
|
+
import cx from "classnames";
|
|
4
|
+
import { useMemo, useRef } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { useField, useFormikContext } from "formik";
|
|
7
|
+
//#region src/editor/EditorField.tsx
|
|
8
|
+
function hasResetKeys(obj) {
|
|
9
|
+
return typeof obj === "object" && obj !== null && "editorKeyPostfix" in obj && typeof obj.editorKeyPostfix === "string";
|
|
10
|
+
}
|
|
11
|
+
function EditorField(props) {
|
|
12
|
+
const { field, label, labelPosition, disabled, onChange, tooltipComponent, spaceCompact, setFormDirty } = props;
|
|
13
|
+
const [fieldState] = useField(field.name);
|
|
14
|
+
const { setFieldValue, setFieldTouched, values } = useFormikContext();
|
|
15
|
+
const debounceRef = useRef(null);
|
|
16
|
+
const touchedRef = useRef(false);
|
|
17
|
+
const handleChange = (val) => {
|
|
18
|
+
touchedRef.current = true;
|
|
19
|
+
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
20
|
+
debounceRef.current = setTimeout(() => {
|
|
21
|
+
if (onChange) onChange(val);
|
|
22
|
+
setFieldTouched(field.name, true);
|
|
23
|
+
setFieldValue(field.name, val);
|
|
24
|
+
setFormDirty(true);
|
|
25
|
+
}, 500);
|
|
26
|
+
};
|
|
27
|
+
let editorKeyPostfix = "";
|
|
28
|
+
if (hasResetKeys(values)) editorKeyPostfix = values.editorKeyPostfix;
|
|
29
|
+
const postfixKey = useMemo(() => {
|
|
30
|
+
const randomKey = Math.random().toString(36).substring(7);
|
|
31
|
+
return editorKeyPostfix || randomKey;
|
|
32
|
+
}, [editorKeyPostfix]);
|
|
33
|
+
const value = fieldState.value;
|
|
34
|
+
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
35
|
+
optional: field.optional,
|
|
36
|
+
label,
|
|
37
|
+
tooltipComponent,
|
|
38
|
+
labelPosition,
|
|
39
|
+
spaceCompact,
|
|
40
|
+
children: /* @__PURE__ */ jsx(Editor, {
|
|
41
|
+
ariaLabel: label,
|
|
42
|
+
height: "200px",
|
|
43
|
+
path: field.name,
|
|
44
|
+
...touchedRef.current ? {} : { value },
|
|
45
|
+
className: cx("bg-(--theme-input-bg) w-11 border focus:border rounded text-[10px] leading-4 pl-[6px]", disabled && "opacity-75"),
|
|
46
|
+
readOnly: disabled,
|
|
47
|
+
onChange: handleChange,
|
|
48
|
+
language: field.options?.language || "shell"
|
|
49
|
+
}, field.name + postfixKey)
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { EditorField as default };
|