@oneplatformdev/ui 0.0.1-beta.50 → 0.0.1-beta.51

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