@oneplatformdev/ui 0.0.1-beta.55 → 0.0.1-beta.56

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