@sheetxl/react 0.8.0-beta.6 → 0.8.0-beta.9
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/index.cjs +18 -17
- package/browser/cjs/xuAfpHmA2W4MFa_0.cjs +1 -0
- package/browser/esm/Dk6274Lic6AOmEAq.mjs +2624 -0
- package/browser/esm/index.mjs +6474 -4211
- package/licenses/dependencies.txt +0 -555
- package/node/esm/B-5p0wwNM6Y5jlI2.mjs +2624 -0
- package/node/esm/index.mjs +8166 -5896
- package/package.json +6 -7
- package/resources/locales/de/sheet.cmd.json +126 -20
- package/resources/locales/de/ui.msg.json +8 -0
- package/resources/locales/en/sheet.cmd.json +137 -19
- package/resources/locales/en/ui.msg.json +169 -0
- package/types/src/cell/CornerTriangle.d.ts +6 -0
- package/types/src/cell/OutlineButton.d.ts +123 -0
- package/types/src/cell/index.d.ts +1 -0
- package/types/src/checklist/ValueChecklist.d.ts +15 -3
- package/types/src/comment/CommentCardRequest.d.ts +94 -0
- package/types/src/comment/CommentUtils.d.ts +43 -0
- package/types/src/comment/index.d.ts +4 -0
- package/types/src/comment/useCommentThread.d.ts +37 -0
- package/types/src/comment/useSheetComments.d.ts +28 -0
- package/types/src/control/FormControlRenderers.d.ts +14 -0
- package/types/src/control/index.d.ts +2 -0
- package/types/src/frame/CommandContext.d.ts +27 -0
- package/types/src/index.d.ts +1 -0
- package/types/src/layer/CommentCardLayer.d.ts +45 -0
- package/types/src/layer/SheetHeaderCellLayer.d.ts +9 -0
- package/types/src/layer/SheetOutlineLayer.d.ts +40 -0
- package/types/src/layer/ValidationPromptLayer.d.ts +2 -2
- package/types/src/layer/index.d.ts +2 -0
- package/types/src/listener/useModelListener.d.ts +4 -4
- package/types/src/movable/IMovableArea.d.ts +25 -6
- package/types/src/movable/MovableAdornment.d.ts +20 -0
- package/types/src/movable/MovableControl.d.ts +32 -0
- package/types/src/movable/MovableFrame.d.ts +13 -15
- package/types/src/movable/MovableRenderers.d.ts +55 -0
- package/types/src/movable/RotateHandle.d.ts +29 -0
- package/types/src/movable/framePlacement.d.ts +29 -0
- package/types/src/movable/geometry.d.ts +51 -0
- package/types/src/movable/index.d.ts +1 -0
- package/types/src/shape/ShapeEditor.d.ts +16 -2
- package/types/src/shape/ShapeGallery.d.ts +16 -0
- package/types/src/shape/ShapeHandles.d.ts +28 -0
- package/types/src/shape/ShapeSVG.d.ts +24 -0
- package/types/src/shape/ShapeText.d.ts +17 -0
- package/types/src/shape/icons/ShapeIcons.d.ts +16 -0
- package/types/src/shape/icons/_ShapeIconPack.d.ts +4 -0
- package/types/src/shape/index.d.ts +3 -0
- package/types/src/shape/shapeFrame.d.ts +6 -0
- package/types/src/shape/shapeStyle.d.ts +31 -0
- package/types/src/sheet/ISheetElement.d.ts +16 -1
- package/types/src/sheet/SheetOutlineElement.d.ts +70 -0
- package/types/src/workbook/DefaultMovableRenderers.d.ts +2 -0
- package/browser/cjs/Bo9Kx3L_XQkGPBJ5.cjs +0 -1
- package/browser/cjs/Pl04-kDEQSO8_qFU.cjs +0 -156
- package/browser/esm/CFCvoIa_w1ERjvMW.mjs +0 -6286
- package/node/esm/B9g0FgUjU-KLHkGu.mjs +0 -9
- package/types/src/movable/MoveableBundle.d.ts +0 -4
|
@@ -74,6 +74,33 @@ export interface ResizeHeaderContext {
|
|
|
74
74
|
toUnits?(value: number): number;
|
|
75
75
|
toPixels?(value: number): number;
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* The one group a Show / Hide Detail command acts on, named by its summary header; without it the
|
|
79
|
+
* command acts on the selection.
|
|
80
|
+
*/
|
|
81
|
+
export interface OutlineTarget {
|
|
82
|
+
axis: IRange.Axis;
|
|
83
|
+
/** The summary row or column, zero-based. */
|
|
84
|
+
index: number;
|
|
85
|
+
}
|
|
86
|
+
/** A gutter button's press: expand (`show`) or collapse the group whose summary this is. */
|
|
87
|
+
export interface OutlineToggle extends OutlineTarget {
|
|
88
|
+
show: boolean;
|
|
89
|
+
}
|
|
90
|
+
/** The level a level button shows: `level` on `axis`. */
|
|
91
|
+
export interface OutlineLevel {
|
|
92
|
+
axis: IRange.Axis;
|
|
93
|
+
level: number;
|
|
94
|
+
}
|
|
95
|
+
/** The outline settings window's value. */
|
|
96
|
+
export interface OutlineSettings {
|
|
97
|
+
/** Summary rows below their details (else above). */
|
|
98
|
+
summaryBelow: boolean;
|
|
99
|
+
/** Summary columns to the right of their details (else to the left). */
|
|
100
|
+
summaryRight: boolean;
|
|
101
|
+
/** Apply the automatic outline styles. */
|
|
102
|
+
automaticStyles: boolean;
|
|
103
|
+
}
|
|
77
104
|
export interface NewTable {
|
|
78
105
|
ranges: ICellRanges;
|
|
79
106
|
hasHeader?: boolean;
|
package/types/src/index.d.ts
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ISheet } from '@sheetxl/sdk';
|
|
3
|
+
import { LayerProps } from '@sheetxl/grid-react';
|
|
4
|
+
import { CommentCardRenderProps } from '../comment/CommentCardRequest';
|
|
5
|
+
export interface CommentCardLayerProps extends Omit<LayerProps, 'children'> {
|
|
6
|
+
/** Class for the floated card container. */
|
|
7
|
+
className?: string;
|
|
8
|
+
/** Style for the floated card container. */
|
|
9
|
+
style?: React.CSSProperties;
|
|
10
|
+
/** The sheet whose threads are shown. */
|
|
11
|
+
sheet: ISheet;
|
|
12
|
+
/**
|
|
13
|
+
* Renders the card. The layer places it, keeps it open and keeps its keystrokes and presses from
|
|
14
|
+
* the grid; what it looks like is the renderer's.
|
|
15
|
+
*/
|
|
16
|
+
renderCard: (props: CommentCardRenderProps) => React.ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* The task pane that lists the sheet's threads. While it is the active pane the cards are shown
|
|
19
|
+
* there and this layer shows none.
|
|
20
|
+
* @defaultValue 'comments'
|
|
21
|
+
*/
|
|
22
|
+
paneKey?: string;
|
|
23
|
+
/** Gap (px) between the cell's right edge and the card. @defaultValue 18 */
|
|
24
|
+
offset?: number;
|
|
25
|
+
/** Dwell (ms) on a thread's cell before its card shows. @defaultValue 300 */
|
|
26
|
+
openDelay?: number;
|
|
27
|
+
/** Grace (ms) after leaving the cell and its card before the card hides. @defaultValue 250 */
|
|
28
|
+
closeDelay?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The **comment card** beside a cell — a {@link RangeFloatLayer} showing the thread of the cell the
|
|
32
|
+
* pointer rests on, and the card a command {@link requestCommentCard | asked for}: a draft on a
|
|
33
|
+
* cell with no thread, or the thread a command went to. Selecting a cell shows nothing by itself,
|
|
34
|
+
* as in Excel.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* A note has a box of its own and is not shown here. The card of a requested cell stays until the
|
|
38
|
+
* selection leaves the cell or the card is dismissed; a card that takes the focus is kept the same
|
|
39
|
+
* way, so a reply being typed does not close when the pointer wanders off.
|
|
40
|
+
*
|
|
41
|
+
* The float portals out of the pane, but React events still bubble through the React tree to the
|
|
42
|
+
* grid, so the layer stops the card's keystrokes, presses, clipboard and context-menu events there.
|
|
43
|
+
*/
|
|
44
|
+
export declare const CommentCardLayer: React.MemoExoticComponent<(props: CommentCardLayerProps) => React.JSX.Element>;
|
|
45
|
+
//# sourceMappingURL=CommentCardLayer.d.ts.map
|
|
@@ -8,6 +8,12 @@ export interface SheetHeaderCellLayerProps extends LayerProps {
|
|
|
8
8
|
header: ISheetHeader;
|
|
9
9
|
/** Per-header renderer (the sheet's `SheetHeaderRenderer` wrapping). */
|
|
10
10
|
renderCell: (props: CellRendererProps) => React.ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* A styling input the layer cannot watch itself: a new value busts the label cache. The header
|
|
13
|
+
* element passes its filtered runs' revision (a filter set or cleared may hide no row, so no
|
|
14
|
+
* size change repaints for it).
|
|
15
|
+
*/
|
|
16
|
+
invalidateToken?: unknown;
|
|
11
17
|
}
|
|
12
18
|
/**
|
|
13
19
|
* The header's cell layer.
|
|
@@ -20,6 +26,9 @@ export interface SheetHeaderCellLayerProps extends LayerProps {
|
|
|
20
26
|
* - **size change** (`onSizesChange`) — alters what is visible/labeled;
|
|
21
27
|
* - **selection change** — header labels are styled by selection (fill / weight / color), but the tiled
|
|
22
28
|
* `CellLayer` cache survives scroll, so it must be dropped when *this header's* selected runs change.
|
|
29
|
+
*
|
|
30
|
+
* A third comes from the owner as `invalidateToken`: the rows a filter holds a condition over (the blue
|
|
31
|
+
* row numbers), which the header element reads and the layer cannot.
|
|
23
32
|
* Gated on the runs {@link selectedRunsSignature} so it busts only when the styling would differ (not
|
|
24
33
|
* on every active-cell move, and never on scroll — there is no per-frame range work).
|
|
25
34
|
*
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { IRange, ISheet } from '@sheetxl/sdk';
|
|
3
|
+
import { LayerProps } from '@sheetxl/grid-react';
|
|
4
|
+
import { OutlineButtonProps } from '../cell/OutlineButton';
|
|
5
|
+
export interface SheetOutlineLayerProps extends LayerProps {
|
|
6
|
+
/** The sheet whose outline is drawn. */
|
|
7
|
+
sheet: ISheet;
|
|
8
|
+
/** Rows or columns. */
|
|
9
|
+
axis: IRange.Axis;
|
|
10
|
+
/** The lanes across the gutter: one per level, plus one. */
|
|
11
|
+
lanes: number;
|
|
12
|
+
/** Renders a group's collapse / expand button. Defaults to `OutlineButton`. */
|
|
13
|
+
renderButton?: (props: OutlineButtonProps) => React.ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* The space around the buttons, in pixels: between neighbors, before the first and after the last.
|
|
16
|
+
*
|
|
17
|
+
* @defaultValue 1
|
|
18
|
+
*/
|
|
19
|
+
laneGap?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Space between a bracket's end and its button, in pixels.
|
|
22
|
+
*
|
|
23
|
+
* @defaultValue 0
|
|
24
|
+
*/
|
|
25
|
+
bracketGap?: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The outline gutter's layer: for each group in view, a bracket beside its details and a button on
|
|
29
|
+
* its summary that collapses or expands it; and beside each detail header a dot, as Excel draws.
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* Lane `level - 1` holds the groups of that level, outermost nearest the sheet edge. Groups come from
|
|
33
|
+
* {@link IOutline.getGroups} limited to the pane's visible span, so the work is per group in view. A
|
|
34
|
+
* collapsed group draws only its button. The dots are the gutter's cells: a {@link CellTileDiv} in
|
|
35
|
+
* this layer renders one per header the tiling engine finds in view, and a header at level `n` gets
|
|
36
|
+
* its dot in lane `n`, the lane after its deepest bracket, so a dot never sits on a line.
|
|
37
|
+
* Re-renders on scroll (the pane context) and on `onOutlineChange`.
|
|
38
|
+
*/
|
|
39
|
+
export declare const SheetOutlineLayer: React.MemoExoticComponent<(props: SheetOutlineLayerProps) => React.JSX.Element>;
|
|
40
|
+
//# sourceMappingURL=SheetOutlineLayer.d.ts.map
|
|
@@ -25,7 +25,7 @@ export interface ValidationPromptLayerProps extends Omit<LayerProps, 'children'>
|
|
|
25
25
|
style?: React.CSSProperties;
|
|
26
26
|
/** The sheet whose selection is followed. */
|
|
27
27
|
sheet: ISheet;
|
|
28
|
-
/** Gap (px) between the cell's bottom edge and the prompt. @defaultValue
|
|
28
|
+
/** Gap (px) between the cell's bottom edge and the prompt. @defaultValue 4 */
|
|
29
29
|
offset?: number;
|
|
30
30
|
/**
|
|
31
31
|
* Render the prompt yourself. Spread `floatProps` on the returned element. Omit for the default
|
|
@@ -35,7 +35,7 @@ export interface ValidationPromptLayerProps extends Omit<LayerProps, 'children'>
|
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* The **input prompt** of a data validation — a {@link RangeFloatLayer} activated by the selection,
|
|
38
|
-
* placed under the selected cell (or its merge)
|
|
38
|
+
* placed under the selected cell (or its merge), starting at its horizontal midpoint.
|
|
39
39
|
*
|
|
40
40
|
* @remarks
|
|
41
41
|
* Shows the title and message of the first covering rule that has a prompt to show
|
|
@@ -10,6 +10,7 @@ export * from './SheetColumnButtonLayer';
|
|
|
10
10
|
export * from './SheetGridLineLayer';
|
|
11
11
|
export * from './SheetBackgroundLayer';
|
|
12
12
|
export * from './SheetHeaderCellLayer';
|
|
13
|
+
export * from './SheetOutlineLayer';
|
|
13
14
|
export * from './SheetMovableLayer';
|
|
14
15
|
export * from './TableLayer';
|
|
15
16
|
export * from './SheetTableCommandLayer';
|
|
@@ -23,6 +24,7 @@ export * from './ValidationPromptLayer';
|
|
|
23
24
|
export * from './useValidationPicker';
|
|
24
25
|
export * from './CircularIndicatorLayer';
|
|
25
26
|
export * from './CommentsLayer';
|
|
27
|
+
export * from './CommentCardLayer';
|
|
26
28
|
export * from './ProtectionLayer';
|
|
27
29
|
export * from './HeaderSelectionLayer';
|
|
28
30
|
export * from './HeaderResizerLayer';
|
|
@@ -28,7 +28,7 @@ export interface ModelListenerOptions extends Omit<IListener.Options, 'once'> {
|
|
|
28
28
|
* @template SOURCE - The model type (e.g., IWorkbook, ISheet)
|
|
29
29
|
* @template EVENTS - The listener interface type (e.g., ISheet.IListeners)
|
|
30
30
|
*
|
|
31
|
-
* @param source - The model instance to listen to
|
|
31
|
+
* @param source - The model instance to listen to, or `null` to listen to nothing
|
|
32
32
|
* @param listeners - Object containing listener callbacks for various events
|
|
33
33
|
* @param options - Optional configuration
|
|
34
34
|
*
|
|
@@ -56,12 +56,12 @@ export interface ModelListenerOptions extends Omit<IListener.Options, 'once'> {
|
|
|
56
56
|
* }
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
|
-
export declare const useModelListener: <SOURCE, EVENTS>(source: IListener.ISource<SOURCE
|
|
59
|
+
export declare const useModelListener: <SOURCE, EVENTS>(source: IListener.ISource<SOURCE> | null | undefined, listeners: IListener.Callbacks<SOURCE, EVENTS>, options?: ModelListenerOptions) => void;
|
|
60
60
|
/**
|
|
61
61
|
* Used for syncing with model state that causes a rerenders.
|
|
62
62
|
*
|
|
63
|
-
* @param source The source of the model
|
|
63
|
+
* @param source The source of the model, or `null` to listen to nothing.
|
|
64
64
|
* @param eventNames The name of the event or events to listen for.
|
|
65
65
|
*/
|
|
66
|
-
export declare function useModelSync<EVENTS>(source: IListener.ISource<any
|
|
66
|
+
export declare function useModelSync<EVENTS>(source: IListener.ISource<any> | null | undefined, eventNames: keyof EVENTS | Array<keyof EVENTS>): void;
|
|
67
67
|
//# sourceMappingURL=useModelListener.d.ts.map
|
|
@@ -3,18 +3,27 @@ import { IMovable } from '@sheetxl/sdk';
|
|
|
3
3
|
* Props a movable renderer receives from its frame.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
-
* Spread `style` onto the root element. It
|
|
7
|
-
* its hit-testing: the frame itself is pointer-transparent, so
|
|
8
|
-
* default, `'none'` while the frame is hidden) is what makes the
|
|
9
|
-
* is not solid — a no-fill shape — overrides it with `'none'` on
|
|
10
|
-
* back on its painted parts only (e.g. `visibleStroke` on an SVG
|
|
11
|
-
* interior reaches the cell beneath, exactly as in Excel.
|
|
6
|
+
* Spread `style` onto the root element. It fills the frame, which owns the drawing's bounds (zoom
|
|
7
|
+
* included), AND carries its hit-testing: the frame itself is pointer-transparent, so
|
|
8
|
+
* `style.pointerEvents` (`'auto'` by default, `'none'` while the frame is hidden) is what makes the
|
|
9
|
+
* drawing clickable. A drawing that is not solid — a no-fill shape — overrides it with `'none'` on
|
|
10
|
+
* its root and sets `pointerEvents` back on its painted parts only (e.g. `visibleStroke` on an SVG
|
|
11
|
+
* path), so a click in its unfilled interior reaches the cell beneath, exactly as in Excel.
|
|
12
|
+
*
|
|
13
|
+
* The drawing never sizes itself. `zoom` is given only so that it can scale what it draws inside
|
|
14
|
+
* the frame (text, borders, padding), for example with the CSS `zoom` property; a drawing that
|
|
15
|
+
* stretches to its box, such as a picture, ignores it.
|
|
12
16
|
*/
|
|
13
17
|
export interface MovableElementProps extends React.HTMLAttributes<HTMLElement> {
|
|
14
18
|
/**
|
|
15
19
|
* The movable associated with this element.
|
|
16
20
|
*/
|
|
17
21
|
movable?: IMovable;
|
|
22
|
+
/**
|
|
23
|
+
* The scale of the view the movable is drawn in, where `1` is unscaled.
|
|
24
|
+
* @defaultValue 1
|
|
25
|
+
*/
|
|
26
|
+
zoom?: number;
|
|
18
27
|
/**
|
|
19
28
|
* Called when the movable is hidden from view.
|
|
20
29
|
*
|
|
@@ -38,6 +47,16 @@ export interface MovableElementProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
38
47
|
* box can drag from its border and put the caret where its text is pressed.
|
|
39
48
|
*/
|
|
40
49
|
onDragZone?: (isDragZone: (event: MouseEvent | TouchEvent) => boolean) => void;
|
|
50
|
+
/**
|
|
51
|
+
* A box above the selection chrome, placed and turned exactly as the frame is, for the content's
|
|
52
|
+
* own controls (a shape's adjustment handles). `null` when the movable has none.
|
|
53
|
+
*
|
|
54
|
+
* @remarks
|
|
55
|
+
* Render into it with a portal. It fills the frame's box and is pointer-transparent; controls opt
|
|
56
|
+
* back in. Drawn above the resize handles, so a control on the selection outline wins the press,
|
|
57
|
+
* as in Excel.
|
|
58
|
+
*/
|
|
59
|
+
adornmentHost?: HTMLElement | null;
|
|
41
60
|
/**
|
|
42
61
|
* If true then the component is disabled.
|
|
43
62
|
* @defaultValue false
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { IMovable } from '@sheetxl/sdk';
|
|
3
|
+
import { MovablePreview } from './framePlacement';
|
|
4
|
+
export interface MovableAdornmentProps {
|
|
5
|
+
movable: IMovable;
|
|
6
|
+
/** The gesture preview, as the frame is given it. */
|
|
7
|
+
preview?: MovablePreview | null;
|
|
8
|
+
/** Receives the box once mounted and `null` when it unmounts; the layer hands it to the content. */
|
|
9
|
+
onHost: (movable: IMovable, host: HTMLElement | null) => void;
|
|
10
|
+
/** The layer's own controls for the movable: its outline, resize and rotate handles. */
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The box a selected movable's controls are drawn in: placed and turned as its frame is, from the
|
|
15
|
+
* same numbers. The layer's controls come first and the content renders its own after them (see
|
|
16
|
+
* `MovableElementProps.adornmentHost`), so a content control is hit before a resize handle it
|
|
17
|
+
* overlaps.
|
|
18
|
+
*/
|
|
19
|
+
export declare const MovableAdornment: React.FC<MovableAdornmentProps>;
|
|
20
|
+
//# sourceMappingURL=MovableAdornment.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ResizeDirection } from './geometry';
|
|
3
|
+
/** The resize cursor for a handle on a frame turned `rotation` degrees, so it follows the turn. */
|
|
4
|
+
export declare const resizeCursor: (direction: ResizeDirection, rotation: number) => string;
|
|
5
|
+
export interface MovableControlProps {
|
|
6
|
+
/** Compass names of the handles to draw (`nw`, `n`, … `se`). */
|
|
7
|
+
directions: readonly string[];
|
|
8
|
+
/** Degrees clockwise the frame is turned; only the cursors use it, the box turns itself. */
|
|
9
|
+
rotation: number;
|
|
10
|
+
/**
|
|
11
|
+
* Fade the control, as during a gesture. It stays mounted: the handle being dragged holds the
|
|
12
|
+
* pointer capture.
|
|
13
|
+
*/
|
|
14
|
+
isDragging?: boolean;
|
|
15
|
+
/** A press on a handle. Return `false` to refuse the gesture. */
|
|
16
|
+
onResizeStart: () => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The pointer moved. `delta` is how far it is from the press, in screen pixels; `keepAspect` is
|
|
19
|
+
* whether Shift is held.
|
|
20
|
+
*/
|
|
21
|
+
onResize: (direction: ResizeDirection, delta: readonly [number, number], keepAspect: boolean) => void;
|
|
22
|
+
/** The pointer was released. */
|
|
23
|
+
onResizeEnd: () => void;
|
|
24
|
+
/** The gesture was lost (`pointercancel`). */
|
|
25
|
+
onResizeCancel: () => void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A selected movable's outline and resize handles, drawn in its adornment box so they are placed
|
|
29
|
+
* and turned from the same numbers as the frame. Each handle captures the pointer for its gesture.
|
|
30
|
+
*/
|
|
31
|
+
export declare const MovableControl: React.FC<MovableControlProps>;
|
|
32
|
+
//# sourceMappingURL=MovableControl.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { Bounds } from '@sheetxl/utils';
|
|
3
2
|
import { IMovable } from '@sheetxl/sdk';
|
|
4
3
|
import { MovableElementProps } from './IMovableArea';
|
|
4
|
+
import { MovablePreview } from './framePlacement';
|
|
5
5
|
export interface MovableFrameProps extends React.HTMLAttributes<HTMLElement> {
|
|
6
6
|
/**
|
|
7
7
|
* The underlying model for the chart.
|
|
@@ -18,26 +18,24 @@ export interface MovableFrameProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
18
18
|
onRefUnload: (ref: HTMLElement) => void;
|
|
19
19
|
onHide: (hide: (movable: IMovable) => boolean | Promise<boolean> | void) => void;
|
|
20
20
|
onShow: (show: (movable: IMovable) => void) => void;
|
|
21
|
-
/** {@inheritDoc MovableElementProps.
|
|
22
|
-
|
|
21
|
+
/** {@inheritDoc MovableElementProps.adornmentHost} */
|
|
22
|
+
adornmentHost?: HTMLElement | null;
|
|
23
23
|
/**
|
|
24
|
-
* Live drag/resize preview
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
24
|
+
* Live drag/resize/rotate preview, or null/undefined when idle. When set, the frame renders with it
|
|
25
|
+
* instead of the model (the model isn't touched until the gesture commits). Surface-scoped in the
|
|
26
|
+
* parent, so it's set in every pane — that's what makes a dragged shape appear, correctly clipped,
|
|
27
|
+
* on both sides of a freeze boundary.
|
|
28
28
|
*/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Called after the frame repositions (scroll, keyboard nudge, drag preview, resize). The parent uses
|
|
32
|
-
* it to re-sync the Moveable control box to the frame's new DOM rect — a nudge re-renders only this
|
|
33
|
-
* frame, not the parent, so the parent can't detect the move on its own.
|
|
34
|
-
*/
|
|
35
|
-
onReposition?: () => void;
|
|
29
|
+
preview?: MovablePreview | null;
|
|
36
30
|
/**
|
|
37
31
|
* Called when the final movable is unselected.
|
|
38
32
|
*/
|
|
39
33
|
onUnFocus: () => void;
|
|
40
|
-
|
|
34
|
+
/**
|
|
35
|
+
* A press that may move the frame, after it selected. Not called for a press outside the
|
|
36
|
+
* content's drag zone or in an editable element.
|
|
37
|
+
*/
|
|
38
|
+
dragStart(e: PointerEvent): void;
|
|
41
39
|
disabled?: boolean;
|
|
42
40
|
/**
|
|
43
41
|
* Indicates if the frame is being dragged. Useful for styling.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { IMovable } from '@sheetxl/sdk';
|
|
3
|
+
import { MovableElementProps } from './IMovableArea';
|
|
4
|
+
/**
|
|
5
|
+
* What a movable's renderer is given: the element props the movable layer hands every movable,
|
|
6
|
+
* with the movable itself always present.
|
|
7
|
+
*/
|
|
8
|
+
export interface MovableRendererProps extends MovableElementProps {
|
|
9
|
+
movable: IMovable;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Draws the content of one kind of movable (`IMovable.IContent.getType()`) inside the frame the
|
|
13
|
+
* movable layer gives it.
|
|
14
|
+
*/
|
|
15
|
+
export type MovableRenderer = React.ComponentType<MovableRendererProps>;
|
|
16
|
+
/**
|
|
17
|
+
* Resolves a renderer, as a dynamic `import()` does. Called the first time a movable of the kind
|
|
18
|
+
* is drawn, never before, so a kind that never appears costs nothing.
|
|
19
|
+
*/
|
|
20
|
+
export type MovableRendererLoader = () => Promise<MovableRenderer>;
|
|
21
|
+
/**
|
|
22
|
+
* How a renderer is registered.
|
|
23
|
+
*/
|
|
24
|
+
export interface MovableRendererOptions {
|
|
25
|
+
/**
|
|
26
|
+
* What is drawn while the renderer loads.
|
|
27
|
+
* @defaultValue nothing — the movable's frame is there already.
|
|
28
|
+
*/
|
|
29
|
+
fallback?: React.ReactNode;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Registers the renderer for a kind of movable content, replacing the built-in one.
|
|
33
|
+
*
|
|
34
|
+
* @param type The content type (`picture`, `chart`, `shape`, `checkBox`, …), as registered with
|
|
35
|
+
* `MovableContentRegistry` in the SDK.
|
|
36
|
+
* @param load Resolves the renderer when first needed.
|
|
37
|
+
* @returns A function that removes the registration.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* registerMovableRenderer('map', () => import('./MapRenderer').then((module) => module.MapRenderer));
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function registerMovableRenderer(type: string, load: MovableRendererLoader, options?: MovableRendererOptions): () => void;
|
|
45
|
+
/**
|
|
46
|
+
* The renderer for a kind of movable content: the registered one, else the built-in one, else
|
|
47
|
+
* `undefined`.
|
|
48
|
+
*/
|
|
49
|
+
export declare function getMovableRenderer(type: string): ((props: MovableRendererProps) => React.ReactElement) | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Registers a built-in renderer. A registered renderer always wins over it.
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
export declare function registerBuiltInMovableRenderer(type: string, load: MovableRendererLoader, options?: MovableRendererOptions): void;
|
|
55
|
+
//# sourceMappingURL=MovableRenderers.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface RotateHandleProps {
|
|
3
|
+
/**
|
|
4
|
+
* Fade the handle, as during any gesture. It stays mounted: while it turns the frame it holds
|
|
5
|
+
* the pointer capture.
|
|
6
|
+
*/
|
|
7
|
+
isDragging?: boolean;
|
|
8
|
+
/** A press on the handle. Return `false` to refuse the gesture. */
|
|
9
|
+
onStart: () => boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The pointer moved: `degrees` is the angle swept about the frame's center since the press,
|
|
12
|
+
* clockwise; `snap` is whether the rotation should snap (Shift).
|
|
13
|
+
*/
|
|
14
|
+
onRotate: (degrees: number, snap: boolean) => void;
|
|
15
|
+
/** The pointer was released. */
|
|
16
|
+
onEnd: () => void;
|
|
17
|
+
/** The gesture was lost (`pointercancel`). */
|
|
18
|
+
onCancel: () => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The handle that turns a selected frame, drawn in its adornment box above the top edge so it
|
|
22
|
+
* turns with the frame. Its size and offset are set by the movable layer's stylesheet.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* The angle is measured about the center of the adornment box, which is the frame's center at any
|
|
26
|
+
* rotation. The pointer is captured for the gesture, so it keeps rotating outside the handle.
|
|
27
|
+
*/
|
|
28
|
+
export declare const RotateHandle: React.FC<RotateHandleProps>;
|
|
29
|
+
//# sourceMappingURL=RotateHandle.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Bounds } from '@sheetxl/utils';
|
|
2
|
+
import { IMovable } from '@sheetxl/sdk';
|
|
3
|
+
import { IGridPane } from '@sheetxl/grid-react';
|
|
4
|
+
/** Where a movable's frame sits in a pane: its pane box and its turn about the box's center. */
|
|
5
|
+
export interface FramePlacement {
|
|
6
|
+
left: number;
|
|
7
|
+
top: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
/** Degrees, clockwise. */
|
|
11
|
+
rotation: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* An in-flight gesture's view of one movable, drawn in place of the model until the gesture
|
|
15
|
+
* commits. What it leaves out is read from the model.
|
|
16
|
+
*/
|
|
17
|
+
export interface MovablePreview {
|
|
18
|
+
/** The unrotated frame, absolute. */
|
|
19
|
+
bounds?: Bounds;
|
|
20
|
+
/** Degrees, clockwise. */
|
|
21
|
+
rotation?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The placement of a movable's frame in `pane`, from the drag preview when there is one, else the
|
|
25
|
+
* model. The frame and everything drawn in register with it (adornments) use this, so they cannot
|
|
26
|
+
* disagree.
|
|
27
|
+
*/
|
|
28
|
+
export declare const framePlacement: (movable: IMovable, pane: IGridPane, preview?: MovablePreview | null) => FramePlacement;
|
|
29
|
+
//# sourceMappingURL=framePlacement.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Bounds } from '@sheetxl/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Which handle a resize drags, per axis: `-1` the left or top edge, `1` the right or bottom edge,
|
|
4
|
+
* `0` neither (an edge handle on the other axis).
|
|
5
|
+
*/
|
|
6
|
+
export type ResizeDirection = readonly [number, number];
|
|
7
|
+
/**
|
|
8
|
+
* The frame after dragging a resize handle, with the opposite edge or corner held still on screen.
|
|
9
|
+
*
|
|
10
|
+
* @param start - The unrotated frame when the drag started.
|
|
11
|
+
* @param direction - The handle being dragged.
|
|
12
|
+
* @param dist - How much the frame has grown along its own (unrotated) axes, positive when larger,
|
|
13
|
+
* whichever side is dragged. An axis the handle does not drag is ignored.
|
|
14
|
+
* @param rotation - Degrees clockwise the frame is turned about its center.
|
|
15
|
+
* @param keepAspect - Keep `start`'s aspect ratio. Only a corner drag keeps it.
|
|
16
|
+
* @returns The unrotated frame, turned by `rotation` about its own center like `start`.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* A size is never negative: a frame dragged past its opposite edge stops there.
|
|
20
|
+
*/
|
|
21
|
+
export declare const resizeFrame: (start: Bounds, direction: ResizeDirection, dist: readonly [number, number], rotation: number, keepAspect: boolean) => Bounds;
|
|
22
|
+
/**
|
|
23
|
+
* How much a resize handle's drag grows its frame, the `dist` that `resizeFrame` takes.
|
|
24
|
+
*
|
|
25
|
+
* @param direction - The handle being dragged.
|
|
26
|
+
* @param delta - How far the pointer is from the press, on screen.
|
|
27
|
+
* @param rotation - Degrees clockwise the frame is turned about its center.
|
|
28
|
+
* @returns The growth along the frame's own axes, positive when larger.
|
|
29
|
+
*/
|
|
30
|
+
export declare const resizeGrowth: (direction: ResizeDirection, delta: readonly [number, number], rotation: number) => [number, number];
|
|
31
|
+
/** The step a rotation snaps to while Shift is held, in degrees. */
|
|
32
|
+
export declare const ROTATION_SNAP = 15;
|
|
33
|
+
/**
|
|
34
|
+
* A rotation in `[0, 360)`, optionally snapped to the nearest multiple of `snap` degrees.
|
|
35
|
+
*/
|
|
36
|
+
export declare const normalizeRotation: (degrees: number, snap?: number) => number;
|
|
37
|
+
/**
|
|
38
|
+
* The angle, in degrees clockwise on screen, a pointer has swept about `center` since `press`,
|
|
39
|
+
* in `(-180, 180]`.
|
|
40
|
+
*/
|
|
41
|
+
export declare const sweptAngle: (center: {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
}, press: {
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
}, pointer: {
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
}) => number;
|
|
51
|
+
//# sourceMappingURL=geometry.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
import { IShape } from '@sheetxl/sdk';
|
|
2
3
|
import { MovableElementProps } from '../movable';
|
|
3
4
|
export interface ShapeEditorAttributes {
|
|
4
5
|
isShapeEditor: () => true;
|
|
@@ -6,11 +7,24 @@ export interface ShapeEditorAttributes {
|
|
|
6
7
|
export interface IShapeEditorElement extends HTMLDivElement, ShapeEditorAttributes {
|
|
7
8
|
}
|
|
8
9
|
export interface ShapeEditorProps extends MovableElementProps {
|
|
9
|
-
shape:
|
|
10
|
+
shape: IShape;
|
|
11
|
+
/**
|
|
12
|
+
* Draws the geometry's text rectangle and connection sites over the shape.
|
|
13
|
+
* @defaultValue false
|
|
14
|
+
*/
|
|
15
|
+
debugGeometry?: boolean;
|
|
10
16
|
ref?: React.Ref<IShapeEditorElement>;
|
|
11
17
|
}
|
|
12
18
|
/**
|
|
13
|
-
*
|
|
19
|
+
* A shape in the sheet: its geometry as one SVG that fills the movable's frame, its text at the
|
|
20
|
+
* geometry's text rectangle, and its adjustment handles while it is selected.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* The frame owns position, size and zoom; the drawing is a `viewBox` of the movable's unzoomed
|
|
24
|
+
* bounds stretched to fill it, so a resize re-evaluates the geometry (adjust values are ratios,
|
|
25
|
+
* and the shape stretches as it does in Excel) and zoom thickens lines as Excel's does. A group
|
|
26
|
+
* draws its members in one SVG, each in its own style. A custom geometry is evaluated like a
|
|
27
|
+
* preset, from the definition the file states.
|
|
14
28
|
*/
|
|
15
29
|
export declare const ShapeEditor: React.NamedExoticComponent<Omit<ShapeEditorProps, "ref"> & React.RefAttributes<IShapeEditorElement>>;
|
|
16
30
|
//# sourceMappingURL=ShapeEditor.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One section of the Insert > Shapes gallery: its heading and its presets in display order, each
|
|
3
|
+
* with the message key of its name.
|
|
4
|
+
*/
|
|
5
|
+
export interface ShapeGalleryCategory {
|
|
6
|
+
key: string;
|
|
7
|
+
label: string;
|
|
8
|
+
presets: readonly (readonly [preset: string, label: string])[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The Insert > Shapes gallery: Excel's sections, order and names. A curated subset of the presets
|
|
12
|
+
* (Excel's gallery leaves out some, such as `gear6` and the action buttons); every preset still has
|
|
13
|
+
* an icon in the `shape` pack.
|
|
14
|
+
*/
|
|
15
|
+
export declare const ShapeGallery: readonly ShapeGalleryCategory[];
|
|
16
|
+
//# sourceMappingURL=ShapeGallery.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { IGeometry } from '@sheetxl/sdk';
|
|
3
|
+
export type HandleDragPhase = 'move' | 'end' | 'cancel';
|
|
4
|
+
export interface ShapeHandlesProps {
|
|
5
|
+
/** The handles' positions, in the shape's frame. */
|
|
6
|
+
handles: readonly IGeometry.IHandle[];
|
|
7
|
+
/** The shape's frame: the overlay's `viewBox`, so a handle lands exactly on the geometry. */
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
/** Device px per shape px, for a handle that stays the same size on screen at any zoom. */
|
|
11
|
+
zoom: number;
|
|
12
|
+
/**
|
|
13
|
+
* A handle being dragged: its index and where the pointer is, in the shape's frame. `'move'`
|
|
14
|
+
* while the pointer moves, `'end'` when it is released there, `'cancel'` when the drag is lost.
|
|
15
|
+
*/
|
|
16
|
+
onDrag: (index: number, x: number, y: number, phase: HandleDragPhase) => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The adjustment handles of a selected shape, drawn over its geometry in the same `viewBox`.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* Pointer positions are mapped through the overlay's own screen matrix, which folds in the
|
|
23
|
+
* frame's size, the view's zoom and any rotation, so a drag reads in shape-local px however the
|
|
24
|
+
* frame is placed. The overlay itself is pointer-transparent; only the dots take presses, which
|
|
25
|
+
* do not bubble to the frame as a move.
|
|
26
|
+
*/
|
|
27
|
+
export declare const ShapeHandles: React.FC<ShapeHandlesProps>;
|
|
28
|
+
//# sourceMappingURL=ShapeHandles.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { IGeometry, IResource, IStyleCollection } from '@sheetxl/sdk';
|
|
3
|
+
import { ResolvedShapeStyle } from './shapeStyle';
|
|
4
|
+
/** `pointer-events` for a drawn part: hit where painted, or not at all while the frame is hidden. */
|
|
5
|
+
export type PartHit = 'visiblePainted' | 'none';
|
|
6
|
+
/** A URL an `<image>` can load a resource from: its external URI, or its bytes as a data URL. */
|
|
7
|
+
export declare const resourceUrl: (resource: IResource) => Promise<string>;
|
|
8
|
+
export interface ShapePathsProps {
|
|
9
|
+
geometry: IGeometry;
|
|
10
|
+
/** The shape's own style, for paths that belong to no group member. */
|
|
11
|
+
style: ResolvedShapeStyle;
|
|
12
|
+
/** What a group member's style and a picture's image resolve against. */
|
|
13
|
+
styles: IStyleCollection | null;
|
|
14
|
+
/** The images the shape's JSON names, by resource id (`IShape.getResource`). */
|
|
15
|
+
getResource?: (resourceId: number) => IResource | null;
|
|
16
|
+
zoom: number;
|
|
17
|
+
hit: PartHit;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Everything a geometry draws: a shape's paths in its style, or a group's members, each placed
|
|
21
|
+
* and in its own style.
|
|
22
|
+
*/
|
|
23
|
+
export declare const ShapePaths: React.FC<ShapePathsProps>;
|
|
24
|
+
//# sourceMappingURL=ShapeSVG.d.ts.map
|