@rowsncolumns/spreadsheet-state 29.2.0 → 29.3.3
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/border.d.ts +1 -1
- package/dist/cjs/api/border.d.ts.map +1 -1
- package/dist/cjs/api/paste-special.d.ts +33 -2
- package/dist/cjs/api/paste-special.d.ts.map +1 -1
- package/dist/cjs/api/paste-special.js +62 -19
- package/dist/cjs/commands.d.ts +208 -3
- package/dist/cjs/commands.d.ts.map +1 -1
- package/dist/cjs/components/editors/cell-format/alignment-tab.d.ts +27 -0
- package/dist/cjs/components/editors/cell-format/alignment-tab.d.ts.map +1 -0
- package/dist/cjs/components/editors/cell-format/alignment-tab.js +83 -0
- package/dist/cjs/components/editors/cell-format/border-edges.d.ts +42 -0
- package/dist/cjs/components/editors/cell-format/border-edges.d.ts.map +1 -0
- package/dist/cjs/components/editors/cell-format/border-edges.js +118 -0
- package/dist/cjs/components/editors/cell-format/border-tab.d.ts +21 -0
- package/dist/cjs/components/editors/cell-format/border-tab.d.ts.map +1 -0
- package/dist/cjs/components/editors/cell-format/border-tab.js +123 -0
- package/dist/cjs/components/editors/cell-format/fill-tab.d.ts +14 -0
- package/dist/cjs/components/editors/cell-format/fill-tab.d.ts.map +1 -0
- package/dist/cjs/components/editors/cell-format/fill-tab.js +54 -0
- package/dist/cjs/components/editors/cell-format/font-tab.d.ts +18 -0
- package/dist/cjs/components/editors/cell-format/font-tab.d.ts.map +1 -0
- package/dist/cjs/components/editors/cell-format/font-tab.js +99 -0
- package/dist/cjs/components/editors/cell-format/list-box.d.ts +35 -0
- package/dist/cjs/components/editors/cell-format/list-box.d.ts.map +1 -0
- package/dist/cjs/components/editors/cell-format/list-box.js +37 -0
- package/dist/cjs/components/editors/cell-format/number-formats.d.ts +90 -0
- package/dist/cjs/components/editors/cell-format/number-formats.d.ts.map +1 -0
- package/dist/cjs/components/editors/cell-format/number-formats.js +403 -0
- package/dist/cjs/components/editors/cell-format/number-tab.d.ts +12 -0
- package/dist/cjs/components/editors/cell-format/number-tab.d.ts.map +1 -0
- package/dist/cjs/components/editors/cell-format/number-tab.js +194 -0
- package/dist/cjs/components/editors/cell-format/protection-tab.d.ts +13 -0
- package/dist/cjs/components/editors/cell-format/protection-tab.d.ts.map +1 -0
- package/dist/cjs/components/editors/cell-format/protection-tab.js +13 -0
- package/dist/cjs/components/editors/cell-format-editor.d.ts +31 -3
- package/dist/cjs/components/editors/cell-format-editor.d.ts.map +1 -1
- package/dist/cjs/components/editors/cell-format-editor.js +182 -636
- package/dist/cjs/components/editors/conditional-format-data-bar-options.d.ts +16 -0
- package/dist/cjs/components/editors/conditional-format-data-bar-options.d.ts.map +1 -0
- package/dist/cjs/components/editors/conditional-format-data-bar-options.js +166 -0
- package/dist/cjs/components/editors/conditional-format-editor.d.ts +7 -1
- package/dist/cjs/components/editors/conditional-format-editor.d.ts.map +1 -1
- package/dist/cjs/components/editors/conditional-format-editor.js +51 -9
- package/dist/cjs/components/editors/conditional-format-icon-set-options.d.ts +17 -0
- package/dist/cjs/components/editors/conditional-format-icon-set-options.d.ts.map +1 -0
- package/dist/cjs/components/editors/conditional-format-icon-set-options.js +163 -0
- package/dist/cjs/components/editors/conditional-format-rule-editor.d.ts +9 -0
- package/dist/cjs/components/editors/conditional-format-rule-editor.d.ts.map +1 -1
- package/dist/cjs/components/editors/conditional-format-rule-editor.js +97 -125
- package/dist/cjs/components/editors/sheet-filter.d.ts +20 -9
- package/dist/cjs/components/editors/sheet-filter.d.ts.map +1 -1
- package/dist/cjs/components/editors/sheet-filter.js +44 -12
- package/dist/cjs/constants.d.ts +3 -1
- package/dist/cjs/constants.d.ts.map +1 -1
- package/dist/cjs/constants.js +3 -0
- package/dist/cjs/hooks/use-conditional-formatting-rules.d.ts +2 -0
- package/dist/cjs/hooks/use-conditional-formatting-rules.d.ts.map +1 -1
- package/dist/cjs/hooks/use-conditional-formatting-rules.js +22 -1
- package/dist/cjs/hooks/use-on-paste.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-paste.js +8 -1
- package/dist/cjs/hooks/use-sparkline-groups.d.ts +1 -0
- package/dist/cjs/hooks/use-sparkline-groups.d.ts.map +1 -1
- package/dist/cjs/hooks/use-sparkline-groups.js +28 -1
- package/dist/cjs/hooks/use-spreadsheet-state.d.ts +3 -0
- package/dist/cjs/hooks/use-spreadsheet-state.d.ts.map +1 -1
- package/dist/cjs/hooks/use-spreadsheet-state.js +11 -6
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/interface/change-border.d.ts.map +1 -1
- package/dist/cjs/interface/change-border.js +8 -1
- package/dist/cjs/interface/conditional-formatting-rules.d.ts +11 -1
- package/dist/cjs/interface/conditional-formatting-rules.d.ts.map +1 -1
- package/dist/cjs/interface/conditional-formatting-rules.js +44 -1
- package/dist/cjs/sheet-cell.d.ts +8 -0
- package/dist/cjs/sheet-cell.d.ts.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/api/border.d.ts +1 -1
- package/dist/esm/api/border.d.ts.map +1 -1
- package/dist/esm/api/paste-special.d.ts +33 -2
- package/dist/esm/api/paste-special.d.ts.map +1 -1
- package/dist/esm/api/paste-special.js +62 -13
- package/dist/esm/commands.d.ts +208 -3
- package/dist/esm/commands.d.ts.map +1 -1
- package/dist/esm/components/editors/cell-format/alignment-tab.d.ts +27 -0
- package/dist/esm/components/editors/cell-format/alignment-tab.d.ts.map +1 -0
- package/dist/esm/components/editors/cell-format/alignment-tab.js +81 -0
- package/dist/esm/components/editors/cell-format/border-edges.d.ts +42 -0
- package/dist/esm/components/editors/cell-format/border-edges.d.ts.map +1 -0
- package/dist/esm/components/editors/cell-format/border-edges.js +79 -0
- package/dist/esm/components/editors/cell-format/border-tab.d.ts +21 -0
- package/dist/esm/components/editors/cell-format/border-tab.d.ts.map +1 -0
- package/dist/esm/components/editors/cell-format/border-tab.js +103 -0
- package/dist/esm/components/editors/cell-format/fill-tab.d.ts +14 -0
- package/dist/esm/components/editors/cell-format/fill-tab.d.ts.map +1 -0
- package/dist/esm/components/editors/cell-format/fill-tab.js +49 -0
- package/dist/esm/components/editors/cell-format/font-tab.d.ts +18 -0
- package/dist/esm/components/editors/cell-format/font-tab.d.ts.map +1 -0
- package/dist/esm/components/editors/cell-format/font-tab.js +88 -0
- package/dist/esm/components/editors/cell-format/list-box.d.ts +35 -0
- package/dist/esm/components/editors/cell-format/list-box.d.ts.map +1 -0
- package/dist/esm/components/editors/cell-format/list-box.js +30 -0
- package/dist/esm/components/editors/cell-format/number-formats.d.ts +90 -0
- package/dist/esm/components/editors/cell-format/number-formats.d.ts.map +1 -0
- package/dist/esm/components/editors/cell-format/number-formats.js +383 -0
- package/dist/esm/components/editors/cell-format/number-tab.d.ts +12 -0
- package/dist/esm/components/editors/cell-format/number-tab.d.ts.map +1 -0
- package/dist/esm/components/editors/cell-format/number-tab.js +165 -0
- package/dist/esm/components/editors/cell-format/protection-tab.d.ts +13 -0
- package/dist/esm/components/editors/cell-format/protection-tab.d.ts.map +1 -0
- package/dist/esm/components/editors/cell-format/protection-tab.js +9 -0
- package/dist/esm/components/editors/cell-format-editor.d.ts +31 -3
- package/dist/esm/components/editors/cell-format-editor.d.ts.map +1 -1
- package/dist/esm/components/editors/cell-format-editor.js +148 -615
- package/dist/esm/components/editors/conditional-format-data-bar-options.d.ts +16 -0
- package/dist/esm/components/editors/conditional-format-data-bar-options.d.ts.map +1 -0
- package/dist/esm/components/editors/conditional-format-data-bar-options.js +145 -0
- package/dist/esm/components/editors/conditional-format-editor.d.ts +7 -1
- package/dist/esm/components/editors/conditional-format-editor.d.ts.map +1 -1
- package/dist/esm/components/editors/conditional-format-editor.js +39 -8
- package/dist/esm/components/editors/conditional-format-icon-set-options.d.ts +17 -0
- package/dist/esm/components/editors/conditional-format-icon-set-options.d.ts.map +1 -0
- package/dist/esm/components/editors/conditional-format-icon-set-options.js +139 -0
- package/dist/esm/components/editors/conditional-format-rule-editor.d.ts +9 -0
- package/dist/esm/components/editors/conditional-format-rule-editor.d.ts.map +1 -1
- package/dist/esm/components/editors/conditional-format-rule-editor.js +60 -85
- package/dist/esm/components/editors/sheet-filter.d.ts +20 -9
- package/dist/esm/components/editors/sheet-filter.d.ts.map +1 -1
- package/dist/esm/components/editors/sheet-filter.js +31 -11
- package/dist/esm/constants.d.ts +3 -1
- package/dist/esm/constants.d.ts.map +1 -1
- package/dist/esm/constants.js +3 -0
- package/dist/esm/hooks/use-conditional-formatting-rules.d.ts +2 -0
- package/dist/esm/hooks/use-conditional-formatting-rules.d.ts.map +1 -1
- package/dist/esm/hooks/use-conditional-formatting-rules.js +19 -1
- package/dist/esm/hooks/use-on-paste.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-paste.js +8 -1
- package/dist/esm/hooks/use-sparkline-groups.d.ts +1 -0
- package/dist/esm/hooks/use-sparkline-groups.d.ts.map +1 -1
- package/dist/esm/hooks/use-sparkline-groups.js +20 -1
- package/dist/esm/hooks/use-spreadsheet-state.d.ts +3 -0
- package/dist/esm/hooks/use-spreadsheet-state.d.ts.map +1 -1
- package/dist/esm/hooks/use-spreadsheet-state.js +11 -4
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/interface/change-border.d.ts.map +1 -1
- package/dist/esm/interface/change-border.js +8 -1
- package/dist/esm/interface/conditional-formatting-rules.d.ts +11 -1
- package/dist/esm/interface/conditional-formatting-rules.d.ts.map +1 -1
- package/dist/esm/interface/conditional-formatting-rules.js +29 -1
- package/dist/esm/sheet-cell.d.ts +8 -0
- package/dist/esm/sheet-cell.d.ts.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { __assign, __read } from "tslib";
|
|
2
|
+
import { Input } from "@rowsncolumns/ui";
|
|
3
|
+
import { ssfFormat, ssfFormatColor } from "@rowsncolumns/utils";
|
|
4
|
+
import React, { useMemo, useState } from "react";
|
|
5
|
+
import { CheckboxField, ListBox, SelectField } from "./list-box";
|
|
6
|
+
import { buildAccountingPattern, buildCurrencyPattern, buildNumberPattern, buildPercentPattern, buildScientificPattern, CURRENCY_SYMBOLS, CUSTOM_PATTERNS, defaultFormatForCategory, detectCategory, findFormatLocale, FORMAT_LOCALES, FRACTION_TYPES, getDateTimeTypes, getPatternLocale, inferTypeFromPattern, NEGATIVE_STYLES, NUMBER_CATEGORIES, parseNumericPattern, SPECIAL_TYPES, } from "./number-formats";
|
|
7
|
+
var SAMPLE_NEGATIVE = -1234.1;
|
|
8
|
+
var render = function (pattern, value) {
|
|
9
|
+
try {
|
|
10
|
+
return ssfFormat(pattern, value) || " ";
|
|
11
|
+
}
|
|
12
|
+
catch (_a) {
|
|
13
|
+
return " ";
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var colorOf = function (pattern, value) {
|
|
17
|
+
try {
|
|
18
|
+
return ssfFormatColor(pattern, value);
|
|
19
|
+
}
|
|
20
|
+
catch (_a) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
/** Format Cells → Number. */
|
|
25
|
+
export var NumberTab = function (_a) {
|
|
26
|
+
var _b;
|
|
27
|
+
var numberFormat = _a.numberFormat, onChange = _a.onChange, sampleValue = _a.sampleValue, locale = _a.locale, currencySymbol = _a.currencySymbol;
|
|
28
|
+
var defaultLocale = findFormatLocale(locale);
|
|
29
|
+
var _c = __read(useState(function () {
|
|
30
|
+
return detectCategory(numberFormat);
|
|
31
|
+
}), 2), category = _c[0], setCategory = _c[1];
|
|
32
|
+
var _d = __read(useState(function () { var _a; return (_a = getPatternLocale(numberFormat === null || numberFormat === void 0 ? void 0 : numberFormat.pattern)) !== null && _a !== void 0 ? _a : defaultLocale; }), 2), formatLocale = _d[0], setFormatLocale = _d[1];
|
|
33
|
+
var pattern = (_b = numberFormat === null || numberFormat === void 0 ? void 0 : numberFormat.pattern) !== null && _b !== void 0 ? _b : "General";
|
|
34
|
+
var parsed = parseNumericPattern(numberFormat === null || numberFormat === void 0 ? void 0 : numberFormat.pattern);
|
|
35
|
+
var definition = NUMBER_CATEGORIES.find(function (c) { return c.id === category; });
|
|
36
|
+
var sample = render(pattern, sampleValue);
|
|
37
|
+
var pickCategory = function (id) {
|
|
38
|
+
setCategory(id);
|
|
39
|
+
if (id === "custom")
|
|
40
|
+
return;
|
|
41
|
+
onChange(defaultFormatForCategory(id, {
|
|
42
|
+
currencySymbol: currencySymbol,
|
|
43
|
+
locale: formatLocale,
|
|
44
|
+
defaultLocale: defaultLocale,
|
|
45
|
+
}));
|
|
46
|
+
};
|
|
47
|
+
var dateTimeTypes = useMemo(function () {
|
|
48
|
+
return category === "date" || category === "time"
|
|
49
|
+
? getDateTimeTypes(category, formatLocale, defaultLocale)
|
|
50
|
+
: [];
|
|
51
|
+
}, [category, formatLocale, defaultLocale]);
|
|
52
|
+
var decimalsField = function (onDecimals) { return (React.createElement("label", { className: "flex flex-col gap-1 font-system text-sm" },
|
|
53
|
+
"Decimal places",
|
|
54
|
+
React.createElement(Input, { "aria-label": "Decimal places", type: "number", min: 0, max: 30, className: "text-xs", value: parsed.decimals, onChange: function (event) {
|
|
55
|
+
var n = parseInt(event.target.value, 10);
|
|
56
|
+
if (Number.isFinite(n))
|
|
57
|
+
onDecimals(Math.max(0, Math.min(30, n)));
|
|
58
|
+
} }))); };
|
|
59
|
+
var symbolField = function (onSymbol) { return (React.createElement(SelectField, { label: "Symbol", value: parsed.symbol, options: CURRENCY_SYMBOLS.map(function (s) { return ({ value: s.symbol, label: s.label }); }), onChange: onSymbol })); };
|
|
60
|
+
var negativeList = function (build, selected) { return (React.createElement("div", { className: "flex flex-col gap-1" },
|
|
61
|
+
React.createElement("span", { className: "font-system text-sm" }, "Negative numbers"),
|
|
62
|
+
React.createElement(ListBox, { label: "Negative numbers", value: selected, items: NEGATIVE_STYLES.map(function (style) {
|
|
63
|
+
var p = build(style);
|
|
64
|
+
return {
|
|
65
|
+
value: style,
|
|
66
|
+
label: (React.createElement("span", { style: { color: colorOf(p, SAMPLE_NEGATIVE) } }, render(p, SAMPLE_NEGATIVE))),
|
|
67
|
+
};
|
|
68
|
+
}), onChange: function (style) { var _a; return onChange({ type: (_a = numberFormat === null || numberFormat === void 0 ? void 0 : numberFormat.type) !== null && _a !== void 0 ? _a : "NUMBER", pattern: build(style) }); } }))); };
|
|
69
|
+
var localeField = (React.createElement(SelectField, { label: "Locale (location)", value: formatLocale.tag, options: FORMAT_LOCALES.map(function (l) { return ({ value: l.tag, label: l.label }); }), onChange: function (tag) {
|
|
70
|
+
var next = findFormatLocale(tag);
|
|
71
|
+
setFormatLocale(next);
|
|
72
|
+
if (category === "date" || category === "time") {
|
|
73
|
+
onChange({
|
|
74
|
+
type: category === "date" ? "DATE" : "DATE_TIME",
|
|
75
|
+
pattern: getDateTimeTypes(category, next, defaultLocale)[0],
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
} }));
|
|
79
|
+
var options = null;
|
|
80
|
+
switch (category) {
|
|
81
|
+
case "number":
|
|
82
|
+
options = (React.createElement(React.Fragment, null,
|
|
83
|
+
decimalsField(function (decimals) {
|
|
84
|
+
return onChange({
|
|
85
|
+
type: "NUMBER",
|
|
86
|
+
pattern: buildNumberPattern(__assign(__assign({}, parsed), { decimals: decimals })),
|
|
87
|
+
});
|
|
88
|
+
}),
|
|
89
|
+
React.createElement(CheckboxField, { label: "Use 1000 Separator (,)", checked: parsed.thousands, onChange: function (thousands) {
|
|
90
|
+
return onChange({
|
|
91
|
+
type: "NUMBER",
|
|
92
|
+
pattern: buildNumberPattern(__assign(__assign({}, parsed), { thousands: thousands })),
|
|
93
|
+
});
|
|
94
|
+
} }),
|
|
95
|
+
negativeList(function (negative) { return buildNumberPattern(__assign(__assign({}, parsed), { negative: negative })); }, parsed.negative)));
|
|
96
|
+
break;
|
|
97
|
+
case "currency":
|
|
98
|
+
options = (React.createElement(React.Fragment, null,
|
|
99
|
+
decimalsField(function (decimals) {
|
|
100
|
+
return onChange({
|
|
101
|
+
type: "CURRENCY",
|
|
102
|
+
pattern: buildCurrencyPattern(__assign(__assign({}, parsed), { decimals: decimals })),
|
|
103
|
+
});
|
|
104
|
+
}),
|
|
105
|
+
symbolField(function (symbol) {
|
|
106
|
+
return onChange({
|
|
107
|
+
type: "CURRENCY",
|
|
108
|
+
pattern: buildCurrencyPattern(__assign(__assign({}, parsed), { symbol: symbol })),
|
|
109
|
+
});
|
|
110
|
+
}),
|
|
111
|
+
negativeList(function (negative) { return buildCurrencyPattern(__assign(__assign({}, parsed), { negative: negative })); }, parsed.negative)));
|
|
112
|
+
break;
|
|
113
|
+
case "accounting":
|
|
114
|
+
options = (React.createElement(React.Fragment, null,
|
|
115
|
+
decimalsField(function (decimals) {
|
|
116
|
+
return onChange({
|
|
117
|
+
type: "ACCOUNTING",
|
|
118
|
+
pattern: buildAccountingPattern(__assign(__assign({}, parsed), { decimals: decimals })),
|
|
119
|
+
});
|
|
120
|
+
}),
|
|
121
|
+
symbolField(function (symbol) {
|
|
122
|
+
return onChange({
|
|
123
|
+
type: "ACCOUNTING",
|
|
124
|
+
pattern: buildAccountingPattern(__assign(__assign({}, parsed), { symbol: symbol })),
|
|
125
|
+
});
|
|
126
|
+
})));
|
|
127
|
+
break;
|
|
128
|
+
case "percentage":
|
|
129
|
+
options = decimalsField(function (decimals) {
|
|
130
|
+
return onChange({ type: "PERCENT", pattern: buildPercentPattern(decimals) });
|
|
131
|
+
});
|
|
132
|
+
break;
|
|
133
|
+
case "scientific":
|
|
134
|
+
options = decimalsField(function (decimals) {
|
|
135
|
+
return onChange({ type: "SCIENTIFIC", pattern: buildScientificPattern(decimals) });
|
|
136
|
+
});
|
|
137
|
+
break;
|
|
138
|
+
case "date":
|
|
139
|
+
case "time":
|
|
140
|
+
options = (React.createElement(React.Fragment, null,
|
|
141
|
+
React.createElement("div", { className: "flex flex-col gap-1" },
|
|
142
|
+
React.createElement("span", { className: "font-system text-sm" }, "Type"),
|
|
143
|
+
React.createElement(ListBox, { label: "Type", value: pattern, items: dateTimeTypes.map(function (p) { return ({
|
|
144
|
+
value: p,
|
|
145
|
+
label: render(p, sampleDate()),
|
|
146
|
+
}); }), onChange: function (p) {
|
|
147
|
+
return onChange({
|
|
148
|
+
type: category === "date" ? "DATE" : "DATE_TIME",
|
|
149
|
+
pattern: p,
|
|
150
|
+
});
|
|
151
|
+
} })),
|
|
152
|
+
localeField));
|
|
153
|
+
break;
|
|
154
|
+
case "fraction":
|
|
155
|
+
options = (React.createElement("div", { className: "flex flex-col gap-1" },
|
|
156
|
+
React.createElement("span", { className: "font-system text-sm" }, "Type"),
|
|
157
|
+
React.createElement(ListBox, { label: "Type", value: pattern, items: FRACTION_TYPES.map(function (t) { return ({ value: t.pattern, label: t.label }); }), onChange: function (p) { return onChange({ type: "FRACTION", pattern: p }); } })));
|
|
158
|
+
break;
|
|
159
|
+
case "special":
|
|
160
|
+
options = (React.createElement(React.Fragment, null,
|
|
161
|
+
React.createElement("div", { className: "flex flex-col gap-1" },
|
|
162
|
+
React.createElement("span", { className: "font-system text-sm" }, "Type"),
|
|
163
|
+
React.createElement(ListBox, { label: "Type", value: pattern, items: SPECIAL_TYPES.map(function (t) { return ({ value: t.pattern, label: t.label }); }), onChange: function (p) { return onChange({ type: "SPECIAL", pattern: p }); } })),
|
|
164
|
+
React.createElement(SelectField, { label: "Locale (location)", value: "en-US", options: [{ value: "en-US", label: "English (United States)" }], onChange: function () { return undefined; } })));
|
|
165
|
+
break;
|
|
166
|
+
case "custom":
|
|
167
|
+
options = (React.createElement("div", { className: "flex flex-col gap-1" },
|
|
168
|
+
React.createElement("label", { className: "flex flex-col gap-1 font-system text-sm" },
|
|
169
|
+
"Type",
|
|
170
|
+
React.createElement(Input, { "aria-label": "Custom format code", type: "text", className: "text-xs", value: pattern, onChange: function (event) {
|
|
171
|
+
return onChange({
|
|
172
|
+
type: inferTypeFromPattern(event.target.value),
|
|
173
|
+
pattern: event.target.value,
|
|
174
|
+
});
|
|
175
|
+
} })),
|
|
176
|
+
React.createElement(ListBox, { label: "Custom formats", value: pattern, items: CUSTOM_PATTERNS.map(function (p) { return ({ value: p, label: p }); }), onChange: function (p) {
|
|
177
|
+
return onChange(p === "General" ? null : { type: inferTypeFromPattern(p), pattern: p });
|
|
178
|
+
} })));
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
return (React.createElement("div", { className: "grid grid-cols-[140px_1fr] gap-3" },
|
|
182
|
+
React.createElement("div", { className: "flex flex-col gap-1" },
|
|
183
|
+
React.createElement("span", { className: "font-system text-sm" }, "Category"),
|
|
184
|
+
React.createElement(ListBox, { label: "Category", value: category, items: NUMBER_CATEGORIES.map(function (c) { return ({ value: c.id, label: c.name }); }), onChange: pickCategory, className: "max-h-[260px]" })),
|
|
185
|
+
React.createElement("div", { className: "flex flex-col gap-2" },
|
|
186
|
+
React.createElement("div", { className: "flex flex-col gap-1" },
|
|
187
|
+
React.createElement("span", { className: "font-system text-sm" }, "Sample"),
|
|
188
|
+
React.createElement("div", { "data-testid": "number-sample", className: "rounded-sm bg-rnc-muted p-1 px-2 text-rnc-foreground", style: { color: colorOf(pattern, sampleValue) } }, sample)),
|
|
189
|
+
options,
|
|
190
|
+
React.createElement("p", { className: "font-system text-xs text-rnc-muted-foreground" }, definition === null || definition === void 0 ? void 0 : definition.description))));
|
|
191
|
+
};
|
|
192
|
+
// Excel previews date and time types on the active cell's value when it is a
|
|
193
|
+
// date; a fixed date keeps the list stable otherwise.
|
|
194
|
+
var sampleDate = function () { return new Date(2012, 2, 14, 13, 30, 55); };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type CellProtectionDraft = {
|
|
3
|
+
locked: boolean;
|
|
4
|
+
hidden: boolean;
|
|
5
|
+
};
|
|
6
|
+
/** Excel's note under the Protection tab's checkboxes. */
|
|
7
|
+
export declare const PROTECTION_NOTE = "Locking cells or hiding formulas has no effect until you protect the worksheet (Review tab, Protect group, Protect Sheet button).";
|
|
8
|
+
/** Format Cells → Protection: Locked (default on) and Hidden. */
|
|
9
|
+
export declare const ProtectionTab: ({ protection, onChange, }: {
|
|
10
|
+
protection: CellProtectionDraft;
|
|
11
|
+
onChange(protection: CellProtectionDraft): void;
|
|
12
|
+
}) => React.JSX.Element;
|
|
13
|
+
//# sourceMappingURL=protection-tab.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protection-tab.d.ts","sourceRoot":"","sources":["../../../../../components/editors/cell-format/protection-tab.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,MAAM,mBAAmB,GAAG;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC;AAEvE,0DAA0D;AAC1D,eAAO,MAAM,eAAe,sIACyG,CAAC;AAEtI,iEAAiE;AACjE,eAAO,MAAM,aAAa,GAAI,2BAG3B;IACD,UAAU,EAAE,mBAAmB,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,mBAAmB,GAAG,IAAI,CAAC;CACjD,sBAcA,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { CheckboxField } from "./list-box";
|
|
4
|
+
/** Excel's note under the Protection tab's checkboxes. */
|
|
5
|
+
export var PROTECTION_NOTE = "Locking cells or hiding formulas has no effect until you protect the worksheet (Review tab, Protect group, Protect Sheet button).";
|
|
6
|
+
/** Format Cells → Protection: Locked (default on) and Hidden. */
|
|
7
|
+
export var ProtectionTab = function (_a) {
|
|
8
|
+
var protection = _a.protection, onChange = _a.onChange;
|
|
9
|
+
return (React.createElement("div", { className: "flex flex-col gap-2" },
|
|
10
|
+
React.createElement(CheckboxField, { label: "Locked", checked: protection.locked, onChange: function (locked) { return onChange(__assign(__assign({}, protection), { locked: locked })); } }),
|
|
11
|
+
React.createElement(CheckboxField, { label: "Hidden", checked: protection.hidden, onChange: function (hidden) { return onChange(__assign(__assign({}, protection), { hidden: hidden })); } }),
|
|
12
|
+
React.createElement("p", { className: "font-system text-xs text-rnc-muted-foreground" }, PROTECTION_NOTE)));
|
|
13
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { CellInterface, SelectionArea } from "@rowsncolumns/common-types";
|
|
2
|
-
import type { SelectionAttributes, SpreadsheetTheme } from "@rowsncolumns/spreadsheet";
|
|
3
|
-
import type { CellFormat } from "@rowsncolumns/spreadsheet";
|
|
2
|
+
import type { CellFormat, SelectionAttributes, SpreadsheetTheme } from "@rowsncolumns/spreadsheet";
|
|
4
3
|
import React from "react";
|
|
5
4
|
import type { useSpreadsheetState } from "../../hooks/use-spreadsheet-state";
|
|
5
|
+
export type CellFormatTab = "number" | "alignment" | "font" | "border" | "fill" | "protection";
|
|
6
6
|
type CellFormatEditorProps = {
|
|
7
7
|
sheetId: number;
|
|
8
8
|
activeCell: CellInterface;
|
|
@@ -16,9 +16,37 @@ type CellFormatEditorProps = {
|
|
|
16
16
|
onChangeFormatting: ReturnType<typeof useSpreadsheetState>["onChangeFormatting"];
|
|
17
17
|
getEffectiveValue: ReturnType<typeof useSpreadsheetState>["getEffectiveValue"];
|
|
18
18
|
onMergeCells: ReturnType<typeof useSpreadsheetState>["onMergeCells"];
|
|
19
|
+
/** Alignment → Merge cells unchecked on a merged cell. */
|
|
20
|
+
onUnMergeCells?: ReturnType<typeof useSpreadsheetState>["onUnMergeCells"];
|
|
21
|
+
/** Whether the active cell is part of a merge (Merge cells opens checked). */
|
|
22
|
+
isMerged?: boolean;
|
|
23
|
+
/** The active cell's `CellData.protection` (Protection tab; absent = Locked, not Hidden). */
|
|
24
|
+
cellProtection?: {
|
|
25
|
+
locked?: boolean | null;
|
|
26
|
+
hidden?: boolean | null;
|
|
27
|
+
} | null;
|
|
28
|
+
/** Protection tab: write `locked` / `hidden` onto the selection. */
|
|
29
|
+
onChangeCellProtection?(sheetId: number, activeCell: CellInterface, selections: SelectionArea<SelectionAttributes>[], protection: {
|
|
30
|
+
locked?: boolean;
|
|
31
|
+
hidden?: boolean;
|
|
32
|
+
}): void;
|
|
33
|
+
/** The tab the dialog opens on (Excel reopens on the last one used). */
|
|
34
|
+
defaultTab?: CellFormatTab;
|
|
19
35
|
onCancel?(): void;
|
|
20
36
|
};
|
|
21
|
-
|
|
37
|
+
/**
|
|
38
|
+
* The properties the dialog changed, and only those — Excel's Format Cells
|
|
39
|
+
* applies what you edited to every selected cell and leaves the rest of each
|
|
40
|
+
* cell's format alone. A removed value is sent as `undefined` (the engines'
|
|
41
|
+
* clear for that property).
|
|
42
|
+
*/
|
|
43
|
+
export declare const diffCellFormat: (initial: CellFormat, draft: CellFormat) => CellFormat;
|
|
44
|
+
/**
|
|
45
|
+
* Excel's Format Cells dialog (Ctrl+1 / ⌘1): Number, Alignment, Font,
|
|
46
|
+
* Border, Fill and Protection. Every tab edits a draft; OK applies the
|
|
47
|
+
* edits to the selection, Cancel drops them.
|
|
48
|
+
*/
|
|
49
|
+
export declare const CellFormatEditor: ({ locale, cellFormat, sheetId, activeCell, selections, currencySymbol, theme, isDarkMode, onMergeCells, onUnMergeCells, isMerged, cellProtection, onChangeCellProtection, onChangeFormatting, onChangeBorder, onCancel, getEffectiveValue, defaultTab, }: CellFormatEditorProps) => React.JSX.Element;
|
|
22
50
|
export declare const CellFormatEditorDialog: ({ children, }: {
|
|
23
51
|
children: React.ReactNode;
|
|
24
52
|
}) => React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell-format-editor.d.ts","sourceRoot":"","sources":["../../../../components/editors/cell-format-editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+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