@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
@@ -1,657 +1,203 @@
1
- import { __read } from "tslib";
2
- import { Direction } from "@rowsncolumns/grid";
3
- import { AiOutlineMergeCells, Cross2Icon, TextOverflowWrapIcon, } from "@rowsncolumns/icons";
4
- import { BorderColorSelector, BorderLineStyleOptions, BorderLocationOptions, ButtonBold, ButtonItalic, ButtonStrikethrough, ButtonUnderline, FontFamilySelector, FontSizeSelector, TextColorSelector, useFocusSheet, } from "@rowsncolumns/spreadsheet";
5
- import { Button, Dialog, DialogBody, DialogCloseButton, DialogContent, DialogTitle, Input, Select, SelectContent, SelectItem, SelectPortal, SelectTrigger, SelectValue, Stack, } from "@rowsncolumns/ui";
6
- import { Tabs } from "@rowsncolumns/ui";
7
- import { TabsList } from "@rowsncolumns/ui";
8
- import { TabsTrigger } from "@rowsncolumns/ui";
9
- import { TabsContent } from "@rowsncolumns/ui";
10
- import { getDefaultDateFormat, getDefaultTimeFormat, ssfFormat, ssfFormatColor, supplant, } from "@rowsncolumns/utils";
11
- import { useFormik } from "formik";
12
- import React, { useCallback, useMemo, useState } from "react";
13
- import { addThousandSeparator, changeDecimals, getCurrentDecimalCountInPattern, hasThousandsSeparator, removeThousandSeparator, } from "../../api/decimals";
1
+ import { __assign, __read, __spreadArray, __values } from "tslib";
2
+ import { Cross2Icon } from "@rowsncolumns/icons";
3
+ import { useFocusSheet } from "@rowsncolumns/spreadsheet";
4
+ import { Button, Dialog, DialogBody, DialogCloseButton, DialogContent, DialogTitle, Tabs, TabsContent, TabsList, TabsTrigger, } from "@rowsncolumns/ui";
5
+ import React, { useMemo, useState } from "react";
14
6
  import { useFormatCellsDialogState, useSetFormatCellsDialogState, } from "../../atoms/dialog-state.atom";
15
- var getNumberFormatCategories = function (locale) { return [
16
- {
17
- name: "General",
18
- value: "GENERAL",
19
- description: "General format cells have no specific number format.",
20
- },
21
- {
22
- name: "Number",
23
- value: "NUMBER",
24
- description: "Number is used for general display of numbers.",
25
- pattern: "#.00",
26
- options: ["Decimal", "ThousandSeparator"],
27
- },
28
- {
29
- name: "Currency",
30
- value: "CURRENCY",
31
- description: "Currency formats are used for general monetary values.",
32
- pattern: "\"{currencySymbol}\"* #,##0.00;\"{currencySymbol}\"* (#,##0.00);\"{currencySymbol}\"* \"-\"??;@",
33
- options: ["CurrencySymbol", "Decimal"],
34
- },
35
- {
36
- name: "Accounting",
37
- value: "ACCOUNTING",
38
- pattern: "\"{currencySymbol}\"* #,##0.00;\"{currencySymbol}\"* (#,##0.00);\"{currencySymbol}\"* \"-\"??;@",
39
- options: ["CurrencySymbol", "Decimal"],
40
- },
41
- {
42
- name: "Date",
43
- value: "DATE",
44
- description: "Date formats display date and time serial numbers as date values.",
45
- pattern: getDefaultDateFormat(locale),
46
- },
47
- {
48
- name: "Time",
49
- value: "DATE_TIME",
50
- description: "Time formats display date and time serial numbers as date values.",
51
- pattern: getDefaultTimeFormat(locale),
52
- },
53
- {
54
- name: "Percentage",
55
- value: "PERCENT",
56
- pattern: "0%",
57
- options: ["Decimal"],
58
- },
59
- {
60
- name: "Fraction",
61
- value: "FRACTION",
62
- pattern: "#/#",
63
- },
64
- {
65
- name: "Scientific",
66
- value: "SCIENTIFIC",
67
- pattern: "0.00E+00",
68
- options: ["Decimal"],
69
- },
70
- {
71
- name: "Text",
72
- value: "TEXT",
73
- },
74
- {
75
- name: "Custom",
76
- value: "CUSTOM",
77
- pattern: "General",
78
- },
79
- ]; };
80
- var horizontalAlignments = [
81
- {
82
- name: "General",
83
- value: undefined,
84
- },
85
- {
86
- name: "Left",
87
- value: "left",
88
- },
89
- {
90
- name: "Center",
91
- value: "center",
92
- },
93
- {
94
- name: "Right",
95
- value: "right",
96
- },
97
- ];
98
- var verticalAlignments = [
99
- {
100
- name: "Top",
101
- value: "top",
102
- },
103
- {
104
- name: "Center",
105
- value: "middle",
106
- },
107
- {
108
- name: "Bottom",
109
- value: "bottom",
110
- },
111
- ];
112
- var customFormats = [
113
- {
114
- type: "GENERAL",
115
- },
116
- {
117
- type: "NUMBER",
118
- pattern: "0",
119
- },
120
- {
121
- type: "NUMBER",
122
- pattern: "##.00",
123
- },
124
- {
125
- type: "NUMBER",
126
- pattern: "#,##0",
127
- },
128
- {
129
- type: "NUMBER",
130
- pattern: "#,##0.00",
131
- },
132
- {
133
- type: "NUMBER",
134
- pattern: "#,##0;(#,##0)",
135
- },
136
- {
137
- type: "NUMBER",
138
- pattern: "#,##0;[Red](#,##0)",
139
- },
140
- {
141
- type: "NUMBER",
142
- pattern: "#,##0.00;(#,##0.00)",
143
- },
144
- {
145
- type: "NUMBER",
146
- pattern: "#,##0.00;[Red](#,##0.00)",
147
- },
148
- {
149
- type: "CURRENCY",
150
- pattern: '"{currencySymbol}"#,##0;("{currencySymbol}"#,##0)',
151
- },
152
- {
153
- type: "CURRENCY",
154
- pattern: '"{currencySymbol}"#,##0;[Red]("{currencySymbol}"#,##0)',
155
- },
156
- {
157
- type: "CURRENCY",
158
- pattern: '"{currencySymbol}"#,##0.00;("{currencySymbol}"#,##0.00)',
159
- },
160
- {
161
- type: "CURRENCY",
162
- pattern: '"{currencySymbol}"#,##0.00;[Red]("{currencySymbol}"#,##0.00)',
163
- },
164
- {
165
- type: "PERCENT",
166
- pattern: "0%",
167
- },
168
- {
169
- type: "PERCENT",
170
- pattern: "0.00%",
171
- },
172
- {
173
- type: "SCIENTIFIC",
174
- pattern: "0.00E+00",
175
- },
176
- {
177
- type: "SCIENTIFIC",
178
- pattern: "##0.0E+0",
179
- },
180
- {
181
- type: "FRACTION",
182
- pattern: "# ?/?",
183
- },
184
- {
185
- type: "FRACTION",
186
- pattern: "# ??/??",
187
- },
188
- {
189
- type: "DATE",
190
- pattern: "d/m/yy",
191
- },
192
- {
193
- type: "DATE",
194
- pattern: "d-mmm-yy",
195
- },
196
- {
197
- type: "DATE",
198
- pattern: "d-mmm",
199
- },
200
- {
201
- type: "DATE",
202
- pattern: "mmm-yy",
203
- },
204
- {
205
- type: "DATE_TIME",
206
- pattern: "h:mm AM/PM",
207
- },
208
- {
209
- type: "DATE_TIME",
210
- pattern: "h:mm:ss AM/PM",
211
- },
212
- {
213
- type: "DATE_TIME",
214
- pattern: "h:mm",
215
- },
216
- {
217
- type: "DATE_TIME",
218
- pattern: "h:mm:ss",
219
- },
220
- {
221
- type: "DATE",
222
- pattern: "d/m/yy h:mm",
223
- },
224
- {
225
- type: "DATE_TIME",
226
- pattern: "mm:ss",
227
- },
228
- {
229
- type: "DATE_TIME",
230
- pattern: "mm:ss.0",
231
- },
232
- {
233
- type: "TEXT",
234
- pattern: "@",
235
- },
236
- {
237
- type: "DATE_TIME",
238
- pattern: "[h]:mm:ss",
239
- },
240
- {
241
- type: "CURRENCY",
242
- pattern: '"{currencySymbol}"* #,##0;"{currencySymbol}"* (#,##0);"{currencySymbol}"* "-";@',
243
- },
244
- {
245
- type: "ACCOUNTING",
246
- pattern: '* #,##0;* (#,##0);* "-";@',
247
- },
248
- {
249
- type: "CURRENCY",
250
- pattern: "\"{currencySymbol}\"* #,##0.00;\"{currencySymbol}\"* (#,##0.00);\"{currencySymbol}\"* \"-\"??;@",
251
- },
252
- {
253
- type: "ACCOUNTING",
254
- pattern: '* #,##0.00;* (#,##0.00);* "-"??;@',
255
- },
256
- {
257
- type: "DATE_TIME",
258
- pattern: "[$-en-US]h:mm:ss AM/PM",
259
- },
260
- {
261
- type: "DATE_TIME",
262
- pattern: "[$-en-US]hh:mm:ss AM/PM;@",
263
- },
264
- {
265
- type: "DATE",
266
- pattern: "[$-en-US]m/d/yy h:mm AM/PM;@",
267
- },
268
- {
269
- type: "DATE_TIME",
270
- pattern: "[$-en-US]h:mm AM/PM;@",
271
- },
272
- {
273
- type: "DATE",
274
- pattern: "d/m/yyyy",
275
- },
276
- {
277
- type: "NUMBER",
278
- pattern: "00000",
279
- },
280
- ];
281
- var dateFormats = [
282
- {
283
- pattern: "dd/m/yy",
284
- type: "DATE",
285
- },
286
- {
287
- pattern: "dddd, dd mmmm yyyy",
288
- type: "DATE",
289
- },
290
- {
291
- pattern: "dd/mm/yyyy",
292
- type: "DATE",
293
- },
294
- {
295
- pattern: "dd/mm/yy",
296
- type: "DATE",
297
- },
298
- {
299
- pattern: "dd\\.mm\\.yyyy",
300
- type: "DATE",
301
- },
302
- {
303
- pattern: "yyyy-mm-dd",
304
- type: "DATE",
305
- },
306
- {
307
- pattern: "dd mmmm yyyy",
308
- type: "DATE",
309
- },
310
- {
311
- pattern: "dd-mmm",
312
- type: "DATE",
313
- },
314
- {
315
- pattern: "dd-mmm-yy",
316
- type: "DATE",
317
- },
318
- {
319
- pattern: "mmm-dd",
320
- type: "DATE",
321
- },
322
- {
323
- pattern: "mmmm-dd",
324
- type: "DATE",
325
- },
326
- {
327
- pattern: "mmm-dd, yyyy",
328
- type: "DATE",
329
- },
330
- ];
331
- var timeFormats = [
332
- {
333
- pattern: "hh:mm",
334
- type: "DATE_TIME",
335
- },
336
- {
337
- pattern: "h:mm AM/PM",
338
- type: "DATE_TIME",
339
- },
340
- {
341
- pattern: "hh:mm:ss",
342
- type: "DATE_TIME",
343
- },
344
- {
345
- pattern: "h:mm:ss AM/PM",
346
- type: "DATE_TIME",
347
- },
348
- {
349
- pattern: "d/m/yy h:mm AM/PM",
350
- type: "DATE",
351
- },
352
- {
353
- pattern: "d/m/yy hh:mm",
354
- type: "DATE",
355
- },
356
- ];
7
+ import { AlignmentTab } from "./cell-format/alignment-tab";
8
+ import { edgesFromBorders, toBorderCommands, } from "./cell-format/border-edges";
9
+ import { BorderTab } from "./cell-format/border-tab";
10
+ import { FillTab } from "./cell-format/fill-tab";
11
+ import { FontTab } from "./cell-format/font-tab";
12
+ import { NumberTab } from "./cell-format/number-tab";
13
+ import { ProtectionTab, } from "./cell-format/protection-tab";
14
+ var same = function (a, b) {
15
+ return JSON.stringify(a !== null && a !== void 0 ? a : null) === JSON.stringify(b !== null && b !== void 0 ? b : null);
16
+ };
17
+ /**
18
+ * The properties the dialog changed, and only those — Excel's Format Cells
19
+ * applies what you edited to every selected cell and leaves the rest of each
20
+ * cell's format alone. A removed value is sent as `undefined` (the engines'
21
+ * clear for that property).
22
+ */
23
+ export var diffCellFormat = function (initial, draft) {
24
+ var e_1, _a, e_2, _b;
25
+ var _c, _d;
26
+ var patch = {};
27
+ var keys = new Set(__spreadArray(__spreadArray([], __read(Object.keys(initial)), false), __read(Object.keys(draft)), false));
28
+ try {
29
+ for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
30
+ var key = keys_1_1.value;
31
+ if (key === "textFormat" || key === "borders")
32
+ continue;
33
+ var before = initial[key];
34
+ var after = draft[key];
35
+ if (!same(before, after))
36
+ patch[key] = after;
37
+ }
38
+ }
39
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
40
+ finally {
41
+ try {
42
+ if (keys_1_1 && !keys_1_1.done && (_a = keys_1.return)) _a.call(keys_1);
43
+ }
44
+ finally { if (e_1) throw e_1.error; }
45
+ }
46
+ var tfBefore = ((_c = initial.textFormat) !== null && _c !== void 0 ? _c : {});
47
+ var tfAfter = ((_d = draft.textFormat) !== null && _d !== void 0 ? _d : {});
48
+ var textFormat = {};
49
+ try {
50
+ for (var _e = __values(new Set(__spreadArray(__spreadArray([], __read(Object.keys(tfBefore)), false), __read(Object.keys(tfAfter)), false))), _f = _e.next(); !_f.done; _f = _e.next()) {
51
+ var key = _f.value;
52
+ if (!same(tfBefore[key], tfAfter[key]))
53
+ textFormat[key] = tfAfter[key];
54
+ }
55
+ }
56
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
57
+ finally {
58
+ try {
59
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
60
+ }
61
+ finally { if (e_2) throw e_2.error; }
62
+ }
63
+ if (Object.keys(textFormat).length)
64
+ patch.textFormat = textFormat;
65
+ return patch;
66
+ };
67
+ var selectionSpans = function (activeCell, selections) {
68
+ var ranges = selections.length
69
+ ? selections.map(function (s) { return s.range; })
70
+ : [
71
+ {
72
+ startRowIndex: activeCell.rowIndex,
73
+ endRowIndex: activeCell.rowIndex,
74
+ startColumnIndex: activeCell.columnIndex,
75
+ endColumnIndex: activeCell.columnIndex,
76
+ },
77
+ ];
78
+ return {
79
+ rows: ranges.some(function (r) { return r.endRowIndex > r.startRowIndex; }),
80
+ columns: ranges.some(function (r) { return r.endColumnIndex > r.startColumnIndex; }),
81
+ };
82
+ };
83
+ /**
84
+ * Excel's Format Cells dialog (Ctrl+1 / ⌘1): Number, Alignment, Font,
85
+ * Border, Fill and Protection. Every tab edits a draft; OK applies the
86
+ * edits to the selection, Cancel drops them.
87
+ */
357
88
  export var CellFormatEditor = function (_a) {
358
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
359
- var locale = _a.locale, cellFormat = _a.cellFormat, sheetId = _a.sheetId, activeCell = _a.activeCell, selections = _a.selections, _r = _a.currencySymbol, currencySymbol = _r === void 0 ? "$" : _r, theme = _a.theme, isDarkMode = _a.isDarkMode, onMergeCells = _a.onMergeCells, onChangeFormatting = _a.onChangeFormatting, onChangeBorder = _a.onChangeBorder, onCancel = _a.onCancel, getEffectiveValue = _a.getEffectiveValue;
360
- var _s = __read(useState(false), 2), isCustom = _s[0], setIsCustom = _s[1];
361
- var _t = __read(useState(undefined), 2), color = _t[0], setColorState = _t[1];
362
- var _u = __read(useState("solid"), 2), borderStyle = _u[0], setStyleState = _u[1];
363
- var _v = __read(useState(), 2), borderLocation = _v[0], setBorderLocationState = _v[1];
89
+ var _b;
90
+ var locale = _a.locale, cellFormat = _a.cellFormat, sheetId = _a.sheetId, activeCell = _a.activeCell, selections = _a.selections, _c = _a.currencySymbol, currencySymbol = _c === void 0 ? "$" : _c, theme = _a.theme, isDarkMode = _a.isDarkMode, onMergeCells = _a.onMergeCells, onUnMergeCells = _a.onUnMergeCells, _d = _a.isMerged, isMerged = _d === void 0 ? false : _d, cellProtection = _a.cellProtection, onChangeCellProtection = _a.onChangeCellProtection, onChangeFormatting = _a.onChangeFormatting, onChangeBorder = _a.onChangeBorder, onCancel = _a.onCancel, getEffectiveValue = _a.getEffectiveValue, _e = _a.defaultTab, defaultTab = _e === void 0 ? "number" : _e;
364
91
  var setFormatCellDialogState = useSetFormatCellsDialogState();
365
- // close dialog
366
92
  var onRequestCloseDialog = function () { return setFormatCellDialogState(false); };
93
+ var initial = useMemo(function () { return cellFormat !== null && cellFormat !== void 0 ? cellFormat : {}; }, [cellFormat]);
94
+ var _f = __read(useState(initial), 2), draft = _f[0], setDraft = _f[1];
95
+ var patchDraft = function (patch) {
96
+ return setDraft(function (prev) { return (__assign(__assign({}, prev), patch)); });
97
+ };
98
+ var patchText = function (patch) {
99
+ return setDraft(function (prev) {
100
+ var _a;
101
+ return (__assign(__assign({}, prev), { textFormat: __assign(__assign({}, ((_a = prev.textFormat) !== null && _a !== void 0 ? _a : {})), patch) }));
102
+ });
103
+ };
104
+ var _g = __read(useState(isMerged), 2), merged = _g[0], setMerged = _g[1];
105
+ var initialProtection = {
106
+ locked: (cellProtection === null || cellProtection === void 0 ? void 0 : cellProtection.locked) !== false,
107
+ hidden: (cellProtection === null || cellProtection === void 0 ? void 0 : cellProtection.hidden) === true,
108
+ };
109
+ var _h = __read(useState(initialProtection), 2), protection = _h[0], setProtection = _h[1];
110
+ // Border: the edges the user edited, on top of the active cell's own.
111
+ var initialEdges = useMemo(function () { return edgesFromBorders(cellFormat === null || cellFormat === void 0 ? void 0 : cellFormat.borders); }, [cellFormat === null || cellFormat === void 0 ? void 0 : cellFormat.borders]);
112
+ var _j = __read(useState({}), 2), edgeEdits = _j[0], setEdgeEdits = _j[1];
113
+ var _k = __read(useState(false), 2), clearedAll = _k[0], setClearedAll = _k[1];
114
+ var _l = __read(useState("solid"), 2), lineStyle = _l[0], setLineStyle = _l[1];
115
+ var _m = __read(useState(function () { return ({
116
+ theme: 1,
117
+ tint: isDarkMode ? 1 : 0,
118
+ }); }), 2), borderColor = _m[0], setBorderColor = _m[1];
119
+ var shownEdges = clearedAll
120
+ ? __assign({}, edgeEdits) : __assign(__assign({}, initialEdges), edgeEdits);
121
+ var spans = selectionSpans(activeCell, selections);
367
122
  var effectiveValue = getEffectiveValue(sheetId, activeCell.rowIndex, activeCell.columnIndex);
368
- var _w = __read(useState(), 2), customFormatValue = _w[0], setCustomFormatValue = _w[1];
369
- var numberCategories = useMemo(function () { return getNumberFormatCategories(locale); }, [locale]);
370
- var getDefaultBorderColor = useCallback(function () {
371
- return { theme: 1, tint: isDarkMode ? 1 : 0 };
372
- }, [isDarkMode]);
373
- var overflowDivClass = "grid grid-cols-1 max-h-[200px] overflow-auto border-rnc-border border-solid rounded-sm border";
374
- var sampleDate = new Date();
375
- var _x = useFormik({
376
- initialValues: cellFormat !== null && cellFormat !== void 0 ? cellFormat : {},
377
- onSubmit: function (values) {
378
- // Formatting
379
- onChangeFormatting === null || onChangeFormatting === void 0 ? void 0 : onChangeFormatting(sheetId, activeCell, selections, values);
380
- // Border TBD
381
- // Merge cells TBD
382
- onRequestCloseDialog();
383
- },
384
- }), handleSubmit = _x.handleSubmit, resetForm = _x.resetForm, setFieldValue = _x.setFieldValue, values = _x.values;
385
- var type = (_b = values === null || values === void 0 ? void 0 : values.numberFormat) === null || _b === void 0 ? void 0 : _b.type;
386
- var pattern = (_c = values === null || values === void 0 ? void 0 : values.numberFormat) === null || _c === void 0 ? void 0 : _c.pattern;
387
- var formattedValue = ssfFormat(pattern !== null && pattern !== void 0 ? pattern : "General", effectiveValue) || "\u00A0";
388
- var formattedColor = ssfFormatColor(pattern !== null && pattern !== void 0 ? pattern : "General", effectiveValue);
389
- var selectedNumberFormat = type !== null && type !== void 0 ? type : "GENERAL";
390
- var selectedOption = numberCategories.find(function (opt) { return opt.value === selectedNumberFormat; });
391
- var decimalCount = getCurrentDecimalCountInPattern(pattern !== null && pattern !== void 0 ? pattern : undefined);
392
- var thousandsSeparator = hasThousandsSeparator(pattern !== null && pattern !== void 0 ? pattern : undefined);
393
- // Cancel
123
+ var fill = {
124
+ backgroundColor: draft.backgroundColor,
125
+ fillPattern: draft.fillPattern,
126
+ foregroundColor: draft.foregroundColor,
127
+ gradient: draft.gradient,
128
+ };
129
+ var onSave = function () {
130
+ var e_3, _a;
131
+ var patch = diffCellFormat(initial, draft);
132
+ if (Object.keys(patch).length) {
133
+ onChangeFormatting === null || onChangeFormatting === void 0 ? void 0 : onChangeFormatting(sheetId, activeCell, selections, patch);
134
+ }
135
+ try {
136
+ for (var _b = __values(toBorderCommands(edgeEdits, { clearedAll: clearedAll })), _c = _b.next(); !_c.done; _c = _b.next()) {
137
+ var command = _c.value;
138
+ onChangeBorder === null || onChangeBorder === void 0 ? void 0 : onChangeBorder(sheetId, activeCell, selections, command.location, command.color, command.style);
139
+ }
140
+ }
141
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
142
+ finally {
143
+ try {
144
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
145
+ }
146
+ finally { if (e_3) throw e_3.error; }
147
+ }
148
+ if (merged !== isMerged) {
149
+ if (merged)
150
+ onMergeCells === null || onMergeCells === void 0 ? void 0 : onMergeCells(sheetId, activeCell, selections);
151
+ else
152
+ onUnMergeCells === null || onUnMergeCells === void 0 ? void 0 : onUnMergeCells(sheetId, activeCell, selections);
153
+ }
154
+ if (protection.locked !== initialProtection.locked ||
155
+ protection.hidden !== initialProtection.hidden) {
156
+ onChangeCellProtection === null || onChangeCellProtection === void 0 ? void 0 : onChangeCellProtection(sheetId, activeCell, selections, __assign(__assign({}, (protection.locked !== initialProtection.locked
157
+ ? { locked: protection.locked }
158
+ : {})), (protection.hidden !== initialProtection.hidden
159
+ ? { hidden: protection.hidden }
160
+ : {})));
161
+ }
162
+ onRequestCloseDialog();
163
+ };
394
164
  var onCancelForm = function () {
395
- resetForm();
396
165
  onRequestCloseDialog();
397
166
  onCancel === null || onCancel === void 0 ? void 0 : onCancel();
398
167
  };
399
- return (React.createElement("form", { onSubmit: handleSubmit },
400
- React.createElement(Tabs, { defaultValue: "number" },
168
+ return (React.createElement("form", { onSubmit: function (event) {
169
+ event.preventDefault();
170
+ onSave();
171
+ } },
172
+ React.createElement(Tabs, { defaultValue: defaultTab },
401
173
  React.createElement(TabsList, null,
402
174
  React.createElement(TabsTrigger, { value: "number" }, "Number"),
403
175
  React.createElement(TabsTrigger, { value: "alignment" }, "Alignment"),
404
176
  React.createElement(TabsTrigger, { value: "font" }, "Font"),
405
- React.createElement(TabsTrigger, { value: "border" }, "Border")),
177
+ React.createElement(TabsTrigger, { value: "border" }, "Border"),
178
+ React.createElement(TabsTrigger, { value: "fill" }, "Fill"),
179
+ React.createElement(TabsTrigger, { value: "protection" }, "Protection")),
406
180
  React.createElement(TabsContent, { value: "number" },
407
- React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-3" },
408
- React.createElement("label", { className: "font-system text-sm" }, "Sample"),
409
- React.createElement("div", { className: "text-rnc-foreground p-1 px-2 bg-rnc-muted rounded-sm", style: {
410
- color: formattedColor,
411
- } }, formattedValue)),
412
- React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-3" },
413
- React.createElement("label", { className: "font-system text-sm" }, "Choose category"),
414
- React.createElement(Select, { value: isCustom ? "CUSTOM" : selectedNumberFormat, onValueChange: function (value) {
415
- var format = numberCategories.find(function (n) { return n.value === value; });
416
- if ((format === null || format === void 0 ? void 0 : format.value) === "CUSTOM") {
417
- // Show custom options
418
- setIsCustom(true);
419
- setCustomFormatValue(values.numberFormat);
420
- }
421
- else if (format) {
422
- // Toggle custom
423
- setIsCustom(false);
424
- // Apply formatting
425
- setFieldValue("numberFormat", {
426
- pattern: format.pattern
427
- ? supplant(format.pattern, { currencySymbol: currencySymbol })
428
- : undefined,
429
- type: format.value,
430
- });
431
- }
432
- } },
433
- React.createElement(SelectTrigger, { className: "mb-1" },
434
- React.createElement(SelectValue, { placeholder: "None" })),
435
- React.createElement(SelectPortal, null,
436
- React.createElement(SelectContent, null, numberCategories.map(function (_a) {
437
- var name = _a.name, value = _a.value;
438
- return (React.createElement(SelectItem, { value: value, key: name }, name));
439
- }))))),
440
- isCustom ? null : (React.createElement(Stack, { className: "grid grid-cols-2 gap-2" }, (_d = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.options) === null || _d === void 0 ? void 0 : _d.map(function (opt) {
441
- return opt === "Decimal" ? (React.createElement(Stack, { direction: "vertical", key: opt, className: "gap-1 pb-3" },
442
- React.createElement("label", { className: "font-system text-sm" }, "Decimal places"),
443
- React.createElement(Input, { min: 0, max: 10, type: "number", className: "text-xs", value: decimalCount, onChange: function (event) {
444
- var numDecimals = parseInt(event.target.value, 10);
445
- if (type) {
446
- setFieldValue("numberFormat", {
447
- type: type,
448
- pattern: changeDecimals(pattern !== null && pattern !== void 0 ? pattern : "#,##0.00", numDecimals, false),
449
- });
450
- }
451
- } }))) : opt === "ThousandSeparator" ? (React.createElement(Stack, { direction: "vertical", key: opt, className: "gap-1 pb-3" },
452
- React.createElement("label", { className: "font-system text-sm" }, "Thousands separator"),
453
- React.createElement("label", { className: "font-system text-xs flex items-center gap-1", key: opt },
454
- React.createElement("input", { type: "checkbox", checked: thousandsSeparator, onChange: function (e) {
455
- var checked = e.target.checked;
456
- var newPattern = checked
457
- ? addThousandSeparator(pattern !== null && pattern !== void 0 ? pattern : undefined)
458
- : removeThousandSeparator(pattern !== null && pattern !== void 0 ? pattern : undefined);
459
- setFieldValue("numberFormat", {
460
- type: type !== null && type !== void 0 ? type : "NUMBER",
461
- pattern: newPattern,
462
- });
463
- } }),
464
- "Use 1000 Separator (,)"))) : opt === "CurrencySymbol" ? (React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-3", key: opt },
465
- React.createElement("label", { className: "font-system text-sm" }, "Currency Symbol"),
466
- React.createElement(Input, { type: "text", defaultValue: currencySymbol, className: "text-xs", onChange: function (event) {
467
- var currencyPattern = numberCategories.find(function (n) { return n.value === "CURRENCY"; });
468
- if (currencyPattern && currencyPattern.pattern) {
469
- setFieldValue("numberFormat", {
470
- type: "CURRENCY",
471
- pattern: supplant(currencyPattern.pattern, {
472
- currencySymbol: event.target.value,
473
- }),
474
- });
475
- }
476
- } }))) : null;
477
- }))),
478
- isCustom ? (React.createElement("div", { className: "flex flex-col gap-2" },
479
- React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-1" },
480
- React.createElement("label", { className: "font-system text-sm" }, "Type"),
481
- React.createElement(Input, { type: "text", className: "text-xs", value: (_e = customFormatValue === null || customFormatValue === void 0 ? void 0 : customFormatValue.pattern) !== null && _e !== void 0 ? _e : undefined, onChange: function (e) {
482
- var _a;
483
- setCustomFormatValue(function (prev) {
484
- var _a;
485
- return {
486
- type: (_a = prev === null || prev === void 0 ? void 0 : prev.type) !== null && _a !== void 0 ? _a : "GENERAL",
487
- pattern: e.target.value,
488
- };
489
- });
490
- setFieldValue("numberFormat", {
491
- type: (_a = customFormatValue === null || customFormatValue === void 0 ? void 0 : customFormatValue.type) !== null && _a !== void 0 ? _a : "GENERAL",
492
- pattern: e.target.value,
493
- });
494
- } })),
495
- React.createElement("div", { className: overflowDivClass }, customFormats.map(function (format, idx) {
496
- var _a;
497
- return (React.createElement(Button, { key: idx, className: "text-xs py-1 px-1.5", onClick: function () {
498
- var _a, _b;
499
- setFieldValue("numberFormat", {
500
- type: format.type,
501
- pattern: supplant((_a = format.pattern) !== null && _a !== void 0 ? _a : "General", {
502
- currencySymbol: currencySymbol,
503
- }),
504
- });
505
- // Set current format type
506
- setCustomFormatValue({
507
- type: format.type,
508
- pattern: supplant((_b = format.pattern) !== null && _b !== void 0 ? _b : "General", {
509
- currencySymbol: currencySymbol,
510
- }),
511
- });
512
- } }, supplant((_a = format.pattern) !== null && _a !== void 0 ? _a : format.type, {
513
- currencySymbol: currencySymbol,
514
- })));
515
- })))) : null,
516
- type === "DATE" && !isCustom ? (React.createElement("div", { className: overflowDivClass }, dateFormats.map(function (format, idx) {
517
- var _a;
518
- return (React.createElement(Button, { key: idx, className: "text-xs py-1 px-1.5", onClick: function () {
519
- var _a;
520
- setFieldValue("numberFormat", {
521
- type: format.type,
522
- pattern: supplant((_a = format.pattern) !== null && _a !== void 0 ? _a : "General", {
523
- currencySymbol: currencySymbol,
524
- }),
525
- });
526
- } }, ssfFormat((_a = format.pattern) !== null && _a !== void 0 ? _a : getDefaultDateFormat(locale), sampleDate)));
527
- }))) : null,
528
- type === "DATE_TIME" && !isCustom ? (React.createElement("div", { className: overflowDivClass }, timeFormats.map(function (format, idx) {
529
- var _a;
530
- return (React.createElement(Button, { key: idx, className: "text-xs py-1 px-1.5", onClick: function () {
531
- var _a;
532
- setFieldValue("numberFormat", {
533
- type: format.type,
534
- pattern: supplant((_a = format.pattern) !== null && _a !== void 0 ? _a : "General", {
535
- currencySymbol: currencySymbol,
536
- }),
537
- });
538
- } }, ssfFormat((_a = format.pattern) !== null && _a !== void 0 ? _a : getDefaultDateFormat(locale), sampleDate)));
539
- }))) : null),
181
+ React.createElement(NumberTab, { numberFormat: draft.numberFormat, onChange: function (numberFormat) { return patchDraft({ numberFormat: numberFormat }); }, sampleValue: effectiveValue, locale: locale, currencySymbol: currencySymbol })),
540
182
  React.createElement(TabsContent, { value: "alignment" },
541
- React.createElement(Stack, { className: "grid grid-cols-2 gap-2 pb-3" },
542
- React.createElement(Stack, { direction: "vertical", className: "gap-1" },
543
- React.createElement("label", { className: "font-system text-sm" }, "Horizontal Alignment"),
544
- React.createElement(Select, { value: (_f = values === null || values === void 0 ? void 0 : values.horizontalAlignment) !== null && _f !== void 0 ? _f : "General", onValueChange: function (value) {
545
- return setFieldValue("horizontalAlignment", value);
546
- } },
547
- React.createElement(SelectTrigger, { className: "mb-1" },
548
- React.createElement(SelectValue, { placeholder: "General" })),
549
- React.createElement(SelectPortal, null,
550
- React.createElement(SelectContent, null, horizontalAlignments.map(function (_a) {
551
- var name = _a.name, _b = _a.value, value = _b === void 0 ? "General" : _b;
552
- return (React.createElement(SelectItem, { value: value, key: value }, name));
553
- }))))),
554
- React.createElement(Stack, { direction: "vertical", className: "gap-1" },
555
- React.createElement("label", { className: "font-system text-sm" }, "Indent"),
556
- React.createElement(Input, { value: (_g = values === null || values === void 0 ? void 0 : values.indent) !== null && _g !== void 0 ? _g : 0, min: 0, max: 10, type: "number", className: "text-xs", onChange: function (event) {
557
- setFieldValue("indent", Number(event.target.value));
558
- } }))),
559
- React.createElement(Stack, { className: "grid grid-cols-2 gap-2" },
560
- React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-3" },
561
- React.createElement("label", { className: "font-system text-sm" }, "Vertical Alignment"),
562
- React.createElement(Select, { value: (_h = values === null || values === void 0 ? void 0 : values.verticalAlignment) !== null && _h !== void 0 ? _h : "bottom", onValueChange: function (value) {
563
- return setFieldValue("verticalAlignment", value);
564
- } },
565
- React.createElement(SelectTrigger, { className: "mb-1" },
566
- React.createElement(SelectValue, { placeholder: "General" })),
567
- React.createElement(SelectPortal, null,
568
- React.createElement(SelectContent, null, verticalAlignments.map(function (_a) {
569
- var name = _a.name, value = _a.value;
570
- return (React.createElement(SelectItem, { value: value, key: value }, name));
571
- })))))),
572
- React.createElement("label", { className: "font-system text-sm pb-3" }, "Text control"),
573
- React.createElement(Stack, { className: "grid grid-cols-2 gap-2" },
574
- React.createElement(Button, { className: "flex items-center gap-2", onClick: function () {
575
- setFieldValue("wrapStrategy", "wrap");
576
- }, variant: "ghost" },
577
- React.createElement("span", { className: "text-lg leading-none" },
578
- React.createElement(TextOverflowWrapIcon, null)),
579
- "Wrap text"),
580
- React.createElement(Button, { className: "flex items-center gap-2", onClick: function () {
581
- onMergeCells === null || onMergeCells === void 0 ? void 0 : onMergeCells(sheetId, activeCell, selections, Direction.Right);
582
- }, variant: "ghost" },
583
- React.createElement("span", { className: "text-lg leading-none" },
584
- React.createElement(AiOutlineMergeCells, null)),
585
- "Merge"))),
183
+ React.createElement(AlignmentTab, { format: draft, onChange: patchDraft, merged: merged, onChangeMerged: setMerged })),
586
184
  React.createElement(TabsContent, { value: "font" },
587
- React.createElement(Stack, { className: "grid grid-cols-2 gap-2 pb-3" },
588
- React.createElement(Stack, { direction: "vertical", className: "gap-1" },
589
- React.createElement("label", { className: "font-system text-sm" }, "Font"),
590
- React.createElement(FontFamilySelector, { theme: theme, value: (_j = values === null || values === void 0 ? void 0 : values.textFormat) === null || _j === void 0 ? void 0 : _j.fontFamily, onChange: function (fontFamily) {
591
- setFieldValue("textFormat.fontFamily", fontFamily);
592
- }, triggerVariant: "outline" })),
593
- React.createElement(Stack, { direction: "vertical", className: "gap-1" },
594
- React.createElement("label", { className: "font-system text-sm" }, "Font size"),
595
- React.createElement(FontSizeSelector, { value: (_k = values === null || values === void 0 ? void 0 : values.textFormat) === null || _k === void 0 ? void 0 : _k.fontSize, onChange: function (fontSize) {
596
- setFieldValue("textFormat.fontSize", fontSize);
597
- } }))),
598
- React.createElement(Stack, { className: "grid grid-cols-2 gap-2 pb-3" },
599
- React.createElement(Stack, { direction: "vertical", className: "gap-1" },
600
- React.createElement("label", { className: "font-system text-sm" }, "Effects"),
601
- React.createElement(Stack, { direction: "horizontal", className: "gap-2" },
602
- React.createElement(ButtonBold, { isActive: (_l = values === null || values === void 0 ? void 0 : values.textFormat) === null || _l === void 0 ? void 0 : _l.bold, onClick: function () {
603
- var _a;
604
- setFieldValue("textFormat.bold", !((_a = values === null || values === void 0 ? void 0 : values.textFormat) === null || _a === void 0 ? void 0 : _a.bold));
605
- } }),
606
- React.createElement(ButtonItalic, { isActive: (_m = values === null || values === void 0 ? void 0 : values.textFormat) === null || _m === void 0 ? void 0 : _m.italic, onClick: function () {
607
- var _a;
608
- setFieldValue("textFormat.italic", !((_a = values === null || values === void 0 ? void 0 : values.textFormat) === null || _a === void 0 ? void 0 : _a.italic));
609
- } }),
610
- React.createElement(ButtonUnderline, { isActive: (_o = values === null || values === void 0 ? void 0 : values.textFormat) === null || _o === void 0 ? void 0 : _o.underline, onClick: function () {
611
- var _a;
612
- setFieldValue("textFormat.underline", !((_a = values === null || values === void 0 ? void 0 : values.textFormat) === null || _a === void 0 ? void 0 : _a.underline));
613
- } }),
614
- React.createElement(ButtonStrikethrough, { isActive: (_p = values === null || values === void 0 ? void 0 : values.textFormat) === null || _p === void 0 ? void 0 : _p.strikethrough, onClick: function () {
615
- var _a;
616
- setFieldValue("textFormat.strikethrough", !((_a = values === null || values === void 0 ? void 0 : values.textFormat) === null || _a === void 0 ? void 0 : _a.strikethrough));
617
- } }))),
618
- React.createElement(Stack, { direction: "vertical", className: "gap-1" },
619
- React.createElement("label", { className: "font-system text-sm" }, "Color"),
620
- React.createElement("div", null,
621
- React.createElement(TextColorSelector, { color: (_q = values === null || values === void 0 ? void 0 : values.textFormat) === null || _q === void 0 ? void 0 : _q.color, theme: theme, isDarkMode: isDarkMode, onChange: function (color) {
622
- setFieldValue("textFormat.color", color);
623
- } }))))),
185
+ React.createElement(FontTab, { textFormat: (_b = draft.textFormat) !== null && _b !== void 0 ? _b : {}, onChange: patchText, theme: theme, isDarkMode: isDarkMode })),
624
186
  React.createElement(TabsContent, { value: "border" },
625
- React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-3" },
626
- React.createElement("label", { className: "font-system text-sm" }, "Border style"),
627
- React.createElement(Stack, { direction: "horizontal", className: "flex flex-wrap gap-2 pb-3" },
628
- React.createElement(BorderLocationOptions, { borderLocation: borderLocation, onChange: function (value) {
629
- setBorderLocationState(value);
630
- // Update border
631
- onChangeBorder === null || onChangeBorder === void 0 ? void 0 : onChangeBorder(sheetId, activeCell, selections, value, color !== null && color !== void 0 ? color : getDefaultBorderColor(), borderStyle);
632
- }, onClear: function () {
633
- // Update border
634
- onChangeBorder === null || onChangeBorder === void 0 ? void 0 : onChangeBorder(sheetId, activeCell, selections, "all", undefined, undefined);
635
- } }))),
636
- React.createElement(Stack, { className: "grid grid-cols-3 gap-2" },
637
- React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-3 col-span-2" },
638
- React.createElement("label", { className: "font-system text-sm" }, "Border Style"),
639
- React.createElement("div", { className: "flex flex-wrap gap-2" },
640
- React.createElement(BorderLineStyleOptions, { borderStyle: borderStyle, onChange: function (value) {
641
- setStyleState(value);
642
- // Update border
643
- onChangeBorder === null || onChangeBorder === void 0 ? void 0 : onChangeBorder(sheetId, activeCell, selections, borderLocation !== null && borderLocation !== void 0 ? borderLocation : "all", color !== null && color !== void 0 ? color : getDefaultBorderColor(), value);
644
- } }))),
645
- React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-3" },
646
- React.createElement("label", { className: "font-system text-sm" }, "Border color"),
647
- React.createElement("div", null,
648
- React.createElement(BorderColorSelector, { color: color !== null && color !== void 0 ? color : getDefaultBorderColor(), onChange: function (value) {
649
- setColorState(value);
650
- // Update border
651
- onChangeBorder === null || onChangeBorder === void 0 ? void 0 : onChangeBorder(sheetId, activeCell, selections, borderLocation !== null && borderLocation !== void 0 ? borderLocation : "all", value, borderStyle);
652
- }, theme: theme })))))),
187
+ React.createElement(BorderTab, { edges: shownEdges, onEdit: function (edits, options) {
188
+ if (options === null || options === void 0 ? void 0 : options.clearedAll) {
189
+ setClearedAll(true);
190
+ setEdgeEdits({});
191
+ return;
192
+ }
193
+ setEdgeEdits(function (prev) { return (__assign(__assign({}, prev), edits)); });
194
+ }, lineStyle: lineStyle, onLineStyle: setLineStyle, color: borderColor, onColor: setBorderColor, hasInsideRows: spans.rows, hasInsideColumns: spans.columns, theme: theme })),
195
+ React.createElement(TabsContent, { value: "fill" },
196
+ React.createElement(FillTab, { fill: fill, onChange: function (next) { return patchDraft(next); }, theme: theme })),
197
+ React.createElement(TabsContent, { value: "protection" },
198
+ React.createElement(ProtectionTab, { protection: protection, onChange: setProtection }))),
653
199
  React.createElement("div", { className: "flex gap-1 py-2" },
654
- React.createElement(Button, { type: "submit", variant: "primary", size: "xs" }, "Save"),
200
+ React.createElement(Button, { type: "submit", variant: "primary", size: "xs" }, "OK"),
655
201
  React.createElement(Button, { size: "xs", onClick: onCancelForm, type: "button" }, "Cancel"))));
656
202
  };
657
203
  export var CellFormatEditorDialog = function (_a) {