@akin2unde/flowui-core 0.1.3 → 0.1.5

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 CHANGED
@@ -20,14 +20,21 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ clampNumber: () => clampNumber,
23
24
  createTheme: () => createTheme,
24
25
  defaultTheme: () => defaultTheme,
26
+ enabledSelectableDescendants: () => enabledSelectableDescendants,
25
27
  exportTableToExcel: () => exportTableToExcel,
26
28
  exportTableToPdf: () => exportTableToPdf,
29
+ filterTree: () => filterTree,
30
+ flattenTree: () => flattenTree,
27
31
  flowClass: () => flowClass,
28
32
  formatLocalDateTime: () => formatLocalDateTime,
33
+ resolveColorValue: () => resolveColorValue,
29
34
  resolveFlowStyle: () => resolveFlowStyle,
30
35
  responsiveCSS: () => responsiveCSS,
36
+ sanitizeInputValue: () => sanitizeInputValue,
37
+ selectedTreeModels: () => selectedTreeModels,
31
38
  setLocalDayBoundary: () => setLocalDayBoundary,
32
39
  themeToCSS: () => themeToCSS
33
40
  });
@@ -350,7 +357,7 @@ var dimension = (value) => ({
350
357
  max: "max-content"
351
358
  })[String(value)] ?? length(value);
352
359
  var spacing = (value, theme) => value in theme.spacing ? `var(--fui-spacing-${String(value)})` : length(value);
353
- var color = (value) => {
360
+ var resolveColorValue = (value) => {
354
361
  if ([
355
362
  "canvas",
356
363
  "surface",
@@ -374,6 +381,7 @@ var color = (value) => {
374
381
  }
375
382
  return value;
376
383
  };
384
+ var color = resolveColorValue;
377
385
  var justify = (value) => ({
378
386
  start: "flex-start",
379
387
  end: "flex-end",
@@ -513,6 +521,21 @@ function setLocalDayBoundary(value, boundary) {
513
521
  return `${datePart}T${boundary === "start" ? "00:00" : "23:59"}`;
514
522
  }
515
523
 
524
+ // src/input.ts
525
+ function sanitizeInputValue(value, mode = "text") {
526
+ if (mode === "integer") return value.replace(/[^0-9-]/g, "");
527
+ if (mode === "decimal" || mode === "money") {
528
+ const cleaned = value.replace(/[^0-9.-]/g, "");
529
+ const [whole, ...decimals] = cleaned.split(".");
530
+ return decimals.length ? `${whole}.${decimals.join("")}` : whole;
531
+ }
532
+ if (mode === "alphabet") return value.replace(/[^a-zA-Z\s'-]/g, "");
533
+ return value;
534
+ }
535
+ function clampNumber(value, min, max) {
536
+ return Math.min(max, Math.max(min, value));
537
+ }
538
+
516
539
  // src/table-export.ts
517
540
  function cellText(row, column) {
518
541
  const value = row[column.field];
@@ -600,16 +623,48 @@ ${xref}
600
623
  %%EOF`;
601
624
  download(pdf, "application/pdf", `${fileName}.pdf`);
602
625
  }
626
+
627
+ // src/selection.ts
628
+ function flattenTree(nodes) {
629
+ return nodes.flatMap((node) => [node, ...flattenTree(node.children ?? [])]);
630
+ }
631
+ function enabledSelectableDescendants(node) {
632
+ const children = node.children ?? [];
633
+ if (!children.length) {
634
+ return !node.disabled && node.selectable !== false ? [node] : [];
635
+ }
636
+ return children.flatMap(enabledSelectableDescendants);
637
+ }
638
+ function filterTree(nodes, query) {
639
+ const search = query.trim().toLowerCase();
640
+ if (!search) return nodes;
641
+ return nodes.flatMap((node) => {
642
+ const children = filterTree(node.children ?? [], query);
643
+ const matches = String(node.display).toLowerCase().includes(search);
644
+ return matches || children.length ? [{ ...node, children }] : [];
645
+ });
646
+ }
647
+ function selectedTreeModels(nodes, values) {
648
+ const selected = new Set(values);
649
+ return flattenTree(nodes).filter((node) => selected.has(node.value));
650
+ }
603
651
  // Annotate the CommonJS export names for ESM import in node:
604
652
  0 && (module.exports = {
653
+ clampNumber,
605
654
  createTheme,
606
655
  defaultTheme,
656
+ enabledSelectableDescendants,
607
657
  exportTableToExcel,
608
658
  exportTableToPdf,
659
+ filterTree,
660
+ flattenTree,
609
661
  flowClass,
610
662
  formatLocalDateTime,
663
+ resolveColorValue,
611
664
  resolveFlowStyle,
612
665
  responsiveCSS,
666
+ sanitizeInputValue,
667
+ selectedTreeModels,
613
668
  setLocalDayBoundary,
614
669
  themeToCSS
615
670
  });
package/dist/index.d.cts CHANGED
@@ -173,6 +173,7 @@ interface StyleResolution {
173
173
  classNames: string[];
174
174
  style: ResolvedStyle;
175
175
  }
176
+ declare const resolveColorValue: (value: ColorValue) => string;
176
177
  declare function resolveFlowStyle(props: Record<string, unknown>, theme: FlowUITheme): StyleResolution;
177
178
  declare function flowClass(base: string, props: Pick<BaseUIProps, "className">, resolution: StyleResolution, ...extra: Array<string | false | undefined>): string;
178
179
 
@@ -221,6 +222,10 @@ interface InputProps extends BaseUIProps, TypographyProps, DisableableProps, Rea
221
222
  name?: string;
222
223
  value?: string | number;
223
224
  placeholder?: string;
225
+ /** Controls which characters FlowUI accepts without changing the visual input type. */
226
+ inputMode?: "text" | "integer" | "decimal" | "money" | "alphabet";
227
+ /** Currency symbol shown when inputMode is money. */
228
+ currencySymbol?: string;
224
229
  type?: "text" | "email" | "password" | "number" | "search" | "tel" | "url" | "date" | "time";
225
230
  }
226
231
  interface DividerProps extends BaseUIProps {
@@ -252,9 +257,46 @@ interface DropdownModel {
252
257
  display: string | number;
253
258
  value: string | number;
254
259
  other: any;
260
+ disabled?: boolean;
261
+ group?: string | number;
255
262
  }
256
263
  interface TreeModel extends DropdownModel {
257
264
  children?: TreeModel[];
265
+ selectable?: boolean;
266
+ hasChildren?: boolean;
267
+ }
268
+ interface DropdownBehaviorProps extends BaseUIProps, DisableableProps {
269
+ options: DropdownModel[];
270
+ searchable?: boolean;
271
+ searchPlaceholder?: string;
272
+ emptyText?: string;
273
+ loading?: boolean;
274
+ hasMore?: boolean;
275
+ loadMoreText?: string;
276
+ grouped?: boolean;
277
+ }
278
+ interface MultiSelectProps extends DropdownBehaviorProps {
279
+ value?: Array<string | number>;
280
+ placeholder?: string;
281
+ maxVisibleChips?: number;
282
+ showCheckboxes?: boolean;
283
+ chipTextColor?: ColorValue;
284
+ chipBackgroundColor?: ColorValue;
285
+ chipCloseIconColor?: ColorValue;
286
+ }
287
+ interface TreeMultiSelectProps extends BaseUIProps, DisableableProps {
288
+ nodes: TreeModel[];
289
+ value?: Array<string | number>;
290
+ expandedValues?: Array<string | number>;
291
+ searchable?: boolean;
292
+ searchPlaceholder?: string;
293
+ placeholder?: string;
294
+ emptyText?: string;
295
+ cascadeSelection?: boolean;
296
+ maxVisibleChips?: number;
297
+ chipTextColor?: ColorValue;
298
+ chipBackgroundColor?: ColorValue;
299
+ chipCloseIconColor?: ColorValue;
258
300
  }
259
301
  interface TabItem {
260
302
  id: string;
@@ -303,6 +345,14 @@ interface TreeProps extends BaseUIProps {
303
345
  value?: string | number;
304
346
  defaultExpanded?: boolean;
305
347
  }
348
+ interface TreeDropdownProps extends BaseUIProps, DisableableProps {
349
+ nodes: TreeModel[];
350
+ value?: string | number;
351
+ placeholder?: string;
352
+ searchable?: boolean;
353
+ searchPlaceholder?: string;
354
+ emptyText?: string;
355
+ }
306
356
  interface TooltipProps extends BaseUIProps {
307
357
  text: string;
308
358
  location?: TooltipLocation;
@@ -388,14 +438,80 @@ interface NotificationProps extends BaseUIProps {
388
438
  duration?: number;
389
439
  dismissible?: boolean;
390
440
  }
441
+ interface KnobProps extends BaseUIProps, DisableableProps {
442
+ value?: number;
443
+ min?: number;
444
+ max?: number;
445
+ step?: number;
446
+ size?: number;
447
+ strokeWidth?: number;
448
+ showValue?: boolean;
449
+ valueSuffix?: string;
450
+ color?: ColorValue;
451
+ trackColor?: ColorValue;
452
+ }
453
+ interface OTPInputProps extends BaseUIProps, DisableableProps {
454
+ value?: string;
455
+ length?: number;
456
+ numericOnly?: boolean;
457
+ masked?: boolean;
458
+ name?: string;
459
+ }
460
+ interface PhoneCountry {
461
+ code: string;
462
+ name: string;
463
+ dialCode: string;
464
+ flag?: string;
465
+ }
466
+ interface PhoneNumberValue {
467
+ countryCode: string;
468
+ dialCode: string;
469
+ number: string;
470
+ }
471
+ interface PhoneInputProps extends BaseUIProps, DisableableProps {
472
+ value?: PhoneNumberValue;
473
+ countries: PhoneCountry[];
474
+ searchable?: boolean;
475
+ placeholder?: string;
476
+ name?: string;
477
+ }
478
+ type ChartType = "bar" | "line" | "pie" | "doughnut";
479
+ interface ChartSeries {
480
+ name: string;
481
+ data: number[];
482
+ color?: ColorValue;
483
+ }
484
+ interface ChartData {
485
+ labels: string[];
486
+ series: ChartSeries[];
487
+ }
488
+ interface ChartProps extends BaseUIProps {
489
+ type?: ChartType;
490
+ data: ChartData;
491
+ height?: number;
492
+ showLegend?: boolean;
493
+ showValues?: boolean;
494
+ animated?: boolean;
495
+ }
391
496
 
392
497
  /** Formats a Date for native date/time controls without converting it to UTC. */
393
498
  declare function formatLocalDateTime(value: Date, mode?: DateTimeMode): string;
394
499
  declare function setLocalDayBoundary(value: string | undefined, boundary: "start" | "end"): string;
395
500
 
501
+ type FlowInputMode = NonNullable<InputProps["inputMode"]>;
502
+ /** Keeps only characters allowed by the selected FlowUI input mode. */
503
+ declare function sanitizeInputValue(value: string, mode?: FlowInputMode): string;
504
+ declare function clampNumber(value: number, min: number, max: number): number;
505
+
396
506
  /** Downloads an Excel-compatible SpreadsheetML workbook without a runtime dependency. */
397
507
  declare function exportTableToExcel<T>(data: T[], columns: TableColumn<T>[], fileName?: string): void;
398
508
  /** Downloads a compact PDF containing the currently visible table data. */
399
509
  declare function exportTableToPdf<T>(data: T[], columns: TableColumn<T>[], fileName?: string): void;
400
510
 
401
- export { type AlignValue, 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 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 DropdownModel, type FileUploadProps, type FlexContainerProps, type FlexDirection, type FlexItemProps, type FlexWrap, type FlowUIStyle, type FlowUITheme, type FocusableProps, type HStackProps, type IconProps, type ImageProps, type InputProps, type JustifyValue, type LabelProps, type LayoutProps, type ListboxProps, type LoadingProps, type MenuItem, type NotificationHorizontal, type NotificationProps, type NotificationType, type NotificationVertical, type Orientation, type PaletteColor, type PasswordInputProps, 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 SliderProps, type SortDirection, type SortState, type SpacingProps, type SpacingToken, type SpacingValue, type StackProps, type StyleResolution, type SwitchProps, type TabItem, type TableColumn, type ThemeColorScheme, type ThemeMode, type TimelineItem, type TimelineProps, type TooltipLocation, type TooltipProps, type TreeModel, type TreeProps, type TypographyProps, type VStackProps, type VisualProps, createTheme, defaultTheme, exportTableToExcel, exportTableToPdf, flowClass, formatLocalDateTime, resolveFlowStyle, responsiveCSS, setLocalDayBoundary, themeToCSS };
511
+ type SelectionValue = string | number;
512
+ declare function flattenTree(nodes: TreeModel[]): TreeModel[];
513
+ declare function enabledSelectableDescendants(node: TreeModel): TreeModel[];
514
+ declare function filterTree(nodes: TreeModel[], query: string): TreeModel[];
515
+ declare function selectedTreeModels(nodes: TreeModel[], values: SelectionValue[]): TreeModel[];
516
+
517
+ export { type AlignValue, 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 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 LabelProps, 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 TableColumn, 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, createTheme, defaultTheme, enabledSelectableDescendants, exportTableToExcel, exportTableToPdf, filterTree, flattenTree, flowClass, formatLocalDateTime, resolveColorValue, resolveFlowStyle, responsiveCSS, sanitizeInputValue, selectedTreeModels, setLocalDayBoundary, themeToCSS };
package/dist/index.d.ts CHANGED
@@ -173,6 +173,7 @@ interface StyleResolution {
173
173
  classNames: string[];
174
174
  style: ResolvedStyle;
175
175
  }
176
+ declare const resolveColorValue: (value: ColorValue) => string;
176
177
  declare function resolveFlowStyle(props: Record<string, unknown>, theme: FlowUITheme): StyleResolution;
177
178
  declare function flowClass(base: string, props: Pick<BaseUIProps, "className">, resolution: StyleResolution, ...extra: Array<string | false | undefined>): string;
178
179
 
@@ -221,6 +222,10 @@ interface InputProps extends BaseUIProps, TypographyProps, DisableableProps, Rea
221
222
  name?: string;
222
223
  value?: string | number;
223
224
  placeholder?: string;
225
+ /** Controls which characters FlowUI accepts without changing the visual input type. */
226
+ inputMode?: "text" | "integer" | "decimal" | "money" | "alphabet";
227
+ /** Currency symbol shown when inputMode is money. */
228
+ currencySymbol?: string;
224
229
  type?: "text" | "email" | "password" | "number" | "search" | "tel" | "url" | "date" | "time";
225
230
  }
226
231
  interface DividerProps extends BaseUIProps {
@@ -252,9 +257,46 @@ interface DropdownModel {
252
257
  display: string | number;
253
258
  value: string | number;
254
259
  other: any;
260
+ disabled?: boolean;
261
+ group?: string | number;
255
262
  }
256
263
  interface TreeModel extends DropdownModel {
257
264
  children?: TreeModel[];
265
+ selectable?: boolean;
266
+ hasChildren?: boolean;
267
+ }
268
+ interface DropdownBehaviorProps extends BaseUIProps, DisableableProps {
269
+ options: DropdownModel[];
270
+ searchable?: boolean;
271
+ searchPlaceholder?: string;
272
+ emptyText?: string;
273
+ loading?: boolean;
274
+ hasMore?: boolean;
275
+ loadMoreText?: string;
276
+ grouped?: boolean;
277
+ }
278
+ interface MultiSelectProps extends DropdownBehaviorProps {
279
+ value?: Array<string | number>;
280
+ placeholder?: string;
281
+ maxVisibleChips?: number;
282
+ showCheckboxes?: boolean;
283
+ chipTextColor?: ColorValue;
284
+ chipBackgroundColor?: ColorValue;
285
+ chipCloseIconColor?: ColorValue;
286
+ }
287
+ interface TreeMultiSelectProps extends BaseUIProps, DisableableProps {
288
+ nodes: TreeModel[];
289
+ value?: Array<string | number>;
290
+ expandedValues?: Array<string | number>;
291
+ searchable?: boolean;
292
+ searchPlaceholder?: string;
293
+ placeholder?: string;
294
+ emptyText?: string;
295
+ cascadeSelection?: boolean;
296
+ maxVisibleChips?: number;
297
+ chipTextColor?: ColorValue;
298
+ chipBackgroundColor?: ColorValue;
299
+ chipCloseIconColor?: ColorValue;
258
300
  }
259
301
  interface TabItem {
260
302
  id: string;
@@ -303,6 +345,14 @@ interface TreeProps extends BaseUIProps {
303
345
  value?: string | number;
304
346
  defaultExpanded?: boolean;
305
347
  }
348
+ interface TreeDropdownProps extends BaseUIProps, DisableableProps {
349
+ nodes: TreeModel[];
350
+ value?: string | number;
351
+ placeholder?: string;
352
+ searchable?: boolean;
353
+ searchPlaceholder?: string;
354
+ emptyText?: string;
355
+ }
306
356
  interface TooltipProps extends BaseUIProps {
307
357
  text: string;
308
358
  location?: TooltipLocation;
@@ -388,14 +438,80 @@ interface NotificationProps extends BaseUIProps {
388
438
  duration?: number;
389
439
  dismissible?: boolean;
390
440
  }
441
+ interface KnobProps extends BaseUIProps, DisableableProps {
442
+ value?: number;
443
+ min?: number;
444
+ max?: number;
445
+ step?: number;
446
+ size?: number;
447
+ strokeWidth?: number;
448
+ showValue?: boolean;
449
+ valueSuffix?: string;
450
+ color?: ColorValue;
451
+ trackColor?: ColorValue;
452
+ }
453
+ interface OTPInputProps extends BaseUIProps, DisableableProps {
454
+ value?: string;
455
+ length?: number;
456
+ numericOnly?: boolean;
457
+ masked?: boolean;
458
+ name?: string;
459
+ }
460
+ interface PhoneCountry {
461
+ code: string;
462
+ name: string;
463
+ dialCode: string;
464
+ flag?: string;
465
+ }
466
+ interface PhoneNumberValue {
467
+ countryCode: string;
468
+ dialCode: string;
469
+ number: string;
470
+ }
471
+ interface PhoneInputProps extends BaseUIProps, DisableableProps {
472
+ value?: PhoneNumberValue;
473
+ countries: PhoneCountry[];
474
+ searchable?: boolean;
475
+ placeholder?: string;
476
+ name?: string;
477
+ }
478
+ type ChartType = "bar" | "line" | "pie" | "doughnut";
479
+ interface ChartSeries {
480
+ name: string;
481
+ data: number[];
482
+ color?: ColorValue;
483
+ }
484
+ interface ChartData {
485
+ labels: string[];
486
+ series: ChartSeries[];
487
+ }
488
+ interface ChartProps extends BaseUIProps {
489
+ type?: ChartType;
490
+ data: ChartData;
491
+ height?: number;
492
+ showLegend?: boolean;
493
+ showValues?: boolean;
494
+ animated?: boolean;
495
+ }
391
496
 
392
497
  /** Formats a Date for native date/time controls without converting it to UTC. */
393
498
  declare function formatLocalDateTime(value: Date, mode?: DateTimeMode): string;
394
499
  declare function setLocalDayBoundary(value: string | undefined, boundary: "start" | "end"): string;
395
500
 
501
+ type FlowInputMode = NonNullable<InputProps["inputMode"]>;
502
+ /** Keeps only characters allowed by the selected FlowUI input mode. */
503
+ declare function sanitizeInputValue(value: string, mode?: FlowInputMode): string;
504
+ declare function clampNumber(value: number, min: number, max: number): number;
505
+
396
506
  /** Downloads an Excel-compatible SpreadsheetML workbook without a runtime dependency. */
397
507
  declare function exportTableToExcel<T>(data: T[], columns: TableColumn<T>[], fileName?: string): void;
398
508
  /** Downloads a compact PDF containing the currently visible table data. */
399
509
  declare function exportTableToPdf<T>(data: T[], columns: TableColumn<T>[], fileName?: string): void;
400
510
 
401
- export { type AlignValue, 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 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 DropdownModel, type FileUploadProps, type FlexContainerProps, type FlexDirection, type FlexItemProps, type FlexWrap, type FlowUIStyle, type FlowUITheme, type FocusableProps, type HStackProps, type IconProps, type ImageProps, type InputProps, type JustifyValue, type LabelProps, type LayoutProps, type ListboxProps, type LoadingProps, type MenuItem, type NotificationHorizontal, type NotificationProps, type NotificationType, type NotificationVertical, type Orientation, type PaletteColor, type PasswordInputProps, 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 SliderProps, type SortDirection, type SortState, type SpacingProps, type SpacingToken, type SpacingValue, type StackProps, type StyleResolution, type SwitchProps, type TabItem, type TableColumn, type ThemeColorScheme, type ThemeMode, type TimelineItem, type TimelineProps, type TooltipLocation, type TooltipProps, type TreeModel, type TreeProps, type TypographyProps, type VStackProps, type VisualProps, createTheme, defaultTheme, exportTableToExcel, exportTableToPdf, flowClass, formatLocalDateTime, resolveFlowStyle, responsiveCSS, setLocalDayBoundary, themeToCSS };
511
+ type SelectionValue = string | number;
512
+ declare function flattenTree(nodes: TreeModel[]): TreeModel[];
513
+ declare function enabledSelectableDescendants(node: TreeModel): TreeModel[];
514
+ declare function filterTree(nodes: TreeModel[], query: string): TreeModel[];
515
+ declare function selectedTreeModels(nodes: TreeModel[], values: SelectionValue[]): TreeModel[];
516
+
517
+ export { type AlignValue, 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 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 LabelProps, 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 TableColumn, 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, createTheme, defaultTheme, enabledSelectableDescendants, exportTableToExcel, exportTableToPdf, filterTree, flattenTree, flowClass, formatLocalDateTime, resolveColorValue, resolveFlowStyle, responsiveCSS, sanitizeInputValue, selectedTreeModels, setLocalDayBoundary, themeToCSS };
package/dist/index.js CHANGED
@@ -315,7 +315,7 @@ var dimension = (value) => ({
315
315
  max: "max-content"
316
316
  })[String(value)] ?? length(value);
317
317
  var spacing = (value, theme) => value in theme.spacing ? `var(--fui-spacing-${String(value)})` : length(value);
318
- var color = (value) => {
318
+ var resolveColorValue = (value) => {
319
319
  if ([
320
320
  "canvas",
321
321
  "surface",
@@ -339,6 +339,7 @@ var color = (value) => {
339
339
  }
340
340
  return value;
341
341
  };
342
+ var color = resolveColorValue;
342
343
  var justify = (value) => ({
343
344
  start: "flex-start",
344
345
  end: "flex-end",
@@ -478,6 +479,21 @@ function setLocalDayBoundary(value, boundary) {
478
479
  return `${datePart}T${boundary === "start" ? "00:00" : "23:59"}`;
479
480
  }
480
481
 
482
+ // src/input.ts
483
+ function sanitizeInputValue(value, mode = "text") {
484
+ if (mode === "integer") return value.replace(/[^0-9-]/g, "");
485
+ if (mode === "decimal" || mode === "money") {
486
+ const cleaned = value.replace(/[^0-9.-]/g, "");
487
+ const [whole, ...decimals] = cleaned.split(".");
488
+ return decimals.length ? `${whole}.${decimals.join("")}` : whole;
489
+ }
490
+ if (mode === "alphabet") return value.replace(/[^a-zA-Z\s'-]/g, "");
491
+ return value;
492
+ }
493
+ function clampNumber(value, min, max) {
494
+ return Math.min(max, Math.max(min, value));
495
+ }
496
+
481
497
  // src/table-export.ts
482
498
  function cellText(row, column) {
483
499
  const value = row[column.field];
@@ -565,15 +581,47 @@ ${xref}
565
581
  %%EOF`;
566
582
  download(pdf, "application/pdf", `${fileName}.pdf`);
567
583
  }
584
+
585
+ // src/selection.ts
586
+ function flattenTree(nodes) {
587
+ return nodes.flatMap((node) => [node, ...flattenTree(node.children ?? [])]);
588
+ }
589
+ function enabledSelectableDescendants(node) {
590
+ const children = node.children ?? [];
591
+ if (!children.length) {
592
+ return !node.disabled && node.selectable !== false ? [node] : [];
593
+ }
594
+ return children.flatMap(enabledSelectableDescendants);
595
+ }
596
+ function filterTree(nodes, query) {
597
+ const search = query.trim().toLowerCase();
598
+ if (!search) return nodes;
599
+ return nodes.flatMap((node) => {
600
+ const children = filterTree(node.children ?? [], query);
601
+ const matches = String(node.display).toLowerCase().includes(search);
602
+ return matches || children.length ? [{ ...node, children }] : [];
603
+ });
604
+ }
605
+ function selectedTreeModels(nodes, values) {
606
+ const selected = new Set(values);
607
+ return flattenTree(nodes).filter((node) => selected.has(node.value));
608
+ }
568
609
  export {
610
+ clampNumber,
569
611
  createTheme,
570
612
  defaultTheme,
613
+ enabledSelectableDescendants,
571
614
  exportTableToExcel,
572
615
  exportTableToPdf,
616
+ filterTree,
617
+ flattenTree,
573
618
  flowClass,
574
619
  formatLocalDateTime,
620
+ resolveColorValue,
575
621
  resolveFlowStyle,
576
622
  responsiveCSS,
623
+ sanitizeInputValue,
624
+ selectedTreeModels,
577
625
  setLocalDayBoundary,
578
626
  themeToCSS
579
627
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akin2unde/flowui-core",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Framework-independent contracts, themes and style resolution for FlowUI.",
5
5
  "author": "Akintunde Morakinyo",
6
6
  "repository": {