@akin2unde/flowui-core 0.1.3 → 0.1.4

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
@@ -22,12 +22,17 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  createTheme: () => createTheme,
24
24
  defaultTheme: () => defaultTheme,
25
+ enabledSelectableDescendants: () => enabledSelectableDescendants,
25
26
  exportTableToExcel: () => exportTableToExcel,
26
27
  exportTableToPdf: () => exportTableToPdf,
28
+ filterTree: () => filterTree,
29
+ flattenTree: () => flattenTree,
27
30
  flowClass: () => flowClass,
28
31
  formatLocalDateTime: () => formatLocalDateTime,
32
+ resolveColorValue: () => resolveColorValue,
29
33
  resolveFlowStyle: () => resolveFlowStyle,
30
34
  responsiveCSS: () => responsiveCSS,
35
+ selectedTreeModels: () => selectedTreeModels,
31
36
  setLocalDayBoundary: () => setLocalDayBoundary,
32
37
  themeToCSS: () => themeToCSS
33
38
  });
@@ -350,7 +355,7 @@ var dimension = (value) => ({
350
355
  max: "max-content"
351
356
  })[String(value)] ?? length(value);
352
357
  var spacing = (value, theme) => value in theme.spacing ? `var(--fui-spacing-${String(value)})` : length(value);
353
- var color = (value) => {
358
+ var resolveColorValue = (value) => {
354
359
  if ([
355
360
  "canvas",
356
361
  "surface",
@@ -374,6 +379,7 @@ var color = (value) => {
374
379
  }
375
380
  return value;
376
381
  };
382
+ var color = resolveColorValue;
377
383
  var justify = (value) => ({
378
384
  start: "flex-start",
379
385
  end: "flex-end",
@@ -600,16 +606,46 @@ ${xref}
600
606
  %%EOF`;
601
607
  download(pdf, "application/pdf", `${fileName}.pdf`);
602
608
  }
609
+
610
+ // src/selection.ts
611
+ function flattenTree(nodes) {
612
+ return nodes.flatMap((node) => [node, ...flattenTree(node.children ?? [])]);
613
+ }
614
+ function enabledSelectableDescendants(node) {
615
+ const children = node.children ?? [];
616
+ if (!children.length) {
617
+ return !node.disabled && node.selectable !== false ? [node] : [];
618
+ }
619
+ return children.flatMap(enabledSelectableDescendants);
620
+ }
621
+ function filterTree(nodes, query) {
622
+ const search = query.trim().toLowerCase();
623
+ if (!search) return nodes;
624
+ return nodes.flatMap((node) => {
625
+ const children = filterTree(node.children ?? [], query);
626
+ const matches = String(node.display).toLowerCase().includes(search);
627
+ return matches || children.length ? [{ ...node, children }] : [];
628
+ });
629
+ }
630
+ function selectedTreeModels(nodes, values) {
631
+ const selected = new Set(values);
632
+ return flattenTree(nodes).filter((node) => selected.has(node.value));
633
+ }
603
634
  // Annotate the CommonJS export names for ESM import in node:
604
635
  0 && (module.exports = {
605
636
  createTheme,
606
637
  defaultTheme,
638
+ enabledSelectableDescendants,
607
639
  exportTableToExcel,
608
640
  exportTableToPdf,
641
+ filterTree,
642
+ flattenTree,
609
643
  flowClass,
610
644
  formatLocalDateTime,
645
+ resolveColorValue,
611
646
  resolveFlowStyle,
612
647
  responsiveCSS,
648
+ selectedTreeModels,
613
649
  setLocalDayBoundary,
614
650
  themeToCSS
615
651
  });
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
 
@@ -252,9 +253,46 @@ interface DropdownModel {
252
253
  display: string | number;
253
254
  value: string | number;
254
255
  other: any;
256
+ disabled?: boolean;
257
+ group?: string | number;
255
258
  }
256
259
  interface TreeModel extends DropdownModel {
257
260
  children?: TreeModel[];
261
+ selectable?: boolean;
262
+ hasChildren?: boolean;
263
+ }
264
+ interface DropdownBehaviorProps extends BaseUIProps, DisableableProps {
265
+ options: DropdownModel[];
266
+ searchable?: boolean;
267
+ searchPlaceholder?: string;
268
+ emptyText?: string;
269
+ loading?: boolean;
270
+ hasMore?: boolean;
271
+ loadMoreText?: string;
272
+ grouped?: boolean;
273
+ }
274
+ interface MultiSelectProps extends DropdownBehaviorProps {
275
+ value?: Array<string | number>;
276
+ placeholder?: string;
277
+ maxVisibleChips?: number;
278
+ showCheckboxes?: boolean;
279
+ chipTextColor?: ColorValue;
280
+ chipBackgroundColor?: ColorValue;
281
+ chipCloseIconColor?: ColorValue;
282
+ }
283
+ interface TreeMultiSelectProps extends BaseUIProps, DisableableProps {
284
+ nodes: TreeModel[];
285
+ value?: Array<string | number>;
286
+ expandedValues?: Array<string | number>;
287
+ searchable?: boolean;
288
+ searchPlaceholder?: string;
289
+ placeholder?: string;
290
+ emptyText?: string;
291
+ cascadeSelection?: boolean;
292
+ maxVisibleChips?: number;
293
+ chipTextColor?: ColorValue;
294
+ chipBackgroundColor?: ColorValue;
295
+ chipCloseIconColor?: ColorValue;
258
296
  }
259
297
  interface TabItem {
260
298
  id: string;
@@ -398,4 +436,10 @@ declare function exportTableToExcel<T>(data: T[], columns: TableColumn<T>[], fil
398
436
  /** Downloads a compact PDF containing the currently visible table data. */
399
437
  declare function exportTableToPdf<T>(data: T[], columns: TableColumn<T>[], fileName?: string): void;
400
438
 
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 };
439
+ type SelectionValue = string | number;
440
+ declare function flattenTree(nodes: TreeModel[]): TreeModel[];
441
+ declare function enabledSelectableDescendants(node: TreeModel): TreeModel[];
442
+ declare function filterTree(nodes: TreeModel[], query: string): TreeModel[];
443
+ declare function selectedTreeModels(nodes: TreeModel[], values: SelectionValue[]): TreeModel[];
444
+
445
+ 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 DropdownBehaviorProps, 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 MultiSelectProps, 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 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 TreeModel, type TreeMultiSelectProps, type TreeProps, type TypographyProps, type VStackProps, type VisualProps, createTheme, defaultTheme, enabledSelectableDescendants, exportTableToExcel, exportTableToPdf, filterTree, flattenTree, flowClass, formatLocalDateTime, resolveColorValue, resolveFlowStyle, responsiveCSS, 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
 
@@ -252,9 +253,46 @@ interface DropdownModel {
252
253
  display: string | number;
253
254
  value: string | number;
254
255
  other: any;
256
+ disabled?: boolean;
257
+ group?: string | number;
255
258
  }
256
259
  interface TreeModel extends DropdownModel {
257
260
  children?: TreeModel[];
261
+ selectable?: boolean;
262
+ hasChildren?: boolean;
263
+ }
264
+ interface DropdownBehaviorProps extends BaseUIProps, DisableableProps {
265
+ options: DropdownModel[];
266
+ searchable?: boolean;
267
+ searchPlaceholder?: string;
268
+ emptyText?: string;
269
+ loading?: boolean;
270
+ hasMore?: boolean;
271
+ loadMoreText?: string;
272
+ grouped?: boolean;
273
+ }
274
+ interface MultiSelectProps extends DropdownBehaviorProps {
275
+ value?: Array<string | number>;
276
+ placeholder?: string;
277
+ maxVisibleChips?: number;
278
+ showCheckboxes?: boolean;
279
+ chipTextColor?: ColorValue;
280
+ chipBackgroundColor?: ColorValue;
281
+ chipCloseIconColor?: ColorValue;
282
+ }
283
+ interface TreeMultiSelectProps extends BaseUIProps, DisableableProps {
284
+ nodes: TreeModel[];
285
+ value?: Array<string | number>;
286
+ expandedValues?: Array<string | number>;
287
+ searchable?: boolean;
288
+ searchPlaceholder?: string;
289
+ placeholder?: string;
290
+ emptyText?: string;
291
+ cascadeSelection?: boolean;
292
+ maxVisibleChips?: number;
293
+ chipTextColor?: ColorValue;
294
+ chipBackgroundColor?: ColorValue;
295
+ chipCloseIconColor?: ColorValue;
258
296
  }
259
297
  interface TabItem {
260
298
  id: string;
@@ -398,4 +436,10 @@ declare function exportTableToExcel<T>(data: T[], columns: TableColumn<T>[], fil
398
436
  /** Downloads a compact PDF containing the currently visible table data. */
399
437
  declare function exportTableToPdf<T>(data: T[], columns: TableColumn<T>[], fileName?: string): void;
400
438
 
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 };
439
+ type SelectionValue = string | number;
440
+ declare function flattenTree(nodes: TreeModel[]): TreeModel[];
441
+ declare function enabledSelectableDescendants(node: TreeModel): TreeModel[];
442
+ declare function filterTree(nodes: TreeModel[], query: string): TreeModel[];
443
+ declare function selectedTreeModels(nodes: TreeModel[], values: SelectionValue[]): TreeModel[];
444
+
445
+ 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 DropdownBehaviorProps, 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 MultiSelectProps, 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 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 TreeModel, type TreeMultiSelectProps, type TreeProps, type TypographyProps, type VStackProps, type VisualProps, createTheme, defaultTheme, enabledSelectableDescendants, exportTableToExcel, exportTableToPdf, filterTree, flattenTree, flowClass, formatLocalDateTime, resolveColorValue, resolveFlowStyle, responsiveCSS, 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",
@@ -565,15 +566,45 @@ ${xref}
565
566
  %%EOF`;
566
567
  download(pdf, "application/pdf", `${fileName}.pdf`);
567
568
  }
569
+
570
+ // src/selection.ts
571
+ function flattenTree(nodes) {
572
+ return nodes.flatMap((node) => [node, ...flattenTree(node.children ?? [])]);
573
+ }
574
+ function enabledSelectableDescendants(node) {
575
+ const children = node.children ?? [];
576
+ if (!children.length) {
577
+ return !node.disabled && node.selectable !== false ? [node] : [];
578
+ }
579
+ return children.flatMap(enabledSelectableDescendants);
580
+ }
581
+ function filterTree(nodes, query) {
582
+ const search = query.trim().toLowerCase();
583
+ if (!search) return nodes;
584
+ return nodes.flatMap((node) => {
585
+ const children = filterTree(node.children ?? [], query);
586
+ const matches = String(node.display).toLowerCase().includes(search);
587
+ return matches || children.length ? [{ ...node, children }] : [];
588
+ });
589
+ }
590
+ function selectedTreeModels(nodes, values) {
591
+ const selected = new Set(values);
592
+ return flattenTree(nodes).filter((node) => selected.has(node.value));
593
+ }
568
594
  export {
569
595
  createTheme,
570
596
  defaultTheme,
597
+ enabledSelectableDescendants,
571
598
  exportTableToExcel,
572
599
  exportTableToPdf,
600
+ filterTree,
601
+ flattenTree,
573
602
  flowClass,
574
603
  formatLocalDateTime,
604
+ resolveColorValue,
575
605
  resolveFlowStyle,
576
606
  responsiveCSS,
607
+ selectedTreeModels,
577
608
  setLocalDayBoundary,
578
609
  themeToCSS
579
610
  };
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.4",
4
4
  "description": "Framework-independent contracts, themes and style resolution for FlowUI.",
5
5
  "author": "Akintunde Morakinyo",
6
6
  "repository": {