@stll/ui 0.19.0 → 0.21.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/components/context-menu.d.ts +37 -0
- package/dist/components/context-menu.js +48 -0
- package/dist/components/input-group.d.ts +1 -1
- package/dist/components/sidebar.d.ts +109 -0
- package/dist/components/sidebar.js +361 -0
- package/dist/components/sidebar.logic.d.ts +34 -0
- package/dist/components/sidebar.logic.js +27 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -2
- package/dist/inspector/entity-tab.d.ts +54 -0
- package/dist/inspector/entity-tab.js +56 -0
- package/dist/inspector/entity-tab.logic.d.ts +28 -0
- package/dist/inspector/entity-tab.logic.js +32 -0
- package/dist/inspector/facet-bar.d.ts +46 -0
- package/dist/inspector/facet-bar.js +166 -0
- package/dist/inspector/facet-bar.logic.d.ts +51 -0
- package/dist/inspector/facet-bar.logic.js +53 -0
- package/dist/inspector/index.d.ts +3 -1
- package/dist/inspector/index.js +3 -1
- package/dist/kanban/subgroup-board.js +4 -4
- package/dist/kanban/virtual-cell.d.ts +10 -1
- package/dist/kanban/virtual-cell.js +25 -3
- package/dist/lib/slot.d.ts +28 -0
- package/dist/lib/slot.js +64 -0
- package/package.json +13 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Inspector, InspectorActions, InspectorContent, InspectorDescription, InspectorEmptyRow, InspectorHeader, InspectorHeaderText, InspectorProperty, InspectorPropertyLabel, InspectorPropertyList, InspectorPropertyValue, InspectorRail, InspectorRailCell, InspectorRailContent, InspectorRailFooter, InspectorRailIconButton, InspectorRailTab, InspectorSection, InspectorSectionTitle, InspectorTitle } from "./chrome.js";
|
|
2
2
|
import { InspectorDock } from "./dock.js";
|
|
3
|
+
import { InspectorEntityTab, entityTabGlyph } from "./entity-tab.js";
|
|
4
|
+
import { InspectorFacetBar } from "./facet-bar.js";
|
|
3
5
|
import { InspectorTab, InspectorTabList, InspectorTabPanel, InspectorTabs } from "./tabs.js";
|
|
4
6
|
import { PROPERTY_ROW_GRID, SIDE_RAIL_CONTAINER_CLASS, SIDE_RAIL_ICON_BUTTON_SIZE, SIDE_RAIL_TAB_ICON_SIZE, SIDE_RAIL_WIDTH, TOOLBAR_ROW_HEIGHT, TOOLBAR_ROW_HEIGHT_PX } from "./layout-tokens.js";
|
|
5
7
|
import { INSPECTOR_CONTENT_MIN_WIDTH, INSPECTOR_EDITOR_MIN_WIDTH, INSPECTOR_PANE_DEFAULT_WIDTH, INSPECTOR_PANE_MAX_WIDTH, INSPECTOR_PANE_MIN_WIDTH, INSPECTOR_RAIL_WIDTH, resolveInspectorDockWidth, resolveInspectorPaneMaxWidth, resolveInspectorPaneWidth, shouldForceSidebarCollapsed } from "./pane-width.js";
|
|
6
8
|
import { INSPECTOR_PANE_KEYBOARD_PAGE_STEP, INSPECTOR_PANE_KEYBOARD_STEP, parsePersistedPaneWidth, resolveDragWidth, resolveKeyboardWidth, useInspectorPaneWidth } from "./use-pane-width.js";
|
|
7
|
-
export { INSPECTOR_CONTENT_MIN_WIDTH, INSPECTOR_EDITOR_MIN_WIDTH, INSPECTOR_PANE_DEFAULT_WIDTH, INSPECTOR_PANE_KEYBOARD_PAGE_STEP, INSPECTOR_PANE_KEYBOARD_STEP, INSPECTOR_PANE_MAX_WIDTH, INSPECTOR_PANE_MIN_WIDTH, INSPECTOR_RAIL_WIDTH, Inspector, InspectorActions, InspectorContent, InspectorDescription, InspectorDock, InspectorEmptyRow, InspectorHeader, InspectorHeaderText, InspectorProperty, InspectorPropertyLabel, InspectorPropertyList, InspectorPropertyValue, InspectorRail, InspectorRailCell, InspectorRailContent, InspectorRailFooter, InspectorRailIconButton, InspectorRailTab, InspectorSection, InspectorSectionTitle, InspectorTab, InspectorTabList, InspectorTabPanel, InspectorTabs, InspectorTitle, PROPERTY_ROW_GRID, SIDE_RAIL_CONTAINER_CLASS, SIDE_RAIL_ICON_BUTTON_SIZE, SIDE_RAIL_TAB_ICON_SIZE, SIDE_RAIL_WIDTH, TOOLBAR_ROW_HEIGHT, TOOLBAR_ROW_HEIGHT_PX, parsePersistedPaneWidth, resolveDragWidth, resolveInspectorDockWidth, resolveInspectorPaneMaxWidth, resolveInspectorPaneWidth, resolveKeyboardWidth, shouldForceSidebarCollapsed, useInspectorPaneWidth };
|
|
9
|
+
export { INSPECTOR_CONTENT_MIN_WIDTH, INSPECTOR_EDITOR_MIN_WIDTH, INSPECTOR_PANE_DEFAULT_WIDTH, INSPECTOR_PANE_KEYBOARD_PAGE_STEP, INSPECTOR_PANE_KEYBOARD_STEP, INSPECTOR_PANE_MAX_WIDTH, INSPECTOR_PANE_MIN_WIDTH, INSPECTOR_RAIL_WIDTH, Inspector, InspectorActions, InspectorContent, InspectorDescription, InspectorDock, InspectorEmptyRow, InspectorEntityTab, InspectorFacetBar, InspectorHeader, InspectorHeaderText, InspectorProperty, InspectorPropertyLabel, InspectorPropertyList, InspectorPropertyValue, InspectorRail, InspectorRailCell, InspectorRailContent, InspectorRailFooter, InspectorRailIconButton, InspectorRailTab, InspectorSection, InspectorSectionTitle, InspectorTab, InspectorTabList, InspectorTabPanel, InspectorTabs, InspectorTitle, PROPERTY_ROW_GRID, SIDE_RAIL_CONTAINER_CLASS, SIDE_RAIL_ICON_BUTTON_SIZE, SIDE_RAIL_TAB_ICON_SIZE, SIDE_RAIL_WIDTH, TOOLBAR_ROW_HEIGHT, TOOLBAR_ROW_HEIGHT_PX, entityTabGlyph, parsePersistedPaneWidth, resolveDragWidth, resolveInspectorDockWidth, resolveInspectorPaneMaxWidth, resolveInspectorPaneWidth, resolveKeyboardWidth, shouldForceSidebarCollapsed, useInspectorPaneWidth };
|
package/dist/inspector/index.js
CHANGED
|
@@ -2,6 +2,8 @@ import { PROPERTY_ROW_GRID, SIDE_RAIL_CONTAINER_CLASS, SIDE_RAIL_ICON_BUTTON_SIZ
|
|
|
2
2
|
import { Inspector, InspectorActions, InspectorContent, InspectorDescription, InspectorEmptyRow, InspectorHeader, InspectorHeaderText, InspectorProperty, InspectorPropertyLabel, InspectorPropertyList, InspectorPropertyValue, InspectorRail, InspectorRailCell, InspectorRailContent, InspectorRailFooter, InspectorRailIconButton, InspectorRailTab, InspectorSection, InspectorSectionTitle, InspectorTitle } from "./chrome.js";
|
|
3
3
|
import { INSPECTOR_CONTENT_MIN_WIDTH, INSPECTOR_EDITOR_MIN_WIDTH, INSPECTOR_PANE_DEFAULT_WIDTH, INSPECTOR_PANE_MAX_WIDTH, INSPECTOR_PANE_MIN_WIDTH, INSPECTOR_RAIL_WIDTH, resolveInspectorDockWidth, resolveInspectorPaneMaxWidth, resolveInspectorPaneWidth, shouldForceSidebarCollapsed } from "./pane-width.js";
|
|
4
4
|
import { InspectorDock } from "./dock.js";
|
|
5
|
+
import { InspectorEntityTab, entityTabGlyph } from "./entity-tab.js";
|
|
6
|
+
import { InspectorFacetBar } from "./facet-bar.js";
|
|
5
7
|
import { InspectorTab, InspectorTabList, InspectorTabPanel, InspectorTabs } from "./tabs.js";
|
|
6
8
|
import { INSPECTOR_PANE_KEYBOARD_PAGE_STEP, INSPECTOR_PANE_KEYBOARD_STEP, parsePersistedPaneWidth, resolveDragWidth, resolveKeyboardWidth, useInspectorPaneWidth } from "./use-pane-width.js";
|
|
7
|
-
export { INSPECTOR_CONTENT_MIN_WIDTH, INSPECTOR_EDITOR_MIN_WIDTH, INSPECTOR_PANE_DEFAULT_WIDTH, INSPECTOR_PANE_KEYBOARD_PAGE_STEP, INSPECTOR_PANE_KEYBOARD_STEP, INSPECTOR_PANE_MAX_WIDTH, INSPECTOR_PANE_MIN_WIDTH, INSPECTOR_RAIL_WIDTH, Inspector, InspectorActions, InspectorContent, InspectorDescription, InspectorDock, InspectorEmptyRow, InspectorHeader, InspectorHeaderText, InspectorProperty, InspectorPropertyLabel, InspectorPropertyList, InspectorPropertyValue, InspectorRail, InspectorRailCell, InspectorRailContent, InspectorRailFooter, InspectorRailIconButton, InspectorRailTab, InspectorSection, InspectorSectionTitle, InspectorTab, InspectorTabList, InspectorTabPanel, InspectorTabs, InspectorTitle, PROPERTY_ROW_GRID, SIDE_RAIL_CONTAINER_CLASS, SIDE_RAIL_ICON_BUTTON_SIZE, SIDE_RAIL_TAB_ICON_SIZE, SIDE_RAIL_WIDTH, TOOLBAR_ROW_HEIGHT, TOOLBAR_ROW_HEIGHT_PX, parsePersistedPaneWidth, resolveDragWidth, resolveInspectorDockWidth, resolveInspectorPaneMaxWidth, resolveInspectorPaneWidth, resolveKeyboardWidth, shouldForceSidebarCollapsed, useInspectorPaneWidth };
|
|
9
|
+
export { INSPECTOR_CONTENT_MIN_WIDTH, INSPECTOR_EDITOR_MIN_WIDTH, INSPECTOR_PANE_DEFAULT_WIDTH, INSPECTOR_PANE_KEYBOARD_PAGE_STEP, INSPECTOR_PANE_KEYBOARD_STEP, INSPECTOR_PANE_MAX_WIDTH, INSPECTOR_PANE_MIN_WIDTH, INSPECTOR_RAIL_WIDTH, Inspector, InspectorActions, InspectorContent, InspectorDescription, InspectorDock, InspectorEmptyRow, InspectorEntityTab, InspectorFacetBar, InspectorHeader, InspectorHeaderText, InspectorProperty, InspectorPropertyLabel, InspectorPropertyList, InspectorPropertyValue, InspectorRail, InspectorRailCell, InspectorRailContent, InspectorRailFooter, InspectorRailIconButton, InspectorRailTab, InspectorSection, InspectorSectionTitle, InspectorTab, InspectorTabList, InspectorTabPanel, InspectorTabs, InspectorTitle, PROPERTY_ROW_GRID, SIDE_RAIL_CONTAINER_CLASS, SIDE_RAIL_ICON_BUTTON_SIZE, SIDE_RAIL_TAB_ICON_SIZE, SIDE_RAIL_WIDTH, TOOLBAR_ROW_HEIGHT, TOOLBAR_ROW_HEIGHT_PX, entityTabGlyph, parsePersistedPaneWidth, resolveDragWidth, resolveInspectorDockWidth, resolveInspectorPaneMaxWidth, resolveInspectorPaneWidth, resolveKeyboardWidth, shouldForceSidebarCollapsed, useInspectorPaneWidth };
|
|
@@ -226,9 +226,9 @@ const KanbanSubgroupBoard = ({ matrix, renderColumnHeader, renderLaneIdentity, r
|
|
|
226
226
|
className: "min-w-max",
|
|
227
227
|
children: [
|
|
228
228
|
/* @__PURE__ */ jsxs("div", {
|
|
229
|
-
className: "bg-background sticky top-0 z-20 pt-
|
|
229
|
+
className: "bg-background sticky top-0 z-20 pt-2 pb-2",
|
|
230
230
|
children: [hasBands ? /* @__PURE__ */ jsx("div", {
|
|
231
|
-
className: "flex items-end gap-3 pb-1
|
|
231
|
+
className: "flex items-end gap-3 pb-1",
|
|
232
232
|
"data-kanban-band-row": "",
|
|
233
233
|
children: spans.map((span) => {
|
|
234
234
|
const band = span.band;
|
|
@@ -285,7 +285,7 @@ const KanbanSubgroupBoard = ({ matrix, renderColumnHeader, renderLaneIdentity, r
|
|
|
285
285
|
const collapsed = isLaneCollapsed ? isLaneCollapsed(group, count) : defaultCollapsed;
|
|
286
286
|
const cellFor = (column) => cells.find((candidate) => columnKey(candidate.coordinate.column) === columnKey(column));
|
|
287
287
|
return /* @__PURE__ */ jsxs("section", {
|
|
288
|
-
className: "border-border/60 border-b py-
|
|
288
|
+
className: "border-border/60 border-b py-1 first:pt-0 last:border-b-0",
|
|
289
289
|
children: [
|
|
290
290
|
/* @__PURE__ */ jsx("div", {
|
|
291
291
|
className: "bg-background/95 sticky start-0 z-10 flex min-h-11 items-center backdrop-blur-sm",
|
|
@@ -311,7 +311,7 @@ const KanbanSubgroupBoard = ({ matrix, renderColumnHeader, renderLaneIdentity, r
|
|
|
311
311
|
]
|
|
312
312
|
})
|
|
313
313
|
}),
|
|
314
|
-
renderRow({
|
|
314
|
+
collapsed && renderRow({
|
|
315
315
|
label: "Lane column counts",
|
|
316
316
|
renderColumn: (column) => {
|
|
317
317
|
const columnRows = cellFor(column)?.rows.length ?? 0;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OptionColor } from "../lib/option-color.js";
|
|
1
2
|
import { UseKanbanDropTargetOptions } from "./sortable-interactions.js";
|
|
2
3
|
import { Key, ReactNode, RefObject } from "react";
|
|
3
4
|
import { UniqueIdentifier } from "@dnd-kit/core";
|
|
@@ -38,6 +39,14 @@ type KanbanVirtualCellProps<TRow> = {
|
|
|
38
39
|
containerRef?: RefObject<HTMLDivElement | null> | undefined;
|
|
39
40
|
active?: boolean | undefined;
|
|
40
41
|
backgroundColor?: string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Optional colour identity for the cell surface: a faint resting tint at
|
|
44
|
+
* the same alpha as `option-color`'s own subtle background, with a
|
|
45
|
+
* stronger accent-coloured wash and ring while `active` is also set. Omit
|
|
46
|
+
* for the plain neutral surface; `backgroundColor` still wins outright
|
|
47
|
+
* when both are given, since that prop is the caller's explicit override.
|
|
48
|
+
*/
|
|
49
|
+
accent?: OptionColor | undefined;
|
|
41
50
|
footer?: ReactNode;
|
|
42
51
|
estimateSize?: number | undefined;
|
|
43
52
|
overscan?: number | undefined;
|
|
@@ -45,6 +54,6 @@ type KanbanVirtualCellProps<TRow> = {
|
|
|
45
54
|
className?: string | undefined;
|
|
46
55
|
};
|
|
47
56
|
/** Bounded, virtualized Kanban cell with cursor-page request deduplication. */
|
|
48
|
-
declare const KanbanVirtualCell: <TRow>({ rows, getRowKey, renderRow, pagination, sortable, containerRef, active, backgroundColor, footer, estimateSize, overscan, loadMoreThreshold, className }: KanbanVirtualCellProps<TRow>) => import("react").JSX.Element;
|
|
57
|
+
declare const KanbanVirtualCell: <TRow>({ rows, getRowKey, renderRow, pagination, sortable, containerRef, active, backgroundColor, accent, footer, estimateSize, overscan, loadMoreThreshold, className }: KanbanVirtualCellProps<TRow>) => import("react").JSX.Element;
|
|
49
58
|
//#endregion
|
|
50
59
|
export { KANBAN_VIRTUAL_CELL_PAGINATION, KanbanVirtualCell, KanbanVirtualCellPagination, KanbanVirtualCellProps, KanbanVirtualCellSortableContext };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cn } from "../lib/utils.js";
|
|
2
2
|
import { useKanbanDropTarget } from "./sortable-interactions.js";
|
|
3
|
+
import { resolveOptionColor } from "../lib/option-color.js";
|
|
3
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
5
|
import { useId, useRef } from "react";
|
|
5
6
|
import { useDndContext } from "@dnd-kit/core";
|
|
@@ -9,6 +10,18 @@ import { defaultRangeExtractor, useVirtualizer } from "@tanstack/react-virtual";
|
|
|
9
10
|
const DEFAULT_ESTIMATE_SIZE_PX = 128;
|
|
10
11
|
const DEFAULT_OVERSCAN = 8;
|
|
11
12
|
const DEFAULT_LOAD_MORE_THRESHOLD_PX = 200;
|
|
13
|
+
/** The CSS custom property every accent tint and the active accent ring are
|
|
14
|
+
* derived from, so both stay in lockstep with the resolved colour token. */
|
|
15
|
+
const KANBAN_CELL_ACCENT_VAR = "--kanban-cell-accent";
|
|
16
|
+
/** Faint resting wash: matches the alpha `option-color` already uses for its
|
|
17
|
+
* own subtle background token, so a tinted cell reads at the same weight as
|
|
18
|
+
* the swatch and badges that carry the same colour. */
|
|
19
|
+
const KANBAN_CELL_ACCENT_RESTING_ALPHA = 12;
|
|
20
|
+
/** Stronger wash while a card is dragged over an accented cell. */
|
|
21
|
+
const KANBAN_CELL_ACCENT_ACTIVE_ALPHA = 22;
|
|
22
|
+
/** Ring alpha for the active accent frame, well above the wash so the frame
|
|
23
|
+
* still reads as the drag-over affordance rather than more background tint. */
|
|
24
|
+
const KANBAN_CELL_ACCENT_ACTIVE_RING_ALPHA = 55;
|
|
12
25
|
const retainActiveSortableIndex = (range, activeIndex) => {
|
|
13
26
|
const indexes = defaultRangeExtractor(range);
|
|
14
27
|
if (activeIndex < 0 || indexes.includes(activeIndex)) return indexes;
|
|
@@ -21,7 +34,7 @@ const KANBAN_VIRTUAL_CELL_PAGINATION = {
|
|
|
21
34
|
CURSOR: "cursor"
|
|
22
35
|
};
|
|
23
36
|
/** Bounded, virtualized Kanban cell with cursor-page request deduplication. */
|
|
24
|
-
const KanbanVirtualCell = ({ rows, getRowKey, renderRow, pagination, sortable, containerRef, active = false, backgroundColor, footer, estimateSize = DEFAULT_ESTIMATE_SIZE_PX, overscan = DEFAULT_OVERSCAN, loadMoreThreshold = DEFAULT_LOAD_MORE_THRESHOLD_PX, className }) => {
|
|
37
|
+
const KanbanVirtualCell = ({ rows, getRowKey, renderRow, pagination, sortable, containerRef, active = false, backgroundColor, accent, footer, estimateSize = DEFAULT_ESTIMATE_SIZE_PX, overscan = DEFAULT_OVERSCAN, loadMoreThreshold = DEFAULT_LOAD_MORE_THRESHOLD_PX, className }) => {
|
|
25
38
|
const internalRef = useRef(null);
|
|
26
39
|
const fallbackDropTargetId = useId();
|
|
27
40
|
const scrollRef = internalRef;
|
|
@@ -69,12 +82,21 @@ const KanbanVirtualCell = ({ rows, getRowKey, renderRow, pagination, sortable, c
|
|
|
69
82
|
if (containerRef) containerRef.current = element;
|
|
70
83
|
dropTarget.setNodeRef(element);
|
|
71
84
|
};
|
|
85
|
+
const accentVariants = accent === void 0 ? void 0 : resolveOptionColor(accent);
|
|
86
|
+
const accentBackground = accentVariants === void 0 ? void 0 : `color-mix(in srgb, var(${KANBAN_CELL_ACCENT_VAR}) ${active ? KANBAN_CELL_ACCENT_ACTIVE_ALPHA : KANBAN_CELL_ACCENT_RESTING_ALPHA}%, var(--background))`;
|
|
87
|
+
const activeAccentRing = active && accentVariants !== void 0 ? `0 0 0 2px color-mix(in srgb, var(${KANBAN_CELL_ACCENT_VAR}) ${KANBAN_CELL_ACCENT_ACTIVE_RING_ALPHA}%, transparent)` : void 0;
|
|
88
|
+
const style = backgroundColor === void 0 && accentVariants === void 0 ? void 0 : {
|
|
89
|
+
backgroundColor: backgroundColor ?? accentBackground,
|
|
90
|
+
...activeAccentRing === void 0 ? void 0 : { boxShadow: activeAccentRing },
|
|
91
|
+
...accentVariants === void 0 ? void 0 : { [KANBAN_CELL_ACCENT_VAR]: accentVariants.color }
|
|
92
|
+
};
|
|
72
93
|
const content = /* @__PURE__ */ jsxs("div", {
|
|
73
|
-
className: cn("bg-muted/20 max-h-[min(60vh,40rem)] min-h-20 overflow-y-auto overscroll-y-contain rounded-xl p-2 transition-[background-color,outline-color]", active && "bg-primary/5 ring-primary/50 ring-2", className),
|
|
94
|
+
className: cn("bg-muted/20 max-h-[min(60vh,40rem)] min-h-20 overflow-y-auto overscroll-y-contain rounded-xl p-2 transition-[background-color,outline-color]", active && accentVariants === void 0 && "bg-primary/5 ring-primary/50 ring-2", className),
|
|
74
95
|
"data-kanban-cell": sortable?.dropTarget.id,
|
|
96
|
+
"data-kanban-cell-accent": accentVariants === void 0 ? void 0 : "true",
|
|
75
97
|
onScroll: handleScroll,
|
|
76
98
|
ref: setScrollElement,
|
|
77
|
-
style
|
|
99
|
+
style,
|
|
78
100
|
children: [/* @__PURE__ */ jsx("div", {
|
|
79
101
|
className: "relative",
|
|
80
102
|
style: { height: virtualizer.getTotalSize() },
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/lib/slot.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Minimal replacement for `@radix-ui/react-slot`.
|
|
4
|
+
*
|
|
5
|
+
* Renders its single child element with the parent's props
|
|
6
|
+
* (className, style, event handlers, ref, data-* attributes)
|
|
7
|
+
* merged onto it. Used by the sidebar shell for the `asChild`
|
|
8
|
+
* pattern.
|
|
9
|
+
*
|
|
10
|
+
* Ref composition logic adapted from the MIT-licensed
|
|
11
|
+
* `@radix-ui/react-compose-refs` (v1.1.2).
|
|
12
|
+
*
|
|
13
|
+
* This module intentionally uses `Children.only` and
|
|
14
|
+
* `cloneElement`: it is a low-level composition primitive
|
|
15
|
+
* that merges props onto a single child, which is exactly
|
|
16
|
+
* the use case React documents for these APIs.
|
|
17
|
+
*
|
|
18
|
+
* Several lint suppressions are necessary because prop
|
|
19
|
+
* merging is inherently dynamic; the types of child props
|
|
20
|
+
* are not statically known.
|
|
21
|
+
*/
|
|
22
|
+
type SlotProps = React.HTMLAttributes<HTMLElement> & {
|
|
23
|
+
children?: React.ReactNode;
|
|
24
|
+
ref?: React.Ref<HTMLElement> | undefined;
|
|
25
|
+
};
|
|
26
|
+
declare const Slot: ({ ref: parentRef, children, className, style, ...rest }: SlotProps) => React.ReactNode;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { Slot };
|
package/dist/lib/slot.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { cn } from "./utils.js";
|
|
2
|
+
import { Children, Fragment, cloneElement, isValidElement } from "react";
|
|
3
|
+
//#region src/lib/slot.tsx
|
|
4
|
+
/**
|
|
5
|
+
* Minimal replacement for `@radix-ui/react-slot`.
|
|
6
|
+
*
|
|
7
|
+
* Renders its single child element with the parent's props
|
|
8
|
+
* (className, style, event handlers, ref, data-* attributes)
|
|
9
|
+
* merged onto it. Used by the sidebar shell for the `asChild`
|
|
10
|
+
* pattern.
|
|
11
|
+
*
|
|
12
|
+
* Ref composition logic adapted from the MIT-licensed
|
|
13
|
+
* `@radix-ui/react-compose-refs` (v1.1.2).
|
|
14
|
+
*
|
|
15
|
+
* This module intentionally uses `Children.only` and
|
|
16
|
+
* `cloneElement`: it is a low-level composition primitive
|
|
17
|
+
* that merges props onto a single child, which is exactly
|
|
18
|
+
* the use case React documents for these APIs.
|
|
19
|
+
*
|
|
20
|
+
* Several lint suppressions are necessary because prop
|
|
21
|
+
* merging is inherently dynamic; the types of child props
|
|
22
|
+
* are not statically known.
|
|
23
|
+
*/
|
|
24
|
+
const Slot = ({ ref: parentRef, children, className, style, ...rest }) => {
|
|
25
|
+
const child = Children.only(children);
|
|
26
|
+
if (!isValidElement(child)) return child;
|
|
27
|
+
if (child.type === Fragment) return child;
|
|
28
|
+
const childProps = child.props;
|
|
29
|
+
const mergedProps = {
|
|
30
|
+
...rest,
|
|
31
|
+
...childProps
|
|
32
|
+
};
|
|
33
|
+
const childRef = childProps["ref"];
|
|
34
|
+
if (parentRef !== void 0 || childRef !== void 0) mergedProps["ref"] = composeSlotRefs(parentRef, childRef);
|
|
35
|
+
const childClassName = childProps["className"];
|
|
36
|
+
if (className || typeof childClassName === "string") mergedProps["className"] = cn(className, typeof childClassName === "string" ? childClassName : void 0);
|
|
37
|
+
const childStyle = childProps["style"];
|
|
38
|
+
if (style || typeof childStyle === "object" && childStyle !== null) mergedProps["style"] = {
|
|
39
|
+
...style,
|
|
40
|
+
...typeof childStyle === "object" && childStyle !== null ? childStyle : {}
|
|
41
|
+
};
|
|
42
|
+
const restEntries = Object.entries(rest);
|
|
43
|
+
for (const [key, parentValue] of restEntries) if (key.startsWith("on") && typeof parentValue === "function") {
|
|
44
|
+
const childValue = childProps[key];
|
|
45
|
+
if (typeof childValue === "function") mergedProps[key] = (...args) => {
|
|
46
|
+
Reflect.apply(childValue, void 0, args);
|
|
47
|
+
Reflect.apply(parentValue, void 0, args);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return cloneElement(child, mergedProps);
|
|
51
|
+
};
|
|
52
|
+
const composeSlotRefs = (parentRef, childRef) => (node) => {
|
|
53
|
+
setSlotRef(parentRef, node);
|
|
54
|
+
setSlotRef(childRef, node);
|
|
55
|
+
};
|
|
56
|
+
const setSlotRef = (ref, node) => {
|
|
57
|
+
if (typeof ref === "function") {
|
|
58
|
+
Reflect.apply(ref, void 0, [node]);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (typeof ref === "object" && ref !== null && "current" in ref) ref.current = node;
|
|
62
|
+
};
|
|
63
|
+
//#endregion
|
|
64
|
+
export { Slot };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Stella's design system: bidi-aware React primitives built on Base UI, the dockable inspector pane, and the Tailwind v4 theme they are styled with.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"base-ui",
|
|
@@ -93,6 +93,10 @@
|
|
|
93
93
|
"types": "./dist/components/composer.d.ts",
|
|
94
94
|
"import": "./dist/components/composer.js"
|
|
95
95
|
},
|
|
96
|
+
"./context-menu": {
|
|
97
|
+
"types": "./dist/components/context-menu.d.ts",
|
|
98
|
+
"import": "./dist/components/context-menu.js"
|
|
99
|
+
},
|
|
96
100
|
"./control-size": {
|
|
97
101
|
"types": "./dist/lib/control-size.d.ts",
|
|
98
102
|
"import": "./dist/lib/control-size.js"
|
|
@@ -257,6 +261,10 @@
|
|
|
257
261
|
"types": "./dist/components/sheet.d.ts",
|
|
258
262
|
"import": "./dist/components/sheet.js"
|
|
259
263
|
},
|
|
264
|
+
"./sidebar": {
|
|
265
|
+
"types": "./dist/components/sidebar.d.ts",
|
|
266
|
+
"import": "./dist/components/sidebar.js"
|
|
267
|
+
},
|
|
260
268
|
"./loader": {
|
|
261
269
|
"types": "./dist/components/loader.d.ts",
|
|
262
270
|
"import": "./dist/components/loader.js"
|
|
@@ -494,6 +502,10 @@
|
|
|
494
502
|
"types": "./dist/components/sheet.d.ts",
|
|
495
503
|
"import": "./dist/components/sheet.js"
|
|
496
504
|
},
|
|
505
|
+
"./components/sidebar": {
|
|
506
|
+
"types": "./dist/components/sidebar.d.ts",
|
|
507
|
+
"import": "./dist/components/sidebar.js"
|
|
508
|
+
},
|
|
497
509
|
"./components/skeleton": {
|
|
498
510
|
"types": "./dist/components/skeleton.d.ts",
|
|
499
511
|
"import": "./dist/components/skeleton.js"
|