@sheetxl/utils-react 0.7.27 → 0.7.28-beta.1
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/cjs/C7jPCqFJNiWyD2pr.cjs +1 -0
- package/browser/cjs/CyWMySHsu-RvsIGs.cjs +1 -0
- package/browser/cjs/DZSvmqU8nRas1uz6.cjs +1 -0
- package/browser/cjs/index.cjs +5 -7
- package/browser/esm/CD4Q4NRTfHSJirLz.mjs +139 -0
- package/browser/esm/DAwEWkKjQCR-nguL.mjs +2171 -0
- package/browser/esm/DUF3Ugd4Z1SDNXPb.mjs +390 -0
- package/browser/esm/index.mjs +6128 -1806
- package/licenses/dependencies.txt +246 -39
- package/node/esm/DA8vLJ8AED3TYoSo.mjs +2171 -0
- package/node/esm/DKS7p6NraAuZKdCC.mjs +139 -0
- package/node/esm/index.mjs +5141 -1774
- package/package.json +8 -5
- package/types/index.d.ts +2 -2043
- package/types/src/animation/AnimationModeContext.d.ts +10 -0
- package/types/src/animation/index.d.ts +3 -0
- package/types/src/animation/useAnimatedMeasure.d.ts +39 -0
- package/types/src/command/ActivationTracker.d.ts +53 -0
- package/types/src/command/CommandAnchorProvider.d.ts +64 -0
- package/types/src/command/CommandButtonEntryLabel.d.ts +25 -0
- package/types/src/command/CommandButtonRegistry.d.ts +159 -0
- package/types/src/command/CommandButtonRegistryContext.d.ts +35 -0
- package/types/src/command/CommandCatalog.d.ts +155 -0
- package/types/src/command/CommandCatalogResource.d.ts +7 -0
- package/types/src/command/CommandCatalogService.d.ts +61 -0
- package/types/src/command/CommandChainContext.d.ts +32 -0
- package/types/src/command/CommandFallbackContext.d.ts +30 -0
- package/types/src/command/CommandFocusContext.d.ts +21 -0
- package/types/src/command/CommandRegistry.d.ts +164 -0
- package/types/src/command/CommandRegistryContext.d.ts +16 -0
- package/types/src/command/CommandResolver.d.ts +162 -0
- package/types/src/command/CommandScope.d.ts +343 -0
- package/types/src/command/CommandScopeContext.d.ts +205 -0
- package/types/src/command/FocusActivation.d.ts +140 -0
- package/types/src/command/ICommand.d.ts +31 -0
- package/types/src/command/ICommandDefinition.d.ts +82 -0
- package/types/src/command/KeyBindingDispatcher.d.ts +150 -0
- package/types/src/command/LayerActivation.d.ts +45 -0
- package/types/src/command/Types.d.ts +80 -0
- package/types/src/command/createResolvedCommand.d.ts +91 -0
- package/types/src/command/index.d.ts +26 -0
- package/types/src/command/reduceDefinitions.d.ts +33 -0
- package/types/src/command/useCommands.d.ts +22 -0
- package/types/src/command/useContributeCommands.d.ts +18 -0
- package/types/src/components/FocusKeyNavigation.d.ts +22 -0
- package/types/src/components/ITooltip.d.ts +38 -0
- package/types/src/components/RoundedTab.d.ts +26 -0
- package/types/src/components/index.d.ts +4 -0
- package/types/src/error/ErrorPanel.d.ts +14 -0
- package/types/src/error/ReactErrorBoundary.d.ts +7 -0
- package/types/src/error/UncaughtErrorBoundary.d.ts +5 -0
- package/types/src/error/index.d.ts +4 -0
- package/types/src/float/FloatPanel.d.ts +57 -0
- package/types/src/float/FloatPopper.d.ts +85 -0
- package/types/src/float/FloatPopup.d.ts +19 -0
- package/types/src/float/FloatProvider.d.ts +60 -0
- package/types/src/float/FloatStackContext.d.ts +25 -0
- package/types/src/float/FloatTooltip.d.ts +22 -0
- package/types/src/float/FloatUtils.d.ts +55 -0
- package/types/src/float/_FloatUtils.d.ts +51 -0
- package/types/src/float/index.d.ts +9 -0
- package/types/src/float/useFloatStack.d.ts +92 -0
- package/types/src/hooks/LanguageState.d.ts +15 -0
- package/types/src/hooks/index.d.ts +19 -0
- package/types/src/hooks/useBoundSyncExternalStore.d.ts +23 -0
- package/types/src/hooks/useCallbackRef.d.ts +11 -0
- package/types/src/hooks/useDevicePixelRatio.d.ts +37 -0
- package/types/src/hooks/useEditMode.d.ts +66 -0
- package/types/src/hooks/useGlobalClipboard.d.ts +7 -0
- package/types/src/hooks/useId.d.ts +9 -0
- package/types/src/hooks/useImperativeElement.d.ts +3 -0
- package/types/src/hooks/useLanguage.d.ts +13 -0
- package/types/src/hooks/useMouseDownAndHoldListener.d.ts +13 -0
- package/types/src/hooks/useNotifier.d.ts +330 -0
- package/types/src/hooks/useOnClickOrFocusAway.d.ts +8 -0
- package/types/src/hooks/useOptionalBoundSyncExternalStore.d.ts +20 -0
- package/types/src/hooks/useOptionalSyncExternalStore.d.ts +18 -0
- package/types/src/hooks/useSynchronizedPointerHandler.d.ts +54 -0
- package/types/src/hooks/useTextareaCaretRect.d.ts +85 -0
- package/types/src/hooks/useTraceUpdate.d.ts +2 -0
- package/types/src/hooks/useTranslator.d.ts +32 -0
- package/types/src/icons/DynamicIcon.d.ts +17 -0
- package/types/src/icons/DynamicIconService.d.ts +39 -0
- package/types/src/icons/ErrorIcon.d.ts +6 -0
- package/types/src/icons/Types.d.ts +81 -0
- package/types/src/icons/WalkingIcon.d.ts +27 -0
- package/types/src/icons/_Utils.d.ts +3 -0
- package/types/src/icons/index.d.ts +5 -0
- package/types/src/icons/packs/Base.d.ts +4 -0
- package/types/src/icons/packs/Conditional.d.ts +4 -0
- package/types/src/index.d.ts +18 -0
- package/types/src/loading/LoadingPanel.d.ts +31 -0
- package/types/src/loading/index.d.ts +2 -0
- package/types/src/persistence/InMemoryStore.d.ts +12 -0
- package/types/src/persistence/LocalStorageStore.d.ts +15 -0
- package/types/src/persistence/PersistenceStateProvider.d.ts +3 -0
- package/types/src/persistence/Types.d.ts +95 -0
- package/types/src/persistence/_Context.d.ts +9 -0
- package/types/src/persistence/index.d.ts +6 -0
- package/types/src/persistence/usePersistenceState.d.ts +33 -0
- package/types/src/react-resizable/Resizable.d.ts +30 -0
- package/types/src/react-resizable/ResizableBox.d.ts +18 -0
- package/types/src/react-resizable/index.d.ts +11 -0
- package/types/src/react-resizable/propTypes.d.ts +56 -0
- package/types/src/react-resizable/utils.d.ts +3 -0
- package/types/src/scroll/AxisViewport.d.ts +73 -0
- package/types/src/scroll/IScrollPane.d.ts +63 -0
- package/types/src/scroll/IScrollbar.d.ts +94 -0
- package/types/src/scroll/NativeScrollbar.d.ts +7 -0
- package/types/src/scroll/ScrollButton.d.ts +29 -0
- package/types/src/scroll/ScrollPane.d.ts +4 -0
- package/types/src/scroll/Scrollbar.d.ts +4 -0
- package/types/src/scroll/TouchThumbContext.d.ts +93 -0
- package/types/src/scroll/TouchThumbHandle.d.ts +64 -0
- package/types/src/scroll/TrackDrag.d.ts +107 -0
- package/types/src/scroll/Utils.d.ts +8 -0
- package/types/src/scroll/Viewport.d.ts +285 -0
- package/types/src/scroll/VirtualScrollbar.d.ts +49 -0
- package/types/src/scroll/index.d.ts +14 -0
- package/types/src/scroll/scrollbarTheming.d.ts +27 -0
- package/types/src/scroll/useWheelScroll.d.ts +27 -0
- package/types/src/scroller/Scroller.d.ts +260 -0
- package/types/src/scroller/animate.d.ts +30 -0
- package/types/src/scroller/index.d.ts +2 -0
- package/types/src/singletonHook/components/SingleItemContainer.d.ts +6 -0
- package/types/src/singletonHook/components/SingletonHooksContainer.d.ts +7 -0
- package/types/src/singletonHook/index.d.ts +11 -0
- package/types/src/singletonHook/singletonHook.d.ts +6 -0
- package/types/src/singletonHook/utils/env.d.ts +4 -0
- package/types/src/singletonHook/utils/env.native.d.ts +1 -0
- package/types/src/singletonHook/utils/warning.d.ts +2 -0
- package/types/src/splitPane/SplitPane.d.ts +91 -0
- package/types/src/splitPane/SplitPaneResizer.d.ts +11 -0
- package/types/src/splitPane/index.d.ts +3 -0
- package/types/src/theme/TokenTheme.d.ts +196 -0
- package/types/src/theme/TokenThemeProvider.d.ts +97 -0
- package/types/src/theme/buildThemeCSS.d.ts +54 -0
- package/types/src/theme/createThemeVars.d.ts +15 -0
- package/types/src/theme/defaultTheme.d.ts +15 -0
- package/types/src/theme/index.d.ts +9 -0
- package/types/src/theme/resolveTokens.d.ts +21 -0
- package/types/src/theme/themeAttrs.d.ts +32 -0
- package/types/src/theme/useResolvedThemeMode.d.ts +17 -0
- package/types/src/types/Types.d.ts +71 -0
- package/types/src/types/index.d.ts +2 -0
- package/types/src/utils/FullScreenPortal.d.ts +6 -0
- package/types/src/utils/PinchZoom.d.ts +3 -0
- package/types/src/utils/ReactUtils.d.ts +134 -0
- package/types/src/utils/index.d.ts +4 -0
- package/types/src/utils/useFullScreen.d.ts +47 -0
- package/browser/cjs/DJJQOl0dYYJgXfru.cjs +0 -6
- package/browser/esm/Bh0xih0ZamA4MXkt.mjs +0 -12
- package/node/assets/style.css +0 -1
- package/node/esm/DdwriRgF582bPBWP.mjs +0 -12
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { TokenTheme, ThemeMode } from './TokenTheme';
|
|
3
|
+
import { ThemeCSSOptions } from './buildThemeCSS';
|
|
4
|
+
/**
|
|
5
|
+
* What a {@link TokenThemeProvider} publishes to descendants — the *handle*, not resolved values (resolution
|
|
6
|
+
* stays in CSS). A portaled float is a React descendant but NOT a DOM descendant, so the cascade can't reach
|
|
7
|
+
* it; a float layer reads this to re-attach the theme (stamp `scopeClass` + `mode` on its portal root).
|
|
8
|
+
* `light`/`dark` are the already-MERGED inputs so a nested provider can merge further.
|
|
9
|
+
*/
|
|
10
|
+
export interface TokenThemeContextValue {
|
|
11
|
+
/**
|
|
12
|
+
* Per-instance scope class (no leading dot) — present ONLY when the provider is `isolate`d (i.e. it emits
|
|
13
|
+
* `@scope`d rules). A float carries it so those scoped rules apply on the portal root; `undefined` for a
|
|
14
|
+
* global provider (nothing to carry — global rules reach the float anyway).
|
|
15
|
+
*/
|
|
16
|
+
scopeClass?: string;
|
|
17
|
+
/** The mode a float should stamp, when this provider (or an ancestor provider) pins one. */
|
|
18
|
+
mode?: ThemeMode;
|
|
19
|
+
/** Merged light-mode token inputs (base/parent ⊕ own) — a child provider merges on top of these. */
|
|
20
|
+
light?: Partial<TokenTheme>;
|
|
21
|
+
/** Merged dark-mode token inputs. */
|
|
22
|
+
dark?: Partial<TokenTheme>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The raw context. Exported so a non-`TokenThemeProvider` theme root (e.g. the MUI studio, which builds its
|
|
26
|
+
* own sheet) can still PUBLISH the handle — `<TokenThemeContext.Provider value={{ scopeClass, mode }}>` — so
|
|
27
|
+
* floats and nested `TokenThemeProvider`s see it. Prefer {@link useTokenThemeContext} to read it.
|
|
28
|
+
*/
|
|
29
|
+
export declare const TokenThemeContext: React.Context<TokenThemeContextValue | null>;
|
|
30
|
+
/** Read the nearest {@link TokenThemeProvider}'s handle (scope class + mode + merged inputs), or `null`. */
|
|
31
|
+
export declare const useTokenThemeContext: () => TokenThemeContextValue | null;
|
|
32
|
+
export interface TokenThemeProviderProps {
|
|
33
|
+
/** Light-mode token overrides. Shallow-merged over the base (parent provider ?? `base` prop). Own wins. */
|
|
34
|
+
light?: Partial<TokenTheme>;
|
|
35
|
+
/** Dark-mode token overrides. Shallow-merged over the base. Own wins. */
|
|
36
|
+
dark?: Partial<TokenTheme>;
|
|
37
|
+
/**
|
|
38
|
+
* The app baseline both modes start from, for the **from-scratch** case (theming a bare `Grid`, which has
|
|
39
|
+
* no surfaces of its own). Omit it in the **common** case — wrap a component that already brings its base +
|
|
40
|
+
* surfaces (`Studio`, `WorkbookElement`) and this provider is a pure override layer. Layered low → high as
|
|
41
|
+
* `base` ⊕ parent-provider ⊕ own, so a nested provider keeps `base` as a floor under the inherited tokens.
|
|
42
|
+
*/
|
|
43
|
+
base?: Record<ThemeMode, TokenTheme>;
|
|
44
|
+
/**
|
|
45
|
+
* Named surface overrides (e.g. `{ grid: GRID_SURFACE, header: HEADER_SURFACE }`), passed straight to
|
|
46
|
+
* {@link buildThemeCSS}. Only for the from-scratch case; a wrapped `Studio`/`WorkbookElement` supplies its
|
|
47
|
+
* own. Pass a stable object (it re-emits the sheet when the reference changes).
|
|
48
|
+
*/
|
|
49
|
+
surfaces?: ThemeCSSOptions['surfaces'];
|
|
50
|
+
/**
|
|
51
|
+
* Pin the mode by stamping `data-sxl-theme-mode` on this provider's root (`'auto'` follows the OS / a
|
|
52
|
+
* `light`|`dark` class). **Omit it in the common case** — the wrapped component stamps its own mode, and
|
|
53
|
+
* the mode-keyed overrides follow it via the cascade. Pin it only when the themed content sits on this
|
|
54
|
+
* provider's own root with no inner mode (the from-scratch bare-`Grid` case).
|
|
55
|
+
*/
|
|
56
|
+
mode?: ThemeMode | 'auto';
|
|
57
|
+
/** Stamp `data-sxl-theme-surface` on the root (e.g. `'grid'`). Optional — app is the default surface. */
|
|
58
|
+
surface?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Isolate this instance in an `@scope` so its tokens don't collide with another provider on the page.
|
|
61
|
+
* Default `false` (global) — correct for the common "theme the whole app" case, and it reaches portaled
|
|
62
|
+
* popups for free. Set `true` for multiple independently-themed instances on one page (note: an isolated
|
|
63
|
+
* provider's overrides don't yet reach a WRAPPED component's own portaled floats — that needs float-layer
|
|
64
|
+
* wiring off {@link useTokenThemeContext}). @defaultValue false
|
|
65
|
+
*/
|
|
66
|
+
isolate?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* The `@layer` the tokens emit into. Default `'sxl-overrides'` — the top layer, so overrides win over the
|
|
69
|
+
* app/defaults regardless of specificity. Pass `'sxl-app'` to act as an app baseline instead.
|
|
70
|
+
* @defaultValue 'sxl-overrides'
|
|
71
|
+
*/
|
|
72
|
+
layer?: string;
|
|
73
|
+
/**
|
|
74
|
+
* The content to theme. A provider renders **no DOM box of its own** — when a `mode`/`surface` is pinned or
|
|
75
|
+
* the instance is `isolate`d, those are cloned ONTO this child, so in that case it must be a **single**
|
|
76
|
+
* element that forwards `className` / DOM attributes to its root (`Studio`, `WorkbookElement`, and intrinsic
|
|
77
|
+
* elements all do). In the common case (global, no pinned mode) nothing is injected and children render as-is.
|
|
78
|
+
*/
|
|
79
|
+
children?: React.ReactNode;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A thin React wrapper around the CSS-variable theme model — the ergonomic form of the hand-written
|
|
83
|
+
* `<style>` + `data-sxl-theme-*` ceremony (see the "CSS Variables" story). It builds the `--sxl-*` stylesheet
|
|
84
|
+
* from `light`/`dark` token sets (via {@link buildThemeCSS}) and injects it, so the common flow is: render a
|
|
85
|
+
* workbook, wrap it, pass your brand tokens. It renders **no DOM box of its own** — when a mode/surface is
|
|
86
|
+
* pinned or the instance is `isolate`d, those attributes are cloned onto its single child instead.
|
|
87
|
+
*
|
|
88
|
+
* @remarks
|
|
89
|
+
* **Resolution stays in CSS** — this only *emits* CSS and publishes a {@link TokenThemeContextValue} handle.
|
|
90
|
+
* The default is an **override layer over a wrapped component that already defines base + surfaces** (Studio /
|
|
91
|
+
* WorkbookElement); `base`/`surfaces` are the from-scratch escape hatch. Nesting is a **shallow input merge**
|
|
92
|
+
* (base/parent ⊕ own) — a `TokenTheme` is flat, so a shallow spread is the correct merge (the one array token
|
|
93
|
+
* `color-series` is replaced wholesale by design). There is intentionally **no shared-`theme` prop**: put
|
|
94
|
+
* shared tokens in both modes, or in a parent provider both modes inherit (nesting IS the shared layer).
|
|
95
|
+
*/
|
|
96
|
+
export declare const TokenThemeProvider: React.FC<TokenThemeProviderProps>;
|
|
97
|
+
//# sourceMappingURL=TokenThemeProvider.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { TokenTheme, ThemeMode } from './TokenTheme';
|
|
2
|
+
/**
|
|
3
|
+
* Per-element override hook for the generic text-selection tint (below). An element sets this custom
|
|
4
|
+
* property to retint or clear (`transparent`) its own selection without a bespoke `::selection` rule —
|
|
5
|
+
* e.g. the formula editor clears it while its hover eval-run band is shown so the two same-colored
|
|
6
|
+
* highlights don't stack.
|
|
7
|
+
*/
|
|
8
|
+
export declare const INPUT_SELECTION_VAR = "--sxl-input-selection";
|
|
9
|
+
/**
|
|
10
|
+
* The generic selection tint: `--sxl-color-primary` at a low alpha, so text stays readable through it and
|
|
11
|
+
* it follows light/dark + any brand override automatically. Shared so a component painting its own matching
|
|
12
|
+
* "highlight" surface (the formula editor's eval-run band) reads as the same system, not a hardcoded blue.
|
|
13
|
+
*/
|
|
14
|
+
export declare const INPUT_SELECTION_TINT = "color-mix(in srgb, var(--sxl-color-primary, rgb(0, 120, 215)) 20%, transparent)";
|
|
15
|
+
/**
|
|
16
|
+
* The canonical `@layer` cascade (lowest → highest priority). A later layer wins over an earlier one
|
|
17
|
+
* regardless of specificity, so the whole model is: grid-react emits neutral defaults into `sxl-defaults`,
|
|
18
|
+
* studio-mui emits its MUI-derived values into `sxl-app`, and clients override in `sxl-overrides`. Consumers
|
|
19
|
+
* read `var(--sxl-*)` UNLAYERED, so they (and inline one-offs) still beat every layer.
|
|
20
|
+
*/
|
|
21
|
+
export declare const SXL_THEME_LAYERS: readonly ["sxl-defaults", "sxl-app", "sxl-overrides"];
|
|
22
|
+
export type SxlThemeLayer = typeof SXL_THEME_LAYERS[number];
|
|
23
|
+
/**
|
|
24
|
+
* The `@layer a, b, c;` order statement. Emit it at the top of EVERY layered sheet (idempotent): CSS derives
|
|
25
|
+
* layer order from first appearance, so without an explicit declaration the order would depend on which sheet
|
|
26
|
+
* (studio vs. Sheet) mounted first. Declaring it makes `sxl-app` beat `sxl-defaults` regardless of load order.
|
|
27
|
+
*/
|
|
28
|
+
export declare const SXL_THEME_LAYER_ORDER: string;
|
|
29
|
+
export interface ThemeCSSOptions {
|
|
30
|
+
/** App baseline per mode. @defaultValue `defaultTheme` */
|
|
31
|
+
app?: Record<ThemeMode, TokenTheme>;
|
|
32
|
+
/** Extra surfaces: name → per-mode partial overrides (e.g. `{ grid: GRID_SURFACE, header: HEADER_SURFACE }`). */
|
|
33
|
+
surfaces?: Record<string, Partial<Record<ThemeMode, Partial<TokenTheme>>>>;
|
|
34
|
+
/** High-contrast override tokens (rides the `mode="hc"` value). */
|
|
35
|
+
hc?: Partial<TokenTheme>;
|
|
36
|
+
modeAttr?: string;
|
|
37
|
+
surfaceAttr?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Wrap all emitted rules in `@layer <layer>{…}` (and prepend {@link SXL_THEME_LAYER_ORDER} so the cascade
|
|
40
|
+
* order is deterministic). Omit for an unlayered sheet (e.g. storybook one-offs). See {@link SXL_THEME_LAYERS}.
|
|
41
|
+
*/
|
|
42
|
+
layer?: SxlThemeLayer | string;
|
|
43
|
+
/**
|
|
44
|
+
* Wrap the theme rules in `@scope (<scopeSelector>){…}` so this instance's tokens don't collide with
|
|
45
|
+
* other instances or shadow DOM boundaries (design §6). When both `layer` and `scope` are set the nesting
|
|
46
|
+
* is `@layer <layer>{ @scope (<sel>){ rules } }` — the layer-order statement stays top-level (layers are
|
|
47
|
+
* document-global) and `@scope` binds only the rules. Inside a scope the defaults attach to `:scope`
|
|
48
|
+
* (the scope root), not `:root`. Omit for a global sheet.
|
|
49
|
+
*/
|
|
50
|
+
scope?: string;
|
|
51
|
+
}
|
|
52
|
+
/** Build the injectable theme CSS from the app baseline + surface overrides. */
|
|
53
|
+
export declare function buildThemeCSS(options?: ThemeCSSOptions): string;
|
|
54
|
+
//# sourceMappingURL=buildThemeCSS.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { TokenTheme, ThemeMode } from './TokenTheme';
|
|
3
|
+
/**
|
|
4
|
+
* Flat theme (token values) → `--sxl-*` style object (skips `undefined`). An **array** token expands to a
|
|
5
|
+
* 1-based numbered ramp (`--sxl-color-series-1`, `-2`, …), matching {@link buildThemeCSS}'s stylesheet form.
|
|
6
|
+
*/
|
|
7
|
+
export declare function toVars(theme: Partial<TokenTheme> | Record<string, string | string[] | undefined>): CSSProperties;
|
|
8
|
+
/**
|
|
9
|
+
* The single entry: resolve `--sxl-*` vars for a mode, with any number of partial overrides merged over
|
|
10
|
+
* the default theme (later wins). A *surface* is just an overrides partial — e.g. grid-react's
|
|
11
|
+
* `GRID_SURFACE[mode]` — so `themeVars(mode, GRID_SURFACE[mode])` yields the grid surface, and a client's
|
|
12
|
+
* brand tweak is one more partial: `themeVars(mode, GRID_SURFACE[mode], { 'color-accent': 'purple' })`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function themeVars(mode: ThemeMode, ...overrides: Array<Partial<TokenTheme> | undefined>): CSSProperties;
|
|
15
|
+
//# sourceMappingURL=createThemeVars.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TokenTheme, ThemeMode } from './TokenTheme';
|
|
2
|
+
/**
|
|
3
|
+
* The length of the categorical `color-series` palette (the `--sxl-color-series-1..N` ramp). **Fixed** — like
|
|
4
|
+
* MUI's grey ramp, this is a constant the whole system agrees on, never a tunable. A client may swap the seven
|
|
5
|
+
* hues (replace the `color-series` array), but never the count. Consumers rotate with `i % SERIES_COUNT`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SERIES_COUNT = 7;
|
|
8
|
+
/**
|
|
9
|
+
* The default theme — the framework-neutral, **unbranded** baseline (per mode) every surface inherits.
|
|
10
|
+
* The floor for an app with no theme at all; a themed app (MUI, VS Code, …) injects its own palette over
|
|
11
|
+
* it, and branding is expressed in THAT layer, never here. Grid/header surfaces (in grid-react) layer
|
|
12
|
+
* their overrides on top of this.
|
|
13
|
+
*/
|
|
14
|
+
export declare const defaultTheme: Record<ThemeMode, TokenTheme>;
|
|
15
|
+
//# sourceMappingURL=defaultTheme.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './TokenTheme';
|
|
2
|
+
export * from './defaultTheme';
|
|
3
|
+
export * from './createThemeVars';
|
|
4
|
+
export * from './buildThemeCSS';
|
|
5
|
+
export * from './themeAttrs';
|
|
6
|
+
export * from './TokenThemeProvider';
|
|
7
|
+
export * from './useResolvedThemeMode';
|
|
8
|
+
export * from './resolveTokens';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read resolved `--sxl-*` token values off a live element via `getComputedStyle`.
|
|
3
|
+
*
|
|
4
|
+
* This is the escape hatch for the few consumers that CSS `var()` cannot reach — a `<canvas>`, an SVG
|
|
5
|
+
* `data:` URI, or SDK interop — where a concrete color string is required. Because it reads the *computed*
|
|
6
|
+
* style of `el`, the value already reflects that element's surface, mode, and any override, with no
|
|
7
|
+
* configuration and no theme context (see THEMING-DESIGN.md, decision 1). It is the counterpart to the
|
|
8
|
+
* CSS-first read path; do NOT use it where a plain `var(--sxl-*)` works.
|
|
9
|
+
*
|
|
10
|
+
* SSR / detached element: returns `undefined` / `{}` so the caller falls back to its literal. Never throws.
|
|
11
|
+
*
|
|
12
|
+
* `name` is a {@link TokenTheme} key (e.g. `'color-base-100'`) or a full custom-property name
|
|
13
|
+
* (e.g. `'--sxl-color-base-100'`); the `--sxl-` prefix is added when absent.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveToken(el: Element | null | undefined, name: string): string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Batch form of {@link resolveToken} — resolves several tokens from a single `getComputedStyle` read.
|
|
18
|
+
* Returns a record keyed by the input `names` (unresolved/empty tokens are omitted).
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveTokens(el: Element | null | undefined, names: string[]): Record<string, string>;
|
|
21
|
+
//# sourceMappingURL=resolveTokens.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ThemeMode } from './TokenTheme';
|
|
2
|
+
/**
|
|
3
|
+
* The two attributes a container sets to **select** a cell of the `(token × surface × mode)` matrix. The
|
|
4
|
+
* value cells live in the injected stylesheet (see {@link buildThemeCSS}); a consumer just reads
|
|
5
|
+
* `var(--sxl-*)` and knows nothing about mode/surface. See THEMING-DESIGN.md.
|
|
6
|
+
*/
|
|
7
|
+
export declare const THEME_MODE_ATTR = "data-sxl-theme-mode";
|
|
8
|
+
export declare const THEME_SURFACE_ATTR = "data-sxl-theme-surface";
|
|
9
|
+
export interface ThemeAttrs {
|
|
10
|
+
'data-sxl-theme-mode'?: ThemeMode;
|
|
11
|
+
'data-sxl-theme-surface'?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The selection attributes for a surface container, ready to spread onto the element — e.g.
|
|
15
|
+
* `<div {...themeSurfaceProps('grid', 'dark')}>`. `mode` is optional: omit it to inherit the ancestor's
|
|
16
|
+
* mode via the CSS cascade; pass it when the region flips mode (a light grid in a dark app), which selects
|
|
17
|
+
* the compound `[mode][surface]` cell.
|
|
18
|
+
*/
|
|
19
|
+
export declare const themeSurfaceProps: (surface: string, mode?: ThemeMode) => ThemeAttrs;
|
|
20
|
+
/**
|
|
21
|
+
* A stable, CSS-safe per-instance scope **class name** (no leading dot) for a theme instance root — e.g.
|
|
22
|
+
* `sheetxl-studio-r0`. Set it as the element's `className` and, for the matching `@scope` selector, prefix a
|
|
23
|
+
* dot: `@scope (.${cls})`.
|
|
24
|
+
*
|
|
25
|
+
* `id` is typically a React `useId()` value, which is wrapped in colons (`":r0:"`) — invalid in a class name
|
|
26
|
+
* and, unescaped, a broken selector. Every non-`[A-Za-z0-9_-]` character is stripped so the result is valid
|
|
27
|
+
* in both a `class` attribute and a selector, while staying unique (the colons only delimit, they don't
|
|
28
|
+
* distinguish). Prefer a component-instance id (`useId()`) over data ids so the scope is stable across the
|
|
29
|
+
* data the component renders.
|
|
30
|
+
*/
|
|
31
|
+
export declare const createThemeScopeClass: (instanceType: string, id: string) => string;
|
|
32
|
+
//# sourceMappingURL=themeAttrs.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ThemeMode } from './TokenTheme';
|
|
2
|
+
type Source = 'prop' | 'class' | 'media';
|
|
3
|
+
interface UseThemeOptions {
|
|
4
|
+
mode?: ThemeMode;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Resolves the effective light/dark mode from (in priority order) an explicit `mode`, a `dark`/`light`
|
|
8
|
+
* class on `<html>`/`<body>`, then `prefers-color-scheme`. Framework-neutral (DOM only) — lives here so
|
|
9
|
+
* both the neutral `@sheetxl/react` layer and the MUI studio resolve the SAME preference the same way
|
|
10
|
+
* (no drift). Re-resolves on class mutations + media changes when no explicit `mode` is given.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useResolvedThemeMode(options?: UseThemeOptions): {
|
|
13
|
+
themeMode: ThemeMode;
|
|
14
|
+
source: Source;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=useResolvedThemeMode.d.ts.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export declare const KeyModifiers: {
|
|
2
|
+
readonly Shift: "shift";
|
|
3
|
+
readonly Alt: "alt";
|
|
4
|
+
readonly Ctrl: "ctrl";
|
|
5
|
+
readonly Meta: "meta";
|
|
6
|
+
};
|
|
7
|
+
export type KeyModifiers = typeof KeyModifiers[keyof typeof KeyModifiers];
|
|
8
|
+
export interface IKeyStroke {
|
|
9
|
+
readonly key: string;
|
|
10
|
+
readonly modifiers?: KeyModifiers[];
|
|
11
|
+
}
|
|
12
|
+
export declare const KeyCodes: {
|
|
13
|
+
readonly BackSpace: 8;
|
|
14
|
+
readonly Tab: 9;
|
|
15
|
+
readonly Clear: 12;
|
|
16
|
+
readonly Enter: 13;
|
|
17
|
+
readonly Shift: 16;
|
|
18
|
+
readonly Control: 17;
|
|
19
|
+
readonly Alt: 18;
|
|
20
|
+
readonly Pause: 19;
|
|
21
|
+
readonly CapsLock: 20;
|
|
22
|
+
readonly Escape: 27;
|
|
23
|
+
readonly Space: 32;
|
|
24
|
+
readonly PageUp: 33;
|
|
25
|
+
readonly PageDown: 34;
|
|
26
|
+
readonly End: 35;
|
|
27
|
+
readonly Home: 36;
|
|
28
|
+
readonly Left: 37;
|
|
29
|
+
readonly Up: 38;
|
|
30
|
+
readonly Right: 39;
|
|
31
|
+
readonly Down: 40;
|
|
32
|
+
readonly Insert: 45;
|
|
33
|
+
readonly Delete: 46;
|
|
34
|
+
readonly Digit_8: 56;
|
|
35
|
+
readonly Y: 89;
|
|
36
|
+
readonly Z: 90;
|
|
37
|
+
readonly Meta: 91;
|
|
38
|
+
readonly F1: 112;
|
|
39
|
+
readonly F2: 113;
|
|
40
|
+
readonly F3: 114;
|
|
41
|
+
readonly F4: 115;
|
|
42
|
+
readonly F5: 116;
|
|
43
|
+
readonly F6: 117;
|
|
44
|
+
readonly F7: 118;
|
|
45
|
+
readonly F8: 119;
|
|
46
|
+
readonly F9: 120;
|
|
47
|
+
readonly F10: 121;
|
|
48
|
+
readonly F11: 122;
|
|
49
|
+
readonly F12: 123;
|
|
50
|
+
readonly NumLock: 144;
|
|
51
|
+
readonly ScrollLock: 145;
|
|
52
|
+
readonly BackSlash: 220;
|
|
53
|
+
readonly Slash: 191;
|
|
54
|
+
readonly BracketRight: 221;
|
|
55
|
+
readonly BracketLeft: 219;
|
|
56
|
+
/** Android/IME composition key - used when virtual keyboards send composite input */
|
|
57
|
+
readonly Composition: 229;
|
|
58
|
+
};
|
|
59
|
+
export type KeyCodes = typeof KeyCodes[keyof typeof KeyCodes];
|
|
60
|
+
export declare const MouseButtonCodes: {
|
|
61
|
+
readonly Left: 1;
|
|
62
|
+
readonly Middle: 2;
|
|
63
|
+
readonly Right: 3;
|
|
64
|
+
};
|
|
65
|
+
export type MouseButtonCodes = typeof MouseButtonCodes[keyof typeof MouseButtonCodes];
|
|
66
|
+
export interface TextSelectionRange {
|
|
67
|
+
start: number;
|
|
68
|
+
end: number;
|
|
69
|
+
direction?: 'forward' | 'backward' | 'none';
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=Types.d.ts.map
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
export declare const focusableNodeNames: Set<string>;
|
|
2
|
+
export declare const EmptyCssProperties: React.CSSProperties;
|
|
3
|
+
/**
|
|
4
|
+
* Whether `el` is a DOM text-editable — a text `<input>`, a `<textarea>`, or a `contenteditable`. That
|
|
5
|
+
* is: "does the browser's native caret/clipboard apply here", which is the question both the
|
|
6
|
+
* **input-clipboard injector** (whose commands act on this element) and keystroke diagnostics ask. One
|
|
7
|
+
* definition, low in the stack, so the two can't drift.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isEditable(el: Element | null | undefined): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Replace `[start, end)` of a text field with `text` **as a user edit** — the browser records it on the
|
|
12
|
+
* element's own undo stack, and a native `input` event fires so a controlled React input picks it up.
|
|
13
|
+
*
|
|
14
|
+
* Any programmatic edit that goes around this (assigning `.value`, or pushing new text through React's
|
|
15
|
+
* controlled `value`) is invisible to the browser's undo history — and worse, assigning `.value`
|
|
16
|
+
* *clears* it. So a feature that rewrites the field's text on the user's behalf (paste-insert, the
|
|
17
|
+
* formula editor's F9) has to go through here, or the very next `ctrl+Z` does nothing (or something
|
|
18
|
+
* older and more surprising). This is the same undo stack the input-clipboard injector's `undo`/`redo`
|
|
19
|
+
* drive, which is what makes them one coherent history rather than two.
|
|
20
|
+
*
|
|
21
|
+
* `execCommand` is deprecated but is still the only API that writes to that history; `setRangeText` is
|
|
22
|
+
* the fallback for anywhere it isn't honored (it edits correctly, it just isn't undoable).
|
|
23
|
+
*
|
|
24
|
+
* @returns `false` if the element could not be edited at all.
|
|
25
|
+
*/
|
|
26
|
+
export declare function replaceRangeText(el: HTMLInputElement | HTMLTextAreaElement, start: number, end: number, text: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Re-export detectIt.
|
|
29
|
+
*
|
|
30
|
+
* @returns The `detect-it` library.
|
|
31
|
+
*/
|
|
32
|
+
export declare function detectIt(): {
|
|
33
|
+
supportsPassiveEvents: boolean;
|
|
34
|
+
supportsPointerEvents: boolean;
|
|
35
|
+
supportsTouchEvents: boolean;
|
|
36
|
+
deviceType: 'mouseOnly' | 'touchOnly' | 'hybrid';
|
|
37
|
+
primaryInput: 'mouse' | 'touch';
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* The current device pixel ratio (always `>= 1`). Safe to call outside the DOM.
|
|
41
|
+
*/
|
|
42
|
+
export declare function getDevicePixelRatio(): number;
|
|
43
|
+
/**
|
|
44
|
+
* Round a CSS stroke width to a whole number of device pixels (minimum 1 device
|
|
45
|
+
* pixel), returned in CSS pixels.
|
|
46
|
+
*
|
|
47
|
+
* A fractional device-pixel width (e.g. a 1px CSS stroke at a 1.5 dpr) cannot
|
|
48
|
+
* render crisply - the browser anti-aliases it, and the result drifts as the dpr
|
|
49
|
+
* changes. Rounding to whole device pixels keeps the stroke crisp at any dpr.
|
|
50
|
+
*/
|
|
51
|
+
export declare function snapDeviceWidth(cssWidth: number, dpr?: number): number;
|
|
52
|
+
/**
|
|
53
|
+
* Snap a CSS coordinate to a whole device-pixel boundary.
|
|
54
|
+
*
|
|
55
|
+
* Use for line endpoints and the edges of filled rectangles, so two shapes that
|
|
56
|
+
* share an edge resolve to the same device pixel (no seam, no overlap).
|
|
57
|
+
*/
|
|
58
|
+
export declare function snapDeviceEdge(cssPoint: number, dpr?: number): number;
|
|
59
|
+
/**
|
|
60
|
+
* Snap the CENTER of a stroke so it renders crisply for the given width.
|
|
61
|
+
*
|
|
62
|
+
* A stroke is crisp when both of its edges land on device-pixel boundaries. That
|
|
63
|
+
* requires an odd device-pixel width to be centered on a half device pixel, and
|
|
64
|
+
* an even width on a whole device pixel. Two layers that snap the same boundary
|
|
65
|
+
* coordinate with the same width resolve to the same device pixels, so they line
|
|
66
|
+
* up with each other (and stay aligned and crisp across device pixel ratios).
|
|
67
|
+
*
|
|
68
|
+
* This is the device-aware replacement for the former (no-op) `boundPixel`.
|
|
69
|
+
*
|
|
70
|
+
* @param cssCenter The desired stroke center, in CSS pixels.
|
|
71
|
+
* @param cssWidth The stroke width, in CSS pixels (used only for odd/even parity).
|
|
72
|
+
*/
|
|
73
|
+
export declare function snapLineCenter(cssCenter: number, cssWidth?: number, dpr?: number): number;
|
|
74
|
+
/**
|
|
75
|
+
* Which side of a divider an edge belongs to. `leading` = left/top, `trailing` =
|
|
76
|
+
* right/bottom. Determines outward growth for even-width strokes (see {@link edgeCenter}).
|
|
77
|
+
*/
|
|
78
|
+
export type EdgeKind = 'leading' | 'trailing';
|
|
79
|
+
/**
|
|
80
|
+
* The CSS-pixel shift a stroke takes so it grows OUTWARD from its cell.
|
|
81
|
+
*
|
|
82
|
+
* Odd device widths are already centered (one device px each side of the divider) and
|
|
83
|
+
* never shift. Even device widths snap to a whole device pixel, where the centered
|
|
84
|
+
* result lands the extra pixel *before* the divider; a `trailing` edge then shifts +1
|
|
85
|
+
* device px so it sits *after* it (leading stays before). This is the only case that
|
|
86
|
+
* needs a tie-break.
|
|
87
|
+
*/
|
|
88
|
+
export declare function edgeTrailingShift(edge: EdgeKind, deviceWidth: number, dpr?: number): number;
|
|
89
|
+
/**
|
|
90
|
+
* The snapped CSS center a stroke of `deviceWidth` device px sits at for a boundary at
|
|
91
|
+
* `boundaryCss`, accounting for crisp parity ({@link snapLineCenter}) and edge-aware
|
|
92
|
+
* outward growth ({@link edgeTrailingShift}).
|
|
93
|
+
*
|
|
94
|
+
* This is the single placement rule shared by gridlines, cell borders, and range
|
|
95
|
+
* overlays - anything that calls it lands on the same device pixels and lines up.
|
|
96
|
+
*/
|
|
97
|
+
export declare function edgeCenter(boundaryCss: number, edge: EdgeKind, deviceWidth: number, dpr?: number): number;
|
|
98
|
+
export declare const toPrettyKeyCode: (key: string) => string;
|
|
99
|
+
/**
|
|
100
|
+
* Creates a React synthetic event from a native DOM event.
|
|
101
|
+
*
|
|
102
|
+
* @remarks
|
|
103
|
+
* This helper creates a synthetic event wrapper that mimics React's SyntheticEvent behavior,
|
|
104
|
+
* including proper type inference for specific event types (PointerEvent, MouseEvent, etc.).
|
|
105
|
+
*
|
|
106
|
+
* @template T - The element type (extends Element)
|
|
107
|
+
* @template E - The native event type (extends Event)
|
|
108
|
+
*
|
|
109
|
+
* @param event - The native DOM event to wrap
|
|
110
|
+
* @param currentTarget - Optional override for currentTarget (useful for portals/delegated events)
|
|
111
|
+
*
|
|
112
|
+
* @returns A React synthetic event with all standard properties and methods
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* // Basic usage
|
|
117
|
+
* const syntheticEvent = createSyntheticEvent<HTMLDivElement, PointerEvent>(nativePointerEvent);
|
|
118
|
+
*
|
|
119
|
+
* // With custom currentTarget (for portals)
|
|
120
|
+
* const syntheticEvent = createSyntheticEvent<HTMLDivElement, PointerEvent>(
|
|
121
|
+
* nativePointerEvent,
|
|
122
|
+
* portalElement
|
|
123
|
+
* );
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export declare const createSyntheticEvent: <T extends Element, E extends Event, R extends React.SyntheticEvent<T, E>>(event: E, currentTarget?: EventTarget & T) => R;
|
|
127
|
+
/**
|
|
128
|
+
* Finds the React 18/19 root element by walking up the DOM tree.
|
|
129
|
+
* React 18+ attaches event listeners to the root element passed to createRoot().
|
|
130
|
+
*
|
|
131
|
+
* @param element - Any element within the React tree
|
|
132
|
+
* @returns The React root element, or document.body as fallback
|
|
133
|
+
*/
|
|
134
|
+
//# sourceMappingURL=ReactUtils.d.ts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* React hook for controlling the Fullscreen API.
|
|
4
|
+
*
|
|
5
|
+
* Correctly handles restricted contexts such as iframes where
|
|
6
|
+
* `document.fullscreenEnabled` may be `true` but the Permissions Policy
|
|
7
|
+
* actually blocks the API. Detection is performed in order:
|
|
8
|
+
*
|
|
9
|
+
* 1. `document.permissionsPolicy?.allowsFeature('fullscreen')` (modern)
|
|
10
|
+
* 2. `document.featurePolicy?.allowsFeature('fullscreen')` (older Chrome)
|
|
11
|
+
* 3. `document.fullscreenEnabled` (fallback)
|
|
12
|
+
*
|
|
13
|
+
* If `requestFullscreen` throws a `TypeError` at runtime, `isFullscreenAvailable`
|
|
14
|
+
* is reactively set to `false` so the UI can hide or disable the button.
|
|
15
|
+
*/
|
|
16
|
+
interface UseFullscreenProps {
|
|
17
|
+
/** The element to make fullscreen. Defaults to `document.documentElement`. */
|
|
18
|
+
target?: RefObject<Element | null>;
|
|
19
|
+
/** Called whenever the fullscreen state changes. */
|
|
20
|
+
onChange?: (event: Event) => void;
|
|
21
|
+
/** Called when a fullscreen error occurs. */
|
|
22
|
+
onError?: (event: Event) => void;
|
|
23
|
+
/** Options forwarded to `requestFullscreen`. */
|
|
24
|
+
requestFullScreenOptions?: FullscreenOptions;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Controls the browser Fullscreen API for a target element.
|
|
28
|
+
*
|
|
29
|
+
* @param props - See {@link UseFullscreenProps}.
|
|
30
|
+
* @returns
|
|
31
|
+
* - `isFullscreenAvailable` — `true` when the current context permits fullscreen.
|
|
32
|
+
* - `isFullscreenEnabled` — `true` when an element is currently fullscreen.
|
|
33
|
+
* - `fullscreenElement` — The element that is currently fullscreen, or `null`.
|
|
34
|
+
* - `enableFullscreen` — Requests fullscreen on the target element.
|
|
35
|
+
* - `disableFullscreen` — Exits fullscreen.
|
|
36
|
+
* - `toggleFullscreen` — Toggles between fullscreen and normal.
|
|
37
|
+
*/
|
|
38
|
+
export declare function useFullscreen(props?: UseFullscreenProps): {
|
|
39
|
+
isFullscreenAvailable: boolean;
|
|
40
|
+
fullscreenElement: Element | null;
|
|
41
|
+
isFullscreenEnabled: boolean;
|
|
42
|
+
enableFullscreen: () => Promise<void>;
|
|
43
|
+
disableFullscreen: () => Promise<void>;
|
|
44
|
+
toggleFullscreen: () => Promise<void>;
|
|
45
|
+
};
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=useFullScreen.d.ts.map
|