laif-ds 0.1.55 → 0.1.57

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.
@@ -0,0 +1,62 @@
1
+ "use client";
2
+ var m = /* @__PURE__ */ ((e) => (e.AND = "AND", e.OR = "OR", e))(m || {});
3
+ function f(e, i, r, t, a) {
4
+ const u = e.getValue(i), o = t == null ? void 0 : t.find((n) => n.column === i), s = (o == null ? void 0 : o.innerFiltersMode) ?? "OR";
5
+ if (a) return !0;
6
+ if (Array.isArray(u))
7
+ return s === "AND" ? r.every((n) => u.includes(n)) : r.some((n) => u.includes(n));
8
+ switch (s) {
9
+ case "AND":
10
+ return r.every((n) => String(u) === n);
11
+ case "OR":
12
+ default:
13
+ return r.some((n) => String(u) === n);
14
+ }
15
+ }
16
+ function h(e, i) {
17
+ return e.reduce(
18
+ (r, t) => (t.filterFn && (r[t.column] = (a, u, o) => {
19
+ if (i) return !0;
20
+ const s = a.getValue(u);
21
+ switch (t.innerFiltersMode ?? "OR") {
22
+ case "AND":
23
+ return o.every(
24
+ (c) => t.filterFn(s, [c])
25
+ );
26
+ case "OR":
27
+ default:
28
+ return o.some(
29
+ (c) => t.filterFn(s, [c])
30
+ );
31
+ }
32
+ }), r),
33
+ {}
34
+ ) || {};
35
+ }
36
+ function A(e, i) {
37
+ const {
38
+ rowHeight: r = 1,
39
+ headerHeight: t = 1,
40
+ containerHeight: a = 1,
41
+ onPageChange: u,
42
+ setPagination: o
43
+ } = i, s = (e == null ? void 0 : e.offsetHeight) || a, n = Math.floor(
44
+ (s - t) / r
45
+ ), c = n > 1 ? n : 1;
46
+ o((g) => g.pageSize !== c ? (u && u(0, c), { ...g, pageSize: c }) : g);
47
+ }
48
+ function F(e, i) {
49
+ let r;
50
+ return function(...t) {
51
+ clearTimeout(r), r = setTimeout(() => {
52
+ e(...t);
53
+ }, i);
54
+ };
55
+ }
56
+ export {
57
+ m as ELogicalFilterOperator,
58
+ h as createCustomFilterFns,
59
+ f as createMultiValueFilterFn,
60
+ F as debounce,
61
+ A as updatePageSizeFromContainer
62
+ };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as o, jsxs as M, Fragment as N } from "react/jsx-runtime";
3
3
  import { useContext as R, useRef as a, useState as s, useCallback as k, useMemo as y, useEffect as u } from "react";
4
- import A from "../../../../../_virtual/index8.js";
4
+ import A from "../../../../../_virtual/index7.js";
5
5
  import B from "../../../../../_virtual/debounce.js";
6
6
  import { GanttContext as F } from "../Gantt/GanttContext.js";
7
7
  import { transformData as O } from "../../utils/transformData.js";
@@ -1,23 +1,25 @@
1
1
  "use client";
2
- import { jsx as i, jsxs as e } from "react/jsx-runtime";
3
- import { cn as t } from "../../lib/utils.js";
4
- import { buttonVariants as l } from "./button.js";
5
- import c from "../../node_modules/lucide-react/dist/esm/icons/ellipsis.js";
6
- import p from "../../node_modules/lucide-react/dist/esm/icons/chevron-right.js";
7
- import m from "../../node_modules/lucide-react/dist/esm/icons/chevron-left.js";
8
- function N({ className: a, ...n }) {
2
+ import { jsx as i, jsxs as o } from "react/jsx-runtime";
3
+ import { cn as e } from "../../lib/utils.js";
4
+ import { buttonVariants as c } from "./button.js";
5
+ import p from "../../node_modules/lucide-react/dist/esm/icons/ellipsis.js";
6
+ import m from "../../node_modules/lucide-react/dist/esm/icons/chevron-right.js";
7
+ import u from "../../node_modules/lucide-react/dist/esm/icons/chevron-left.js";
8
+ import g from "../../node_modules/lucide-react/dist/esm/icons/chevron-first.js";
9
+ import d from "../../node_modules/lucide-react/dist/esm/icons/chevron-last.js";
10
+ function C({ className: a, ...n }) {
9
11
  return /* @__PURE__ */ i(
10
12
  "nav",
11
13
  {
12
14
  role: "navigation",
13
15
  "aria-label": "pagination",
14
16
  "data-slot": "pagination",
15
- className: t("mx-auto flex w-full justify-center", a),
17
+ className: e("mx-auto flex w-full justify-center", a),
16
18
  ...n
17
19
  }
18
20
  );
19
21
  }
20
- function P({
22
+ function L({
21
23
  className: a,
22
24
  ...n
23
25
  }) {
@@ -25,19 +27,20 @@ function P({
25
27
  "ul",
26
28
  {
27
29
  "data-slot": "pagination-content",
28
- className: t("flex flex-row items-center gap-1", a),
30
+ className: e("flex flex-row items-center gap-1", a),
29
31
  ...n
30
32
  }
31
33
  );
32
34
  }
33
- function v({ ...a }) {
35
+ function j({ ...a }) {
34
36
  return /* @__PURE__ */ i("li", { "data-slot": "pagination-item", ...a });
35
37
  }
36
- function o({
38
+ function r({
37
39
  className: a,
38
40
  isActive: n,
39
- size: r = "icon",
40
- ...s
41
+ isDisabled: t,
42
+ size: s = "icon",
43
+ ...l
41
44
  }) {
42
45
  return /* @__PURE__ */ i(
43
46
  "a",
@@ -45,77 +48,117 @@ function o({
45
48
  "aria-current": n ? "page" : void 0,
46
49
  "data-slot": "pagination-link",
47
50
  "data-active": n,
48
- className: t(
49
- l({
51
+ className: e(
52
+ c({
50
53
  variant: n ? "outline" : "ghost",
51
- size: r
54
+ // variant: isDisabled ? "disabled" : isActive ? "outline" : "ghost",
55
+ size: s
52
56
  }),
57
+ t && "pointer-events-none cursor-not-allowed opacity-40",
53
58
  a
54
59
  ),
55
- ...s
60
+ ...l
56
61
  }
57
62
  );
58
63
  }
59
- function b({
64
+ function y({
60
65
  className: a,
61
- ...n
66
+ label: n,
67
+ ...t
62
68
  }) {
63
- return /* @__PURE__ */ e(
64
- o,
69
+ return /* @__PURE__ */ o(
70
+ r,
65
71
  {
66
72
  "aria-label": "Go to previous page",
67
- size: "default",
68
- className: t("gap-1 px-2.5 sm:pl-2.5", a),
69
- ...n,
73
+ className: e("gap-1 px-2.5 sm:pl-2.5", a),
74
+ ...t,
70
75
  children: [
71
- /* @__PURE__ */ i(m, {}),
72
- /* @__PURE__ */ i("span", { className: "hidden sm:block", children: "Previous" })
76
+ /* @__PURE__ */ i(g, {}),
77
+ /* @__PURE__ */ i("span", { className: "hidden sm:block", children: n ?? "First" })
73
78
  ]
74
79
  }
75
80
  );
76
81
  }
77
- function j({
82
+ function G({
78
83
  className: a,
79
- ...n
84
+ label: n,
85
+ ...t
86
+ }) {
87
+ return /* @__PURE__ */ o(
88
+ r,
89
+ {
90
+ "aria-label": "Go to previous page",
91
+ className: e("gap-1 px-2.5 sm:pl-2.5", a),
92
+ ...t,
93
+ children: [
94
+ /* @__PURE__ */ i(u, {}),
95
+ /* @__PURE__ */ i("span", { className: "hidden sm:block", children: n ?? "Previous" })
96
+ ]
97
+ }
98
+ );
99
+ }
100
+ function w({
101
+ className: a,
102
+ label: n,
103
+ ...t
80
104
  }) {
81
- return /* @__PURE__ */ e(
82
- o,
105
+ return /* @__PURE__ */ o(
106
+ r,
83
107
  {
84
108
  "aria-label": "Go to next page",
85
- size: "default",
86
- className: t("gap-1 px-2.5 sm:pr-2.5", a),
87
- ...n,
109
+ className: e("gap-1 px-2.5 sm:pr-2.5", a),
110
+ ...t,
111
+ children: [
112
+ /* @__PURE__ */ i("span", { className: "hidden sm:block", children: n ?? "Next" }),
113
+ /* @__PURE__ */ i(m, {})
114
+ ]
115
+ }
116
+ );
117
+ }
118
+ function F({
119
+ className: a,
120
+ label: n,
121
+ ...t
122
+ }) {
123
+ return /* @__PURE__ */ o(
124
+ r,
125
+ {
126
+ "aria-label": "Go to next page",
127
+ className: e("gap-1 px-2.5 sm:pr-2.5", a),
128
+ ...t,
88
129
  children: [
89
- /* @__PURE__ */ i("span", { className: "hidden sm:block", children: "Next" }),
90
- /* @__PURE__ */ i(p, {})
130
+ /* @__PURE__ */ i("span", { className: "hidden sm:block", children: n ?? "Last" }),
131
+ /* @__PURE__ */ i(d, {})
91
132
  ]
92
133
  }
93
134
  );
94
135
  }
95
- function k({
136
+ function z({
96
137
  className: a,
97
138
  ...n
98
139
  }) {
99
- return /* @__PURE__ */ e(
140
+ return /* @__PURE__ */ o(
100
141
  "span",
101
142
  {
102
143
  "aria-hidden": !0,
103
144
  "data-slot": "pagination-ellipsis",
104
- className: t("flex size-9 items-center justify-center", a),
145
+ className: e("flex size-9 items-center justify-center", a),
105
146
  ...n,
106
147
  children: [
107
- /* @__PURE__ */ i(c, { className: "size-4" }),
148
+ /* @__PURE__ */ i(p, { className: "size-4" }),
108
149
  /* @__PURE__ */ i("span", { className: "sr-only", children: "More pages" })
109
150
  ]
110
151
  }
111
152
  );
112
153
  }
113
154
  export {
114
- N as Pagination,
115
- P as PaginationContent,
116
- k as PaginationEllipsis,
117
- v as PaginationItem,
118
- o as PaginationLink,
119
- j as PaginationNext,
120
- b as PaginationPrevious
155
+ C as Pagination,
156
+ L as PaginationContent,
157
+ z as PaginationEllipsis,
158
+ y as PaginationFirst,
159
+ j as PaginationItem,
160
+ F as PaginationLast,
161
+ r as PaginationLink,
162
+ w as PaginationNext,
163
+ G as PaginationPrevious
121
164
  };
package/dist/index.d.ts CHANGED
@@ -45,6 +45,7 @@ import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
45
45
  import * as SelectPrimitive from '@radix-ui/react-select';
46
46
  import * as SeparatorPrimitive from '@radix-ui/react-separator';
47
47
  import { SeparatorProps } from '@radix-ui/react-separator';
48
+ import { SetStateAction } from 'react';
48
49
  import * as SliderPrimitive from '@radix-ui/react-slider';
49
50
  import { Slot } from '@radix-ui/react-slot';
50
51
  import * as SwitchPrimitive from '@radix-ui/react-switch';
@@ -650,9 +651,9 @@ export declare enum DataRepeatTypes {
650
651
  MONTH = "MONTH"
651
652
  }
652
653
 
653
- export declare function DataTable<TData, TValue>({ columns, data, loading, emptyComponent, className, rowSelection, onRowSelectionChange, checkable, onCheckedRowsChange, notFoundMessage, searchBar, dropdownFilters, }: DataTableProps<TData, TValue>): JSX.Element;
654
+ export declare function DataTable<TData, TValue>({ columns, data, loading, emptyComponent, className, rowSelection, onRowSelectionChange, checkable, onCheckedRowsChange, notFoundMessage, searchBar, dropdownFilters, totalItems, datatableSizes, paginationPlaceholders, serverOptions, setServerOptions, }: DataTableProps<TData, TValue>): JSX.Element;
654
655
 
655
- declare interface DataTableProps<TData, TValue> {
656
+ export declare interface DataTableProps<TData, TValue> {
656
657
  columns: ColumnDef<TData, TValue>[];
657
658
  data: TData[];
658
659
  loading?: boolean;
@@ -663,8 +664,13 @@ declare interface DataTableProps<TData, TValue> {
663
664
  checkable?: boolean;
664
665
  onCheckedRowsChange?: (checkedRows: TData[]) => void;
665
666
  notFoundMessage?: string;
666
- searchBar?: SearchBarProps;
667
- dropdownFilters?: DropdownFilterProp[];
667
+ searchBar?: ISearchBarProps;
668
+ dropdownFilters?: IDropdownFilterProp[];
669
+ totalItems?: number;
670
+ datatableSizes?: IDatatableSizes;
671
+ paginationPlaceholders?: IDatatablePaginationPlaceholders;
672
+ serverOptions?: IServerOptionsProps;
673
+ setServerOptions?: (value: SetStateAction<IServerOptionsProps>) => void;
668
674
  }
669
675
 
670
676
  export declare function DatePicker({ value, onChange, placeholder, dateFormat, className, buttonVariant, disabled, size, }: DatePickerProps): JSX.Element;
@@ -720,20 +726,6 @@ export declare function DrawerTitle({ className, ...props }: React_2.ComponentPr
720
726
 
721
727
  export declare function DrawerTrigger({ ...props }: React_2.ComponentProps<typeof Drawer_2.Trigger>): JSX.Element;
722
728
 
723
- declare interface DropdownFilterItem {
724
- label: string;
725
- value: string;
726
- }
727
-
728
- declare interface DropdownFilterProp {
729
- column: string;
730
- placeholder: string;
731
- label?: string;
732
- innerFiltersMode?: ELogicalFilterOperator;
733
- items: DropdownFilterItem[];
734
- filterFn?: (rowValue: unknown, filterValue: string[]) => boolean;
735
- }
736
-
737
729
  export declare const DropdownMenu: React_2.FC<DropdownMenuPrimitive.DropdownMenuProps>;
738
730
 
739
731
  export declare const DropdownMenuContent: React_2.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuContentProps & React_2.RefAttributes<HTMLDivElement>, "ref"> & React_2.RefAttributes<HTMLDivElement>>;
@@ -750,7 +742,7 @@ export declare const DropdownMenuSeparator: React_2.ForwardRefExoticComponent<Om
750
742
 
751
743
  export declare const DropdownMenuTrigger: React_2.ForwardRefExoticComponent<DropdownMenuPrimitive.DropdownMenuTriggerProps & React_2.RefAttributes<HTMLButtonElement>>;
752
744
 
753
- declare enum ELogicalFilterOperator {
745
+ export declare enum ELogicalFilterOperator {
754
746
  AND = "AND",
755
747
  OR = "OR"
756
748
  }
@@ -855,6 +847,10 @@ export declare function HoverCardContent({ className, align, sideOffset, ...prop
855
847
 
856
848
  export declare function HoverCardTrigger({ ...props }: React_2.ComponentProps<typeof HoverCardPrimitive.Trigger>): JSX.Element;
857
849
 
850
+ export declare type IColumnDefWithSticky<TData, TValue = unknown> = ColumnDef<TData, TValue> & {
851
+ sticky?: boolean;
852
+ };
853
+
858
854
  /**
859
855
  * Componente Icon che renderizza un'icona da lucide-react
860
856
  *
@@ -883,6 +879,35 @@ declare interface IconProps {
883
879
 
884
880
  declare type IconSize = keyof typeof sizeMap;
885
881
 
882
+ export declare interface IDatatablePaginationPlaceholders {
883
+ rows?: string;
884
+ pages?: string;
885
+ first?: string;
886
+ previous?: string;
887
+ next?: string;
888
+ last?: string;
889
+ }
890
+
891
+ export declare interface IDatatableSizes {
892
+ rowHeight?: number;
893
+ headerHeight?: number;
894
+ containerHeight?: number;
895
+ }
896
+
897
+ export declare interface IDropdownFilterItem {
898
+ label: string;
899
+ value: string;
900
+ }
901
+
902
+ export declare interface IDropdownFilterProp {
903
+ column: string;
904
+ placeholder: string;
905
+ label?: string;
906
+ innerFiltersMode?: ELogicalFilterOperator;
907
+ items: IDropdownFilterItem[];
908
+ filterFn?: (rowValue: unknown, filterValue: string[]) => boolean;
909
+ }
910
+
886
911
  export declare const Input: React_2.ForwardRefExoticComponent<Omit<InputProps, "ref"> & React_2.RefAttributes<HTMLInputElement>>;
887
912
 
888
913
  export declare function InputOTP({ className, containerClassName, ...props }: React_2.ComponentProps<typeof OTPInput> & {
@@ -925,6 +950,35 @@ declare interface InterruptPromptProps {
925
950
  close: () => void;
926
951
  }
927
952
 
953
+ export declare interface IPaginationProps {
954
+ pageIndex: number;
955
+ pageSize: number;
956
+ }
957
+
958
+ export declare interface ISearchBarProps {
959
+ placeholder?: string;
960
+ columns: string[];
961
+ }
962
+
963
+ export declare interface IServerFilterProps {
964
+ searchbarFilters?: {
965
+ value: string;
966
+ columns: string[];
967
+ };
968
+ dropdownFilters?: {
969
+ [column: string]: {
970
+ logic: ELogicalFilterOperator;
971
+ value: string[];
972
+ column: string;
973
+ };
974
+ };
975
+ }
976
+
977
+ export declare interface IServerOptionsProps {
978
+ pagination: IPaginationProps;
979
+ filters?: IServerFilterProps;
980
+ }
981
+
928
982
  export declare function Label({ className, ...props }: React_2.ComponentProps<typeof LabelPrimitive.Root>): JSX.Element;
929
983
 
930
984
  export declare function MarkdownRenderer({ children }: MarkdownRendererProps): JSX.Element;
@@ -1182,15 +1236,17 @@ export declare function PaginationEllipsis({ className, ...props }: React_2.Comp
1182
1236
 
1183
1237
  export declare function PaginationItem({ ...props }: React_2.ComponentProps<"li">): JSX.Element;
1184
1238
 
1185
- export declare function PaginationLink({ className, isActive, size, ...props }: PaginationLinkProps): JSX.Element;
1239
+ export declare function PaginationLink({ className, isActive, isDisabled, size, ...props }: PaginationLinkProps): JSX.Element;
1186
1240
 
1187
1241
  declare type PaginationLinkProps = {
1188
1242
  isActive?: boolean;
1243
+ isDisabled?: boolean;
1244
+ label?: string;
1189
1245
  } & Pick<React_2.ComponentProps<typeof Button>, "size"> & React_2.ComponentProps<"a">;
1190
1246
 
1191
- export declare function PaginationNext({ className, ...props }: React_2.ComponentProps<typeof PaginationLink>): JSX.Element;
1247
+ export declare function PaginationNext({ className, label, ...props }: React_2.ComponentProps<typeof PaginationLink>): JSX.Element;
1192
1248
 
1193
- export declare function PaginationPrevious({ className, ...props }: React_2.ComponentProps<typeof PaginationLink>): JSX.Element;
1249
+ export declare function PaginationPrevious({ className, label, ...props }: React_2.ComponentProps<typeof PaginationLink>): JSX.Element;
1194
1250
 
1195
1251
  declare interface PartialToolCall {
1196
1252
  state: "partial-call";
@@ -1298,11 +1354,6 @@ export declare function ScrollArea({ className, children, ...props }: React_2.Co
1298
1354
 
1299
1355
  export declare function ScrollBar({ className, orientation, ...props }: React_2.ComponentProps<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>): JSX.Element;
1300
1356
 
1301
- declare interface SearchBarProps {
1302
- placeholder?: string;
1303
- columns: string[];
1304
- }
1305
-
1306
1357
  export declare function Select({ size, label, labelClassName, ...props }: SelectProps): JSX.Element;
1307
1358
 
1308
1359
  export declare function SelectContent({ className, children, position, ...props }: React_2.ComponentProps<typeof SelectPrimitive.Content>): JSX.Element;