@oneplatformdev/ui 0.0.1-beta.52 → 0.0.1-beta.54

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