@parallelworks/ui 0.41.0 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/dist/ai/components/AllocationSelector.d.ts +3 -4
- package/dist/ai/components/AllocationSelector.js +37 -33
- package/dist/ai/components/AttachmentManager.js +7 -7
- package/dist/ai/components/AttachmentUpload.js +5 -5
- package/dist/ai/components/BranchNavigator.js +1 -1
- package/dist/ai/components/ChatEmptyState.js +2 -2
- package/dist/ai/components/ChatInput.js +10 -8
- package/dist/ai/components/ChatLayout.js +4 -5
- package/dist/ai/components/ChatMessage.js +12 -12
- package/dist/ai/components/ChatMessageList.js +9 -9
- package/dist/ai/components/ChatSidebar.js +8 -9
- package/dist/ai/components/ChatThread.js +4 -4
- package/dist/ai/components/ComposerChrome.d.ts +2 -2
- package/dist/ai/components/ComposerChrome.js +3 -6
- package/dist/ai/components/DragOverlay.js +2 -2
- package/dist/ai/components/ModelSelector.d.ts +5 -3
- package/dist/ai/components/ModelSelector.js +102 -339
- package/dist/ai/components/PastedText.js +11 -11
- package/dist/ai/components/ProviderIssueBanner.d.ts +2 -0
- package/dist/ai/components/ProviderIssueBanner.js +34 -16
- package/dist/ai/components/Reasoning.js +4 -4
- package/dist/ai/components/ShareDialog.js +43 -35
- package/dist/ai/components/SlashMenu.d.ts +12 -2
- package/dist/ai/components/SlashMenu.js +29 -13
- package/dist/ai/components/agent/ActivityLine.js +3 -3
- package/dist/ai/components/agent/AgentMessageParts.js +20 -20
- package/dist/ai/components/agent/PermissionPicker.js +13 -11
- package/dist/ai/components/conversationActions.d.ts +4 -6
- package/dist/ai/components/conversationActions.js +9 -13
- package/dist/ai/core/ChatProvider.js +1 -1
- package/dist/ai/core/config.js +1 -1
- package/dist/ai/core/providerIssues.d.ts +7 -0
- package/dist/ai/core/providerIssues.js +9 -1
- package/dist/ai/core/useKeyboardShortcuts.d.ts +4 -0
- package/dist/ai/core/useKeyboardShortcuts.js +8 -2
- package/dist/ai/index.d.ts +0 -1
- package/dist/ai/index.js +1 -2
- package/dist/ai/strings.d.ts +19 -0
- package/dist/ai/strings.js +18 -1
- package/dist/ai/ui/Avatar.js +5 -5
- package/dist/ai/ui/ConversationSidebar.d.ts +0 -1
- package/dist/ai/ui/ConversationSidebar.js +6 -7
- package/dist/ai/ui/Markdown.js +3 -3
- package/dist/ai/ui/Notice.js +6 -6
- package/dist/ai/ui/chip.d.ts +4 -0
- package/dist/ai/ui/chip.js +8 -0
- package/dist/ai/ui/sidebar.d.ts +6 -5
- package/dist/ai/ui/sidebar.js +39 -43
- package/dist/components/ActionMenu.d.ts +13 -0
- package/dist/components/ActionMenu.js +30 -0
- package/dist/components/Avatar.js +6 -6
- package/dist/components/Breadcrumbs.js +1 -1
- package/dist/components/Button.js +10 -10
- package/dist/components/Callout.js +2 -2
- package/dist/components/Card.js +3 -3
- package/dist/components/Combobox.d.ts +66 -0
- package/dist/components/Combobox.js +393 -0
- package/dist/components/ConfirmModal.js +11 -11
- package/dist/components/ContextMenu.d.ts +23 -0
- package/dist/components/ContextMenu.js +89 -0
- package/dist/components/CopyToClipboard.js +2 -2
- package/dist/components/CreateModal.d.ts +17 -36
- package/dist/components/CreateModal.js +97 -259
- package/dist/components/DescriptionList.js +8 -8
- package/dist/components/Filter.js +2 -2
- package/dist/components/FilterPill.js +2 -2
- package/dist/components/HoverCard.d.ts +14 -0
- package/dist/components/HoverCard.js +33 -0
- package/dist/components/IconButton.d.ts +5 -5
- package/dist/components/IconButton.js +18 -22
- package/dist/components/InfoTip.d.ts +15 -0
- package/dist/components/InfoTip.js +60 -0
- package/dist/components/Input.js +5 -5
- package/dist/components/LetterBadge.js +2 -2
- package/dist/components/Loader.js +3 -3
- package/dist/components/Markdown.js +1 -1
- package/dist/components/MarkdownImpl.js +2 -2
- package/dist/components/Menu.d.ts +33 -0
- package/dist/components/Menu.js +86 -0
- package/dist/components/MenuEntries.d.ts +56 -0
- package/dist/components/MenuEntries.js +123 -0
- package/dist/components/Modal.d.ts +29 -0
- package/dist/components/Modal.js +47 -0
- package/dist/components/Overview.js +11 -10
- package/dist/components/PageHeader.d.ts +10 -16
- package/dist/components/PageHeader.js +69 -95
- package/dist/components/Pagination.js +5 -5
- package/dist/components/Provider.d.ts +5 -11
- package/dist/components/Provider.js +11 -14
- package/dist/components/Radio.d.ts +8 -0
- package/dist/components/Radio.js +16 -0
- package/dist/components/SectionHeader.js +2 -2
- package/dist/components/SegmentedControl.d.ts +6 -5
- package/dist/components/SegmentedControl.js +34 -30
- package/dist/components/Select.d.ts +27 -0
- package/dist/components/Select.js +78 -0
- package/dist/components/SettingModeOption.d.ts +5 -8
- package/dist/components/SettingModeOption.js +10 -12
- package/dist/components/SettingRow.js +4 -4
- package/dist/components/SettingsCard.js +4 -4
- package/dist/components/SettingsGroup.js +2 -2
- package/dist/components/Sort.js +1 -1
- package/dist/components/StatusBadge.js +7 -7
- package/dist/components/StatusIcons.js +4 -4
- package/dist/components/Switch.d.ts +22 -0
- package/dist/components/Switch.js +28 -0
- package/dist/components/Table.js +11 -11
- package/dist/components/Tooltip.d.ts +24 -20
- package/dist/components/Tooltip.js +58 -76
- package/dist/components/floating.d.ts +14 -0
- package/dist/components/floating.js +21 -0
- package/dist/components/search.d.ts +2 -0
- package/dist/components/search.js +14 -0
- package/dist/editor/Editor.js +1 -1
- package/dist/editor/EditorField.js +16 -21
- package/dist/editor/FormCodePanel.js +19 -19
- package/dist/editor/Monaco.js +3 -3
- package/dist/file-explorer/FileExplorer.js +77 -81
- package/dist/file-explorer/FileExplorerContext.js +2 -2
- package/dist/file-explorer/FilePreview/CodePreviewEditor.js +1 -1
- package/dist/file-explorer/FilePreview/Inline.js +1 -1
- package/dist/file-explorer/FilePreview/StreamedBadge.js +5 -6
- package/dist/file-explorer/FilePreview/Viewer.js +8 -8
- package/dist/file-explorer/FilePreview/index.d.ts +1 -1
- package/dist/file-explorer/FilePreview/index.js +49 -83
- package/dist/file-explorer/FileRow.d.ts +4 -3
- package/dist/file-explorer/FileRow.js +32 -38
- package/dist/file-explorer/FileRowsWindow.d.ts +3 -2
- package/dist/file-explorer/FileRowsWindow.js +4 -4
- package/dist/file-explorer/FileTable.d.ts +3 -2
- package/dist/file-explorer/FileTable.js +3 -3
- package/dist/file-explorer/LoadMoreRow.js +1 -1
- package/dist/file-explorer/TreeView.js +11 -16
- package/dist/file-explorer/helpers.js +11 -12
- package/dist/file-explorer/toasts.js +11 -11
- package/dist/form/FieldGroup.d.ts +11 -0
- package/dist/form/FieldGroup.js +36 -0
- package/dist/form/FieldWrapper.js +4 -4
- package/dist/form/Fields/BooleanField.js +23 -33
- package/dist/form/Fields/CheckboxGroupField.d.ts +1 -1
- package/dist/form/Fields/CheckboxGroupField.js +9 -13
- package/dist/form/Fields/ColorField.d.ts +1 -2
- package/dist/form/Fields/ColorField.js +6 -11
- package/dist/form/Fields/DropdownField.d.ts +3 -13
- package/dist/form/Fields/DropdownField.js +40 -27
- package/dist/form/Fields/DurationField.d.ts +1 -2
- package/dist/form/Fields/DurationField.js +25 -32
- package/dist/form/Fields/LabelField.js +2 -2
- package/dist/form/Fields/MultiDropdownField.d.ts +6 -12
- package/dist/form/Fields/MultiDropdownField.js +31 -22
- package/dist/form/Fields/NumberField.d.ts +1 -1
- package/dist/form/Fields/NumberField.js +65 -35
- package/dist/form/Fields/ObjectField.d.ts +1 -1
- package/dist/form/Fields/ObjectField.js +12 -43
- package/dist/form/Fields/RadioField.d.ts +1 -1
- package/dist/form/Fields/RadioField.js +30 -41
- package/dist/form/Fields/RangeField.d.ts +1 -2
- package/dist/form/Fields/RangeField.js +23 -16
- package/dist/form/Fields/StringField.d.ts +1 -2
- package/dist/form/Fields/StringField.js +58 -26
- package/dist/form/Fields/TextAreaField.js +12 -10
- package/dist/form/Form.d.ts +30 -48
- package/dist/form/Form.js +306 -412
- package/dist/form/FormLayout.js +9 -9
- package/dist/form/Wizard/WizardContainer.d.ts +1 -4
- package/dist/form/Wizard/WizardContainer.js +40 -56
- package/dist/form/Wizard/WizardNavigation.js +1 -1
- package/dist/form/Wizard/WizardStepContent.d.ts +1 -5
- package/dist/form/Wizard/WizardStepContent.js +11 -16
- package/dist/form/Wizard/WizardStepIndicator.js +6 -6
- package/dist/form/Wizard/types.d.ts +0 -14
- package/dist/form/fieldRegistry.d.ts +1 -1
- package/dist/form/fieldRegistry.js +6 -6
- package/dist/form/formEditing.js +1 -1
- package/dist/form/index.d.ts +5 -4
- package/dist/form/index.js +6 -7
- package/dist/form/types/fieldComponentTypes.d.ts +8 -10
- package/dist/form/useChoiceField.d.ts +20 -0
- package/dist/form/useChoiceField.js +49 -0
- package/dist/form/useFieldValue.d.ts +7 -0
- package/dist/form/useFieldValue.js +20 -0
- package/dist/form/useParsedOpts.d.ts +3 -1
- package/dist/form/useParsedOpts.js +12 -17
- package/dist/form/utils/dependentOptions.d.ts +8 -4
- package/dist/form/utils/dependentOptions.js +25 -17
- package/dist/form/utils/fieldItems.d.ts +10 -0
- package/dist/form/utils/fieldItems.js +11 -0
- package/dist/form/utils/fieldPath.d.ts +10 -0
- package/dist/form/utils/fieldPath.js +20 -0
- package/dist/form/utils/shareEqual.d.ts +6 -0
- package/dist/form/utils/shareEqual.js +38 -0
- package/dist/graph/AnnotationBanner.js +8 -8
- package/dist/graph/Collapse.d.ts +1 -0
- package/dist/graph/Collapse.js +6 -27
- package/dist/graph/Connectors.js +5 -5
- package/dist/graph/DependencyGraph.js +20 -19
- package/dist/graph/GraphEditor.js +30 -41
- package/dist/graph/GraphEditorDialogs.js +17 -17
- package/dist/graph/GraphNode.js +1 -1
- package/dist/graph/InputDialog.js +19 -22
- package/dist/graph/InputsEditor.js +58 -66
- package/dist/graph/JobSummary.js +42 -39
- package/dist/graph/MatrixGroup.js +1 -1
- package/dist/graph/ProblemsButton.js +18 -19
- package/dist/graph/Reveal.js +1 -1
- package/dist/graph/ShortcutsButton.js +15 -18
- package/dist/graph/SuggestionInput.d.ts +5 -10
- package/dist/graph/SuggestionInput.js +14 -18
- package/dist/graph/ToolbarPopover.d.ts +11 -6
- package/dist/graph/ToolbarPopover.js +35 -67
- package/dist/graph/TreeView.js +24 -37
- package/dist/graph/WorkflowSettingsDialog.js +4 -4
- package/dist/graph/editorChrome.js +13 -12
- package/dist/graph/editorFields.js +29 -29
- package/dist/graph/editorPrimitives.d.ts +1 -1
- package/dist/graph/editorPrimitives.js +10 -7
- package/dist/graph/editorRows.js +103 -97
- package/dist/graph/fieldProblems.js +2 -2
- package/dist/graph/graphEditorState.d.ts +4 -3
- package/dist/graph/inputRefs.js +9 -9
- package/dist/graph/settingsViews.js +6 -7
- package/dist/graph/stepWith.js +6 -6
- package/dist/index.d.ts +14 -15
- package/dist/index.js +15 -14
- package/dist/list/ActionToolbar.d.ts +6 -14
- package/dist/list/ActionToolbar.js +48 -96
- package/dist/list/ListPage.d.ts +6 -12
- package/dist/list/ListPage.js +46 -29
- package/dist/list/ListPager.js +4 -4
- package/dist/list/ListTable.js +5 -5
- package/dist/list/ListViewControls.d.ts +5 -4
- package/dist/list/ListViewControls.js +177 -267
- package/dist/list/UserHoverCard.d.ts +3 -17
- package/dist/list/UserHoverCard.js +21 -45
- package/dist/list/index.d.ts +3 -4
- package/dist/list/index.js +3 -4
- package/dist/list/listSearch.js +12 -11
- package/dist/list/rowMenu.d.ts +63 -0
- package/dist/list/rowMenu.js +134 -0
- package/dist/logviewer/LogViewer.js +26 -26
- package/dist/styles.css +1 -1
- package/package.json +7 -13
- package/dist/ai/ui/Dropdown.d.ts +0 -31
- package/dist/ai/ui/Dropdown.js +0 -110
- package/dist/components/AddMenu.d.ts +0 -18
- package/dist/components/AddMenu.js +0 -46
- package/dist/components/BareModal.d.ts +0 -17
- package/dist/components/BareModal.js +0 -77
- package/dist/components/CollapsiblePanel.d.ts +0 -27
- package/dist/components/CollapsiblePanel.js +0 -77
- package/dist/components/Dropdown.d.ts +0 -28
- package/dist/components/Dropdown.js +0 -355
- package/dist/components/Listbox.d.ts +0 -21
- package/dist/components/Listbox.js +0 -119
- package/dist/components/MultiSelect.d.ts +0 -22
- package/dist/components/MultiSelect.js +0 -168
- package/dist/components/SwitchToggle.d.ts +0 -15
- package/dist/components/SwitchToggle.js +0 -57
- package/dist/components/SwitchToggleSmall.d.ts +0 -6
- package/dist/components/SwitchToggleSmall.js +0 -14
- package/dist/components/Toggle.d.ts +0 -6
- package/dist/components/Toggle.js +0 -20
- package/dist/components/dropdownUtils.d.ts +0 -37
- package/dist/components/dropdownUtils.js +0 -99
- package/dist/form/SpecialTypes/DropdownWrapper.d.ts +0 -25
- package/dist/form/SpecialTypes/DropdownWrapper.js +0 -28
- package/dist/form/SpecialTypes/FormikCustomDropdown.d.ts +0 -51
- package/dist/form/SpecialTypes/FormikCustomDropdown.js +0 -119
- package/dist/form/SpecialTypes/FormikCustomInput.d.ts +0 -19
- package/dist/form/SpecialTypes/FormikCustomInput.js +0 -121
- package/dist/form/SpecialTypes/FormikMultiSelectDropdown.d.ts +0 -13
- package/dist/form/SpecialTypes/FormikMultiSelectDropdown.js +0 -31
- package/dist/form/SpecialTypes/FormikNumericInput.d.ts +0 -9
- package/dist/form/SpecialTypes/FormikNumericInput.js +0 -60
- package/dist/form/SpecialTypes/index.d.ts +0 -3
- package/dist/list/HoverCard.d.ts +0 -24
- package/dist/list/HoverCard.js +0 -73
- package/dist/list/RowContextMenu.d.ts +0 -127
- package/dist/list/RowContextMenu.js +0 -515
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ComponentType, ReactNode } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { type HeaderAddMenuItem } from './AddMenu.js';
|
|
2
|
+
import type { MenuEntry } from './MenuEntries.js';
|
|
4
3
|
export interface PageHeaderBreadcrumb {
|
|
5
4
|
label: string;
|
|
6
5
|
href?: string;
|
|
@@ -14,28 +13,23 @@ export declare const headerActionButtonClasses = "flex items-center justify-cent
|
|
|
14
13
|
/** With menu, the plus opens a chooser; otherwise navigates to or calls the
|
|
15
14
|
* single action. `word` is the visible verb; `label` stays the full action for
|
|
16
15
|
* the tooltip and screen readers. */
|
|
17
|
-
export declare function HeaderAddButton({
|
|
18
|
-
|
|
16
|
+
export declare function HeaderAddButton({ href, onClick, label, word, menu, disabled, disabledHint, }: {
|
|
17
|
+
href?: string;
|
|
19
18
|
onClick?: () => void;
|
|
20
19
|
label: string;
|
|
21
20
|
word?: 'add' | 'create';
|
|
22
|
-
menu?:
|
|
21
|
+
menu?: MenuEntry[];
|
|
23
22
|
/** Button mode only. */
|
|
24
23
|
disabled?: boolean;
|
|
25
24
|
disabledHint?: string;
|
|
26
25
|
}): import("react").JSX.Element;
|
|
26
|
+
/** The header's "…" menu of actions on the page's subject. */
|
|
27
27
|
export declare function HeaderActionMenu({ items, label, }: {
|
|
28
|
-
items:
|
|
29
|
-
label?: string;
|
|
30
|
-
}): import("react").JSX.Element | null;
|
|
31
|
-
/** The header "…" trigger for a RowMenuItem menu — same rendering (submenus,
|
|
32
|
-
* destructive styling) as the list pages' right-click context menus. */
|
|
33
|
-
export declare function HeaderRowMenu({ items, label, }: {
|
|
34
|
-
items: RowMenuItem[];
|
|
28
|
+
items: MenuEntry[];
|
|
35
29
|
label?: string;
|
|
36
30
|
}): import("react").JSX.Element | null;
|
|
37
|
-
export declare function HeaderEditButton({
|
|
38
|
-
|
|
31
|
+
export declare function HeaderEditButton({ href, onClick, label, disabled, tooltip, }: {
|
|
32
|
+
href?: string;
|
|
39
33
|
onClick?: () => void;
|
|
40
34
|
label?: string;
|
|
41
35
|
disabled?: boolean;
|
|
@@ -48,13 +42,13 @@ export declare function BreadcrumbsTitleAction({ children }: {
|
|
|
48
42
|
export declare function BreadcrumbsRightAction({ children }: {
|
|
49
43
|
children: ReactNode;
|
|
50
44
|
}): import("react").ReactPortal | null;
|
|
51
|
-
export declare function BreadcrumbsActionButton({ icon: Icon, label, ariaLabel,
|
|
45
|
+
export declare function BreadcrumbsActionButton({ icon: Icon, label, ariaLabel, href, onClick, disabled, tooltip, }: {
|
|
52
46
|
icon: ComponentType<{
|
|
53
47
|
className?: string;
|
|
54
48
|
}>;
|
|
55
49
|
label: string;
|
|
56
50
|
ariaLabel?: string;
|
|
57
|
-
|
|
51
|
+
href?: string;
|
|
58
52
|
onClick?: (() => void) | undefined;
|
|
59
53
|
disabled?: boolean;
|
|
60
54
|
tooltip?: string | undefined;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { useLink, useSlots, useStrings } from "./Provider.js";
|
|
2
1
|
import { BsThreeDots } from "../icons/bs/BsThreeDots.js";
|
|
3
2
|
import { FaEdit } from "../icons/fa/FaEdit.js";
|
|
4
3
|
import { FaPlus } from "../icons/fa/FaPlus.js";
|
|
5
4
|
import { LuChevronRight } from "../icons/lu/LuChevronRight.js";
|
|
6
5
|
import { keyedByContent } from "./keys.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { Tooltip } from "./Tooltip.js";
|
|
7
|
+
import { useLink, useSlots, useStrings } from "./Provider.js";
|
|
8
|
+
import { ActionMenu } from "./ActionMenu.js";
|
|
9
9
|
import { useBreadcrumb } from "./Breadcrumbs.js";
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import { Fragment, useLayoutEffect } from "react";
|
|
13
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { clsx } from "clsx";
|
|
11
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { Fragment as Fragment$1, useLayoutEffect } from "react";
|
|
14
13
|
import { createPortal } from "react-dom";
|
|
15
14
|
//#region src/components/PageHeader.tsx
|
|
16
15
|
var headerActionButtonClasses = "flex items-center justify-center w-6 h-6 rounded-md shrink-0 cursor-pointer text-(--theme-muted-text-color) hover:text-(--theme-app) hover:bg-(--theme-muted-panel-bg) transition-colors";
|
|
@@ -18,86 +17,65 @@ var headerAddButtonClasses = "inline-flex h-[26px] shrink-0 items-center gap-1.5
|
|
|
18
17
|
/** With menu, the plus opens a chooser; otherwise navigates to or calls the
|
|
19
18
|
* single action. `word` is the visible verb; `label` stays the full action for
|
|
20
19
|
* the tooltip and screen readers. */
|
|
21
|
-
function HeaderAddButton({
|
|
20
|
+
function HeaderAddButton({ href, onClick, label, word = "add", menu, disabled = false, disabledHint }) {
|
|
22
21
|
const { common } = useStrings();
|
|
23
22
|
const Link = useLink();
|
|
24
|
-
const content = /* @__PURE__ */ jsxs(Fragment
|
|
25
|
-
if (menu) return /* @__PURE__ */ jsx(
|
|
23
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(FaPlus, { className: "w-3 h-3" }), /* @__PURE__ */ jsx("span", { children: word === "create" ? common.create : common.add })] });
|
|
24
|
+
if (menu) return /* @__PURE__ */ jsx(ActionMenu, {
|
|
26
25
|
items: menu,
|
|
27
26
|
label,
|
|
28
|
-
|
|
27
|
+
triggerClassName: headerAddButtonClasses,
|
|
29
28
|
children: content
|
|
30
29
|
});
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
if (href) return /* @__PURE__ */ jsx(Tooltip, {
|
|
31
|
+
content: label,
|
|
32
|
+
children: /* @__PURE__ */ jsx(Link, {
|
|
33
|
+
href,
|
|
34
|
+
"aria-label": label,
|
|
35
|
+
className: headerAddButtonClasses,
|
|
36
|
+
children: content
|
|
37
|
+
})
|
|
37
38
|
});
|
|
38
39
|
const hint = disabled ? disabledHint : void 0;
|
|
39
|
-
return /* @__PURE__ */ jsx(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
children: content
|
|
40
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
41
|
+
content: hint ?? label,
|
|
42
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
43
|
+
type: "button",
|
|
44
|
+
onClick: disabled ? void 0 : onClick,
|
|
45
|
+
"aria-label": hint ? `${label}. ${hint}` : label,
|
|
46
|
+
"aria-disabled": disabled || void 0,
|
|
47
|
+
className: clsx(headerAddButtonClasses, "aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:hover:bg-transparent aria-disabled:hover:text-(--theme-muted-text-color)"),
|
|
48
|
+
children: content
|
|
49
|
+
})
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
+
/** The header's "…" menu of actions on the page's subject. */
|
|
52
53
|
function HeaderActionMenu({ items, label = "Actions" }) {
|
|
53
54
|
if (items.length === 0) return null;
|
|
54
|
-
return /* @__PURE__ */ jsx(
|
|
55
|
+
return /* @__PURE__ */ jsx(ActionMenu, {
|
|
55
56
|
items,
|
|
56
57
|
label,
|
|
57
|
-
|
|
58
|
+
triggerClassName: headerActionButtonClasses,
|
|
58
59
|
children: /* @__PURE__ */ jsx(BsThreeDots, { className: "w-3.5 h-3.5" })
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
-
* destructive styling) as the list pages' right-click context menus. */
|
|
63
|
-
function HeaderRowMenu({ items, label = "Actions" }) {
|
|
64
|
-
const { openMenu, contextMenu } = useRowMenu();
|
|
65
|
-
if (items.length === 0) return null;
|
|
66
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("button", {
|
|
67
|
-
type: "button",
|
|
68
|
-
"aria-label": label,
|
|
69
|
-
title: label,
|
|
70
|
-
className: headerActionButtonClasses,
|
|
71
|
-
onClick: (e) => {
|
|
72
|
-
const r = e.currentTarget.getBoundingClientRect();
|
|
73
|
-
openMenu(r.left, r.bottom + 4, items);
|
|
74
|
-
},
|
|
75
|
-
children: /* @__PURE__ */ jsx(BsThreeDots, { className: "w-3.5 h-3.5" })
|
|
76
|
-
}), contextMenu] });
|
|
77
|
-
}
|
|
78
|
-
function HeaderEditButton({ to, onClick, label = "Edit", disabled, tooltip }) {
|
|
62
|
+
function HeaderEditButton({ href, onClick, label = "Edit", disabled, tooltip }) {
|
|
79
63
|
const Link = useLink();
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
disabled,
|
|
96
|
-
"aria-label": label,
|
|
97
|
-
title: tooltip ? void 0 : label,
|
|
98
|
-
className: cx(headerActionButtonClasses, disabled && "opacity-50 cursor-not-allowed hover:bg-transparent"),
|
|
99
|
-
...tooltipProps,
|
|
100
|
-
children: /* @__PURE__ */ jsx(FaEdit, { className: "w-3 h-3" })
|
|
64
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
65
|
+
content: tooltip ?? label,
|
|
66
|
+
children: href && !disabled ? /* @__PURE__ */ jsx(Link, {
|
|
67
|
+
href,
|
|
68
|
+
"aria-label": label,
|
|
69
|
+
className: headerActionButtonClasses,
|
|
70
|
+
children: /* @__PURE__ */ jsx(FaEdit, { className: "w-3 h-3" })
|
|
71
|
+
}) : /* @__PURE__ */ jsx("button", {
|
|
72
|
+
type: "button",
|
|
73
|
+
onClick,
|
|
74
|
+
disabled,
|
|
75
|
+
"aria-label": label,
|
|
76
|
+
className: clsx(headerActionButtonClasses, disabled && "opacity-50 cursor-not-allowed hover:bg-transparent"),
|
|
77
|
+
children: /* @__PURE__ */ jsx(FaEdit, { className: "w-3 h-3" })
|
|
78
|
+
})
|
|
101
79
|
});
|
|
102
80
|
}
|
|
103
81
|
/** Renders nothing when the modern breadcrumb strip isn't mounted (classic chrome or self-headered pages). */
|
|
@@ -112,28 +90,24 @@ function BreadcrumbsRightAction({ children }) {
|
|
|
112
90
|
return createPortal(children, rightActionSlot);
|
|
113
91
|
}
|
|
114
92
|
var breadcrumbsActionClasses = "flex items-center gap-1 link text-xs whitespace-nowrap disabled:opacity-50 disabled:cursor-not-allowed";
|
|
115
|
-
function BreadcrumbsActionButton({ icon: Icon, label, ariaLabel,
|
|
93
|
+
function BreadcrumbsActionButton({ icon: Icon, label, ariaLabel, href, onClick, disabled, tooltip }) {
|
|
116
94
|
const Link = useLink();
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
className: breadcrumbsActionClasses,
|
|
134
|
-
...ariaLabel ? { "aria-label": ariaLabel } : {},
|
|
135
|
-
...tip,
|
|
136
|
-
children: content
|
|
95
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Icon, { className: "w-3 h-3" }), label] });
|
|
96
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
97
|
+
content: tooltip,
|
|
98
|
+
children: href && !disabled ? /* @__PURE__ */ jsx(Link, {
|
|
99
|
+
href,
|
|
100
|
+
className: breadcrumbsActionClasses,
|
|
101
|
+
"aria-label": ariaLabel,
|
|
102
|
+
children: content
|
|
103
|
+
}) : /* @__PURE__ */ jsx("button", {
|
|
104
|
+
type: "button",
|
|
105
|
+
onClick,
|
|
106
|
+
disabled,
|
|
107
|
+
className: breadcrumbsActionClasses,
|
|
108
|
+
"aria-label": ariaLabel,
|
|
109
|
+
children: content
|
|
110
|
+
})
|
|
137
111
|
});
|
|
138
112
|
}
|
|
139
113
|
function PageHeader({ breadcrumbs, title, titleAction, actions, toolbar, className, sticky = true, stickyTopClassName = "top-0" }) {
|
|
@@ -158,8 +132,8 @@ function PageHeader({ breadcrumbs, title, titleAction, actions, toolbar, classNa
|
|
|
158
132
|
className: "m-0 text-[13px] font-medium leading-none text-(--theme-app) truncate",
|
|
159
133
|
children: crumb.label
|
|
160
134
|
}, key);
|
|
161
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [crumb.href ? /* @__PURE__ */ jsx(Link, {
|
|
162
|
-
|
|
135
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [crumb.href ? /* @__PURE__ */ jsx(Link, {
|
|
136
|
+
href: crumb.href,
|
|
163
137
|
className: "text-(--theme-muted-text-color) hover:text-(--theme-app) transition-colors cursor-pointer whitespace-nowrap",
|
|
164
138
|
children: crumb.label
|
|
165
139
|
}) : /* @__PURE__ */ jsx("span", {
|
|
@@ -183,9 +157,9 @@ function PageHeader({ breadcrumbs, title, titleAction, actions, toolbar, classNa
|
|
|
183
157
|
children: [toggle, crumbRow]
|
|
184
158
|
}) : /* @__PURE__ */ jsx("div", {});
|
|
185
159
|
return /* @__PURE__ */ jsxs("div", {
|
|
186
|
-
className:
|
|
160
|
+
className: clsx(sticky && clsx("sticky z-20", stickyTopClassName), "w-full bg-(--theme-app-bg)", className),
|
|
187
161
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
188
|
-
className:
|
|
162
|
+
className: clsx("flex items-center justify-between gap-6 px-4 h-11", hasLeading && "border-b border-(--theme-border)"),
|
|
189
163
|
children: [leading, actionCluster]
|
|
190
164
|
}), toolbar && /* @__PURE__ */ jsx("div", {
|
|
191
165
|
className: "px-4",
|
|
@@ -194,4 +168,4 @@ function PageHeader({ breadcrumbs, title, titleAction, actions, toolbar, classNa
|
|
|
194
168
|
});
|
|
195
169
|
}
|
|
196
170
|
//#endregion
|
|
197
|
-
export { BreadcrumbsActionButton, BreadcrumbsRightAction, BreadcrumbsTitleAction, HeaderActionMenu, HeaderAddButton, HeaderEditButton,
|
|
171
|
+
export { BreadcrumbsActionButton, BreadcrumbsRightAction, BreadcrumbsTitleAction, HeaderActionMenu, HeaderAddButton, HeaderEditButton, PageHeader, headerActionButtonClasses };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { useStrings } from "./Provider.js";
|
|
2
|
-
import
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
//#region src/components/Pagination.tsx
|
|
5
5
|
function Pagination({ endingNumber, endingTime, nextCallback, prevCallback, roundedBottom, startingNumber, startingTime, nextDisabled, prevDisabled, name, useTimeRange = false }) {
|
|
6
6
|
const t = useStrings().list;
|
|
7
7
|
return /* @__PURE__ */ jsxs("nav", {
|
|
8
|
-
className:
|
|
8
|
+
className: clsx(roundedBottom && "rounded-b-2xl", "theme-muted-panel flex items-center justify-between border-t theme-border px-4 py-1 sm:px-6"),
|
|
9
9
|
"aria-label": "Pagination",
|
|
10
10
|
children: [/* @__PURE__ */ jsx("div", {
|
|
11
|
-
className:
|
|
11
|
+
className: clsx("hidden", (startingNumber !== void 0 && endingNumber !== void 0 || startingTime && endingTime) && "sm:block"),
|
|
12
12
|
children: /* @__PURE__ */ jsx("p", {
|
|
13
13
|
className: "text-sm whitespace-nowrap",
|
|
14
14
|
children: useTimeRange && startingTime && endingTime ? t.paginationShowingTimeRange(name ?? "", startingTime, endingTime) : t.paginationShowing(name ?? "", startingNumber ?? "", endingNumber ?? "")
|
|
@@ -19,13 +19,13 @@ function Pagination({ endingNumber, endingTime, nextCallback, prevCallback, roun
|
|
|
19
19
|
type: "button",
|
|
20
20
|
disabled: prevDisabled,
|
|
21
21
|
onClick: prevCallback,
|
|
22
|
-
className:
|
|
22
|
+
className: clsx("link text-sm", prevDisabled && "disabled"),
|
|
23
23
|
children: t.paginationPrevious
|
|
24
24
|
}), /* @__PURE__ */ jsx("button", {
|
|
25
25
|
type: "button",
|
|
26
26
|
disabled: nextDisabled,
|
|
27
27
|
onClick: nextCallback,
|
|
28
|
-
className:
|
|
28
|
+
className: clsx("link text-sm", nextDisabled && "disabled"),
|
|
29
29
|
children: t.paginationNext
|
|
30
30
|
})]
|
|
31
31
|
})]
|
|
@@ -45,7 +45,6 @@ export interface UIStrings {
|
|
|
45
45
|
favoriteHintOn: string;
|
|
46
46
|
favoriteHintOff: string;
|
|
47
47
|
filter: string;
|
|
48
|
-
noOptions: string;
|
|
49
48
|
};
|
|
50
49
|
common: {
|
|
51
50
|
copy: string;
|
|
@@ -59,6 +58,7 @@ export interface UIStrings {
|
|
|
59
58
|
remove: string;
|
|
60
59
|
sort: string;
|
|
61
60
|
userAvatar: string;
|
|
61
|
+
moreInfo: string;
|
|
62
62
|
};
|
|
63
63
|
dropdown: {
|
|
64
64
|
select: (type: string) => string;
|
|
@@ -354,7 +354,6 @@ export interface UIStrings {
|
|
|
354
354
|
couldntCopy: (label: string) => string;
|
|
355
355
|
moreActions: string;
|
|
356
356
|
/** A toolbar toggle's name in the overflow menu, where a row can't be pressed. */
|
|
357
|
-
toggleState: (label: string, on: boolean) => string;
|
|
358
357
|
labelName: string;
|
|
359
358
|
labelEmail: string;
|
|
360
359
|
labelUsername: string;
|
|
@@ -448,15 +447,10 @@ import type { FieldComponent } from '../form/fieldRegistry.js';
|
|
|
448
447
|
import type { PageHeaderCrumb } from './PageHeader.js';
|
|
449
448
|
/** Renders internal navigation; hosts bind their router's Link. Accessibility
|
|
450
449
|
* and tooltip data attributes pass through so header links keep their labels. */
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
children: ReactNode;
|
|
456
|
-
title?: string | undefined;
|
|
457
|
-
'aria-label'?: string | undefined;
|
|
458
|
-
'aria-current'?: 'page' | undefined;
|
|
459
|
-
[dataAttr: `data-${string}`]: string | undefined;
|
|
450
|
+
/** An internal navigation link. It passes every other prop, ref included, to
|
|
451
|
+
* its anchor, so menus and tooltips can attach to it. */
|
|
452
|
+
export type UILinkComponent = React.ComponentType<React.ComponentPropsWithRef<'a'> & {
|
|
453
|
+
href: string;
|
|
460
454
|
}>;
|
|
461
455
|
/** The provider's link slot, with a plain anchor fallback. */
|
|
462
456
|
export declare function useLink(): UILinkComponent;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { safeUrl } from "../safeUrl.js";
|
|
2
|
+
import { TooltipProvider } from "./Tooltip.js";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
4
|
import { createContext, use, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
3
5
|
import { useLocalStorage } from "usehooks-ts";
|
|
4
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
//#region src/components/Provider.tsx
|
|
6
|
-
var DefaultLink = ({
|
|
7
|
-
href: safeUrl(
|
|
8
|
-
|
|
9
|
-
className,
|
|
10
|
-
...rest,
|
|
11
|
-
children
|
|
7
|
+
var DefaultLink = ({ href, ...rest }) => /* @__PURE__ */ jsx("a", {
|
|
8
|
+
href: safeUrl(href),
|
|
9
|
+
...rest
|
|
12
10
|
});
|
|
13
11
|
/** The provider's link slot, with a plain anchor fallback. */
|
|
14
12
|
function useLink() {
|
|
@@ -46,8 +44,7 @@ var DEFAULTS = {
|
|
|
46
44
|
favorited: "Favorited",
|
|
47
45
|
favoriteHintOn: "Your item will be favorited when it's created",
|
|
48
46
|
favoriteHintOff: "Favorite your item when it's created",
|
|
49
|
-
filter: "Filter"
|
|
50
|
-
noOptions: "No options available"
|
|
47
|
+
filter: "Filter"
|
|
51
48
|
},
|
|
52
49
|
common: {
|
|
53
50
|
copy: "Copy",
|
|
@@ -60,7 +57,8 @@ var DEFAULTS = {
|
|
|
60
57
|
jsonHasErrors: "JSON has errors, please fix before saving",
|
|
61
58
|
remove: "Remove",
|
|
62
59
|
sort: "Sort",
|
|
63
|
-
userAvatar: "User avatar"
|
|
60
|
+
userAvatar: "User avatar",
|
|
61
|
+
moreInfo: "More information"
|
|
64
62
|
},
|
|
65
63
|
dropdown: {
|
|
66
64
|
select: (type) => `Select ${type}`,
|
|
@@ -350,7 +348,6 @@ var DEFAULTS = {
|
|
|
350
348
|
copied: (label) => `Copied ${label}`,
|
|
351
349
|
couldntCopy: (label) => `Couldn't copy ${label}`,
|
|
352
350
|
moreActions: "More actions",
|
|
353
|
-
toggleState: (label, on) => `${label}, ${on ? "on" : "off"}`,
|
|
354
351
|
labelName: "name",
|
|
355
352
|
labelEmail: "email",
|
|
356
353
|
labelUsername: "username",
|
|
@@ -383,7 +380,7 @@ var DEFAULTS = {
|
|
|
383
380
|
perPage: "Per page",
|
|
384
381
|
paginationPrevious: "Previous",
|
|
385
382
|
paginationNext: "Next",
|
|
386
|
-
paginationShowing: (name, start, end) => /* @__PURE__ */ jsxs(Fragment
|
|
383
|
+
paginationShowing: (name, start, end) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
387
384
|
"Showing ",
|
|
388
385
|
name,
|
|
389
386
|
" ",
|
|
@@ -398,7 +395,7 @@ var DEFAULTS = {
|
|
|
398
395
|
children: end
|
|
399
396
|
})
|
|
400
397
|
] }),
|
|
401
|
-
paginationShowingTimeRange: (name, startTime, endTime) => /* @__PURE__ */ jsxs(Fragment
|
|
398
|
+
paginationShowingTimeRange: (name, startTime, endTime) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
402
399
|
"Showing ",
|
|
403
400
|
name,
|
|
404
401
|
" from ",
|
|
@@ -613,7 +610,7 @@ function UIProvider({ notify, strings, navigation, data, slots, engine, children
|
|
|
613
610
|
]);
|
|
614
611
|
return /* @__PURE__ */ jsx(UIContext.Provider, {
|
|
615
612
|
value,
|
|
616
|
-
children
|
|
613
|
+
children: /* @__PURE__ */ jsx(TooltipProvider, { children })
|
|
617
614
|
});
|
|
618
615
|
}
|
|
619
616
|
//#endregion
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Radio as BaseRadio } from '@base-ui/react/radio';
|
|
2
|
+
export { RadioGroup } from '@base-ui/react/radio-group';
|
|
3
|
+
export interface RadioProps<Value> extends Omit<BaseRadio.Root.Props<Value>, 'className'> {
|
|
4
|
+
className?: string | undefined;
|
|
5
|
+
}
|
|
6
|
+
/** One choice in a `RadioGroup`, which holds the value. Name it with an
|
|
7
|
+
* enclosing `<label>`. */
|
|
8
|
+
export declare function Radio<Value>({ className, ...props }: RadioProps<Value>): import("react").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { clsx } from "clsx";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Radio } from "@base-ui/react/radio";
|
|
4
|
+
import { RadioGroup } from "@base-ui/react/radio-group";
|
|
5
|
+
//#region src/components/Radio.tsx
|
|
6
|
+
/** One choice in a `RadioGroup`, which holds the value. Name it with an
|
|
7
|
+
* enclosing `<label>`. */
|
|
8
|
+
function Radio$1({ className, ...props }) {
|
|
9
|
+
return /* @__PURE__ */ jsx(Radio.Root, {
|
|
10
|
+
...props,
|
|
11
|
+
className: clsx("flex size-4 shrink-0 items-center justify-center rounded-full border border-(--theme-border) bg-(--theme-input-bg) cursor-pointer outline-none transition-colors", "data-checked:border-(--theme-element) data-checked:bg-(--theme-element)", "focus-visible:ring-2 focus-visible:ring-(--theme-focus-ring) aria-invalid:border-(--theme-error)", "data-disabled:cursor-not-allowed data-disabled:opacity-50", className),
|
|
12
|
+
children: /* @__PURE__ */ jsx(Radio.Indicator, { className: "size-1.5 rounded-full bg-(--theme-element-text)" })
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { Radio$1 as Radio, RadioGroup };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { clsx } from "clsx";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
//#region src/components/SectionHeader.tsx
|
|
4
4
|
function SectionHeader({ children, className = "", size = "md" }) {
|
|
5
5
|
return /* @__PURE__ */ jsx("div", {
|
|
6
|
-
className:
|
|
6
|
+
className: clsx("w-full font-semibold", size === "sm" ? "mb-2 text-sm theme-text" : "text-lg", className),
|
|
7
7
|
children
|
|
8
8
|
});
|
|
9
9
|
}
|
|
@@ -5,18 +5,19 @@ export interface SegmentedOption<T extends string> {
|
|
|
5
5
|
icon?: ReactNode;
|
|
6
6
|
/** Beside the label, or in the corner when only the icon shows. */
|
|
7
7
|
badge?: ReactNode;
|
|
8
|
-
/** Navigates instead of
|
|
9
|
-
|
|
8
|
+
/** Navigates instead of choosing, for segments that are pages. */
|
|
9
|
+
href?: string;
|
|
10
10
|
testId?: string;
|
|
11
11
|
}
|
|
12
12
|
/** A few mutually exclusive choices side by side, one always current. With
|
|
13
13
|
* `iconOnly` the segments stack as icons with their labels in tooltips, for
|
|
14
|
-
* a collapsed rail.
|
|
15
|
-
|
|
14
|
+
* a collapsed rail. Segments with `href` are pages, so the control becomes
|
|
15
|
+
* navigation. */
|
|
16
|
+
export declare function SegmentedControl<T extends string>({ label, options, value, onValueChange, fill, iconOnly, testId, }: {
|
|
16
17
|
label: string;
|
|
17
18
|
options: SegmentedOption<T>[];
|
|
18
19
|
value: T;
|
|
19
|
-
|
|
20
|
+
onValueChange?: (value: T) => void;
|
|
20
21
|
/** Segments share the container's width equally. */
|
|
21
22
|
fill?: boolean;
|
|
22
23
|
iconOnly?: boolean;
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
+
import { Tooltip } from "./Tooltip.js";
|
|
1
2
|
import { useLink } from "./Provider.js";
|
|
2
|
-
import {
|
|
3
|
-
import cx from "classnames";
|
|
3
|
+
import { clsx } from "clsx";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Toggle } from "@base-ui/react/toggle";
|
|
6
|
+
import { ToggleGroup } from "@base-ui/react/toggle-group";
|
|
5
7
|
//#region src/components/SegmentedControl.tsx
|
|
6
8
|
var itemBase = "relative flex min-w-0 items-center justify-center rounded-md font-medium transition-colors duration-150 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-(--theme-link)";
|
|
7
9
|
var itemCurrent = "bg-(--theme-panel-bg) theme-text shadow-sm ring-1 ring-(--theme-border)";
|
|
8
10
|
var itemIdle = "theme-muted-text hover:theme-text hover:bg-(--theme-hover)";
|
|
9
11
|
/** A few mutually exclusive choices side by side, one always current. With
|
|
10
12
|
* `iconOnly` the segments stack as icons with their labels in tooltips, for
|
|
11
|
-
* a collapsed rail.
|
|
12
|
-
|
|
13
|
+
* a collapsed rail. Segments with `href` are pages, so the control becomes
|
|
14
|
+
* navigation. */
|
|
15
|
+
function SegmentedControl({ label, options, value, onValueChange, fill = false, iconOnly = false, testId }) {
|
|
13
16
|
const Link = useLink();
|
|
14
|
-
const links = options.some((o) => o.
|
|
17
|
+
const links = options.some((o) => o.href);
|
|
15
18
|
const items = options.map((option) => {
|
|
16
19
|
const current = option.value === value;
|
|
17
|
-
const className =
|
|
20
|
+
const className = clsx(itemBase, current ? itemCurrent : itemIdle, iconOnly ? "h-8 w-8" : clsx("h-7 gap-1.5 text-[13px]", fill ? "px-1.5" : "px-2.5"));
|
|
18
21
|
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
19
22
|
option.icon,
|
|
20
23
|
iconOnly ? /* @__PURE__ */ jsx("span", {
|
|
@@ -29,39 +32,40 @@ function SegmentedControl({ label, options, value, onChange, fill = false, iconO
|
|
|
29
32
|
children: option.badge
|
|
30
33
|
}) : option.badge)
|
|
31
34
|
] });
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
onClick: () => onChange?.(option.value),
|
|
49
|
-
className,
|
|
50
|
-
...tooltip,
|
|
51
|
-
children: content
|
|
35
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
36
|
+
content: option.label,
|
|
37
|
+
side: "right",
|
|
38
|
+
disabled: !iconOnly,
|
|
39
|
+
children: option.href ? /* @__PURE__ */ jsx(Link, {
|
|
40
|
+
href: option.href,
|
|
41
|
+
"aria-current": current ? "page" : void 0,
|
|
42
|
+
"data-testid": option.testId,
|
|
43
|
+
className,
|
|
44
|
+
children: content
|
|
45
|
+
}) : /* @__PURE__ */ jsx(Toggle, {
|
|
46
|
+
value: option.value,
|
|
47
|
+
"data-testid": option.testId,
|
|
48
|
+
className,
|
|
49
|
+
children: content
|
|
50
|
+
})
|
|
52
51
|
}, option.value);
|
|
53
52
|
});
|
|
54
|
-
const groupClassName =
|
|
55
|
-
|
|
53
|
+
const groupClassName = clsx("gap-0.5", iconOnly ? "flex flex-col items-center" : clsx("rounded-lg theme-muted-panel p-0.5", fill ? "grid auto-cols-fr grid-flow-col" : "inline-flex"));
|
|
54
|
+
if (links) return /* @__PURE__ */ jsx("nav", {
|
|
56
55
|
"aria-label": label,
|
|
57
56
|
"data-testid": testId,
|
|
58
57
|
className: groupClassName,
|
|
59
58
|
children: items
|
|
60
|
-
})
|
|
61
|
-
|
|
59
|
+
});
|
|
60
|
+
return /* @__PURE__ */ jsx(ToggleGroup, {
|
|
62
61
|
"aria-label": label,
|
|
63
62
|
"data-testid": testId,
|
|
64
63
|
className: groupClassName,
|
|
64
|
+
orientation: iconOnly ? "vertical" : "horizontal",
|
|
65
|
+
value: [value],
|
|
66
|
+
onValueChange: ([next]) => {
|
|
67
|
+
if (next !== void 0) onValueChange?.(next);
|
|
68
|
+
},
|
|
65
69
|
children: items
|
|
66
70
|
});
|
|
67
71
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Select as BaseSelect } from '@base-ui/react/select';
|
|
2
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
3
|
+
export interface SelectItem<Value> {
|
|
4
|
+
value: Value;
|
|
5
|
+
label: string;
|
|
6
|
+
/** A second line under the label, such as what an option does. */
|
|
7
|
+
description?: string | undefined;
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
disabled?: boolean | undefined;
|
|
10
|
+
}
|
|
11
|
+
export type SelectProps<Value, Multiple extends boolean | undefined = false> = Omit<BaseSelect.Root.Props<Value, Multiple>, 'items' | 'children'> & {
|
|
12
|
+
items: readonly SelectItem<Value>[];
|
|
13
|
+
placeholder?: string | undefined;
|
|
14
|
+
/** Applied to the trigger. */
|
|
15
|
+
className?: string | undefined;
|
|
16
|
+
'aria-label'?: string | undefined;
|
|
17
|
+
'aria-describedby'?: string | undefined;
|
|
18
|
+
'aria-invalid'?: boolean | undefined;
|
|
19
|
+
/** Renders the field as this button, for compact pickers such as a toolbar pill. The
|
|
20
|
+
* button shows the selection itself; `placeholder` and `className` then go unused. */
|
|
21
|
+
trigger?: ReactElement | undefined;
|
|
22
|
+
/** A hint on the trigger button. */
|
|
23
|
+
triggerTooltip?: ReactNode;
|
|
24
|
+
};
|
|
25
|
+
/** Picks one value, or several with `multiple`, from a short list. Use
|
|
26
|
+
* Combobox when the list is long enough to need filtering. */
|
|
27
|
+
export declare function Select<Value, Multiple extends boolean | undefined = false>({ items, placeholder, className, 'aria-label': ariaLabel, 'aria-describedby': describedBy, 'aria-invalid': invalid, trigger, triggerTooltip, ...rootProps }: SelectProps<Value, Multiple>): import("react").JSX.Element;
|