@womp/kookie-ui 0.36.0 → 0.37.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/components.css +0 -20
- package/dist/cjs/components/_internal/base-menu.utils.js +1 -1
- package/dist/cjs/components/_internal/base-menu.utils.js.map +2 -2
- package/dist/cjs/components/_internal/menu-context.js +1 -1
- package/dist/cjs/components/_internal/menu-context.js.map +2 -2
- package/dist/cjs/components/_internal/pane-chrome.js +1 -1
- package/dist/cjs/components/_internal/pane-chrome.js.map +2 -2
- package/dist/cjs/components/_internal/shell-bottom.d.ts +3 -3
- package/dist/cjs/components/_internal/shell-bottom.d.ts.map +1 -1
- package/dist/cjs/components/_internal/shell-bottom.js +1 -1
- package/dist/cjs/components/_internal/shell-bottom.js.map +3 -3
- package/dist/cjs/components/_internal/shell-handles.d.ts.map +1 -1
- package/dist/cjs/components/_internal/shell-handles.js +1 -1
- package/dist/cjs/components/_internal/shell-handles.js.map +3 -3
- package/dist/cjs/components/_internal/shell-inspector.d.ts +3 -3
- package/dist/cjs/components/_internal/shell-inspector.d.ts.map +1 -1
- package/dist/cjs/components/_internal/shell-inspector.js +1 -1
- package/dist/cjs/components/_internal/shell-inspector.js.map +3 -3
- package/dist/cjs/components/_internal/shell-pane.d.ts +2 -7
- package/dist/cjs/components/_internal/shell-pane.d.ts.map +1 -1
- package/dist/cjs/components/_internal/shell-pane.js +1 -1
- package/dist/cjs/components/_internal/shell-pane.js.map +3 -3
- package/dist/cjs/components/_internal/shell-resizable.d.ts +3 -9
- package/dist/cjs/components/_internal/shell-resizable.d.ts.map +1 -1
- package/dist/cjs/components/_internal/shell-resizable.js +1 -1
- package/dist/cjs/components/_internal/shell-resizable.js.map +3 -3
- package/dist/cjs/components/_internal/shell-resize.d.ts +0 -4
- package/dist/cjs/components/_internal/shell-resize.d.ts.map +1 -1
- package/dist/cjs/components/_internal/shell-resize.js +1 -1
- package/dist/cjs/components/_internal/shell-resize.js.map +2 -2
- package/dist/cjs/components/_internal/shell-rest.d.ts +1 -6
- package/dist/cjs/components/_internal/shell-rest.d.ts.map +1 -1
- package/dist/cjs/components/_internal/shell-rest.js +1 -1
- package/dist/cjs/components/_internal/shell-rest.js.map +3 -3
- package/dist/cjs/components/_internal/shell-sidebar.d.ts +3 -3
- package/dist/cjs/components/_internal/shell-sidebar.d.ts.map +1 -1
- package/dist/cjs/components/_internal/shell-sidebar.js +1 -1
- package/dist/cjs/components/_internal/shell-sidebar.js.map +3 -3
- package/dist/cjs/components/_internal/shell-store.d.ts +0 -10
- package/dist/cjs/components/_internal/shell-store.d.ts.map +1 -1
- package/dist/cjs/components/_internal/shell-store.js +1 -1
- package/dist/cjs/components/_internal/shell-store.js.map +3 -3
- package/dist/cjs/components/checkbox-group.js +1 -1
- package/dist/cjs/components/checkbox-group.js.map +3 -3
- package/dist/cjs/components/checkbox-group.primitive.d.ts +0 -10
- package/dist/cjs/components/checkbox-group.primitive.d.ts.map +1 -1
- package/dist/cjs/components/checkbox-group.primitive.js +1 -1
- package/dist/cjs/components/checkbox-group.primitive.js.map +3 -3
- package/dist/cjs/components/context-menu.d.ts +1 -5
- package/dist/cjs/components/context-menu.d.ts.map +1 -1
- package/dist/cjs/components/context-menu.js +1 -1
- package/dist/cjs/components/context-menu.js.map +3 -3
- package/dist/cjs/components/dropdown-menu.js +1 -1
- package/dist/cjs/components/dropdown-menu.js.map +2 -2
- package/dist/cjs/components/index.js +2 -2
- package/dist/cjs/components/index.js.map +4 -4
- package/dist/cjs/components/navigator.js.map +2 -2
- package/dist/cjs/components/schemas/index.d.ts +1 -1
- package/dist/cjs/components/schemas/index.d.ts.map +1 -1
- package/dist/cjs/components/schemas/index.js +1 -1
- package/dist/cjs/components/schemas/index.js.map +3 -3
- package/dist/cjs/components/schemas/shell.schema.d.ts +6 -112
- package/dist/cjs/components/schemas/shell.schema.d.ts.map +1 -1
- package/dist/cjs/components/schemas/shell.schema.js +1 -1
- package/dist/cjs/components/schemas/shell.schema.js.map +3 -3
- package/dist/cjs/components/separator.js +1 -1
- package/dist/cjs/components/separator.js.map +2 -2
- package/dist/cjs/components/shell.context.d.ts +1 -45
- package/dist/cjs/components/shell.context.d.ts.map +1 -1
- package/dist/cjs/components/shell.context.js +1 -1
- package/dist/cjs/components/shell.context.js.map +4 -4
- package/dist/cjs/components/shell.d.ts +7 -37
- package/dist/cjs/components/shell.d.ts.map +1 -1
- package/dist/cjs/components/shell.js +1 -1
- package/dist/cjs/components/shell.js.map +4 -4
- package/dist/cjs/components/shell.types.d.ts +6 -27
- package/dist/cjs/components/shell.types.d.ts.map +1 -1
- package/dist/cjs/components/shell.types.js +1 -1
- package/dist/cjs/components/shell.types.js.map +2 -2
- package/dist/cjs/components/sidebar.js +1 -1
- package/dist/cjs/components/sidebar.js.map +2 -2
- package/dist/cjs/components/toolbar.js +1 -1
- package/dist/cjs/components/toolbar.js.map +2 -2
- package/dist/cjs/hooks/use-breakpoint.js +1 -1
- package/dist/cjs/hooks/use-breakpoint.js.map +2 -2
- package/dist/cjs/index.js +4 -4
- package/dist/cjs/index.js.map +4 -4
- package/dist/esm/{chunk-5RLGDXOM.js → chunk-2K46JPUL.js} +2 -2
- package/dist/esm/chunk-3K7E4XL3.js +3 -0
- package/dist/esm/chunk-3K7E4XL3.js.map +7 -0
- package/dist/esm/chunk-3LR7KMBE.js +3 -0
- package/dist/esm/chunk-3LR7KMBE.js.map +7 -0
- package/dist/esm/chunk-5U2LEJLU.js +3 -0
- package/dist/esm/chunk-5U2LEJLU.js.map +7 -0
- package/dist/esm/{chunk-IN6D33TU.js → chunk-5XO3PLDH.js} +2 -2
- package/dist/esm/{chunk-COLJWVN7.js → chunk-AQR42GKA.js} +2 -2
- package/dist/esm/{chunk-FTNZWAPB.js → chunk-ARPUPT4M.js} +2 -2
- package/dist/esm/{chunk-ISCZ57VL.js → chunk-DJGZ4K3V.js} +2 -2
- package/dist/esm/{chunk-PMXIQ5B4.js → chunk-FKCKELUB.js} +2 -2
- package/dist/esm/chunk-H7GH3DTF.js +3 -0
- package/dist/esm/chunk-H7GH3DTF.js.map +7 -0
- package/dist/esm/{chunk-E6MOZSYV.js → chunk-HNOT2HS4.js} +2 -2
- package/dist/esm/chunk-LBAC2X4U.js +3 -0
- package/dist/esm/{chunk-5BXCPANF.js.map → chunk-LBAC2X4U.js.map} +3 -3
- package/dist/esm/{chunk-MAA6LEE2.js → chunk-MDQ7ZHOS.js} +1 -1
- package/dist/esm/chunk-MDQ7ZHOS.js.map +7 -0
- package/dist/esm/chunk-MQA3BKF4.js +3 -0
- package/dist/esm/chunk-MQA3BKF4.js.map +7 -0
- package/dist/esm/chunk-MXNPCJPV.js +3 -0
- package/dist/esm/chunk-MXNPCJPV.js.map +7 -0
- package/dist/esm/{chunk-EB4AG3OL.js → chunk-REELD6CT.js} +2 -2
- package/dist/esm/chunk-RYXIRZQW.js +3 -0
- package/dist/esm/chunk-RYXIRZQW.js.map +7 -0
- package/dist/esm/chunk-S66WR5R7.js +3 -0
- package/dist/esm/{chunk-MXEOE4LA.js.map → chunk-S66WR5R7.js.map} +2 -2
- package/dist/esm/chunk-SECVO3CW.js +3 -0
- package/dist/esm/chunk-SECVO3CW.js.map +7 -0
- package/dist/esm/chunk-SHDZYFUN.js +3 -0
- package/dist/esm/chunk-SHDZYFUN.js.map +7 -0
- package/dist/esm/{chunk-3M5ZM67R.js → chunk-TCFBNE6A.js} +2 -2
- package/dist/esm/chunk-U7P64MXD.js +3 -0
- package/dist/esm/chunk-U7P64MXD.js.map +7 -0
- package/dist/esm/chunk-UFYQC5XY.js +3 -0
- package/dist/esm/chunk-UFYQC5XY.js.map +7 -0
- package/dist/esm/{chunk-G66WDIIV.js → chunk-WJKCXGVN.js} +2 -2
- package/dist/esm/chunk-XBDAE77C.js +3 -0
- package/dist/esm/chunk-XBDAE77C.js.map +7 -0
- package/dist/esm/{chunk-SIYOLE6P.js → chunk-YM47BXKK.js} +2 -2
- package/dist/esm/components/_internal/base-menu.utils.js +1 -1
- package/dist/esm/components/_internal/menu-context.js +1 -1
- package/dist/esm/components/_internal/pane-chrome.js +1 -1
- package/dist/esm/components/_internal/shell-bottom.d.ts +3 -3
- package/dist/esm/components/_internal/shell-bottom.d.ts.map +1 -1
- package/dist/esm/components/_internal/shell-bottom.js +1 -1
- package/dist/esm/components/_internal/shell-handles.d.ts.map +1 -1
- package/dist/esm/components/_internal/shell-handles.js +1 -1
- package/dist/esm/components/_internal/shell-inspector.d.ts +3 -3
- package/dist/esm/components/_internal/shell-inspector.d.ts.map +1 -1
- package/dist/esm/components/_internal/shell-inspector.js +1 -1
- package/dist/esm/components/_internal/shell-pane.d.ts +2 -7
- package/dist/esm/components/_internal/shell-pane.d.ts.map +1 -1
- package/dist/esm/components/_internal/shell-pane.js +1 -1
- package/dist/esm/components/_internal/shell-resizable.d.ts +3 -9
- package/dist/esm/components/_internal/shell-resizable.d.ts.map +1 -1
- package/dist/esm/components/_internal/shell-resizable.js +1 -1
- package/dist/esm/components/_internal/shell-resize.d.ts +0 -4
- package/dist/esm/components/_internal/shell-resize.d.ts.map +1 -1
- package/dist/esm/components/_internal/shell-resize.js +1 -1
- package/dist/esm/components/_internal/shell-rest.d.ts +1 -6
- package/dist/esm/components/_internal/shell-rest.d.ts.map +1 -1
- package/dist/esm/components/_internal/shell-rest.js +1 -1
- package/dist/esm/components/_internal/shell-sidebar.d.ts +3 -3
- package/dist/esm/components/_internal/shell-sidebar.d.ts.map +1 -1
- package/dist/esm/components/_internal/shell-sidebar.js +1 -1
- package/dist/esm/components/_internal/shell-store.d.ts +0 -10
- package/dist/esm/components/_internal/shell-store.d.ts.map +1 -1
- package/dist/esm/components/_internal/shell-store.js +1 -1
- package/dist/esm/components/checkbox-group.js +1 -1
- package/dist/esm/components/checkbox-group.primitive.d.ts +0 -10
- package/dist/esm/components/checkbox-group.primitive.d.ts.map +1 -1
- package/dist/esm/components/checkbox-group.primitive.js +1 -1
- package/dist/esm/components/context-menu.d.ts +1 -5
- package/dist/esm/components/context-menu.d.ts.map +1 -1
- package/dist/esm/components/context-menu.js +1 -1
- package/dist/esm/components/dropdown-menu.js +1 -1
- package/dist/esm/components/index.js +1 -1
- package/dist/esm/components/navigator.js +1 -1
- package/dist/esm/components/schemas/index.d.ts +1 -1
- package/dist/esm/components/schemas/index.d.ts.map +1 -1
- package/dist/esm/components/schemas/index.js +1 -1
- package/dist/esm/components/schemas/index.js.map +2 -2
- package/dist/esm/components/schemas/shell.schema.d.ts +6 -112
- package/dist/esm/components/schemas/shell.schema.d.ts.map +1 -1
- package/dist/esm/components/schemas/shell.schema.js +1 -1
- package/dist/esm/components/separator.js +1 -1
- package/dist/esm/components/shell.context.d.ts +1 -45
- package/dist/esm/components/shell.context.d.ts.map +1 -1
- package/dist/esm/components/shell.context.js +1 -1
- package/dist/esm/components/shell.d.ts +7 -37
- package/dist/esm/components/shell.d.ts.map +1 -1
- package/dist/esm/components/shell.js +1 -1
- package/dist/esm/components/shell.types.d.ts +6 -27
- package/dist/esm/components/shell.types.d.ts.map +1 -1
- package/dist/esm/components/shell.types.js +1 -1
- package/dist/esm/components/sidebar.js +1 -1
- package/dist/esm/components/toolbar.js +1 -1
- package/dist/esm/components/virtual-menu.js +1 -1
- package/dist/esm/hooks/use-breakpoint.js +1 -1
- package/dist/esm/index.js +1 -1
- package/package.json +1 -1
- package/schemas/index.json +13 -335
- package/schemas/shell-bottom.json +2 -63
- package/schemas/shell-inspector.json +2 -63
- package/schemas/shell-panel.json +2 -63
- package/schemas/shell-rail.json +2 -38
- package/schemas/shell-sidebar.json +5 -102
- package/schemas/shell-trigger.json +0 -6
- package/src/components/_internal/shell-bottom.tsx +6 -26
- package/src/components/_internal/shell-handles.tsx +2 -32
- package/src/components/_internal/shell-inspector.tsx +6 -26
- package/src/components/_internal/shell-pane.tsx +7 -56
- package/src/components/_internal/shell-resizable.tsx +6 -81
- package/src/components/_internal/shell-resize.tsx +0 -4
- package/src/components/_internal/shell-rest.ts +2 -11
- package/src/components/_internal/shell-sidebar.tsx +8 -30
- package/src/components/_internal/shell-store.tsx +1 -34
- package/src/components/checkbox-group.primitive.tsx +0 -12
- package/src/components/context-menu.tsx +1 -6
- package/src/components/schemas/index.ts +0 -1
- package/src/components/schemas/shell.schema.ts +3 -20
- package/src/components/shell.context.tsx +5 -112
- package/src/components/shell.css +1 -29
- package/src/components/shell.tsx +12 -97
- package/src/components/shell.types.ts +6 -28
- package/styles.css +0 -20
- package/dist/cjs/components/shell.hooks.d.ts +0 -10
- package/dist/cjs/components/shell.hooks.d.ts.map +0 -1
- package/dist/cjs/components/shell.hooks.js +0 -3
- package/dist/cjs/components/shell.hooks.js.map +0 -7
- package/dist/esm/chunk-2VSRZ4IT.js +0 -3
- package/dist/esm/chunk-2VSRZ4IT.js.map +0 -7
- package/dist/esm/chunk-2WFN4D52.js +0 -3
- package/dist/esm/chunk-2WFN4D52.js.map +0 -7
- package/dist/esm/chunk-4OJRLS5N.js +0 -3
- package/dist/esm/chunk-4OJRLS5N.js.map +0 -7
- package/dist/esm/chunk-4TTRPCGG.js +0 -3
- package/dist/esm/chunk-4TTRPCGG.js.map +0 -7
- package/dist/esm/chunk-5BXCPANF.js +0 -3
- package/dist/esm/chunk-B447PNRD.js +0 -3
- package/dist/esm/chunk-B447PNRD.js.map +0 -7
- package/dist/esm/chunk-BJVXB3PN.js +0 -3
- package/dist/esm/chunk-BJVXB3PN.js.map +0 -7
- package/dist/esm/chunk-DNY4WWZF.js +0 -3
- package/dist/esm/chunk-DNY4WWZF.js.map +0 -7
- package/dist/esm/chunk-HQT32HQ6.js +0 -3
- package/dist/esm/chunk-HQT32HQ6.js.map +0 -7
- package/dist/esm/chunk-KGCGT4MJ.js +0 -3
- package/dist/esm/chunk-KGCGT4MJ.js.map +0 -7
- package/dist/esm/chunk-M26LLCQC.js +0 -3
- package/dist/esm/chunk-M26LLCQC.js.map +0 -7
- package/dist/esm/chunk-MAA6LEE2.js.map +0 -7
- package/dist/esm/chunk-MXEOE4LA.js +0 -3
- package/dist/esm/chunk-TS4QCDSI.js +0 -3
- package/dist/esm/chunk-TS4QCDSI.js.map +0 -7
- package/dist/esm/chunk-XOAOSRTH.js +0 -3
- package/dist/esm/chunk-XOAOSRTH.js.map +0 -7
- package/dist/esm/chunk-XUCR7L4G.js +0 -3
- package/dist/esm/chunk-XUCR7L4G.js.map +0 -7
- package/dist/esm/components/shell.hooks.d.ts +0 -10
- package/dist/esm/components/shell.hooks.d.ts.map +0 -1
- package/dist/esm/components/shell.hooks.js +0 -3
- package/dist/esm/components/shell.hooks.js.map +0 -7
- package/src/components/shell.hooks.ts +0 -20
- /package/dist/esm/{chunk-5RLGDXOM.js.map → chunk-2K46JPUL.js.map} +0 -0
- /package/dist/esm/{chunk-IN6D33TU.js.map → chunk-5XO3PLDH.js.map} +0 -0
- /package/dist/esm/{chunk-COLJWVN7.js.map → chunk-AQR42GKA.js.map} +0 -0
- /package/dist/esm/{chunk-FTNZWAPB.js.map → chunk-ARPUPT4M.js.map} +0 -0
- /package/dist/esm/{chunk-ISCZ57VL.js.map → chunk-DJGZ4K3V.js.map} +0 -0
- /package/dist/esm/{chunk-PMXIQ5B4.js.map → chunk-FKCKELUB.js.map} +0 -0
- /package/dist/esm/{chunk-E6MOZSYV.js.map → chunk-HNOT2HS4.js.map} +0 -0
- /package/dist/esm/{chunk-EB4AG3OL.js.map → chunk-REELD6CT.js.map} +0 -0
- /package/dist/esm/{chunk-3M5ZM67R.js.map → chunk-TCFBNE6A.js.map} +0 -0
- /package/dist/esm/{chunk-G66WDIIV.js.map → chunk-WJKCXGVN.js.map} +0 -0
- /package/dist/esm/{chunk-SIYOLE6P.js.map → chunk-YM47BXKK.js.map} +0 -0
|
@@ -9,10 +9,8 @@ import {
|
|
|
9
9
|
notifyShellStore,
|
|
10
10
|
tableAttributes,
|
|
11
11
|
tableOf,
|
|
12
|
-
usePeeking,
|
|
13
12
|
useShellStore,
|
|
14
13
|
useStableKey,
|
|
15
|
-
warnOnce,
|
|
16
14
|
type OpenChangeReason,
|
|
17
15
|
type PaneEntry,
|
|
18
16
|
type PaneValue,
|
|
@@ -28,8 +26,8 @@ export type UsePaneOptions = {
|
|
|
28
26
|
/** The prop names a warning should use: `open`/`defaultOpen`, or `state`/`defaultState`. */
|
|
29
27
|
propNames: { controlled: string; default: string };
|
|
30
28
|
id: string | undefined;
|
|
31
|
-
/** The controlled value.
|
|
32
|
-
controlled:
|
|
29
|
+
/** The controlled value. */
|
|
30
|
+
controlled: PaneValue | undefined;
|
|
33
31
|
/**
|
|
34
32
|
* The uncontrolled default. A single value fixes where the pane starts. A
|
|
35
33
|
* responsive object leaves the pane untouched (`auto`), with that object as
|
|
@@ -44,8 +42,6 @@ export type UsePaneOptions = {
|
|
|
44
42
|
onChange: ((value: PaneValue, reason: OpenChangeReason) => void) | undefined;
|
|
45
43
|
/** The value a toggle moves to. Defaults to open and closed in turn. */
|
|
46
44
|
toggleNext?: (current: PaneValue, defaultHere: PaneValue | undefined) => PaneValue;
|
|
47
|
-
onExpand: (() => void) | undefined;
|
|
48
|
-
onCollapse: (() => void) | undefined;
|
|
49
45
|
/** The pane's designed open width, published for the panes beside it. */
|
|
50
46
|
size: number;
|
|
51
47
|
};
|
|
@@ -54,15 +50,6 @@ export type PaneController = ReturnType<typeof usePane>;
|
|
|
54
50
|
|
|
55
51
|
const isMap = (value: ResponsiveValue | undefined): value is Partial<Record<Breakpoint, PaneValue>> => typeof value === 'object' && value !== null;
|
|
56
52
|
|
|
57
|
-
/** The first value a responsive object states, smallest breakpoint first. */
|
|
58
|
-
function firstStated(map: Partial<Record<Breakpoint, PaneValue>>): PaneValue {
|
|
59
|
-
for (const bp of ['initial', 'xs', 'sm', 'md', 'lg', 'xl'] as const) {
|
|
60
|
-
const value = map[bp];
|
|
61
|
-
if (value !== undefined) return value;
|
|
62
|
-
}
|
|
63
|
-
return 'closed';
|
|
64
|
-
}
|
|
65
|
-
|
|
66
53
|
/** Everything the togglable panes share: their state, their registry entry and their callbacks. */
|
|
67
54
|
export function usePane(options: UsePaneOptions) {
|
|
68
55
|
const { name, label, propNames, presentationTable, builtIn } = options;
|
|
@@ -71,34 +58,21 @@ export function usePane(options: UsePaneOptions) {
|
|
|
71
58
|
const id = options.id ?? `shell-${name}${generatedId}`;
|
|
72
59
|
|
|
73
60
|
const controlled = options.controlled !== undefined;
|
|
74
|
-
const
|
|
75
|
-
if (controlledIsMap) {
|
|
76
|
-
warnOnce(
|
|
77
|
-
`Shell.${label}: a responsive \`${propNames.controlled}\` is deprecated and is removed in 1.0. ` +
|
|
78
|
-
`Pass a boolean and decide it from your own state, or use \`${propNames.default}\` with a responsive object.`,
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// A responsive controlled value is resolved the way a responsive default
|
|
83
|
-
// is: it becomes the table an untouched pane follows, so the stylesheet
|
|
84
|
-
// answers it at each breakpoint (right in the server HTML, with no
|
|
85
|
-
// callback on a crossing) and the app's prop is still the only writer.
|
|
86
|
-
const controlledMap = controlledIsMap ? (options.controlled as Partial<Record<Breakpoint, PaneValue>>) : undefined;
|
|
87
|
-
const autoSource = controlledMap ?? (isMap(options.defaultValue) ? options.defaultValue : undefined);
|
|
61
|
+
const autoSource = isMap(options.defaultValue) ? options.defaultValue : undefined;
|
|
88
62
|
const autoKey = useStableKey(autoSource);
|
|
89
63
|
const [inner, setInner] = React.useState<'auto' | PaneValue>(() => (typeof options.defaultValue === 'string' ? options.defaultValue : 'auto'));
|
|
90
64
|
|
|
91
65
|
// What an untouched pane shows at each breakpoint: a responsive default
|
|
92
66
|
// where it states one, the pane's own default where it does not.
|
|
93
67
|
const autoTable = React.useMemo(
|
|
94
|
-
() =>
|
|
68
|
+
() => tableOf<PaneValue>(autoSource, (bp) => builtIn(presentationTable[bp])),
|
|
95
69
|
// `autoKey` stands for the responsive object, which is usually a new literal each render.
|
|
96
70
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
97
|
-
[autoKey,
|
|
71
|
+
[autoKey, presentationTable, builtIn],
|
|
98
72
|
);
|
|
99
73
|
|
|
100
74
|
let state: 'auto' | PaneValue = inner;
|
|
101
|
-
if (controlled) state =
|
|
75
|
+
if (options.controlled !== undefined) state = options.controlled;
|
|
102
76
|
|
|
103
77
|
// Only a pane whose answer depends on the window subscribes to it, so a
|
|
104
78
|
// pane with one presentation and one default never re-renders on a resize.
|
|
@@ -194,23 +168,6 @@ export function usePane(options: UsePaneOptions) {
|
|
|
194
168
|
};
|
|
195
169
|
}, [store, name, id, value, presentation, presentationTable, overlayLive, options.size, setValue, toggle]);
|
|
196
170
|
|
|
197
|
-
// onExpand/onCollapse fire when the pane's state changes and that changes
|
|
198
|
-
// whether it is shown: a user's toggle, or a controlled prop. Never on
|
|
199
|
-
// mount, and never because the window crossed a breakpoint.
|
|
200
|
-
const callbacks = React.useRef({ onExpand: options.onExpand, onCollapse: options.onCollapse });
|
|
201
|
-
useLayoutEffect(() => {
|
|
202
|
-
callbacks.current = { onExpand: options.onExpand, onCollapse: options.onCollapse };
|
|
203
|
-
});
|
|
204
|
-
const previous = React.useRef({ state, shown });
|
|
205
|
-
React.useEffect(() => {
|
|
206
|
-
const before = previous.current;
|
|
207
|
-
if (before.state !== state && before.shown !== undefined && shown !== undefined && before.shown !== shown) {
|
|
208
|
-
if (shown) callbacks.current.onExpand?.();
|
|
209
|
-
else callbacks.current.onCollapse?.();
|
|
210
|
-
}
|
|
211
|
-
previous.current = { state, shown };
|
|
212
|
-
}, [state, shown]);
|
|
213
|
-
|
|
214
171
|
// Development guards. Once per mount, not once per render.
|
|
215
172
|
useLayoutEffect(() => {
|
|
216
173
|
if (process.env.NODE_ENV === 'production') return;
|
|
@@ -229,8 +186,6 @@ export function usePane(options: UsePaneOptions) {
|
|
|
229
186
|
}
|
|
230
187
|
}, [controlled, label, propNames.controlled]);
|
|
231
188
|
|
|
232
|
-
const peeking = usePeeking(store, name) && shown === false && !overlaying;
|
|
233
|
-
|
|
234
189
|
return {
|
|
235
190
|
store,
|
|
236
191
|
id,
|
|
@@ -240,7 +195,6 @@ export function usePane(options: UsePaneOptions) {
|
|
|
240
195
|
presentation,
|
|
241
196
|
overlaying,
|
|
242
197
|
overlayLive,
|
|
243
|
-
peeking,
|
|
244
198
|
ready,
|
|
245
199
|
breakpoint,
|
|
246
200
|
autoTable,
|
|
@@ -253,16 +207,13 @@ export function usePane(options: UsePaneOptions) {
|
|
|
253
207
|
|
|
254
208
|
/** The data attributes every togglable pane renders. */
|
|
255
209
|
export function paneAttributes(pane: PaneController, presentationAttributes: Record<string, string>) {
|
|
256
|
-
const { state, value, presentation
|
|
210
|
+
const { state, value, presentation } = pane;
|
|
257
211
|
return {
|
|
258
212
|
...presentationAttributes,
|
|
259
213
|
'data-state': state,
|
|
260
214
|
...(state === 'auto' ? tableAttributes('auto', pane.autoTable) : {}),
|
|
261
215
|
'data-presentation': presentation,
|
|
262
216
|
'data-mode': value === undefined ? undefined : value === 'closed' ? 'collapsed' : 'expanded',
|
|
263
|
-
// Kept for stylesheets written against 0.7: set while a stacked pane is open.
|
|
264
|
-
'data-open': presentation === 'stacked' && shown ? '' : undefined,
|
|
265
|
-
'data-peek': pane.peeking ? '' : undefined,
|
|
266
217
|
} as const;
|
|
267
218
|
}
|
|
268
219
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { useLayoutEffect } from 'radix-ui/internal';
|
|
5
5
|
import { normalizeToPx } from '../../helpers/normalize-to-px.js';
|
|
6
|
-
import type { PaneName
|
|
6
|
+
import type { PaneName } from '../shell.types.js';
|
|
7
7
|
import type { PaneResizeContextValue } from './shell-resize.js';
|
|
8
8
|
|
|
9
9
|
export type SizeChangeMeta = { reason: 'init' | 'resize' | 'controlled' };
|
|
@@ -30,16 +30,10 @@ export type ResizableOptions = {
|
|
|
30
30
|
onResize: ((size: number) => void) | undefined;
|
|
31
31
|
onResizeStart: ((size: number) => void) | undefined;
|
|
32
32
|
onResizeEnd: ((size: number) => void) | undefined;
|
|
33
|
-
|
|
34
|
-
snapTolerance: number | undefined;
|
|
35
|
-
collapseThreshold: number | undefined;
|
|
36
|
-
paneId: string | undefined;
|
|
37
|
-
persistence: PaneSizePersistence | undefined;
|
|
38
|
-
/** Whether the pane is presented as an overlay right now. An overlay keeps its designed size and persists nothing. */
|
|
33
|
+
/** Whether the pane is presented as an overlay right now. An overlay keeps its designed size. */
|
|
39
34
|
overlaying: boolean;
|
|
40
35
|
/** The same question asked at effect time, for a pane whose presentation is learnt after its first render. */
|
|
41
36
|
overlayingNow: () => boolean;
|
|
42
|
-
requestCollapse: () => void;
|
|
43
37
|
requestToggle: () => void;
|
|
44
38
|
};
|
|
45
39
|
|
|
@@ -63,9 +57,9 @@ export function useInitialPaneSize(size: number | string | undefined, defaultSiz
|
|
|
63
57
|
return initial;
|
|
64
58
|
}
|
|
65
59
|
|
|
66
|
-
/** Everything a resizable pane shares: size props
|
|
60
|
+
/** Everything a resizable pane shares: size props and the handle's context. */
|
|
67
61
|
export function useResizablePane(options: ResizableOptions): PaneResizeContextValue {
|
|
68
|
-
const { name, elementRef, cssVarName, orientation, minSize, maxSize,
|
|
62
|
+
const { name, elementRef, cssVarName, orientation, minSize, maxSize, size, defaultSize } = options;
|
|
69
63
|
|
|
70
64
|
// The latest callbacks, so the size emitter does not change identity when a
|
|
71
65
|
// consumer passes an inline function. A controlled `size` is reported again
|
|
@@ -107,7 +101,7 @@ export function useResizablePane(options: ResizableOptions): PaneResizeContextVa
|
|
|
107
101
|
/**
|
|
108
102
|
* The one way a size reaches the pane: the size variable, and the value
|
|
109
103
|
* every handle of this pane announces. Once anything but `expandedSize` has
|
|
110
|
-
* written a size (a default, a controlled value
|
|
104
|
+
* written a size (a default, a controlled value or a
|
|
111
105
|
* resize), the pane owns that size and a new `expandedSize` leaves it alone.
|
|
112
106
|
*/
|
|
113
107
|
const ownedRef = React.useRef(false);
|
|
@@ -154,65 +148,6 @@ export function useResizablePane(options: ResizableOptions): PaneResizeContextVa
|
|
|
154
148
|
emitSizeChange(clamped, { reason: 'controlled' });
|
|
155
149
|
}, [size, minSize, maxSize, options.overlaying, toPx, writeSize, emitSizeChange]);
|
|
156
150
|
|
|
157
|
-
// A persistence adapter from `paneId` when none is given. A given one is read through
|
|
158
|
-
// `latest`, so an inline object (the documented shape) does not reload the size every render.
|
|
159
|
-
const hasPersistence = persistence !== undefined;
|
|
160
|
-
const adapter = React.useMemo<PaneSizePersistence | undefined>(() => {
|
|
161
|
-
if (hasPersistence) {
|
|
162
|
-
return {
|
|
163
|
-
load: () => latest.current.persistence?.load?.(),
|
|
164
|
-
save: (value: number) => latest.current.persistence?.save?.(value),
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
if (!paneId) return undefined;
|
|
168
|
-
const key = `kookie-ui:shell:${name}:${paneId}`;
|
|
169
|
-
return {
|
|
170
|
-
load: () => {
|
|
171
|
-
if (typeof window === 'undefined') return undefined;
|
|
172
|
-
try {
|
|
173
|
-
const stored = window.localStorage.getItem(key);
|
|
174
|
-
return stored ? Number(stored) : undefined;
|
|
175
|
-
} catch (err) {
|
|
176
|
-
if (process.env.NODE_ENV !== 'production') console.warn(`Shell.${name}: failed to load persisted size`, err);
|
|
177
|
-
return undefined;
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
save: (value: number) => {
|
|
181
|
-
if (typeof window === 'undefined') return;
|
|
182
|
-
try {
|
|
183
|
-
window.localStorage.setItem(key, String(value));
|
|
184
|
-
} catch (err) {
|
|
185
|
-
if (process.env.NODE_ENV !== 'production') console.warn(`Shell.${name}: failed to save persisted size`, err);
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
};
|
|
189
|
-
}, [name, paneId, hasPersistence]);
|
|
190
|
-
|
|
191
|
-
// Persisted size, loaded in a layout effect and clamped, so a reload does
|
|
192
|
-
// not paint the default and then jump. Only where the pane is in the frame:
|
|
193
|
-
// an overlay keeps its designed size.
|
|
194
|
-
useLayoutEffect(() => {
|
|
195
|
-
if (!resizable || !adapter?.load || latest.current.overlayingNow()) return undefined;
|
|
196
|
-
let mounted = true;
|
|
197
|
-
const apply = (value: number | undefined) => {
|
|
198
|
-
if (!mounted || typeof value !== 'number' || !Number.isFinite(value)) return;
|
|
199
|
-
const clamped = clampTo(value, minSize, maxSize);
|
|
200
|
-
writeSize(clamped, true);
|
|
201
|
-
latest.current.onResize?.(clamped);
|
|
202
|
-
};
|
|
203
|
-
const loaded = adapter.load();
|
|
204
|
-
if (loaded instanceof Promise) {
|
|
205
|
-
loaded.then(apply).catch((err) => {
|
|
206
|
-
if (process.env.NODE_ENV !== 'production') console.warn(`Shell.${name}: failed to load persisted size`, err);
|
|
207
|
-
});
|
|
208
|
-
} else {
|
|
209
|
-
apply(loaded);
|
|
210
|
-
}
|
|
211
|
-
return () => {
|
|
212
|
-
mounted = false;
|
|
213
|
-
};
|
|
214
|
-
}, [resizable, adapter, options.overlaying, writeSize, minSize, maxSize, name]);
|
|
215
|
-
|
|
216
151
|
// What the handle announces before any effect has run: the same starting size the pane's
|
|
217
152
|
// first render uses, so the server HTML already states a value.
|
|
218
153
|
const [startSize] = React.useState(() => {
|
|
@@ -230,11 +165,9 @@ export function useResizablePane(options: ResizableOptions): PaneResizeContextVa
|
|
|
230
165
|
(value: number) => {
|
|
231
166
|
latest.current.onResizeEnd?.(value);
|
|
232
167
|
emitSizeChange(value, { reason: 'resize' });
|
|
233
|
-
adapter?.save?.(value);
|
|
234
168
|
},
|
|
235
|
-
[emitSizeChange
|
|
169
|
+
[emitSizeChange],
|
|
236
170
|
);
|
|
237
|
-
const requestCollapse = React.useCallback(() => latest.current.requestCollapse(), []);
|
|
238
171
|
const requestToggle = React.useCallback(() => latest.current.requestToggle(), []);
|
|
239
172
|
|
|
240
173
|
return React.useMemo(
|
|
@@ -254,10 +187,6 @@ export function useResizablePane(options: ResizableOptions): PaneResizeContextVa
|
|
|
254
187
|
onResizeEnd,
|
|
255
188
|
target: name,
|
|
256
189
|
collapsible: options.collapsible,
|
|
257
|
-
snapPoints: options.snapPoints,
|
|
258
|
-
snapTolerance: options.snapTolerance ?? 8,
|
|
259
|
-
collapseThreshold: options.collapseThreshold,
|
|
260
|
-
requestCollapse,
|
|
261
190
|
requestToggle,
|
|
262
191
|
}),
|
|
263
192
|
[
|
|
@@ -276,10 +205,6 @@ export function useResizablePane(options: ResizableOptions): PaneResizeContextVa
|
|
|
276
205
|
onResizeEnd,
|
|
277
206
|
name,
|
|
278
207
|
options.collapsible,
|
|
279
|
-
options.snapPoints,
|
|
280
|
-
options.snapTolerance,
|
|
281
|
-
options.collapseThreshold,
|
|
282
|
-
requestCollapse,
|
|
283
208
|
requestToggle,
|
|
284
209
|
],
|
|
285
210
|
);
|
|
@@ -24,10 +24,6 @@ export interface PaneResizeContextValue {
|
|
|
24
24
|
onResizeEnd?: (size: number) => void;
|
|
25
25
|
target: PaneName;
|
|
26
26
|
collapsible: boolean;
|
|
27
|
-
snapPoints?: number[];
|
|
28
|
-
snapTolerance: number;
|
|
29
|
-
collapseThreshold?: number;
|
|
30
|
-
requestCollapse?: () => void;
|
|
31
27
|
requestToggle?: () => void;
|
|
32
28
|
}
|
|
33
29
|
|
|
@@ -4,6 +4,8 @@ import type { PaneValue } from './shell-store.js';
|
|
|
4
4
|
type ResponsiveBoolean = boolean | Partial<Record<Breakpoint, boolean>>;
|
|
5
5
|
|
|
6
6
|
/** `open`/`defaultOpen` as the pane's own value type. */
|
|
7
|
+
export function toPaneValue(value: boolean | undefined): PaneValue | undefined;
|
|
8
|
+
export function toPaneValue(value: ResponsiveBoolean | undefined): PaneValue | Partial<Record<Breakpoint, PaneValue>> | undefined;
|
|
7
9
|
export function toPaneValue(value: ResponsiveBoolean | undefined): PaneValue | Partial<Record<Breakpoint, PaneValue>> | undefined {
|
|
8
10
|
if (value === undefined) return undefined;
|
|
9
11
|
if (typeof value === 'boolean') return value ? 'open' : 'closed';
|
|
@@ -32,14 +34,3 @@ export const endAnchoredGrowth = (isRtl: boolean): 1 | -1 => (isRtl ? 1 : -1);
|
|
|
32
34
|
|
|
33
35
|
/** A pane anchored at the block end grows as its top edge moves up. */
|
|
34
36
|
export const bottomAnchoredGrowth = (): 1 | -1 => -1;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* `height` and `resizer` left PaneBaseProps in 0.8.0: no pane ever read them.
|
|
38
|
-
* A call site written against 0.7 can still pass them, so they are dropped
|
|
39
|
-
* here rather than reaching the DOM as invalid attributes.
|
|
40
|
-
*/
|
|
41
|
-
export function withoutRemovedPaneProps<T extends object>(props: T): T {
|
|
42
|
-
if (!('height' in props) && !('resizer' in props)) return props;
|
|
43
|
-
const { height: _height, resizer: _resizer, ...rest } = props as T & { height?: unknown; resizer?: unknown };
|
|
44
|
-
return rest as T;
|
|
45
|
-
}
|
|
@@ -7,15 +7,15 @@ import { PaneResizeContext } from './shell-resize.js';
|
|
|
7
7
|
import { PaneHandle, SidebarHandle } from './shell-handles.js';
|
|
8
8
|
import { usePane, paneAttributes, usePresentationTable } from './shell-pane.js';
|
|
9
9
|
import { splitHandles, useInitialPaneSize, useResizablePane, type SizeChangeMeta } from './shell-resizable.js';
|
|
10
|
-
import { useFrameRegistration,
|
|
11
|
-
import { navigationRest, startAnchoredGrowth
|
|
10
|
+
import { useFrameRegistration, type PaneValue } from './shell-store.js';
|
|
11
|
+
import { navigationRest, startAnchoredGrowth } from './shell-rest.js';
|
|
12
12
|
import { readBreakpoint } from '../../hooks/use-breakpoint.js';
|
|
13
13
|
import { PaneChromeScope } from './pane-chrome.js';
|
|
14
14
|
import { PageScope } from './page-scope.js';
|
|
15
|
-
import type { Breakpoint, CSSPropertiesWithVars, PaneBaseProps, Responsive, SidebarMode } from '../shell.types.js';
|
|
15
|
+
import type { Breakpoint, CSSPropertiesWithVars, PaneBaseProps, PaneOpenChangeReason, Responsive, SidebarMode } from '../shell.types.js';
|
|
16
16
|
|
|
17
|
-
type SidebarStateChangeMeta = { reason:
|
|
18
|
-
type SidebarControlledProps = { state:
|
|
17
|
+
type SidebarStateChangeMeta = { reason: PaneOpenChangeReason };
|
|
18
|
+
type SidebarControlledProps = { state: SidebarMode; onStateChange?: (state: SidebarMode, meta: SidebarStateChangeMeta) => void; defaultState?: never };
|
|
19
19
|
type SidebarUncontrolledProps = { defaultState?: SidebarMode | Partial<Record<Breakpoint, SidebarMode>>; onStateChange?: (state: SidebarMode, meta: SidebarStateChangeMeta) => void; state?: never };
|
|
20
20
|
type SidebarPublicProps = PaneBaseProps & {
|
|
21
21
|
size?: number | string;
|
|
@@ -37,6 +37,8 @@ type SidebarComponent = React.ForwardRefExoticComponent<SidebarPublicProps & Rea
|
|
|
37
37
|
const toValue = (mode: SidebarMode): PaneValue => (mode === 'collapsed' ? 'closed' : 'open');
|
|
38
38
|
const toMode = (value: PaneValue): SidebarMode => (value === 'closed' ? 'collapsed' : 'expanded');
|
|
39
39
|
|
|
40
|
+
function modeToValue(state: SidebarMode | undefined): PaneValue | undefined;
|
|
41
|
+
function modeToValue(state: Responsive<SidebarMode> | undefined): PaneValue | Partial<Record<Breakpoint, PaneValue>> | undefined;
|
|
40
42
|
function modeToValue(state: Responsive<SidebarMode> | undefined): PaneValue | Partial<Record<Breakpoint, PaneValue>> | undefined {
|
|
41
43
|
if (state === undefined) return undefined;
|
|
42
44
|
if (typeof state === 'string') return toValue(state);
|
|
@@ -62,16 +64,9 @@ export const Sidebar = React.forwardRef<HTMLDivElement, SidebarPublicProps>((pro
|
|
|
62
64
|
maxSize = 400,
|
|
63
65
|
resizable = false,
|
|
64
66
|
collapsible = true,
|
|
65
|
-
onExpand,
|
|
66
|
-
onCollapse,
|
|
67
67
|
onResize,
|
|
68
68
|
onResizeStart,
|
|
69
69
|
onResizeEnd,
|
|
70
|
-
snapPoints,
|
|
71
|
-
snapTolerance,
|
|
72
|
-
collapseThreshold,
|
|
73
|
-
paneId,
|
|
74
|
-
persistence,
|
|
75
70
|
children,
|
|
76
71
|
style,
|
|
77
72
|
state,
|
|
@@ -98,17 +93,10 @@ export const Sidebar = React.forwardRef<HTMLDivElement, SidebarPublicProps>((pro
|
|
|
98
93
|
presentationTable: table,
|
|
99
94
|
builtIn: navigationRest,
|
|
100
95
|
onChange: (value, reason) => onStateChange?.(toMode(value), { reason }),
|
|
101
|
-
onExpand,
|
|
102
|
-
onCollapse,
|
|
103
96
|
size: expandedSize,
|
|
104
97
|
});
|
|
105
98
|
useFrameRegistration('sidebar', flush);
|
|
106
99
|
|
|
107
|
-
React.useEffect(() => {
|
|
108
|
-
if (snapPoints !== undefined || collapseThreshold !== undefined || paneId !== undefined || persistence !== undefined) {
|
|
109
|
-
warnOnce('Shell.Sidebar: `snapPoints`, `collapseThreshold`, `paneId` and `persistence` are deprecated and are removed in 1.0. Keep the size in your own state with `size`/`onSizeChange`.');
|
|
110
|
-
}
|
|
111
|
-
}, [snapPoints, collapseThreshold, paneId, persistence]);
|
|
112
100
|
|
|
113
101
|
const elementRef = React.useRef<HTMLElement | null>(null);
|
|
114
102
|
const composedRef = useComposedRefs(ref, pane.setElement, elementRef);
|
|
@@ -134,14 +122,8 @@ export const Sidebar = React.forwardRef<HTMLDivElement, SidebarPublicProps>((pro
|
|
|
134
122
|
onResize,
|
|
135
123
|
onResizeStart,
|
|
136
124
|
onResizeEnd,
|
|
137
|
-
snapPoints,
|
|
138
|
-
snapTolerance,
|
|
139
|
-
collapseThreshold,
|
|
140
|
-
paneId,
|
|
141
|
-
persistence,
|
|
142
125
|
overlaying: pane.overlaying,
|
|
143
126
|
overlayingNow: () => table[readBreakpoint()] === 'overlay',
|
|
144
|
-
requestCollapse: () => pane.setValue('closed', 'toggle'),
|
|
145
127
|
requestToggle: () => pane.toggle('toggle'),
|
|
146
128
|
});
|
|
147
129
|
|
|
@@ -151,13 +133,10 @@ export const Sidebar = React.forwardRef<HTMLDivElement, SidebarPublicProps>((pro
|
|
|
151
133
|
<PaneResizeContext.Provider value={resize}>{handles.length > 0 ? handles : <PaneHandle />}</PaneResizeContext.Provider>
|
|
152
134
|
) : null;
|
|
153
135
|
|
|
154
|
-
// A peek previews the width the next toggle opens to.
|
|
155
|
-
const peekWidth = pane.peeking ? `var(--sidebar-size, ${expandedSize}px)` : undefined;
|
|
156
|
-
|
|
157
136
|
const initialSize = useInitialPaneSize(size, defaultSize, minSize, maxSize);
|
|
158
137
|
return (
|
|
159
138
|
<div
|
|
160
|
-
{...
|
|
139
|
+
{...domProps}
|
|
161
140
|
role={domProps.role ?? 'navigation'}
|
|
162
141
|
id={pane.id}
|
|
163
142
|
ref={composedRef}
|
|
@@ -172,7 +151,6 @@ export const Sidebar = React.forwardRef<HTMLDivElement, SidebarPublicProps>((pro
|
|
|
172
151
|
...(initialSize ? { '--sidebar-size': initialSize } : {}),
|
|
173
152
|
'--sidebar-min-size': `${minSize}px`,
|
|
174
153
|
'--sidebar-max-size': `${maxSize}px`,
|
|
175
|
-
...(peekWidth ? { '--peek-sidebar-width': peekWidth } : {}),
|
|
176
154
|
} as CSSPropertiesWithVars
|
|
177
155
|
}
|
|
178
156
|
>
|
|
@@ -117,12 +117,10 @@ export type ShellStore = {
|
|
|
117
117
|
* it, would be a new identity on every read.
|
|
118
118
|
*/
|
|
119
119
|
version: number;
|
|
120
|
-
/** The pane a hovered Trigger is previewing, if any. Layout only. */
|
|
121
|
-
peek: PaneName | null;
|
|
122
120
|
};
|
|
123
121
|
|
|
124
122
|
export function createShellStore(): ShellStore {
|
|
125
|
-
return { entries: new Map(), listeners: new Set(), version: 0
|
|
123
|
+
return { entries: new Map(), listeners: new Set(), version: 0 };
|
|
126
124
|
}
|
|
127
125
|
|
|
128
126
|
export function notifyShellStore(store: ShellStore) {
|
|
@@ -137,12 +135,6 @@ export function subscribeShellStore(store: ShellStore, listener: () => void) {
|
|
|
137
135
|
};
|
|
138
136
|
}
|
|
139
137
|
|
|
140
|
-
export function setShellPeek(store: ShellStore, peek: PaneName | null) {
|
|
141
|
-
if (store.peek === peek) return;
|
|
142
|
-
store.peek = peek;
|
|
143
|
-
notifyShellStore(store);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
138
|
export const ShellStoreContext = React.createContext<ShellStore | null>(null);
|
|
147
139
|
|
|
148
140
|
export function useShellStore(part: string): ShellStore {
|
|
@@ -158,19 +150,6 @@ export function usePaneEntry(store: ShellStore, name: PaneName): PaneEntry | und
|
|
|
158
150
|
return React.useSyncExternalStore(subscribe, getSnapshot, () => undefined);
|
|
159
151
|
}
|
|
160
152
|
|
|
161
|
-
/**
|
|
162
|
-
* Whether this pane is the one being previewed. A boolean per pane rather than
|
|
163
|
-
* the peek target itself, so hovering one Trigger re-renders one pane, not all.
|
|
164
|
-
*/
|
|
165
|
-
export function usePeeking(store: ShellStore, name: PaneName): boolean {
|
|
166
|
-
const subscribe = React.useCallback((listener: () => void) => subscribeShellStore(store, listener), [store]);
|
|
167
|
-
return React.useSyncExternalStore(
|
|
168
|
-
subscribe,
|
|
169
|
-
() => store.peek === name,
|
|
170
|
-
() => false,
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
153
|
/* ── Off the frame ─────────────────────────────────────────────────────────── */
|
|
175
154
|
|
|
176
155
|
export type FramePaneId = 'rail' | 'panel' | 'sidebar' | 'content' | 'inspector' | 'bottom';
|
|
@@ -191,15 +170,3 @@ export function useFrameRegistration(id: FramePaneId, flush: boolean) {
|
|
|
191
170
|
return () => unregisterOffFrame(id);
|
|
192
171
|
}, [id, flush, registerOffFrame, unregisterOffFrame]);
|
|
193
172
|
}
|
|
194
|
-
|
|
195
|
-
/* ── Development warnings ──────────────────────────────────────────────────── */
|
|
196
|
-
|
|
197
|
-
const warned = new Set<string>();
|
|
198
|
-
|
|
199
|
-
/** A deprecation warning, once per message per page load. Development only. */
|
|
200
|
-
export function warnOnce(message: string) {
|
|
201
|
-
if (process.env.NODE_ENV === 'production') return;
|
|
202
|
-
if (warned.has(message)) return;
|
|
203
|
-
warned.add(message);
|
|
204
|
-
console.warn(`[kookie-ui] ${message}`);
|
|
205
|
-
}
|
|
@@ -37,16 +37,6 @@ interface CheckboxGroupProps extends PrimitiveDivProps {
|
|
|
37
37
|
required?: React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>['required'];
|
|
38
38
|
disabled?: React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>['disabled'];
|
|
39
39
|
dir?: 'ltr' | 'rtl';
|
|
40
|
-
/**
|
|
41
|
-
* @deprecated Has no effect. Each checkbox is its own tab stop, as with native checkboxes,
|
|
42
|
-
* so there is no arrow-key navigation to orient.
|
|
43
|
-
*/
|
|
44
|
-
orientation?: 'horizontal' | 'vertical';
|
|
45
|
-
/**
|
|
46
|
-
* @deprecated Has no effect. Each checkbox is its own tab stop, as with native checkboxes,
|
|
47
|
-
* so there is no arrow-key navigation to loop.
|
|
48
|
-
*/
|
|
49
|
-
loop?: boolean;
|
|
50
40
|
defaultValue?: string[];
|
|
51
41
|
value?: CheckboxGroupContextValue['value'];
|
|
52
42
|
onValueChange?: (value: string[]) => void;
|
|
@@ -61,9 +51,7 @@ const CheckboxGroup = React.forwardRef<CheckboxGroupElement, CheckboxGroupProps>
|
|
|
61
51
|
value: valueProp,
|
|
62
52
|
required = false,
|
|
63
53
|
disabled = false,
|
|
64
|
-
orientation: _orientation,
|
|
65
54
|
dir,
|
|
66
|
-
loop: _loop,
|
|
67
55
|
onValueChange,
|
|
68
56
|
...groupProps
|
|
69
57
|
} = props;
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
} from './_internal/base-menu.utils.js';
|
|
39
39
|
|
|
40
40
|
import type { ComponentPropsWithout, RemovedProps } from '../helpers/component-props.js';
|
|
41
|
-
import type { GetPropDefTypes
|
|
41
|
+
import type { GetPropDefTypes } from '../props/prop-def.js';
|
|
42
42
|
|
|
43
43
|
interface ContextMenuRootProps
|
|
44
44
|
extends React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Root> {}
|
|
@@ -95,10 +95,6 @@ interface ContextMenuContentProps
|
|
|
95
95
|
* Use this when rendering virtualized lists inside the context menu.
|
|
96
96
|
*/
|
|
97
97
|
virtualized?: boolean;
|
|
98
|
-
/**
|
|
99
|
-
* @deprecated Has no effect. ContextMenu submenus always cascade.
|
|
100
|
-
*/
|
|
101
|
-
submenuBehavior?: Responsive<'cascade' | 'drill-down'>;
|
|
102
98
|
}
|
|
103
99
|
const ContextMenuContent = React.forwardRef<ContextMenuContentElement, ContextMenuContentProps>(
|
|
104
100
|
(ownProps, forwardedRef) => {
|
|
@@ -113,7 +109,6 @@ const ContextMenuContent = React.forwardRef<ContextMenuContentElement, ContextMe
|
|
|
113
109
|
color,
|
|
114
110
|
container,
|
|
115
111
|
forceMount,
|
|
116
|
-
submenuBehavior: _submenuBehavior,
|
|
117
112
|
virtualized = false,
|
|
118
113
|
...contentProps
|
|
119
114
|
} = extractProps(props, contextMenuContentPropDefs);
|
|
@@ -24,7 +24,7 @@ const PaneModeSchema = z.enum(['expanded', 'collapsed']).describe('Pane state mo
|
|
|
24
24
|
const SidebarModeSchema = z.enum(['collapsed', 'expanded']).describe('Sidebar state');
|
|
25
25
|
const PresentationValueSchema = z.enum(['fixed', 'overlay', 'stacked']).describe('Presentation mode');
|
|
26
26
|
const _BreakpointSchema = z.enum(['initial', 'xs', 'sm', 'md', 'lg', 'xl']).describe('Responsive breakpoint');
|
|
27
|
-
const PaneTargetSchema = z.enum(['
|
|
27
|
+
const PaneTargetSchema = z.enum(['rail', 'panel', 'sidebar', 'inspector', 'bottom']).describe('Pane target');
|
|
28
28
|
const TriggerActionSchema = z.enum(['toggle', 'expand', 'collapse']).describe('Trigger action');
|
|
29
29
|
const OpenChangeReasonSchema = z.enum(['toggle', 'dismiss']).describe('Why the state changed: `toggle` for a trigger or the resize handle, `dismiss` for Escape or the scrim');
|
|
30
30
|
const SizeChangeReasonSchema = z.enum(['init', 'resize', 'controlled']).describe('Why the size changed');
|
|
@@ -49,21 +49,13 @@ const ResponsiveSidebarModeSchema = responsive(SidebarModeSchema).describe('Resp
|
|
|
49
49
|
const ResponsivePresentationSchema = responsive(PresentationValueSchema).describe('Responsive presentation configuration');
|
|
50
50
|
const ResponsiveOpenSchema = responsive(z.boolean()).describe('Responsive open state');
|
|
51
51
|
|
|
52
|
-
// Size persistence adapter (deprecated)
|
|
53
|
-
const PaneSizePersistenceSchema = z
|
|
54
|
-
.object({
|
|
55
|
-
load: z.function({ output: z.union([z.number(), z.promise(z.number()), z.undefined()]) }).optional(),
|
|
56
|
-
save: z.function({ input: [z.number()], output: z.union([z.void(), z.promise(z.void())]) }).optional(),
|
|
57
|
-
})
|
|
58
|
-
.describe('Deprecated, removed in 1.0. Keep the size in your own state with `size`/`onSizeChange`.');
|
|
59
|
-
|
|
60
52
|
const StyleSchema = z
|
|
61
53
|
.record(z.string(), z.union([z.string(), z.number()]))
|
|
62
54
|
.optional()
|
|
63
55
|
.describe('Inline styles');
|
|
64
56
|
|
|
65
57
|
const OpenPropsSchema = {
|
|
66
|
-
open: z.
|
|
58
|
+
open: z.boolean().optional().describe('The open state, when controlled'),
|
|
67
59
|
defaultOpen: z
|
|
68
60
|
.union([z.boolean(), ResponsiveOpenSchema])
|
|
69
61
|
.optional()
|
|
@@ -80,8 +72,6 @@ const PaneBaseShape = {
|
|
|
80
72
|
presentation: ResponsivePresentationSchema.optional(),
|
|
81
73
|
expandedSize: z.number().optional(),
|
|
82
74
|
flush: z.boolean().optional().describe('Whether the pane joins the app frame. Defaults to true. `false` pulls it off the frame as a card.'),
|
|
83
|
-
onExpand: z.function({ output: z.void() }).optional().describe('Deprecated: use `onOpenChange`'),
|
|
84
|
-
onCollapse: z.function({ output: z.void() }).optional().describe('Deprecated: use `onOpenChange`'),
|
|
85
75
|
className: z.string().optional().describe('Additional CSS class name'),
|
|
86
76
|
style: StyleSchema,
|
|
87
77
|
children: z.any().optional(),
|
|
@@ -107,11 +97,6 @@ const ResizeShape = {
|
|
|
107
97
|
.describe('Called during a drag, at most once per animation frame'),
|
|
108
98
|
onResizeStart: z.function({ input: [z.number()], output: z.void() }).optional(),
|
|
109
99
|
onResizeEnd: z.function({ input: [z.number()], output: z.void() }).optional(),
|
|
110
|
-
snapPoints: z.array(z.number()).optional().describe('Deprecated, removed in 1.0'),
|
|
111
|
-
snapTolerance: z.number().optional().describe('Deprecated, removed in 1.0'),
|
|
112
|
-
collapseThreshold: z.number().optional().describe('Deprecated, removed in 1.0'),
|
|
113
|
-
paneId: z.string().optional().describe('Deprecated, removed in 1.0'),
|
|
114
|
-
persistence: PaneSizePersistenceSchema.optional(),
|
|
115
100
|
};
|
|
116
101
|
|
|
117
102
|
/**
|
|
@@ -183,7 +168,7 @@ export const ShellSidebarSchema = z
|
|
|
183
168
|
.object({
|
|
184
169
|
...PaneBaseShape,
|
|
185
170
|
...ResizeShape,
|
|
186
|
-
state:
|
|
171
|
+
state: SidebarModeSchema.optional().describe('The state, when controlled'),
|
|
187
172
|
defaultState: ResponsiveSidebarModeSchema.optional().describe('The starting state. With no value the sidebar is open where it is in the frame and closed where it is an overlay.'),
|
|
188
173
|
onStateChange: z
|
|
189
174
|
.function({ input: [SidebarModeSchema, z.object({ reason: OpenChangeReasonSchema })], output: z.void() })
|
|
@@ -251,7 +236,6 @@ export const ShellTriggerSchema = z
|
|
|
251
236
|
.object({
|
|
252
237
|
target: PaneTargetSchema.describe('Which pane to drive'),
|
|
253
238
|
action: TriggerActionSchema.default('toggle').describe('Action to perform'),
|
|
254
|
-
peekOnHover: z.boolean().default(false).describe('Deprecated, removed in 1.0. Shows a preview of a closed pane on hover.'),
|
|
255
239
|
type: z.enum(['button', 'submit', 'reset']).default('button').describe('The button type'),
|
|
256
240
|
className: z.string().optional().describe('Additional CSS class name'),
|
|
257
241
|
style: StyleSchema,
|
|
@@ -298,7 +282,6 @@ export type TriggerAction = z.infer<typeof TriggerActionSchema>;
|
|
|
298
282
|
export type ResponsiveMode = z.infer<typeof _ResponsiveModeSchema>;
|
|
299
283
|
export type ResponsiveSidebarMode = z.infer<typeof ResponsiveSidebarModeSchema>;
|
|
300
284
|
export type ResponsivePresentation = z.infer<typeof ResponsivePresentationSchema>;
|
|
301
|
-
export type PaneSizePersistence = z.infer<typeof PaneSizePersistenceSchema>;
|
|
302
285
|
|
|
303
286
|
/**
|
|
304
287
|
* Development-only helper to validate and normalize Shell props
|