@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.
- package/dist/cjs/api/border.d.ts +1 -1
- package/dist/cjs/api/border.d.ts.map +1 -1
- package/dist/cjs/commands.d.ts +36 -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/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-spreadsheet-state.d.ts +2 -0
- package/dist/cjs/hooks/use-spreadsheet-state.d.ts.map +1 -1
- package/dist/cjs/hooks/use-spreadsheet-state.js +4 -2
- 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/commands.d.ts +36 -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/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-spreadsheet-state.d.ts +2 -0
- package/dist/esm/hooks/use-spreadsheet-state.d.ts.map +1 -1
- package/dist/esm/hooks/use-spreadsheet-state.js +4 -2
- 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 +6 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __assign, __read, __spreadArray } from "tslib";
|
|
2
2
|
import { useIsomorphicLayoutEffect } from "@rowsncolumns/grid";
|
|
3
3
|
import { CrossCircledIcon } from "@rowsncolumns/icons";
|
|
4
|
-
import { BackgroundColorSelector, BorderSelector, ButtonBold, ButtonItalic, ButtonStrikethrough, ButtonUnderline, CONDITION_LABELS, CONDITION_NONE, FormulaInput, getStringifiedColor,
|
|
4
|
+
import { BackgroundColorSelector, BorderSelector, ButtonBold, ButtonItalic, ButtonStrikethrough, ButtonUnderline, CONDITION_LABELS, CONDITION_NONE, FormulaInput, getStringifiedColor, shouldShowFromValue, shouldShowToValue, TextColorSelector, useFormulaInputState, useFormulaRangeHelpers, } from "@rowsncolumns/spreadsheet";
|
|
5
5
|
import { Button, IconButton, Input, Select, SelectContent, SelectItem, SelectPortal, SelectTrigger, SelectValue, Stack, } from "@rowsncolumns/ui";
|
|
6
6
|
import { isNil, uuid } from "@rowsncolumns/utils";
|
|
7
7
|
import { useFormik } from "formik";
|
|
@@ -9,6 +9,8 @@ import isEqual from "lodash/isEqual";
|
|
|
9
9
|
import omit from "lodash/omit";
|
|
10
10
|
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
11
11
|
import { getBorderWidthFromStyle, getCSSBorderStyleFromStyle, } from "../../api/border";
|
|
12
|
+
import { ConditionalFormatDataBarOptions, DEFAULT_DATA_BAR_RULE, } from "./conditional-format-data-bar-options";
|
|
13
|
+
import { ConditionalFormatIconSetOptions, defaultIconThresholds, } from "./conditional-format-icon-set-options";
|
|
12
14
|
export var createBorderCSSFromBorder = function (borders, theme) {
|
|
13
15
|
if (!borders) {
|
|
14
16
|
return {};
|
|
@@ -41,6 +43,43 @@ export var createRulePreviewStyle = function (format, theme) {
|
|
|
41
43
|
" " +
|
|
42
44
|
(((_e = format === null || format === void 0 ? void 0 : format.textFormat) === null || _e === void 0 ? void 0 : _e.strikethrough) ? "line-through" : "") }, createBorderCSSFromBorder(format === null || format === void 0 ? void 0 : format.borders, theme));
|
|
43
45
|
};
|
|
46
|
+
/** Excel's "Format only values that are above or below average" choices. */
|
|
47
|
+
export var AVERAGE_OPTIONS = __spreadArray(__spreadArray([
|
|
48
|
+
{ key: "above", label: "above", type: "NUMBER_ABOVE_AVERAGE" },
|
|
49
|
+
{ key: "below", label: "below", type: "NUMBER_BELOW_AVERAGE" },
|
|
50
|
+
{
|
|
51
|
+
key: "equalAbove",
|
|
52
|
+
label: "equal or above",
|
|
53
|
+
type: "NUMBER_ABOVE_AVERAGE",
|
|
54
|
+
equalAverage: true,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
key: "equalBelow",
|
|
58
|
+
label: "equal or below",
|
|
59
|
+
type: "NUMBER_BELOW_AVERAGE",
|
|
60
|
+
equalAverage: true,
|
|
61
|
+
}
|
|
62
|
+
], __read([1, 2, 3].map(function (stdDev) { return ({
|
|
63
|
+
key: "above".concat(stdDev),
|
|
64
|
+
label: "".concat(stdDev, " std dev above"),
|
|
65
|
+
type: "NUMBER_ABOVE_AVERAGE",
|
|
66
|
+
stdDev: stdDev,
|
|
67
|
+
}); })), false), __read([1, 2, 3].map(function (stdDev) { return ({
|
|
68
|
+
key: "below".concat(stdDev),
|
|
69
|
+
label: "".concat(stdDev, " std dev below"),
|
|
70
|
+
type: "NUMBER_BELOW_AVERAGE",
|
|
71
|
+
stdDev: stdDev,
|
|
72
|
+
}); })), false);
|
|
73
|
+
export var averageOptionKey = function (rule) {
|
|
74
|
+
var _a;
|
|
75
|
+
var above = ((_a = rule === null || rule === void 0 ? void 0 : rule.condition) === null || _a === void 0 ? void 0 : _a.type) !== "NUMBER_BELOW_AVERAGE";
|
|
76
|
+
if (rule === null || rule === void 0 ? void 0 : rule.stdDev) {
|
|
77
|
+
return "".concat(above ? "above" : "below").concat(rule.stdDev);
|
|
78
|
+
}
|
|
79
|
+
if (rule === null || rule === void 0 ? void 0 : rule.equalAverage)
|
|
80
|
+
return above ? "equalAbove" : "equalBelow";
|
|
81
|
+
return above ? "above" : "below";
|
|
82
|
+
};
|
|
44
83
|
var ensureFormula = function (value) {
|
|
45
84
|
if (!value)
|
|
46
85
|
return undefined;
|
|
@@ -65,16 +104,16 @@ var ConditionalFormatRangeInput = function (_a) {
|
|
|
65
104
|
}, value: formulaInput.value, required: true, placeholder: "Select a range", autoFocus: autoFocus, className: "mb-0" }));
|
|
66
105
|
};
|
|
67
106
|
export var ConditionalFormatRuleEditor = function (_a) {
|
|
68
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18;
|
|
107
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19;
|
|
69
108
|
var sheetId = _a.sheetId, conditionalFormatRule = _a.conditionalFormatRule, theme = _a.theme, functionDescriptions = _a.functionDescriptions, locale = _a.locale, idCreationStrategy = _a.idCreationStrategy, onSubmit = _a.onSubmit, onCancel = _a.onCancel, onChange = _a.onChange;
|
|
70
|
-
var
|
|
109
|
+
var _20 = __read(useState(function () {
|
|
71
110
|
var _a, _b, _c;
|
|
72
111
|
return shouldShowToValue((_c = (_b = (_a = conditionalFormatRule.booleanRule) === null || _a === void 0 ? void 0 : _a.condition) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : undefined);
|
|
73
|
-
}), 2), showToValue =
|
|
74
|
-
var
|
|
112
|
+
}), 2), showToValue = _20[0], setShowToValue = _20[1];
|
|
113
|
+
var _21 = __read(useState(function () {
|
|
75
114
|
var _a, _b, _c;
|
|
76
115
|
return shouldShowFromValue((_c = (_b = (_a = conditionalFormatRule.booleanRule) === null || _a === void 0 ? void 0 : _a.condition) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : undefined);
|
|
77
|
-
}), 2), showFromValue =
|
|
116
|
+
}), 2), showFromValue = _21[0], setShowFromValue = _21[1];
|
|
78
117
|
var conditionLabelOptions = useMemo(function () {
|
|
79
118
|
return CONDITION_LABELS.filter(function (_a) {
|
|
80
119
|
var condition = _a.condition;
|
|
@@ -88,9 +127,9 @@ export var ConditionalFormatRuleEditor = function (_a) {
|
|
|
88
127
|
}, []);
|
|
89
128
|
var selectedTabRef = useRef("booleanRule");
|
|
90
129
|
// Helpers
|
|
91
|
-
var
|
|
130
|
+
var _22 = useFormulaRangeHelpers({
|
|
92
131
|
sheetId: sheetId,
|
|
93
|
-
}), rangeToFormula =
|
|
132
|
+
}), rangeToFormula = _22.rangeToFormula, formulaToRange = _22.formulaToRange;
|
|
94
133
|
var sanitizeRuleByTab = function (rule, tab) {
|
|
95
134
|
if (tab === void 0) { tab = selectedTabRef.current; }
|
|
96
135
|
var allRuleKeys = [
|
|
@@ -110,14 +149,14 @@ export var ConditionalFormatRuleEditor = function (_a) {
|
|
|
110
149
|
// state on some hosts).
|
|
111
150
|
var dismissalRef = useRef({ settled: false, dirty: false });
|
|
112
151
|
var restorePreviewRef = useRef(function () { });
|
|
113
|
-
var
|
|
152
|
+
var _23 = useFormik({
|
|
114
153
|
initialValues: conditionalFormatRule,
|
|
115
154
|
enableReinitialize: false,
|
|
116
155
|
onSubmit: function (values) {
|
|
117
156
|
dismissalRef.current.settled = true;
|
|
118
157
|
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(sanitizeRuleByTab(values), sanitizeRuleByTab(initialValues));
|
|
119
158
|
},
|
|
120
|
-
}), setFieldValue =
|
|
159
|
+
}), setFieldValue = _23.setFieldValue, resetForm = _23.resetForm, handleSubmit = _23.handleSubmit, values = _23.values, initialValues = _23.initialValues;
|
|
121
160
|
var booleanRule = values.booleanRule, gradientRule = values.gradientRule, topBottomRule = values.topBottomRule, distinctRule = values.distinctRule, iconSetRule = values.iconSetRule, dataBarRule = values.dataBarRule;
|
|
122
161
|
var defaultTabValue = gradientRule
|
|
123
162
|
? "gradientRule"
|
|
@@ -130,17 +169,17 @@ export var ConditionalFormatRuleEditor = function (_a) {
|
|
|
130
169
|
: dataBarRule
|
|
131
170
|
? "dataBarRule"
|
|
132
171
|
: "booleanRule";
|
|
133
|
-
var
|
|
172
|
+
var _24 = __read(useState(defaultTabValue), 2), selectedTab = _24[0], onChangeSelectedTab = _24[1];
|
|
134
173
|
useEffect(function () {
|
|
135
174
|
selectedTabRef.current = selectedTab;
|
|
136
175
|
}, [selectedTab]);
|
|
137
|
-
var
|
|
176
|
+
var _25 = useMemo(function () {
|
|
138
177
|
var _a, _b, _c, _d, _e, _f;
|
|
139
178
|
return {
|
|
140
179
|
fromValue: (_c = (_b = (_a = booleanRule === null || booleanRule === void 0 ? void 0 : booleanRule.condition) === null || _a === void 0 ? void 0 : _a.values) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.userEnteredValue,
|
|
141
180
|
toValue: (_f = (_e = (_d = booleanRule === null || booleanRule === void 0 ? void 0 : booleanRule.condition) === null || _d === void 0 ? void 0 : _d.values) === null || _e === void 0 ? void 0 : _e[1]) === null || _f === void 0 ? void 0 : _f.userEnteredValue,
|
|
142
181
|
};
|
|
143
|
-
}, [booleanRule]), fromValue =
|
|
182
|
+
}, [booleanRule]), fromValue = _25.fromValue, toValue = _25.toValue;
|
|
144
183
|
var updateBooleanRuleInputs = function (nextFromValue, nextToValue, nextType, includeToValue, includeFromValue) {
|
|
145
184
|
var _a, _b;
|
|
146
185
|
if (nextType === void 0) { nextType = (_a = booleanRule === null || booleanRule === void 0 ? void 0 : booleanRule.condition) === null || _a === void 0 ? void 0 : _a.type; }
|
|
@@ -232,10 +271,7 @@ export var ConditionalFormatRuleEditor = function (_a) {
|
|
|
232
271
|
if (selectedTab === "iconSetRule" && !values.iconSetRule) {
|
|
233
272
|
setFieldValue("iconSetRule", {
|
|
234
273
|
iconSet: "3TrafficLights1",
|
|
235
|
-
thresholds:
|
|
236
|
-
{ type: "PERCENT", value: 33 },
|
|
237
|
-
{ type: "PERCENT", value: 67 },
|
|
238
|
-
],
|
|
274
|
+
thresholds: defaultIconThresholds(3),
|
|
239
275
|
});
|
|
240
276
|
}
|
|
241
277
|
}, [selectedTab, values.iconSetRule]);
|
|
@@ -244,11 +280,7 @@ export var ConditionalFormatRuleEditor = function (_a) {
|
|
|
244
280
|
// "Single color" on reopen). Mirrors the topBottomRule/distinctRule effects.
|
|
245
281
|
useIsomorphicLayoutEffect(function () {
|
|
246
282
|
if (selectedTab === "dataBarRule" && !values.dataBarRule) {
|
|
247
|
-
setFieldValue("dataBarRule",
|
|
248
|
-
minpoint: { type: "MIN" },
|
|
249
|
-
maxpoint: { type: "MAX" },
|
|
250
|
-
color: "#638ec6",
|
|
251
|
-
});
|
|
283
|
+
setFieldValue("dataBarRule", DEFAULT_DATA_BAR_RULE);
|
|
252
284
|
}
|
|
253
285
|
}, [selectedTab, values.dataBarRule]);
|
|
254
286
|
var len = values.ranges.length;
|
|
@@ -381,8 +413,23 @@ export var ConditionalFormatRuleEditor = function (_a) {
|
|
|
381
413
|
var condition = _a.condition, label = _a.label;
|
|
382
414
|
return (React.createElement(SelectItem, { key: condition, value: condition }, label));
|
|
383
415
|
}))))),
|
|
416
|
+
((_e = booleanRule === null || booleanRule === void 0 ? void 0 : booleanRule.condition) === null || _e === void 0 ? void 0 : _e.type) === "NUMBER_ABOVE_AVERAGE" ||
|
|
417
|
+
((_f = booleanRule === null || booleanRule === void 0 ? void 0 : booleanRule.condition) === null || _f === void 0 ? void 0 : _f.type) === "NUMBER_BELOW_AVERAGE" ? (React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-3" },
|
|
418
|
+
React.createElement("label", { className: "font-system text-sm" }, "Format values that are"),
|
|
419
|
+
React.createElement(Select, { value: averageOptionKey(booleanRule), onValueChange: function (key) {
|
|
420
|
+
var option = AVERAGE_OPTIONS.find(function (o) { return o.key === key; });
|
|
421
|
+
if (!option)
|
|
422
|
+
return;
|
|
423
|
+
setFieldValue("booleanRule.condition.type", option.type);
|
|
424
|
+
setFieldValue("booleanRule.equalAverage", option.equalAverage || undefined);
|
|
425
|
+
setFieldValue("booleanRule.stdDev", option.stdDev);
|
|
426
|
+
} },
|
|
427
|
+
React.createElement(SelectTrigger, { className: "text-sm", "aria-label": "Average option" },
|
|
428
|
+
React.createElement(SelectValue, null)),
|
|
429
|
+
React.createElement(SelectPortal, null,
|
|
430
|
+
React.createElement(SelectContent, null, AVERAGE_OPTIONS.map(function (option) { return (React.createElement(SelectItem, { key: option.key, value: option.key }, option.label)); })))))) : null,
|
|
384
431
|
React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-3" },
|
|
385
|
-
showFromValue ? (((
|
|
432
|
+
showFromValue ? (((_h = (_g = values.booleanRule) === null || _g === void 0 ? void 0 : _g.condition) === null || _h === void 0 ? void 0 : _h.type) === "CUSTOM_FORMULA" ? (React.createElement(FormulaInput, { onChange: function (value) {
|
|
386
433
|
return updateBooleanRuleInputs(value, undefined, "CUSTOM_FORMULA", false);
|
|
387
434
|
}, value: fromValue !== null && fromValue !== void 0 ? fromValue : "=", required: true, placeholder: "Enter a formula", autoFocus: true, functionDescriptions: functionDescriptions })) : (React.createElement(Input, { value: fromValue !== null && fromValue !== void 0 ? fromValue : "", type: "text", name: "fromValue", onChange: function (e) {
|
|
388
435
|
return updateBooleanRuleInputs(e.target.value, toValue);
|
|
@@ -393,31 +440,31 @@ export var ConditionalFormatRuleEditor = function (_a) {
|
|
|
393
440
|
React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-3" },
|
|
394
441
|
React.createElement("label", { className: "font-system text-sm" }, "Format"),
|
|
395
442
|
React.createElement(Stack, { direction: "horizontal", className: "gap-1" },
|
|
396
|
-
React.createElement(ButtonBold, { type: "button", isActive: (
|
|
443
|
+
React.createElement(ButtonBold, { type: "button", isActive: (_k = (_j = booleanRule === null || booleanRule === void 0 ? void 0 : booleanRule.format) === null || _j === void 0 ? void 0 : _j.textFormat) === null || _k === void 0 ? void 0 : _k.bold, onClick: function () {
|
|
397
444
|
var _a, _b;
|
|
398
445
|
setFieldValue("booleanRule.format.textFormat.bold", !((_b = (_a = booleanRule === null || booleanRule === void 0 ? void 0 : booleanRule.format) === null || _a === void 0 ? void 0 : _a.textFormat) === null || _b === void 0 ? void 0 : _b.bold));
|
|
399
446
|
} }),
|
|
400
|
-
React.createElement(ButtonItalic, { isActive: (
|
|
447
|
+
React.createElement(ButtonItalic, { isActive: (_m = (_l = booleanRule === null || booleanRule === void 0 ? void 0 : booleanRule.format) === null || _l === void 0 ? void 0 : _l.textFormat) === null || _m === void 0 ? void 0 : _m.italic, onClick: function () {
|
|
401
448
|
var _a, _b;
|
|
402
449
|
setFieldValue("booleanRule.format.textFormat.italic", !((_b = (_a = booleanRule === null || booleanRule === void 0 ? void 0 : booleanRule.format) === null || _a === void 0 ? void 0 : _a.textFormat) === null || _b === void 0 ? void 0 : _b.italic));
|
|
403
450
|
} }),
|
|
404
|
-
React.createElement(ButtonUnderline, { isActive: (
|
|
451
|
+
React.createElement(ButtonUnderline, { isActive: (_p = (_o = booleanRule === null || booleanRule === void 0 ? void 0 : booleanRule.format) === null || _o === void 0 ? void 0 : _o.textFormat) === null || _p === void 0 ? void 0 : _p.underline, onClick: function () {
|
|
405
452
|
var _a, _b;
|
|
406
453
|
setFieldValue("booleanRule.format.textFormat.underline", !((_b = (_a = booleanRule === null || booleanRule === void 0 ? void 0 : booleanRule.format) === null || _a === void 0 ? void 0 : _a.textFormat) === null || _b === void 0 ? void 0 : _b.underline));
|
|
407
454
|
} }),
|
|
408
|
-
React.createElement(ButtonStrikethrough, { isActive: (
|
|
455
|
+
React.createElement(ButtonStrikethrough, { isActive: (_r = (_q = booleanRule === null || booleanRule === void 0 ? void 0 : booleanRule.format) === null || _q === void 0 ? void 0 : _q.textFormat) === null || _r === void 0 ? void 0 : _r.strikethrough, onClick: function () {
|
|
409
456
|
var _a, _b;
|
|
410
457
|
setFieldValue("booleanRule.format.textFormat.strikethrough", !((_b = (_a = booleanRule === null || booleanRule === void 0 ? void 0 : booleanRule.format) === null || _a === void 0 ? void 0 : _a.textFormat) === null || _b === void 0 ? void 0 : _b.strikethrough));
|
|
411
458
|
} }),
|
|
412
|
-
React.createElement(TextColorSelector, { color: (
|
|
459
|
+
React.createElement(TextColorSelector, { color: (_t = (_s = booleanRule === null || booleanRule === void 0 ? void 0 : booleanRule.format) === null || _s === void 0 ? void 0 : _s.textFormat) === null || _t === void 0 ? void 0 : _t.color, theme: theme,
|
|
413
460
|
// isDarkMode={isDarkMode}
|
|
414
461
|
onChange: function (value) {
|
|
415
462
|
setFieldValue("booleanRule.format.textFormat.color", value);
|
|
416
463
|
} }),
|
|
417
|
-
React.createElement(BackgroundColorSelector, { color: (
|
|
464
|
+
React.createElement(BackgroundColorSelector, { color: (_u = booleanRule === null || booleanRule === void 0 ? void 0 : booleanRule.format) === null || _u === void 0 ? void 0 : _u.backgroundColor, theme: theme, onChange: function (value) {
|
|
418
465
|
setFieldValue("booleanRule.format.backgroundColor", value);
|
|
419
466
|
} }),
|
|
420
|
-
React.createElement(BorderSelector, { theme: theme, borders: (
|
|
467
|
+
React.createElement(BorderSelector, { theme: theme, borders: (_v = booleanRule === null || booleanRule === void 0 ? void 0 : booleanRule.format) === null || _v === void 0 ? void 0 : _v.borders, disabledBorderLocations: [
|
|
421
468
|
"all",
|
|
422
469
|
"horizontal",
|
|
423
470
|
"inner",
|
|
@@ -459,7 +506,7 @@ export var ConditionalFormatRuleEditor = function (_a) {
|
|
|
459
506
|
React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-2" },
|
|
460
507
|
React.createElement("label", { className: "font-system text-sm" }, "Minpoint"),
|
|
461
508
|
React.createElement(Stack, { direction: "horizontal", className: "gap-2 items-center" },
|
|
462
|
-
React.createElement(Select, { value: (
|
|
509
|
+
React.createElement(Select, { value: (_x = (_w = gradientRule === null || gradientRule === void 0 ? void 0 : gradientRule.minpoint) === null || _w === void 0 ? void 0 : _w.type) !== null && _x !== void 0 ? _x : "MIN", onValueChange: function (value) {
|
|
463
510
|
var _a;
|
|
464
511
|
setFieldValue("gradientRule.minpoint", __assign(__assign({}, gradientRule === null || gradientRule === void 0 ? void 0 : gradientRule.minpoint), { type: value, value: value === "MIN" ? "" : (_a = gradientRule === null || gradientRule === void 0 ? void 0 : gradientRule.minpoint) === null || _a === void 0 ? void 0 : _a.value }));
|
|
465
512
|
} },
|
|
@@ -471,17 +518,17 @@ export var ConditionalFormatRuleEditor = function (_a) {
|
|
|
471
518
|
React.createElement(SelectItem, { value: "NUMBER" }, "Number"),
|
|
472
519
|
React.createElement(SelectItem, { value: "PERCENT" }, "Percent"),
|
|
473
520
|
React.createElement(SelectItem, { value: "PERCENTILE" }, "Percentile")))),
|
|
474
|
-
React.createElement(Input, { value: (
|
|
521
|
+
React.createElement(Input, { value: (_z = (_y = gradientRule === null || gradientRule === void 0 ? void 0 : gradientRule.minpoint) === null || _y === void 0 ? void 0 : _y.value) !== null && _z !== void 0 ? _z : "", onChange: function (e) {
|
|
475
522
|
return setFieldValue("gradientRule.minpoint.value", e.target.value);
|
|
476
|
-
}, disabled: !((
|
|
477
|
-
((
|
|
478
|
-
React.createElement(BackgroundColorSelector, { color: (
|
|
523
|
+
}, disabled: !((_0 = gradientRule === null || gradientRule === void 0 ? void 0 : gradientRule.minpoint) === null || _0 === void 0 ? void 0 : _0.type) ||
|
|
524
|
+
((_1 = gradientRule === null || gradientRule === void 0 ? void 0 : gradientRule.minpoint) === null || _1 === void 0 ? void 0 : _1.type) === "MIN" }),
|
|
525
|
+
React.createElement(BackgroundColorSelector, { color: (_2 = gradientRule === null || gradientRule === void 0 ? void 0 : gradientRule.minpoint) === null || _2 === void 0 ? void 0 : _2.color, theme: theme, onChange: function (value) {
|
|
479
526
|
setFieldValue("gradientRule.minpoint.color", value);
|
|
480
527
|
} }))),
|
|
481
528
|
React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-2" },
|
|
482
529
|
React.createElement("label", { className: "font-system text-sm" }, "Midpoint"),
|
|
483
530
|
React.createElement(Stack, { direction: "horizontal", className: "gap-2 items-center" },
|
|
484
|
-
React.createElement(Select, { value: (
|
|
531
|
+
React.createElement(Select, { value: (_4 = (_3 = gradientRule === null || gradientRule === void 0 ? void 0 : gradientRule.midpoint) === null || _3 === void 0 ? void 0 : _3.type) !== null && _4 !== void 0 ? _4 : CONDITION_NONE, onValueChange: function (value) {
|
|
485
532
|
setFieldValue("gradientRule.midpoint.type", value);
|
|
486
533
|
if (value === "MIN") {
|
|
487
534
|
setFieldValue("gradientRule.midpoint.value", "");
|
|
@@ -495,18 +542,18 @@ export var ConditionalFormatRuleEditor = function (_a) {
|
|
|
495
542
|
React.createElement(SelectItem, { value: "NUMBER" }, "Number"),
|
|
496
543
|
React.createElement(SelectItem, { value: "PERCENT" }, "Percent"),
|
|
497
544
|
React.createElement(SelectItem, { value: "PERCENTILE" }, "Percentile")))),
|
|
498
|
-
React.createElement(Input, { value: (
|
|
545
|
+
React.createElement(Input, { value: (_6 = (_5 = gradientRule === null || gradientRule === void 0 ? void 0 : gradientRule.midpoint) === null || _5 === void 0 ? void 0 : _5.value) !== null && _6 !== void 0 ? _6 : "", onChange: function (e) {
|
|
499
546
|
return setFieldValue("gradientRule.midpoint.value", e.target.value);
|
|
500
|
-
}, disabled: !((
|
|
501
|
-
((
|
|
547
|
+
}, disabled: !((_7 = gradientRule === null || gradientRule === void 0 ? void 0 : gradientRule.midpoint) === null || _7 === void 0 ? void 0 : _7.type) ||
|
|
548
|
+
((_8 = gradientRule === null || gradientRule === void 0 ? void 0 : gradientRule.midpoint) === null || _8 === void 0 ? void 0 : _8.type) ===
|
|
502
549
|
CONDITION_NONE }),
|
|
503
|
-
React.createElement(BackgroundColorSelector, { color: (
|
|
550
|
+
React.createElement(BackgroundColorSelector, { color: (_9 = gradientRule === null || gradientRule === void 0 ? void 0 : gradientRule.midpoint) === null || _9 === void 0 ? void 0 : _9.color, theme: theme, onChange: function (value) {
|
|
504
551
|
setFieldValue("gradientRule.midpoint.color", value);
|
|
505
552
|
} }))),
|
|
506
553
|
React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-2" },
|
|
507
554
|
React.createElement("label", { className: "font-system text-sm" }, "Maxpoint"),
|
|
508
555
|
React.createElement(Stack, { direction: "horizontal", className: "gap-2 items-center" },
|
|
509
|
-
React.createElement(Select, { value: (
|
|
556
|
+
React.createElement(Select, { value: (_11 = (_10 = gradientRule === null || gradientRule === void 0 ? void 0 : gradientRule.maxpoint) === null || _10 === void 0 ? void 0 : _10.type) !== null && _11 !== void 0 ? _11 : "MAX", onValueChange: function (value) {
|
|
510
557
|
setFieldValue("gradientRule.maxpoint.type", value);
|
|
511
558
|
if (value === "MIN") {
|
|
512
559
|
setFieldValue("gradientRule.maxpoint.value", "");
|
|
@@ -520,18 +567,18 @@ export var ConditionalFormatRuleEditor = function (_a) {
|
|
|
520
567
|
React.createElement(SelectItem, { value: "NUMBER" }, "Number"),
|
|
521
568
|
React.createElement(SelectItem, { value: "PERCENT" }, "Percent"),
|
|
522
569
|
React.createElement(SelectItem, { value: "PERCENTILE" }, "Percentile")))),
|
|
523
|
-
React.createElement(Input, { value: (
|
|
570
|
+
React.createElement(Input, { value: (_13 = (_12 = gradientRule === null || gradientRule === void 0 ? void 0 : gradientRule.maxpoint) === null || _12 === void 0 ? void 0 : _12.value) !== null && _13 !== void 0 ? _13 : "", onChange: function (e) {
|
|
524
571
|
return setFieldValue("gradientRule.maxpoint.value", e.target.value);
|
|
525
|
-
}, disabled: !((
|
|
526
|
-
((
|
|
527
|
-
React.createElement(BackgroundColorSelector, { color: (
|
|
572
|
+
}, disabled: !((_14 = gradientRule === null || gradientRule === void 0 ? void 0 : gradientRule.maxpoint) === null || _14 === void 0 ? void 0 : _14.type) ||
|
|
573
|
+
((_15 = gradientRule === null || gradientRule === void 0 ? void 0 : gradientRule.maxpoint) === null || _15 === void 0 ? void 0 : _15.type) === "MAX" }),
|
|
574
|
+
React.createElement(BackgroundColorSelector, { color: (_16 = gradientRule === null || gradientRule === void 0 ? void 0 : gradientRule.maxpoint) === null || _16 === void 0 ? void 0 : _16.color, theme: theme, onChange: function (value) {
|
|
528
575
|
setFieldValue("gradientRule.maxpoint.color", value);
|
|
529
576
|
} }))))),
|
|
530
577
|
selectedTab === "topBottomRule" && (React.createElement(React.Fragment, null,
|
|
531
578
|
React.createElement(Stack, { direction: "vertical", className: "gap-2 pb-3" },
|
|
532
579
|
React.createElement("label", { className: "font-system text-sm" }, "Rule"),
|
|
533
580
|
React.createElement(Stack, { direction: "horizontal", className: "gap-2 items-center" },
|
|
534
|
-
React.createElement(Select, { value: (
|
|
581
|
+
React.createElement(Select, { value: (_17 = topBottomRule === null || topBottomRule === void 0 ? void 0 : topBottomRule.type) !== null && _17 !== void 0 ? _17 : "TOP", onValueChange: function (value) {
|
|
535
582
|
setFieldValue("topBottomRule.type", value);
|
|
536
583
|
} },
|
|
537
584
|
React.createElement(SelectTrigger, { className: "text-sm" },
|
|
@@ -540,7 +587,7 @@ export var ConditionalFormatRuleEditor = function (_a) {
|
|
|
540
587
|
React.createElement(SelectContent, null,
|
|
541
588
|
React.createElement(SelectItem, { value: "TOP" }, "Top"),
|
|
542
589
|
React.createElement(SelectItem, { value: "BOTTOM" }, "Bottom")))),
|
|
543
|
-
React.createElement(Input, { className: "text-xs", type: "number", min: 1, value: (
|
|
590
|
+
React.createElement(Input, { className: "text-xs", type: "number", min: 1, value: (_18 = topBottomRule === null || topBottomRule === void 0 ? void 0 : topBottomRule.rank) !== null && _18 !== void 0 ? _18 : 5, onChange: function (event) {
|
|
544
591
|
var value = Number(event.target.value);
|
|
545
592
|
setFieldValue("topBottomRule.rank", Number.isNaN(value) ? 1 : Math.max(1, value));
|
|
546
593
|
} }),
|
|
@@ -556,7 +603,7 @@ export var ConditionalFormatRuleEditor = function (_a) {
|
|
|
556
603
|
selectedTab === "distinctRule" && (React.createElement(React.Fragment, null,
|
|
557
604
|
React.createElement(Stack, { direction: "vertical", className: "gap-2 pb-3" },
|
|
558
605
|
React.createElement("label", { className: "font-system text-sm" }, "Rule"),
|
|
559
|
-
React.createElement(Select, { value: (
|
|
606
|
+
React.createElement(Select, { value: (_19 = distinctRule === null || distinctRule === void 0 ? void 0 : distinctRule.type) !== null && _19 !== void 0 ? _19 : "DUPLICATE", onValueChange: function (value) {
|
|
560
607
|
setFieldValue("distinctRule.type", value);
|
|
561
608
|
} },
|
|
562
609
|
React.createElement(SelectTrigger, { className: "text-sm mb-0 w-40" },
|
|
@@ -569,83 +616,8 @@ export var ConditionalFormatRuleEditor = function (_a) {
|
|
|
569
616
|
React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-3" },
|
|
570
617
|
React.createElement("label", { className: "font-system text-sm" }, "Preview"),
|
|
571
618
|
React.createElement("div", { className: "p-2 text-center shadow-lg", style: createRulePreviewStyle(distinctRule === null || distinctRule === void 0 ? void 0 : distinctRule.format, theme) }, "AaBbCcYyZz")))),
|
|
572
|
-
selectedTab === "iconSetRule" && (React.createElement(
|
|
573
|
-
|
|
574
|
-
React.createElement(Select, { value: (_18 = iconSetRule === null || iconSetRule === void 0 ? void 0 : iconSetRule.iconSet) !== null && _18 !== void 0 ? _18 : "3TrafficLights1", onValueChange: function (value) {
|
|
575
|
-
var _a;
|
|
576
|
-
// Default thresholds at 33% / 67% to bucket the value range
|
|
577
|
-
// into 3 equal slices when switching to a 3-icon set, etc.
|
|
578
|
-
var familyDefaults = {
|
|
579
|
-
"3": [{ value: 33 }, { value: 67 }],
|
|
580
|
-
"4": [{ value: 25 }, { value: 50 }, { value: 75 }],
|
|
581
|
-
"5": [
|
|
582
|
-
{ value: 20 },
|
|
583
|
-
{ value: 40 },
|
|
584
|
-
{ value: 60 },
|
|
585
|
-
{ value: 80 },
|
|
586
|
-
],
|
|
587
|
-
};
|
|
588
|
-
var count = value.startsWith("5")
|
|
589
|
-
? "5"
|
|
590
|
-
: value.startsWith("4")
|
|
591
|
-
? "4"
|
|
592
|
-
: "3";
|
|
593
|
-
setFieldValue("iconSetRule.iconSet", value);
|
|
594
|
-
if (!((_a = iconSetRule === null || iconSetRule === void 0 ? void 0 : iconSetRule.thresholds) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
595
|
-
setFieldValue("iconSetRule.thresholds", familyDefaults[count].map(function (t) { return ({
|
|
596
|
-
type: "PERCENT",
|
|
597
|
-
value: t.value,
|
|
598
|
-
}); }));
|
|
599
|
-
}
|
|
600
|
-
} },
|
|
601
|
-
React.createElement(SelectTrigger, { className: "text-sm mb-0 w-64" },
|
|
602
|
-
React.createElement(SelectValue, { placeholder: "3 Traffic Lights" })),
|
|
603
|
-
React.createElement(SelectPortal, null,
|
|
604
|
-
React.createElement(SelectContent, null, [
|
|
605
|
-
["3Arrows", "3 Arrows"],
|
|
606
|
-
["3TrafficLights1", "3 Traffic Lights"],
|
|
607
|
-
["3Signs", "3 Signs"],
|
|
608
|
-
["3Symbols", "3 Symbols"],
|
|
609
|
-
["3Flags", "3 Flags"],
|
|
610
|
-
["4Arrows", "4 Arrows"],
|
|
611
|
-
["4Rating", "4 Rating"],
|
|
612
|
-
["4TrafficLights", "4 Traffic Lights"],
|
|
613
|
-
["5Arrows", "5 Arrows"],
|
|
614
|
-
["5Rating", "5 Rating"],
|
|
615
|
-
["5Quarters", "5 Quarters"],
|
|
616
|
-
].map(function (_a) {
|
|
617
|
-
var _b = __read(_a, 2), family = _b[0], label = _b[1];
|
|
618
|
-
var glyphs = ICON_SET_GLYPHS[family];
|
|
619
|
-
var colors = ICON_SET_COLORS[family];
|
|
620
|
-
return (React.createElement(SelectItem, { key: family, value: family },
|
|
621
|
-
React.createElement("span", { className: "inline-flex items-center gap-2" },
|
|
622
|
-
React.createElement("span", null, label),
|
|
623
|
-
React.createElement("span", { className: "inline-flex gap-0.5" }, glyphs.map(function (glyph, i) { return (React.createElement("span", { key: i, style: { color: colors[i] } }, glyph)); })))));
|
|
624
|
-
})))),
|
|
625
|
-
React.createElement("label", { className: "font-system text-sm mt-2 inline-flex items-center gap-2" },
|
|
626
|
-
React.createElement("input", { type: "checkbox", checked: !!(iconSetRule === null || iconSetRule === void 0 ? void 0 : iconSetRule.reverse), onChange: function (e) {
|
|
627
|
-
setFieldValue("iconSetRule.reverse", e.target.checked);
|
|
628
|
-
} }),
|
|
629
|
-
"Reverse icon order"))),
|
|
630
|
-
selectedTab === "dataBarRule" && (React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-1" },
|
|
631
|
-
React.createElement("label", { className: "font-system text-sm" }, "Bar color"),
|
|
632
|
-
React.createElement(Input, { type: "color", value: typeof (dataBarRule === null || dataBarRule === void 0 ? void 0 : dataBarRule.color) === "string"
|
|
633
|
-
? dataBarRule.color
|
|
634
|
-
: "#638ec6", onChange: function (e) {
|
|
635
|
-
setFieldValue("dataBarRule.color", e.target.value);
|
|
636
|
-
if (!(dataBarRule === null || dataBarRule === void 0 ? void 0 : dataBarRule.minpoint)) {
|
|
637
|
-
setFieldValue("dataBarRule.minpoint", { type: "MIN" });
|
|
638
|
-
}
|
|
639
|
-
if (!(dataBarRule === null || dataBarRule === void 0 ? void 0 : dataBarRule.maxpoint)) {
|
|
640
|
-
setFieldValue("dataBarRule.maxpoint", { type: "MAX" });
|
|
641
|
-
}
|
|
642
|
-
}, className: "w-24 h-8" }),
|
|
643
|
-
React.createElement("label", { className: "font-system text-sm mt-2" }, "Negative color (optional)"),
|
|
644
|
-
React.createElement(Input, { type: "color", value: typeof (dataBarRule === null || dataBarRule === void 0 ? void 0 : dataBarRule.negativeColor) === "string"
|
|
645
|
-
? dataBarRule.negativeColor
|
|
646
|
-
: "#dc2626", onChange: function (e) {
|
|
647
|
-
setFieldValue("dataBarRule.negativeColor", e.target.value);
|
|
648
|
-
}, className: "w-24 h-8" })))),
|
|
619
|
+
selectedTab === "iconSetRule" && (React.createElement(ConditionalFormatIconSetOptions, { rule: iconSetRule, onChange: function (next) { return setFieldValue("iconSetRule", next); } })),
|
|
620
|
+
selectedTab === "dataBarRule" && (React.createElement(ConditionalFormatDataBarOptions, { rule: dataBarRule, theme: theme, onChange: function (next) { return setFieldValue("dataBarRule", next); } }))),
|
|
649
621
|
React.createElement("div", { className: "flex gap-1 py-2" },
|
|
650
622
|
React.createElement(Button, { type: "submit", variant: "primary", size: "xs" }, "Save"),
|
|
651
623
|
React.createElement(Button, { size: "xs", onClick: onCancelForm, type: "button" }, "Cancel"))));
|
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
/**
|
|
3
|
-
* "all",
|
|
3
|
+
* "all", "selection" (Excel's "Show formatting rules for: Current Selection"), or a specific sheet
|
|
4
|
+
* id a rule list is narrowed to.
|
|
4
5
|
*/
|
|
5
|
-
export type SheetFilter = number | "all";
|
|
6
|
+
export type SheetFilter = number | "all" | "selection";
|
|
7
|
+
type FilterRange = {
|
|
8
|
+
sheetId?: number;
|
|
9
|
+
startRowIndex?: number;
|
|
10
|
+
endRowIndex?: number;
|
|
11
|
+
startColumnIndex?: number;
|
|
12
|
+
endColumnIndex?: number;
|
|
13
|
+
};
|
|
6
14
|
type RuleWithRanges = {
|
|
7
|
-
ranges?:
|
|
8
|
-
sheetId?: number;
|
|
9
|
-
}[];
|
|
15
|
+
ranges?: FilterRange[];
|
|
10
16
|
};
|
|
11
17
|
/**
|
|
12
|
-
* A rule belongs to a sheet when any of its ranges targets that sheet
|
|
18
|
+
* A rule belongs to a sheet when any of its ranges targets that sheet, and to the current selection
|
|
19
|
+
* when any of its ranges overlaps a selected range.
|
|
13
20
|
*/
|
|
14
|
-
export declare function filterRulesBySheet<T extends RuleWithRanges>(rules: T[], filter: SheetFilter): T[];
|
|
21
|
+
export declare function filterRulesBySheet<T extends RuleWithRanges>(rules: T[], filter: SheetFilter, selectionRanges?: readonly FilterRange[]): T[];
|
|
15
22
|
/**
|
|
16
23
|
* Sheet ids that appear in at least one rule's ranges, in first-seen order.
|
|
17
24
|
*/
|
|
@@ -51,17 +58,21 @@ export declare function getFilterableSheetIds(rules: RuleWithRanges[], sheetId:
|
|
|
51
58
|
*
|
|
52
59
|
* `workbookSheetIds` is the workbook's sheets in tab order; see getFilterableSheetIds.
|
|
53
60
|
*/
|
|
54
|
-
export declare function useSheetFilter<T extends RuleWithRanges>(sheetId: number, rules: T[], workbookSheetIds?: readonly number[]
|
|
61
|
+
export declare function useSheetFilter<T extends RuleWithRanges>(sheetId: number, rules: T[], workbookSheetIds?: readonly number[],
|
|
62
|
+
/** The selected ranges (with `sheetId`), read when "Current selection" is chosen. */
|
|
63
|
+
getSelectionRanges?: () => readonly FilterRange[]): {
|
|
55
64
|
sheetFilter: SheetFilter;
|
|
56
65
|
setSheetFilter: React.Dispatch<React.SetStateAction<SheetFilter>>;
|
|
57
66
|
filterableSheetIds: number[];
|
|
58
67
|
visibleRules: T[];
|
|
59
68
|
showFilter: boolean;
|
|
60
69
|
};
|
|
61
|
-
export declare const SheetFilterSelect: ({ value, sheetIds, onValueChange, }: {
|
|
70
|
+
export declare const SheetFilterSelect: ({ value, sheetIds, onValueChange, offerSelection, }: {
|
|
62
71
|
value: SheetFilter;
|
|
63
72
|
sheetIds: number[];
|
|
64
73
|
onValueChange: (value: SheetFilter) => void;
|
|
74
|
+
/** Offer "Current selection" (the Conditional Formatting Rules Manager does). */
|
|
75
|
+
offerSelection?: boolean;
|
|
65
76
|
}) => React.JSX.Element;
|
|
66
77
|
export declare const SheetFilterEmptyState: ({ sheetFilter, label, }: {
|
|
67
78
|
sheetFilter: SheetFilter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet-filter.d.ts","sourceRoot":"","sources":["../../../../components/editors/sheet-filter.tsx"],"names":[],"mappings":"AASA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAE5D
|
|
1
|
+
{"version":3,"file":"sheet-filter.d.ts","sourceRoot":"","sources":["../../../../components/editors/sheet-filter.tsx"],"names":[],"mappings":"AASA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAE5D;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,KAAK,GAAG,WAAW,CAAC;AAEvD,KAAK,WAAW,GAAG;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;CACxB,CAAC;AASF;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,cAAc,EACzD,KAAK,EAAE,CAAC,EAAE,EACV,MAAM,EAAE,WAAW,EACnB,eAAe,GAAE,SAAS,WAAW,EAAO,GAC3C,CAAC,EAAE,CAYL;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,MAAM,EAAE,CAUtE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,WAAW,EACX,OAAO,GACR,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAEV;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,cAAc,EAAE,EACvB,OAAO,EAAE,MAAM,EACf,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,GACnC,MAAM,EAAE,CAKV;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,cAAc,EACrD,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,CAAC,EAAE,EACV,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE;AACpC,qFAAqF;AACrF,kBAAkB,CAAC,EAAE,MAAM,SAAS,WAAW,EAAE;;;;;;EAoClD;AAED,eAAO,MAAM,iBAAiB,GAAI,qDAK/B;IACD,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,aAAa,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IAC5C,iFAAiF;IACjF,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,sBAkCA,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,yBAGnC;IACD,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;CACf,sBASA,CAAC"}
|
|
@@ -2,13 +2,31 @@ import { __read, __spreadArray, __values } from "tslib";
|
|
|
2
2
|
import { useGetSheetName } from "@rowsncolumns/spreadsheet";
|
|
3
3
|
import { Select, SelectContent, SelectItem, SelectPortal, SelectTrigger, SelectValue, } from "@rowsncolumns/ui";
|
|
4
4
|
import React, { useEffect, useMemo, useState } from "react";
|
|
5
|
+
var rangesIntersect = function (a, b) {
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7
|
+
return a.sheetId === b.sheetId &&
|
|
8
|
+
((_a = a.startRowIndex) !== null && _a !== void 0 ? _a : 0) <= ((_b = b.endRowIndex) !== null && _b !== void 0 ? _b : Number.MAX_SAFE_INTEGER) &&
|
|
9
|
+
((_c = b.startRowIndex) !== null && _c !== void 0 ? _c : 0) <= ((_d = a.endRowIndex) !== null && _d !== void 0 ? _d : Number.MAX_SAFE_INTEGER) &&
|
|
10
|
+
((_e = a.startColumnIndex) !== null && _e !== void 0 ? _e : 0) <= ((_f = b.endColumnIndex) !== null && _f !== void 0 ? _f : Number.MAX_SAFE_INTEGER) &&
|
|
11
|
+
((_g = b.startColumnIndex) !== null && _g !== void 0 ? _g : 0) <= ((_h = a.endColumnIndex) !== null && _h !== void 0 ? _h : Number.MAX_SAFE_INTEGER);
|
|
12
|
+
};
|
|
5
13
|
/**
|
|
6
|
-
* A rule belongs to a sheet when any of its ranges targets that sheet
|
|
14
|
+
* A rule belongs to a sheet when any of its ranges targets that sheet, and to the current selection
|
|
15
|
+
* when any of its ranges overlaps a selected range.
|
|
7
16
|
*/
|
|
8
|
-
export function filterRulesBySheet(rules, filter) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
17
|
+
export function filterRulesBySheet(rules, filter, selectionRanges) {
|
|
18
|
+
if (selectionRanges === void 0) { selectionRanges = []; }
|
|
19
|
+
if (filter === "all")
|
|
20
|
+
return rules;
|
|
21
|
+
if (filter === "selection") {
|
|
22
|
+
return rules.filter(function (rule) {
|
|
23
|
+
var _a;
|
|
24
|
+
return (_a = rule.ranges) === null || _a === void 0 ? void 0 : _a.some(function (range) {
|
|
25
|
+
return selectionRanges.some(function (selected) { return rangesIntersect(range, selected); });
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return rules.filter(function (rule) { var _a; return (_a = rule.ranges) === null || _a === void 0 ? void 0 : _a.some(function (range) { return range.sheetId === filter; }); });
|
|
12
30
|
}
|
|
13
31
|
/**
|
|
14
32
|
* Sheet ids that appear in at least one rule's ranges, in first-seen order.
|
|
@@ -85,13 +103,22 @@ export function getFilterableSheetIds(rules, sheetId, workbookSheetIds) {
|
|
|
85
103
|
*
|
|
86
104
|
* `workbookSheetIds` is the workbook's sheets in tab order; see getFilterableSheetIds.
|
|
87
105
|
*/
|
|
88
|
-
export function useSheetFilter(sheetId, rules, workbookSheetIds
|
|
89
|
-
|
|
106
|
+
export function useSheetFilter(sheetId, rules, workbookSheetIds,
|
|
107
|
+
/** The selected ranges (with `sheetId`), read when "Current selection" is chosen. */
|
|
108
|
+
getSelectionRanges) {
|
|
109
|
+
var _a;
|
|
110
|
+
var _b = __read(useState(sheetId), 2), sheetFilter = _b[0], setSheetFilter = _b[1];
|
|
90
111
|
useEffect(function () {
|
|
91
112
|
setSheetFilter(sheetId);
|
|
92
113
|
}, [sheetId]);
|
|
93
114
|
var filterableSheetIds = useMemo(function () { return getFilterableSheetIds(rules, sheetId, workbookSheetIds); }, [rules, sheetId, workbookSheetIds]);
|
|
94
|
-
var
|
|
115
|
+
var sheetRules = useMemo(function () {
|
|
116
|
+
return sheetFilter === "selection" ? rules : filterRulesBySheet(rules, sheetFilter);
|
|
117
|
+
}, [rules, sheetFilter]);
|
|
118
|
+
// The selection can move while the (non-modal) dialog is open, so it is read on every render.
|
|
119
|
+
var visibleRules = sheetFilter === "selection"
|
|
120
|
+
? filterRulesBySheet(rules, "selection", (_a = getSelectionRanges === null || getSelectionRanges === void 0 ? void 0 : getSelectionRanges()) !== null && _a !== void 0 ? _a : [])
|
|
121
|
+
: sheetRules;
|
|
95
122
|
var showFilter = shouldShowSheetFilter({
|
|
96
123
|
ruleCount: rules.length,
|
|
97
124
|
sheetFilter: sheetFilter,
|
|
@@ -106,17 +133,18 @@ export function useSheetFilter(sheetId, rules, workbookSheetIds) {
|
|
|
106
133
|
};
|
|
107
134
|
}
|
|
108
135
|
export var SheetFilterSelect = function (_a) {
|
|
109
|
-
var value = _a.value, sheetIds = _a.sheetIds, onValueChange = _a.onValueChange;
|
|
136
|
+
var value = _a.value, sheetIds = _a.sheetIds, onValueChange = _a.onValueChange, _b = _a.offerSelection, offerSelection = _b === void 0 ? false : _b;
|
|
110
137
|
var getSheetName = useGetSheetName();
|
|
111
138
|
return (React.createElement("div", { className: "flex items-center gap-2 p-2 text-sm border-0 border-solid border-b border-rnc-border" },
|
|
112
139
|
React.createElement("label", { className: "text-rnc-muted-foreground whitespace-nowrap" }, "Show rules for"),
|
|
113
|
-
React.createElement(Select, { value: value === "
|
|
114
|
-
onValueChange(next === "all"
|
|
140
|
+
React.createElement(Select, { value: typeof value === "number" ? String(value) : value, onValueChange: function (next) {
|
|
141
|
+
onValueChange(next === "all" || next === "selection" ? next : Number(next));
|
|
115
142
|
} },
|
|
116
143
|
React.createElement(SelectTrigger, { className: "text-sm" },
|
|
117
144
|
React.createElement(SelectValue, null)),
|
|
118
145
|
React.createElement(SelectPortal, null,
|
|
119
146
|
React.createElement(SelectContent, null,
|
|
147
|
+
offerSelection ? (React.createElement(SelectItem, { value: "selection" }, "Current selection")) : null,
|
|
120
148
|
React.createElement(SelectItem, { value: "all" }, "All sheets"),
|
|
121
149
|
sheetIds.map(function (id) {
|
|
122
150
|
var _a;
|
|
@@ -128,5 +156,9 @@ export var SheetFilterEmptyState = function (_a) {
|
|
|
128
156
|
return (React.createElement("div", { className: "p-4 text-sm text-rnc-muted-foreground text-center" },
|
|
129
157
|
"No ",
|
|
130
158
|
label,
|
|
131
|
-
sheetFilter === "all"
|
|
159
|
+
sheetFilter === "all"
|
|
160
|
+
? ""
|
|
161
|
+
: sheetFilter === "selection"
|
|
162
|
+
? " in the current selection"
|
|
163
|
+
: " in this sheet"));
|
|
132
164
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ConditionalFormatRule } from "@rowsncolumns/spreadsheet";
|
|
2
|
+
import { type ConditionalFormatPriorityUpdate } from "../interface/conditional-formatting-rules";
|
|
2
3
|
import type { useCalculation } from "./use-calculation";
|
|
3
4
|
import type { SpreadsheetPatch } from "./use-undo-redo";
|
|
4
5
|
export type UseConditionalFormattingRulesProps = {
|
|
@@ -17,6 +18,7 @@ export declare const useConditionalFormattingRules: ({ enqueueCalculation, creat
|
|
|
17
18
|
onCreateConditionalFormattingRule: (rule: ConditionalFormatRule) => void;
|
|
18
19
|
onUpdateConditionalFormattingRule: (updatedRule: ConditionalFormatRule, previousRule: ConditionalFormatRule) => void;
|
|
19
20
|
onDeleteConditionalFormattingRule: (rule: ConditionalFormatRule) => void;
|
|
21
|
+
onReorderConditionalFormattingRules: (updates: ConditionalFormatPriorityUpdate[]) => void;
|
|
20
22
|
onPreviewConditionalFormattingRule: (rule: ConditionalFormatRule) => void;
|
|
21
23
|
};
|
|
22
24
|
//# sourceMappingURL=use-conditional-formatting-rules.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-conditional-formatting-rules.d.ts","sourceRoot":"","sources":["../../../hooks/use-conditional-formatting-rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"use-conditional-formatting-rules.d.ts","sourceRoot":"","sources":["../../../hooks/use-conditional-formatting-rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGvE,OAAO,EAGL,KAAK,+BAA+B,EAIrC,MAAM,2CAA2C,CAAC;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAcxD,MAAM,MAAM,kCAAkC,GAAG;IAC/C,kBAAkB,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,oBAAoB,CAAC,CAAC;IAC5E;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACzD;;OAEG;IACH,0BAA0B,CAAC,EAAE,KAAK,CAAC,QAAQ,CACzC,KAAK,CAAC,cAAc,CAAC,qBAAqB,EAAE,CAAC,CAC9C,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,6BAA6B,GAAI,oEAI3C,kCAAkC;8CAK1B,qBAAqB;qDAwBb,qBAAqB,gBACpB,qBAAqB;8CA2B9B,qBAAqB;mDAuBlB,+BAA+B,EAAE;+CAyBpC,qBAAqB;CAiB/B,CAAC"}
|