laif-ds 0.2.3 → 0.2.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.
@@ -1,43 +1,41 @@
1
1
  "use client";
2
2
  import { jsx as r, jsxs as l, Fragment as A } from "react/jsx-runtime";
3
3
  import * as t from "react";
4
- import { useEffect as E } from "react";
5
- import { cn as m } from "../../lib/utils.js";
6
- import { Label as F } from "./label.js";
7
- import { Badge as V } from "./badge.js";
8
- import { Button as G } from "./button.js";
9
- import { Popover as X, PopoverTrigger as $, PopoverContent as q } from "./popover.js";
10
- import { Command as H, CommandList as I, CommandEmpty as J, CommandGroup as K, CommandItem as Q } from "./command.js";
11
- import { inputVariants as U } from "./input.js";
12
- import { Checkbox as Y } from "./checkbox.js";
4
+ import { useEffect as B } from "react";
5
+ import { cn as u } from "../../lib/utils.js";
6
+ import { Label as E } from "./label.js";
7
+ import { Badge as F } from "./badge.js";
8
+ import { Popover as V, PopoverTrigger as G, PopoverContent as X } from "./popover.js";
9
+ import { Command as $, CommandList as q, CommandEmpty as H, CommandGroup as I, CommandItem as J } from "./command.js";
10
+ import { inputVariants as K } from "./input.js";
11
+ import { Checkbox as Q } from "./checkbox.js";
13
12
  import { Icon as N } from "./icon.js";
14
- import { selectTriggerVariants as Z } from "./async-select.js";
15
- import _ from "../../node_modules/lucide-react/dist/esm/icons/chevron-down.js";
16
- const ee = t.createContext({ size: "default" });
17
- function pe({
13
+ import { selectTriggerVariants as U } from "./async-select.js";
14
+ import Y from "../../node_modules/lucide-react/dist/esm/icons/chevron-down.js";
15
+ const Z = t.createContext({ size: "default" });
16
+ function ue({
18
17
  options: a,
19
18
  value: n,
20
19
  onChange: o,
21
20
  onClear: g,
22
- placeholder: y = "Seleziona...",
23
- disabled: k = !1,
24
- size: f = "default",
21
+ placeholder: C = "Seleziona...",
22
+ disabled: y = !1,
23
+ size: m = "default",
25
24
  label: b,
26
- labelClassName: z,
25
+ labelClassName: k,
27
26
  emptyMessage: M = "Nessun risultato trovato",
28
- className: P,
29
- searchPlaceholder: R = "Cerca...",
30
- searchable: j = !0,
31
- cancelLabel: D = "Cancella selezione",
32
- cancelButtonLabel: O = "Cancella",
27
+ className: z,
28
+ searchPlaceholder: P = "Cerca...",
29
+ searchable: R = !0,
30
+ cancelLabel: j = "Cancella selezione",
33
31
  maxSelectedItems: i
34
32
  }) {
35
- const p = t.useId(), [s, S] = t.useState(!1), [d, v] = t.useState(""), [L, B] = t.useState(
33
+ const f = t.useId(), [s, D] = t.useState(!1), [c, v] = t.useState(""), [O, S] = t.useState(
36
34
  void 0
37
- ), T = t.useRef(null), h = t.useRef(null), w = t.useCallback(
35
+ ), L = t.useRef(null), p = t.useRef(null), w = t.useCallback(
38
36
  (e) => {
39
37
  if (n.includes(e))
40
- o(n.filter((c) => c !== e));
38
+ o(n.filter((d) => d !== e));
41
39
  else {
42
40
  if (i && n.length >= i)
43
41
  return;
@@ -45,53 +43,53 @@ function pe({
45
43
  }
46
44
  },
47
45
  [n, o, i]
48
- ), x = t.useCallback(() => {
46
+ ), T = t.useCallback(() => {
49
47
  o([]), v(""), g && g();
50
- }, [o]), u = t.useMemo(() => a.filter((e) => n.includes(e.value)), [a, n]), W = t.useMemo(() => d ? a.filter(
51
- (e) => e.label.toLowerCase().includes(d.toLowerCase())
52
- ) : a, [a, d]), C = t.useMemo(() => i ? n.length >= i : !1, [n, i]);
53
- return E(() => {
54
- if (s && h.current) {
55
- const e = h.current.getBoundingClientRect();
56
- B(e.width);
48
+ }, [o]), h = t.useMemo(() => a.filter((e) => n.includes(e.value)), [a, n]), W = t.useMemo(() => c ? a.filter(
49
+ (e) => e.label.toLowerCase().includes(c.toLowerCase())
50
+ ) : a, [a, c]), x = t.useMemo(() => i ? n.length >= i : !1, [n, i]);
51
+ return B(() => {
52
+ if (s && p.current) {
53
+ const e = p.current.getBoundingClientRect();
54
+ S(e.width);
57
55
  }
58
- }, [s]), /* @__PURE__ */ r(ee.Provider, { value: { size: f, id: p }, children: /* @__PURE__ */ l("div", { className: "space-y-1.5", children: [
59
- b && /* @__PURE__ */ r(F, { htmlFor: p, className: m(z, "w-fit"), children: b }),
56
+ }, [s]), /* @__PURE__ */ r(Z.Provider, { value: { size: m, id: f }, children: /* @__PURE__ */ l("div", { className: "space-y-1.5", children: [
57
+ b && /* @__PURE__ */ r(E, { htmlFor: f, className: u(k, "w-fit"), children: b }),
60
58
  /* @__PURE__ */ r(
61
59
  "div",
62
60
  {
63
- ref: T,
61
+ ref: L,
64
62
  className: "relative w-full",
65
63
  "data-slot": "app-multiple-select-dropdown",
66
- children: /* @__PURE__ */ l(X, { open: s, onOpenChange: S, children: [
67
- /* @__PURE__ */ r($, { asChild: !0, children: /* @__PURE__ */ l(
64
+ children: /* @__PURE__ */ l(V, { open: s, onOpenChange: D, children: [
65
+ /* @__PURE__ */ r(G, { asChild: !0, children: /* @__PURE__ */ l(
68
66
  "button",
69
67
  {
70
- id: p,
68
+ id: f,
71
69
  type: "button",
72
70
  role: "combobox",
73
71
  "aria-expanded": s,
74
- disabled: k,
75
- ref: h,
76
- className: m(
77
- Z({ size: f }),
72
+ disabled: y,
73
+ ref: p,
74
+ className: u(
75
+ U({ size: m }),
78
76
  "!bg-d-input hover:bg-d-input/50 relative w-full justify-between font-normal",
79
77
  "ring-offset-background border-d-border/50 flex items-center rounded-md border whitespace-nowrap focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",
80
78
  "aria-invalid:ring-d-destructive/20 dark:aria-invalid:ring-d-destructive/40 aria-invalid:border-d-destructive",
81
79
  "focus-visible:ring-d-ring focus-visible:ring-1",
82
80
  s && "ring-d-ring ring-1",
83
- P
81
+ z
84
82
  ),
85
83
  children: [
86
- /* @__PURE__ */ r("div", { className: "flex w-full items-center justify-between gap-2 overflow-hidden", children: u.length > 0 ? /* @__PURE__ */ l(A, { children: [
84
+ /* @__PURE__ */ r("div", { className: "flex w-full items-center justify-between gap-2 overflow-hidden", children: h.length > 0 ? /* @__PURE__ */ l(A, { children: [
87
85
  /* @__PURE__ */ l(
88
- V,
86
+ F,
89
87
  {
90
88
  variant: "secondary",
91
89
  className: "!bg-d-accent flex items-center gap-1",
92
90
  children: [
93
- /* @__PURE__ */ r("span", { children: u.length }),
94
- u.length === 1 ? " elemento selezionato" : " elementi selezionati"
91
+ /* @__PURE__ */ r("span", { children: h.length }),
92
+ h.length === 1 ? " elemento selezionato" : " elementi selezionati"
95
93
  ]
96
94
  }
97
95
  ),
@@ -100,10 +98,10 @@ function pe({
100
98
  {
101
99
  className: "border-d-input bg-d-accent cursor-pointer rounded-full p-1",
102
100
  onClick: (e) => {
103
- e.stopPropagation(), e.preventDefault(), x();
101
+ e.stopPropagation(), e.preventDefault(), T();
104
102
  },
105
103
  onMouseDown: (e) => e.preventDefault(),
106
- "aria-label": D,
104
+ "aria-label": j,
107
105
  children: /* @__PURE__ */ r(
108
106
  N,
109
107
  {
@@ -114,73 +112,61 @@ function pe({
114
112
  )
115
113
  }
116
114
  )
117
- ] }) : /* @__PURE__ */ r("span", { className: "text-d-muted-foreground", children: y }) }),
118
- /* @__PURE__ */ r(_, { className: "ml-1 h-4 w-4 shrink-0 opacity-50" })
115
+ ] }) : /* @__PURE__ */ r("span", { className: "text-d-muted-foreground", children: C }) }),
116
+ /* @__PURE__ */ r(Y, { className: "ml-1 h-4 w-4 shrink-0 opacity-50" })
119
117
  ]
120
118
  }
121
119
  ) }),
122
120
  /* @__PURE__ */ r(
123
- q,
121
+ X,
124
122
  {
125
- className: m("p-0"),
126
- style: { width: L },
123
+ className: u("p-0"),
124
+ style: { width: O },
127
125
  align: "start",
128
126
  side: "bottom",
129
127
  sideOffset: 4,
130
128
  onWheel: (e) => e.stopPropagation(),
131
129
  avoidCollisions: !1,
132
- children: /* @__PURE__ */ l(H, { className: "bg-d-popover w-full rounded-md border border-none", children: [
133
- j && /* @__PURE__ */ l("div", { className: "border-d-border flex items-center justify-between border-b px-3", children: [
134
- /* @__PURE__ */ l("div", { className: "flex items-center", children: [
135
- /* @__PURE__ */ r(
136
- N,
137
- {
138
- name: "Search",
139
- className: "text-d-accent-foreground opacity-50",
140
- size: "sm"
141
- }
142
- ),
143
- /* @__PURE__ */ r(
144
- "input",
145
- {
146
- id: "app-multiple-select-dropdown-filter",
147
- placeholder: R,
148
- value: d,
149
- onChange: (e) => v(e.target.value),
150
- className: `focus-visible:ring-none border-none focus-visible:border-none disabled:opacity-50 ${U({ size: f })} !shadow-none`
151
- }
152
- )
153
- ] }),
154
- u.length > 0 && /* @__PURE__ */ r(
155
- G,
130
+ children: /* @__PURE__ */ l($, { className: "bg-d-popover w-full rounded-md border border-none", children: [
131
+ R && /* @__PURE__ */ r("div", { className: "border-d-border flex items-center justify-between border-b px-3", children: /* @__PURE__ */ l("div", { className: "flex items-center", children: [
132
+ /* @__PURE__ */ r(
133
+ N,
134
+ {
135
+ name: "Search",
136
+ className: "text-d-accent-foreground opacity-50",
137
+ size: "sm"
138
+ }
139
+ ),
140
+ /* @__PURE__ */ r(
141
+ "input",
156
142
  {
157
- variant: "ghost",
158
- size: "sm",
159
- className: "h-6 px-2 text-xs",
160
- onClick: x,
161
- children: O
143
+ id: "app-multiple-select-dropdown-filter",
144
+ placeholder: P,
145
+ value: c,
146
+ onChange: (e) => v(e.target.value),
147
+ className: `focus-visible:ring-none border-none focus-visible:border-none disabled:opacity-50 ${K({ size: m })} !shadow-none`
162
148
  }
163
149
  )
164
- ] }),
165
- /* @__PURE__ */ l(I, { className: "max-h-60 w-full", children: [
166
- /* @__PURE__ */ r(J, { children: M }),
167
- /* @__PURE__ */ r(K, { children: W.map((e) => {
168
- const c = n.includes(e.value);
150
+ ] }) }),
151
+ /* @__PURE__ */ l(q, { className: "max-h-60 w-full", children: [
152
+ /* @__PURE__ */ r(H, { children: M }),
153
+ /* @__PURE__ */ r(I, { children: W.map((e) => {
154
+ const d = n.includes(e.value);
169
155
  return /* @__PURE__ */ l(
170
- Q,
156
+ J,
171
157
  {
172
158
  value: e.value,
173
- disabled: e.disabled || !c && C,
159
+ disabled: e.disabled || !d && x,
174
160
  onSelect: () => w(e.value),
175
- className: m(
161
+ className: u(
176
162
  "aria-selected:!bg-d-accent aria-selected:text-d-accent-foreground flex cursor-pointer items-center gap-2 px-2 py-1.5",
177
- (e.disabled || !c && C) && "cursor-not-allowed opacity-50"
163
+ (e.disabled || !d && x) && "cursor-not-allowed opacity-50"
178
164
  ),
179
165
  children: [
180
166
  /* @__PURE__ */ r(
181
- Y,
167
+ Q,
182
168
  {
183
- checked: c,
169
+ checked: d,
184
170
  className: "z-10 mr-2 flex-shrink-0",
185
171
  onCheckedChange: () => {
186
172
  console.log("checkbox change for:", e.value), w(e.value);
@@ -203,5 +189,5 @@ function pe({
203
189
  ] }) });
204
190
  }
205
191
  export {
206
- pe as AppMultipleSelectDropdown
192
+ ue as AppMultipleSelectDropdown
207
193
  };
@@ -61,7 +61,7 @@ const Oe = o.forwardRef(
61
61
  ({
62
62
  value: s,
63
63
  onChange: l,
64
- placeholder: i,
64
+ placeholder: i = "Cerca...",
65
65
  defaultOptions: u = [],
66
66
  options: a,
67
67
  delay: V,
@@ -71,7 +71,7 @@ const Oe = o.forwardRef(
71
71
  emptyIndicator: D,
72
72
  maxSelected: _ = Number.MAX_SAFE_INTEGER,
73
73
  onMaxSelected: A,
74
- hidePlaceholderWhenSelected: U,
74
+ hidePlaceholderWhenSelected: U = !0,
75
75
  disabled: N,
76
76
  groupBy: v,
77
77
  className: Z,
package/dist/index.d.ts CHANGED
@@ -143,7 +143,7 @@ declare interface AppEditorProps {
143
143
 
144
144
  declare type AppEditorToolbar = "block-format" | "font-format" | "history";
145
145
 
146
- export declare function AppMultipleSelectDropdown({ options, value, onChange, onClear, placeholder, disabled, size, label, labelClassName, emptyMessage, className, searchPlaceholder, searchable, cancelLabel, cancelButtonLabel, maxSelectedItems, }: MultipleSelectDropdownProps): JSX.Element;
146
+ export declare function AppMultipleSelectDropdown({ options, value, onChange, onClear, placeholder, disabled, size, label, labelClassName, emptyMessage, className, searchPlaceholder, searchable, cancelLabel, maxSelectedItems, }: MultipleSelectDropdownProps): JSX.Element;
147
147
 
148
148
  export declare interface AppMultipleSelectOption {
149
149
  value: string;
@@ -1209,7 +1209,6 @@ declare interface MultipleSelectDropdownProps {
1209
1209
  searchable?: boolean;
1210
1210
  maxSelectedItems?: number;
1211
1211
  cancelLabel?: string;
1212
- cancelButtonLabel?: string;
1213
1212
  }
1214
1213
 
1215
1214
  export declare const MultipleSelector: React_2.ForwardRefExoticComponent<MultipleSelectorProps & React_2.RefAttributes<MultipleSelectorRef>>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "laif-ds",
3
3
  "private": false,
4
- "version": "0.2.3",
4
+ "version": "0.2.5",
5
5
  "type": "module",
6
6
  "main": "dist/index.es.js",
7
7
  "module": "dist/index.es.js",