@akin2unde/flowui-core 1.0.1 → 1.0.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/index.cjs +212 -4
- package/dist/index.d.cts +115 -2
- package/dist/index.d.ts +115 -2
- package/dist/index.js +207 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
AsyncLabelStore: () => AsyncLabelStore,
|
|
24
|
+
buildChart: () => buildChart,
|
|
24
25
|
clampNumber: () => clampNumber,
|
|
25
26
|
createAsyncLabelStore: () => createAsyncLabelStore,
|
|
26
27
|
createNotificationTimer: () => createNotificationTimer,
|
|
@@ -35,6 +36,7 @@ __export(index_exports, {
|
|
|
35
36
|
flowClass: () => flowClass,
|
|
36
37
|
formatLocalDateTime: () => formatLocalDateTime,
|
|
37
38
|
notificationDuration: () => notificationDuration,
|
|
39
|
+
numericInputError: () => numericInputError,
|
|
38
40
|
resolveColorValue: () => resolveColorValue,
|
|
39
41
|
resolveFlowStyle: () => resolveFlowStyle,
|
|
40
42
|
resolveTooltipLocation: () => resolveTooltipLocation,
|
|
@@ -43,7 +45,9 @@ __export(index_exports, {
|
|
|
43
45
|
selectedTreeModels: () => selectedTreeModels,
|
|
44
46
|
setLocalDayBoundary: () => setLocalDayBoundary,
|
|
45
47
|
tableToCsv: () => tableToCsv,
|
|
46
|
-
themeToCSS: () => themeToCSS
|
|
48
|
+
themeToCSS: () => themeToCSS,
|
|
49
|
+
toggleTreeCheck: () => toggleTreeCheck,
|
|
50
|
+
treeCheckState: () => treeCheckState
|
|
47
51
|
});
|
|
48
52
|
module.exports = __toCommonJS(index_exports);
|
|
49
53
|
|
|
@@ -330,6 +334,13 @@ var responsiveProperties = {
|
|
|
330
334
|
borderStyle: "border-style",
|
|
331
335
|
borderColor: "border-color",
|
|
332
336
|
cornerRadius: "border-radius",
|
|
337
|
+
iconColor: "--fui-control-icon",
|
|
338
|
+
placeholderColor: "--fui-control-placeholder",
|
|
339
|
+
panelBackgroundColor: "--fui-panel-background",
|
|
340
|
+
panelTextColor: "--fui-panel-text",
|
|
341
|
+
optionHoverBackgroundColor: "--fui-option-hover-background",
|
|
342
|
+
selectedOptionBackgroundColor: "--fui-option-selected-background",
|
|
343
|
+
selectedOptionTextColor: "--fui-option-selected-text",
|
|
333
344
|
backgroundColor: "background-color",
|
|
334
345
|
opacity: "opacity",
|
|
335
346
|
shadow: "box-shadow",
|
|
@@ -343,10 +354,12 @@ var responsiveProperties = {
|
|
|
343
354
|
function responsiveCSS(theme) {
|
|
344
355
|
const output = [];
|
|
345
356
|
for (const [prop, css] of Object.entries(responsiveProperties)) {
|
|
346
|
-
output.push(
|
|
357
|
+
output.push(
|
|
358
|
+
`.fui-r-${prop}-default{${css}:var(--fui-${prop}-default)${prop === "backgroundColor" ? ";--fui-control-background:var(--fui-backgroundColor-default)" : prop === "textColor" ? ";--fui-control-text:var(--fui-textColor-default)" : ""}}`
|
|
359
|
+
);
|
|
347
360
|
for (const [breakpoint, width] of Object.entries(theme.breakpoints)) {
|
|
348
361
|
output.push(
|
|
349
|
-
`@media(min-width:${width}){.fui-r-${prop}-${breakpoint}{${css}:var(--fui-${prop}-${breakpoint})}}`
|
|
362
|
+
`@media(min-width:${width}){.fui-r-${prop}-${breakpoint}{${css}:var(--fui-${prop}-${breakpoint})${prop === "backgroundColor" ? `;--fui-control-background:var(--fui-backgroundColor-${breakpoint})` : prop === "textColor" ? `;--fui-control-text:var(--fui-textColor-${breakpoint})` : ""}}}`
|
|
350
363
|
);
|
|
351
364
|
}
|
|
352
365
|
}
|
|
@@ -452,6 +465,22 @@ var propertyMap = {
|
|
|
452
465
|
css: "borderRadius",
|
|
453
466
|
resolve: ((v, t) => v in t.radius ? `var(--fui-radius-${v})` : length(v))
|
|
454
467
|
},
|
|
468
|
+
iconColor: { css: "--fui-control-icon", resolve: color },
|
|
469
|
+
placeholderColor: { css: "--fui-control-placeholder", resolve: color },
|
|
470
|
+
panelBackgroundColor: { css: "--fui-panel-background", resolve: color },
|
|
471
|
+
panelTextColor: { css: "--fui-panel-text", resolve: color },
|
|
472
|
+
optionHoverBackgroundColor: {
|
|
473
|
+
css: "--fui-option-hover-background",
|
|
474
|
+
resolve: color
|
|
475
|
+
},
|
|
476
|
+
selectedOptionBackgroundColor: {
|
|
477
|
+
css: "--fui-option-selected-background",
|
|
478
|
+
resolve: color
|
|
479
|
+
},
|
|
480
|
+
selectedOptionTextColor: {
|
|
481
|
+
css: "--fui-option-selected-text",
|
|
482
|
+
resolve: color
|
|
483
|
+
},
|
|
455
484
|
backgroundColor: { css: "backgroundColor", resolve: color },
|
|
456
485
|
opacity: { css: "opacity", resolve: String },
|
|
457
486
|
shadow: {
|
|
@@ -513,6 +542,10 @@ function resolveFlowStyle(props, theme) {
|
|
|
513
542
|
style["--fui-field-focus-border"] = "var(--fui-color-borderStrong)";
|
|
514
543
|
style["--fui-field-focus-shadow"] = "none";
|
|
515
544
|
}
|
|
545
|
+
if (style.backgroundColor !== void 0)
|
|
546
|
+
style["--fui-control-background"] = String(style.backgroundColor);
|
|
547
|
+
if (style.color !== void 0)
|
|
548
|
+
style["--fui-control-text"] = String(style.color);
|
|
516
549
|
Object.assign(style, userStyle);
|
|
517
550
|
return { classNames, style };
|
|
518
551
|
}
|
|
@@ -553,6 +586,20 @@ function sanitizeInputValue(value, mode = "text") {
|
|
|
553
586
|
function clampNumber(value, min, max) {
|
|
554
587
|
return Math.min(max, Math.max(min, value));
|
|
555
588
|
}
|
|
589
|
+
function numericInputError(value, min, max, step) {
|
|
590
|
+
if (String(value).trim() === "") return;
|
|
591
|
+
const number = Number(value);
|
|
592
|
+
if (!Number.isFinite(number)) return "Enter a valid number.";
|
|
593
|
+
if (min !== void 0 && number < Number(min))
|
|
594
|
+
return `Enter a value of at least ${min}.`;
|
|
595
|
+
if (max !== void 0 && number > Number(max))
|
|
596
|
+
return `Enter a value no greater than ${max}.`;
|
|
597
|
+
if (step !== void 0 && step !== "any" && Number(step) > 0) {
|
|
598
|
+
const count = (number - Number(min ?? 0)) / Number(step);
|
|
599
|
+
if (Math.abs(count - Math.round(count)) > 1e-8)
|
|
600
|
+
return `Use increments of ${step}.`;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
556
603
|
|
|
557
604
|
// src/table-export.ts
|
|
558
605
|
function cellText(row, column) {
|
|
@@ -683,6 +730,22 @@ function selectedTreeModels(nodes, values) {
|
|
|
683
730
|
const selected = new Set(values);
|
|
684
731
|
return flattenTree(nodes).filter((node) => selected.has(node.value));
|
|
685
732
|
}
|
|
733
|
+
function treeCheckState(node, selected) {
|
|
734
|
+
const leaves = enabledSelectableDescendants(node);
|
|
735
|
+
const checked = leaves.filter((leaf) => selected.has(leaf.value)).length;
|
|
736
|
+
if (!checked) return false;
|
|
737
|
+
return checked === leaves.length ? true : "mixed";
|
|
738
|
+
}
|
|
739
|
+
function toggleTreeCheck(node, values) {
|
|
740
|
+
const selected = new Set(values);
|
|
741
|
+
if (node.disabled || node.selectable === false) return [...selected];
|
|
742
|
+
const remove = treeCheckState(node, selected) === true;
|
|
743
|
+
for (const leaf of enabledSelectableDescendants(node)) {
|
|
744
|
+
if (remove) selected.delete(leaf.value);
|
|
745
|
+
else selected.add(leaf.value);
|
|
746
|
+
}
|
|
747
|
+
return [...selected];
|
|
748
|
+
}
|
|
686
749
|
|
|
687
750
|
// src/async-label.ts
|
|
688
751
|
var idle = Object.freeze({ status: "idle" });
|
|
@@ -1037,9 +1100,151 @@ function createNotificationTimer(duration, onElapsed) {
|
|
|
1037
1100
|
}
|
|
1038
1101
|
};
|
|
1039
1102
|
}
|
|
1103
|
+
|
|
1104
|
+
// src/chart.ts
|
|
1105
|
+
var palette = ["#3b82c4", "#f59429", "#8cba39", "#ed74a7", "#8762c8"];
|
|
1106
|
+
function buildChart(data, type, height, showValues) {
|
|
1107
|
+
const width = 640;
|
|
1108
|
+
const marks = [];
|
|
1109
|
+
const labels = [];
|
|
1110
|
+
const label = (x2, y2, text, anchor = "middle") => labels.push({ x: x2, y: y2, text: String(text), anchor });
|
|
1111
|
+
const legend = data.series.map((series, index) => ({
|
|
1112
|
+
label: series.name,
|
|
1113
|
+
color: series.color ? resolveColorValue(series.color) : palette[index % palette.length]
|
|
1114
|
+
}));
|
|
1115
|
+
const colorAt = (index) => palette[index % palette.length];
|
|
1116
|
+
const path = (d, fill = "none", stroke, opacity) => marks.push({ path: d, fill, stroke, opacity });
|
|
1117
|
+
if (type === "pie" || type === "doughnut") {
|
|
1118
|
+
const values2 = (data.series[0]?.data ?? []).map(
|
|
1119
|
+
(value) => Math.max(0, value)
|
|
1120
|
+
);
|
|
1121
|
+
const total = values2.reduce((sum, value) => sum + value, 0);
|
|
1122
|
+
const radius = height * 0.38;
|
|
1123
|
+
const centerX = width / 2;
|
|
1124
|
+
const centerY = height / 2;
|
|
1125
|
+
const point = (r, angle) => [
|
|
1126
|
+
centerX + r * Math.cos(angle),
|
|
1127
|
+
centerY + r * Math.sin(angle)
|
|
1128
|
+
];
|
|
1129
|
+
let start = -Math.PI / 2;
|
|
1130
|
+
values2.forEach((value, index) => {
|
|
1131
|
+
if (!value || !total) return;
|
|
1132
|
+
const sweep = 2 * Math.PI * value / total;
|
|
1133
|
+
const end = start + Math.min(sweep, 2 * Math.PI - 1e-4);
|
|
1134
|
+
const inner = type === "doughnut" ? radius * 0.55 : 0;
|
|
1135
|
+
const large = sweep > Math.PI ? 1 : 0;
|
|
1136
|
+
const tail = inner ? `L ${point(inner, end)} A ${inner},${inner} 0 ${large} 0 ${point(inner, start)}` : `L ${centerX},${centerY}`;
|
|
1137
|
+
path(
|
|
1138
|
+
`M ${point(radius, start)} A ${radius},${radius} 0 ${large} 1 ${point(radius, end)} ${tail} Z`,
|
|
1139
|
+
colorAt(index),
|
|
1140
|
+
"white"
|
|
1141
|
+
);
|
|
1142
|
+
if (showValues) {
|
|
1143
|
+
const [x2, y2] = point(radius * 0.75, (start + end) / 2);
|
|
1144
|
+
label(x2, y2, value);
|
|
1145
|
+
}
|
|
1146
|
+
start += sweep;
|
|
1147
|
+
});
|
|
1148
|
+
return {
|
|
1149
|
+
marks,
|
|
1150
|
+
labels,
|
|
1151
|
+
legend: values2.map((_, index) => ({
|
|
1152
|
+
label: data.labels[index] ?? String(index + 1),
|
|
1153
|
+
color: colorAt(index)
|
|
1154
|
+
})),
|
|
1155
|
+
width,
|
|
1156
|
+
height
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
const left = type === "horizontal-bar" ? 120 : 48;
|
|
1160
|
+
const right = width - 28;
|
|
1161
|
+
const top = 24;
|
|
1162
|
+
const bottom = height - 34;
|
|
1163
|
+
const values = data.series.flatMap((series) => series.data);
|
|
1164
|
+
const min = Math.min(0, ...values);
|
|
1165
|
+
const max = Math.max(1, ...values);
|
|
1166
|
+
const groupCount = Math.max(
|
|
1167
|
+
1,
|
|
1168
|
+
data.labels.length,
|
|
1169
|
+
...data.series.map((series) => series.data.length)
|
|
1170
|
+
);
|
|
1171
|
+
const groupWidth = (right - left) / groupCount;
|
|
1172
|
+
const groupHeight = (bottom - top) / groupCount;
|
|
1173
|
+
const x = (index) => left + groupWidth * (index + 0.5);
|
|
1174
|
+
const y = (value) => bottom - (value - min) / (max - min) * (bottom - top);
|
|
1175
|
+
const scaleX = (value) => left + (value - min) / (max - min) * (right - left);
|
|
1176
|
+
const horizontal = type === "horizontal-bar";
|
|
1177
|
+
path(
|
|
1178
|
+
horizontal ? `M ${left} ${top} V ${bottom} H ${right} M ${scaleX(0)} ${top} V ${bottom}` : `M ${left} ${top} V ${y(0)} H ${right}`,
|
|
1179
|
+
"none",
|
|
1180
|
+
"#cbd5e1"
|
|
1181
|
+
);
|
|
1182
|
+
data.labels.forEach(
|
|
1183
|
+
(item, index) => horizontal ? label(left - 10, top + groupHeight * (index + 0.5) + 4, item, "end") : label(x(index), height - 10, item)
|
|
1184
|
+
);
|
|
1185
|
+
const isLine = (index) => type === "line" || type === "area" || type === "combo" && (data.series[index].type ?? (index === data.series.length - 1 ? "line" : "column")) === "line";
|
|
1186
|
+
const columns = data.series.filter((_, index) => !isLine(index));
|
|
1187
|
+
data.series.forEach((series, index) => {
|
|
1188
|
+
if (isLine(index)) return;
|
|
1189
|
+
const columnIndex = columns.indexOf(series);
|
|
1190
|
+
const size = (horizontal ? groupHeight : groupWidth) * 0.68 / columns.length;
|
|
1191
|
+
series.data.forEach((value, valueIndex) => {
|
|
1192
|
+
const fill = type === "bar" || series.color || columns.length > 1 ? legend[index].color : colorAt(valueIndex);
|
|
1193
|
+
if (horizontal) {
|
|
1194
|
+
const rowY = top + groupHeight * (valueIndex + 0.5) + (columnIndex - columns.length / 2) * size;
|
|
1195
|
+
marks.push({
|
|
1196
|
+
x: Math.min(scaleX(0), scaleX(value)),
|
|
1197
|
+
y: rowY,
|
|
1198
|
+
width: Math.abs(scaleX(value) - scaleX(0)),
|
|
1199
|
+
height: Math.max(1, size - 3),
|
|
1200
|
+
fill
|
|
1201
|
+
});
|
|
1202
|
+
if (showValues)
|
|
1203
|
+
label(
|
|
1204
|
+
scaleX(value) + (value < 0 ? -4 : 4),
|
|
1205
|
+
rowY + size / 2 + 4,
|
|
1206
|
+
value,
|
|
1207
|
+
value < 0 ? "end" : "start"
|
|
1208
|
+
);
|
|
1209
|
+
} else {
|
|
1210
|
+
const columnX = x(valueIndex) + (columnIndex - columns.length / 2) * size;
|
|
1211
|
+
marks.push({
|
|
1212
|
+
x: columnX,
|
|
1213
|
+
y: Math.min(y(0), y(value)),
|
|
1214
|
+
width: Math.max(1, size - 3),
|
|
1215
|
+
height: Math.abs(y(0) - y(value)),
|
|
1216
|
+
fill
|
|
1217
|
+
});
|
|
1218
|
+
if (showValues) label(columnX + size / 2, y(value) - 6, value);
|
|
1219
|
+
}
|
|
1220
|
+
});
|
|
1221
|
+
});
|
|
1222
|
+
data.series.forEach((series, index) => {
|
|
1223
|
+
if (!isLine(index) || !series.data.length) return;
|
|
1224
|
+
const coordinates = series.data.map(
|
|
1225
|
+
(value, valueIndex) => `${x(valueIndex)},${y(value)}`
|
|
1226
|
+
);
|
|
1227
|
+
const trace = `M ${coordinates.join(" L ")}`;
|
|
1228
|
+
if (type === "area") {
|
|
1229
|
+
path(
|
|
1230
|
+
`${trace} L ${x(coordinates.length - 1)},${y(0)} L ${x(0)},${y(0)} Z`,
|
|
1231
|
+
legend[index].color,
|
|
1232
|
+
void 0,
|
|
1233
|
+
0.28
|
|
1234
|
+
);
|
|
1235
|
+
}
|
|
1236
|
+
path(trace, "none", legend[index].color);
|
|
1237
|
+
if (showValues)
|
|
1238
|
+
series.data.forEach(
|
|
1239
|
+
(value, valueIndex) => label(x(valueIndex), y(value) - 8, value)
|
|
1240
|
+
);
|
|
1241
|
+
});
|
|
1242
|
+
return { marks, labels, legend, width, height };
|
|
1243
|
+
}
|
|
1040
1244
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1041
1245
|
0 && (module.exports = {
|
|
1042
1246
|
AsyncLabelStore,
|
|
1247
|
+
buildChart,
|
|
1043
1248
|
clampNumber,
|
|
1044
1249
|
createAsyncLabelStore,
|
|
1045
1250
|
createNotificationTimer,
|
|
@@ -1054,6 +1259,7 @@ function createNotificationTimer(duration, onElapsed) {
|
|
|
1054
1259
|
flowClass,
|
|
1055
1260
|
formatLocalDateTime,
|
|
1056
1261
|
notificationDuration,
|
|
1262
|
+
numericInputError,
|
|
1057
1263
|
resolveColorValue,
|
|
1058
1264
|
resolveFlowStyle,
|
|
1059
1265
|
resolveTooltipLocation,
|
|
@@ -1062,5 +1268,7 @@ function createNotificationTimer(duration, onElapsed) {
|
|
|
1062
1268
|
selectedTreeModels,
|
|
1063
1269
|
setLocalDayBoundary,
|
|
1064
1270
|
tableToCsv,
|
|
1065
|
-
themeToCSS
|
|
1271
|
+
themeToCSS,
|
|
1272
|
+
toggleTreeCheck,
|
|
1273
|
+
treeCheckState
|
|
1066
1274
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -96,6 +96,14 @@ interface BorderProps {
|
|
|
96
96
|
cornerRadius?: ResponsiveValue<RadiusValue>;
|
|
97
97
|
}
|
|
98
98
|
interface VisualProps {
|
|
99
|
+
textColor?: ResponsiveValue<ColorValue>;
|
|
100
|
+
iconColor?: ResponsiveValue<ColorValue>;
|
|
101
|
+
placeholderColor?: ResponsiveValue<ColorValue>;
|
|
102
|
+
panelBackgroundColor?: ResponsiveValue<ColorValue>;
|
|
103
|
+
panelTextColor?: ResponsiveValue<ColorValue>;
|
|
104
|
+
optionHoverBackgroundColor?: ResponsiveValue<ColorValue>;
|
|
105
|
+
selectedOptionBackgroundColor?: ResponsiveValue<ColorValue>;
|
|
106
|
+
selectedOptionTextColor?: ResponsiveValue<ColorValue>;
|
|
99
107
|
backgroundColor?: ResponsiveValue<ColorValue>;
|
|
100
108
|
opacity?: ResponsiveValue<number>;
|
|
101
109
|
shadow?: ResponsiveValue<"none" | "xs" | "sm" | "md" | "lg" | "xl">;
|
|
@@ -213,6 +221,8 @@ interface ButtonProps extends BaseUIProps, TypographyProps, DisableableProps, Lo
|
|
|
213
221
|
iconPosition?: "left" | "right" | "center";
|
|
214
222
|
badge?: string | number;
|
|
215
223
|
ariaLabel?: string;
|
|
224
|
+
/** Label for a self-closing button. Children/content take precedence. */
|
|
225
|
+
text?: string;
|
|
216
226
|
}
|
|
217
227
|
interface ButtonGroupProps extends BaseUIProps {
|
|
218
228
|
orientation?: Orientation;
|
|
@@ -223,6 +233,11 @@ interface ButtonGroupProps extends BaseUIProps {
|
|
|
223
233
|
}
|
|
224
234
|
interface InputProps extends BaseUIProps, TypographyProps, DisableableProps, ReadOnlyProps, RequiredProps, FocusableProps {
|
|
225
235
|
name?: string;
|
|
236
|
+
min?: string | number;
|
|
237
|
+
max?: string | number;
|
|
238
|
+
step?: string | number;
|
|
239
|
+
minLength?: number;
|
|
240
|
+
maxLength?: number;
|
|
226
241
|
value?: string | number;
|
|
227
242
|
placeholder?: string;
|
|
228
243
|
/** Controls which characters FlowUI accepts without changing the visual input type. */
|
|
@@ -264,6 +279,7 @@ interface DropdownModel {
|
|
|
264
279
|
group?: string | number;
|
|
265
280
|
}
|
|
266
281
|
interface TreeModel extends DropdownModel {
|
|
282
|
+
icon?: string;
|
|
267
283
|
children?: TreeModel[];
|
|
268
284
|
selectable?: boolean;
|
|
269
285
|
hasChildren?: boolean;
|
|
@@ -354,6 +370,8 @@ interface PasswordInputProps extends Omit<InputProps, "type"> {
|
|
|
354
370
|
visible?: boolean;
|
|
355
371
|
}
|
|
356
372
|
interface TreeProps extends BaseUIProps {
|
|
373
|
+
showCheckboxes?: boolean;
|
|
374
|
+
checkedValues?: readonly (string | number)[];
|
|
357
375
|
nodes: TreeModel[];
|
|
358
376
|
value?: string | number;
|
|
359
377
|
defaultExpanded?: boolean;
|
|
@@ -491,8 +509,9 @@ interface PhoneInputProps extends BaseUIProps, DisableableProps {
|
|
|
491
509
|
placeholder?: string;
|
|
492
510
|
name?: string;
|
|
493
511
|
}
|
|
494
|
-
type ChartType = "bar" | "line" | "pie" | "doughnut";
|
|
512
|
+
type ChartType = "bar" | "column" | "horizontal-bar" | "line" | "area" | "combo" | "pie" | "doughnut";
|
|
495
513
|
interface ChartSeries {
|
|
514
|
+
type?: "column" | "line";
|
|
496
515
|
name: string;
|
|
497
516
|
data: number[];
|
|
498
517
|
color?: ColorValue;
|
|
@@ -518,6 +537,8 @@ type FlowInputMode = NonNullable<InputProps["inputMode"]>;
|
|
|
518
537
|
/** Keeps only characters allowed by the selected FlowUI input mode. */
|
|
519
538
|
declare function sanitizeInputValue(value: string, mode?: FlowInputMode): string;
|
|
520
539
|
declare function clampNumber(value: number, min: number, max: number): number;
|
|
540
|
+
/** Validate numeric bounds without silently clamping user-entered text. */
|
|
541
|
+
declare function numericInputError(value: string | number, min?: string | number, max?: string | number, step?: string | number): string | undefined;
|
|
521
542
|
|
|
522
543
|
declare function tableToCsv<T>(data: readonly T[], columns: readonly TableColumn<T>[]): string;
|
|
523
544
|
declare function exportTableToCsv<T>(data: T[], columns: TableColumn<T>[], fileName?: string): void;
|
|
@@ -531,6 +552,8 @@ declare function flattenTree(nodes: TreeModel[]): TreeModel[];
|
|
|
531
552
|
declare function enabledSelectableDescendants(node: TreeModel): TreeModel[];
|
|
532
553
|
declare function filterTree(nodes: TreeModel[], query: string): TreeModel[];
|
|
533
554
|
declare function selectedTreeModels(nodes: TreeModel[], values: SelectionValue[]): TreeModel[];
|
|
555
|
+
declare function treeCheckState(node: TreeModel, selected: ReadonlySet<SelectionValue>): boolean | "mixed";
|
|
556
|
+
declare function toggleTreeCheck(node: TreeModel, values: readonly SelectionValue[]): SelectionValue[];
|
|
534
557
|
|
|
535
558
|
/** Code-to-text results. null is a confirmed missing value; absent keys are errors. */
|
|
536
559
|
type LabelResults = Readonly<Record<string, string | null>>;
|
|
@@ -635,4 +658,94 @@ interface NotificationAction {
|
|
|
635
658
|
onClick: () => void | Promise<void>;
|
|
636
659
|
}
|
|
637
660
|
|
|
638
|
-
|
|
661
|
+
interface FlowTextStyle {
|
|
662
|
+
color?: string;
|
|
663
|
+
fontFamily?: string;
|
|
664
|
+
fontSize?: number;
|
|
665
|
+
fontWeight?: "normal" | "bold" | "400" | "500" | "600" | "700";
|
|
666
|
+
lineHeight?: number;
|
|
667
|
+
textAlign?: "left" | "center" | "right";
|
|
668
|
+
}
|
|
669
|
+
interface FlowIconStyle {
|
|
670
|
+
color?: string;
|
|
671
|
+
size?: number;
|
|
672
|
+
}
|
|
673
|
+
interface FlowAction {
|
|
674
|
+
Label: string;
|
|
675
|
+
Icon?: string;
|
|
676
|
+
IsReadonly?: boolean;
|
|
677
|
+
TextStyle?: FlowTextStyle;
|
|
678
|
+
IconStyle?: FlowIconStyle;
|
|
679
|
+
}
|
|
680
|
+
interface FlowStage {
|
|
681
|
+
Id: string;
|
|
682
|
+
Label: string;
|
|
683
|
+
IsCurrent?: boolean;
|
|
684
|
+
IsCompleted?: boolean;
|
|
685
|
+
IsDisabled?: boolean;
|
|
686
|
+
Actions?: readonly FlowAction[];
|
|
687
|
+
SelectedAction?: FlowAction;
|
|
688
|
+
TextStyle?: FlowTextStyle;
|
|
689
|
+
}
|
|
690
|
+
interface FlowStageStyle {
|
|
691
|
+
backgroundColor?: string;
|
|
692
|
+
icon?: string;
|
|
693
|
+
iconStyle?: FlowIconStyle;
|
|
694
|
+
textStyle?: FlowTextStyle;
|
|
695
|
+
}
|
|
696
|
+
interface FlowActionItemStyle {
|
|
697
|
+
backgroundColor?: string;
|
|
698
|
+
textStyle?: FlowTextStyle;
|
|
699
|
+
iconStyle?: FlowIconStyle;
|
|
700
|
+
}
|
|
701
|
+
interface WorkflowStepperProps extends BaseUIProps {
|
|
702
|
+
stages: readonly FlowStage[];
|
|
703
|
+
direction?: "horizontal" | "vertical";
|
|
704
|
+
labelPosition?: "above" | "below" | "beside";
|
|
705
|
+
lineColor?: string;
|
|
706
|
+
stageTextStyle?: FlowTextStyle;
|
|
707
|
+
completedStyle?: FlowStageStyle;
|
|
708
|
+
currentStyle?: FlowStageStyle;
|
|
709
|
+
disabledStyle?: FlowStageStyle;
|
|
710
|
+
actionMenuStyle?: {
|
|
711
|
+
backgroundColor?: string;
|
|
712
|
+
borderColor?: string;
|
|
713
|
+
borderRadius?: number;
|
|
714
|
+
boxShadow?: string;
|
|
715
|
+
};
|
|
716
|
+
actionItemStyle?: FlowActionItemStyle & {
|
|
717
|
+
hover?: FlowActionItemStyle;
|
|
718
|
+
selected?: FlowActionItemStyle;
|
|
719
|
+
readonly?: FlowActionItemStyle;
|
|
720
|
+
};
|
|
721
|
+
checkmarkStyle?: FlowIconStyle;
|
|
722
|
+
chevronStyle?: FlowIconStyle;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
type Mark = {
|
|
726
|
+
fill: string;
|
|
727
|
+
path?: string;
|
|
728
|
+
stroke?: string;
|
|
729
|
+
opacity?: number;
|
|
730
|
+
x?: number;
|
|
731
|
+
y?: number;
|
|
732
|
+
width?: number;
|
|
733
|
+
height?: number;
|
|
734
|
+
};
|
|
735
|
+
declare function buildChart(data: ChartData, type: ChartType, height: number, showValues: boolean): {
|
|
736
|
+
marks: Mark[];
|
|
737
|
+
labels: {
|
|
738
|
+
x: number;
|
|
739
|
+
y: number;
|
|
740
|
+
text: string;
|
|
741
|
+
anchor: "middle" | "end" | "start";
|
|
742
|
+
}[];
|
|
743
|
+
legend: {
|
|
744
|
+
label: string;
|
|
745
|
+
color: string;
|
|
746
|
+
}[];
|
|
747
|
+
width: number;
|
|
748
|
+
height: number;
|
|
749
|
+
};
|
|
750
|
+
|
|
751
|
+
export { type AlignValue, type AsyncLabelCode, type AsyncLabelConfig, type AsyncLabelOptions, type AsyncLabelState, AsyncLabelStore, type AutocompleteProps, type BadgeProps, type BaseUIProps, type BorderProps, type BreadcrumbItem, type BreadcrumbProps, type BreakpointName, type ButtonGroupProps, type ButtonProps, type CSSLength, type CSSVariableStyle, type CardProps, type CarouselProps, type ChartData, type ChartProps, type ChartSeries, type ChartType, type ColorPalette, type ColorScale, type ColorShade, type ColorValue, type ComponentSize, type ComponentVariant, type DateTimeMode, type DateTimeProps, type DeepPartial, type DialogPosition, type DimensionValue, type DisableableProps, type DividerProps, type DropdownBehaviorProps, type DropdownModel, type FieldFocusStyle, type FileUploadProps, type FlexContainerProps, type FlexDirection, type FlexItemProps, type FlexWrap, type FlowAction, type FlowActionItemStyle, type FlowIconStyle, type FlowInputMode, type FlowStage, type FlowStageStyle, type FlowTextStyle, type FlowUIStyle, type FlowUITheme, type FocusableProps, type HStackProps, type IconProps, type ImageProps, type InputProps, type JustifyValue, type KnobProps, type LabelLookup, type LabelProps, type LabelResolverContext, type LabelResults, type LayoutProps, type ListboxProps, type LoadingProps, type MenuItem, type MultiSelectProps, type NotificationAction, type NotificationHorizontal, type NotificationProps, type NotificationType, type NotificationVertical, type OTPInputProps, type Orientation, type PaletteColor, type PasswordInputProps, type PhoneCountry, type PhoneInputProps, type PhoneNumberValue, type PopoverProps, type PositionProps, type PositionValue, type RadiusToken, type RadiusValue, type RatingProps, type ReadOnlyProps, type RequiredProps, type ResolvedStyle, type ResponsiveObject, type ResponsiveValue, type SchemeColor, type SelectOption, type SelectionValue, type SliderProps, type SortDirection, type SortState, type SpacingProps, type SpacingToken, type SpacingValue, type StackProps, type StyleResolution, type SwitchProps, type TabItem, type TabSelectedStyle, type TableColumn, type TableLoadMoreContext, type ThemeColorScheme, type ThemeMode, type TimelineItem, type TimelineProps, type TooltipLocation, type TooltipProps, type TreeDropdownProps, type TreeModel, type TreeMultiSelectProps, type TreeProps, type TypographyProps, type VStackProps, type VisualProps, type WorkflowStepperProps, buildChart, clampNumber, createAsyncLabelStore, createNotificationTimer, createTheme, defaultTheme, enabledSelectableDescendants, exportTableToCsv, exportTableToExcel, exportTableToPdf, filterTree, flattenTree, flowClass, formatLocalDateTime, notificationDuration, numericInputError, resolveColorValue, resolveFlowStyle, resolveTooltipLocation, responsiveCSS, sanitizeInputValue, selectedTreeModels, setLocalDayBoundary, tableToCsv, themeToCSS, toggleTreeCheck, treeCheckState };
|
package/dist/index.d.ts
CHANGED
|
@@ -96,6 +96,14 @@ interface BorderProps {
|
|
|
96
96
|
cornerRadius?: ResponsiveValue<RadiusValue>;
|
|
97
97
|
}
|
|
98
98
|
interface VisualProps {
|
|
99
|
+
textColor?: ResponsiveValue<ColorValue>;
|
|
100
|
+
iconColor?: ResponsiveValue<ColorValue>;
|
|
101
|
+
placeholderColor?: ResponsiveValue<ColorValue>;
|
|
102
|
+
panelBackgroundColor?: ResponsiveValue<ColorValue>;
|
|
103
|
+
panelTextColor?: ResponsiveValue<ColorValue>;
|
|
104
|
+
optionHoverBackgroundColor?: ResponsiveValue<ColorValue>;
|
|
105
|
+
selectedOptionBackgroundColor?: ResponsiveValue<ColorValue>;
|
|
106
|
+
selectedOptionTextColor?: ResponsiveValue<ColorValue>;
|
|
99
107
|
backgroundColor?: ResponsiveValue<ColorValue>;
|
|
100
108
|
opacity?: ResponsiveValue<number>;
|
|
101
109
|
shadow?: ResponsiveValue<"none" | "xs" | "sm" | "md" | "lg" | "xl">;
|
|
@@ -213,6 +221,8 @@ interface ButtonProps extends BaseUIProps, TypographyProps, DisableableProps, Lo
|
|
|
213
221
|
iconPosition?: "left" | "right" | "center";
|
|
214
222
|
badge?: string | number;
|
|
215
223
|
ariaLabel?: string;
|
|
224
|
+
/** Label for a self-closing button. Children/content take precedence. */
|
|
225
|
+
text?: string;
|
|
216
226
|
}
|
|
217
227
|
interface ButtonGroupProps extends BaseUIProps {
|
|
218
228
|
orientation?: Orientation;
|
|
@@ -223,6 +233,11 @@ interface ButtonGroupProps extends BaseUIProps {
|
|
|
223
233
|
}
|
|
224
234
|
interface InputProps extends BaseUIProps, TypographyProps, DisableableProps, ReadOnlyProps, RequiredProps, FocusableProps {
|
|
225
235
|
name?: string;
|
|
236
|
+
min?: string | number;
|
|
237
|
+
max?: string | number;
|
|
238
|
+
step?: string | number;
|
|
239
|
+
minLength?: number;
|
|
240
|
+
maxLength?: number;
|
|
226
241
|
value?: string | number;
|
|
227
242
|
placeholder?: string;
|
|
228
243
|
/** Controls which characters FlowUI accepts without changing the visual input type. */
|
|
@@ -264,6 +279,7 @@ interface DropdownModel {
|
|
|
264
279
|
group?: string | number;
|
|
265
280
|
}
|
|
266
281
|
interface TreeModel extends DropdownModel {
|
|
282
|
+
icon?: string;
|
|
267
283
|
children?: TreeModel[];
|
|
268
284
|
selectable?: boolean;
|
|
269
285
|
hasChildren?: boolean;
|
|
@@ -354,6 +370,8 @@ interface PasswordInputProps extends Omit<InputProps, "type"> {
|
|
|
354
370
|
visible?: boolean;
|
|
355
371
|
}
|
|
356
372
|
interface TreeProps extends BaseUIProps {
|
|
373
|
+
showCheckboxes?: boolean;
|
|
374
|
+
checkedValues?: readonly (string | number)[];
|
|
357
375
|
nodes: TreeModel[];
|
|
358
376
|
value?: string | number;
|
|
359
377
|
defaultExpanded?: boolean;
|
|
@@ -491,8 +509,9 @@ interface PhoneInputProps extends BaseUIProps, DisableableProps {
|
|
|
491
509
|
placeholder?: string;
|
|
492
510
|
name?: string;
|
|
493
511
|
}
|
|
494
|
-
type ChartType = "bar" | "line" | "pie" | "doughnut";
|
|
512
|
+
type ChartType = "bar" | "column" | "horizontal-bar" | "line" | "area" | "combo" | "pie" | "doughnut";
|
|
495
513
|
interface ChartSeries {
|
|
514
|
+
type?: "column" | "line";
|
|
496
515
|
name: string;
|
|
497
516
|
data: number[];
|
|
498
517
|
color?: ColorValue;
|
|
@@ -518,6 +537,8 @@ type FlowInputMode = NonNullable<InputProps["inputMode"]>;
|
|
|
518
537
|
/** Keeps only characters allowed by the selected FlowUI input mode. */
|
|
519
538
|
declare function sanitizeInputValue(value: string, mode?: FlowInputMode): string;
|
|
520
539
|
declare function clampNumber(value: number, min: number, max: number): number;
|
|
540
|
+
/** Validate numeric bounds without silently clamping user-entered text. */
|
|
541
|
+
declare function numericInputError(value: string | number, min?: string | number, max?: string | number, step?: string | number): string | undefined;
|
|
521
542
|
|
|
522
543
|
declare function tableToCsv<T>(data: readonly T[], columns: readonly TableColumn<T>[]): string;
|
|
523
544
|
declare function exportTableToCsv<T>(data: T[], columns: TableColumn<T>[], fileName?: string): void;
|
|
@@ -531,6 +552,8 @@ declare function flattenTree(nodes: TreeModel[]): TreeModel[];
|
|
|
531
552
|
declare function enabledSelectableDescendants(node: TreeModel): TreeModel[];
|
|
532
553
|
declare function filterTree(nodes: TreeModel[], query: string): TreeModel[];
|
|
533
554
|
declare function selectedTreeModels(nodes: TreeModel[], values: SelectionValue[]): TreeModel[];
|
|
555
|
+
declare function treeCheckState(node: TreeModel, selected: ReadonlySet<SelectionValue>): boolean | "mixed";
|
|
556
|
+
declare function toggleTreeCheck(node: TreeModel, values: readonly SelectionValue[]): SelectionValue[];
|
|
534
557
|
|
|
535
558
|
/** Code-to-text results. null is a confirmed missing value; absent keys are errors. */
|
|
536
559
|
type LabelResults = Readonly<Record<string, string | null>>;
|
|
@@ -635,4 +658,94 @@ interface NotificationAction {
|
|
|
635
658
|
onClick: () => void | Promise<void>;
|
|
636
659
|
}
|
|
637
660
|
|
|
638
|
-
|
|
661
|
+
interface FlowTextStyle {
|
|
662
|
+
color?: string;
|
|
663
|
+
fontFamily?: string;
|
|
664
|
+
fontSize?: number;
|
|
665
|
+
fontWeight?: "normal" | "bold" | "400" | "500" | "600" | "700";
|
|
666
|
+
lineHeight?: number;
|
|
667
|
+
textAlign?: "left" | "center" | "right";
|
|
668
|
+
}
|
|
669
|
+
interface FlowIconStyle {
|
|
670
|
+
color?: string;
|
|
671
|
+
size?: number;
|
|
672
|
+
}
|
|
673
|
+
interface FlowAction {
|
|
674
|
+
Label: string;
|
|
675
|
+
Icon?: string;
|
|
676
|
+
IsReadonly?: boolean;
|
|
677
|
+
TextStyle?: FlowTextStyle;
|
|
678
|
+
IconStyle?: FlowIconStyle;
|
|
679
|
+
}
|
|
680
|
+
interface FlowStage {
|
|
681
|
+
Id: string;
|
|
682
|
+
Label: string;
|
|
683
|
+
IsCurrent?: boolean;
|
|
684
|
+
IsCompleted?: boolean;
|
|
685
|
+
IsDisabled?: boolean;
|
|
686
|
+
Actions?: readonly FlowAction[];
|
|
687
|
+
SelectedAction?: FlowAction;
|
|
688
|
+
TextStyle?: FlowTextStyle;
|
|
689
|
+
}
|
|
690
|
+
interface FlowStageStyle {
|
|
691
|
+
backgroundColor?: string;
|
|
692
|
+
icon?: string;
|
|
693
|
+
iconStyle?: FlowIconStyle;
|
|
694
|
+
textStyle?: FlowTextStyle;
|
|
695
|
+
}
|
|
696
|
+
interface FlowActionItemStyle {
|
|
697
|
+
backgroundColor?: string;
|
|
698
|
+
textStyle?: FlowTextStyle;
|
|
699
|
+
iconStyle?: FlowIconStyle;
|
|
700
|
+
}
|
|
701
|
+
interface WorkflowStepperProps extends BaseUIProps {
|
|
702
|
+
stages: readonly FlowStage[];
|
|
703
|
+
direction?: "horizontal" | "vertical";
|
|
704
|
+
labelPosition?: "above" | "below" | "beside";
|
|
705
|
+
lineColor?: string;
|
|
706
|
+
stageTextStyle?: FlowTextStyle;
|
|
707
|
+
completedStyle?: FlowStageStyle;
|
|
708
|
+
currentStyle?: FlowStageStyle;
|
|
709
|
+
disabledStyle?: FlowStageStyle;
|
|
710
|
+
actionMenuStyle?: {
|
|
711
|
+
backgroundColor?: string;
|
|
712
|
+
borderColor?: string;
|
|
713
|
+
borderRadius?: number;
|
|
714
|
+
boxShadow?: string;
|
|
715
|
+
};
|
|
716
|
+
actionItemStyle?: FlowActionItemStyle & {
|
|
717
|
+
hover?: FlowActionItemStyle;
|
|
718
|
+
selected?: FlowActionItemStyle;
|
|
719
|
+
readonly?: FlowActionItemStyle;
|
|
720
|
+
};
|
|
721
|
+
checkmarkStyle?: FlowIconStyle;
|
|
722
|
+
chevronStyle?: FlowIconStyle;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
type Mark = {
|
|
726
|
+
fill: string;
|
|
727
|
+
path?: string;
|
|
728
|
+
stroke?: string;
|
|
729
|
+
opacity?: number;
|
|
730
|
+
x?: number;
|
|
731
|
+
y?: number;
|
|
732
|
+
width?: number;
|
|
733
|
+
height?: number;
|
|
734
|
+
};
|
|
735
|
+
declare function buildChart(data: ChartData, type: ChartType, height: number, showValues: boolean): {
|
|
736
|
+
marks: Mark[];
|
|
737
|
+
labels: {
|
|
738
|
+
x: number;
|
|
739
|
+
y: number;
|
|
740
|
+
text: string;
|
|
741
|
+
anchor: "middle" | "end" | "start";
|
|
742
|
+
}[];
|
|
743
|
+
legend: {
|
|
744
|
+
label: string;
|
|
745
|
+
color: string;
|
|
746
|
+
}[];
|
|
747
|
+
width: number;
|
|
748
|
+
height: number;
|
|
749
|
+
};
|
|
750
|
+
|
|
751
|
+
export { type AlignValue, type AsyncLabelCode, type AsyncLabelConfig, type AsyncLabelOptions, type AsyncLabelState, AsyncLabelStore, type AutocompleteProps, type BadgeProps, type BaseUIProps, type BorderProps, type BreadcrumbItem, type BreadcrumbProps, type BreakpointName, type ButtonGroupProps, type ButtonProps, type CSSLength, type CSSVariableStyle, type CardProps, type CarouselProps, type ChartData, type ChartProps, type ChartSeries, type ChartType, type ColorPalette, type ColorScale, type ColorShade, type ColorValue, type ComponentSize, type ComponentVariant, type DateTimeMode, type DateTimeProps, type DeepPartial, type DialogPosition, type DimensionValue, type DisableableProps, type DividerProps, type DropdownBehaviorProps, type DropdownModel, type FieldFocusStyle, type FileUploadProps, type FlexContainerProps, type FlexDirection, type FlexItemProps, type FlexWrap, type FlowAction, type FlowActionItemStyle, type FlowIconStyle, type FlowInputMode, type FlowStage, type FlowStageStyle, type FlowTextStyle, type FlowUIStyle, type FlowUITheme, type FocusableProps, type HStackProps, type IconProps, type ImageProps, type InputProps, type JustifyValue, type KnobProps, type LabelLookup, type LabelProps, type LabelResolverContext, type LabelResults, type LayoutProps, type ListboxProps, type LoadingProps, type MenuItem, type MultiSelectProps, type NotificationAction, type NotificationHorizontal, type NotificationProps, type NotificationType, type NotificationVertical, type OTPInputProps, type Orientation, type PaletteColor, type PasswordInputProps, type PhoneCountry, type PhoneInputProps, type PhoneNumberValue, type PopoverProps, type PositionProps, type PositionValue, type RadiusToken, type RadiusValue, type RatingProps, type ReadOnlyProps, type RequiredProps, type ResolvedStyle, type ResponsiveObject, type ResponsiveValue, type SchemeColor, type SelectOption, type SelectionValue, type SliderProps, type SortDirection, type SortState, type SpacingProps, type SpacingToken, type SpacingValue, type StackProps, type StyleResolution, type SwitchProps, type TabItem, type TabSelectedStyle, type TableColumn, type TableLoadMoreContext, type ThemeColorScheme, type ThemeMode, type TimelineItem, type TimelineProps, type TooltipLocation, type TooltipProps, type TreeDropdownProps, type TreeModel, type TreeMultiSelectProps, type TreeProps, type TypographyProps, type VStackProps, type VisualProps, type WorkflowStepperProps, buildChart, clampNumber, createAsyncLabelStore, createNotificationTimer, createTheme, defaultTheme, enabledSelectableDescendants, exportTableToCsv, exportTableToExcel, exportTableToPdf, filterTree, flattenTree, flowClass, formatLocalDateTime, notificationDuration, numericInputError, resolveColorValue, resolveFlowStyle, resolveTooltipLocation, responsiveCSS, sanitizeInputValue, selectedTreeModels, setLocalDayBoundary, tableToCsv, themeToCSS, toggleTreeCheck, treeCheckState };
|
package/dist/index.js
CHANGED
|
@@ -281,6 +281,13 @@ var responsiveProperties = {
|
|
|
281
281
|
borderStyle: "border-style",
|
|
282
282
|
borderColor: "border-color",
|
|
283
283
|
cornerRadius: "border-radius",
|
|
284
|
+
iconColor: "--fui-control-icon",
|
|
285
|
+
placeholderColor: "--fui-control-placeholder",
|
|
286
|
+
panelBackgroundColor: "--fui-panel-background",
|
|
287
|
+
panelTextColor: "--fui-panel-text",
|
|
288
|
+
optionHoverBackgroundColor: "--fui-option-hover-background",
|
|
289
|
+
selectedOptionBackgroundColor: "--fui-option-selected-background",
|
|
290
|
+
selectedOptionTextColor: "--fui-option-selected-text",
|
|
284
291
|
backgroundColor: "background-color",
|
|
285
292
|
opacity: "opacity",
|
|
286
293
|
shadow: "box-shadow",
|
|
@@ -294,10 +301,12 @@ var responsiveProperties = {
|
|
|
294
301
|
function responsiveCSS(theme) {
|
|
295
302
|
const output = [];
|
|
296
303
|
for (const [prop, css] of Object.entries(responsiveProperties)) {
|
|
297
|
-
output.push(
|
|
304
|
+
output.push(
|
|
305
|
+
`.fui-r-${prop}-default{${css}:var(--fui-${prop}-default)${prop === "backgroundColor" ? ";--fui-control-background:var(--fui-backgroundColor-default)" : prop === "textColor" ? ";--fui-control-text:var(--fui-textColor-default)" : ""}}`
|
|
306
|
+
);
|
|
298
307
|
for (const [breakpoint, width] of Object.entries(theme.breakpoints)) {
|
|
299
308
|
output.push(
|
|
300
|
-
`@media(min-width:${width}){.fui-r-${prop}-${breakpoint}{${css}:var(--fui-${prop}-${breakpoint})}}`
|
|
309
|
+
`@media(min-width:${width}){.fui-r-${prop}-${breakpoint}{${css}:var(--fui-${prop}-${breakpoint})${prop === "backgroundColor" ? `;--fui-control-background:var(--fui-backgroundColor-${breakpoint})` : prop === "textColor" ? `;--fui-control-text:var(--fui-textColor-${breakpoint})` : ""}}}`
|
|
301
310
|
);
|
|
302
311
|
}
|
|
303
312
|
}
|
|
@@ -403,6 +412,22 @@ var propertyMap = {
|
|
|
403
412
|
css: "borderRadius",
|
|
404
413
|
resolve: ((v, t) => v in t.radius ? `var(--fui-radius-${v})` : length(v))
|
|
405
414
|
},
|
|
415
|
+
iconColor: { css: "--fui-control-icon", resolve: color },
|
|
416
|
+
placeholderColor: { css: "--fui-control-placeholder", resolve: color },
|
|
417
|
+
panelBackgroundColor: { css: "--fui-panel-background", resolve: color },
|
|
418
|
+
panelTextColor: { css: "--fui-panel-text", resolve: color },
|
|
419
|
+
optionHoverBackgroundColor: {
|
|
420
|
+
css: "--fui-option-hover-background",
|
|
421
|
+
resolve: color
|
|
422
|
+
},
|
|
423
|
+
selectedOptionBackgroundColor: {
|
|
424
|
+
css: "--fui-option-selected-background",
|
|
425
|
+
resolve: color
|
|
426
|
+
},
|
|
427
|
+
selectedOptionTextColor: {
|
|
428
|
+
css: "--fui-option-selected-text",
|
|
429
|
+
resolve: color
|
|
430
|
+
},
|
|
406
431
|
backgroundColor: { css: "backgroundColor", resolve: color },
|
|
407
432
|
opacity: { css: "opacity", resolve: String },
|
|
408
433
|
shadow: {
|
|
@@ -464,6 +489,10 @@ function resolveFlowStyle(props, theme) {
|
|
|
464
489
|
style["--fui-field-focus-border"] = "var(--fui-color-borderStrong)";
|
|
465
490
|
style["--fui-field-focus-shadow"] = "none";
|
|
466
491
|
}
|
|
492
|
+
if (style.backgroundColor !== void 0)
|
|
493
|
+
style["--fui-control-background"] = String(style.backgroundColor);
|
|
494
|
+
if (style.color !== void 0)
|
|
495
|
+
style["--fui-control-text"] = String(style.color);
|
|
467
496
|
Object.assign(style, userStyle);
|
|
468
497
|
return { classNames, style };
|
|
469
498
|
}
|
|
@@ -504,6 +533,20 @@ function sanitizeInputValue(value, mode = "text") {
|
|
|
504
533
|
function clampNumber(value, min, max) {
|
|
505
534
|
return Math.min(max, Math.max(min, value));
|
|
506
535
|
}
|
|
536
|
+
function numericInputError(value, min, max, step) {
|
|
537
|
+
if (String(value).trim() === "") return;
|
|
538
|
+
const number = Number(value);
|
|
539
|
+
if (!Number.isFinite(number)) return "Enter a valid number.";
|
|
540
|
+
if (min !== void 0 && number < Number(min))
|
|
541
|
+
return `Enter a value of at least ${min}.`;
|
|
542
|
+
if (max !== void 0 && number > Number(max))
|
|
543
|
+
return `Enter a value no greater than ${max}.`;
|
|
544
|
+
if (step !== void 0 && step !== "any" && Number(step) > 0) {
|
|
545
|
+
const count = (number - Number(min ?? 0)) / Number(step);
|
|
546
|
+
if (Math.abs(count - Math.round(count)) > 1e-8)
|
|
547
|
+
return `Use increments of ${step}.`;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
507
550
|
|
|
508
551
|
// src/table-export.ts
|
|
509
552
|
function cellText(row, column) {
|
|
@@ -634,6 +677,22 @@ function selectedTreeModels(nodes, values) {
|
|
|
634
677
|
const selected = new Set(values);
|
|
635
678
|
return flattenTree(nodes).filter((node) => selected.has(node.value));
|
|
636
679
|
}
|
|
680
|
+
function treeCheckState(node, selected) {
|
|
681
|
+
const leaves = enabledSelectableDescendants(node);
|
|
682
|
+
const checked = leaves.filter((leaf) => selected.has(leaf.value)).length;
|
|
683
|
+
if (!checked) return false;
|
|
684
|
+
return checked === leaves.length ? true : "mixed";
|
|
685
|
+
}
|
|
686
|
+
function toggleTreeCheck(node, values) {
|
|
687
|
+
const selected = new Set(values);
|
|
688
|
+
if (node.disabled || node.selectable === false) return [...selected];
|
|
689
|
+
const remove = treeCheckState(node, selected) === true;
|
|
690
|
+
for (const leaf of enabledSelectableDescendants(node)) {
|
|
691
|
+
if (remove) selected.delete(leaf.value);
|
|
692
|
+
else selected.add(leaf.value);
|
|
693
|
+
}
|
|
694
|
+
return [...selected];
|
|
695
|
+
}
|
|
637
696
|
|
|
638
697
|
// src/async-label.ts
|
|
639
698
|
var idle = Object.freeze({ status: "idle" });
|
|
@@ -988,8 +1047,150 @@ function createNotificationTimer(duration, onElapsed) {
|
|
|
988
1047
|
}
|
|
989
1048
|
};
|
|
990
1049
|
}
|
|
1050
|
+
|
|
1051
|
+
// src/chart.ts
|
|
1052
|
+
var palette = ["#3b82c4", "#f59429", "#8cba39", "#ed74a7", "#8762c8"];
|
|
1053
|
+
function buildChart(data, type, height, showValues) {
|
|
1054
|
+
const width = 640;
|
|
1055
|
+
const marks = [];
|
|
1056
|
+
const labels = [];
|
|
1057
|
+
const label = (x2, y2, text, anchor = "middle") => labels.push({ x: x2, y: y2, text: String(text), anchor });
|
|
1058
|
+
const legend = data.series.map((series, index) => ({
|
|
1059
|
+
label: series.name,
|
|
1060
|
+
color: series.color ? resolveColorValue(series.color) : palette[index % palette.length]
|
|
1061
|
+
}));
|
|
1062
|
+
const colorAt = (index) => palette[index % palette.length];
|
|
1063
|
+
const path = (d, fill = "none", stroke, opacity) => marks.push({ path: d, fill, stroke, opacity });
|
|
1064
|
+
if (type === "pie" || type === "doughnut") {
|
|
1065
|
+
const values2 = (data.series[0]?.data ?? []).map(
|
|
1066
|
+
(value) => Math.max(0, value)
|
|
1067
|
+
);
|
|
1068
|
+
const total = values2.reduce((sum, value) => sum + value, 0);
|
|
1069
|
+
const radius = height * 0.38;
|
|
1070
|
+
const centerX = width / 2;
|
|
1071
|
+
const centerY = height / 2;
|
|
1072
|
+
const point = (r, angle) => [
|
|
1073
|
+
centerX + r * Math.cos(angle),
|
|
1074
|
+
centerY + r * Math.sin(angle)
|
|
1075
|
+
];
|
|
1076
|
+
let start = -Math.PI / 2;
|
|
1077
|
+
values2.forEach((value, index) => {
|
|
1078
|
+
if (!value || !total) return;
|
|
1079
|
+
const sweep = 2 * Math.PI * value / total;
|
|
1080
|
+
const end = start + Math.min(sweep, 2 * Math.PI - 1e-4);
|
|
1081
|
+
const inner = type === "doughnut" ? radius * 0.55 : 0;
|
|
1082
|
+
const large = sweep > Math.PI ? 1 : 0;
|
|
1083
|
+
const tail = inner ? `L ${point(inner, end)} A ${inner},${inner} 0 ${large} 0 ${point(inner, start)}` : `L ${centerX},${centerY}`;
|
|
1084
|
+
path(
|
|
1085
|
+
`M ${point(radius, start)} A ${radius},${radius} 0 ${large} 1 ${point(radius, end)} ${tail} Z`,
|
|
1086
|
+
colorAt(index),
|
|
1087
|
+
"white"
|
|
1088
|
+
);
|
|
1089
|
+
if (showValues) {
|
|
1090
|
+
const [x2, y2] = point(radius * 0.75, (start + end) / 2);
|
|
1091
|
+
label(x2, y2, value);
|
|
1092
|
+
}
|
|
1093
|
+
start += sweep;
|
|
1094
|
+
});
|
|
1095
|
+
return {
|
|
1096
|
+
marks,
|
|
1097
|
+
labels,
|
|
1098
|
+
legend: values2.map((_, index) => ({
|
|
1099
|
+
label: data.labels[index] ?? String(index + 1),
|
|
1100
|
+
color: colorAt(index)
|
|
1101
|
+
})),
|
|
1102
|
+
width,
|
|
1103
|
+
height
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
const left = type === "horizontal-bar" ? 120 : 48;
|
|
1107
|
+
const right = width - 28;
|
|
1108
|
+
const top = 24;
|
|
1109
|
+
const bottom = height - 34;
|
|
1110
|
+
const values = data.series.flatMap((series) => series.data);
|
|
1111
|
+
const min = Math.min(0, ...values);
|
|
1112
|
+
const max = Math.max(1, ...values);
|
|
1113
|
+
const groupCount = Math.max(
|
|
1114
|
+
1,
|
|
1115
|
+
data.labels.length,
|
|
1116
|
+
...data.series.map((series) => series.data.length)
|
|
1117
|
+
);
|
|
1118
|
+
const groupWidth = (right - left) / groupCount;
|
|
1119
|
+
const groupHeight = (bottom - top) / groupCount;
|
|
1120
|
+
const x = (index) => left + groupWidth * (index + 0.5);
|
|
1121
|
+
const y = (value) => bottom - (value - min) / (max - min) * (bottom - top);
|
|
1122
|
+
const scaleX = (value) => left + (value - min) / (max - min) * (right - left);
|
|
1123
|
+
const horizontal = type === "horizontal-bar";
|
|
1124
|
+
path(
|
|
1125
|
+
horizontal ? `M ${left} ${top} V ${bottom} H ${right} M ${scaleX(0)} ${top} V ${bottom}` : `M ${left} ${top} V ${y(0)} H ${right}`,
|
|
1126
|
+
"none",
|
|
1127
|
+
"#cbd5e1"
|
|
1128
|
+
);
|
|
1129
|
+
data.labels.forEach(
|
|
1130
|
+
(item, index) => horizontal ? label(left - 10, top + groupHeight * (index + 0.5) + 4, item, "end") : label(x(index), height - 10, item)
|
|
1131
|
+
);
|
|
1132
|
+
const isLine = (index) => type === "line" || type === "area" || type === "combo" && (data.series[index].type ?? (index === data.series.length - 1 ? "line" : "column")) === "line";
|
|
1133
|
+
const columns = data.series.filter((_, index) => !isLine(index));
|
|
1134
|
+
data.series.forEach((series, index) => {
|
|
1135
|
+
if (isLine(index)) return;
|
|
1136
|
+
const columnIndex = columns.indexOf(series);
|
|
1137
|
+
const size = (horizontal ? groupHeight : groupWidth) * 0.68 / columns.length;
|
|
1138
|
+
series.data.forEach((value, valueIndex) => {
|
|
1139
|
+
const fill = type === "bar" || series.color || columns.length > 1 ? legend[index].color : colorAt(valueIndex);
|
|
1140
|
+
if (horizontal) {
|
|
1141
|
+
const rowY = top + groupHeight * (valueIndex + 0.5) + (columnIndex - columns.length / 2) * size;
|
|
1142
|
+
marks.push({
|
|
1143
|
+
x: Math.min(scaleX(0), scaleX(value)),
|
|
1144
|
+
y: rowY,
|
|
1145
|
+
width: Math.abs(scaleX(value) - scaleX(0)),
|
|
1146
|
+
height: Math.max(1, size - 3),
|
|
1147
|
+
fill
|
|
1148
|
+
});
|
|
1149
|
+
if (showValues)
|
|
1150
|
+
label(
|
|
1151
|
+
scaleX(value) + (value < 0 ? -4 : 4),
|
|
1152
|
+
rowY + size / 2 + 4,
|
|
1153
|
+
value,
|
|
1154
|
+
value < 0 ? "end" : "start"
|
|
1155
|
+
);
|
|
1156
|
+
} else {
|
|
1157
|
+
const columnX = x(valueIndex) + (columnIndex - columns.length / 2) * size;
|
|
1158
|
+
marks.push({
|
|
1159
|
+
x: columnX,
|
|
1160
|
+
y: Math.min(y(0), y(value)),
|
|
1161
|
+
width: Math.max(1, size - 3),
|
|
1162
|
+
height: Math.abs(y(0) - y(value)),
|
|
1163
|
+
fill
|
|
1164
|
+
});
|
|
1165
|
+
if (showValues) label(columnX + size / 2, y(value) - 6, value);
|
|
1166
|
+
}
|
|
1167
|
+
});
|
|
1168
|
+
});
|
|
1169
|
+
data.series.forEach((series, index) => {
|
|
1170
|
+
if (!isLine(index) || !series.data.length) return;
|
|
1171
|
+
const coordinates = series.data.map(
|
|
1172
|
+
(value, valueIndex) => `${x(valueIndex)},${y(value)}`
|
|
1173
|
+
);
|
|
1174
|
+
const trace = `M ${coordinates.join(" L ")}`;
|
|
1175
|
+
if (type === "area") {
|
|
1176
|
+
path(
|
|
1177
|
+
`${trace} L ${x(coordinates.length - 1)},${y(0)} L ${x(0)},${y(0)} Z`,
|
|
1178
|
+
legend[index].color,
|
|
1179
|
+
void 0,
|
|
1180
|
+
0.28
|
|
1181
|
+
);
|
|
1182
|
+
}
|
|
1183
|
+
path(trace, "none", legend[index].color);
|
|
1184
|
+
if (showValues)
|
|
1185
|
+
series.data.forEach(
|
|
1186
|
+
(value, valueIndex) => label(x(valueIndex), y(value) - 8, value)
|
|
1187
|
+
);
|
|
1188
|
+
});
|
|
1189
|
+
return { marks, labels, legend, width, height };
|
|
1190
|
+
}
|
|
991
1191
|
export {
|
|
992
1192
|
AsyncLabelStore,
|
|
1193
|
+
buildChart,
|
|
993
1194
|
clampNumber,
|
|
994
1195
|
createAsyncLabelStore,
|
|
995
1196
|
createNotificationTimer,
|
|
@@ -1004,6 +1205,7 @@ export {
|
|
|
1004
1205
|
flowClass,
|
|
1005
1206
|
formatLocalDateTime,
|
|
1006
1207
|
notificationDuration,
|
|
1208
|
+
numericInputError,
|
|
1007
1209
|
resolveColorValue,
|
|
1008
1210
|
resolveFlowStyle,
|
|
1009
1211
|
resolveTooltipLocation,
|
|
@@ -1012,5 +1214,7 @@ export {
|
|
|
1012
1214
|
selectedTreeModels,
|
|
1013
1215
|
setLocalDayBoundary,
|
|
1014
1216
|
tableToCsv,
|
|
1015
|
-
themeToCSS
|
|
1217
|
+
themeToCSS,
|
|
1218
|
+
toggleTreeCheck,
|
|
1219
|
+
treeCheckState
|
|
1016
1220
|
};
|