@oneplatformdev/ui 0.0.1-beta.58 → 0.0.1-beta.59

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,94 +1,105 @@
1
- import { jsx as a, jsxs as o, Fragment as R } from "react/jsx-runtime";
2
- import s, { useRef as U, useEffect as _, useCallback as c, useLayoutEffect as A } from "react";
3
- import { LoadingMask as V } from "../LoadingMask/LoadingMask.mjs";
4
- import { Popover as X, PopoverTrigger as q, PopoverContent as z } from "../Popover/Popover.mjs";
1
+ import { jsx as a, jsxs as o, Fragment as I } from "react/jsx-runtime";
2
+ import s, { useRef as R, useEffect as U, useCallback as c, useLayoutEffect as q } from "react";
3
+ import { LoadingMask as z } from "../LoadingMask/LoadingMask.mjs";
4
+ import { Popover as A, PopoverTrigger as V, PopoverContent as X } from "../Popover/Popover.mjs";
5
5
  import { Button as H } from "../Button/Button.mjs";
6
6
  import "../Button/buttonVariants.mjs";
7
7
  import { Command as J, CommandInput as K, CommandList as Q, CommandGroup as W, CommandEmpty as k, CommandItem as Y } from "../Command/Command.mjs";
8
- import { cn as y } from "@oneplatformdev/utils";
8
+ import { cn as h } from "@oneplatformdev/utils";
9
9
  import { useDebounceCallback as Z } from "@oneplatformdev/hooks";
10
10
  import { X as $, ChevronsUpDown as ee, Check as ae } from "lucide-react";
11
- const pe = (O) => {
12
- var L;
11
+ const ue = (O) => {
12
+ var j;
13
13
  const {
14
14
  value: n,
15
15
  onChange: P,
16
- placeholder: j,
17
- disabled: D,
18
- searchLabel: T = "Type to search...",
19
- fetchOptions: B,
16
+ placeholder: D,
17
+ disabled: T,
18
+ searchLabel: B = "Type to search...",
19
+ fetchOptions: E,
20
20
  options: r,
21
21
  emptyLabel: C = "No options",
22
22
  emptyAction: i,
23
23
  onMount: x
24
- } = O, h = U(!1), [t, d] = s.useState(!1), [m, w] = s.useState(""), [p, u] = s.useState([]), [f, N] = s.useState(), [b, l] = s.useState(!1);
25
- _(() => {
26
- r != null && r.length && u(r);
24
+ } = O, f = R(!1), [t, d] = s.useState(!1), [m, w] = s.useState(""), [u, p] = s.useState([]), [b, N] = s.useState(), [g, l] = s.useState(!1);
25
+ U(() => {
26
+ r != null && r.length && p(r);
27
27
  }, [r]);
28
- const E = async () => {
28
+ const M = async () => {
29
29
  t || (S(), w(""));
30
30
  }, S = c(async (e) => {
31
31
  l(!0);
32
32
  try {
33
- const v = await B(e);
34
- u(v);
35
- } catch (v) {
36
- console.error("Unexpected error while get option:", v);
33
+ const y = await E(e);
34
+ p(y);
35
+ } catch (y) {
36
+ console.error("Unexpected error while get option:", y);
37
37
  } finally {
38
38
  l(!1);
39
39
  }
40
- }, []), M = Z(S, 1e3, { leading: !1, trailing: !0 }), F = c((e) => {
41
- l(!0), w(e), M(e);
42
- }, []), g = c((e) => {
40
+ }, []), _ = Z(S, 1e3, {
41
+ leading: !1,
42
+ trailing: !0
43
+ }), F = c((e) => {
44
+ l(!0), w(e), _(e);
45
+ }, []), v = c((e) => {
43
46
  P(e.value), N(e), l(!1);
47
+ }, []), L = c(() => {
48
+ console.log("handleClearSelection", L), v({ value: "", label: "" }), N(void 0), l(!1);
44
49
  }, []), G = c(() => {
45
- g({ value: "", label: "" }), N(void 0), l(!1);
46
- }, []), I = c(() => {
47
50
  if (!x) {
48
- h.current = !0;
51
+ f.current = !0;
49
52
  return;
50
53
  }
51
- x({ setOptions: u, search: m || "", open: t, setOpen: d }).finally(() => {
52
- h.current = !0;
53
- });
54
+ x({ setOptions: p, search: m || "", open: t, setOpen: d }).finally(
55
+ () => {
56
+ f.current = !0;
57
+ }
58
+ );
54
59
  }, []);
55
- return A(() => (I(), () => {
56
- h.current = !1;
60
+ return q(() => (G(), () => {
61
+ f.current = !1;
57
62
  }), []), /* @__PURE__ */ a("div", { className: "w-full", children: /* @__PURE__ */ o(
58
- X,
63
+ A,
59
64
  {
60
65
  open: t,
61
66
  onOpenChange: (e) => {
62
- d(e), e && E();
67
+ d(e), e && M();
63
68
  },
64
69
  children: [
65
- /* @__PURE__ */ a(q, { asChild: !0, className: "border-input", children: /* @__PURE__ */ o(
70
+ /* @__PURE__ */ a(V, { asChild: !0, className: "border-input", children: /* @__PURE__ */ o(
66
71
  H,
67
72
  {
68
73
  variant: "outline",
69
74
  role: "combobox",
70
75
  "aria-expanded": t,
71
- className: y(
72
- "w-full justify-between font-normal text-sm border bg-transparent",
76
+ className: h(
77
+ "w-full justify-between font-normal text-sm border bg-transparent relative",
73
78
  t ? "border-2 border-sidebar-accent" : "border-border"
74
79
  ),
75
- disabled: D,
80
+ disabled: T,
76
81
  children: [
77
- /* @__PURE__ */ a("span", { className: "truncate max-w-[calc(100%-1.5rem)] overflow-hidden whitespace-nowrap", children: n ? ((L = p.find((e) => e.value === n)) == null ? void 0 : L.label) || (f == null ? void 0 : f.label) : /* @__PURE__ */ a("span", { className: "text-gray-400", children: j }) }),
82
+ /* @__PURE__ */ a("span", { className: "truncate max-w-[calc(100%-1.5rem)] overflow-hidden whitespace-nowrap", children: n ? ((j = u.find((e) => e.value === n)) == null ? void 0 : j.label) || (b == null ? void 0 : b.label) : /* @__PURE__ */ a("span", { className: "text-gray-400", children: D }) }),
78
83
  n ? /* @__PURE__ */ a(
79
- $,
84
+ "div",
80
85
  {
81
- className: "opacity-50 w-4 h-4 cursor-pointer hover:opacity-100",
86
+ className: h(
87
+ "absolute top-0 right-1",
88
+ "flex items-center justify-center",
89
+ "w-9 aspect-square [&_svg]:size-5",
90
+ "opacity-50 cursor-pointer hover:opacity-100"
91
+ ),
82
92
  onClick: (e) => {
83
- e.stopPropagation(), G();
84
- }
93
+ e.stopPropagation(), L();
94
+ },
95
+ children: /* @__PURE__ */ a($, {})
85
96
  }
86
97
  ) : /* @__PURE__ */ a(ee, { className: "opacity-50 w-4 h-4" })
87
98
  ]
88
99
  }
89
100
  ) }),
90
101
  /* @__PURE__ */ a(
91
- z,
102
+ X,
92
103
  {
93
104
  className: "w-[var(--radix-popper-anchor-width)] max-w-none p-0",
94
105
  align: "start",
@@ -96,7 +107,7 @@ const pe = (O) => {
96
107
  /* @__PURE__ */ a(
97
108
  K,
98
109
  {
99
- placeholder: T,
110
+ placeholder: B,
100
111
  value: m,
101
112
  onValueChange: F
102
113
  }
@@ -104,33 +115,31 @@ const pe = (O) => {
104
115
  /* @__PURE__ */ a(Q, { children: /* @__PURE__ */ o(
105
116
  W,
106
117
  {
107
- className: y(
108
- !p.length && "p-0 shadow-none"
109
- ),
118
+ className: h(!u.length && "p-0 shadow-none"),
110
119
  children: [
111
- b && /* @__PURE__ */ a("div", { className: "flex justify-center", children: /* @__PURE__ */ a(V, {}) }),
112
- !b && !!m && /* @__PURE__ */ a(R, { children: i ? /* @__PURE__ */ o(k, { className: "flex flex-col gap-3 py-5 px-3 items-center", children: [
120
+ g && /* @__PURE__ */ a("div", { className: "flex justify-center", children: /* @__PURE__ */ a(z, {}) }),
121
+ !g && !!m && /* @__PURE__ */ a(I, { children: i ? /* @__PURE__ */ o(k, { className: "flex flex-col gap-3 py-5 px-3 items-center", children: [
113
122
  /* @__PURE__ */ a("span", { children: C }),
114
123
  typeof i == "function" ? i({
115
- setOptions: u,
124
+ setOptions: p,
116
125
  search: m || "",
117
126
  open: t,
118
127
  setOpen: d
119
128
  }) : i
120
129
  ] }) : /* @__PURE__ */ a(k, { children: C }) }),
121
- !b && !!p.length && p.map((e) => /* @__PURE__ */ o(
130
+ !g && !!u.length && u.map((e) => /* @__PURE__ */ o(
122
131
  Y,
123
132
  {
124
133
  value: e.value,
125
134
  onSelect: () => {
126
- n === e.value ? g({ value: "", label: "" }) : g(e), d(!1);
135
+ n === e.value ? v({ value: "", label: "" }) : v(e), d(!1);
127
136
  },
128
137
  children: [
129
138
  e.label,
130
139
  /* @__PURE__ */ a(
131
140
  ae,
132
141
  {
133
- className: y(
142
+ className: h(
134
143
  "ml-auto",
135
144
  n === e.value ? "opacity-100" : "opacity-0"
136
145
  )
@@ -151,5 +160,5 @@ const pe = (O) => {
151
160
  ) });
152
161
  };
153
162
  export {
154
- pe as Combobox
163
+ ue as Combobox
155
164
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneplatformdev/ui",
3
- "version": "0.0.1-beta.58",
3
+ "version": "0.0.1-beta.59",
4
4
  "description": "UI React Components.",
5
5
  "author": "One Platform Development Team",
6
6
  "keywords": [