laif-ds 0.2.42 → 0.2.44

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.d.ts CHANGED
@@ -42,6 +42,7 @@ import * as RechartsPrimitive from 'recharts';
42
42
  import { RefAttributes } from 'react';
43
43
  import { RefObject } from 'react';
44
44
  import * as ResizablePrimitive from 'react-resizable-panels';
45
+ import { Row } from '@tanstack/react-table';
45
46
  import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
46
47
  import * as SelectPrimitive from '@radix-ui/react-select';
47
48
  import * as SeparatorPrimitive from '@radix-ui/react-separator';
@@ -356,6 +357,23 @@ export declare const badgeVariants: (props?: ({
356
357
 
357
358
  declare type BarItemDataType = RepeatDataType | NoRepeatDataType;
358
359
 
360
+ /**
361
+ * Base configuration for all column types
362
+ * - accessorKey: optional, type-safe key from TData (supports nested paths like "user.name")
363
+ * - id: optional, auto-generated if not provided (allows multiple columns with same accessor)
364
+ * - cell: can receive either value (if accessorKey provided) or just row (if no accessorKey)
365
+ */
366
+ declare interface BaseColumnConfig<TData> {
367
+ id?: string;
368
+ accessorKey?: DeepKeys<TData>;
369
+ header: string;
370
+ sortable?: boolean;
371
+ filterable?: boolean;
372
+ searchable?: boolean;
373
+ pinned?: "left" | "right";
374
+ cell?: (value: any, row: TData, tableRow: Row<TData>) => React.ReactNode;
375
+ }
376
+
359
377
  declare type BaseProps = {
360
378
  options: AppSelectOption[];
361
379
  placeholder?: string;
@@ -770,6 +788,286 @@ declare type CopyButtonProps = {
770
788
  copyMessage?: string;
771
789
  };
772
790
 
791
+ /**
792
+ * Creates an action column (not sortable/filterable/searchable)
793
+ * @example
794
+ * createActionColumn<Person>({
795
+ * id: "actions",
796
+ * header: "Azioni",
797
+ * pinned: "right",
798
+ * cell: (row) => <Button>Edit {row.name}</Button>
799
+ * })
800
+ */
801
+ export declare function createActionColumn<TData>(config: {
802
+ id: string;
803
+ header: string;
804
+ pinned?: "left" | "right";
805
+ cell: (row: TData) => React.ReactNode;
806
+ }): ColumnDef<TData>;
807
+
808
+ /**
809
+ * Creates a boolean column with sensible defaults
810
+ * @example
811
+ * createBooleanColumn<Person>({
812
+ * accessorKey: "is_active",
813
+ * header: "Attivo",
814
+ * filterable: true,
815
+ * cell: (value) => value ? "✓" : "✗"
816
+ * })
817
+ */
818
+ export declare function createBooleanColumn<TData>(config: BaseColumnConfig<TData>): ColumnDef<TData>;
819
+
820
+ /**
821
+ * Creates a boolean filter badge
822
+ * @example
823
+ * createBooleanFilter("is_active", "Attivo", "checked")
824
+ */
825
+ export declare function createBooleanFilter(columnId: string, columnAccessorKey: string, columnLabel: string, operator: "checked" | "unchecked" | "eq" | "ne", value?: boolean): DataTableBadgeFilter;
826
+
827
+ /**
828
+ * Creates a computed column with a specific type (allows filtering/sorting based on computed value)
829
+ * Useful when you want to compute a value from row data but still have type-specific filtering
830
+ * @example
831
+ * // Age in months (computed from age)
832
+ * createComputedColumn<Person>({
833
+ * id: "age_months",
834
+ * header: "Età (mesi)",
835
+ * type: "number",
836
+ * cell: (row) => row.age * 12,
837
+ * sortable: true
838
+ * })
839
+ */
840
+ export declare function createComputedColumn<TData>(config: {
841
+ id?: string;
842
+ header: string;
843
+ type: "string" | "number" | "boolean" | "date" | "datetime";
844
+ cell: (row: TData) => React.ReactNode;
845
+ pinned?: "left" | "right";
846
+ sortable?: boolean;
847
+ filterable?: boolean;
848
+ searchable?: boolean;
849
+ }): ColumnDef<TData>;
850
+
851
+ /**
852
+ * Creates a date column with sensible defaults
853
+ * @example
854
+ * createDateColumn<Person>({
855
+ * accessorKey: "birth_date",
856
+ * header: "Data di nascita",
857
+ * sortable: true,
858
+ * filterable: true
859
+ * })
860
+ */
861
+ export declare function createDateColumn<TData>(config: BaseColumnConfig<TData>): ColumnDef<TData>;
862
+
863
+ /**
864
+ * Creates a date filter badge
865
+ * @example
866
+ * createDateFilter("birth_date", "Data di nascita", "date_after", "2000-01-01")
867
+ */
868
+ export declare function createDateFilter(columnId: string, columnAccessorKey: string, columnLabel: string, operator: "eq" | "date_before" | "date_after" | "eq_null" | "n_eq_null", value?: string): DataTableBadgeFilter;
869
+
870
+ /**
871
+ * Creates a datetime column with sensible defaults
872
+ * @example
873
+ * createDateTimeColumn<Person>({
874
+ * accessorKey: "created_at",
875
+ * header: "Data creazione",
876
+ * sortable: true,
877
+ * filterable: true
878
+ * })
879
+ */
880
+ export declare function createDateTimeColumn<TData>(config: BaseColumnConfig<TData>): ColumnDef<TData>;
881
+
882
+ /**
883
+ * Creates a datetime filter badge
884
+ * @example
885
+ * createDateTimeFilter("created_at", "Data creazione", "date_time_after", "2024-01-01T00:00:00")
886
+ */
887
+ export declare function createDateTimeFilter(columnId: string, columnAccessorKey: string, columnLabel: string, operator: "date_time_before" | "date_time_after" | "eq_null" | "n_eq_null", value?: string): DataTableBadgeFilter;
888
+
889
+ /**
890
+ * Creates a display-only column (no data binding, for computed/derived values)
891
+ * @example
892
+ * // Computed full name column
893
+ * createDisplayColumn<Person>({
894
+ * id: "full_name",
895
+ * header: "Nome Completo",
896
+ * cell: (row) => `${row.firstName} ${row.lastName}`,
897
+ * searchable: true // Can make it searchable if needed
898
+ * })
899
+ *
900
+ * // Status badge column
901
+ * createDisplayColumn<Person>({
902
+ * id: "status_badge",
903
+ * header: "Stato",
904
+ * cell: (row) => <Badge color={row.is_active ? "green" : "red"}>{row.status}</Badge>
905
+ * })
906
+ */
907
+ export declare function createDisplayColumn<TData>(config: {
908
+ id?: string;
909
+ header: string;
910
+ cell: (row: TData) => React.ReactNode;
911
+ pinned?: "left" | "right";
912
+ searchable?: boolean;
913
+ }): ColumnDef<TData>;
914
+
915
+ /**
916
+ * Creates a filter badge with auto-generated ID
917
+ * @example
918
+ * createFilterBadge({
919
+ * columnId: "name",
920
+ * columnLabel: "Nome",
921
+ * columnType: "string",
922
+ * columnAccessorKey: "name",
923
+ * operator: "like",
924
+ * value: "John"
925
+ * })
926
+ */
927
+ export declare function createFilterBadge(config: FilterBadgeConfig): DataTableBadgeFilter;
928
+
929
+ /**
930
+ * Creates multiple filter badges at once
931
+ * @example
932
+ * createFilterBadges([
933
+ * { columnId: "name", columnLabel: "Nome", columnType: "string", operator: "like", value: "John" },
934
+ * { columnId: "age", columnLabel: "Età", columnType: "number", operator: "gt", value: 25 }
935
+ * ])
936
+ */
937
+ export declare function createFilterBadges(configs: FilterBadgeConfig[]): DataTableBadgeFilter[];
938
+
939
+ /**
940
+ * Creates initial state configuration for DataTable
941
+ * @example
942
+ * createInitialState({
943
+ * filters: [createStringFilter("name", "Nome", "like", "John")],
944
+ * searchbarFilter: "active users",
945
+ * sorting: [{ column: "name", order: "asc" }],
946
+ * pagination: { pageIndex: 0, pageSize: 20 }
947
+ * })
948
+ */
949
+ export declare function createInitialState(config: InitialStateConfig): DataTableState;
950
+
951
+ /**
952
+ * Creates a list filter badge
953
+ * @example
954
+ * createListFilter("role", "Ruolo", "list_single_select", "array_overlap", ["Admin"], roleOptions)
955
+ */
956
+ export declare function createListFilter(columnId: string, columnAccessorKey: string, columnLabel: string, columnType: "list_single_select" | "list_multi_select", operator: "array_overlap" | "n_array_overlap" | "eq_null" | "n_eq_null", value?: Array<string | number>, listOptions?: AppSelectOption[]): DataTableBadgeFilter;
957
+
958
+ /**
959
+ * Creates a multi select list column (array where user can select multiple values)
960
+ * @example
961
+ * createMultiSelectColumn<Person>({
962
+ * accessorKey: "tags",
963
+ * header: "Tags",
964
+ * options: ["frontend", "backend", "devops"],
965
+ * filterable: true
966
+ * })
967
+ */
968
+ export declare function createMultiSelectColumn<TData>(config: ListColumnConfig<TData>): ColumnDef<TData>;
969
+
970
+ /**
971
+ * Creates a number column with sensible defaults
972
+ * @example
973
+ * createNumberColumn<Person>({
974
+ * accessorKey: "age",
975
+ * header: "Età",
976
+ * sortable: true,
977
+ * filterable: true
978
+ * })
979
+ *
980
+ * // Display-only computed column
981
+ * createNumberColumn<Person>({
982
+ * id: "age_in_months",
983
+ * header: "Età (mesi)",
984
+ * cell: (_, row) => row.age * 12
985
+ * })
986
+ */
987
+ export declare function createNumberColumn<TData>(config: BaseColumnConfig<TData>): ColumnDef<TData>;
988
+
989
+ /**
990
+ * Creates a number filter badge
991
+ * @example
992
+ * createNumberFilter("age", "Età", "gt", 25)
993
+ */
994
+ export declare function createNumberFilter(columnId: string, columnAccessorKey: string, columnLabel: string, operator: "eq" | "ne" | "lt" | "le" | "gt" | "ge" | "eq_null" | "n_eq_null", value?: number): DataTableBadgeFilter;
995
+
996
+ /**
997
+ * Creates a single select list column (array where user can select one value)
998
+ * @example
999
+ * createSingleSelectColumn<Person>({
1000
+ * accessorKey: "role",
1001
+ * header: "Ruolo",
1002
+ * options: ["Admin", "User", "Guest"],
1003
+ * filterable: true
1004
+ * })
1005
+ */
1006
+ export declare function createSingleSelectColumn<TData>(config: ListColumnConfig<TData>): ColumnDef<TData>;
1007
+
1008
+ /**
1009
+ * Creates sorting configuration
1010
+ * @example
1011
+ * createSorting([
1012
+ * { column: "name", order: "asc" },
1013
+ * { column: "age", order: "desc" }
1014
+ * ])
1015
+ */
1016
+ export declare function createSorting(sorts: Array<{
1017
+ column: string;
1018
+ order: "asc" | "desc";
1019
+ }>): DataTableSorting;
1020
+
1021
+ /**
1022
+ * Creates a string column with sensible defaults
1023
+ * @example
1024
+ * // Data-bound column
1025
+ * createStringColumn<Person>({
1026
+ * accessorKey: "name",
1027
+ * header: "Nome",
1028
+ * sortable: true,
1029
+ * filterable: true
1030
+ * })
1031
+ *
1032
+ * // Nested object path (supports dot notation, including nullable/optional objects)
1033
+ * createStringColumn<Person>({
1034
+ * accessorKey: "address.city",
1035
+ * header: "Città",
1036
+ * sortable: true,
1037
+ * filterable: true
1038
+ * })
1039
+ *
1040
+ * // Nullable nested object (e.g., item?: PricingItem | null)
1041
+ * createStringColumn<Order>({
1042
+ * accessorKey: "item.cod_master_pu",
1043
+ * header: "Master PU",
1044
+ * sortable: true
1045
+ * })
1046
+ *
1047
+ * // Multiple columns with same accessor (use unique IDs)
1048
+ * createStringColumn<Person>({
1049
+ * id: "name_display",
1050
+ * accessorKey: "name",
1051
+ * header: "Nome (Display)",
1052
+ * cell: (value) => <strong>{value}</strong>
1053
+ * })
1054
+ *
1055
+ * // Display-only column (no accessorKey)
1056
+ * createStringColumn<Person>({
1057
+ * id: "custom_display",
1058
+ * header: "Custom",
1059
+ * cell: (_, row) => `${row.firstName} ${row.lastName}`
1060
+ * })
1061
+ */
1062
+ export declare function createStringColumn<TData>(config: BaseColumnConfig<TData>): ColumnDef<TData>;
1063
+
1064
+ /**
1065
+ * Creates a string filter badge
1066
+ * @example
1067
+ * createStringFilter("name", "Nome", "like", "John")
1068
+ */
1069
+ export declare function createStringFilter(columnId: string, columnAccessorKey: string, columnLabel: string, operator: "like" | "n_like" | "starts_with" | "ends_with" | "eq" | "ne" | "eq_null" | "n_eq_null", value?: string): DataTableBadgeFilter;
1070
+
773
1071
  export declare interface CrossTableCell {
774
1072
  render?: (fromId: string, toId: string, id?: string) => ReactNode;
775
1073
  value?: number | string | null;
@@ -876,7 +1174,7 @@ export declare enum DataRepeatTypes {
876
1174
  MONTH = "MONTH"
877
1175
  }
878
1176
 
879
- export declare function DataTable<TData, TValue>({ columns, data, loading, emptyComponent, className, rowSelection, onRowSelectionChange, checkable, onCheckedRowsChange, actions, hidePagination, hideActionsRow, i18n, maxSortedColumns, initialState, serverMode: isServerSide, serverConfig: resolvedServerConfig, disableAutoPageSize, }: DataTableProps<TData, TValue>): JSX.Element;
1177
+ export declare function DataTable<TData, TValue>({ columns, data, loading, emptyComponent, className, rowSelection, onRowSelectionChange, checkable, onCheckedRowsChange, actions, customComponentsLeft, customComponentsRight, hidePagination, hideActionsRow, i18n, maxSortedColumns, initialState, serverMode: isServerSide, serverConfig: resolvedServerConfig, disableAutoPageSize, }: DataTableProps<TData, TValue>): JSX.Element;
880
1178
 
881
1179
  export declare interface DataTableActions {
882
1180
  label: string;
@@ -896,6 +1194,7 @@ declare interface DataTableAndGroup {
896
1194
  export declare interface DataTableBadgeFilter {
897
1195
  id: string;
898
1196
  columnId: string;
1197
+ columnAccessorKey: string;
899
1198
  columnLabel: string;
900
1199
  columnType: IColumnType;
901
1200
  operator: FilterOperator;
@@ -1053,6 +1352,8 @@ export declare interface DataTableProps<TData, TValue> {
1053
1352
  checkable?: boolean;
1054
1353
  onCheckedRowsChange?: (checkedRows: TData[]) => void;
1055
1354
  actions?: DataTableActions[];
1355
+ customComponentsLeft?: ReactNode;
1356
+ customComponentsRight?: ReactNode;
1056
1357
  hidePagination?: boolean;
1057
1358
  hideActionsRow?: boolean;
1058
1359
  i18n?: DataTableI18n;
@@ -1101,6 +1402,15 @@ export declare interface DatePickerProps {
1101
1402
  customCalendarProps?: React_2.ComponentProps<typeof Calendar>;
1102
1403
  }
1103
1404
 
1405
+ /**
1406
+ * Type helper to extract all possible deep paths from an object type
1407
+ * Supports nested properties with dot notation (e.g., "user.name", "address.city")
1408
+ * Handles nullable and optional nested objects (e.g., "item?.cod_master_pu")
1409
+ */
1410
+ declare type DeepKeys<T> = T extends object ? {
1411
+ [K in keyof T & string]: NonNullable<T[K]> extends object ? NonNullable<T[K]> extends any[] ? `${K}` : `${K}` | `${K}.${DeepKeys<NonNullable<T[K]>>}` : `${K}`;
1412
+ }[keyof T & string] : never;
1413
+
1104
1414
  export declare function Dialog({ ...props }: React_2.ComponentProps<typeof DialogPrimitive.Root>): JSX.Element;
1105
1415
 
1106
1416
  export declare function DialogContent({ className, children, size, closeOnOverlay, ...props }: React_2.ComponentProps<typeof DialogPrimitive.Content> & {
@@ -1194,6 +1504,16 @@ declare interface FileUploaderProps {
1194
1504
  maxFiles?: number;
1195
1505
  }
1196
1506
 
1507
+ declare interface FilterBadgeConfig {
1508
+ columnId: string;
1509
+ columnAccessorKey: string;
1510
+ columnLabel: string;
1511
+ columnType: IColumnType;
1512
+ operator: FilterOperator;
1513
+ value?: string | number | boolean | Array<string | number>;
1514
+ listOptions?: AppSelectOption[];
1515
+ }
1516
+
1197
1517
  declare type FilterOperator = "array_overlap" | "checked" | "date_after" | "date_before" | "date_time_after" | "date_time_before" | "ends_with" | "eq" | "eq_null" | "ge" | "gt" | "le" | "like" | "lt" | "n_array_overlap" | "n_eq_null" | "n_like" | "ne" | "starts_with" | "unchecked";
1198
1518
 
1199
1519
  export declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>(props: FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React_2.JSX.Element;
@@ -1283,6 +1603,13 @@ declare type GanttProps = {
1283
1603
  treeTitle?: string;
1284
1604
  };
1285
1605
 
1606
+ /**
1607
+ * Extracts column IDs from column definitions
1608
+ * @example
1609
+ * getColumnIds(columns) // ["name", "email", "age", "actions"]
1610
+ */
1611
+ export declare function getColumnIds<TData>(columns: ColumnDef<TData>[]): string[];
1612
+
1286
1613
  export declare const hexContrast: (hex: string) => string;
1287
1614
 
1288
1615
  export declare const hexToRgba: (hex: string, alpha: number) => string;
@@ -1296,6 +1623,7 @@ export declare function HoverCardTrigger({ ...props }: React_2.ComponentProps<ty
1296
1623
  declare interface IAdvancedFilterCondition {
1297
1624
  id: string;
1298
1625
  columnId: string;
1626
+ columnAccessorKey: string;
1299
1627
  columnLabel: string;
1300
1628
  columnType: IColumnType;
1301
1629
  operator: FilterOperator;
@@ -1352,6 +1680,19 @@ declare interface IFilterState {
1352
1680
  searchbarFilter?: string;
1353
1681
  }
1354
1682
 
1683
+ declare interface InitialStateConfig {
1684
+ filters?: DataTableBadgeFilter[];
1685
+ searchbarFilter?: string;
1686
+ sorting?: Array<{
1687
+ column: string;
1688
+ order: "asc" | "desc";
1689
+ }>;
1690
+ pagination?: {
1691
+ pageIndex: number;
1692
+ pageSize: number;
1693
+ };
1694
+ }
1695
+
1355
1696
  export declare const Input: React_2.ForwardRefExoticComponent<Omit<InputProps, "ref"> & React_2.RefAttributes<HTMLInputElement>>;
1356
1697
 
1357
1698
  export declare function InputOTP({ className, containerClassName, ...props }: React_2.ComponentProps<typeof OTPInput> & {
@@ -1413,8 +1754,20 @@ declare interface InterruptPromptProps {
1413
1754
  close: () => void;
1414
1755
  }
1415
1756
 
1757
+ /**
1758
+ * Validates if a filter operator is valid for a column type
1759
+ * @example
1760
+ * isValidOperatorForType("like", "string") // true
1761
+ * isValidOperatorForType("like", "number") // false
1762
+ */
1763
+ export declare function isValidOperatorForType(operator: FilterOperator, columnType: IColumnType): boolean;
1764
+
1416
1765
  export declare function Label({ className, ...props }: React_2.ComponentProps<typeof LabelPrimitive.Root>): JSX.Element;
1417
1766
 
1767
+ declare interface ListColumnConfig<TData> extends BaseColumnConfig<TData> {
1768
+ options: string[] | AppSelectOption[];
1769
+ }
1770
+
1418
1771
  declare type LogicalOperator = "AND" | "OR";
1419
1772
 
1420
1773
  export declare function MarkdownRenderer({ children }: MarkdownRendererProps): JSX.Element;
@@ -1714,6 +2067,16 @@ declare interface PartialToolCall {
1714
2067
  toolName: string;
1715
2068
  }
1716
2069
 
2070
+ /**
2071
+ * Creates a pinned version of existing columns
2072
+ * @example
2073
+ * pinColumns(columns, { left: ["name", "email"], right: ["actions"] })
2074
+ */
2075
+ export declare function pinColumns<TData>(columns: ColumnDef<TData>[], pinConfig: {
2076
+ left?: string[];
2077
+ right?: string[];
2078
+ }): ColumnDef<TData>[];
2079
+
1717
2080
  export declare function Popover({ ...props }: React_2.ComponentProps<typeof PopoverPrimitive.Root>): JSX.Element;
1718
2081
 
1719
2082
  export declare function PopoverContent({ className, align, sideOffset, container, ...props }: React_2.ComponentProps<typeof PopoverPrimitive.Content> & {
@@ -2022,6 +2385,17 @@ declare interface SourcePart {
2022
2385
  type: "source";
2023
2386
  }
2024
2387
 
2388
+ export declare function Spinner({ size, variant, className, ...props }: SpinnerProps): JSX.Element;
2389
+
2390
+ export declare interface SpinnerProps extends React_2.ComponentProps<"svg"> {
2391
+ size?: SpinnerSize | number;
2392
+ variant?: SpinnerVariant;
2393
+ }
2394
+
2395
+ export declare type SpinnerSize = "xxs" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
2396
+
2397
+ export declare type SpinnerVariant = "default" | "destructive" | "primary" | "secondary";
2398
+
2025
2399
  declare type StepIndicators = {
2026
2400
  active?: React_2.ReactNode;
2027
2401
  completed?: React_2.ReactNode;
@@ -2156,6 +2530,22 @@ declare const tooltipVariants: (props?: ({
2156
2530
  variant?: "primary" | "card" | null | undefined;
2157
2531
  } & ClassProp) | undefined) => string;
2158
2532
 
2533
+ /**
2534
+ * Converts string array to AppSelectOption array
2535
+ * @example
2536
+ * toSelectOptions(["Admin", "User", "Guest"])
2537
+ * // Returns: [{ value: "Admin", label: "Admin" }, ...]
2538
+ */
2539
+ export declare function toSelectOptions(values: string[]): AppSelectOption[];
2540
+
2541
+ /**
2542
+ * Converts array of objects to AppSelectOption array
2543
+ * @example
2544
+ * toSelectOptionsFromObjects(users, "id", "name")
2545
+ * // Returns: [{ value: user.id, label: user.name }, ...]
2546
+ */
2547
+ export declare function toSelectOptionsFromObjects<T>(items: T[], valueKey: keyof T, labelKey: keyof T): AppSelectOption[];
2548
+
2159
2549
  declare type TransformedDataType<T> = {
2160
2550
  [P in keyof T as Exclude<P, "children">]: T[P];
2161
2551
  };
@@ -2171,6 +2561,13 @@ export declare interface TypoProps extends React_2.HTMLAttributes<HTMLElement> {
2171
2561
 
2172
2562
  declare type TypoVariant = "hero-title" | "title" | "subtitle" | "body" | "body-bold" | "caption" | "overline" | "button" | "small" | "h1" | "h2" | "h3" | "h4" | "h5";
2173
2563
 
2564
+ /**
2565
+ * Updates list options for a specific column in columns array
2566
+ * @example
2567
+ * updateColumnListOptions(columns, "role", ["Admin", "User", "Guest"])
2568
+ */
2569
+ export declare function updateColumnListOptions<TData>(columns: ColumnDef<TData>[], columnAccessorKey: string, options: string[] | AppSelectOption[]): ColumnDef<TData>[];
2570
+
2174
2571
  export declare function useAudioRecording({ transcribeAudio, onTranscriptionComplete, }: UseAudioRecordingOptions): {
2175
2572
  isListening: boolean;
2176
2573
  isSpeechSupported: boolean;