@rowsncolumns/spreadsheet 10.2.73 → 10.2.75
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/dist/cjs/api/evaluate-formula.d.ts +17 -0
- package/dist/cjs/api/evaluate-formula.d.ts.map +1 -0
- package/dist/cjs/api/evaluate-formula.js +141 -0
- package/dist/cjs/api/excel-validation-kinds.d.ts +71 -0
- package/dist/cjs/api/excel-validation-kinds.d.ts.map +1 -0
- package/dist/cjs/api/excel-validation-kinds.js +304 -0
- package/dist/cjs/api/go-to-special.d.ts +32 -0
- package/dist/cjs/api/go-to-special.d.ts.map +1 -0
- package/dist/cjs/api/go-to-special.js +111 -0
- package/dist/cjs/api/go-to.d.ts +19 -0
- package/dist/cjs/api/go-to.d.ts.map +1 -0
- package/dist/cjs/api/go-to.js +49 -0
- package/dist/cjs/api/validation-tooltip.d.ts +17 -0
- package/dist/cjs/api/validation-tooltip.d.ts.map +1 -0
- package/dist/cjs/api/validation-tooltip.js +42 -0
- package/dist/cjs/atoms/advanced-filter-dialog.atom.d.ts +28 -0
- package/dist/cjs/atoms/advanced-filter-dialog.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/advanced-filter-dialog.atom.js +32 -0
- package/dist/cjs/atoms/evaluate-formula-dialog.atom.d.ts +36 -0
- package/dist/cjs/atoms/evaluate-formula-dialog.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/evaluate-formula-dialog.atom.js +36 -0
- package/dist/cjs/atoms/go-to-dialog.atom.d.ts +46 -0
- package/dist/cjs/atoms/go-to-dialog.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/go-to-dialog.atom.js +34 -0
- package/dist/cjs/atoms/goal-seek-dialog.atom.d.ts +29 -0
- package/dist/cjs/atoms/goal-seek-dialog.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/goal-seek-dialog.atom.js +30 -0
- package/dist/cjs/atoms/index.d.ts +5 -0
- package/dist/cjs/atoms/index.d.ts.map +1 -1
- package/dist/cjs/atoms/index.js +5 -0
- package/dist/cjs/atoms/paste-special-dialog.atom.d.ts +29 -0
- package/dist/cjs/atoms/paste-special-dialog.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/paste-special-dialog.atom.js +34 -0
- package/dist/cjs/atoms/remove-duplicates-dialog.atom.d.ts +45 -0
- package/dist/cjs/atoms/remove-duplicates-dialog.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/remove-duplicates-dialog.atom.js +37 -0
- package/dist/cjs/atoms/subtotal-dialog.atom.d.ts +39 -0
- package/dist/cjs/atoms/subtotal-dialog.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/subtotal-dialog.atom.js +30 -0
- package/dist/cjs/atoms/text-to-columns-dialog.atom.d.ts +34 -0
- package/dist/cjs/atoms/text-to-columns-dialog.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/text-to-columns-dialog.atom.js +36 -0
- package/dist/cjs/atoms/watch-window.atom.d.ts +37 -0
- package/dist/cjs/atoms/watch-window.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/watch-window.atom.js +61 -0
- package/dist/cjs/components/advanced-filter-dialog/index.d.ts +28 -0
- package/dist/cjs/components/advanced-filter-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/advanced-filter-dialog/index.js +134 -0
- package/dist/cjs/components/calculation-options-dialog/index.d.ts +33 -0
- package/dist/cjs/components/calculation-options-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/calculation-options-dialog/index.js +69 -0
- package/dist/cjs/components/canvas-grid/index.d.ts.map +1 -1
- package/dist/cjs/components/canvas-grid/index.js +208 -19
- package/dist/cjs/components/canvas-grid/typings.d.ts +72 -9
- package/dist/cjs/components/canvas-grid/typings.d.ts.map +1 -1
- package/dist/cjs/components/cell/alignment.d.ts +30 -0
- package/dist/cjs/components/cell/alignment.d.ts.map +1 -1
- package/dist/cjs/components/cell/alignment.js +56 -1
- package/dist/cjs/components/cell/index.d.ts.map +1 -1
- package/dist/cjs/components/cell/index.js +15 -7
- package/dist/cjs/components/cell-diff/index.d.ts +3 -2
- package/dist/cjs/components/cell-diff/index.d.ts.map +1 -1
- package/dist/cjs/components/cell-editor/index.d.ts.map +1 -1
- package/dist/cjs/components/cell-editor/index.js +2 -1
- package/dist/cjs/components/context-menu/index.d.ts +21 -3
- package/dist/cjs/components/context-menu/index.d.ts.map +1 -1
- package/dist/cjs/components/context-menu/index.js +256 -6
- package/dist/cjs/components/context-menu/total-row-functions.d.ts +32 -0
- package/dist/cjs/components/context-menu/total-row-functions.d.ts.map +1 -0
- package/dist/cjs/components/context-menu/total-row-functions.js +62 -0
- package/dist/cjs/components/embeds/embed-component.d.ts.map +1 -1
- package/dist/cjs/components/embeds/embed-component.js +16 -1
- package/dist/cjs/components/evaluate-formula-dialog/index.d.ts +34 -0
- package/dist/cjs/components/evaluate-formula-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/evaluate-formula-dialog/index.js +106 -0
- package/dist/cjs/components/go-to-dialog/index.d.ts +45 -0
- package/dist/cjs/components/go-to-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/go-to-dialog/index.js +136 -0
- package/dist/cjs/components/goal-seek-dialog/index.d.ts +32 -0
- package/dist/cjs/components/goal-seek-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/goal-seek-dialog/index.js +149 -0
- package/dist/cjs/components/paste-special-dialog/index.d.ts +29 -0
- package/dist/cjs/components/paste-special-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/paste-special-dialog/index.js +99 -0
- package/dist/cjs/components/remove-duplicates-dialog/index.d.ts +37 -0
- package/dist/cjs/components/remove-duplicates-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/remove-duplicates-dialog/index.js +91 -0
- package/dist/cjs/components/subtotal-dialog/index.d.ts +30 -0
- package/dist/cjs/components/subtotal-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/subtotal-dialog/index.js +126 -0
- package/dist/cjs/components/text-to-columns-dialog/index.d.ts +37 -0
- package/dist/cjs/components/text-to-columns-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/text-to-columns-dialog/index.js +166 -0
- package/dist/cjs/components/toolbar/background-color-selector.d.ts +13 -1
- package/dist/cjs/components/toolbar/background-color-selector.d.ts.map +1 -1
- package/dist/cjs/components/toolbar/background-color-selector.js +57 -11
- package/dist/cjs/components/toolbar/cell-style-selector.d.ts +15 -2
- package/dist/cjs/components/toolbar/cell-style-selector.d.ts.map +1 -1
- package/dist/cjs/components/toolbar/cell-style-selector.js +56 -3
- package/dist/cjs/components/toolbar/fill-selectors.d.ts +49 -0
- package/dist/cjs/components/toolbar/fill-selectors.d.ts.map +1 -0
- package/dist/cjs/components/toolbar/fill-selectors.js +196 -0
- package/dist/cjs/components/toolbar/index.d.ts +2 -0
- package/dist/cjs/components/toolbar/index.d.ts.map +1 -1
- package/dist/cjs/components/toolbar/index.js +2 -0
- package/dist/cjs/components/toolbar/text-horizontal-align-selector.d.ts +8 -0
- package/dist/cjs/components/toolbar/text-horizontal-align-selector.d.ts.map +1 -1
- package/dist/cjs/components/toolbar/text-horizontal-align-selector.js +23 -4
- package/dist/cjs/components/toolbar/text-rotation-selector.d.ts +29 -0
- package/dist/cjs/components/toolbar/text-rotation-selector.d.ts.map +1 -0
- package/dist/cjs/components/toolbar/text-rotation-selector.js +78 -0
- package/dist/cjs/components/toolbar/text-wrap-selector.d.ts +7 -1
- package/dist/cjs/components/toolbar/text-wrap-selector.d.ts.map +1 -1
- package/dist/cjs/components/toolbar/text-wrap-selector.js +10 -3
- package/dist/cjs/components/watch-window/index.d.ts +25 -0
- package/dist/cjs/components/watch-window/index.d.ts.map +1 -0
- package/dist/cjs/components/watch-window/index.js +63 -0
- package/dist/cjs/hooks/use-cell-renderer.d.ts.map +1 -1
- package/dist/cjs/hooks/use-cell-renderer.js +17 -6
- package/dist/cjs/hooks/use-copy-paste-cut.d.ts +20 -1
- package/dist/cjs/hooks/use-copy-paste-cut.d.ts.map +1 -1
- package/dist/cjs/hooks/use-copy-paste-cut.js +25 -20
- package/dist/cjs/hooks/use-get-tooltip.d.ts.map +1 -1
- package/dist/cjs/hooks/use-get-tooltip.js +7 -2
- package/dist/cjs/hooks/use-keyboard-handler.d.ts +17 -2
- package/dist/cjs/hooks/use-keyboard-handler.d.ts.map +1 -1
- package/dist/cjs/hooks/use-keyboard-handler.js +206 -31
- package/dist/cjs/index.d.ts +14 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +15 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/cjs/types.d.ts +289 -4
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/types.js +19 -1
- package/dist/esm/api/evaluate-formula.d.ts +17 -0
- package/dist/esm/api/evaluate-formula.d.ts.map +1 -0
- package/dist/esm/api/evaluate-formula.js +109 -0
- package/dist/esm/api/excel-validation-kinds.d.ts +71 -0
- package/dist/esm/api/excel-validation-kinds.d.ts.map +1 -0
- package/dist/esm/api/excel-validation-kinds.js +287 -0
- package/dist/esm/api/go-to-special.d.ts +32 -0
- package/dist/esm/api/go-to-special.d.ts.map +1 -0
- package/dist/esm/api/go-to-special.js +96 -0
- package/dist/esm/api/go-to.d.ts +19 -0
- package/dist/esm/api/go-to.d.ts.map +1 -0
- package/dist/esm/api/go-to.js +41 -0
- package/dist/esm/api/validation-tooltip.d.ts +17 -0
- package/dist/esm/api/validation-tooltip.d.ts.map +1 -0
- package/dist/esm/api/validation-tooltip.js +34 -0
- package/dist/esm/atoms/advanced-filter-dialog.atom.d.ts +28 -0
- package/dist/esm/atoms/advanced-filter-dialog.atom.d.ts.map +1 -0
- package/dist/esm/atoms/advanced-filter-dialog.atom.js +21 -0
- package/dist/esm/atoms/evaluate-formula-dialog.atom.d.ts +36 -0
- package/dist/esm/atoms/evaluate-formula-dialog.atom.d.ts.map +1 -0
- package/dist/esm/atoms/evaluate-formula-dialog.atom.js +25 -0
- package/dist/esm/atoms/go-to-dialog.atom.d.ts +46 -0
- package/dist/esm/atoms/go-to-dialog.atom.d.ts.map +1 -0
- package/dist/esm/atoms/go-to-dialog.atom.js +25 -0
- package/dist/esm/atoms/goal-seek-dialog.atom.d.ts +29 -0
- package/dist/esm/atoms/goal-seek-dialog.atom.d.ts.map +1 -0
- package/dist/esm/atoms/goal-seek-dialog.atom.js +21 -0
- package/dist/esm/atoms/index.d.ts +5 -0
- package/dist/esm/atoms/index.d.ts.map +1 -1
- package/dist/esm/atoms/index.js +5 -0
- package/dist/esm/atoms/paste-special-dialog.atom.d.ts +29 -0
- package/dist/esm/atoms/paste-special-dialog.atom.d.ts.map +1 -0
- package/dist/esm/atoms/paste-special-dialog.atom.js +25 -0
- package/dist/esm/atoms/remove-duplicates-dialog.atom.d.ts +45 -0
- package/dist/esm/atoms/remove-duplicates-dialog.atom.d.ts.map +1 -0
- package/dist/esm/atoms/remove-duplicates-dialog.atom.js +26 -0
- package/dist/esm/atoms/subtotal-dialog.atom.d.ts +39 -0
- package/dist/esm/atoms/subtotal-dialog.atom.d.ts.map +1 -0
- package/dist/esm/atoms/subtotal-dialog.atom.js +21 -0
- package/dist/esm/atoms/text-to-columns-dialog.atom.d.ts +34 -0
- package/dist/esm/atoms/text-to-columns-dialog.atom.d.ts.map +1 -0
- package/dist/esm/atoms/text-to-columns-dialog.atom.js +25 -0
- package/dist/esm/atoms/watch-window.atom.d.ts +37 -0
- package/dist/esm/atoms/watch-window.atom.d.ts.map +1 -0
- package/dist/esm/atoms/watch-window.atom.js +37 -0
- package/dist/esm/components/advanced-filter-dialog/index.d.ts +28 -0
- package/dist/esm/components/advanced-filter-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/advanced-filter-dialog/index.js +125 -0
- package/dist/esm/components/calculation-options-dialog/index.d.ts +33 -0
- package/dist/esm/components/calculation-options-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/calculation-options-dialog/index.js +61 -0
- package/dist/esm/components/canvas-grid/index.d.ts.map +1 -1
- package/dist/esm/components/canvas-grid/index.js +202 -19
- package/dist/esm/components/canvas-grid/typings.d.ts +72 -9
- package/dist/esm/components/canvas-grid/typings.d.ts.map +1 -1
- package/dist/esm/components/cell/alignment.d.ts +30 -0
- package/dist/esm/components/cell/alignment.d.ts.map +1 -1
- package/dist/esm/components/cell/alignment.js +51 -0
- package/dist/esm/components/cell/index.d.ts.map +1 -1
- package/dist/esm/components/cell/index.js +16 -8
- package/dist/esm/components/cell-diff/index.d.ts +3 -2
- package/dist/esm/components/cell-diff/index.d.ts.map +1 -1
- package/dist/esm/components/cell-editor/index.d.ts.map +1 -1
- package/dist/esm/components/cell-editor/index.js +2 -1
- package/dist/esm/components/context-menu/index.d.ts +21 -3
- package/dist/esm/components/context-menu/index.d.ts.map +1 -1
- package/dist/esm/components/context-menu/index.js +251 -9
- package/dist/esm/components/context-menu/total-row-functions.d.ts +32 -0
- package/dist/esm/components/context-menu/total-row-functions.d.ts.map +1 -0
- package/dist/esm/components/context-menu/total-row-functions.js +50 -0
- package/dist/esm/components/embeds/embed-component.d.ts.map +1 -1
- package/dist/esm/components/embeds/embed-component.js +17 -1
- package/dist/esm/components/evaluate-formula-dialog/index.d.ts +34 -0
- package/dist/esm/components/evaluate-formula-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/evaluate-formula-dialog/index.js +86 -0
- package/dist/esm/components/go-to-dialog/index.d.ts +45 -0
- package/dist/esm/components/go-to-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/go-to-dialog/index.js +124 -0
- package/dist/esm/components/goal-seek-dialog/index.d.ts +32 -0
- package/dist/esm/components/goal-seek-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/goal-seek-dialog/index.js +125 -0
- package/dist/esm/components/paste-special-dialog/index.d.ts +29 -0
- package/dist/esm/components/paste-special-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/paste-special-dialog/index.js +90 -0
- package/dist/esm/components/remove-duplicates-dialog/index.d.ts +37 -0
- package/dist/esm/components/remove-duplicates-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/remove-duplicates-dialog/index.js +82 -0
- package/dist/esm/components/subtotal-dialog/index.d.ts +30 -0
- package/dist/esm/components/subtotal-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/subtotal-dialog/index.js +115 -0
- package/dist/esm/components/text-to-columns-dialog/index.d.ts +37 -0
- package/dist/esm/components/text-to-columns-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/text-to-columns-dialog/index.js +147 -0
- package/dist/esm/components/toolbar/background-color-selector.d.ts +13 -1
- package/dist/esm/components/toolbar/background-color-selector.d.ts.map +1 -1
- package/dist/esm/components/toolbar/background-color-selector.js +61 -11
- package/dist/esm/components/toolbar/cell-style-selector.d.ts +15 -2
- package/dist/esm/components/toolbar/cell-style-selector.d.ts.map +1 -1
- package/dist/esm/components/toolbar/cell-style-selector.js +46 -2
- package/dist/esm/components/toolbar/fill-selectors.d.ts +49 -0
- package/dist/esm/components/toolbar/fill-selectors.d.ts.map +1 -0
- package/dist/esm/components/toolbar/fill-selectors.js +162 -0
- package/dist/esm/components/toolbar/index.d.ts +2 -0
- package/dist/esm/components/toolbar/index.d.ts.map +1 -1
- package/dist/esm/components/toolbar/index.js +2 -0
- package/dist/esm/components/toolbar/text-horizontal-align-selector.d.ts +8 -0
- package/dist/esm/components/toolbar/text-horizontal-align-selector.d.ts.map +1 -1
- package/dist/esm/components/toolbar/text-horizontal-align-selector.js +21 -5
- package/dist/esm/components/toolbar/text-rotation-selector.d.ts +29 -0
- package/dist/esm/components/toolbar/text-rotation-selector.d.ts.map +1 -0
- package/dist/esm/components/toolbar/text-rotation-selector.js +71 -0
- package/dist/esm/components/toolbar/text-wrap-selector.d.ts +7 -1
- package/dist/esm/components/toolbar/text-wrap-selector.d.ts.map +1 -1
- package/dist/esm/components/toolbar/text-wrap-selector.js +10 -3
- package/dist/esm/components/watch-window/index.d.ts +25 -0
- package/dist/esm/components/watch-window/index.d.ts.map +1 -0
- package/dist/esm/components/watch-window/index.js +54 -0
- package/dist/esm/hooks/use-cell-renderer.d.ts.map +1 -1
- package/dist/esm/hooks/use-cell-renderer.js +17 -6
- package/dist/esm/hooks/use-copy-paste-cut.d.ts +20 -1
- package/dist/esm/hooks/use-copy-paste-cut.d.ts.map +1 -1
- package/dist/esm/hooks/use-copy-paste-cut.js +8 -3
- package/dist/esm/hooks/use-get-tooltip.d.ts.map +1 -1
- package/dist/esm/hooks/use-get-tooltip.js +7 -2
- package/dist/esm/hooks/use-keyboard-handler.d.ts +17 -2
- package/dist/esm/hooks/use-keyboard-handler.d.ts.map +1 -1
- package/dist/esm/hooks/use-keyboard-handler.js +193 -31
- package/dist/esm/index.d.ts +14 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +13 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/types.d.ts +289 -4
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js +18 -0
- package/dist/spreadsheet.min.css +1 -1
- package/package.json +6 -6
|
@@ -11,24 +11,70 @@ var atoms_1 = require("../../atoms");
|
|
|
11
11
|
var config_1 = require("../../config");
|
|
12
12
|
var themes_1 = require("../../themes");
|
|
13
13
|
var color_selector_1 = require("./color-selector");
|
|
14
|
+
var fill_selectors_1 = require("./fill-selectors");
|
|
14
15
|
var BackgroundColorSelector = function (_a) {
|
|
15
|
-
var _b
|
|
16
|
-
var _e =
|
|
16
|
+
var _b, _c;
|
|
17
|
+
var _d = _a.color, color = _d === void 0 ? "transparent" : _d, _e = _a.theme, theme = _e === void 0 ? config_1.defaultSpreadsheetTheme : _e, onChange = _a.onChange, fill = _a.fill, onChangeFill = _a.onChangeFill, onAddUserDefinedColor = _a.onAddUserDefinedColor, userDefinedColors = _a.userDefinedColors, disabled = _a.disabled, _f = _a.ColorSelector, ColorSelectorComponent = _f === void 0 ? color_selector_1.ColorSelector : _f;
|
|
18
|
+
var _g = tslib_1.__read((0, react_2.useState)(false), 2), isOpen = _g[0], setIsOpen = _g[1];
|
|
17
19
|
var close = function () { return setIsOpen(false); };
|
|
18
20
|
var open = function () { return setIsOpen(true); };
|
|
19
21
|
var colorString = (0, themes_1.getStringifiedColor)(color, theme);
|
|
20
22
|
var focusSheet = (0, atoms_1.useFocusSheet)();
|
|
23
|
+
// The trigger underline previews the effective fill: gradient, then the
|
|
24
|
+
// pattern colour, then the solid colour.
|
|
25
|
+
var swatchStyle = (fill === null || fill === void 0 ? void 0 : fill.gradient)
|
|
26
|
+
? {
|
|
27
|
+
borderBottom: "4px solid transparent",
|
|
28
|
+
borderImage: "".concat((0, fill_selectors_1.gradientToCss)(fill.gradient), " 1"),
|
|
29
|
+
}
|
|
30
|
+
: {
|
|
31
|
+
borderBottom: "4px ".concat((fill === null || fill === void 0 ? void 0 : fill.fillPattern) &&
|
|
32
|
+
fill.fillPattern !== "none" &&
|
|
33
|
+
fill.foregroundColor
|
|
34
|
+
? (0, themes_1.getStringifiedColor)(fill.foregroundColor, theme)
|
|
35
|
+
: colorString, " solid"),
|
|
36
|
+
};
|
|
37
|
+
var solidPicker = (react_1.default.createElement(ColorSelectorComponent, { color: color, onChange: function (color) {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
// A solid pick replaces a gradient (Excel keeps them exclusive) and,
|
|
40
|
+
// with "No fill", clears the pattern too.
|
|
41
|
+
if (onChangeFill && ((fill === null || fill === void 0 ? void 0 : fill.gradient) || (!color && (fill === null || fill === void 0 ? void 0 : fill.fillPattern)))) {
|
|
42
|
+
onChangeFill({
|
|
43
|
+
backgroundColor: color,
|
|
44
|
+
fillPattern: color ? (_a = fill === null || fill === void 0 ? void 0 : fill.fillPattern) !== null && _a !== void 0 ? _a : undefined : undefined,
|
|
45
|
+
foregroundColor: color
|
|
46
|
+
? (_b = fill === null || fill === void 0 ? void 0 : fill.foregroundColor) !== null && _b !== void 0 ? _b : undefined
|
|
47
|
+
: undefined,
|
|
48
|
+
gradient: undefined,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(color);
|
|
53
|
+
}
|
|
54
|
+
focusSheet === null || focusSheet === void 0 ? void 0 : focusSheet();
|
|
55
|
+
close();
|
|
56
|
+
}, theme: theme, resetButtonTitle: "No fill", userDefinedColors: userDefinedColors, onAddUserDefinedColor: onAddUserDefinedColor }));
|
|
57
|
+
var applyFill = function (next) {
|
|
58
|
+
onChangeFill === null || onChangeFill === void 0 ? void 0 : onChangeFill(next);
|
|
59
|
+
focusSheet === null || focusSheet === void 0 ? void 0 : focusSheet();
|
|
60
|
+
};
|
|
21
61
|
return (react_1.default.createElement(ui_1.Popover, { modal: false, open: isOpen, onOpenChange: setIsOpen },
|
|
22
62
|
react_1.default.createElement(ui_1.PopoverTrigger, { asChild: true },
|
|
23
|
-
react_1.default.createElement(ui_2.IconButton, { className: "text-base flex-row", style:
|
|
24
|
-
borderBottom: "4px ".concat(colorString, " solid"),
|
|
25
|
-
}, tooltip: "Fill color", onClick: open, disabled: disabled },
|
|
63
|
+
react_1.default.createElement(ui_2.IconButton, { className: "text-base flex-row", style: swatchStyle, tooltip: "Fill color", "aria-label": "Fill color", onClick: open, disabled: disabled },
|
|
26
64
|
react_1.default.createElement(icons_1.IoMdColorFill, null))),
|
|
27
|
-
react_1.default.createElement(ui_1.PopoverContent, { align: "start" },
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
65
|
+
react_1.default.createElement(ui_1.PopoverContent, { align: "start" }, onChangeFill ? (react_1.default.createElement(ui_2.Tabs, { defaultValue: (fill === null || fill === void 0 ? void 0 : fill.gradient)
|
|
66
|
+
? "gradient"
|
|
67
|
+
: (fill === null || fill === void 0 ? void 0 : fill.fillPattern) && fill.fillPattern !== "none"
|
|
68
|
+
? "pattern"
|
|
69
|
+
: "solid" },
|
|
70
|
+
react_1.default.createElement(ui_2.TabsList, { className: "grid-cols-3 mb-2" },
|
|
71
|
+
react_1.default.createElement(ui_2.TabsTrigger, { value: "solid" }, "Solid"),
|
|
72
|
+
react_1.default.createElement(ui_2.TabsTrigger, { value: "pattern" }, "Pattern"),
|
|
73
|
+
react_1.default.createElement(ui_2.TabsTrigger, { value: "gradient" }, "Gradient")),
|
|
74
|
+
react_1.default.createElement(ui_2.TabsContent, { value: "solid" }, solidPicker),
|
|
75
|
+
react_1.default.createElement(ui_2.TabsContent, { value: "pattern" },
|
|
76
|
+
react_1.default.createElement(fill_selectors_1.PatternFillPicker, { fill: tslib_1.__assign(tslib_1.__assign({}, fill), { backgroundColor: (_b = fill === null || fill === void 0 ? void 0 : fill.backgroundColor) !== null && _b !== void 0 ? _b : color }), theme: theme, onChangeFill: applyFill })),
|
|
77
|
+
react_1.default.createElement(ui_2.TabsContent, { value: "gradient" },
|
|
78
|
+
react_1.default.createElement(fill_selectors_1.GradientFillPicker, { fill: tslib_1.__assign(tslib_1.__assign({}, fill), { backgroundColor: (_c = fill === null || fill === void 0 ? void 0 : fill.backgroundColor) !== null && _c !== void 0 ? _c : color }), theme: theme, onChangeFill: applyFill })))) : (solidPicker))));
|
|
33
79
|
};
|
|
34
80
|
exports.BackgroundColorSelector = BackgroundColorSelector;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { CellFormat } from "../../types";
|
|
2
|
+
import type { CellFormat, NamedCellStyle } from "../../types";
|
|
3
3
|
import type { SpreadsheetTheme } from "../canvas-grid/typings";
|
|
4
4
|
type WithCellFormat = (value: CellFormat) => void;
|
|
5
5
|
type WithTypeValue<T extends keyof CellFormat> = (type: T, value: CellFormat[T]) => void;
|
|
@@ -8,6 +8,13 @@ export type CellStyleSelectorProps = {
|
|
|
8
8
|
locale?: string;
|
|
9
9
|
theme: SpreadsheetTheme;
|
|
10
10
|
userDefinedStyles?: [string, CellFormat][];
|
|
11
|
+
/**
|
|
12
|
+
* Workbook named cell styles imported from `<cellStyles>` ("Heading 1",
|
|
13
|
+
* "Good", "Accent 1", …). Shown as a "Workbook styles" section ahead of
|
|
14
|
+
* the built-in gallery; hidden entries and the "Normal" base style are
|
|
15
|
+
* skipped, as is any entry whose xf resolved to no formatting.
|
|
16
|
+
*/
|
|
17
|
+
namedCellStyles?: NamedCellStyle[] | null;
|
|
11
18
|
selectedFormat?: CellFormat | null;
|
|
12
19
|
onAddUserDefinedStyle?(name: string): void;
|
|
13
20
|
onChangeFormatting: (...args: Parameters<WithCellFormat | WithTypeValue<keyof CellFormat>>) => void;
|
|
@@ -19,7 +26,13 @@ type StyleList = [
|
|
|
19
26
|
format: CellFormat,
|
|
20
27
|
style?: React.CSSProperties
|
|
21
28
|
];
|
|
29
|
+
/** Named styles worth showing in the gallery (see `namedCellStyles` prop). */
|
|
30
|
+
export declare const getGalleryNamedCellStyles: (namedCellStyles: NamedCellStyle[] | null | undefined) => Array<NamedCellStyle & {
|
|
31
|
+
format: CellFormat;
|
|
32
|
+
}>;
|
|
33
|
+
/** CSS preview of a named style's format for the gallery swatch. */
|
|
34
|
+
export declare const getNamedCellStylePreview: (format: CellFormat | undefined, theme: SpreadsheetTheme) => React.CSSProperties;
|
|
22
35
|
export declare const getCellStyles: (theme: SpreadsheetTheme, currencySymbol?: string) => Map<string, StyleList[]>;
|
|
23
|
-
export declare const CellStyleSelector: React.MemoExoticComponent<({ currency, locale, theme, selectedFormat, canAddCustomStyle, onChangeFormatting, onClearFormatting, }: CellStyleSelectorProps) => React.JSX.Element>;
|
|
36
|
+
export declare const CellStyleSelector: React.MemoExoticComponent<({ currency, locale, theme, selectedFormat, namedCellStyles, canAddCustomStyle, onChangeFormatting, onClearFormatting, }: CellStyleSelectorProps) => React.JSX.Element>;
|
|
24
37
|
export {};
|
|
25
38
|
//# sourceMappingURL=cell-style-selector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell-style-selector.d.ts","sourceRoot":"","sources":["../../../../components/toolbar/cell-style-selector.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAgC,MAAM,OAAO,CAAC;AAMrD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"cell-style-selector.d.ts","sourceRoot":"","sources":["../../../../components/toolbar/cell-style-selector.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAgC,MAAM,OAAO,CAAC;AAMrD,OAAO,KAAK,EACV,UAAU,EAEV,cAAc,EAEf,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,KAAK,cAAc,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;AAClD,KAAK,aAAa,CAAC,CAAC,SAAS,MAAM,UAAU,IAAI,CAC/C,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,KACjB,IAAI,CAAC;AAEV,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,gBAAgB,CAAC;IACxB,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,CAAC;IAC3C;;;;;OAKG;IACH,eAAe,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IAC1C,cAAc,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IACnC,qBAAqB,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C,kBAAkB,EAAE,CAClB,GAAG,IAAI,EAAE,UAAU,CAAC,cAAc,GAAG,aAAa,CAAC,MAAM,UAAU,CAAC,CAAC,KAClE,IAAI,CAAC;IACV,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,EAAE,MAAM,IAAI,CAAC;CAC/B,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,UAAU;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa;CAC5B,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,yBAAyB,GACpC,iBAAiB,cAAc,EAAE,GAAG,IAAI,GAAG,SAAS,KACnD,KAAK,CAAC,cAAc,GAAG;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,CAQ7C,CAAC;AAcJ,oEAAoE;AACpE,eAAO,MAAM,wBAAwB,GACnC,QAAQ,UAAU,GAAG,SAAS,EAC9B,OAAO,gBAAgB,KACtB,KAAK,CAAC,aAqBR,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,OAAO,gBAAgB,EACvB,iBAAiB,MAAM,6BAgYxB,CAAC;AAEF,eAAO,MAAM,iBAAiB,sJAUzB,sBAAsB,uBAsO1B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CellStyleSelector = exports.getCellStyles = void 0;
|
|
3
|
+
exports.CellStyleSelector = exports.getCellStyles = exports.getNamedCellStylePreview = exports.getGalleryNamedCellStyles = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var icons_1 = require("@rowsncolumns/icons");
|
|
6
6
|
var icons_2 = require("@rowsncolumns/icons");
|
|
@@ -12,6 +12,54 @@ var react_1 = tslib_1.__importStar(require("react"));
|
|
|
12
12
|
var atoms_1 = require("../../atoms");
|
|
13
13
|
var helpers_1 = require("../../helpers");
|
|
14
14
|
var themes_1 = require("../../themes");
|
|
15
|
+
/** Named styles worth showing in the gallery (see `namedCellStyles` prop). */
|
|
16
|
+
var getGalleryNamedCellStyles = function (namedCellStyles) {
|
|
17
|
+
return (namedCellStyles !== null && namedCellStyles !== void 0 ? namedCellStyles : []).filter(function (style) {
|
|
18
|
+
return !style.hidden &&
|
|
19
|
+
style.builtinId !== 0 &&
|
|
20
|
+
style.name !== "Normal" &&
|
|
21
|
+
!!style.format &&
|
|
22
|
+
Object.keys(style.format).length > 0;
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
exports.getGalleryNamedCellStyles = getGalleryNamedCellStyles;
|
|
26
|
+
var previewBorder = function (border, theme) {
|
|
27
|
+
var _a;
|
|
28
|
+
return border
|
|
29
|
+
? "".concat((_a = border.width) !== null && _a !== void 0 ? _a : 1, "px ").concat(border.style === "double" ? "double" : "solid", " ").concat((0, themes_1.getStringifiedColor)(border.color, theme))
|
|
30
|
+
: undefined;
|
|
31
|
+
};
|
|
32
|
+
/** CSS preview of a named style's format for the gallery swatch. */
|
|
33
|
+
var getNamedCellStylePreview = function (format, theme) {
|
|
34
|
+
if (!format)
|
|
35
|
+
return {};
|
|
36
|
+
var style = {};
|
|
37
|
+
if (format.backgroundColor) {
|
|
38
|
+
style.backgroundColor = (0, themes_1.getStringifiedColor)(format.backgroundColor, theme);
|
|
39
|
+
}
|
|
40
|
+
var text = format.textFormat;
|
|
41
|
+
if (text === null || text === void 0 ? void 0 : text.color)
|
|
42
|
+
style.color = (0, themes_1.getStringifiedColor)(text.color, theme);
|
|
43
|
+
if (text === null || text === void 0 ? void 0 : text.bold)
|
|
44
|
+
style.fontWeight = "bold";
|
|
45
|
+
if (text === null || text === void 0 ? void 0 : text.italic)
|
|
46
|
+
style.fontStyle = "italic";
|
|
47
|
+
if (text === null || text === void 0 ? void 0 : text.underline)
|
|
48
|
+
style.textDecoration = "underline";
|
|
49
|
+
if (text === null || text === void 0 ? void 0 : text.fontSize)
|
|
50
|
+
style.fontSize = text.fontSize;
|
|
51
|
+
if (text === null || text === void 0 ? void 0 : text.fontFamily)
|
|
52
|
+
style.fontFamily = text.fontFamily;
|
|
53
|
+
var borders = format.borders;
|
|
54
|
+
if (borders) {
|
|
55
|
+
style.borderTop = previewBorder(borders.top, theme);
|
|
56
|
+
style.borderBottom = previewBorder(borders.bottom, theme);
|
|
57
|
+
style.borderLeft = previewBorder(borders.left, theme);
|
|
58
|
+
style.borderRight = previewBorder(borders.right, theme);
|
|
59
|
+
}
|
|
60
|
+
return style;
|
|
61
|
+
};
|
|
62
|
+
exports.getNamedCellStylePreview = getNamedCellStylePreview;
|
|
15
63
|
var getCellStyles = function (theme, currencySymbol) {
|
|
16
64
|
return new Map([
|
|
17
65
|
[
|
|
@@ -389,13 +437,14 @@ var getCellStyles = function (theme, currencySymbol) {
|
|
|
389
437
|
};
|
|
390
438
|
exports.getCellStyles = getCellStyles;
|
|
391
439
|
exports.CellStyleSelector = (0, react_1.memo)(function (_a) {
|
|
392
|
-
var currency = _a.currency, locale = _a.locale, theme = _a.theme, selectedFormat = _a.selectedFormat, _b = _a.canAddCustomStyle, canAddCustomStyle = _b === void 0 ? false : _b, onChangeFormatting = _a.onChangeFormatting, onClearFormatting = _a.onClearFormatting;
|
|
440
|
+
var currency = _a.currency, locale = _a.locale, theme = _a.theme, selectedFormat = _a.selectedFormat, namedCellStyles = _a.namedCellStyles, _b = _a.canAddCustomStyle, canAddCustomStyle = _b === void 0 ? false : _b, onChangeFormatting = _a.onChangeFormatting, onClearFormatting = _a.onClearFormatting;
|
|
393
441
|
var colorIndexes = [4, 5, 6, 7, 8, 9];
|
|
394
442
|
var colorTints = [0.8, 0.6, 0.4, 0];
|
|
395
443
|
var currencySymbol = (0, helpers_1.getCurrencySymbol)(locale, currency);
|
|
396
444
|
var shouldFocusSheetRef = (0, react_1.useRef)(true);
|
|
397
445
|
var focusSheet = (0, atoms_1.useFocusSheet)();
|
|
398
446
|
var cellStyles = (0, react_1.useMemo)(function () { return tslib_1.__spreadArray([], tslib_1.__read((0, exports.getCellStyles)(theme, currencySymbol).entries()), false); }, [theme, currencySymbol]);
|
|
447
|
+
var workbookStyles = (0, react_1.useMemo)(function () { return (0, exports.getGalleryNamedCellStyles)(namedCellStyles); }, [namedCellStyles]);
|
|
399
448
|
// Number formats
|
|
400
449
|
var numberFormats = [
|
|
401
450
|
[
|
|
@@ -440,7 +489,7 @@ exports.CellStyleSelector = (0, react_1.memo)(function (_a) {
|
|
|
440
489
|
var gridClass = "grid grid-cols-3 md:grid-cols-6 gap-1 pb-1";
|
|
441
490
|
return (react_1.default.createElement(ui_2.DropdownMenu, { modal: false },
|
|
442
491
|
react_1.default.createElement(ui_2.DropdownMenuTrigger, { asChild: true },
|
|
443
|
-
react_1.default.createElement(ui_2.IconButton, { size: "xl", tooltip: "Cell styles", className: "gap-1" },
|
|
492
|
+
react_1.default.createElement(ui_2.IconButton, { size: "xl", tooltip: "Cell styles", "aria-label": "Cell styles", className: "gap-1" },
|
|
444
493
|
react_1.default.createElement(icons_2.MdBrush, null),
|
|
445
494
|
react_1.default.createElement("div", { className: "text-xs" }, "Cell styles"),
|
|
446
495
|
react_1.default.createElement(icons_1.MdOutlineArrowDropDown, null))),
|
|
@@ -454,6 +503,10 @@ exports.CellStyleSelector = (0, react_1.memo)(function (_a) {
|
|
|
454
503
|
shouldFocusSheetRef.current = false;
|
|
455
504
|
} },
|
|
456
505
|
react_1.default.createElement("div", { className: "max-w-dropdown md:min-w-[400px] p-2 pt-0" },
|
|
506
|
+
workbookStyles.length ? (react_1.default.createElement("div", null,
|
|
507
|
+
react_1.default.createElement("div", { className: headingClass }, "Workbook styles"),
|
|
508
|
+
react_1.default.createElement(ui_1.Separator, { className: "mb-2" }),
|
|
509
|
+
react_1.default.createElement("div", { className: gridClass }, workbookStyles.map(function (namedStyle) { return (react_1.default.createElement(ui_1.DropdownMenuItem, { onClick: function () { return onChangeFormatting(namedStyle.format); }, className: hoverClass, key: "".concat(namedStyle.name, "-").concat(namedStyle.xfId), style: (0, exports.getNamedCellStylePreview)(namedStyle.format, theme) }, namedStyle.name)); })))) : null,
|
|
457
510
|
cellStyles.map(function (_a) {
|
|
458
511
|
var _b = tslib_1.__read(_a, 2), category = _b[0], cellStyleList = _b[1];
|
|
459
512
|
return (react_1.default.createElement("div", { key: category },
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { CellFormat, FillPattern, GradientFill } from "../../types";
|
|
3
|
+
import type { SpreadsheetTheme } from "../canvas-grid/typings";
|
|
4
|
+
/** The fill-related slice of a cell format the fill popover authors. */
|
|
5
|
+
export type CellFill = Pick<CellFormat, "backgroundColor" | "fillPattern" | "foregroundColor" | "gradient">;
|
|
6
|
+
/** Excel's Format Cells → Fill → Pattern Style menu, in Excel's order. */
|
|
7
|
+
export declare const FILL_PATTERN_OPTIONS: ReadonlyArray<{
|
|
8
|
+
pattern: FillPattern;
|
|
9
|
+
label: string;
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Excel's Fill Effects → Shading styles. `degree` follows OOXML
|
|
13
|
+
* `<gradientFill degree>`: 0 runs left → right, 90 top → bottom.
|
|
14
|
+
*/
|
|
15
|
+
export declare const GRADIENT_PRESETS: ReadonlyArray<{
|
|
16
|
+
label: string;
|
|
17
|
+
gradient: Omit<GradientFill, "stops">;
|
|
18
|
+
}>;
|
|
19
|
+
/** Two-stop gradient from a preset and two colours. */
|
|
20
|
+
export declare const buildGradientFill: (preset: Omit<GradientFill, "stops">, color1: string, color2: string) => GradientFill;
|
|
21
|
+
/**
|
|
22
|
+
* CSS preview of a gradient fill. OOXML measures the linear angle from the
|
|
23
|
+
* left→right axis; CSS from the bottom→top axis, so CSS = degree + 90.
|
|
24
|
+
*/
|
|
25
|
+
export declare const gradientToCss: (gradient: GradientFill) => string;
|
|
26
|
+
export type PatternFillPickerProps = {
|
|
27
|
+
fill?: CellFill | null;
|
|
28
|
+
theme: SpreadsheetTheme;
|
|
29
|
+
onChangeFill(fill: CellFill): void;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Pattern fill authoring (Excel: Format Cells → Fill → Pattern Color /
|
|
33
|
+
* Pattern Style). The pattern paints in `foregroundColor` over the solid
|
|
34
|
+
* `backgroundColor`; a gradient on the cell is cleared, as Excel treats the
|
|
35
|
+
* two as exclusive.
|
|
36
|
+
*/
|
|
37
|
+
export declare const PatternFillPicker: ({ fill, theme, onChangeFill, }: PatternFillPickerProps) => React.JSX.Element;
|
|
38
|
+
export type GradientFillPickerProps = {
|
|
39
|
+
fill?: CellFill | null;
|
|
40
|
+
theme: SpreadsheetTheme;
|
|
41
|
+
onChangeFill(fill: CellFill): void;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Gradient fill authoring (Excel: Fill Effects → Gradient, two colours +
|
|
45
|
+
* shading style). Picking a style applies immediately with the two colours;
|
|
46
|
+
* changing a colour re-applies when the cell already has a gradient.
|
|
47
|
+
*/
|
|
48
|
+
export declare const GradientFillPicker: ({ fill, theme, onChangeFill, }: GradientFillPickerProps) => React.JSX.Element;
|
|
49
|
+
//# sourceMappingURL=fill-selectors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fill-selectors.d.ts","sourceRoot":"","sources":["../../../../components/toolbar/fill-selectors.tsx"],"names":[],"mappings":"AACA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAIjD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,wEAAwE;AACxE,MAAM,MAAM,QAAQ,GAAG,IAAI,CACzB,UAAU,EACV,iBAAiB,GAAG,aAAa,GAAG,iBAAiB,GAAG,UAAU,CACnE,CAAC;AAEF,0EAA0E;AAC1E,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC;IAC/C,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf,CAkBA,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;CACvC,CASA,CAAC;AAEF,uDAAuD;AACvD,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,EACnC,QAAQ,MAAM,EACd,QAAQ,MAAM,KACb,YAMD,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,UAAU,YAAY,KAAG,MAUtD,CAAC;AAqCF,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IACvB,KAAK,EAAE,gBAAgB,CAAC;IACxB,YAAY,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;CACpC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,gCAI/B,sBAAsB,sBA+ExB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IACvB,KAAK,EAAE,gBAAgB,CAAC;IACxB,YAAY,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;CACpC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,gCAIhC,uBAAuB,sBA8FzB,CAAC"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GradientFillPicker = exports.PatternFillPicker = exports.gradientToCss = exports.buildGradientFill = exports.GRADIENT_PRESETS = exports.FILL_PATTERN_OPTIONS = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var ui_1 = require("@rowsncolumns/ui");
|
|
6
|
+
var react_1 = tslib_1.__importStar(require("react"));
|
|
7
|
+
var fill_patterns_1 = require("../../api/fill-patterns");
|
|
8
|
+
var themes_1 = require("../../themes");
|
|
9
|
+
/** Excel's Format Cells → Fill → Pattern Style menu, in Excel's order. */
|
|
10
|
+
exports.FILL_PATTERN_OPTIONS = [
|
|
11
|
+
{ pattern: "gray0625", label: "6.25% Gray" },
|
|
12
|
+
{ pattern: "gray125", label: "12.5% Gray" },
|
|
13
|
+
{ pattern: "lightGray", label: "25% Gray" },
|
|
14
|
+
{ pattern: "mediumGray", label: "50% Gray" },
|
|
15
|
+
{ pattern: "darkGray", label: "75% Gray" },
|
|
16
|
+
{ pattern: "darkHorizontal", label: "Horizontal Stripe" },
|
|
17
|
+
{ pattern: "darkVertical", label: "Vertical Stripe" },
|
|
18
|
+
{ pattern: "darkDown", label: "Reverse Diagonal Stripe" },
|
|
19
|
+
{ pattern: "darkUp", label: "Diagonal Stripe" },
|
|
20
|
+
{ pattern: "darkGrid", label: "Diagonal Crosshatch" },
|
|
21
|
+
{ pattern: "darkTrellis", label: "Thick Diagonal Crosshatch" },
|
|
22
|
+
{ pattern: "lightHorizontal", label: "Thin Horizontal Stripe" },
|
|
23
|
+
{ pattern: "lightVertical", label: "Thin Vertical Stripe" },
|
|
24
|
+
{ pattern: "lightDown", label: "Thin Reverse Diagonal Stripe" },
|
|
25
|
+
{ pattern: "lightUp", label: "Thin Diagonal Stripe" },
|
|
26
|
+
{ pattern: "lightGrid", label: "Thin Horizontal Crosshatch" },
|
|
27
|
+
{ pattern: "lightTrellis", label: "Thin Diagonal Crosshatch" },
|
|
28
|
+
];
|
|
29
|
+
/**
|
|
30
|
+
* Excel's Fill Effects → Shading styles. `degree` follows OOXML
|
|
31
|
+
* `<gradientFill degree>`: 0 runs left → right, 90 top → bottom.
|
|
32
|
+
*/
|
|
33
|
+
exports.GRADIENT_PRESETS = [
|
|
34
|
+
{ label: "Horizontal", gradient: { type: "linear", degree: 90 } },
|
|
35
|
+
{ label: "Vertical", gradient: { type: "linear", degree: 0 } },
|
|
36
|
+
{ label: "Diagonal up", gradient: { type: "linear", degree: 45 } },
|
|
37
|
+
{ label: "Diagonal down", gradient: { type: "linear", degree: 135 } },
|
|
38
|
+
{
|
|
39
|
+
label: "From center",
|
|
40
|
+
gradient: { type: "path", left: 0.5, right: 0.5, top: 0.5, bottom: 0.5 },
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
/** Two-stop gradient from a preset and two colours. */
|
|
44
|
+
var buildGradientFill = function (preset, color1, color2) { return (tslib_1.__assign(tslib_1.__assign({}, preset), { stops: [
|
|
45
|
+
{ position: 0, color: color1 },
|
|
46
|
+
{ position: 1, color: color2 },
|
|
47
|
+
] })); };
|
|
48
|
+
exports.buildGradientFill = buildGradientFill;
|
|
49
|
+
/**
|
|
50
|
+
* CSS preview of a gradient fill. OOXML measures the linear angle from the
|
|
51
|
+
* left→right axis; CSS from the bottom→top axis, so CSS = degree + 90.
|
|
52
|
+
*/
|
|
53
|
+
var gradientToCss = function (gradient) {
|
|
54
|
+
var _a;
|
|
55
|
+
var stops = gradient.stops
|
|
56
|
+
.slice()
|
|
57
|
+
.sort(function (a, b) { return a.position - b.position; })
|
|
58
|
+
.map(function (stop) { return "".concat(stop.color, " ").concat(Math.round(stop.position * 100), "%"); })
|
|
59
|
+
.join(", ");
|
|
60
|
+
if (gradient.type === "path") {
|
|
61
|
+
return "radial-gradient(circle, ".concat(stops, ")");
|
|
62
|
+
}
|
|
63
|
+
return "linear-gradient(".concat((((_a = gradient.degree) !== null && _a !== void 0 ? _a : 0) + 90) % 360, "deg, ").concat(stops, ")");
|
|
64
|
+
};
|
|
65
|
+
exports.gradientToCss = gradientToCss;
|
|
66
|
+
var DEFAULT_PATTERN_COLOR = "#000000";
|
|
67
|
+
var PatternSwatch = function (_a) {
|
|
68
|
+
var pattern = _a.pattern, foregroundColor = _a.foregroundColor, backgroundColor = _a.backgroundColor, label = _a.label;
|
|
69
|
+
var url = (0, react_1.useMemo)(function () {
|
|
70
|
+
var _a;
|
|
71
|
+
var canvas = (0, fill_patterns_1.getPatternCanvas)(pattern, foregroundColor, backgroundColor);
|
|
72
|
+
try {
|
|
73
|
+
return (_a = canvas === null || canvas === void 0 ? void 0 : canvas.toDataURL()) !== null && _a !== void 0 ? _a : undefined;
|
|
74
|
+
}
|
|
75
|
+
catch (_b) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
}, [pattern, foregroundColor, backgroundColor]);
|
|
79
|
+
return (react_1.default.createElement("span", { "aria-hidden": "true", className: "block w-full h-full border border-solid border-rnc-border", style: url
|
|
80
|
+
? { backgroundImage: "url(".concat(url, ")"), backgroundRepeat: "repeat" }
|
|
81
|
+
: { backgroundColor: backgroundColor }, title: label }));
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Pattern fill authoring (Excel: Format Cells → Fill → Pattern Color /
|
|
85
|
+
* Pattern Style). The pattern paints in `foregroundColor` over the solid
|
|
86
|
+
* `backgroundColor`; a gradient on the cell is cleared, as Excel treats the
|
|
87
|
+
* two as exclusive.
|
|
88
|
+
*/
|
|
89
|
+
var PatternFillPicker = function (_a) {
|
|
90
|
+
var fill = _a.fill, theme = _a.theme, onChangeFill = _a.onChangeFill;
|
|
91
|
+
var background = (fill === null || fill === void 0 ? void 0 : fill.backgroundColor)
|
|
92
|
+
? (0, themes_1.getStringifiedColor)(fill.backgroundColor, theme)
|
|
93
|
+
: undefined;
|
|
94
|
+
var patternColor = (fill === null || fill === void 0 ? void 0 : fill.foregroundColor)
|
|
95
|
+
? (0, themes_1.getStringifiedColor)(fill.foregroundColor, theme)
|
|
96
|
+
: DEFAULT_PATTERN_COLOR;
|
|
97
|
+
var activePattern = (fill === null || fill === void 0 ? void 0 : fill.fillPattern) &&
|
|
98
|
+
fill.fillPattern !== "none" &&
|
|
99
|
+
fill.fillPattern !== "solid"
|
|
100
|
+
? fill.fillPattern
|
|
101
|
+
: undefined;
|
|
102
|
+
var apply = function (pattern, foregroundColor) {
|
|
103
|
+
var _a;
|
|
104
|
+
return onChangeFill({
|
|
105
|
+
backgroundColor: (_a = fill === null || fill === void 0 ? void 0 : fill.backgroundColor) !== null && _a !== void 0 ? _a : undefined,
|
|
106
|
+
fillPattern: pattern,
|
|
107
|
+
foregroundColor: pattern ? foregroundColor : undefined,
|
|
108
|
+
gradient: undefined,
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
return (react_1.default.createElement(ui_1.Stack, { direction: "vertical", className: "gap-1" },
|
|
112
|
+
react_1.default.createElement(ui_1.Button, { variant: "outline", size: "xs", tabIndex: -1, className: "justify-center py-1", onClick: function () { return apply(undefined, undefined); } }, "No pattern"),
|
|
113
|
+
react_1.default.createElement("div", { className: "pt-2 text-xs text-left" }, "Pattern style"),
|
|
114
|
+
react_1.default.createElement("div", { role: "group", "aria-label": "Pattern style", className: "grid grid-cols-6 gap-1" }, exports.FILL_PATTERN_OPTIONS.map(function (_a) {
|
|
115
|
+
var pattern = _a.pattern, label = _a.label;
|
|
116
|
+
return (react_1.default.createElement("button", { type: "button", key: pattern, "aria-label": label, "aria-pressed": activePattern === pattern, className: "w-6 h-6 p-0 border-2 border-solid rounded-sm bg-transparent cursor-pointer ".concat(activePattern === pattern
|
|
117
|
+
? "border-rnc-primary"
|
|
118
|
+
: "border-transparent"), onClick: function () {
|
|
119
|
+
return apply(pattern, (fill === null || fill === void 0 ? void 0 : fill.foregroundColor) ? patternColor : undefined);
|
|
120
|
+
} },
|
|
121
|
+
react_1.default.createElement(PatternSwatch, { pattern: pattern, foregroundColor: patternColor, backgroundColor: background, label: label })));
|
|
122
|
+
})),
|
|
123
|
+
react_1.default.createElement("div", { className: "pt-2 text-xs text-left" }, "Pattern color"),
|
|
124
|
+
react_1.default.createElement(ui_1.ColorPicker, { value: patternColor, colors: themes_1.STANDARD_COLORS, onChange: function (color) { return apply(activePattern !== null && activePattern !== void 0 ? activePattern : "darkGray", color); }, className: "gap-1" }),
|
|
125
|
+
react_1.default.createElement("div", { className: "flex items-center gap-1" },
|
|
126
|
+
react_1.default.createElement(ui_1.HexColorPicker, { value: patternColor, onChange: function (color) { return apply(activePattern !== null && activePattern !== void 0 ? activePattern : "darkGray", color); } }))));
|
|
127
|
+
};
|
|
128
|
+
exports.PatternFillPicker = PatternFillPicker;
|
|
129
|
+
/**
|
|
130
|
+
* Gradient fill authoring (Excel: Fill Effects → Gradient, two colours +
|
|
131
|
+
* shading style). Picking a style applies immediately with the two colours;
|
|
132
|
+
* changing a colour re-applies when the cell already has a gradient.
|
|
133
|
+
*/
|
|
134
|
+
var GradientFillPicker = function (_a) {
|
|
135
|
+
var _b;
|
|
136
|
+
var fill = _a.fill, theme = _a.theme, onChangeFill = _a.onChangeFill;
|
|
137
|
+
var existing = (_b = fill === null || fill === void 0 ? void 0 : fill.gradient) !== null && _b !== void 0 ? _b : undefined;
|
|
138
|
+
var _c = tslib_1.__read((0, react_1.useState)(function () {
|
|
139
|
+
var _a, _b, _c;
|
|
140
|
+
return (_c = (_b = (_a = existing === null || existing === void 0 ? void 0 : existing.stops) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.color) !== null && _c !== void 0 ? _c : ((fill === null || fill === void 0 ? void 0 : fill.backgroundColor)
|
|
141
|
+
? (0, themes_1.getStringifiedColor)(fill.backgroundColor, theme)
|
|
142
|
+
: "#FFFFFF");
|
|
143
|
+
}), 2), color1 = _c[0], setColor1 = _c[1];
|
|
144
|
+
var _d = tslib_1.__read((0, react_1.useState)(function () { var _a, _b, _c; return (_c = (_b = (_a = existing === null || existing === void 0 ? void 0 : existing.stops) === null || _a === void 0 ? void 0 : _a[existing.stops.length - 1]) === null || _b === void 0 ? void 0 : _b.color) !== null && _c !== void 0 ? _c : "#4472C4"; }), 2), color2 = _d[0], setColor2 = _d[1];
|
|
145
|
+
var apply = function (preset, c1, c2) {
|
|
146
|
+
if (c1 === void 0) { c1 = color1; }
|
|
147
|
+
if (c2 === void 0) { c2 = color2; }
|
|
148
|
+
return onChangeFill({
|
|
149
|
+
backgroundColor: undefined,
|
|
150
|
+
fillPattern: undefined,
|
|
151
|
+
foregroundColor: undefined,
|
|
152
|
+
gradient: (0, exports.buildGradientFill)(preset, c1, c2),
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
var reapply = function (c1, c2) {
|
|
156
|
+
if (!existing)
|
|
157
|
+
return;
|
|
158
|
+
var _stops = existing.stops, preset = tslib_1.__rest(existing, ["stops"]);
|
|
159
|
+
apply(preset, c1, c2);
|
|
160
|
+
};
|
|
161
|
+
var isActive = function (preset) {
|
|
162
|
+
var _a, _b;
|
|
163
|
+
return !!existing &&
|
|
164
|
+
existing.type === preset.type &&
|
|
165
|
+
(preset.type === "path" || ((_a = existing.degree) !== null && _a !== void 0 ? _a : 0) === ((_b = preset.degree) !== null && _b !== void 0 ? _b : 0));
|
|
166
|
+
};
|
|
167
|
+
return (react_1.default.createElement(ui_1.Stack, { direction: "vertical", className: "gap-1" },
|
|
168
|
+
react_1.default.createElement(ui_1.Button, { variant: "outline", size: "xs", tabIndex: -1, className: "justify-center py-1", onClick: function () {
|
|
169
|
+
var _a, _b, _c;
|
|
170
|
+
return onChangeFill({
|
|
171
|
+
backgroundColor: (_a = fill === null || fill === void 0 ? void 0 : fill.backgroundColor) !== null && _a !== void 0 ? _a : undefined,
|
|
172
|
+
fillPattern: (_b = fill === null || fill === void 0 ? void 0 : fill.fillPattern) !== null && _b !== void 0 ? _b : undefined,
|
|
173
|
+
foregroundColor: (_c = fill === null || fill === void 0 ? void 0 : fill.foregroundColor) !== null && _c !== void 0 ? _c : undefined,
|
|
174
|
+
gradient: undefined,
|
|
175
|
+
});
|
|
176
|
+
} }, "No gradient"),
|
|
177
|
+
react_1.default.createElement("div", { className: "grid grid-cols-[auto_1fr] items-center gap-2 pt-2 text-xs" },
|
|
178
|
+
react_1.default.createElement("span", null, "Color 1"),
|
|
179
|
+
react_1.default.createElement(ui_1.HexColorPicker, { value: color1, onChange: function (color) {
|
|
180
|
+
setColor1(color);
|
|
181
|
+
reapply(color, color2);
|
|
182
|
+
} }),
|
|
183
|
+
react_1.default.createElement("span", null, "Color 2"),
|
|
184
|
+
react_1.default.createElement(ui_1.HexColorPicker, { value: color2, onChange: function (color) {
|
|
185
|
+
setColor2(color);
|
|
186
|
+
reapply(color1, color);
|
|
187
|
+
} })),
|
|
188
|
+
react_1.default.createElement("div", { className: "pt-2 text-xs text-left" }, "Shading style"),
|
|
189
|
+
react_1.default.createElement("div", { role: "group", "aria-label": "Shading style", className: "grid grid-cols-5 gap-1" }, exports.GRADIENT_PRESETS.map(function (_a) {
|
|
190
|
+
var label = _a.label, gradient = _a.gradient;
|
|
191
|
+
return (react_1.default.createElement("button", { type: "button", key: label, "aria-label": label, "aria-pressed": isActive(gradient), className: "w-8 h-6 p-0 border-2 border-solid rounded-sm cursor-pointer ".concat(isActive(gradient) ? "border-rnc-primary" : "border-rnc-border"), style: {
|
|
192
|
+
backgroundImage: (0, exports.gradientToCss)((0, exports.buildGradientFill)(gradient, color1, color2)),
|
|
193
|
+
}, onClick: function () { return apply(gradient); } }));
|
|
194
|
+
}))));
|
|
195
|
+
};
|
|
196
|
+
exports.GradientFillPicker = GradientFillPicker;
|
|
@@ -4,12 +4,14 @@ export * from "./scale-selector";
|
|
|
4
4
|
export * from "./font-size-selector";
|
|
5
5
|
export * from "./text-color-selector";
|
|
6
6
|
export * from "./background-color-selector";
|
|
7
|
+
export * from "./fill-selectors";
|
|
7
8
|
export * from "./merge-cells-selector";
|
|
8
9
|
export * from "./border-selector";
|
|
9
10
|
export * from "./font-family-selector";
|
|
10
11
|
export * from "./text-horizontal-align-selector";
|
|
11
12
|
export * from "./text-vertical-align-selector";
|
|
12
13
|
export * from "./text-wrap-selector";
|
|
14
|
+
export * from "./text-rotation-selector";
|
|
13
15
|
export * from "./text-format-selector";
|
|
14
16
|
export * from "./theme-selector";
|
|
15
17
|
export * from "./table-actions";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/toolbar/index.tsx"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/toolbar/index.tsx"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
|
|
@@ -7,12 +7,14 @@ tslib_1.__exportStar(require("./scale-selector"), exports);
|
|
|
7
7
|
tslib_1.__exportStar(require("./font-size-selector"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./text-color-selector"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./background-color-selector"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./fill-selectors"), exports);
|
|
10
11
|
tslib_1.__exportStar(require("./merge-cells-selector"), exports);
|
|
11
12
|
tslib_1.__exportStar(require("./border-selector"), exports);
|
|
12
13
|
tslib_1.__exportStar(require("./font-family-selector"), exports);
|
|
13
14
|
tslib_1.__exportStar(require("./text-horizontal-align-selector"), exports);
|
|
14
15
|
tslib_1.__exportStar(require("./text-vertical-align-selector"), exports);
|
|
15
16
|
tslib_1.__exportStar(require("./text-wrap-selector"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./text-rotation-selector"), exports);
|
|
16
18
|
tslib_1.__exportStar(require("./text-format-selector"), exports);
|
|
17
19
|
tslib_1.__exportStar(require("./theme-selector"), exports);
|
|
18
20
|
tslib_1.__exportStar(require("./table-actions"), exports);
|
|
@@ -5,6 +5,14 @@ type TextHorizontalAlignSelectorProps = {
|
|
|
5
5
|
value: HorizontalAlign | undefined | null;
|
|
6
6
|
onChange(value: HorizontalAlign): void;
|
|
7
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* Excel's remaining Format Cells → Alignment → Horizontal entries. They have
|
|
10
|
+
* no toolbar glyph, so they render as labelled buttons under the icon row.
|
|
11
|
+
*/
|
|
12
|
+
export declare const EXTENDED_HORIZONTAL_ALIGNMENTS: ReadonlyArray<{
|
|
13
|
+
value: HorizontalAlign;
|
|
14
|
+
label: string;
|
|
15
|
+
}>;
|
|
8
16
|
export declare const TextHorizontalAlignSelector: ({ value, onChange, disabled, }: TextHorizontalAlignSelectorProps) => React.JSX.Element;
|
|
9
17
|
export {};
|
|
10
18
|
//# sourceMappingURL=text-horizontal-align-selector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-horizontal-align-selector.d.ts","sourceRoot":"","sources":["../../../../components/toolbar/text-horizontal-align-selector.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"text-horizontal-align-selector.d.ts","sourceRoot":"","sources":["../../../../components/toolbar/text-horizontal-align-selector.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,KAAK,gCAAgC,GAAG;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;CACxC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,8BAA8B,EAAE,aAAa,CAAC;IACzD,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf,CAGA,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,gCAIzC,gCAAgC,sBA6FlC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TextHorizontalAlignSelector = void 0;
|
|
3
|
+
exports.TextHorizontalAlignSelector = exports.EXTENDED_HORIZONTAL_ALIGNMENTS = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var icons_1 = require("@rowsncolumns/icons");
|
|
6
6
|
var ui_1 = require("@rowsncolumns/ui");
|
|
@@ -8,15 +8,28 @@ var ui_2 = require("@rowsncolumns/ui");
|
|
|
8
8
|
var ui_3 = require("@rowsncolumns/ui");
|
|
9
9
|
var react_1 = tslib_1.__importStar(require("react"));
|
|
10
10
|
var atoms_1 = require("../../atoms");
|
|
11
|
+
/**
|
|
12
|
+
* Excel's remaining Format Cells → Alignment → Horizontal entries. They have
|
|
13
|
+
* no toolbar glyph, so they render as labelled buttons under the icon row.
|
|
14
|
+
*/
|
|
15
|
+
exports.EXTENDED_HORIZONTAL_ALIGNMENTS = [
|
|
16
|
+
{ value: "distributed", label: "Distributed" },
|
|
17
|
+
{ value: "fill", label: "Fill" },
|
|
18
|
+
];
|
|
11
19
|
var TextHorizontalAlignSelector = function (_a) {
|
|
12
20
|
var _b = _a.value, value = _b === void 0 ? "left" : _b, onChange = _a.onChange, disabled = _a.disabled;
|
|
13
21
|
var focusSheet = (0, atoms_1.useFocusSheet)();
|
|
14
22
|
var _c = tslib_1.__read((0, react_1.useState)(false), 2), isOpen = _c[0], onOpenChange = _c[1];
|
|
15
23
|
var close = function () { return onOpenChange(false); };
|
|
24
|
+
var select = function (next) {
|
|
25
|
+
onChange(next);
|
|
26
|
+
focusSheet === null || focusSheet === void 0 ? void 0 : focusSheet();
|
|
27
|
+
close();
|
|
28
|
+
};
|
|
16
29
|
return (react_1.default.createElement(ui_2.Popover, { open: isOpen, onOpenChange: onOpenChange },
|
|
17
30
|
react_1.default.createElement(ui_2.PopoverTrigger, { asChild: true },
|
|
18
|
-
react_1.default.createElement(ui_1.IconButton, { size: "lg", tooltip: "Horizontal align", disabled: disabled },
|
|
19
|
-
value === "right" ? (react_1.default.createElement(icons_1.MdFormatAlignRight, null)) : value === "center" ? (react_1.default.createElement(icons_1.MdFormatAlignCenter, null)) : (react_1.default.createElement(icons_1.MdFormatAlignLeft, null)),
|
|
31
|
+
react_1.default.createElement(ui_1.IconButton, { size: "lg", tooltip: "Horizontal align", "aria-label": "Horizontal align", disabled: disabled },
|
|
32
|
+
value === "right" ? (react_1.default.createElement(icons_1.MdFormatAlignRight, null)) : value === "center" || value === "centerContinuous" ? (react_1.default.createElement(icons_1.MdFormatAlignCenter, null)) : value === "justify" || value === "distributed" ? (react_1.default.createElement(icons_1.MdFormatAlignJustify, null)) : (react_1.default.createElement(icons_1.MdFormatAlignLeft, null)),
|
|
20
33
|
react_1.default.createElement(icons_1.MdOutlineArrowDropDown, null))),
|
|
21
34
|
react_1.default.createElement(ui_2.PopoverContent, { align: "start" },
|
|
22
35
|
react_1.default.createElement(ui_3.Stack, { direction: "horizontal", className: "gap-1 max-w-[140px] flex-wrap" },
|
|
@@ -37,6 +50,12 @@ var TextHorizontalAlignSelector = function (_a) {
|
|
|
37
50
|
focusSheet === null || focusSheet === void 0 ? void 0 : focusSheet();
|
|
38
51
|
close();
|
|
39
52
|
} },
|
|
40
|
-
react_1.default.createElement(icons_1.MdFormatAlignRight, null))
|
|
53
|
+
react_1.default.createElement(icons_1.MdFormatAlignRight, null)),
|
|
54
|
+
react_1.default.createElement(ui_1.IconButton, { size: "lg", tooltip: "Justify", "aria-label": "Justify", isActive: value === "justify", onClick: function () { return select("justify"); } },
|
|
55
|
+
react_1.default.createElement(icons_1.MdFormatAlignJustify, null))),
|
|
56
|
+
react_1.default.createElement(ui_3.Stack, { direction: "horizontal", className: "gap-1 pt-1 max-w-[140px]" }, exports.EXTENDED_HORIZONTAL_ALIGNMENTS.map(function (_a) {
|
|
57
|
+
var option = _a.value, label = _a.label;
|
|
58
|
+
return (react_1.default.createElement(ui_1.Button, { key: option, type: "button", variant: value === option ? "secondary" : "ghost", size: "xs", "aria-pressed": value === option, onClick: function () { return select(option); } }, label));
|
|
59
|
+
})))));
|
|
41
60
|
};
|
|
42
61
|
exports.TextHorizontalAlignSelector = TextHorizontalAlignSelector;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { CellFormat } from "../../types";
|
|
3
|
+
export type TextRotationValue = NonNullable<CellFormat["textRotation"]>;
|
|
4
|
+
type TextRotationPreset = {
|
|
5
|
+
label: string;
|
|
6
|
+
value: TextRotationValue;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Excel's Orientation menu. Degrees are counter-clockwise positive (Excel's
|
|
10
|
+
* convention, what the renderer and the xlsx round-trip use), so "clockwise"
|
|
11
|
+
* presets are negative. `0` is horizontal — used instead of clearing the
|
|
12
|
+
* property so both engines apply it as a plain format write.
|
|
13
|
+
*/
|
|
14
|
+
export declare const TEXT_ROTATION_PRESETS: TextRotationPreset[];
|
|
15
|
+
export declare const MIN_TEXT_ROTATION = -90;
|
|
16
|
+
export declare const MAX_TEXT_ROTATION = 90;
|
|
17
|
+
/**
|
|
18
|
+
* Coerce free-form degree input into the supported -90…90 range. Returns
|
|
19
|
+
* `undefined` for input that is not a finite number.
|
|
20
|
+
*/
|
|
21
|
+
export declare const clampTextRotation: (input: string | number) => number | undefined;
|
|
22
|
+
type TextRotationSelectorProps = {
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
value?: CellFormat["textRotation"];
|
|
25
|
+
onChange(value: TextRotationValue): void;
|
|
26
|
+
};
|
|
27
|
+
export declare const TextRotationSelector: ({ value, onChange, disabled, }: TextRotationSelectorProps) => React.JSX.Element;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=text-rotation-selector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-rotation-selector.d.ts","sourceRoot":"","sources":["../../../../components/toolbar/text-rotation-selector.tsx"],"names":[],"mappings":"AAaA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAGnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,MAAM,iBAAiB,GAAG,WAAW,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC;AAExE,KAAK,kBAAkB,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,iBAAiB,CAAC;CAC1B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,kBAAkB,EAOrD,CAAC;AAEF,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,GAAG,MAAM,uBAMvD,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;CAC1C,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,gCAIlC,yBAAyB,sBAoF3B,CAAC"}
|