@dashfoo/react 0.7.0 → 0.8.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 +2 -2
- package/dist/index.d.ts +23 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +366 -321
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -66,7 +66,7 @@ a sized parent and add your CSS (see the [attribute reference](#data-dashfoo-att
|
|
|
66
66
|
| `onModelChange` | `(model: Dashfoo, action?: Action) => void` | (none) | Called after every change with the next model and the action that caused it. |
|
|
67
67
|
| `components` | `Record<string, ComponentType<{ node: TabNode }>>` | (none) | Registry mapping `tab.component` keys to components. |
|
|
68
68
|
| `factory` | `(tab: TabNode) => ReactNode` | (none) | Render override. When provided, it resolves every tab and `components` is ignored. |
|
|
69
|
-
| `persist` | `string \| { key; storage?; debounceMs? }` | (none) | Auto-save the model
|
|
69
|
+
| `persist` | `string \| { key; storage?; debounceMs? }` | (none) | Auto-save the model. The props type only accepts it alongside `defaultModel`. A bare string is a localStorage key. |
|
|
70
70
|
| `onAction` | `(action: Action) => Action \| null` | (none) | Intercept each action before it commits: return it, a replacement, or `null` to veto. |
|
|
71
71
|
| `onActiveTabsetChange` | `(id: string \| undefined) => void` | (none) | Fires when the active tabset changes. |
|
|
72
72
|
| `onMaximizedTabsetChange` | `(id: string \| undefined) => void` | (none) | Fires when a tabset is maximized or restored. |
|
|
@@ -356,7 +356,7 @@ const Layout = () => {
|
|
|
356
356
|
a custom store (sessionStorage, in-memory, your own). A pending save flushes on
|
|
357
357
|
unmount and on page hide (reload, tab close, navigation, the page going to the
|
|
358
358
|
background), so the last change is never lost, even inside the debounce window.
|
|
359
|
-
|
|
359
|
+
The props type only accepts `persist` alongside `defaultModel`; in controlled mode, save the model yourself
|
|
360
360
|
in `onModelChange`.
|
|
361
361
|
|
|
362
362
|
The lower-level `usePersistence` load/save primitive (that `persist` is built on)
|
package/dist/index.d.ts
CHANGED
|
@@ -52,10 +52,9 @@ type DashfooHandle = {
|
|
|
52
52
|
selectTab: (tabsetId: string, index: number) => void;
|
|
53
53
|
undo: () => void;
|
|
54
54
|
};
|
|
55
|
-
type
|
|
55
|
+
type DashfooLayoutCommonProps = {
|
|
56
56
|
closableTabs?: boolean;
|
|
57
57
|
components?: Record<string, TabComponent>;
|
|
58
|
-
defaultModel?: Dashfoo;
|
|
59
58
|
draggableTabs?: boolean;
|
|
60
59
|
draggableTabsets?: boolean;
|
|
61
60
|
editable?: boolean;
|
|
@@ -63,12 +62,10 @@ type DashfooLayoutProps = {
|
|
|
63
62
|
floatable?: boolean;
|
|
64
63
|
keepMounted?: boolean;
|
|
65
64
|
maximizable?: boolean;
|
|
66
|
-
model?: Dashfoo;
|
|
67
65
|
onAction?: (action: Action) => Action | null;
|
|
68
66
|
onActiveTabsetChange?: (tabsetId: string | undefined) => void;
|
|
69
67
|
onMaximizedTabsetChange?: (tabsetId: string | undefined) => void;
|
|
70
68
|
onModelChange?: (model: Dashfoo, action?: Action) => void;
|
|
71
|
-
persist?: PersistInput;
|
|
72
69
|
renamableTabs?: boolean;
|
|
73
70
|
renderTabLabel?: (tab: TabNode) => ReactNode;
|
|
74
71
|
renderTabsetToolbar?: (tabset: TabsetNode) => ReactNode;
|
|
@@ -79,9 +76,18 @@ type DashfooLayoutProps = {
|
|
|
79
76
|
};
|
|
80
77
|
snap?: SnapConfig;
|
|
81
78
|
};
|
|
79
|
+
type DashfooLayoutProps = DashfooLayoutCommonProps & ({
|
|
80
|
+
defaultModel: Dashfoo;
|
|
81
|
+
model?: never;
|
|
82
|
+
persist?: PersistInput;
|
|
83
|
+
} | {
|
|
84
|
+
defaultModel?: never;
|
|
85
|
+
model: Dashfoo;
|
|
86
|
+
persist?: never;
|
|
87
|
+
});
|
|
82
88
|
declare const DashfooLayout: import("react").ForwardRefExoticComponent<DashfooLayoutProps & import("react").RefAttributes<DashfooHandle>>;
|
|
83
89
|
//#endregion
|
|
84
|
-
//#region src/components/drag-
|
|
90
|
+
//#region src/components/dashfoo-drag-provider.d.ts
|
|
85
91
|
declare const DashfooDragProvider: ({ children }: {
|
|
86
92
|
children: ReactNode;
|
|
87
93
|
}) => ReactNode;
|
|
@@ -96,16 +102,14 @@ declare const useExternalTabSource: ({ createTab, disabled, label }: ExternalTab
|
|
|
96
102
|
ref: (element: Element | null) => void;
|
|
97
103
|
};
|
|
98
104
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* actor to read and they report the empty state instead of throwing: a component
|
|
103
|
-
* that renders both inside and outside a layout should not crash in one of them.
|
|
105
|
+
* Reads the root's actor, so it works from an overlay mounted beside the layout
|
|
106
|
+
* rather than inside a drag layer. Outside a provider it reports the empty state
|
|
107
|
+
* instead of throwing.
|
|
104
108
|
*/
|
|
105
109
|
declare const useDragSubject: () => DragSubject | null;
|
|
106
110
|
declare const useDropIntent: () => DropIntent | null;
|
|
107
111
|
//#endregion
|
|
108
|
-
//#region src/components/drag-
|
|
112
|
+
//#region src/components/drag-provider.d.ts
|
|
109
113
|
type DragProviderProps = {
|
|
110
114
|
children: ReactNode;
|
|
111
115
|
onCommit?: (action: Action) => void;
|
|
@@ -116,11 +120,7 @@ type DragProviderProps = {
|
|
|
116
120
|
type FloatLayerProps = {
|
|
117
121
|
children: ReactNode;
|
|
118
122
|
floats: Array<FloatNode>;
|
|
119
|
-
/**
|
|
120
|
-
* Accepted for backwards compatibility only. Floating panels now inherit
|
|
121
|
-
* every global-derived capability from the layout store above them, so this
|
|
122
|
-
* is no longer read; it disappears in the next major.
|
|
123
|
-
*/
|
|
123
|
+
/** Unread: floats inherit every global-derived capability from the layout store above them. */
|
|
124
124
|
global?: GlobalAttributes;
|
|
125
125
|
};
|
|
126
126
|
//#endregion
|
|
@@ -207,7 +207,7 @@ declare const Panel: {
|
|
|
207
207
|
readonly Title: (props: PanelTitleProps) => ReactNode;
|
|
208
208
|
};
|
|
209
209
|
//#endregion
|
|
210
|
-
//#region src/components/tabset/tabset-
|
|
210
|
+
//#region src/components/tabset/tabset-rename-input.d.ts
|
|
211
211
|
type TabsetRenameInputProps = ComponentProps<"input">;
|
|
212
212
|
type TabsetCloseButtonProps = ComponentProps<"button">;
|
|
213
213
|
//#endregion
|
|
@@ -254,7 +254,7 @@ declare const Tabset: {
|
|
|
254
254
|
readonly Trigger: ({ children, onClick, onDoubleClick, ref: userRef, ...props }: TabsetTriggerProps) => import("react").ReactNode;
|
|
255
255
|
};
|
|
256
256
|
//#endregion
|
|
257
|
-
//#region src/components/tab-overflow.d.ts
|
|
257
|
+
//#region src/components/tab-overflow-menu.d.ts
|
|
258
258
|
type OverflowItem = {
|
|
259
259
|
id: string;
|
|
260
260
|
name: string;
|
|
@@ -271,11 +271,12 @@ type TabsetState = {
|
|
|
271
271
|
isMaximized: boolean;
|
|
272
272
|
node: TabsetNode;
|
|
273
273
|
overflowItems: Array<OverflowItem>;
|
|
274
|
+
/** The tab a `closeTab` is waiting on, so a vetoed close cannot restore focus. */
|
|
275
|
+
pendingCloseTabId: string | null;
|
|
274
276
|
registerRenameInput: () => () => void;
|
|
275
277
|
registerTablist: (element: HTMLDivElement | null) => void;
|
|
276
278
|
renameInputCount: number;
|
|
277
279
|
renameTab: (tabId: string, name: string) => void;
|
|
278
|
-
restoreFocus: boolean;
|
|
279
280
|
selectOverflowTab: (tabId: string) => void;
|
|
280
281
|
selectTab: (index: number, options?: {
|
|
281
282
|
focus?: boolean;
|
|
@@ -341,7 +342,9 @@ type UseDashfooStoreOptions = {
|
|
|
341
342
|
onMaximizedTabsetChange?: (tabsetId: string | undefined) => void;
|
|
342
343
|
onModelChange?: (model: Dashfoo, action?: Action) => void;
|
|
343
344
|
};
|
|
345
|
+
/** The mode is latched on the first render; running both sources leaves the
|
|
346
|
+
* unread one describing a document nobody rendered. */
|
|
344
347
|
declare const useDashfooStore: (options: UseDashfooStoreOptions) => DashfooStore;
|
|
345
348
|
//#endregion
|
|
346
|
-
export { type Breakpoint, DashfooDragProvider, type DashfooHandle, DashfooLayout, type DashfooLayoutProps, type DashfooStore, type ExternalTabSourceOptions, Layout, type DragProviderProps as LayoutDragLayerProps, type FloatLayerProps as LayoutFloatLayerProps, type LayoutRootProps, type RowViewProps as LayoutRowsProps, type LayoutState, type TabsetViewProps as LayoutTabsetProps, Panel, type PanelBadgeProps, type PanelBodyProps, type PanelHeaderProps, type PanelIconProps, type PanelRootProps, type PanelTitleProps, type PersistConfig, type Persistence, type ResponsiveModel, type StorageAdapter, type TabComponent, type TabContextValue, Tabset, type TabsetCloseButtonProps, type TabsetContentProps, type TabsetFloatButtonProps, type TabsetGripProps, type TabsetMaximizeButtonProps, type TabsetRenameInputProps, type TabsetRootProps, type TabsetState, type TabsetTabProps, type TabsetTabStripProps, type TabsetTablistProps, type TabsetToolbarProps, type TabsetTriggerProps, type UseDashfooStoreOptions, type UseResponsiveModelOptions, activeBreakpoint, localStorageAdapter, matchBreakpoint, memoryStorageAdapter, useContainerWidth, useDashfooStore, useDragSubject, useDropIntent, useExternalTabSource, useLayout, usePersistence, useResponsiveModel, useTab, useTabset };
|
|
349
|
+
export { type Breakpoint, DashfooDragProvider, type DashfooHandle, DashfooLayout, type DashfooLayoutCommonProps, type DashfooLayoutProps, type DashfooStore, type ExternalTabSourceOptions, Layout, type DragProviderProps as LayoutDragLayerProps, type FloatLayerProps as LayoutFloatLayerProps, type LayoutRootProps, type RowViewProps as LayoutRowsProps, type LayoutState, type TabsetViewProps as LayoutTabsetProps, Panel, type PanelBadgeProps, type PanelBodyProps, type PanelHeaderProps, type PanelIconProps, type PanelRootProps, type PanelTitleProps, type PersistConfig, type Persistence, type ResponsiveModel, type StorageAdapter, type TabComponent, type TabContextValue, Tabset, type TabsetCloseButtonProps, type TabsetContentProps, type TabsetFloatButtonProps, type TabsetGripProps, type TabsetMaximizeButtonProps, type TabsetRenameInputProps, type TabsetRootProps, type TabsetState, type TabsetTabProps, type TabsetTabStripProps, type TabsetTablistProps, type TabsetToolbarProps, type TabsetTriggerProps, type UseDashfooStoreOptions, type UseResponsiveModelOptions, activeBreakpoint, localStorageAdapter, matchBreakpoint, memoryStorageAdapter, useContainerWidth, useDashfooStore, useDragSubject, useDropIntent, useExternalTabSource, useLayout, usePersistence, useResponsiveModel, useTab, useTabset };
|
|
347
350
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/hooks/persistence.ts","../src/components/dashfoo-layout.tsx","../src/components/drag-
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/hooks/persistence.ts","../src/components/dashfoo-layout.tsx","../src/components/dashfoo-drag-provider.tsx","../src/hooks/drag-hooks.tsx","../src/components/drag-provider.tsx","../src/components/float-layer.tsx","../src/hooks/layout-store.ts","../src/components/layout-root.tsx","../src/components/row-view.tsx","../src/components/tabset/tabset-view.tsx","../src/components/layout.tsx","../src/components/panel.tsx","../src/components/tabset/tabset-rename-input.tsx","../src/components/tabset/tabset-content.tsx","../src/components/tabset/tabset-toolbar.tsx","../src/components/tabset/tabset-root.tsx","../src/components/tabset/tabset-tab.tsx","../src/components/tabset/tabset-tablist.tsx","../src/components/tabset/tabset.ts","../src/components/tab-overflow-menu.tsx","../src/components/tabset/tabset-store.ts","../src/hooks/responsive.ts","../src/hooks/store.ts"],"mappings":";;;;;;KAMK;EACH,UAAU;EACV,aAAa;EACb,UAAU,aAAa;;cAGnB,4BAA2B;cAa3B,qBAAqB;KAkCtB;EACH;EACA;EACA,SAAS;;KAGN;EACH;EAEA,cAAc;EACd,OAAO,OAAO;;cAQV,iBACJ,QAAQ,sBACR,cAAc,wBACb;;;KCtDE;EAA0B;EAAqB;EAAa,UAAU;;KAgBtE,eAAe;EAAgB,MAAM;;KAIrC;EACH,SACE,KAAK,SACL;IAAU;IAAgB,WAAW;IAAc;;EAErD;EACA;EACA,WAAW;EACX,WAAW,QAAQ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