@akin2unde/flowui-core 0.3.0 → 1.0.0
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 +64 -12
- package/dist/index.d.cts +31 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.js +61 -12
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -26,6 +26,7 @@ __export(index_exports, {
|
|
|
26
26
|
createTheme: () => createTheme,
|
|
27
27
|
defaultTheme: () => defaultTheme,
|
|
28
28
|
enabledSelectableDescendants: () => enabledSelectableDescendants,
|
|
29
|
+
exportTableToCsv: () => exportTableToCsv,
|
|
29
30
|
exportTableToExcel: () => exportTableToExcel,
|
|
30
31
|
exportTableToPdf: () => exportTableToPdf,
|
|
31
32
|
filterTree: () => filterTree,
|
|
@@ -34,10 +35,12 @@ __export(index_exports, {
|
|
|
34
35
|
formatLocalDateTime: () => formatLocalDateTime,
|
|
35
36
|
resolveColorValue: () => resolveColorValue,
|
|
36
37
|
resolveFlowStyle: () => resolveFlowStyle,
|
|
38
|
+
resolveTooltipLocation: () => resolveTooltipLocation,
|
|
37
39
|
responsiveCSS: () => responsiveCSS,
|
|
38
40
|
sanitizeInputValue: () => sanitizeInputValue,
|
|
39
41
|
selectedTreeModels: () => selectedTreeModels,
|
|
40
42
|
setLocalDayBoundary: () => setLocalDayBoundary,
|
|
43
|
+
tableToCsv: () => tableToCsv,
|
|
41
44
|
themeToCSS: () => themeToCSS
|
|
42
45
|
});
|
|
43
46
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -497,6 +500,17 @@ function resolveFlowStyle(props, theme) {
|
|
|
497
500
|
style.WebkitBoxOrient = "vertical";
|
|
498
501
|
style.WebkitLineClamp = lines;
|
|
499
502
|
}
|
|
503
|
+
const focusStyle = props.focusStyle ?? theme.focusStyle;
|
|
504
|
+
if (focusStyle === "ring") {
|
|
505
|
+
style["--fui-field-focus-border"] = "var(--fui-color-borderStrong)";
|
|
506
|
+
style["--fui-field-focus-shadow"] = "0 0 0 2px color-mix(in srgb, var(--fui-color-focus) 22%, transparent)";
|
|
507
|
+
} else if (focusStyle === "none") {
|
|
508
|
+
style["--fui-field-focus-border"] = "var(--fui-color-border)";
|
|
509
|
+
style["--fui-field-focus-shadow"] = "none";
|
|
510
|
+
} else if (focusStyle === "border") {
|
|
511
|
+
style["--fui-field-focus-border"] = "var(--fui-color-borderStrong)";
|
|
512
|
+
style["--fui-field-focus-shadow"] = "none";
|
|
513
|
+
}
|
|
500
514
|
Object.assign(style, userStyle);
|
|
501
515
|
return { classNames, style };
|
|
502
516
|
}
|
|
@@ -549,10 +563,24 @@ function download(content, type, fileName) {
|
|
|
549
563
|
anchor.href = url;
|
|
550
564
|
anchor.download = fileName;
|
|
551
565
|
anchor.click();
|
|
552
|
-
URL.revokeObjectURL(url);
|
|
566
|
+
setTimeout(() => URL.revokeObjectURL(url), 1e3);
|
|
567
|
+
}
|
|
568
|
+
function tableToCsv(data, columns) {
|
|
569
|
+
const escape = (value) => '"' + value.replaceAll('"', '""') + '"';
|
|
570
|
+
return [
|
|
571
|
+
columns.map((column) => column.header),
|
|
572
|
+
...data.map((item) => columns.map((column) => cellText(item, column)))
|
|
573
|
+
].map((row) => row.map(escape).join(",")).join("\r\n");
|
|
574
|
+
}
|
|
575
|
+
function exportTableToCsv(data, columns, fileName = "table") {
|
|
576
|
+
download(
|
|
577
|
+
"\uFEFF" + tableToCsv(data, columns),
|
|
578
|
+
"text/csv;charset=utf-8",
|
|
579
|
+
`${fileName}.csv`
|
|
580
|
+
);
|
|
553
581
|
}
|
|
554
582
|
function xml(value) {
|
|
555
|
-
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """);
|
|
583
|
+
return value.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, "").replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """);
|
|
556
584
|
}
|
|
557
585
|
function exportTableToExcel(data, columns, fileName = "table") {
|
|
558
586
|
const row = (values) => `<Row>${values.map((value) => `<Cell><Data ss:Type="String">${xml(value)}</Data></Cell>`).join("")}</Row>`;
|
|
@@ -561,21 +589,24 @@ function exportTableToExcel(data, columns, fileName = "table") {
|
|
|
561
589
|
...data.map((item) => row(columns.map((column) => cellText(item, column))))
|
|
562
590
|
].join("");
|
|
563
591
|
const workbook = `<?xml version="1.0"?><Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"><Worksheet ss:Name="Data"><Table>${rows}</Table></Worksheet></Workbook>`;
|
|
564
|
-
download(workbook, "application/vnd.ms-excel", `${fileName}.
|
|
592
|
+
download(workbook, "application/vnd.ms-excel", `${fileName}.xml`);
|
|
565
593
|
}
|
|
566
594
|
function pdfEscape(value) {
|
|
567
595
|
return value.replaceAll("\\", "\\\\").replaceAll("(", "\\(").replaceAll(")", "\\)").replace(/[^\x20-\x7e]/g, "?");
|
|
568
596
|
}
|
|
569
597
|
function exportTableToPdf(data, columns, fileName = "table") {
|
|
570
|
-
const
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
598
|
+
const wrap = (line) => line.replace(/\r?\n/g, " ").match(/.{1,82}/gu) ?? [""];
|
|
599
|
+
const header = wrap(columns.map((column) => column.header).join(" | "));
|
|
600
|
+
const lines = data.flatMap(
|
|
601
|
+
(item) => wrap(columns.map((column) => cellText(item, column)).join(" | "))
|
|
602
|
+
);
|
|
603
|
+
const pageLength = Math.max(1, 48 - header.length);
|
|
576
604
|
const pages = Array.from(
|
|
577
|
-
{ length: Math.max(1, Math.ceil(lines.length /
|
|
578
|
-
(_, index) =>
|
|
605
|
+
{ length: Math.max(1, Math.ceil(lines.length / pageLength)) },
|
|
606
|
+
(_, index) => [
|
|
607
|
+
...header,
|
|
608
|
+
...lines.slice(index * pageLength, (index + 1) * pageLength)
|
|
609
|
+
]
|
|
579
610
|
);
|
|
580
611
|
const fontObject = 3 + pages.length * 2;
|
|
581
612
|
const pageObjects = pages.map((_, index) => 3 + index * 2);
|
|
@@ -590,7 +621,7 @@ function exportTableToPdf(data, columns, fileName = "table") {
|
|
|
590
621
|
"BT /F1 10 Tf 40 800 Td",
|
|
591
622
|
...page.flatMap((line, lineIndex) => [
|
|
592
623
|
lineIndex ? "0 -15 Td" : "",
|
|
593
|
-
`(${pdfEscape(line)
|
|
624
|
+
`(${pdfEscape(line)}) Tj`
|
|
594
625
|
]),
|
|
595
626
|
"ET"
|
|
596
627
|
].filter(Boolean).join("\n");
|
|
@@ -944,6 +975,24 @@ var AsyncLabelStore = class {
|
|
|
944
975
|
function createAsyncLabelStore(config) {
|
|
945
976
|
return new AsyncLabelStore(config);
|
|
946
977
|
}
|
|
978
|
+
|
|
979
|
+
// src/tooltip.ts
|
|
980
|
+
function resolveTooltipLocation(preferred, anchor, tooltip, viewport, gap = 6) {
|
|
981
|
+
const available = {
|
|
982
|
+
top: anchor.top,
|
|
983
|
+
right: viewport.width - anchor.right,
|
|
984
|
+
bottom: viewport.height - anchor.bottom,
|
|
985
|
+
left: anchor.left
|
|
986
|
+
};
|
|
987
|
+
const opposite = {
|
|
988
|
+
top: "bottom",
|
|
989
|
+
bottom: "top",
|
|
990
|
+
left: "right",
|
|
991
|
+
right: "left"
|
|
992
|
+
};
|
|
993
|
+
const required = preferred === "top" || preferred === "bottom" ? tooltip.height + gap : tooltip.width + gap;
|
|
994
|
+
return available[preferred] < required && available[opposite[preferred]] > available[preferred] ? opposite[preferred] : preferred;
|
|
995
|
+
}
|
|
947
996
|
// Annotate the CommonJS export names for ESM import in node:
|
|
948
997
|
0 && (module.exports = {
|
|
949
998
|
AsyncLabelStore,
|
|
@@ -952,6 +1001,7 @@ function createAsyncLabelStore(config) {
|
|
|
952
1001
|
createTheme,
|
|
953
1002
|
defaultTheme,
|
|
954
1003
|
enabledSelectableDescendants,
|
|
1004
|
+
exportTableToCsv,
|
|
955
1005
|
exportTableToExcel,
|
|
956
1006
|
exportTableToPdf,
|
|
957
1007
|
filterTree,
|
|
@@ -960,9 +1010,11 @@ function createAsyncLabelStore(config) {
|
|
|
960
1010
|
formatLocalDateTime,
|
|
961
1011
|
resolveColorValue,
|
|
962
1012
|
resolveFlowStyle,
|
|
1013
|
+
resolveTooltipLocation,
|
|
963
1014
|
responsiveCSS,
|
|
964
1015
|
sanitizeInputValue,
|
|
965
1016
|
selectedTreeModels,
|
|
966
1017
|
setLocalDayBoundary,
|
|
1018
|
+
tableToCsv,
|
|
967
1019
|
themeToCSS
|
|
968
1020
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -109,10 +109,12 @@ interface TypographyProps {
|
|
|
109
109
|
textTransform?: ResponsiveValue<"none" | "uppercase" | "lowercase" | "capitalize">;
|
|
110
110
|
lines?: ResponsiveValue<number>;
|
|
111
111
|
}
|
|
112
|
+
type FieldFocusStyle = "border" | "ring" | "none";
|
|
112
113
|
interface BaseUIProps extends SpacingProps, LayoutProps, PositionProps, FlexItemProps, BorderProps, VisualProps {
|
|
113
114
|
id?: string;
|
|
114
115
|
hidden?: boolean;
|
|
115
116
|
testId?: string;
|
|
117
|
+
focusStyle?: FieldFocusStyle;
|
|
116
118
|
className?: string;
|
|
117
119
|
style?: Readonly<FlowUIStyle>;
|
|
118
120
|
}
|
|
@@ -151,6 +153,7 @@ interface ThemeColorScheme {
|
|
|
151
153
|
overlay: string;
|
|
152
154
|
}
|
|
153
155
|
interface FlowUITheme {
|
|
156
|
+
focusStyle?: FieldFocusStyle;
|
|
154
157
|
palette: ColorPalette;
|
|
155
158
|
schemes: {
|
|
156
159
|
light: ThemeColorScheme;
|
|
@@ -266,6 +269,7 @@ interface TreeModel extends DropdownModel {
|
|
|
266
269
|
hasChildren?: boolean;
|
|
267
270
|
}
|
|
268
271
|
interface DropdownBehaviorProps extends BaseUIProps, DisableableProps {
|
|
272
|
+
clearable?: boolean;
|
|
269
273
|
options: DropdownModel[];
|
|
270
274
|
searchable?: boolean;
|
|
271
275
|
searchPlaceholder?: string;
|
|
@@ -285,6 +289,7 @@ interface MultiSelectProps extends DropdownBehaviorProps {
|
|
|
285
289
|
chipCloseIconColor?: ColorValue;
|
|
286
290
|
}
|
|
287
291
|
interface TreeMultiSelectProps extends BaseUIProps, DisableableProps {
|
|
292
|
+
clearable?: boolean;
|
|
288
293
|
nodes: TreeModel[];
|
|
289
294
|
value?: Array<string | number>;
|
|
290
295
|
expandedValues?: Array<string | number>;
|
|
@@ -298,6 +303,7 @@ interface TreeMultiSelectProps extends BaseUIProps, DisableableProps {
|
|
|
298
303
|
chipBackgroundColor?: ColorValue;
|
|
299
304
|
chipCloseIconColor?: ColorValue;
|
|
300
305
|
}
|
|
306
|
+
type TabSelectedStyle = "underline" | "fill";
|
|
301
307
|
interface TabItem {
|
|
302
308
|
id: string;
|
|
303
309
|
label: string;
|
|
@@ -319,6 +325,13 @@ interface TableColumn<T> {
|
|
|
319
325
|
align?: "left" | "center" | "right";
|
|
320
326
|
format?: (value: unknown, row: T) => string | number;
|
|
321
327
|
}
|
|
328
|
+
interface TableLoadMoreContext {
|
|
329
|
+
loadedCount: number;
|
|
330
|
+
totalCount?: number;
|
|
331
|
+
loading: boolean;
|
|
332
|
+
hasMore: boolean;
|
|
333
|
+
loadMore: () => void;
|
|
334
|
+
}
|
|
322
335
|
type DialogPosition = "center" | "left" | "right" | "top" | "bottom";
|
|
323
336
|
type TooltipLocation = "top" | "right" | "bottom" | "left";
|
|
324
337
|
interface CardProps extends BaseUIProps {
|
|
@@ -346,6 +359,7 @@ interface TreeProps extends BaseUIProps {
|
|
|
346
359
|
defaultExpanded?: boolean;
|
|
347
360
|
}
|
|
348
361
|
interface TreeDropdownProps extends BaseUIProps, DisableableProps {
|
|
362
|
+
clearable?: boolean;
|
|
349
363
|
nodes: TreeModel[];
|
|
350
364
|
value?: string | number;
|
|
351
365
|
placeholder?: string;
|
|
@@ -424,6 +438,7 @@ interface BreadcrumbItem {
|
|
|
424
438
|
other?: any;
|
|
425
439
|
}
|
|
426
440
|
interface BreadcrumbProps extends BaseUIProps {
|
|
441
|
+
separator?: string;
|
|
427
442
|
items: BreadcrumbItem[];
|
|
428
443
|
separatorIcon?: string;
|
|
429
444
|
}
|
|
@@ -503,6 +518,8 @@ type FlowInputMode = NonNullable<InputProps["inputMode"]>;
|
|
|
503
518
|
declare function sanitizeInputValue(value: string, mode?: FlowInputMode): string;
|
|
504
519
|
declare function clampNumber(value: number, min: number, max: number): number;
|
|
505
520
|
|
|
521
|
+
declare function tableToCsv<T>(data: readonly T[], columns: readonly TableColumn<T>[]): string;
|
|
522
|
+
declare function exportTableToCsv<T>(data: T[], columns: TableColumn<T>[], fileName?: string): void;
|
|
506
523
|
/** Downloads an Excel-compatible SpreadsheetML workbook without a runtime dependency. */
|
|
507
524
|
declare function exportTableToExcel<T>(data: T[], columns: TableColumn<T>[], fileName?: string): void;
|
|
508
525
|
/** Downloads a compact PDF containing the currently visible table data. */
|
|
@@ -593,4 +610,17 @@ declare class AsyncLabelStore {
|
|
|
593
610
|
}
|
|
594
611
|
declare function createAsyncLabelStore(config: AsyncLabelConfig): AsyncLabelStore;
|
|
595
612
|
|
|
596
|
-
|
|
613
|
+
declare function resolveTooltipLocation(preferred: TooltipLocation, anchor: {
|
|
614
|
+
top: number;
|
|
615
|
+
right: number;
|
|
616
|
+
bottom: number;
|
|
617
|
+
left: number;
|
|
618
|
+
}, tooltip: {
|
|
619
|
+
width: number;
|
|
620
|
+
height: number;
|
|
621
|
+
}, viewport: {
|
|
622
|
+
width: number;
|
|
623
|
+
height: number;
|
|
624
|
+
}, gap?: number): TooltipLocation;
|
|
625
|
+
|
|
626
|
+
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 FlowInputMode, 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 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, clampNumber, createAsyncLabelStore, createTheme, defaultTheme, enabledSelectableDescendants, exportTableToCsv, exportTableToExcel, exportTableToPdf, filterTree, flattenTree, flowClass, formatLocalDateTime, resolveColorValue, resolveFlowStyle, resolveTooltipLocation, responsiveCSS, sanitizeInputValue, selectedTreeModels, setLocalDayBoundary, tableToCsv, themeToCSS };
|
package/dist/index.d.ts
CHANGED
|
@@ -109,10 +109,12 @@ interface TypographyProps {
|
|
|
109
109
|
textTransform?: ResponsiveValue<"none" | "uppercase" | "lowercase" | "capitalize">;
|
|
110
110
|
lines?: ResponsiveValue<number>;
|
|
111
111
|
}
|
|
112
|
+
type FieldFocusStyle = "border" | "ring" | "none";
|
|
112
113
|
interface BaseUIProps extends SpacingProps, LayoutProps, PositionProps, FlexItemProps, BorderProps, VisualProps {
|
|
113
114
|
id?: string;
|
|
114
115
|
hidden?: boolean;
|
|
115
116
|
testId?: string;
|
|
117
|
+
focusStyle?: FieldFocusStyle;
|
|
116
118
|
className?: string;
|
|
117
119
|
style?: Readonly<FlowUIStyle>;
|
|
118
120
|
}
|
|
@@ -151,6 +153,7 @@ interface ThemeColorScheme {
|
|
|
151
153
|
overlay: string;
|
|
152
154
|
}
|
|
153
155
|
interface FlowUITheme {
|
|
156
|
+
focusStyle?: FieldFocusStyle;
|
|
154
157
|
palette: ColorPalette;
|
|
155
158
|
schemes: {
|
|
156
159
|
light: ThemeColorScheme;
|
|
@@ -266,6 +269,7 @@ interface TreeModel extends DropdownModel {
|
|
|
266
269
|
hasChildren?: boolean;
|
|
267
270
|
}
|
|
268
271
|
interface DropdownBehaviorProps extends BaseUIProps, DisableableProps {
|
|
272
|
+
clearable?: boolean;
|
|
269
273
|
options: DropdownModel[];
|
|
270
274
|
searchable?: boolean;
|
|
271
275
|
searchPlaceholder?: string;
|
|
@@ -285,6 +289,7 @@ interface MultiSelectProps extends DropdownBehaviorProps {
|
|
|
285
289
|
chipCloseIconColor?: ColorValue;
|
|
286
290
|
}
|
|
287
291
|
interface TreeMultiSelectProps extends BaseUIProps, DisableableProps {
|
|
292
|
+
clearable?: boolean;
|
|
288
293
|
nodes: TreeModel[];
|
|
289
294
|
value?: Array<string | number>;
|
|
290
295
|
expandedValues?: Array<string | number>;
|
|
@@ -298,6 +303,7 @@ interface TreeMultiSelectProps extends BaseUIProps, DisableableProps {
|
|
|
298
303
|
chipBackgroundColor?: ColorValue;
|
|
299
304
|
chipCloseIconColor?: ColorValue;
|
|
300
305
|
}
|
|
306
|
+
type TabSelectedStyle = "underline" | "fill";
|
|
301
307
|
interface TabItem {
|
|
302
308
|
id: string;
|
|
303
309
|
label: string;
|
|
@@ -319,6 +325,13 @@ interface TableColumn<T> {
|
|
|
319
325
|
align?: "left" | "center" | "right";
|
|
320
326
|
format?: (value: unknown, row: T) => string | number;
|
|
321
327
|
}
|
|
328
|
+
interface TableLoadMoreContext {
|
|
329
|
+
loadedCount: number;
|
|
330
|
+
totalCount?: number;
|
|
331
|
+
loading: boolean;
|
|
332
|
+
hasMore: boolean;
|
|
333
|
+
loadMore: () => void;
|
|
334
|
+
}
|
|
322
335
|
type DialogPosition = "center" | "left" | "right" | "top" | "bottom";
|
|
323
336
|
type TooltipLocation = "top" | "right" | "bottom" | "left";
|
|
324
337
|
interface CardProps extends BaseUIProps {
|
|
@@ -346,6 +359,7 @@ interface TreeProps extends BaseUIProps {
|
|
|
346
359
|
defaultExpanded?: boolean;
|
|
347
360
|
}
|
|
348
361
|
interface TreeDropdownProps extends BaseUIProps, DisableableProps {
|
|
362
|
+
clearable?: boolean;
|
|
349
363
|
nodes: TreeModel[];
|
|
350
364
|
value?: string | number;
|
|
351
365
|
placeholder?: string;
|
|
@@ -424,6 +438,7 @@ interface BreadcrumbItem {
|
|
|
424
438
|
other?: any;
|
|
425
439
|
}
|
|
426
440
|
interface BreadcrumbProps extends BaseUIProps {
|
|
441
|
+
separator?: string;
|
|
427
442
|
items: BreadcrumbItem[];
|
|
428
443
|
separatorIcon?: string;
|
|
429
444
|
}
|
|
@@ -503,6 +518,8 @@ type FlowInputMode = NonNullable<InputProps["inputMode"]>;
|
|
|
503
518
|
declare function sanitizeInputValue(value: string, mode?: FlowInputMode): string;
|
|
504
519
|
declare function clampNumber(value: number, min: number, max: number): number;
|
|
505
520
|
|
|
521
|
+
declare function tableToCsv<T>(data: readonly T[], columns: readonly TableColumn<T>[]): string;
|
|
522
|
+
declare function exportTableToCsv<T>(data: T[], columns: TableColumn<T>[], fileName?: string): void;
|
|
506
523
|
/** Downloads an Excel-compatible SpreadsheetML workbook without a runtime dependency. */
|
|
507
524
|
declare function exportTableToExcel<T>(data: T[], columns: TableColumn<T>[], fileName?: string): void;
|
|
508
525
|
/** Downloads a compact PDF containing the currently visible table data. */
|
|
@@ -593,4 +610,17 @@ declare class AsyncLabelStore {
|
|
|
593
610
|
}
|
|
594
611
|
declare function createAsyncLabelStore(config: AsyncLabelConfig): AsyncLabelStore;
|
|
595
612
|
|
|
596
|
-
|
|
613
|
+
declare function resolveTooltipLocation(preferred: TooltipLocation, anchor: {
|
|
614
|
+
top: number;
|
|
615
|
+
right: number;
|
|
616
|
+
bottom: number;
|
|
617
|
+
left: number;
|
|
618
|
+
}, tooltip: {
|
|
619
|
+
width: number;
|
|
620
|
+
height: number;
|
|
621
|
+
}, viewport: {
|
|
622
|
+
width: number;
|
|
623
|
+
height: number;
|
|
624
|
+
}, gap?: number): TooltipLocation;
|
|
625
|
+
|
|
626
|
+
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 FlowInputMode, 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 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, clampNumber, createAsyncLabelStore, createTheme, defaultTheme, enabledSelectableDescendants, exportTableToCsv, exportTableToExcel, exportTableToPdf, filterTree, flattenTree, flowClass, formatLocalDateTime, resolveColorValue, resolveFlowStyle, resolveTooltipLocation, responsiveCSS, sanitizeInputValue, selectedTreeModels, setLocalDayBoundary, tableToCsv, themeToCSS };
|
package/dist/index.js
CHANGED
|
@@ -453,6 +453,17 @@ function resolveFlowStyle(props, theme) {
|
|
|
453
453
|
style.WebkitBoxOrient = "vertical";
|
|
454
454
|
style.WebkitLineClamp = lines;
|
|
455
455
|
}
|
|
456
|
+
const focusStyle = props.focusStyle ?? theme.focusStyle;
|
|
457
|
+
if (focusStyle === "ring") {
|
|
458
|
+
style["--fui-field-focus-border"] = "var(--fui-color-borderStrong)";
|
|
459
|
+
style["--fui-field-focus-shadow"] = "0 0 0 2px color-mix(in srgb, var(--fui-color-focus) 22%, transparent)";
|
|
460
|
+
} else if (focusStyle === "none") {
|
|
461
|
+
style["--fui-field-focus-border"] = "var(--fui-color-border)";
|
|
462
|
+
style["--fui-field-focus-shadow"] = "none";
|
|
463
|
+
} else if (focusStyle === "border") {
|
|
464
|
+
style["--fui-field-focus-border"] = "var(--fui-color-borderStrong)";
|
|
465
|
+
style["--fui-field-focus-shadow"] = "none";
|
|
466
|
+
}
|
|
456
467
|
Object.assign(style, userStyle);
|
|
457
468
|
return { classNames, style };
|
|
458
469
|
}
|
|
@@ -505,10 +516,24 @@ function download(content, type, fileName) {
|
|
|
505
516
|
anchor.href = url;
|
|
506
517
|
anchor.download = fileName;
|
|
507
518
|
anchor.click();
|
|
508
|
-
URL.revokeObjectURL(url);
|
|
519
|
+
setTimeout(() => URL.revokeObjectURL(url), 1e3);
|
|
520
|
+
}
|
|
521
|
+
function tableToCsv(data, columns) {
|
|
522
|
+
const escape = (value) => '"' + value.replaceAll('"', '""') + '"';
|
|
523
|
+
return [
|
|
524
|
+
columns.map((column) => column.header),
|
|
525
|
+
...data.map((item) => columns.map((column) => cellText(item, column)))
|
|
526
|
+
].map((row) => row.map(escape).join(",")).join("\r\n");
|
|
527
|
+
}
|
|
528
|
+
function exportTableToCsv(data, columns, fileName = "table") {
|
|
529
|
+
download(
|
|
530
|
+
"\uFEFF" + tableToCsv(data, columns),
|
|
531
|
+
"text/csv;charset=utf-8",
|
|
532
|
+
`${fileName}.csv`
|
|
533
|
+
);
|
|
509
534
|
}
|
|
510
535
|
function xml(value) {
|
|
511
|
-
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """);
|
|
536
|
+
return value.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, "").replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """);
|
|
512
537
|
}
|
|
513
538
|
function exportTableToExcel(data, columns, fileName = "table") {
|
|
514
539
|
const row = (values) => `<Row>${values.map((value) => `<Cell><Data ss:Type="String">${xml(value)}</Data></Cell>`).join("")}</Row>`;
|
|
@@ -517,21 +542,24 @@ function exportTableToExcel(data, columns, fileName = "table") {
|
|
|
517
542
|
...data.map((item) => row(columns.map((column) => cellText(item, column))))
|
|
518
543
|
].join("");
|
|
519
544
|
const workbook = `<?xml version="1.0"?><Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"><Worksheet ss:Name="Data"><Table>${rows}</Table></Worksheet></Workbook>`;
|
|
520
|
-
download(workbook, "application/vnd.ms-excel", `${fileName}.
|
|
545
|
+
download(workbook, "application/vnd.ms-excel", `${fileName}.xml`);
|
|
521
546
|
}
|
|
522
547
|
function pdfEscape(value) {
|
|
523
548
|
return value.replaceAll("\\", "\\\\").replaceAll("(", "\\(").replaceAll(")", "\\)").replace(/[^\x20-\x7e]/g, "?");
|
|
524
549
|
}
|
|
525
550
|
function exportTableToPdf(data, columns, fileName = "table") {
|
|
526
|
-
const
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
551
|
+
const wrap = (line) => line.replace(/\r?\n/g, " ").match(/.{1,82}/gu) ?? [""];
|
|
552
|
+
const header = wrap(columns.map((column) => column.header).join(" | "));
|
|
553
|
+
const lines = data.flatMap(
|
|
554
|
+
(item) => wrap(columns.map((column) => cellText(item, column)).join(" | "))
|
|
555
|
+
);
|
|
556
|
+
const pageLength = Math.max(1, 48 - header.length);
|
|
532
557
|
const pages = Array.from(
|
|
533
|
-
{ length: Math.max(1, Math.ceil(lines.length /
|
|
534
|
-
(_, index) =>
|
|
558
|
+
{ length: Math.max(1, Math.ceil(lines.length / pageLength)) },
|
|
559
|
+
(_, index) => [
|
|
560
|
+
...header,
|
|
561
|
+
...lines.slice(index * pageLength, (index + 1) * pageLength)
|
|
562
|
+
]
|
|
535
563
|
);
|
|
536
564
|
const fontObject = 3 + pages.length * 2;
|
|
537
565
|
const pageObjects = pages.map((_, index) => 3 + index * 2);
|
|
@@ -546,7 +574,7 @@ function exportTableToPdf(data, columns, fileName = "table") {
|
|
|
546
574
|
"BT /F1 10 Tf 40 800 Td",
|
|
547
575
|
...page.flatMap((line, lineIndex) => [
|
|
548
576
|
lineIndex ? "0 -15 Td" : "",
|
|
549
|
-
`(${pdfEscape(line)
|
|
577
|
+
`(${pdfEscape(line)}) Tj`
|
|
550
578
|
]),
|
|
551
579
|
"ET"
|
|
552
580
|
].filter(Boolean).join("\n");
|
|
@@ -900,6 +928,24 @@ var AsyncLabelStore = class {
|
|
|
900
928
|
function createAsyncLabelStore(config) {
|
|
901
929
|
return new AsyncLabelStore(config);
|
|
902
930
|
}
|
|
931
|
+
|
|
932
|
+
// src/tooltip.ts
|
|
933
|
+
function resolveTooltipLocation(preferred, anchor, tooltip, viewport, gap = 6) {
|
|
934
|
+
const available = {
|
|
935
|
+
top: anchor.top,
|
|
936
|
+
right: viewport.width - anchor.right,
|
|
937
|
+
bottom: viewport.height - anchor.bottom,
|
|
938
|
+
left: anchor.left
|
|
939
|
+
};
|
|
940
|
+
const opposite = {
|
|
941
|
+
top: "bottom",
|
|
942
|
+
bottom: "top",
|
|
943
|
+
left: "right",
|
|
944
|
+
right: "left"
|
|
945
|
+
};
|
|
946
|
+
const required = preferred === "top" || preferred === "bottom" ? tooltip.height + gap : tooltip.width + gap;
|
|
947
|
+
return available[preferred] < required && available[opposite[preferred]] > available[preferred] ? opposite[preferred] : preferred;
|
|
948
|
+
}
|
|
903
949
|
export {
|
|
904
950
|
AsyncLabelStore,
|
|
905
951
|
clampNumber,
|
|
@@ -907,6 +953,7 @@ export {
|
|
|
907
953
|
createTheme,
|
|
908
954
|
defaultTheme,
|
|
909
955
|
enabledSelectableDescendants,
|
|
956
|
+
exportTableToCsv,
|
|
910
957
|
exportTableToExcel,
|
|
911
958
|
exportTableToPdf,
|
|
912
959
|
filterTree,
|
|
@@ -915,9 +962,11 @@ export {
|
|
|
915
962
|
formatLocalDateTime,
|
|
916
963
|
resolveColorValue,
|
|
917
964
|
resolveFlowStyle,
|
|
965
|
+
resolveTooltipLocation,
|
|
918
966
|
responsiveCSS,
|
|
919
967
|
sanitizeInputValue,
|
|
920
968
|
selectedTreeModels,
|
|
921
969
|
setLocalDayBoundary,
|
|
970
|
+
tableToCsv,
|
|
922
971
|
themeToCSS
|
|
923
972
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akin2unde/flowui-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Framework-independent contracts, themes and style resolution for FlowUI.",
|
|
5
5
|
"author": "Akintunde Morakinyo",
|
|
6
6
|
"repository": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
36
|
"scripts": {
|
|
37
|
-
"build": "tsup src/index.ts --format esm,cjs --
|
|
37
|
+
"build": "tsup src/index.ts --format esm,cjs --config ../../scripts/tsup.config.mjs --clean",
|
|
38
38
|
"typecheck": "tsc --noEmit",
|
|
39
39
|
"test": "vitest run",
|
|
40
40
|
"prepack": "node ../../scripts/prepack.mjs core"
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"tsup": "^8.5.0",
|
|
47
|
-
"typescript": "
|
|
48
|
-
"vitest": "^
|
|
47
|
+
"typescript": "~6.0.3",
|
|
48
|
+
"vitest": "^4.0.8"
|
|
49
49
|
},
|
|
50
50
|
"sideEffects": false
|
|
51
51
|
}
|