@inkra/react 0.1.0 → 0.2.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 +104 -1
- package/dist/PencilIcon.js +14 -16
- package/dist/PencilLine.js +18 -12
- package/dist/PencilText.js +192 -59
- package/dist/alert-dialog/index.d.ts +64 -0
- package/dist/alert-dialog/index.js +109 -0
- package/dist/audio-player/index.d.ts +60 -0
- package/dist/audio-player/index.js +101 -0
- package/dist/carousel/index.d.ts +51 -0
- package/dist/carousel/index.js +290 -0
- package/dist/choice-grid/index.d.ts +38 -0
- package/dist/choice-grid/index.js +85 -0
- package/dist/color-picker/color.d.ts +15 -0
- package/dist/color-picker/color.js +55 -0
- package/dist/color-picker/index.d.ts +31 -0
- package/dist/color-picker/index.js +69 -0
- package/dist/command/index.d.ts +23 -0
- package/dist/command/index.js +39 -0
- package/dist/context-menu/index.d.ts +76 -0
- package/dist/context-menu/index.js +240 -0
- package/dist/data-table/index.d.ts +47 -0
- package/dist/data-table/index.js +91 -0
- package/dist/date-picker/index.d.ts +50 -0
- package/dist/date-picker/index.js +180 -0
- package/dist/display/ProgressRing.d.ts +6 -0
- package/dist/display/ProgressRing.js +146 -0
- package/dist/display/index.d.ts +27 -0
- package/dist/display/index.js +18 -2
- package/dist/dockable-panel/index.d.ts +41 -0
- package/dist/dockable-panel/index.js +253 -0
- package/dist/dockable-panel/model.d.ts +21 -0
- package/dist/dockable-panel/model.js +61 -0
- package/dist/drawer/index.d.ts +63 -0
- package/dist/drawer/index.js +86 -0
- package/dist/editable/index.d.ts +53 -0
- package/dist/editable/index.js +162 -0
- package/dist/empty/index.d.ts +21 -0
- package/dist/empty/index.js +23 -0
- package/dist/flip/index.d.ts +49 -0
- package/dist/flip/index.js +138 -0
- package/dist/form/EditablePencilText.js +157 -146
- package/dist/form/Textarea.d.ts +12 -0
- package/dist/form/Textarea.js +83 -4
- package/dist/form/index.d.ts +1 -1
- package/dist/heatmap/index.d.ts +59 -0
- package/dist/heatmap/index.js +248 -0
- package/dist/hotkey/index.d.ts +37 -0
- package/dist/hotkey/index.js +130 -0
- package/dist/hotkey/model.d.ts +27 -0
- package/dist/hotkey/model.js +97 -0
- package/dist/hover-card/index.d.ts +33 -0
- package/dist/hover-card/index.js +141 -0
- package/dist/image-cropper/index.d.ts +82 -0
- package/dist/image-cropper/index.js +261 -0
- package/dist/image-cropper/model.d.ts +42 -0
- package/dist/image-cropper/model.js +94 -0
- package/dist/image-viewer/index.d.ts +79 -0
- package/dist/image-viewer/index.js +220 -0
- package/dist/image-viewer/model.d.ts +9 -0
- package/dist/image-viewer/model.js +18 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +47 -0
- package/dist/internal/cache.d.ts +1 -1
- package/dist/internal/cache.js +1 -1
- package/dist/internal/renderTokens.d.ts +10 -0
- package/dist/internal/renderTokens.js +13 -0
- package/dist/internal/surfaceRenderer.d.ts +14 -6
- package/dist/internal/surfaceRenderer.js +15 -12
- package/dist/internal/textRenderer.d.ts +1 -0
- package/dist/internal/textRenderer.js +33 -7
- package/dist/internal/usePencilSurface.js +16 -8
- package/dist/internal/useSelectionDrawing.js +15 -11
- package/dist/journey-map/MapScale.js +3 -1
- package/dist/journey-map/index.js +3 -1
- package/dist/keypad/index.d.ts +23 -0
- package/dist/keypad/index.js +63 -0
- package/dist/keypad/model.d.ts +20 -0
- package/dist/keypad/model.js +33 -0
- package/dist/layout/index.d.ts +63 -0
- package/dist/layout/index.js +62 -0
- package/dist/log/index.d.ts +45 -0
- package/dist/log/index.js +159 -0
- package/dist/log/model.d.ts +16 -0
- package/dist/log/model.js +13 -0
- package/dist/node-graph/index.d.ts +123 -0
- package/dist/node-graph/index.js +304 -0
- package/dist/number-ticker/index.d.ts +29 -0
- package/dist/number-ticker/index.js +132 -0
- package/dist/number-ticker/model.d.ts +8 -0
- package/dist/number-ticker/model.js +34 -0
- package/dist/overflow-list/index.d.ts +39 -0
- package/dist/overflow-list/index.js +230 -0
- package/dist/overflow-list/layout.d.ts +19 -0
- package/dist/overflow-list/layout.js +44 -0
- package/dist/pagination/index.d.ts +23 -0
- package/dist/pagination/index.js +41 -0
- package/dist/pagination/model.d.ts +4 -0
- package/dist/pagination/model.js +42 -0
- package/dist/pan-zoom/index.d.ts +71 -0
- package/dist/pan-zoom/index.js +175 -0
- package/dist/radar/index.d.ts +54 -0
- package/dist/radar/index.js +220 -0
- package/dist/range-slider/index.d.ts +16 -0
- package/dist/range-slider/index.js +22 -0
- package/dist/rating/index.d.ts +28 -0
- package/dist/rating/index.js +127 -0
- package/dist/resizable/index.d.ts +32 -0
- package/dist/resizable/index.js +50 -0
- package/dist/scroll-area/index.d.ts +36 -0
- package/dist/scroll-area/index.js +44 -0
- package/dist/segmented-progress/SegmentedProgress.d.ts +17 -0
- package/dist/segmented-progress/SegmentedProgress.js +42 -0
- package/dist/slider/index.js +1 -1
- package/dist/slot/index.d.ts +24 -0
- package/dist/slot/index.js +29 -0
- package/dist/sortable/index.d.ts +50 -0
- package/dist/sortable/index.js +278 -0
- package/dist/sortable/model.d.ts +30 -0
- package/dist/sortable/model.js +64 -0
- package/dist/sparkline/index.d.ts +19 -0
- package/dist/sparkline/index.js +240 -0
- package/dist/sparkline/model.d.ts +16 -0
- package/dist/sparkline/model.js +28 -0
- package/dist/steps/index.d.ts +16 -0
- package/dist/steps/index.js +37 -0
- package/dist/styles.css +4850 -287
- package/dist/tag-input/index.d.ts +69 -0
- package/dist/tag-input/index.js +325 -0
- package/dist/tag-input/model.d.ts +14 -0
- package/dist/tag-input/model.js +38 -0
- package/dist/time-picker/index.d.ts +15 -0
- package/dist/time-picker/index.js +168 -0
- package/dist/timeline/index.d.ts +14 -0
- package/dist/timeline/index.js +16 -0
- package/dist/toast/index.d.ts +27 -0
- package/dist/toast/index.js +36 -0
- package/dist/toggle-group/index.d.ts +17 -0
- package/dist/toggle-group/index.js +26 -0
- package/dist/tokens.css +10 -9
- package/dist/transfer/index.d.ts +64 -0
- package/dist/transfer/index.js +174 -0
- package/dist/transfer/model.d.ts +12 -0
- package/dist/transfer/model.js +33 -0
- package/dist/tree/index.d.ts +39 -0
- package/dist/tree/index.js +36 -0
- package/dist/tree-select/index.d.ts +59 -0
- package/dist/tree-select/index.js +142 -0
- package/dist/tree-select/model.d.ts +31 -0
- package/dist/tree-select/model.js +135 -0
- package/dist/typewriter/index.d.ts +21 -0
- package/dist/typewriter/index.js +101 -0
- package/dist/typewriter/model.d.ts +7 -0
- package/dist/typewriter/model.js +45 -0
- package/dist/upload/index.d.ts +59 -0
- package/dist/upload/index.js +230 -0
- package/dist/virtual-list/index.d.ts +44 -0
- package/dist/virtual-list/index.js +128 -0
- package/dist/virtual-list/model.d.ts +7 -0
- package/dist/virtual-list/model.js +27 -0
- package/package.json +22 -3
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useId, useMemo, useState, } from 'react';
|
|
3
|
+
import { PencilIcon } from '../PencilIcon.js';
|
|
4
|
+
const defaultSymbolPaths = [
|
|
5
|
+
{ d: 'M12 2.5 L21.5 12 L12 21.5 L2.5 12 Z' },
|
|
6
|
+
{ d: 'M7.5 12 L12 7.5 L16.5 12 L12 16.5 Z', mode: 'scuff' },
|
|
7
|
+
];
|
|
8
|
+
function finitePositive(value, fallback) {
|
|
9
|
+
return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : fallback;
|
|
10
|
+
}
|
|
11
|
+
function decimalPlaces(value) {
|
|
12
|
+
const [coefficient, exponentText] = String(value).toLowerCase().split('e');
|
|
13
|
+
const [, fraction = ''] = coefficient.split('.');
|
|
14
|
+
const exponent = Number(exponentText ?? 0);
|
|
15
|
+
return Math.max(0, fraction.length - exponent);
|
|
16
|
+
}
|
|
17
|
+
export function normalizeRatingValue(value, count, step) {
|
|
18
|
+
const numeric = typeof value === 'number' && Number.isFinite(value) ? value : 0;
|
|
19
|
+
const precision = Math.min(8, Math.max(decimalPlaces(step), decimalPlaces(count)));
|
|
20
|
+
const snapped = Math.round(numeric / step) * step;
|
|
21
|
+
return Number(Math.min(count, Math.max(0, snapped)).toFixed(precision));
|
|
22
|
+
}
|
|
23
|
+
function allowsReselectClear(clearable) {
|
|
24
|
+
return clearable === true || clearable === 'reselect';
|
|
25
|
+
}
|
|
26
|
+
function allowsKeyboardClear(clearable) {
|
|
27
|
+
return clearable === true || clearable === 'keyboard';
|
|
28
|
+
}
|
|
29
|
+
export const Rating = forwardRef(function Rating({ value, defaultValue = 0, onValueChange, count: countProp = 5, step: stepProp = 1, clearable = false, disabled = false, readOnly = false, size = 'md', dir, symbol, renderSymbol, getValueLabel = (nextValue, maximum) => `${nextValue} of ${maximum}`, className = '', 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, onBlur, onKeyDown, onPointerLeave, ...props }, forwardedRef) {
|
|
30
|
+
const count = Math.max(1, Math.floor(finitePositive(countProp, 5)));
|
|
31
|
+
const step = Math.min(count, finitePositive(stepProp, 1));
|
|
32
|
+
const controlled = value !== undefined;
|
|
33
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(() => normalizeRatingValue(defaultValue, count, step));
|
|
34
|
+
const committedValue = normalizeRatingValue(controlled ? value : uncontrolledValue, count, step);
|
|
35
|
+
const [previewValue, setPreviewValue] = useState(null);
|
|
36
|
+
const displayValue = previewValue ?? committedValue;
|
|
37
|
+
const symbolId = useId();
|
|
38
|
+
const symbolIndexes = useMemo(() => Array.from({ length: count }, (_, index) => index), [count]);
|
|
39
|
+
const defaultIconSize = size === 'sm' ? 26 : size === 'lg' ? 38 : 32;
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (disabled || readOnly)
|
|
42
|
+
setPreviewValue(null);
|
|
43
|
+
}, [disabled, readOnly]);
|
|
44
|
+
const commit = (nextValue) => {
|
|
45
|
+
if (disabled || readOnly)
|
|
46
|
+
return;
|
|
47
|
+
const normalized = normalizeRatingValue(nextValue, count, step);
|
|
48
|
+
const cleared = normalized === committedValue && normalized !== 0 && allowsReselectClear(clearable);
|
|
49
|
+
const resolved = cleared ? 0 : normalized;
|
|
50
|
+
setPreviewValue(null);
|
|
51
|
+
if (resolved === committedValue)
|
|
52
|
+
return;
|
|
53
|
+
if (!controlled)
|
|
54
|
+
setUncontrolledValue(resolved);
|
|
55
|
+
onValueChange?.(resolved);
|
|
56
|
+
};
|
|
57
|
+
const valueFromPointer = (event, index) => {
|
|
58
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
59
|
+
const physicalFraction = rect.width > 0 ? (event.clientX - rect.left) / rect.width : 1;
|
|
60
|
+
const logicalFraction = (dir ?? getComputedStyle(event.currentTarget).direction) === 'rtl'
|
|
61
|
+
? 1 - physicalFraction
|
|
62
|
+
: physicalFraction;
|
|
63
|
+
const rawValue = index + Math.min(1, Math.max(0, logicalFraction));
|
|
64
|
+
return normalizeRatingValue(Math.max(step, Math.ceil((rawValue - Number.EPSILON) / step) * step), count, step);
|
|
65
|
+
};
|
|
66
|
+
const handleKeyDown = (event) => {
|
|
67
|
+
onKeyDown?.(event);
|
|
68
|
+
if (event.defaultPrevented || disabled || readOnly)
|
|
69
|
+
return;
|
|
70
|
+
const rtl = (dir ?? getComputedStyle(event.currentTarget).direction) === 'rtl';
|
|
71
|
+
let nextValue = null;
|
|
72
|
+
if (event.key === 'ArrowUp')
|
|
73
|
+
nextValue = committedValue + step;
|
|
74
|
+
if (event.key === 'ArrowDown')
|
|
75
|
+
nextValue = committedValue - step;
|
|
76
|
+
if (event.key === 'ArrowRight')
|
|
77
|
+
nextValue = committedValue + (rtl ? -step : step);
|
|
78
|
+
if (event.key === 'ArrowLeft')
|
|
79
|
+
nextValue = committedValue + (rtl ? step : -step);
|
|
80
|
+
if (event.key === 'Home')
|
|
81
|
+
nextValue = allowsKeyboardClear(clearable) ? 0 : Math.min(step, count);
|
|
82
|
+
if (event.key === 'End')
|
|
83
|
+
nextValue = count;
|
|
84
|
+
if (['Backspace', 'Delete', 'Escape'].includes(event.key) && allowsKeyboardClear(clearable))
|
|
85
|
+
nextValue = 0;
|
|
86
|
+
if (nextValue === null)
|
|
87
|
+
return;
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
setPreviewValue(null);
|
|
90
|
+
let normalized = normalizeRatingValue(nextValue, count, step);
|
|
91
|
+
if (normalized === 0 && committedValue > 0 && !allowsKeyboardClear(clearable)) {
|
|
92
|
+
normalized = Math.min(step, count);
|
|
93
|
+
}
|
|
94
|
+
if (normalized === committedValue)
|
|
95
|
+
return;
|
|
96
|
+
if (!controlled)
|
|
97
|
+
setUncontrolledValue(normalized);
|
|
98
|
+
onValueChange?.(normalized);
|
|
99
|
+
};
|
|
100
|
+
const renderLayerSymbol = (index, fraction, filled) => {
|
|
101
|
+
const state = {
|
|
102
|
+
index: index + 1,
|
|
103
|
+
fraction,
|
|
104
|
+
filled,
|
|
105
|
+
previewing: previewValue !== null,
|
|
106
|
+
};
|
|
107
|
+
if (renderSymbol)
|
|
108
|
+
return renderSymbol(state);
|
|
109
|
+
if (symbol !== undefined)
|
|
110
|
+
return symbol;
|
|
111
|
+
return _jsx(PencilIcon, { paths: defaultSymbolPaths, sourceSize: 24, size: defaultIconSize, active: filled, seed: `${symbolId}-${index}` });
|
|
112
|
+
};
|
|
113
|
+
return (_jsx("div", { ...props, "aria-disabled": disabled || undefined, "aria-label": ariaLabel ?? (ariaLabelledBy ? undefined : 'Rating'), "aria-labelledby": ariaLabelledBy, "aria-readonly": readOnly || undefined, "aria-valuemax": count, "aria-valuemin": 0, "aria-valuenow": committedValue, "aria-valuetext": getValueLabel(committedValue, count), className: ['inkra-rating', className].filter(Boolean).join(' '), "data-disabled": disabled || undefined, "data-previewing": previewValue !== null || undefined, "data-readonly": readOnly || undefined, "data-size": size, dir: dir, onBlur: (event) => {
|
|
114
|
+
setPreviewValue(null);
|
|
115
|
+
onBlur?.(event);
|
|
116
|
+
}, onKeyDown: handleKeyDown, onPointerLeave: (event) => {
|
|
117
|
+
setPreviewValue(null);
|
|
118
|
+
onPointerLeave?.(event);
|
|
119
|
+
}, ref: forwardedRef, role: "slider", tabIndex: disabled ? undefined : (props.tabIndex ?? 0), children: _jsx("span", { className: "inkra-rating__symbols", "aria-hidden": "true", children: symbolIndexes.map((index) => {
|
|
120
|
+
const fraction = Math.min(1, Math.max(0, displayValue - index));
|
|
121
|
+
return (_jsxs("span", { className: "inkra-rating__symbol-target", "data-index": index + 1, onClick: (event) => commit(valueFromPointer(event, index)), onPointerMove: (event) => {
|
|
122
|
+
if (event.pointerType === 'mouse' && !disabled && !readOnly) {
|
|
123
|
+
setPreviewValue(valueFromPointer(event, index));
|
|
124
|
+
}
|
|
125
|
+
}, children: [_jsx("span", { className: "inkra-rating__symbol inkra-rating__symbol--empty", children: renderLayerSymbol(index, 0, false) }), _jsx("span", { className: "inkra-rating__fill", style: { inlineSize: `${fraction * 100}%` }, children: _jsx("span", { className: "inkra-rating__symbol inkra-rating__symbol--filled", children: renderLayerSymbol(index, fraction, true) }) })] }, index));
|
|
126
|
+
}) }) }));
|
|
127
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useGroupCallbackRef, useGroupRef, usePanelCallbackRef, usePanelRef } from 'react-resizable-panels';
|
|
2
|
+
import type { Ref } from 'react';
|
|
3
|
+
import type { GroupImperativeHandle, GroupProps, Layout, LayoutChangedMeta, PanelImperativeHandle, PanelProps, SeparatorProps } from 'react-resizable-panels';
|
|
4
|
+
export type ResizableOrientation = 'horizontal' | 'vertical';
|
|
5
|
+
export type ResizableLayout = Layout;
|
|
6
|
+
export type ResizableLayoutChangeMeta = LayoutChangedMeta;
|
|
7
|
+
export type ResizableRootRef = GroupImperativeHandle;
|
|
8
|
+
export type ResizablePanelRef = PanelImperativeHandle;
|
|
9
|
+
export interface ResizableRootProps extends Omit<GroupProps, 'defaultLayout' | 'elementRef' | 'groupRef' | 'onLayoutChange' | 'onLayoutChanged' | 'orientation' | 'resizeTargetMinimumSize'> {
|
|
10
|
+
orientation?: ResizableOrientation;
|
|
11
|
+
layout?: ResizableLayout;
|
|
12
|
+
defaultLayout?: ResizableLayout;
|
|
13
|
+
onLayoutChange?: (layout: ResizableLayout) => void;
|
|
14
|
+
onLayoutCommit?: (layout: ResizableLayout, meta: ResizableLayoutChangeMeta) => void;
|
|
15
|
+
rootRef?: Ref<HTMLDivElement>;
|
|
16
|
+
apiRef?: Ref<ResizableRootRef>;
|
|
17
|
+
resizeTargetMinimumSize?: GroupProps['resizeTargetMinimumSize'];
|
|
18
|
+
}
|
|
19
|
+
declare function ResizableRoot({ apiRef, className, defaultLayout, layout, onLayoutChange, onLayoutCommit, orientation, resizeTargetMinimumSize, rootRef, ...props }: ResizableRootProps): import("react").JSX.Element;
|
|
20
|
+
export type ResizablePanelProps = PanelProps;
|
|
21
|
+
declare function ResizablePanel({ className, ...props }: ResizablePanelProps): import("react").JSX.Element;
|
|
22
|
+
export interface ResizableHandleProps extends SeparatorProps {
|
|
23
|
+
label?: string;
|
|
24
|
+
lineSeed?: string | number;
|
|
25
|
+
}
|
|
26
|
+
declare function ResizableHandle({ 'aria-label': ariaLabel, children, className, label, lineSeed, ...props }: ResizableHandleProps): import("react").JSX.Element;
|
|
27
|
+
export declare const Resizable: Readonly<{
|
|
28
|
+
Root: typeof ResizableRoot;
|
|
29
|
+
Panel: typeof ResizablePanel;
|
|
30
|
+
Handle: typeof ResizableHandle;
|
|
31
|
+
}>;
|
|
32
|
+
export { useGroupCallbackRef as useResizableRootCallbackRef, useGroupRef as useResizableRootRef, usePanelCallbackRef as useResizablePanelCallbackRef, usePanelRef as useResizablePanelRef, };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Group as ResizableGroupPrimitive, Panel as ResizablePanelPrimitive, Separator as ResizableSeparatorPrimitive, useGroupCallbackRef, useGroupRef, usePanelCallbackRef, usePanelRef, } from 'react-resizable-panels';
|
|
3
|
+
import { useCallback, useReducer } from 'react';
|
|
4
|
+
import { PencilLine } from '../PencilLine.js';
|
|
5
|
+
import { PencilSurface } from '../PencilSurface.js';
|
|
6
|
+
import { useBrowserLayoutEffect } from '../internal/useBrowserLayoutEffect.js';
|
|
7
|
+
const classes = (...values) => values.filter(Boolean).join(' ');
|
|
8
|
+
function assignRef(ref, value) {
|
|
9
|
+
if (typeof ref === 'function')
|
|
10
|
+
ref(value);
|
|
11
|
+
else if (ref)
|
|
12
|
+
ref.current = value;
|
|
13
|
+
}
|
|
14
|
+
function layoutsEqual(current, requested) {
|
|
15
|
+
const currentIds = Object.keys(current);
|
|
16
|
+
const requestedIds = Object.keys(requested);
|
|
17
|
+
return currentIds.length === requestedIds.length
|
|
18
|
+
&& requestedIds.every((id) => Math.abs((current[id] ?? -1) - requested[id]) < 0.001);
|
|
19
|
+
}
|
|
20
|
+
function ResizableRoot({ apiRef, className, defaultLayout, layout, onLayoutChange, onLayoutCommit, orientation = 'horizontal', resizeTargetMinimumSize = { coarse: 44, fine: 12 }, rootRef, ...props }) {
|
|
21
|
+
const [group, setGroup] = useGroupCallbackRef();
|
|
22
|
+
const [layoutRevision, refreshControlledLayout] = useReducer((value) => value + 1, 0);
|
|
23
|
+
const setApiRef = useCallback((value) => {
|
|
24
|
+
setGroup(value);
|
|
25
|
+
assignRef(apiRef, value);
|
|
26
|
+
}, [apiRef, setGroup]);
|
|
27
|
+
const handleLayoutChange = useCallback((nextLayout) => {
|
|
28
|
+
onLayoutChange?.(nextLayout);
|
|
29
|
+
if (layout !== undefined)
|
|
30
|
+
refreshControlledLayout();
|
|
31
|
+
}, [layout, onLayoutChange]);
|
|
32
|
+
useBrowserLayoutEffect(() => {
|
|
33
|
+
if (!group || layout === undefined || layoutsEqual(group.getLayout(), layout))
|
|
34
|
+
return;
|
|
35
|
+
group.setLayout(layout);
|
|
36
|
+
}, [group, layout, layoutRevision]);
|
|
37
|
+
return _jsx(ResizableGroupPrimitive, { ...props, className: classes('inkra-resizable', className), "data-orientation": orientation, defaultLayout: layout ?? defaultLayout, elementRef: rootRef, groupRef: setApiRef, onLayoutChange: handleLayoutChange, onLayoutChanged: onLayoutCommit, orientation: orientation, resizeTargetMinimumSize: resizeTargetMinimumSize });
|
|
38
|
+
}
|
|
39
|
+
function ResizablePanel({ className, ...props }) {
|
|
40
|
+
return _jsx(ResizablePanelPrimitive, { ...props, className: classes('inkra-resizable__panel', className) });
|
|
41
|
+
}
|
|
42
|
+
function ResizableHandle({ 'aria-label': ariaLabel, children, className, label = 'Resize panels', lineSeed = 'inkra-resizable-handle', ...props }) {
|
|
43
|
+
return _jsxs(ResizableSeparatorPrimitive, { ...props, "aria-label": ariaLabel ?? label, className: classes('inkra-resizable__handle', className), children: [_jsx(PencilSurface, { "aria-hidden": "true", as: "span", className: "inkra-resizable__handle-focus", seed: `${lineSeed}-focus`, variant: "outline" }), _jsxs("span", { "aria-hidden": "true", className: "inkra-resizable__handle-mark", children: [_jsx(PencilLine, { className: "inkra-resizable__handle-line inkra-resizable__handle-line--horizontal", seed: `${lineSeed}-horizontal` }), _jsx(PencilLine, { className: "inkra-resizable__handle-line inkra-resizable__handle-line--vertical", orientation: "vertical", seed: `${lineSeed}-vertical` }), children] })] });
|
|
44
|
+
}
|
|
45
|
+
export const Resizable = Object.freeze({
|
|
46
|
+
Root: ResizableRoot,
|
|
47
|
+
Panel: ResizablePanel,
|
|
48
|
+
Handle: ResizableHandle,
|
|
49
|
+
});
|
|
50
|
+
export { useGroupCallbackRef as useResizableRootCallbackRef, useGroupRef as useResizableRootRef, usePanelCallbackRef as useResizablePanelCallbackRef, usePanelRef as useResizablePanelRef, };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ScrollAreaContentProps as PrimitiveContentProps, ScrollAreaCornerProps as PrimitiveCornerProps, ScrollAreaRootProps as PrimitiveRootProps, ScrollAreaScrollbarProps as PrimitiveScrollbarProps, ScrollAreaThumbProps as PrimitiveThumbProps, ScrollAreaViewportProps as PrimitiveViewportProps } from '@base-ui/react/scroll-area';
|
|
2
|
+
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
3
|
+
export type ScrollAreaVisibility = 'auto' | 'always';
|
|
4
|
+
export interface ScrollAreaProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
/** Keep custom scrollbars visible, or reveal them while scrolling/hovering. */
|
|
7
|
+
type?: ScrollAreaVisibility;
|
|
8
|
+
/** The distance in pixels before overflow edge attributes become active. */
|
|
9
|
+
overflowEdgeThreshold?: PrimitiveRootProps['overflowEdgeThreshold'];
|
|
10
|
+
/** Stable seed used by the pencil scrollbar surfaces. */
|
|
11
|
+
seed?: string | number;
|
|
12
|
+
/** Localized accessible name for the scrollable viewport. */
|
|
13
|
+
viewportLabel?: string;
|
|
14
|
+
viewportProps?: Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'role'>;
|
|
15
|
+
}
|
|
16
|
+
export type ScrollAreaRootProps = PrimitiveRootProps;
|
|
17
|
+
export type ScrollAreaViewportProps = PrimitiveViewportProps;
|
|
18
|
+
export type ScrollAreaScrollbarProps = PrimitiveScrollbarProps;
|
|
19
|
+
export type ScrollAreaThumbProps = PrimitiveThumbProps;
|
|
20
|
+
export type ScrollAreaContentProps = PrimitiveContentProps;
|
|
21
|
+
export type ScrollAreaCornerProps = PrimitiveCornerProps;
|
|
22
|
+
declare const ScrollAreaRoot: import("react").ForwardRefExoticComponent<ScrollAreaProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
23
|
+
declare const Viewport: import("react").ForwardRefExoticComponent<Omit<PrimitiveViewportProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
24
|
+
declare const Content: import("react").ForwardRefExoticComponent<Omit<PrimitiveContentProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
25
|
+
declare const Scrollbar: import("react").ForwardRefExoticComponent<Omit<PrimitiveScrollbarProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
26
|
+
declare const Thumb: import("react").ForwardRefExoticComponent<Omit<PrimitiveThumbProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
27
|
+
declare const Corner: import("react").ForwardRefExoticComponent<Omit<PrimitiveCornerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
28
|
+
export declare const ScrollArea: import("react").ForwardRefExoticComponent<ScrollAreaProps & import("react").RefAttributes<HTMLDivElement>> & {
|
|
29
|
+
Root: import("react").ForwardRefExoticComponent<ScrollAreaProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
30
|
+
Viewport: import("react").ForwardRefExoticComponent<Omit<PrimitiveViewportProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
31
|
+
Content: import("react").ForwardRefExoticComponent<Omit<PrimitiveContentProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
32
|
+
Scrollbar: import("react").ForwardRefExoticComponent<Omit<PrimitiveScrollbarProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
33
|
+
Thumb: import("react").ForwardRefExoticComponent<Omit<PrimitiveThumbProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
34
|
+
Corner: import("react").ForwardRefExoticComponent<Omit<PrimitiveCornerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
35
|
+
};
|
|
36
|
+
export { ScrollAreaRoot, Viewport as ScrollAreaViewport, Content as ScrollAreaContent, Scrollbar as ScrollAreaScrollbar, Thumb as ScrollAreaThumb, Corner as ScrollAreaCorner };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ScrollArea as ScrollAreaPrimitive } from '@base-ui/react/scroll-area';
|
|
3
|
+
import { forwardRef, useId } from 'react';
|
|
4
|
+
import { PencilSurface } from '../PencilSurface.js';
|
|
5
|
+
function classes(...values) {
|
|
6
|
+
return values.filter(Boolean).join(' ');
|
|
7
|
+
}
|
|
8
|
+
function withClassName(base, value) {
|
|
9
|
+
return typeof value === 'function'
|
|
10
|
+
? (state) => classes(base, value(state))
|
|
11
|
+
: classes(base, value);
|
|
12
|
+
}
|
|
13
|
+
const ScrollAreaRoot = forwardRef(function ScrollAreaRoot({ 'aria-label': ariaLabel, children, className, overflowEdgeThreshold, seed, style, type = 'auto', viewportLabel, viewportProps, ...props }, ref) {
|
|
14
|
+
const generatedId = useId();
|
|
15
|
+
const resolvedSeed = seed ?? `inkra-scroll-area-${generatedId}`;
|
|
16
|
+
const viewportClassName = classes('inkra-scroll-area__viewport', viewportProps?.className);
|
|
17
|
+
const viewportStyle = viewportProps?.style;
|
|
18
|
+
const viewportLabelValue = viewportProps?.['aria-label'] ?? viewportLabel ?? ariaLabel;
|
|
19
|
+
return _jsxs(ScrollAreaPrimitive.Root, { ...props, ...(ariaLabel ? { 'aria-label': ariaLabel } : {}), className: classes('inkra-scroll-area', className), "data-type": type, overflowEdgeThreshold: overflowEdgeThreshold, ref: ref, style: style, children: [_jsx(ScrollAreaPrimitive.Viewport, { ...viewportProps, "aria-label": viewportLabelValue, className: viewportClassName, style: viewportStyle, children: children }), _jsxs(ScrollAreaPrimitive.Scrollbar, { className: "inkra-scroll-area__scrollbar", orientation: "vertical", children: [_jsx(PencilSurface, { "aria-hidden": "true", as: "span", className: "inkra-scroll-area__track", radius: 3, seed: `${resolvedSeed}-vertical-track`, variant: "quiet" }), _jsx(ScrollAreaPrimitive.Thumb, { className: "inkra-scroll-area__thumb", children: _jsx(PencilSurface, { "aria-hidden": "true", as: "span", className: "inkra-scroll-area__thumb-surface", radius: 3, seed: `${resolvedSeed}-vertical-thumb`, variant: "outline" }) })] }), _jsxs(ScrollAreaPrimitive.Scrollbar, { className: "inkra-scroll-area__scrollbar", orientation: "horizontal", children: [_jsx(PencilSurface, { "aria-hidden": "true", as: "span", className: "inkra-scroll-area__track", radius: 3, seed: `${resolvedSeed}-horizontal-track`, variant: "quiet" }), _jsx(ScrollAreaPrimitive.Thumb, { className: "inkra-scroll-area__thumb", children: _jsx(PencilSurface, { "aria-hidden": "true", as: "span", className: "inkra-scroll-area__thumb-surface", radius: 3, seed: `${resolvedSeed}-horizontal-thumb`, variant: "outline" }) })] }), _jsx(ScrollAreaPrimitive.Corner, { className: "inkra-scroll-area__corner" })] });
|
|
20
|
+
});
|
|
21
|
+
const Viewport = forwardRef(function Viewport({ className, ...props }, ref) {
|
|
22
|
+
return _jsx(ScrollAreaPrimitive.Viewport, { ...props, className: withClassName('inkra-scroll-area__viewport', className), ref: ref });
|
|
23
|
+
});
|
|
24
|
+
const Content = forwardRef(function Content({ className, ...props }, ref) {
|
|
25
|
+
return _jsx(ScrollAreaPrimitive.Content, { ...props, className: withClassName('inkra-scroll-area__content', className), ref: ref });
|
|
26
|
+
});
|
|
27
|
+
const Scrollbar = forwardRef(function Scrollbar({ className, ...props }, ref) {
|
|
28
|
+
return _jsx(ScrollAreaPrimitive.Scrollbar, { ...props, className: withClassName('inkra-scroll-area__scrollbar', className), ref: ref });
|
|
29
|
+
});
|
|
30
|
+
const Thumb = forwardRef(function Thumb({ className, ...props }, ref) {
|
|
31
|
+
return _jsx(ScrollAreaPrimitive.Thumb, { ...props, className: withClassName('inkra-scroll-area__thumb', className), ref: ref });
|
|
32
|
+
});
|
|
33
|
+
const Corner = forwardRef(function Corner({ className, ...props }, ref) {
|
|
34
|
+
return _jsx(ScrollAreaPrimitive.Corner, { ...props, className: withClassName('inkra-scroll-area__corner', className), ref: ref });
|
|
35
|
+
});
|
|
36
|
+
export const ScrollArea = Object.assign(ScrollAreaRoot, {
|
|
37
|
+
Root: ScrollAreaRoot,
|
|
38
|
+
Viewport,
|
|
39
|
+
Content,
|
|
40
|
+
Scrollbar,
|
|
41
|
+
Thumb,
|
|
42
|
+
Corner,
|
|
43
|
+
});
|
|
44
|
+
export { ScrollAreaRoot, Viewport as ScrollAreaViewport, Content as ScrollAreaContent, Scrollbar as ScrollAreaScrollbar, Thumb as ScrollAreaThumb, Corner as ScrollAreaCorner };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type ProgressPartialSegment = 'fractional' | 'complete' | 'next';
|
|
2
|
+
export interface ProgressThreshold {
|
|
3
|
+
value: number;
|
|
4
|
+
color: string;
|
|
5
|
+
}
|
|
6
|
+
interface SegmentedProgressProps {
|
|
7
|
+
count: number;
|
|
8
|
+
gap: number;
|
|
9
|
+
max: number;
|
|
10
|
+
partialSegment: ProgressPartialSegment;
|
|
11
|
+
percent: number | null;
|
|
12
|
+
seed: string | number;
|
|
13
|
+
segmentColors?: readonly string[];
|
|
14
|
+
thresholds?: readonly ProgressThreshold[];
|
|
15
|
+
}
|
|
16
|
+
export declare function SegmentedProgress({ count, gap, max, partialSegment, percent, seed, segmentColors, thresholds, }: SegmentedProgressProps): import("react").JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { PencilSurface } from '../PencilSurface.js';
|
|
3
|
+
function segmentFill(index, count, percent, policy) {
|
|
4
|
+
if (percent === null)
|
|
5
|
+
return 1;
|
|
6
|
+
const raw = percent / 100 * count - index;
|
|
7
|
+
if (policy === 'complete')
|
|
8
|
+
return raw >= 1 ? 1 : 0;
|
|
9
|
+
if (policy === 'next')
|
|
10
|
+
return raw > 0 ? 1 : 0;
|
|
11
|
+
return Math.max(0, Math.min(1, raw));
|
|
12
|
+
}
|
|
13
|
+
function thresholdColor(index, count, max, thresholds) {
|
|
14
|
+
if (!thresholds?.length)
|
|
15
|
+
return undefined;
|
|
16
|
+
const segmentValue = index / count * max;
|
|
17
|
+
let color;
|
|
18
|
+
for (const threshold of thresholds) {
|
|
19
|
+
if (!Number.isFinite(threshold.value) || !threshold.color || threshold.value > segmentValue)
|
|
20
|
+
continue;
|
|
21
|
+
color = threshold.color;
|
|
22
|
+
}
|
|
23
|
+
return color;
|
|
24
|
+
}
|
|
25
|
+
export function SegmentedProgress({ count, gap, max, partialSegment, percent, seed, segmentColors, thresholds, }) {
|
|
26
|
+
const normalizedThresholds = thresholds
|
|
27
|
+
?.filter(threshold => Number.isFinite(threshold.value) && threshold.color)
|
|
28
|
+
.map(threshold => ({ ...threshold, value: Math.max(0, Math.min(max, threshold.value)) }))
|
|
29
|
+
.sort((left, right) => left.value - right.value);
|
|
30
|
+
return (_jsx("span", { "aria-hidden": "true", className: "inkra-progress__segments", style: {
|
|
31
|
+
'--inkra-progress-segment-count': count,
|
|
32
|
+
'--inkra-progress-segment-gap': `${gap}px`,
|
|
33
|
+
}, children: Array.from({ length: count }, (_, index) => {
|
|
34
|
+
const fill = segmentFill(index, count, percent, partialSegment);
|
|
35
|
+
const color = segmentColors?.[index] || thresholdColor(index, count, max, normalizedThresholds);
|
|
36
|
+
const style = {
|
|
37
|
+
'--inkra-progress-segment-fill': `${fill * 100}%`,
|
|
38
|
+
...(color ? { '--inkra-selection-pigment': color } : {}),
|
|
39
|
+
};
|
|
40
|
+
return (_jsxs("span", { className: "inkra-progress__segment", "data-fill": fill === 0 ? 'empty' : fill === 1 ? 'full' : 'partial', children: [_jsx(PencilSurface, { as: "span", className: "inkra-progress__segment-outline", radius: 3, seed: `${seed}-segment-${index}-outline`, variant: "outline" }), _jsx("span", { className: "inkra-progress__segment-fill-clip", style: style, children: _jsx(PencilSurface, { as: "span", className: "inkra-progress__segment-fill", radius: 3, seed: `${seed}-segment-${index}-fill`, variant: "selection" }) })] }, index));
|
|
41
|
+
}) }));
|
|
42
|
+
}
|
package/dist/slider/index.js
CHANGED
|
@@ -40,6 +40,6 @@ export const Slider = forwardRef(function Slider({ 'aria-label': ariaLabel, 'ari
|
|
|
40
40
|
const thumbLabel = thumbLabels?.[index];
|
|
41
41
|
const labelledBy = thumbLabel ? undefined : ariaLabelledBy;
|
|
42
42
|
const label = thumbLabel ?? (ariaLabel ? `${ariaLabel}${values.length > 1 ? ` ${index + 1}` : ''}` : labelledBy ? undefined : `Value${values.length > 1 ? ` ${index + 1}` : ''}`);
|
|
43
|
-
return _jsx(SliderPrimitive.Thumb, { "aria-describedby": ariaDescribedBy, "aria-label": label, "aria-labelledby": labelledBy, "aria-valuetext": getValueLabel?.(current, index) ?? ariaValueText, className: "inkra-slider__thumb", children: _jsx(PencilSurface, { as: "span", "aria-hidden": "true", className: "inkra-slider__thumb-surface", variant: "paper", radius: 8, seed: `${resolvedSeed}-thumb-${index}`, children: _jsx(PencilSurface, { as: "span", className: "inkra-slider__focus-ring", variant: "outline", radius: 8, seed: `${resolvedSeed}-focus-${index}` }) }) }, index);
|
|
43
|
+
return _jsx(SliderPrimitive.Thumb, { "aria-describedby": ariaDescribedBy, "aria-label": label, "aria-labelledby": labelledBy, "aria-valuenow": current, "aria-valuetext": getValueLabel?.(current, index) ?? ariaValueText, className: "inkra-slider__thumb", children: _jsx(PencilSurface, { as: "span", "aria-hidden": "true", className: "inkra-slider__thumb-surface", variant: "paper", radius: 8, seed: `${resolvedSeed}-thumb-${index}`, children: _jsx(PencilSurface, { as: "span", className: "inkra-slider__focus-ring", variant: "outline", radius: 8, seed: `${resolvedSeed}-focus-${index}` }) }) }, index);
|
|
44
44
|
})] });
|
|
45
45
|
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type SlotSize = 'sm' | 'md' | 'lg';
|
|
3
|
+
interface SlotSharedProps {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
/** Shows emptyContent instead of children while preserving the slot geometry. */
|
|
6
|
+
empty?: boolean;
|
|
7
|
+
emptyContent?: ReactNode;
|
|
8
|
+
selected?: boolean;
|
|
9
|
+
size?: SlotSize;
|
|
10
|
+
count?: number;
|
|
11
|
+
/** Replaces the default Badge while keeping the count anchored to the slot. */
|
|
12
|
+
renderCount?: (count: number) => ReactNode;
|
|
13
|
+
seed?: string | number;
|
|
14
|
+
}
|
|
15
|
+
export interface StaticSlotProps extends SlotSharedProps, Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
16
|
+
interactive?: false;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface InteractiveSlotProps extends SlotSharedProps, Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {
|
|
20
|
+
interactive: true;
|
|
21
|
+
}
|
|
22
|
+
export type SlotProps = StaticSlotProps | InteractiveSlotProps;
|
|
23
|
+
export declare const Slot: import("react").ForwardRefExoticComponent<SlotProps & import("react").RefAttributes<HTMLButtonElement | HTMLDivElement>>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useId } from 'react';
|
|
3
|
+
import { Badge } from '../display/index.js';
|
|
4
|
+
import { PencilSurface } from '../PencilSurface.js';
|
|
5
|
+
const classes = (...values) => values.filter(Boolean).join(' ');
|
|
6
|
+
export const Slot = forwardRef(function Slot({ children, className, count, disabled = false, empty = false, emptyContent, interactive = false, renderCount, seed, selected = false, size = 'md', ...props }, ref) {
|
|
7
|
+
const generatedId = useId();
|
|
8
|
+
const resolvedSeed = seed ?? `inkra-slot-${generatedId}`;
|
|
9
|
+
const content = empty
|
|
10
|
+
? (emptyContent ?? _jsx("span", { className: "inkra-slot__empty-mark", "aria-hidden": "true", children: "+" }))
|
|
11
|
+
: children;
|
|
12
|
+
const countContent = count == null
|
|
13
|
+
? null
|
|
14
|
+
: renderCount?.(count) ?? _jsx(Badge, { size: "sm", "aria-label": `${count}`, children: count });
|
|
15
|
+
const commonProps = {
|
|
16
|
+
...props,
|
|
17
|
+
className: classes('inkra-slot', className),
|
|
18
|
+
'data-disabled': disabled || undefined,
|
|
19
|
+
'data-empty': empty || undefined,
|
|
20
|
+
'data-interactive': interactive || undefined,
|
|
21
|
+
'data-selected': selected || undefined,
|
|
22
|
+
'data-size': size,
|
|
23
|
+
};
|
|
24
|
+
const body = _jsxs(_Fragment, { children: [selected && _jsx(PencilSurface, { as: "span", "aria-hidden": "true", className: "inkra-slot__selected-wash", seed: `${resolvedSeed}-wash`, variant: "selection" }), _jsx("span", { className: "inkra-slot__content", children: content }), selected && _jsx(PencilSurface, { as: "span", "aria-hidden": "true", className: "inkra-slot__selected-outline", radius: 8, seed: `${resolvedSeed}-outline`, variant: "outline" }), countContent != null && _jsx("span", { className: "inkra-slot__count", children: countContent })] });
|
|
25
|
+
if (interactive) {
|
|
26
|
+
return _jsx(PencilSurface, { ...commonProps, as: "button", "aria-pressed": selected, disabled: disabled, radius: 8, ref: ref, seed: resolvedSeed, variant: "paper", children: body });
|
|
27
|
+
}
|
|
28
|
+
return _jsx(PencilSurface, { ...commonProps, as: "div", "aria-disabled": disabled || undefined, radius: 8, ref: ref, seed: resolvedSeed, variant: "paper", children: body });
|
|
29
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import type { SortableChangeDetails, SortableContainerData, SortableIdentifier } from './model.js';
|
|
3
|
+
export type { SortableChangeDetails, SortableContainerData, SortableIdentifier, SortableLayout, SortableLocation, } from './model.js';
|
|
4
|
+
export interface SortableLabels {
|
|
5
|
+
handle?: string;
|
|
6
|
+
screenReaderInstructions?: string;
|
|
7
|
+
pickedUp?: (item: string, container: string, position: number, count: number) => string;
|
|
8
|
+
movedOver?: (item: string, container: string, position: number, count: number) => string;
|
|
9
|
+
dropped?: (item: string, container: string, position: number, count: number) => string;
|
|
10
|
+
cancelled?: (item: string) => string;
|
|
11
|
+
}
|
|
12
|
+
export interface SortableItemRenderState<Item> {
|
|
13
|
+
item: Item;
|
|
14
|
+
id: SortableIdentifier;
|
|
15
|
+
containerId: SortableIdentifier;
|
|
16
|
+
index: number;
|
|
17
|
+
disabled: boolean;
|
|
18
|
+
isDragging: boolean;
|
|
19
|
+
isOverlay: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface SortableHandleRenderState<Item> extends SortableItemRenderState<Item> {
|
|
22
|
+
props: ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
23
|
+
ref: (element: HTMLButtonElement | null) => void;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export interface SortableContainerRenderState<Item> {
|
|
27
|
+
container: SortableContainerData<Item>;
|
|
28
|
+
isOver: boolean;
|
|
29
|
+
itemCount: number;
|
|
30
|
+
}
|
|
31
|
+
export interface SortableProps<Item> {
|
|
32
|
+
containers: readonly SortableContainerData<Item>[];
|
|
33
|
+
getItemId: (item: Item) => SortableIdentifier;
|
|
34
|
+
renderItem: (state: SortableItemRenderState<Item>) => ReactNode;
|
|
35
|
+
onChange: (containers: SortableContainerData<Item>[], details: SortableChangeDetails<Item>) => void;
|
|
36
|
+
onReorder?: (details: SortableChangeDetails<Item>) => void;
|
|
37
|
+
onMove?: (details: SortableChangeDetails<Item>) => void;
|
|
38
|
+
renderContainerHeader?: (state: SortableContainerRenderState<Item>) => ReactNode;
|
|
39
|
+
renderOverlay?: (state: SortableItemRenderState<Item>) => ReactNode;
|
|
40
|
+
handle?: boolean | ((state: SortableHandleRenderState<Item>) => ReactNode);
|
|
41
|
+
isItemDisabled?: (item: Item, container: SortableContainerData<Item>) => boolean;
|
|
42
|
+
getItemLabel?: (item: Item) => string;
|
|
43
|
+
getContainerLabel?: (container: SortableContainerData<Item>) => string;
|
|
44
|
+
labels?: SortableLabels;
|
|
45
|
+
className?: string;
|
|
46
|
+
containerClassName?: string;
|
|
47
|
+
itemClassName?: string;
|
|
48
|
+
autoScroll?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export declare function Sortable<Item>({ autoScroll, className, containerClassName, containers, getContainerLabel, getItemId, getItemLabel, handle, isItemDisabled, itemClassName, labels: labelsProp, onChange, onMove, onReorder, renderContainerHeader, renderItem, renderOverlay, }: SortableProps<Item>): import("react").JSX.Element;
|