@rowsncolumns/spreadsheet-state 29.2.0 → 29.3.2

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.
Files changed (127) hide show
  1. package/dist/cjs/api/border.d.ts +1 -1
  2. package/dist/cjs/api/border.d.ts.map +1 -1
  3. package/dist/cjs/commands.d.ts +36 -3
  4. package/dist/cjs/commands.d.ts.map +1 -1
  5. package/dist/cjs/components/editors/cell-format/alignment-tab.d.ts +27 -0
  6. package/dist/cjs/components/editors/cell-format/alignment-tab.d.ts.map +1 -0
  7. package/dist/cjs/components/editors/cell-format/alignment-tab.js +83 -0
  8. package/dist/cjs/components/editors/cell-format/border-edges.d.ts +42 -0
  9. package/dist/cjs/components/editors/cell-format/border-edges.d.ts.map +1 -0
  10. package/dist/cjs/components/editors/cell-format/border-edges.js +118 -0
  11. package/dist/cjs/components/editors/cell-format/border-tab.d.ts +21 -0
  12. package/dist/cjs/components/editors/cell-format/border-tab.d.ts.map +1 -0
  13. package/dist/cjs/components/editors/cell-format/border-tab.js +123 -0
  14. package/dist/cjs/components/editors/cell-format/fill-tab.d.ts +14 -0
  15. package/dist/cjs/components/editors/cell-format/fill-tab.d.ts.map +1 -0
  16. package/dist/cjs/components/editors/cell-format/fill-tab.js +54 -0
  17. package/dist/cjs/components/editors/cell-format/font-tab.d.ts +18 -0
  18. package/dist/cjs/components/editors/cell-format/font-tab.d.ts.map +1 -0
  19. package/dist/cjs/components/editors/cell-format/font-tab.js +99 -0
  20. package/dist/cjs/components/editors/cell-format/list-box.d.ts +35 -0
  21. package/dist/cjs/components/editors/cell-format/list-box.d.ts.map +1 -0
  22. package/dist/cjs/components/editors/cell-format/list-box.js +37 -0
  23. package/dist/cjs/components/editors/cell-format/number-formats.d.ts +90 -0
  24. package/dist/cjs/components/editors/cell-format/number-formats.d.ts.map +1 -0
  25. package/dist/cjs/components/editors/cell-format/number-formats.js +403 -0
  26. package/dist/cjs/components/editors/cell-format/number-tab.d.ts +12 -0
  27. package/dist/cjs/components/editors/cell-format/number-tab.d.ts.map +1 -0
  28. package/dist/cjs/components/editors/cell-format/number-tab.js +194 -0
  29. package/dist/cjs/components/editors/cell-format/protection-tab.d.ts +13 -0
  30. package/dist/cjs/components/editors/cell-format/protection-tab.d.ts.map +1 -0
  31. package/dist/cjs/components/editors/cell-format/protection-tab.js +13 -0
  32. package/dist/cjs/components/editors/cell-format-editor.d.ts +31 -3
  33. package/dist/cjs/components/editors/cell-format-editor.d.ts.map +1 -1
  34. package/dist/cjs/components/editors/cell-format-editor.js +182 -636
  35. package/dist/cjs/components/editors/conditional-format-data-bar-options.d.ts +16 -0
  36. package/dist/cjs/components/editors/conditional-format-data-bar-options.d.ts.map +1 -0
  37. package/dist/cjs/components/editors/conditional-format-data-bar-options.js +166 -0
  38. package/dist/cjs/components/editors/conditional-format-editor.d.ts +7 -1
  39. package/dist/cjs/components/editors/conditional-format-editor.d.ts.map +1 -1
  40. package/dist/cjs/components/editors/conditional-format-editor.js +51 -9
  41. package/dist/cjs/components/editors/conditional-format-icon-set-options.d.ts +17 -0
  42. package/dist/cjs/components/editors/conditional-format-icon-set-options.d.ts.map +1 -0
  43. package/dist/cjs/components/editors/conditional-format-icon-set-options.js +163 -0
  44. package/dist/cjs/components/editors/conditional-format-rule-editor.d.ts +9 -0
  45. package/dist/cjs/components/editors/conditional-format-rule-editor.d.ts.map +1 -1
  46. package/dist/cjs/components/editors/conditional-format-rule-editor.js +97 -125
  47. package/dist/cjs/components/editors/sheet-filter.d.ts +20 -9
  48. package/dist/cjs/components/editors/sheet-filter.d.ts.map +1 -1
  49. package/dist/cjs/components/editors/sheet-filter.js +44 -12
  50. package/dist/cjs/hooks/use-conditional-formatting-rules.d.ts +2 -0
  51. package/dist/cjs/hooks/use-conditional-formatting-rules.d.ts.map +1 -1
  52. package/dist/cjs/hooks/use-conditional-formatting-rules.js +22 -1
  53. package/dist/cjs/hooks/use-spreadsheet-state.d.ts +2 -0
  54. package/dist/cjs/hooks/use-spreadsheet-state.d.ts.map +1 -1
  55. package/dist/cjs/hooks/use-spreadsheet-state.js +4 -2
  56. package/dist/cjs/interface/change-border.d.ts.map +1 -1
  57. package/dist/cjs/interface/change-border.js +8 -1
  58. package/dist/cjs/interface/conditional-formatting-rules.d.ts +11 -1
  59. package/dist/cjs/interface/conditional-formatting-rules.d.ts.map +1 -1
  60. package/dist/cjs/interface/conditional-formatting-rules.js +44 -1
  61. package/dist/cjs/sheet-cell.d.ts +8 -0
  62. package/dist/cjs/sheet-cell.d.ts.map +1 -1
  63. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  64. package/dist/esm/api/border.d.ts +1 -1
  65. package/dist/esm/api/border.d.ts.map +1 -1
  66. package/dist/esm/commands.d.ts +36 -3
  67. package/dist/esm/commands.d.ts.map +1 -1
  68. package/dist/esm/components/editors/cell-format/alignment-tab.d.ts +27 -0
  69. package/dist/esm/components/editors/cell-format/alignment-tab.d.ts.map +1 -0
  70. package/dist/esm/components/editors/cell-format/alignment-tab.js +81 -0
  71. package/dist/esm/components/editors/cell-format/border-edges.d.ts +42 -0
  72. package/dist/esm/components/editors/cell-format/border-edges.d.ts.map +1 -0
  73. package/dist/esm/components/editors/cell-format/border-edges.js +79 -0
  74. package/dist/esm/components/editors/cell-format/border-tab.d.ts +21 -0
  75. package/dist/esm/components/editors/cell-format/border-tab.d.ts.map +1 -0
  76. package/dist/esm/components/editors/cell-format/border-tab.js +103 -0
  77. package/dist/esm/components/editors/cell-format/fill-tab.d.ts +14 -0
  78. package/dist/esm/components/editors/cell-format/fill-tab.d.ts.map +1 -0
  79. package/dist/esm/components/editors/cell-format/fill-tab.js +49 -0
  80. package/dist/esm/components/editors/cell-format/font-tab.d.ts +18 -0
  81. package/dist/esm/components/editors/cell-format/font-tab.d.ts.map +1 -0
  82. package/dist/esm/components/editors/cell-format/font-tab.js +88 -0
  83. package/dist/esm/components/editors/cell-format/list-box.d.ts +35 -0
  84. package/dist/esm/components/editors/cell-format/list-box.d.ts.map +1 -0
  85. package/dist/esm/components/editors/cell-format/list-box.js +30 -0
  86. package/dist/esm/components/editors/cell-format/number-formats.d.ts +90 -0
  87. package/dist/esm/components/editors/cell-format/number-formats.d.ts.map +1 -0
  88. package/dist/esm/components/editors/cell-format/number-formats.js +383 -0
  89. package/dist/esm/components/editors/cell-format/number-tab.d.ts +12 -0
  90. package/dist/esm/components/editors/cell-format/number-tab.d.ts.map +1 -0
  91. package/dist/esm/components/editors/cell-format/number-tab.js +165 -0
  92. package/dist/esm/components/editors/cell-format/protection-tab.d.ts +13 -0
  93. package/dist/esm/components/editors/cell-format/protection-tab.d.ts.map +1 -0
  94. package/dist/esm/components/editors/cell-format/protection-tab.js +9 -0
  95. package/dist/esm/components/editors/cell-format-editor.d.ts +31 -3
  96. package/dist/esm/components/editors/cell-format-editor.d.ts.map +1 -1
  97. package/dist/esm/components/editors/cell-format-editor.js +148 -615
  98. package/dist/esm/components/editors/conditional-format-data-bar-options.d.ts +16 -0
  99. package/dist/esm/components/editors/conditional-format-data-bar-options.d.ts.map +1 -0
  100. package/dist/esm/components/editors/conditional-format-data-bar-options.js +145 -0
  101. package/dist/esm/components/editors/conditional-format-editor.d.ts +7 -1
  102. package/dist/esm/components/editors/conditional-format-editor.d.ts.map +1 -1
  103. package/dist/esm/components/editors/conditional-format-editor.js +39 -8
  104. package/dist/esm/components/editors/conditional-format-icon-set-options.d.ts +17 -0
  105. package/dist/esm/components/editors/conditional-format-icon-set-options.d.ts.map +1 -0
  106. package/dist/esm/components/editors/conditional-format-icon-set-options.js +139 -0
  107. package/dist/esm/components/editors/conditional-format-rule-editor.d.ts +9 -0
  108. package/dist/esm/components/editors/conditional-format-rule-editor.d.ts.map +1 -1
  109. package/dist/esm/components/editors/conditional-format-rule-editor.js +60 -85
  110. package/dist/esm/components/editors/sheet-filter.d.ts +20 -9
  111. package/dist/esm/components/editors/sheet-filter.d.ts.map +1 -1
  112. package/dist/esm/components/editors/sheet-filter.js +31 -11
  113. package/dist/esm/hooks/use-conditional-formatting-rules.d.ts +2 -0
  114. package/dist/esm/hooks/use-conditional-formatting-rules.d.ts.map +1 -1
  115. package/dist/esm/hooks/use-conditional-formatting-rules.js +19 -1
  116. package/dist/esm/hooks/use-spreadsheet-state.d.ts +2 -0
  117. package/dist/esm/hooks/use-spreadsheet-state.d.ts.map +1 -1
  118. package/dist/esm/hooks/use-spreadsheet-state.js +4 -2
  119. package/dist/esm/interface/change-border.d.ts.map +1 -1
  120. package/dist/esm/interface/change-border.js +8 -1
  121. package/dist/esm/interface/conditional-formatting-rules.d.ts +11 -1
  122. package/dist/esm/interface/conditional-formatting-rules.d.ts.map +1 -1
  123. package/dist/esm/interface/conditional-formatting-rules.js +29 -1
  124. package/dist/esm/sheet-cell.d.ts +8 -0
  125. package/dist/esm/sheet-cell.d.ts.map +1 -1
  126. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  127. package/package.json +6 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fill-tab.d.ts","sourceRoot":"","sources":["../../../../../components/editors/cell-format/fill-tab.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAS5E,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC/B,KAAK,EAAE,gBAAgB,CAAC;CACzB,CAAC;AAYF;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,2BAA2B,YAAY,sBA8E9D,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { __assign, __read } from "tslib";
2
+ import { getStringifiedColor, gradientToCss, GradientFillPicker, PatternFillPicker, STANDARD_COLORS, } from "@rowsncolumns/spreadsheet";
3
+ import { Button, ColorPicker, HexColorPicker } from "@rowsncolumns/ui";
4
+ import React, { useState } from "react";
5
+ /** CSS for the Sample box (gradient, else the solid colour; patterns show their base colour). */
6
+ var sampleStyle = function (fill, theme) {
7
+ var _a, _b;
8
+ return ((_b = (_a = fill.gradient) === null || _a === void 0 ? void 0 : _a.stops) === null || _b === void 0 ? void 0 : _b.length)
9
+ ? { backgroundImage: gradientToCss(fill.gradient) }
10
+ : {
11
+ backgroundColor: fill.backgroundColor
12
+ ? getStringifiedColor(fill.backgroundColor, theme)
13
+ : undefined,
14
+ };
15
+ };
16
+ /**
17
+ * Format Cells → Fill: Background Color (No Color, the palette, More
18
+ * Colors…), Fill Effects… (two-colour gradient), Pattern Color and Pattern
19
+ * Style, and a Sample. A solid colour replaces a gradient, as in Excel.
20
+ */
21
+ export var FillTab = function (_a) {
22
+ var fill = _a.fill, onChange = _a.onChange, theme = _a.theme;
23
+ var _b = __read(useState("none"), 2), panel = _b[0], setPanel = _b[1];
24
+ var solid = fill.backgroundColor
25
+ ? getStringifiedColor(fill.backgroundColor, theme)
26
+ : undefined;
27
+ var pickSolid = function (color) {
28
+ return onChange(__assign(__assign({}, fill), { backgroundColor: color, gradient: undefined }));
29
+ };
30
+ return (React.createElement("div", { className: "grid grid-cols-[1fr_200px] gap-4" },
31
+ React.createElement("div", { className: "flex flex-col gap-2" },
32
+ React.createElement("span", { className: "font-system text-sm" }, "Background Color"),
33
+ React.createElement(Button, { size: "xs", variant: "outline", className: "justify-center", onClick: function () {
34
+ return onChange({
35
+ backgroundColor: undefined,
36
+ fillPattern: undefined,
37
+ foregroundColor: undefined,
38
+ gradient: undefined,
39
+ });
40
+ } }, "No Color"),
41
+ React.createElement("div", { role: "group", "aria-label": "Background color", className: "flex flex-col gap-1" },
42
+ React.createElement(ColorPicker, { value: solid, onChange: pickSolid, className: "flex-wrap gap-1" }),
43
+ React.createElement(ColorPicker, { value: solid, colors: STANDARD_COLORS, onChange: pickSolid, className: "gap-1" })),
44
+ React.createElement("div", { className: "flex gap-2" },
45
+ React.createElement(Button, { size: "xs", variant: "outline", "aria-expanded": panel === "effects", onClick: function () { return setPanel(panel === "effects" ? "none" : "effects"); } }, "Fill Effects..."),
46
+ React.createElement(Button, { size: "xs", variant: "outline", "aria-expanded": panel === "more", onClick: function () { return setPanel(panel === "more" ? "none" : "more"); } }, "More Colors...")),
47
+ panel === "more" ? (React.createElement(HexColorPicker, { value: solid !== null && solid !== void 0 ? solid : "#FFFFFF", onChange: pickSolid })) : null,
48
+ panel === "effects" ? (React.createElement("div", { "data-testid": "fill-effects" },
49
+ React.createElement(GradientFillPicker, { fill: fill, theme: theme, onChangeFill: onChange }))) : null),
50
+ React.createElement("div", { className: "flex flex-col gap-2" },
51
+ React.createElement(PatternFillPicker, { fill: fill, theme: theme, onChangeFill: onChange }),
52
+ React.createElement("span", { className: "font-system text-sm" }, "Sample"),
53
+ React.createElement("div", { "data-testid": "fill-sample", className: "h-10 rounded-sm border border-solid border-rnc-border", style: sampleStyle(fill, theme) }))));
54
+ };
@@ -0,0 +1,18 @@
1
+ import type { SpreadsheetTheme, TextFormat, UnderlineStyle } from "@rowsncolumns/spreadsheet";
2
+ import React from "react";
3
+ type UnderlineChoice = "none" | UnderlineStyle;
4
+ /** Excel's Underline list. */
5
+ export declare const UNDERLINE_OPTIONS: {
6
+ value: UnderlineChoice;
7
+ label: string;
8
+ }[];
9
+ export type FontTabProps = {
10
+ textFormat: TextFormat;
11
+ onChange(patch: Partial<TextFormat>): void;
12
+ theme: SpreadsheetTheme;
13
+ isDarkMode?: boolean;
14
+ };
15
+ /** Format Cells → Font. */
16
+ export declare const FontTab: ({ textFormat, onChange, theme, isDarkMode, }: FontTabProps) => React.JSX.Element;
17
+ export {};
18
+ //# sourceMappingURL=font-tab.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"font-tab.d.ts","sourceRoot":"","sources":["../../../../../components/editors/cell-format/font-tab.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,UAAU,EACV,cAAc,EACf,MAAM,2BAA2B,CAAC;AAOnC,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,KAAK,eAAe,GAAG,MAAM,GAAG,cAAc,CAAC;AAS/C,8BAA8B;AAC9B,eAAO,MAAM,iBAAiB,EAAE;IAAE,KAAK,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAMxE,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IAC3C,KAAK,EAAE,gBAAgB,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAoCF,2BAA2B;AAC3B,eAAO,MAAM,OAAO,GAAI,8CAKrB,YAAY,sBA2Gd,CAAC"}
@@ -0,0 +1,99 @@
1
+ import { FontFamilySelector, FontSizeSelector, getStringifiedColor, TextColorSelector, } from "@rowsncolumns/spreadsheet";
2
+ import React from "react";
3
+ import { CheckboxField, ListBox, SelectField } from "./list-box";
4
+ var FONT_STYLES = [
5
+ { value: "regular", label: "Regular" },
6
+ { value: "italic", label: "Italic" },
7
+ { value: "bold", label: "Bold" },
8
+ { value: "boldItalic", label: "Bold Italic" },
9
+ ];
10
+ /** Excel's Underline list. */
11
+ export var UNDERLINE_OPTIONS = [
12
+ { value: "none", label: "None" },
13
+ { value: "single", label: "Single" },
14
+ { value: "double", label: "Double" },
15
+ { value: "singleAccounting", label: "Single Accounting" },
16
+ { value: "doubleAccounting", label: "Double Accounting" },
17
+ ];
18
+ /** CSS for the Preview box: the double / accounting underlines as CSS decorations. */
19
+ var previewStyle = function (tf, theme) {
20
+ var _a, _b;
21
+ var style = tf.underline ? (_a = tf.underlineStyle) !== null && _a !== void 0 ? _a : "single" : undefined;
22
+ var lines = [
23
+ style ? "underline" : "",
24
+ tf.strikethrough ? "line-through" : "",
25
+ ]
26
+ .filter(Boolean)
27
+ .join(" ");
28
+ return {
29
+ fontFamily: (_b = tf.fontFamily) !== null && _b !== void 0 ? _b : undefined,
30
+ fontSize: tf.fontSize ? "".concat(tf.fontSize, "pt") : undefined,
31
+ fontWeight: tf.bold ? "bold" : undefined,
32
+ fontStyle: tf.italic ? "italic" : undefined,
33
+ color: tf.color ? getStringifiedColor(tf.color, theme) : undefined,
34
+ textDecorationLine: lines || undefined,
35
+ textDecorationStyle: style === "double" || style === "doubleAccounting" ? "double" : undefined,
36
+ textUnderlineOffset: style === "singleAccounting" || style === "doubleAccounting"
37
+ ? "0.3em"
38
+ : undefined,
39
+ verticalAlign: tf.baselineOffset === "superscript"
40
+ ? "super"
41
+ : tf.baselineOffset === "subscript"
42
+ ? "sub"
43
+ : undefined,
44
+ };
45
+ };
46
+ /** Format Cells → Font. */
47
+ export var FontTab = function (_a) {
48
+ var _b;
49
+ var textFormat = _a.textFormat, onChange = _a.onChange, theme = _a.theme, isDarkMode = _a.isDarkMode;
50
+ var fontStyle = textFormat.bold && textFormat.italic
51
+ ? "boldItalic"
52
+ : textFormat.bold
53
+ ? "bold"
54
+ : textFormat.italic
55
+ ? "italic"
56
+ : "regular";
57
+ var underline = textFormat.underline
58
+ ? (_b = textFormat.underlineStyle) !== null && _b !== void 0 ? _b : "single"
59
+ : "none";
60
+ return (React.createElement("div", { className: "flex flex-col gap-3" },
61
+ React.createElement("div", { className: "grid grid-cols-[1fr_120px_80px] gap-2" },
62
+ React.createElement("div", { className: "flex flex-col gap-1" },
63
+ React.createElement("span", { className: "font-system text-sm" }, "Font"),
64
+ React.createElement(FontFamilySelector, { theme: theme, value: textFormat.fontFamily, onChange: function (fontFamily) { return onChange({ fontFamily: fontFamily }); }, triggerVariant: "outline" })),
65
+ React.createElement("div", { className: "flex flex-col gap-1" },
66
+ React.createElement("span", { className: "font-system text-sm" }, "Font style"),
67
+ React.createElement(ListBox, { label: "Font style", value: fontStyle, items: FONT_STYLES, onChange: function (value) {
68
+ return onChange({
69
+ bold: value === "bold" || value === "boldItalic",
70
+ italic: value === "italic" || value === "boldItalic",
71
+ });
72
+ } })),
73
+ React.createElement("div", { className: "flex flex-col gap-1" },
74
+ React.createElement("span", { className: "font-system text-sm" }, "Size"),
75
+ React.createElement(FontSizeSelector, { value: textFormat.fontSize, onChange: function (fontSize) { return onChange({ fontSize: fontSize }); } }))),
76
+ React.createElement("div", { className: "grid grid-cols-2 gap-2" },
77
+ React.createElement(SelectField, { label: "Underline", value: underline, options: UNDERLINE_OPTIONS, onChange: function (value) {
78
+ return onChange(value === "none"
79
+ ? { underline: false }
80
+ : { underline: true, underlineStyle: value });
81
+ } }),
82
+ React.createElement("div", { className: "flex flex-col gap-1" },
83
+ React.createElement("span", { className: "font-system text-sm" }, "Color"),
84
+ React.createElement(TextColorSelector, { color: textFormat.color, theme: theme, isDarkMode: isDarkMode, onChange: function (color) { return onChange({ color: color }); } }))),
85
+ React.createElement("div", { className: "grid grid-cols-2 gap-2" },
86
+ React.createElement("fieldset", { className: "flex flex-col gap-1.5 border-0 p-0" },
87
+ React.createElement("legend", { className: "pb-1 font-system text-sm" }, "Effects"),
88
+ React.createElement(CheckboxField, { label: "Strikethrough", checked: !!textFormat.strikethrough, onChange: function (strikethrough) { return onChange({ strikethrough: strikethrough }); } }),
89
+ React.createElement(CheckboxField, { label: "Superscript", checked: textFormat.baselineOffset === "superscript", onChange: function (on) {
90
+ return onChange({ baselineOffset: on ? "superscript" : null });
91
+ } }),
92
+ React.createElement(CheckboxField, { label: "Subscript", checked: textFormat.baselineOffset === "subscript", onChange: function (on) {
93
+ return onChange({ baselineOffset: on ? "subscript" : null });
94
+ } })),
95
+ React.createElement("div", { className: "flex flex-col gap-1" },
96
+ React.createElement("span", { className: "font-system text-sm" }, "Preview"),
97
+ React.createElement("div", { "data-testid": "font-preview", className: "flex h-14 items-center justify-center overflow-hidden rounded-sm border border-solid border-rnc-border bg-rnc-background" },
98
+ React.createElement("span", { style: previewStyle(textFormat, theme) }, "AaBbCcYyZz"))))));
99
+ };
@@ -0,0 +1,35 @@
1
+ import React from "react";
2
+ export type ListBoxItem<T extends string> = {
3
+ value: T;
4
+ label: React.ReactNode;
5
+ };
6
+ /**
7
+ * Excel's always-open selection lists (Category, Type, Font style, Line
8
+ * style …): a listbox with arrow-key navigation, not a dropdown.
9
+ */
10
+ export declare const ListBox: <T extends string>({ label, items, value, onChange, className, }: {
11
+ label: string;
12
+ items: ListBoxItem<T>[];
13
+ value: T | undefined;
14
+ onChange(value: T): void;
15
+ className?: string;
16
+ }) => React.JSX.Element;
17
+ /** A labelled native checkbox (Excel's Text control / Effects / Protection boxes). */
18
+ export declare const CheckboxField: ({ label, checked, disabled, onChange, }: {
19
+ label: string;
20
+ checked: boolean;
21
+ disabled?: boolean;
22
+ onChange(checked: boolean): void;
23
+ }) => React.JSX.Element;
24
+ /** A labelled native select for the short option lists. */
25
+ export declare const SelectField: <T extends string>({ label, value, options, onChange, disabled, }: {
26
+ label: string;
27
+ value: T;
28
+ options: {
29
+ value: T;
30
+ label: string;
31
+ }[];
32
+ onChange(value: T): void;
33
+ disabled?: boolean;
34
+ }) => React.JSX.Element;
35
+ //# sourceMappingURL=list-box.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-box.d.ts","sourceRoot":"","sources":["../../../../../components/editors/cell-format/list-box.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,IAAI;IAC1C,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;CACxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,SAAS,MAAM,EAAE,+CAMvC;IACD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;IACxB,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,sBAoCA,CAAC;AAEF,sFAAsF;AACtF,eAAO,MAAM,aAAa,GAAI,yCAK3B;IACD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CAClC,sBAcA,CAAC;AAEF,2DAA2D;AAC3D,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,MAAM,EAAE,gDAM3C;IACD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,CAAC,CAAC;IACT,OAAO,EAAE;QAAE,KAAK,EAAE,CAAC,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,sBAiBA,CAAC"}
@@ -0,0 +1,37 @@
1
+ import React from "react";
2
+ /**
3
+ * Excel's always-open selection lists (Category, Type, Font style, Line
4
+ * style …): a listbox with arrow-key navigation, not a dropdown.
5
+ */
6
+ export var ListBox = function (_a) {
7
+ var label = _a.label, items = _a.items, value = _a.value, onChange = _a.onChange, _b = _a.className, className = _b === void 0 ? "" : _b;
8
+ var index = items.findIndex(function (item) { return item.value === value; });
9
+ return (React.createElement("div", { role: "listbox", "aria-label": label, tabIndex: 0, className: "max-h-[180px] overflow-auto rounded-sm border border-solid border-rnc-border text-xs outline-none focus-visible:ring-1 focus-visible:ring-rnc-primary ".concat(className), onKeyDown: function (event) {
10
+ if (event.key !== "ArrowDown" && event.key !== "ArrowUp")
11
+ return;
12
+ event.preventDefault();
13
+ var step = event.key === "ArrowDown" ? 1 : -1;
14
+ var next = items[Math.max(0, Math.min(items.length - 1, index + step))];
15
+ if (next)
16
+ onChange(next.value);
17
+ } }, items.map(function (item) {
18
+ var selected = item.value === value;
19
+ return (React.createElement("div", { key: item.value, role: "option", "aria-selected": selected, className: "cursor-default px-1.5 py-0.5 ".concat(selected
20
+ ? "bg-rnc-primary text-rnc-primary-foreground"
21
+ : "hover:bg-rnc-muted"), onClick: function () { return onChange(item.value); } }, item.label));
22
+ })));
23
+ };
24
+ /** A labelled native checkbox (Excel's Text control / Effects / Protection boxes). */
25
+ export var CheckboxField = function (_a) {
26
+ var label = _a.label, checked = _a.checked, disabled = _a.disabled, onChange = _a.onChange;
27
+ return (React.createElement("label", { className: "flex items-center gap-1.5 font-system text-xs ".concat(disabled ? "opacity-50" : "") },
28
+ React.createElement("input", { type: "checkbox", checked: checked, disabled: disabled, onChange: function (event) { return onChange(event.target.checked); } }),
29
+ label));
30
+ };
31
+ /** A labelled native select for the short option lists. */
32
+ export var SelectField = function (_a) {
33
+ var label = _a.label, value = _a.value, options = _a.options, onChange = _a.onChange, disabled = _a.disabled;
34
+ return (React.createElement("label", { className: "flex flex-col gap-1 font-system text-sm" },
35
+ label,
36
+ React.createElement("select", { "aria-label": label, className: "rounded-sm border border-solid border-rnc-border bg-rnc-background px-1 py-1 text-xs text-rnc-foreground", value: value, disabled: disabled, onChange: function (event) { return onChange(event.target.value); } }, options.map(function (option) { return (React.createElement("option", { key: option.value, value: option.value }, option.label)); }))));
37
+ };
@@ -0,0 +1,90 @@
1
+ import type { NumberFormat, NumberFormatType } from "@rowsncolumns/spreadsheet";
2
+ export type NumberCategoryId = "general" | "number" | "currency" | "accounting" | "date" | "time" | "percentage" | "fraction" | "scientific" | "text" | "special" | "custom";
3
+ export type NumberCategory = {
4
+ id: NumberCategoryId;
5
+ name: string;
6
+ type: NumberFormatType;
7
+ description: string;
8
+ };
9
+ /** Excel's category list, in Excel's order. */
10
+ export declare const NUMBER_CATEGORIES: NumberCategory[];
11
+ /** Excel's four "Negative numbers" styles. */
12
+ export type NegativeStyle = "minus" | "red" | "parens" | "redParens";
13
+ export declare const NEGATIVE_STYLES: NegativeStyle[];
14
+ /** Number: decimal places, 1000 separator, negative numbers. */
15
+ export declare const buildNumberPattern: ({ decimals, thousands, negative, }: {
16
+ decimals: number;
17
+ thousands: boolean;
18
+ negative: NegativeStyle;
19
+ }) => string;
20
+ /** Currency: decimal places, symbol, negative numbers. */
21
+ export declare const buildCurrencyPattern: ({ decimals, symbol, negative, }: {
22
+ decimals: number;
23
+ symbol: string;
24
+ negative: NegativeStyle;
25
+ }) => string;
26
+ /**
27
+ * Accounting: decimal places and symbol. The symbol sits at the left edge
28
+ * (`* ` repeats the space to fill the cell), zero shows a dash, and the `_(`
29
+ * / `_)` paddings line the decimal points up across positive and negative.
30
+ */
31
+ export declare const buildAccountingPattern: ({ decimals, symbol, }: {
32
+ decimals: number;
33
+ symbol: string;
34
+ }) => string;
35
+ export declare const buildPercentPattern: (decimals: number) => string;
36
+ export declare const buildScientificPattern: (decimals: number) => string;
37
+ /** Excel's Currency / Accounting symbol list (a representative subset). */
38
+ export declare const CURRENCY_SYMBOLS: {
39
+ symbol: string;
40
+ label: string;
41
+ }[];
42
+ export declare const FRACTION_TYPES: {
43
+ label: string;
44
+ pattern: string;
45
+ }[];
46
+ /** Excel's Special types for English (United States). */
47
+ export declare const SPECIAL_TYPES: {
48
+ label: string;
49
+ pattern: string;
50
+ }[];
51
+ /** Locales offered by the Date / Time / Special "Locale (location)" list. */
52
+ export type FormatLocale = {
53
+ /** BCP-47 tag. */
54
+ tag: string;
55
+ label: string;
56
+ /** Windows LCID (hex) written as Excel's `[$-xxxx]` locale prefix. */
57
+ lcid: string;
58
+ /** Day before month in the short date. */
59
+ dayFirst: boolean;
60
+ };
61
+ export declare const FORMAT_LOCALES: FormatLocale[];
62
+ export declare const findFormatLocale: (tag: string | undefined) => FormatLocale;
63
+ /**
64
+ * The Date / Time types for a locale. The default locale's codes are written
65
+ * bare (they follow the workbook); another locale's carry Excel's
66
+ * `[$-lcid]` prefix so the cell keeps that locale's names and order.
67
+ */
68
+ export declare const getDateTimeTypes: (kind: "date" | "time", locale: FormatLocale, defaultLocale: FormatLocale) => string[];
69
+ /** The locale a format code's `[$-lcid]` prefix names, if any. */
70
+ export declare const getPatternLocale: (pattern: string | null | undefined) => FormatLocale | undefined;
71
+ /** The pieces the Number / Currency options read back off a code. */
72
+ export declare const parseNumericPattern: (pattern: string | null | undefined) => {
73
+ decimals: number;
74
+ thousands: boolean;
75
+ negative: NegativeStyle;
76
+ symbol: string;
77
+ };
78
+ /** Which category a cell's number format opens the Number tab on. */
79
+ export declare const detectCategory: (format: NumberFormat | null | undefined) => NumberCategoryId;
80
+ /** The format a category gets when it is first picked (Excel's defaults). */
81
+ export declare const defaultFormatForCategory: (id: NumberCategoryId, { currencySymbol, locale, defaultLocale, }: {
82
+ currencySymbol: string;
83
+ locale: FormatLocale;
84
+ defaultLocale: FormatLocale;
85
+ }) => NumberFormat | null;
86
+ /** Excel's Custom type list (the built-in codes). */
87
+ export declare const CUSTOM_PATTERNS: string[];
88
+ /** The NumberFormatType a typed custom code is closest to. */
89
+ export declare const inferTypeFromPattern: (pattern: string) => NumberFormatType;
90
+ //# sourceMappingURL=number-formats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number-formats.d.ts","sourceRoot":"","sources":["../../../../../components/editors/cell-format/number-formats.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAEhF,MAAM,MAAM,gBAAgB,GACxB,SAAS,GACT,QAAQ,GACR,UAAU,GACV,YAAY,GACZ,MAAM,GACN,MAAM,GACN,YAAY,GACZ,UAAU,GACV,YAAY,GACZ,MAAM,GACN,SAAS,GACT,QAAQ,CAAC;AAEb,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,gBAAgB,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,gBAAgB,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,+CAA+C;AAC/C,eAAO,MAAM,iBAA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