@stll/workspace-ui 0.18.4 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/sort-chip-classes.d.ts +14 -0
- package/dist/sort-chip-classes.js +16 -0
- package/dist/sorts-face.d.ts +12 -0
- package/dist/sorts-face.js +31 -0
- package/dist/sorts.js +3 -2
- package/dist/view-strip.d.ts +59 -0
- package/dist/view-strip.js +80 -0
- package/dist/view-switcher-face.d.ts +7 -0
- package/dist/view-switcher-face.js +14 -0
- package/dist/view-switcher.d.ts +4 -5
- package/dist/view-switcher.js +36 -59
- package/dist/workspace-frame.d.ts +1 -0
- package/dist/workspace-frame.js +2 -1
- package/package.json +15 -3
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ import { TableSkeletonRows } from "./table-skeleton-rows.js";
|
|
|
13
13
|
import { WorkspaceFrame, WorkspaceFrameEndRail, WorkspaceFrameInspector, WorkspaceFrameNavigation, WorkspaceFrameNavigationItem, WorkspaceFrameProps, WorkspaceFrameTopBar } from "./workspace-frame.js";
|
|
14
14
|
import { WorkspaceKanbanGroupingPicker } from "./kanban-grouping-picker.js";
|
|
15
15
|
import { WorkspaceUiFormattingProvider, WorkspaceUiFormattingProviderProps } from "./formatting.js";
|
|
16
|
-
import {
|
|
16
|
+
import { WorkspaceViewStrip, WorkspaceViewStripProps, WorkspaceViewSwitcherFace, WorkspaceViewSwitcherFaceProps, WorkspaceViewSwitcherItem, WorkspaceViewTabFace, WorkspaceViewTabFaceProps } from "./view-strip.js";
|
|
17
|
+
import { WorkspaceViewSwitcher, WorkspaceViewSwitcherEditing, WorkspaceViewSwitcherProps, WorkspaceViewSwitcherReorder } from "./view-switcher.js";
|
|
18
|
+
import { WorkspaceViewTabName } from "./view-switcher-face.js";
|
|
17
19
|
import { getClipFieldValueLabel } from "./field-value-logic.js";
|
|
18
|
-
export { type ApplyCalculationSelectionParams, CONDITION_OPERATORS, type CalculationFormatters, CalculationKindPicker, type CalculationKindPickerProps, type CalculationLabels, CalculationPicker, type CalculationPickerProps, type CalculationProperty, type CalculationResult, type CalculationSelection, CalculationSummary, type CalculationSummaryProps, type ColorVariants, ColumnCalculation, ConditionBuilder, type ConditionBuilderLabels, type ConditionCapabilities, type ConditionOperator, type CreateWorkspaceKanbanSchemaParams, FIELD_CONTENT_TYPES, type FieldContent, type FieldOption, type FieldOptionChoice, FieldValue, type FieldValueType, type FormatCalculationParams, type FormattedCalculation, type FormulaCellRenderCtx, type GenericProperty, IntFieldValue, KANBAN_EMPTY_GROUP_VISIBILITIES, KANBAN_SAVED_VIEW_STATE_VERSION, type KanbanBoardPresentation, type KanbanEmptyGroupVisibility, type KanbanPresentedBand, type KanbanPresentedLane, type KanbanSavedAxisState, type KanbanSavedGroupAxisState, type KanbanSavedGroupReference, type KanbanSavedSubgroupState, type KanbanSavedViewState, type KanbanSavedViewStateV1, MoneyFieldValue, type OptionColor, PersonFieldValue, PropertyIcon, type PropertyIconType, type ResolveWorkspaceKanbanViewParams, type ResolvedWorkspaceKanbanView, SortChips, type SortChipsLabels, type SortChipsProps, type SortDescriptor, type SortableProperty, TableSkeletonRows, type UseCalculationParams, type ValueEditorKind, type ValueEditorRenderCtx, type WorkspaceCalculationLabels, type WorkspaceFieldContent, WorkspaceFrame, type WorkspaceFrameEndRail, type WorkspaceFrameInspector, type WorkspaceFrameNavigation, type WorkspaceFrameNavigationItem, type WorkspaceFrameProps, type WorkspaceFrameTopBar, type WorkspaceKanbanBuiltInGroupLabel, type WorkspaceKanbanGroupingChoice, WorkspaceKanbanGroupingPicker, type WorkspaceKanbanGroupingPickerLabels, type WorkspaceKanbanGroupingPickerProps, type WorkspaceKanbanProperty, WorkspaceUiFormattingProvider, type WorkspaceUiFormattingProviderProps, WorkspaceViewSwitcher, type WorkspaceViewSwitcherEditing, type WorkspaceViewSwitcherItem, type WorkspaceViewSwitcherProps, type WorkspaceViewSwitcherReorder, appendChild, applyCalculationSelection, asGroup, buildLeaf, createWorkspaceKanbanSchema, emptyColor, fieldForNode, formatCalculationResult, getClipFieldValueLabel, getWorkspaceKanbanGroupingChoices, isConditionOperator, isMultiValue, leafFromField, leafOperand, leafOperator, leafValueList, leafValueString, normalizeKanbanSavedViewState, operandsEqual, operatorsFor, optionColors, presentKanbanBoard, removeChild, replaceChild, resolveOptionColor, resolveWorkspaceKanbanView, useCalculation, valueEditorFor };
|
|
20
|
+
export { type ApplyCalculationSelectionParams, CONDITION_OPERATORS, type CalculationFormatters, CalculationKindPicker, type CalculationKindPickerProps, type CalculationLabels, CalculationPicker, type CalculationPickerProps, type CalculationProperty, type CalculationResult, type CalculationSelection, CalculationSummary, type CalculationSummaryProps, type ColorVariants, ColumnCalculation, ConditionBuilder, type ConditionBuilderLabels, type ConditionCapabilities, type ConditionOperator, type CreateWorkspaceKanbanSchemaParams, FIELD_CONTENT_TYPES, type FieldContent, type FieldOption, type FieldOptionChoice, FieldValue, type FieldValueType, type FormatCalculationParams, type FormattedCalculation, type FormulaCellRenderCtx, type GenericProperty, IntFieldValue, KANBAN_EMPTY_GROUP_VISIBILITIES, KANBAN_SAVED_VIEW_STATE_VERSION, type KanbanBoardPresentation, type KanbanEmptyGroupVisibility, type KanbanPresentedBand, type KanbanPresentedLane, type KanbanSavedAxisState, type KanbanSavedGroupAxisState, type KanbanSavedGroupReference, type KanbanSavedSubgroupState, type KanbanSavedViewState, type KanbanSavedViewStateV1, MoneyFieldValue, type OptionColor, PersonFieldValue, PropertyIcon, type PropertyIconType, type ResolveWorkspaceKanbanViewParams, type ResolvedWorkspaceKanbanView, SortChips, type SortChipsLabels, type SortChipsProps, type SortDescriptor, type SortableProperty, TableSkeletonRows, type UseCalculationParams, type ValueEditorKind, type ValueEditorRenderCtx, type WorkspaceCalculationLabels, type WorkspaceFieldContent, WorkspaceFrame, type WorkspaceFrameEndRail, type WorkspaceFrameInspector, type WorkspaceFrameNavigation, type WorkspaceFrameNavigationItem, type WorkspaceFrameProps, type WorkspaceFrameTopBar, type WorkspaceKanbanBuiltInGroupLabel, type WorkspaceKanbanGroupingChoice, WorkspaceKanbanGroupingPicker, type WorkspaceKanbanGroupingPickerLabels, type WorkspaceKanbanGroupingPickerProps, type WorkspaceKanbanProperty, WorkspaceUiFormattingProvider, type WorkspaceUiFormattingProviderProps, WorkspaceViewStrip, type WorkspaceViewStripProps, WorkspaceViewSwitcher, type WorkspaceViewSwitcherEditing, WorkspaceViewSwitcherFace, type WorkspaceViewSwitcherFaceProps, type WorkspaceViewSwitcherItem, type WorkspaceViewSwitcherProps, type WorkspaceViewSwitcherReorder, WorkspaceViewTabFace, type WorkspaceViewTabFaceProps, WorkspaceViewTabName, appendChild, applyCalculationSelection, asGroup, buildLeaf, createWorkspaceKanbanSchema, emptyColor, fieldForNode, formatCalculationResult, getClipFieldValueLabel, getWorkspaceKanbanGroupingChoices, isConditionOperator, isMultiValue, leafFromField, leafOperand, leafOperator, leafValueList, leafValueString, normalizeKanbanSavedViewState, operandsEqual, operatorsFor, optionColors, presentKanbanBoard, removeChild, replaceChild, resolveOptionColor, resolveWorkspaceKanbanView, useCalculation, valueEditorFor };
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,8 @@ import { TableSkeletonRows } from "./table-skeleton-rows.js";
|
|
|
13
13
|
import { FIELD_CONTENT_TYPES } from "./types.js";
|
|
14
14
|
import { KANBAN_EMPTY_GROUP_VISIBILITIES, KANBAN_SAVED_VIEW_STATE_VERSION, createWorkspaceKanbanSchema, getWorkspaceKanbanGroupingChoices, normalizeKanbanSavedViewState, presentKanbanBoard, resolveWorkspaceKanbanView } from "./kanban-view.js";
|
|
15
15
|
import { WorkspaceKanbanGroupingPicker } from "./kanban-grouping-picker.js";
|
|
16
|
+
import { WorkspaceViewStrip, WorkspaceViewSwitcherFace, WorkspaceViewTabFace } from "./view-strip.js";
|
|
16
17
|
import { WorkspaceViewSwitcher } from "./view-switcher.js";
|
|
18
|
+
import { WorkspaceViewTabName } from "./view-switcher-face.js";
|
|
17
19
|
import { WorkspaceFrame } from "./workspace-frame.js";
|
|
18
|
-
export { CONDITION_OPERATORS, CalculationKindPicker, CalculationPicker, CalculationSummary, ColumnCalculation, ConditionBuilder, FIELD_CONTENT_TYPES, FieldValue, IntFieldValue, KANBAN_EMPTY_GROUP_VISIBILITIES, KANBAN_SAVED_VIEW_STATE_VERSION, MoneyFieldValue, PersonFieldValue, PropertyIcon, SortChips, TableSkeletonRows, WorkspaceFrame, WorkspaceKanbanGroupingPicker, WorkspaceUiFormattingProvider, WorkspaceViewSwitcher, appendChild, applyCalculationSelection, asGroup, buildLeaf, createWorkspaceKanbanSchema, emptyColor, fieldForNode, formatCalculationResult, getClipFieldValueLabel, getWorkspaceKanbanGroupingChoices, isConditionOperator, isMultiValue, leafFromField, leafOperand, leafOperator, leafValueList, leafValueString, normalizeKanbanSavedViewState, operandsEqual, operatorsFor, optionColors, presentKanbanBoard, removeChild, replaceChild, resolveOptionColor, resolveWorkspaceKanbanView, useCalculation, valueEditorFor };
|
|
20
|
+
export { CONDITION_OPERATORS, CalculationKindPicker, CalculationPicker, CalculationSummary, ColumnCalculation, ConditionBuilder, FIELD_CONTENT_TYPES, FieldValue, IntFieldValue, KANBAN_EMPTY_GROUP_VISIBILITIES, KANBAN_SAVED_VIEW_STATE_VERSION, MoneyFieldValue, PersonFieldValue, PropertyIcon, SortChips, TableSkeletonRows, WorkspaceFrame, WorkspaceKanbanGroupingPicker, WorkspaceUiFormattingProvider, WorkspaceViewStrip, WorkspaceViewSwitcher, WorkspaceViewSwitcherFace, WorkspaceViewTabFace, WorkspaceViewTabName, appendChild, applyCalculationSelection, asGroup, buildLeaf, createWorkspaceKanbanSchema, emptyColor, fieldForNode, formatCalculationResult, getClipFieldValueLabel, getWorkspaceKanbanGroupingChoices, isConditionOperator, isMultiValue, leafFromField, leafOperand, leafOperator, leafValueList, leafValueString, normalizeKanbanSavedViewState, operandsEqual, operatorsFor, optionColors, presentKanbanBoard, removeChild, replaceChild, resolveOptionColor, resolveWorkspaceKanbanView, useCalculation, valueEditorFor };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The bordered pill around one sort's toggle and its remove button. */
|
|
2
|
+
export declare const SORT_CHIP_CLASS = "bg-muted/50 flex items-center rounded-md border";
|
|
3
|
+
/** The part that names the sort and flips its direction. */
|
|
4
|
+
export declare const SORT_CHIP_TOGGLE: {
|
|
5
|
+
readonly size: "xs";
|
|
6
|
+
readonly variant: "ghost";
|
|
7
|
+
};
|
|
8
|
+
/** A glyph-only button: the chip's remove, and "add a sort". */
|
|
9
|
+
export declare const SORT_ICON_BUTTON: {
|
|
10
|
+
readonly size: "icon-xs";
|
|
11
|
+
readonly variant: "ghost";
|
|
12
|
+
};
|
|
13
|
+
/** The direction's words beside the property's name. */
|
|
14
|
+
export declare const SORT_DIRECTION_CLASS = "text-muted-foreground";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/sort-chip-classes.ts
|
|
2
|
+
/** The bordered pill around one sort's toggle and its remove button. */
|
|
3
|
+
const SORT_CHIP_CLASS = "bg-muted/50 flex items-center rounded-md border";
|
|
4
|
+
/** The part that names the sort and flips its direction. */
|
|
5
|
+
const SORT_CHIP_TOGGLE = {
|
|
6
|
+
size: "xs",
|
|
7
|
+
variant: "ghost"
|
|
8
|
+
};
|
|
9
|
+
/** A glyph-only button: the chip's remove, and "add a sort". */
|
|
10
|
+
const SORT_ICON_BUTTON = {
|
|
11
|
+
size: "icon-xs",
|
|
12
|
+
variant: "ghost"
|
|
13
|
+
};
|
|
14
|
+
/** The direction's words beside the property's name. */
|
|
15
|
+
const SORT_DIRECTION_CLASS = "text-muted-foreground";
|
|
16
|
+
export { SORT_CHIP_CLASS, SORT_CHIP_TOGGLE, SORT_DIRECTION_CLASS, SORT_ICON_BUTTON };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type SortChipsFaceProps = {
|
|
2
|
+
/** The view's sorts, in order; their names wait on the properties. */
|
|
3
|
+
sorts: readonly {
|
|
4
|
+
propertyId: string;
|
|
5
|
+
}[];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* `SortChips` before the properties are read: one chip per sort, with bars
|
|
9
|
+
* where the property's name and the direction go, then "add a sort".
|
|
10
|
+
*/
|
|
11
|
+
export declare const SortChipsFace: ({ sorts }: SortChipsFaceProps) => import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SORT_CHIP_CLASS, SORT_CHIP_TOGGLE, SORT_DIRECTION_CLASS, SORT_ICON_BUTTON } from "./sort-chip-classes.js";
|
|
2
|
+
import { ArrowUpDownIcon, XIcon } from "@stll/ui/icons";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { ButtonFace, FaceLabelPending } from "@stll/ui/control-face";
|
|
5
|
+
// src/sorts-face.tsx
|
|
6
|
+
/**
|
|
7
|
+
* `SortChips` before the properties are read: one chip per sort, with bars
|
|
8
|
+
* where the property's name and the direction go, then "add a sort".
|
|
9
|
+
*/
|
|
10
|
+
const SortChipsFace = ({ sorts }) => /* @__PURE__ */ jsxs(Fragment, { children: [sorts.map((sort) => /* @__PURE__ */ jsxs("span", {
|
|
11
|
+
"aria-hidden": "true",
|
|
12
|
+
className: SORT_CHIP_CLASS,
|
|
13
|
+
"data-slot": "sort-chip-face",
|
|
14
|
+
children: [/* @__PURE__ */ jsxs(ButtonFace, {
|
|
15
|
+
size: SORT_CHIP_TOGGLE.size,
|
|
16
|
+
variant: SORT_CHIP_TOGGLE.variant,
|
|
17
|
+
children: [/* @__PURE__ */ jsx(FaceLabelPending, { className: "w-14" }), /* @__PURE__ */ jsx("span", {
|
|
18
|
+
className: SORT_DIRECTION_CLASS,
|
|
19
|
+
children: /* @__PURE__ */ jsx(FaceLabelPending, { className: "w-8" })
|
|
20
|
+
})]
|
|
21
|
+
}), /* @__PURE__ */ jsx(ButtonFace, {
|
|
22
|
+
size: SORT_ICON_BUTTON.size,
|
|
23
|
+
variant: SORT_ICON_BUTTON.variant,
|
|
24
|
+
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
25
|
+
})]
|
|
26
|
+
}, sort.propertyId)), /* @__PURE__ */ jsx(ButtonFace, {
|
|
27
|
+
size: SORT_ICON_BUTTON.size,
|
|
28
|
+
variant: SORT_ICON_BUTTON.variant,
|
|
29
|
+
children: /* @__PURE__ */ jsx(ArrowUpDownIcon, {})
|
|
30
|
+
})] });
|
|
31
|
+
export { SortChipsFace };
|
package/dist/sorts.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { sortDirectionOf } from "./column-sort.js";
|
|
2
2
|
import { PropertyIcon } from "./property-icon.js";
|
|
3
|
+
import { SORT_CHIP_CLASS, SORT_DIRECTION_CLASS } from "./sort-chip-classes.js";
|
|
3
4
|
import { Button } from "@stll/ui/button";
|
|
4
5
|
import { ArrowUpDownIcon, XIcon } from "@stll/ui/icons";
|
|
5
6
|
import { Menu, MenuItem, MenuPopup, MenuTrigger } from "@stll/ui/menu";
|
|
@@ -38,13 +39,13 @@ const SortChips = ({ sorts, properties, onUpdate, labels, maxSorts }) => /* @__P
|
|
|
38
39
|
sortedPropertyIds: new Set(sorts.map((sort) => sort.propertyId))
|
|
39
40
|
})] });
|
|
40
41
|
const SortChip = ({ propertyName, sortKind, desc, onToggle, onRemove, labels }) => /* @__PURE__ */ jsxs("div", {
|
|
41
|
-
className:
|
|
42
|
+
className: SORT_CHIP_CLASS,
|
|
42
43
|
children: [/* @__PURE__ */ jsxs(Button, {
|
|
43
44
|
onClick: onToggle,
|
|
44
45
|
size: "xs",
|
|
45
46
|
variant: "ghost",
|
|
46
47
|
children: [propertyName, /* @__PURE__ */ jsx("span", {
|
|
47
|
-
className:
|
|
48
|
+
className: SORT_DIRECTION_CLASS,
|
|
48
49
|
children: labels.directions[sortKind][sortDirectionOf(desc)]
|
|
49
50
|
})]
|
|
50
51
|
}), /* @__PURE__ */ jsx(Button, {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode, Ref } from "react";
|
|
2
|
+
import { InlineDirection } from "@stll/ui/inline-reorder";
|
|
3
|
+
import { TabsTab } from "@stll/ui/tabs";
|
|
4
|
+
export type WorkspaceViewSwitcherItem = {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
export type WorkspaceViewStripProps = {
|
|
9
|
+
activeViewId: string;
|
|
10
|
+
ariaLabel: string;
|
|
11
|
+
/** The strip's reading direction; the document's when left out. */
|
|
12
|
+
direction?: InlineDirection | undefined;
|
|
13
|
+
addControl?: ReactNode;
|
|
14
|
+
onViewChange?: (viewId: string) => void;
|
|
15
|
+
/** The element that holds the tabs, for a drop target around them. */
|
|
16
|
+
stripRef?: Ref<HTMLDivElement>;
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The saved-view strip without behaviour: one toolbar row of underline tabs
|
|
21
|
+
* and, after them, the add control. `WorkspaceViewSwitcher` renders its tabs
|
|
22
|
+
* inside it; a loading view renders `WorkspaceViewSwitcherFace` in the same
|
|
23
|
+
* strip, so the row does not move when the switcher takes over.
|
|
24
|
+
*/
|
|
25
|
+
export declare const WorkspaceViewStrip: ({ activeViewId, ariaLabel, direction, addControl, onViewChange, stripRef, children }: WorkspaceViewStripProps) => import("react").JSX.Element;
|
|
26
|
+
export type WorkspaceViewTabFaceProps = Omit<ComponentProps<typeof TabsTab>, "className"> & {
|
|
27
|
+
/** Room at the end of each tab for the active tab's action menu. */
|
|
28
|
+
reserveActionSpace: boolean;
|
|
29
|
+
};
|
|
30
|
+
/** One view's tab, sized the same with or without its behaviour. */
|
|
31
|
+
export declare const WorkspaceViewTabFace: ({ reserveActionSpace, ...props }: WorkspaceViewTabFaceProps) => import("react").JSX.Element;
|
|
32
|
+
/** A view's name on its tab: the width at which it is cut short. */
|
|
33
|
+
export declare const WORKSPACE_VIEW_TAB_NAME_CLASS = "max-w-36 whitespace-pre";
|
|
34
|
+
/** A view's name on its tab before the switcher mounts: the same box, cut
|
|
35
|
+
* short the same way, with no hint that shows the whole name. */
|
|
36
|
+
export declare const WorkspaceViewTabNameFace: ({ name }: {
|
|
37
|
+
name: string;
|
|
38
|
+
}) => import("react").JSX.Element;
|
|
39
|
+
export type WorkspaceViewSwitcherFaceProps<View extends WorkspaceViewSwitcherItem> = {
|
|
40
|
+
activeViewId: string;
|
|
41
|
+
ariaLabel: string;
|
|
42
|
+
/** The strip's reading direction; the document's when left out. */
|
|
43
|
+
direction?: InlineDirection | undefined;
|
|
44
|
+
views: readonly View[];
|
|
45
|
+
renderIcon: (view: View) => ReactNode;
|
|
46
|
+
/**
|
|
47
|
+
* A view's name in its tab's name box, for a name the caller draws itself
|
|
48
|
+
* (one that waits on the app's messages); `null`, or no callback, draws
|
|
49
|
+
* the view's own name.
|
|
50
|
+
*/
|
|
51
|
+
renderName?: ((view: View) => ReactNode) | undefined;
|
|
52
|
+
reserveActionSpace: boolean;
|
|
53
|
+
addControl?: ReactNode;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* The strip as it looks before its behaviour has loaded: the same tabs, names
|
|
57
|
+
* and icons, with no reordering, menus or renaming.
|
|
58
|
+
*/
|
|
59
|
+
export declare const WorkspaceViewSwitcherFace: <View extends WorkspaceViewSwitcherItem>({ activeViewId, ariaLabel, direction, views, renderIcon, renderName, reserveActionSpace, addControl }: WorkspaceViewSwitcherFaceProps<View>) => import("react").JSX.Element;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { BidiText } from "@stll/ui/bidi-text";
|
|
4
|
+
import { cn } from "@stll/ui/utils";
|
|
5
|
+
import { TOOLBAR_ROW_HEIGHT } from "@stll/ui/layout-tokens";
|
|
6
|
+
import { Tabs, TabsList, TabsTab } from "@stll/ui/tabs";
|
|
7
|
+
import { TRUNCATED_TEXT_LINES_CLASS } from "@stll/ui/truncated-text-face";
|
|
8
|
+
// src/view-strip.tsx
|
|
9
|
+
/**
|
|
10
|
+
* The saved-view strip without behaviour: one toolbar row of underline tabs
|
|
11
|
+
* and, after them, the add control. `WorkspaceViewSwitcher` renders its tabs
|
|
12
|
+
* inside it; a loading view renders `WorkspaceViewSwitcherFace` in the same
|
|
13
|
+
* strip, so the row does not move when the switcher takes over.
|
|
14
|
+
*/
|
|
15
|
+
const WorkspaceViewStrip = ({ activeViewId, ariaLabel, direction, addControl, onViewChange, stripRef, children }) => /* @__PURE__ */ jsxs("div", {
|
|
16
|
+
className: cn("flex min-w-0 flex-1 items-center gap-1 px-2", TOOLBAR_ROW_HEIGHT),
|
|
17
|
+
"data-slot": "workspace-view-switcher",
|
|
18
|
+
dir: direction,
|
|
19
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
20
|
+
className: "h-full min-w-0 flex-1",
|
|
21
|
+
ref: stripRef,
|
|
22
|
+
children: /* @__PURE__ */ jsx(Tabs, {
|
|
23
|
+
className: "h-full gap-0",
|
|
24
|
+
onValueChange: (value) => {
|
|
25
|
+
if (typeof value === "string") onViewChange?.(value);
|
|
26
|
+
},
|
|
27
|
+
value: activeViewId,
|
|
28
|
+
children: /* @__PURE__ */ jsx(TabsList, {
|
|
29
|
+
"aria-label": ariaLabel,
|
|
30
|
+
className: "h-full data-[orientation=horizontal]:py-0",
|
|
31
|
+
variant: "underline",
|
|
32
|
+
children
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
}), addControl === null || addControl === void 0 ? null : /* @__PURE__ */ jsx("div", {
|
|
36
|
+
className: "border-border flex shrink-0 translate-y-1 items-center border-s ps-1",
|
|
37
|
+
children: addControl
|
|
38
|
+
})]
|
|
39
|
+
});
|
|
40
|
+
/** One view's tab, sized the same with or without its behaviour. */
|
|
41
|
+
const WorkspaceViewTabFace = ({ reserveActionSpace, ...props }) => /* @__PURE__ */ jsx(TabsTab, {
|
|
42
|
+
...props,
|
|
43
|
+
className: cn("h-full pt-2 sm:h-full", reserveActionSpace ? "pe-6.5" : void 0)
|
|
44
|
+
});
|
|
45
|
+
/** A view's name on its tab: the width at which it is cut short. */
|
|
46
|
+
const WORKSPACE_VIEW_TAB_NAME_CLASS = "max-w-36 whitespace-pre";
|
|
47
|
+
/** A view's name on its tab before the switcher mounts: the same box, cut
|
|
48
|
+
* short the same way, with no hint that shows the whole name. */
|
|
49
|
+
const WorkspaceViewTabNameFace = ({ name }) => /* @__PURE__ */ jsx(BidiText, {
|
|
50
|
+
as: "span",
|
|
51
|
+
className: cn(TRUNCATED_TEXT_LINES_CLASS[1], WORKSPACE_VIEW_TAB_NAME_CLASS),
|
|
52
|
+
"data-slot": "truncated-text",
|
|
53
|
+
children: name
|
|
54
|
+
});
|
|
55
|
+
/**
|
|
56
|
+
* The strip as it looks before its behaviour has loaded: the same tabs, names
|
|
57
|
+
* and icons, with no reordering, menus or renaming.
|
|
58
|
+
*/
|
|
59
|
+
const WorkspaceViewSwitcherFace = ({ activeViewId, ariaLabel, direction, views, renderIcon, renderName, reserveActionSpace, addControl }) => /* @__PURE__ */ jsx(WorkspaceViewStrip, {
|
|
60
|
+
activeViewId,
|
|
61
|
+
addControl,
|
|
62
|
+
ariaLabel,
|
|
63
|
+
direction,
|
|
64
|
+
children: views.map((view) => {
|
|
65
|
+
const name = renderName?.(view) ?? null;
|
|
66
|
+
return /* @__PURE__ */ jsx("div", {
|
|
67
|
+
className: "relative flex h-full items-center",
|
|
68
|
+
children: /* @__PURE__ */ jsxs(WorkspaceViewTabFace, {
|
|
69
|
+
reserveActionSpace,
|
|
70
|
+
value: view.id,
|
|
71
|
+
children: [renderIcon(view), name === null ? /* @__PURE__ */ jsx(WorkspaceViewTabNameFace, { name: view.name }) : /* @__PURE__ */ jsx("span", {
|
|
72
|
+
className: cn(TRUNCATED_TEXT_LINES_CLASS[1], WORKSPACE_VIEW_TAB_NAME_CLASS),
|
|
73
|
+
"data-slot": "truncated-text",
|
|
74
|
+
children: name
|
|
75
|
+
})]
|
|
76
|
+
})
|
|
77
|
+
}, view.id);
|
|
78
|
+
})
|
|
79
|
+
});
|
|
80
|
+
export { WORKSPACE_VIEW_TAB_NAME_CLASS, WorkspaceViewStrip, WorkspaceViewSwitcherFace, WorkspaceViewTabFace, WorkspaceViewTabNameFace };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { WorkspaceViewStrip, WorkspaceViewStripProps, WorkspaceViewSwitcherFace, WorkspaceViewSwitcherFaceProps, WorkspaceViewSwitcherItem, WorkspaceViewTabFace, WorkspaceViewTabFaceProps } from "./view-strip.js";
|
|
2
|
+
/** A view's name on its tab, cut short at a fixed width; a name that is cut
|
|
3
|
+
* shows whole on hover, focus or tap. */
|
|
4
|
+
export declare const WorkspaceViewTabName: ({ name }: {
|
|
5
|
+
name: string;
|
|
6
|
+
}) => import("react").JSX.Element;
|
|
7
|
+
export { WorkspaceViewStrip, type WorkspaceViewStripProps, WorkspaceViewSwitcherFace, type WorkspaceViewSwitcherFaceProps, type WorkspaceViewSwitcherItem, WorkspaceViewTabFace, type WorkspaceViewTabFaceProps };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { WORKSPACE_VIEW_TAB_NAME_CLASS, WorkspaceViewStrip, WorkspaceViewSwitcherFace, WorkspaceViewTabFace } from "./view-strip.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { BidiText } from "@stll/ui/bidi-text";
|
|
5
|
+
import { TruncatedText } from "@stll/ui/truncated-text";
|
|
6
|
+
// src/view-switcher-face.tsx
|
|
7
|
+
/** A view's name on its tab, cut short at a fixed width; a name that is cut
|
|
8
|
+
* shows whole on hover, focus or tap. */
|
|
9
|
+
const WorkspaceViewTabName = ({ name }) => /* @__PURE__ */ jsx(TruncatedText, {
|
|
10
|
+
className: WORKSPACE_VIEW_TAB_NAME_CLASS,
|
|
11
|
+
render: /* @__PURE__ */ jsx(BidiText, { as: "span" }),
|
|
12
|
+
children: name
|
|
13
|
+
});
|
|
14
|
+
export { WorkspaceViewStrip, WorkspaceViewSwitcherFace, WorkspaceViewTabFace, WorkspaceViewTabName };
|
package/dist/view-switcher.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
import "./view-switcher-face.js";
|
|
1
2
|
import { InlineDirection } from "@stll/ui/inline-reorder";
|
|
2
|
-
|
|
3
|
-
id: string;
|
|
4
|
-
name: string;
|
|
5
|
-
};
|
|
3
|
+
import { WorkspaceViewSwitcherItem } from "./view-strip.js";
|
|
6
4
|
export type WorkspaceViewSwitcherEditing<View> = {
|
|
7
5
|
viewId: string;
|
|
8
6
|
renderLabel: (view: View) => React.ReactNode;
|
|
@@ -31,4 +29,5 @@ export type WorkspaceViewSwitcherProps<View extends WorkspaceViewSwitcherItem> =
|
|
|
31
29
|
};
|
|
32
30
|
renderIcon: (view: View) => React.ReactNode;
|
|
33
31
|
};
|
|
34
|
-
export declare const WorkspaceViewSwitcher: <View extends WorkspaceViewSwitcherItem>({ activeViewId, ariaLabel, direction, reorder, views, addControl, editing, onViewChange, onViewContextMenu, onViewDoubleClick, actionMenu, renderIcon }: WorkspaceViewSwitcherProps<View>) => import("react").JSX.Element;
|
|
32
|
+
export declare const WorkspaceViewSwitcher: <View extends WorkspaceViewSwitcherItem>({ activeViewId, ariaLabel, direction, reorder, views, addControl, editing, onViewChange, onViewContextMenu, onViewDoubleClick, actionMenu, renderIcon }: WorkspaceViewSwitcherProps<View>) => import("react").JSX.Element;
|
|
33
|
+
export type { WorkspaceViewSwitcherItem };
|
package/dist/view-switcher.js
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { WorkspaceViewStrip, WorkspaceViewTabFace } from "./view-strip.js";
|
|
3
|
+
import { WorkspaceViewTabName } from "./view-switcher-face.js";
|
|
2
4
|
import { Button } from "@stll/ui/button";
|
|
3
5
|
import { EllipsisVerticalIcon } from "@stll/ui/icons";
|
|
4
6
|
import { Menu, MenuPopup, MenuTrigger } from "@stll/ui/menu";
|
|
5
7
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
6
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { BidiText } from "@stll/ui/bidi-text";
|
|
8
|
-
import { TruncatedText } from "@stll/ui/truncated-text";
|
|
9
|
-
import { cn } from "@stll/ui/utils";
|
|
10
9
|
import { attachClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge/attach-closest-edge";
|
|
11
10
|
import { extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge/extract-closest-edge";
|
|
12
11
|
import { draggable, dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter";
|
|
13
12
|
import { combine } from "@atlaskit/pragmatic-drag-and-drop/utils/combine";
|
|
14
13
|
import { InlineDropIndicator } from "@stll/ui/inline-drop-indicator";
|
|
15
14
|
import { reorderInlineIds, toInlineDropPosition } from "@stll/ui/inline-reorder";
|
|
16
|
-
import { TOOLBAR_ROW_HEIGHT } from "@stll/ui/inspector";
|
|
17
|
-
import { Tabs, TabsList, TabsTab } from "@stll/ui/tabs";
|
|
18
15
|
// src/view-switcher.tsx
|
|
19
16
|
const VIEW_DRAG_TYPE = "@stll/workspace-ui/view-switcher/drag-type";
|
|
20
17
|
const VIEW_DRAG_ID = "@stll/workspace-ui/view-switcher/view-id";
|
|
@@ -76,53 +73,37 @@ const WorkspaceViewSwitcher = ({ activeViewId, ariaLabel, direction, reorder, vi
|
|
|
76
73
|
});
|
|
77
74
|
if (reordered) reorder?.onReorder(reordered);
|
|
78
75
|
};
|
|
79
|
-
return /* @__PURE__ */
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
value:
|
|
92
|
-
children:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
isDragBlocked: openMenuId !== null || (reorder?.isBlocked ?? false),
|
|
111
|
-
instanceId,
|
|
112
|
-
onContextMenu: onViewContextMenu,
|
|
113
|
-
onDoubleClick: onViewDoubleClick,
|
|
114
|
-
onReorder: handleReorder,
|
|
115
|
-
renderIcon,
|
|
116
|
-
reserveActionSpace,
|
|
117
|
-
view
|
|
118
|
-
}, view.id);
|
|
119
|
-
})
|
|
120
|
-
})
|
|
121
|
-
})
|
|
122
|
-
}), addControl === null || addControl === void 0 ? null : /* @__PURE__ */ jsx("div", {
|
|
123
|
-
className: "border-border flex shrink-0 translate-y-1 items-center border-s ps-1",
|
|
124
|
-
children: addControl
|
|
125
|
-
})]
|
|
76
|
+
return /* @__PURE__ */ jsx(WorkspaceViewStrip, {
|
|
77
|
+
activeViewId,
|
|
78
|
+
addControl,
|
|
79
|
+
ariaLabel,
|
|
80
|
+
direction,
|
|
81
|
+
onViewChange,
|
|
82
|
+
stripRef: setStripContainer,
|
|
83
|
+
children: viewTabs.map(({ view, actions }) => {
|
|
84
|
+
if (editing?.viewId === view.id) return /* @__PURE__ */ jsxs(WorkspaceViewTabFace, {
|
|
85
|
+
nativeButton: false,
|
|
86
|
+
render: /* @__PURE__ */ jsx("div", {}),
|
|
87
|
+
reserveActionSpace,
|
|
88
|
+
value: view.id,
|
|
89
|
+
children: [renderIcon(view), editing.renderLabel(view)]
|
|
90
|
+
}, view.id);
|
|
91
|
+
return /* @__PURE__ */ jsx(WorkspaceViewTab, {
|
|
92
|
+
actions,
|
|
93
|
+
canReorder,
|
|
94
|
+
direction,
|
|
95
|
+
getDragData: reorder?.getDragData,
|
|
96
|
+
getDropData: reorder?.getDropData,
|
|
97
|
+
isDragBlocked: openMenuId !== null || (reorder?.isBlocked ?? false),
|
|
98
|
+
instanceId,
|
|
99
|
+
onContextMenu: onViewContextMenu,
|
|
100
|
+
onDoubleClick: onViewDoubleClick,
|
|
101
|
+
onReorder: handleReorder,
|
|
102
|
+
renderIcon,
|
|
103
|
+
reserveActionSpace,
|
|
104
|
+
view
|
|
105
|
+
}, view.id);
|
|
106
|
+
})
|
|
126
107
|
});
|
|
127
108
|
};
|
|
128
109
|
const WorkspaceViewTab = ({ actions, canReorder, direction, getDragData, getDropData, isDragBlocked, instanceId, onContextMenu, onDoubleClick, onReorder, renderIcon, reserveActionSpace, view }) => {
|
|
@@ -180,16 +161,12 @@ const WorkspaceViewTab = ({ actions, canReorder, direction, getDragData, getDrop
|
|
|
180
161
|
ref: setTabContainer,
|
|
181
162
|
children: [
|
|
182
163
|
/* @__PURE__ */ jsx(InlineDropIndicator, { position: dropPosition }),
|
|
183
|
-
/* @__PURE__ */ jsxs(
|
|
184
|
-
className: cn("h-full pt-2 sm:h-full", reserveActionSpace ? "pe-6.5" : void 0),
|
|
164
|
+
/* @__PURE__ */ jsxs(WorkspaceViewTabFace, {
|
|
185
165
|
onContextMenu: (event) => onContextMenu?.(view, event),
|
|
186
166
|
onDoubleClick: (event) => onDoubleClick?.(view, event),
|
|
167
|
+
reserveActionSpace,
|
|
187
168
|
value: view.id,
|
|
188
|
-
children: [renderIcon(view), /* @__PURE__ */ jsx(
|
|
189
|
-
className: "max-w-36 whitespace-pre",
|
|
190
|
-
render: /* @__PURE__ */ jsx(BidiText, { as: "span" }),
|
|
191
|
-
children: view.name
|
|
192
|
-
})]
|
|
169
|
+
children: [renderIcon(view), /* @__PURE__ */ jsx(WorkspaceViewTabName, { name: view.name })]
|
|
193
170
|
}),
|
|
194
171
|
actions === null || actions === void 0 ? null : /* @__PURE__ */ jsx("div", {
|
|
195
172
|
className: "absolute inset-e-0 top-1/2 mt-1 -translate-y-1/2",
|
|
@@ -91,6 +91,7 @@ export type WorkspaceFrameProps = {
|
|
|
91
91
|
topBar: ComponentProps<typeof WorkspaceShell>["topBar"];
|
|
92
92
|
/** Omitted when the host has nothing for the inline-end edge. */
|
|
93
93
|
endDock?: ReactElement | undefined;
|
|
94
|
+
skipToContentLabel?: ComponentProps<typeof WorkspaceShell>["skipToContentLabel"];
|
|
94
95
|
});
|
|
95
96
|
export type WorkspaceFrameTopBar = {
|
|
96
97
|
leading?: ReactNode;
|
package/dist/workspace-frame.js
CHANGED
|
@@ -6,9 +6,9 @@ import { Tooltip, TooltipPopup, TooltipTrigger } from "@stll/ui/tooltip";
|
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { TruncatedText } from "@stll/ui/truncated-text";
|
|
8
8
|
import { cn } from "@stll/ui/utils";
|
|
9
|
-
import { InspectorDock, SIDE_RAIL_ICON_BUTTON_SIZE, TOOLBAR_ROW_HEIGHT } from "@stll/ui/inspector";
|
|
10
9
|
import { ApplicationRail, ApplicationRailButton, ApplicationRailContent, ApplicationRailFooter, ApplicationRailHeader, ApplicationRailMenu } from "@stll/ui/application-rail";
|
|
11
10
|
import { DirectionalIcon } from "@stll/ui/directional-icon";
|
|
11
|
+
import { InspectorDock, SIDE_RAIL_ICON_BUTTON_SIZE, TOOLBAR_ROW_HEIGHT } from "@stll/ui/inspector";
|
|
12
12
|
import { Sheet, SheetPopup, SheetTitle } from "@stll/ui/sheet";
|
|
13
13
|
import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarProvider, useSidebar } from "@stll/ui/sidebar";
|
|
14
14
|
import { useIsMobile } from "@stll/ui/use-mobile";
|
|
@@ -35,6 +35,7 @@ const WorkspaceFrame = (props) => {
|
|
|
35
35
|
if (props.composition === "host-responsive") return /* @__PURE__ */ jsx(WorkspaceShell, {
|
|
36
36
|
endDock: props.endDock,
|
|
37
37
|
navigation: props.navigation,
|
|
38
|
+
skipToContentLabel: props.skipToContentLabel,
|
|
38
39
|
topBar: props.topBar,
|
|
39
40
|
children: props.children
|
|
40
41
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/workspace-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Reusable workspace presentation components and view helpers for Stella.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"calculations",
|
|
@@ -91,6 +91,10 @@
|
|
|
91
91
|
"types": "./dist/sorts.d.ts",
|
|
92
92
|
"import": "./dist/sorts.js"
|
|
93
93
|
},
|
|
94
|
+
"./sorts-face": {
|
|
95
|
+
"types": "./dist/sorts-face.d.ts",
|
|
96
|
+
"import": "./dist/sorts-face.js"
|
|
97
|
+
},
|
|
94
98
|
"./table-skeleton-rows": {
|
|
95
99
|
"types": "./dist/table-skeleton-rows.d.ts",
|
|
96
100
|
"import": "./dist/table-skeleton-rows.js"
|
|
@@ -107,6 +111,14 @@
|
|
|
107
111
|
"types": "./dist/view-switcher.d.ts",
|
|
108
112
|
"import": "./dist/view-switcher.js"
|
|
109
113
|
},
|
|
114
|
+
"./view-strip": {
|
|
115
|
+
"types": "./dist/view-strip.d.ts",
|
|
116
|
+
"import": "./dist/view-strip.js"
|
|
117
|
+
},
|
|
118
|
+
"./view-switcher-face": {
|
|
119
|
+
"types": "./dist/view-switcher-face.d.ts",
|
|
120
|
+
"import": "./dist/view-switcher-face.js"
|
|
121
|
+
},
|
|
110
122
|
"./workspace-frame": {
|
|
111
123
|
"types": "./dist/workspace-frame.d.ts",
|
|
112
124
|
"import": "./dist/workspace-frame.js"
|
|
@@ -130,10 +142,10 @@
|
|
|
130
142
|
"@stll/calculations": "^0.1.5",
|
|
131
143
|
"@stll/conditions": "^0.4.1",
|
|
132
144
|
"@stll/money": "^0.4.0",
|
|
133
|
-
"@stll/ui": "^0.
|
|
145
|
+
"@stll/ui": "^0.76.0",
|
|
134
146
|
"better-result": "3.0.1",
|
|
135
147
|
"temporal-polyfill": "1.0.8",
|
|
136
|
-
"use-intl": "4.
|
|
148
|
+
"use-intl": "4.15.1"
|
|
137
149
|
},
|
|
138
150
|
"devDependencies": {
|
|
139
151
|
"@atlaskit/pragmatic-drag-and-drop": "^4.0.0",
|