@sheetxl/utils-react 1.0.4 → 1.0.6
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/browser/esm/{DBYWSeGFzHNKP-Y6.mjs → 7edl-sYQMunFVC0Y.mjs} +1 -1
- package/browser/esm/{B5eig7-kNFNn5Zsr.mjs → Bs0tOutsyxrwsx85.mjs} +3 -3
- package/browser/esm/C2XhaxJYv89gHu_o.mjs +100 -0
- package/browser/esm/index.mjs +186 -144
- package/node/esm/{ChJrp4qPk0bNL-My.mjs → CSH38x_MaxNFczQs.mjs} +1 -1
- package/node/esm/DLiF-zHaMR-Qi275.mjs +100 -0
- package/node/esm/index.mjs +248 -206
- package/package.json +2 -2
- package/types/src/command/CommandCatalog.d.ts +1 -1
- package/types/src/command/CommandChainContext.d.ts +6 -0
- package/types/src/command/CommandScope.d.ts +16 -3
- package/types/src/command/CommandScopeContext.d.ts +9 -1
- package/types/src/command/LayerActivation.d.ts +19 -2
- package/types/src/icons/packs/Base.json.d.ts +20 -0
- package/types/src/splitPane/SplitPane.d.ts +10 -0
- package/browser/esm/BY3qtNG7q1_SCyu8.mjs +0 -100
- package/node/esm/CONFyJIToklTND9g.mjs +0 -100
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sheetxl/utils-react",
|
|
3
3
|
"description": "Utils React - Utilities for React capabilities needed for all SheetXL components.",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.6",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@floating-ui/react-dom": "^2.1.9",
|
|
43
|
-
"@sheetxl/utils": "^1.0.
|
|
43
|
+
"@sheetxl/utils": "^1.0.6",
|
|
44
44
|
"clsx": "^2.1.1",
|
|
45
45
|
"detect-it": "^4.0.1",
|
|
46
46
|
"prop-types": "^15.8.1",
|
|
@@ -55,7 +55,7 @@ export interface ChromeRecord {
|
|
|
55
55
|
* the default, `null` = exclude it). A locale pack inherits English shortcuts by *absence*, so
|
|
56
56
|
* `null` is the only way for a locale to drop one — needed when a localized mnemonic claims a
|
|
57
57
|
* chord English gives to some other command (de Bold takes `ctrl+shift+F`, so de
|
|
58
|
-
* `
|
|
58
|
+
* `formatFont` must give it up). See `config/i18n-catalog-build.mjs`.
|
|
59
59
|
*/
|
|
60
60
|
shortcut?: string | string[] | null;
|
|
61
61
|
/** Accumulated metadata tags (e.g. `'mutator'`, `'quickAction'`). */
|
|
@@ -11,6 +11,12 @@ import { CommandScope } from './CommandScope';
|
|
|
11
11
|
export interface CommandChain {
|
|
12
12
|
/** Join `scope` to the chain at `order` (reparent-on-insert). Returns an unregister that re-chains the rest. */
|
|
13
13
|
register(scope: CommandScope, order: number): RemoveListener;
|
|
14
|
+
/**
|
|
15
|
+
* Chain a registered `scope` on the ancestor scope named `ancestor` instead of on the layer below it —
|
|
16
|
+
* the layers below drop out of its resolution while layers above still stack on it. `null` restores
|
|
17
|
+
* the ordinary place. A name with no matching ancestor chains as usual.
|
|
18
|
+
*/
|
|
19
|
+
setAttach(scope: CommandScope, ancestor: string | null): void;
|
|
14
20
|
}
|
|
15
21
|
/**
|
|
16
22
|
* The ambient z-chain a layer's {@link CommandScopeProvider} joins, or `null` **outside** a chain — the
|
|
@@ -30,8 +30,14 @@ export interface CommandContribution {
|
|
|
30
30
|
* e.g. a sheet's protection reducer does `for (const key of getKeysByTag('mutator')) updateCommand(key,
|
|
31
31
|
* { disabledReasons })`, so the tag authored in the catalog is the single source of truth (the
|
|
32
32
|
* resolved `disabled()` then accumulates the reasons — no new resolve-time machinery needed).
|
|
33
|
+
*
|
|
34
|
+
* With `own`, only the keys this scope itself holds: its own contributions and its name's catalog
|
|
35
|
+
* entries, nothing up the chain. A scope that shares a rule with a parent (each gating its own
|
|
36
|
+
* commands) reads its half this way, so a key is gated once.
|
|
33
37
|
*/
|
|
34
|
-
getKeysByTag(tag: string
|
|
38
|
+
getKeysByTag(tag: string, options?: {
|
|
39
|
+
own?: boolean;
|
|
40
|
+
}): string[];
|
|
35
41
|
/** Remove every command + middleware this contribution touched. Idempotent. */
|
|
36
42
|
remove(): void;
|
|
37
43
|
}
|
|
@@ -244,6 +250,12 @@ export declare class CommandScope {
|
|
|
244
250
|
* re-resolve. No-op if `parent` is already the parent.
|
|
245
251
|
*/
|
|
246
252
|
setParent(parent: CommandScope | null): void;
|
|
253
|
+
/**
|
|
254
|
+
* Drop `child` from the children map only if it is the entry under its key: scopes re-parented onto a
|
|
255
|
+
* shared ancestor (one layer per pane, each attached to the same `sheet`) can share a key, and one
|
|
256
|
+
* leaving must not evict another.
|
|
257
|
+
*/
|
|
258
|
+
protected _detachChild(child: CommandScope): void;
|
|
247
259
|
/**
|
|
248
260
|
* Tear this scope down when the feature/region that owns it unmounts: recursively dispose
|
|
249
261
|
* children, drop this scope's definitions, detach it from its parent (so it stops
|
|
@@ -298,9 +310,10 @@ export declare class CommandScope {
|
|
|
298
310
|
* Like {@link collectKeys}, but only keys whose contribution **somewhere along the chain** carries
|
|
299
311
|
* `tag` (tags accumulate across scopes, so a match at any scope on the chain counts). Enables
|
|
300
312
|
* cross-cutting, tag-driven rules — e.g. "disable every `mutator` command when the sheet is
|
|
301
|
-
* protected" — without a hand-maintained parallel key list. Order unspecified; deduped.
|
|
313
|
+
* protected" — without a hand-maintained parallel key list. Order unspecified; deduped. `root` stops
|
|
314
|
+
* the walk there (inclusive), as {@link collectKeys}'s does.
|
|
302
315
|
*/
|
|
303
|
-
collectKeysByTag(tag: string, anchor?: CommandScope): string[];
|
|
316
|
+
collectKeysByTag(tag: string, anchor?: CommandScope, root?: CommandScope): string[];
|
|
304
317
|
getVersion(): number;
|
|
305
318
|
/**
|
|
306
319
|
* Trigger a re-resolution **without** changing any contribution — bump version + notify.
|
|
@@ -110,6 +110,14 @@ export interface CommandScopeProviderProps {
|
|
|
110
110
|
* the one grid-aware value a layer passes — everything else about being a "layer" is ambient.
|
|
111
111
|
*/
|
|
112
112
|
order?: number;
|
|
113
|
+
/**
|
|
114
|
+
* Inside a pane's chain, the **name** of an ancestor scope to chain on instead of the layer below — the
|
|
115
|
+
* layers below this one stop resolving through it, and layers above still stack on it. `null` or
|
|
116
|
+
* omitted ⇒ the ordinary place at {@link order}. Switchable live: a layer that takes over the region
|
|
117
|
+
* (a selected drawing, an active edit) sets it while it holds the focus and clears it after. A name
|
|
118
|
+
* with no matching ancestor leaves the layer in its ordinary place. Ignored outside a chain.
|
|
119
|
+
*/
|
|
120
|
+
attachTo?: string | null;
|
|
113
121
|
/**
|
|
114
122
|
* The created scope's **element** — the DOM node this scope's commands belong to. Attaching one bounds
|
|
115
123
|
* the scope's region for **origin containment**: its shortcuts then only dispatch for keystrokes born
|
|
@@ -185,7 +193,7 @@ export declare function attachWhenReady(ref: {
|
|
|
185
193
|
* the scope's region (and, with {@link CommandScopeProviderProps.region region}, naming a focus leaf).
|
|
186
194
|
* Optionally registers dispatch middleware via {@link CommandScopeProviderProps.use}.
|
|
187
195
|
*/
|
|
188
|
-
export declare function CommandScopeProvider({ spec, scope, use, order, elementRef, region, scopeRef, children }: CommandScopeProviderProps): ReactNode;
|
|
196
|
+
export declare function CommandScopeProvider({ spec, scope, use, order, attachTo, elementRef, region, scopeRef, children }: CommandScopeProviderProps): ReactNode;
|
|
189
197
|
/**
|
|
190
198
|
* Name a scope's **element** — the primitive {@link CommandScopeProvider} is built on, for a component
|
|
191
199
|
* that already owns both. Bounds the scope's region ({@link CommandScope.attachBounds}) so its commands
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RemoveListener } from '@sheetxl/utils';
|
|
2
2
|
import { CommandScope } from './CommandScope';
|
|
3
3
|
import { ActivationTracker } from './ActivationTracker';
|
|
4
|
+
import { CommandChain } from './CommandChainContext';
|
|
4
5
|
/**
|
|
5
6
|
* The **z-ordered layer→scope registry** — the anchor source for a *region* whose behavior is composed
|
|
6
7
|
* from stacked layers (selection, clipboard, format painter, the cell editor, …). Each command-bearing
|
|
@@ -16,15 +17,20 @@ import { ActivationTracker } from './ActivationTracker';
|
|
|
16
17
|
* {@link AnchorSource}, read live) with no other changes. It has no DOM element of its own — the **region**
|
|
17
18
|
* owns focus/keys (a pane maps its `Stage` element to this stack; see {@link FocusActivation}).
|
|
18
19
|
*
|
|
20
|
+
* A layer may also **attach higher** ({@link setAttach}): chain on a named ancestor of the base instead
|
|
21
|
+
* of the layer below it, so the layers below (and the scopes between the base and that ancestor) drop out
|
|
22
|
+
* of resolution while it is attached. Layers above it still chain on top of it.
|
|
23
|
+
*
|
|
19
24
|
* @remarks
|
|
20
25
|
* Ties (equal z) keep insertion order. Reusing the same scope twice is not supported (register each
|
|
21
26
|
* layer's scope once). The base is never removed; it's the region's always-present floor.
|
|
22
27
|
*/
|
|
23
|
-
export declare class LayerActivation implements ActivationTracker {
|
|
28
|
+
export declare class LayerActivation implements ActivationTracker, CommandChain {
|
|
24
29
|
protected readonly _base: CommandScope;
|
|
25
30
|
protected _layers: Array<{
|
|
26
31
|
scope: CommandScope;
|
|
27
32
|
z: number;
|
|
33
|
+
attach: string | null;
|
|
28
34
|
}>;
|
|
29
35
|
protected _top: CommandScope;
|
|
30
36
|
protected readonly _listeners: Set<() => void>;
|
|
@@ -35,7 +41,18 @@ export declare class LayerActivation implements ActivationTracker {
|
|
|
35
41
|
* (`contribution.remove()` / `scope.dispose()`); this only manages stack membership.
|
|
36
42
|
*/
|
|
37
43
|
register(scope: CommandScope, z: number): RemoveListener;
|
|
38
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Chain a registered `scope` on the ancestor named `ancestor` (the base or one of its parents, matched
|
|
46
|
+
* by {@link CommandScope.name}) instead of on the layer below it; `null` puts it back in place. When no
|
|
47
|
+
* such ancestor exists the scope chains as usual. No-op for a scope that isn't registered.
|
|
48
|
+
*/
|
|
49
|
+
setAttach(scope: CommandScope, ancestor: string | null): void;
|
|
50
|
+
/** The base or its nearest ancestor named `name`. */
|
|
51
|
+
protected _findAncestor(name: string): CommandScope | null;
|
|
52
|
+
/**
|
|
53
|
+
* Re-link the registered scopes into a chain ordered by z: base → lowest → … → highest (= anchor). An
|
|
54
|
+
* attached layer starts the chain over from its ancestor.
|
|
55
|
+
*/
|
|
39
56
|
protected _rechain(): void;
|
|
40
57
|
/** The region's floor scope (always present, below every layer). */
|
|
41
58
|
getBase(): CommandScope;
|
|
@@ -1655,6 +1655,14 @@ declare const _default: {
|
|
|
1655
1655
|
}
|
|
1656
1656
|
]
|
|
1657
1657
|
},
|
|
1658
|
+
"Format": {
|
|
1659
|
+
"svg": [
|
|
1660
|
+
{
|
|
1661
|
+
"d": "m 10.528179,19.562028 c -1.7343434,1.716485 -8.2856339,2.416233 -8.5670016,2.445551 -0.012453,0 -0.029322,0.0044 -0.042022,0.0044 -0.1595352,0 -0.3065553,-0.09153 -0.3779146,-0.237596 -0.075664,-0.158266 -0.046148,-0.349891 0.079779,-0.474991 1.5791201,-1.570615 2.0997524,-3.641269 2.2592811,-5.099404 0.1302154,-1.212387 0.7474075,-2.333064 1.696601,-3.078796 0.8860437,-0.699802 1.9779731,-1.008145 3.0782999,-0.878995 0.4619876,0.05411 0.8735503,0.170871 1.2178048,0.345817 0.2520114,0.120831 0.4703904,0.279099 0.6551224,0.462379 0.0084,0.0084 0.01682,0.01667 0.02522,0.02501 0.104989,0.10415 0.201567,0.212574 0.29405,0.325069 0.05044,0.05838 0.09656,0.120832 0.142727,0.183281 0.07977,0.108422 0.15543,0.220717 0.230888,0.337481 0.147031,0.245739 0.272927,0.508151 0.36951,0.774842 0.61743,1.637295 0.260415,3.553749 -1.062373,4.86602 z M 22.320393,2.168841 C 21.942481,1.7980015 21.262117,1.8856764 19.145567,3.510428 17.680045,4.6353785 15.861604,6.2601042 14.022063,8.0847991 12.679166,9.4135704 11.431597,10.74943 10.41537,11.940881 c 0.250573,0.139552 0.492743,0.308797 0.7062,0.519746 0.151328,0.150532 0.266977,0.279911 0.377709,0.414986 0.04921,0.05655 0.109499,0.136291 0.168552,0.216033 0.08981,0.122467 0.174296,0.247769 0.259188,0.378367 0.137596,0.229456 0.245245,0.452614 0.341006,0.675582 0.460957,-0.383045 0.94263,-0.799474 1.443371,-1.248996 0.848297,-0.762446 1.747046,-1.603791 2.645584,-2.495595 1.835236,-1.8204231 3.472993,-3.6286623 4.611057,-5.0867958 1.633662,-2.0995051 1.721852,-2.7744652 1.352348,-3.1453005 z",
|
|
1662
|
+
"className": "fill primary"
|
|
1663
|
+
}
|
|
1664
|
+
]
|
|
1665
|
+
},
|
|
1658
1666
|
"FormatAlignCenter": {
|
|
1659
1667
|
"svg": [
|
|
1660
1668
|
{
|
|
@@ -2696,6 +2704,18 @@ declare const _default: {
|
|
|
2696
2704
|
}
|
|
2697
2705
|
]
|
|
2698
2706
|
},
|
|
2707
|
+
"PivotAxis": {
|
|
2708
|
+
"svg": [
|
|
2709
|
+
{
|
|
2710
|
+
"d": "M 2.7363281 1.2207031 C 1.7148853 1.2207031 0.8671875 2.0291177 0.8671875 3.0039062 L 0.8671875 19.646484 C 0.8671875 20.621273 1.7148853 21.429687 2.7363281 21.429688 L 9.859375 21.429688 L 9.859375 19.646484 L 8.9648438 19.646484 L 8.9648438 14.890625 L 9.859375 14.890625 L 9.859375 13.701172 L 8.9648438 13.701172 L 8.9648438 8.9472656 L 13.947266 8.9472656 L 13.947266 9.921875 L 14.396484 10 L 15.193359 10 L 15.193359 8.9472656 L 20.173828 8.9472656 L 20.173828 10 L 22.042969 10 L 22.042969 3.0039062 C 22.042969 2.0291178 21.195271 1.2207031 20.173828 1.2207031 L 2.7363281 1.2207031 z M 2.7363281 3.0039062 L 7.71875 3.0039062 L 7.71875 7.7578125 L 2.7363281 7.7578125 L 2.7363281 3.0039062 z M 8.9648438 3.0039062 L 13.947266 3.0039062 L 13.947266 7.7578125 L 8.9648438 7.7578125 L 8.9648438 3.0039062 z M 15.193359 3.0039062 L 20.173828 3.0039062 L 20.173828 7.7578125 L 15.193359 7.7578125 L 15.193359 3.0039062 z M 2.7363281 8.9472656 L 7.71875 8.9472656 L 7.71875 13.701172 L 2.7363281 13.701172 L 2.7363281 8.9472656 z M 2.7363281 14.890625 L 7.71875 14.890625 L 7.71875 19.646484 L 2.7363281 19.646484 L 2.7363281 14.890625 z ",
|
|
2711
|
+
"className": "fill"
|
|
2712
|
+
},
|
|
2713
|
+
{
|
|
2714
|
+
"d": "m 20.74572,11.128255 2.408876,4.172336 h -1.200907 v 5.491436 C 21.953689,21.459704 21.413397,22 20.745719,22 h -5.491438 v 1.200904 l -4.17233,-2.408877 4.17233,-2.408874 v 1.200902 h 4.283467 v -4.283464 h -1.200905 z",
|
|
2715
|
+
"className": "fill primary"
|
|
2716
|
+
}
|
|
2717
|
+
]
|
|
2718
|
+
},
|
|
2699
2719
|
"PresetStyles": {
|
|
2700
2720
|
"svg": [
|
|
2701
2721
|
{
|
|
@@ -28,6 +28,16 @@ export interface SplitPaneProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
28
28
|
* When set the default position to be interpreted as pixels.
|
|
29
29
|
*/
|
|
30
30
|
fixedPane?: 'before' | 'after' | null;
|
|
31
|
+
/**
|
|
32
|
+
* If `true` the {@link fixedPane} is hidden and there is no resizer; the other pane fills the split.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* The hidden pane stays mounted, so its content keeps its state. The position is kept too, so
|
|
36
|
+
* clearing it restores the pane to the size it had. Ignored without a `fixedPane`.
|
|
37
|
+
*
|
|
38
|
+
* @defaultValue false
|
|
39
|
+
*/
|
|
40
|
+
collapsed?: boolean;
|
|
31
41
|
/**
|
|
32
42
|
* The position. Can be either a string with px or %.
|
|
33
43
|
* If it is a number it will be interpreted based on whether there is a fixed pane or not.
|