@pibit.ai/cure-design-system 0.6.29 → 0.6.31

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,86 +1,86 @@
1
- import { jsx as r, jsxs as F, Fragment as z } from "react/jsx-runtime";
2
- import { useRef as L, useCallback as b, useEffect as k, useMemo as q } from "react";
3
- import { SearchMd as A, XClose as E } from "@untitledui/icons";
4
- import { ComboBox as P, Group as R, Input as j } from "react-aria-components";
5
- import { cx as i } from "../../utils/cn.js";
6
- import { getPlatformShortcutLabel as B } from "../../utils/keyboard-shortcut.js";
7
- import { sizes as g } from "./select-shared.js";
8
- import { ButtonUtility as G } from "../button/button-utility.js";
9
- const M = {
1
+ import { jsx as r, jsxs as _, Fragment as M } from "react/jsx-runtime";
2
+ import { useRef as U, useCallback as S, useEffect as F, useMemo as j } from "react";
3
+ import { SearchMd as B, XClose as G } from "@untitledui/icons";
4
+ import { ComboBox as O, Group as T, Input as V } from "react-aria-components";
5
+ import { cx as c } from "../../utils/cn.js";
6
+ import { getPlatformShortcutLabel as X } from "../../utils/keyboard-shortcut.js";
7
+ import { sizes as k } from "./select-shared.js";
8
+ import { ButtonUtility as H } from "../button/button-utility.js";
9
+ const J = 15, Q = {
10
10
  xs: "h-7",
11
11
  sm: "h-8",
12
12
  md: "h-9",
13
13
  lg: "h-11"
14
- }, _ = ({
15
- size: u,
16
- shortcut: l,
17
- bordered: h = !1,
18
- placeholder: y,
19
- shortcutClassName: x,
20
- onKeyDown: d,
21
- onClear: m,
22
- hasValue: o,
23
- className: s
14
+ }, W = ({
15
+ size: m,
16
+ shortcut: u,
17
+ bordered: g = !1,
18
+ placeholder: x,
19
+ shortcutClassName: b,
20
+ onKeyDown: f,
21
+ onClear: p,
22
+ hasValue: i,
23
+ className: l
24
24
  }) => {
25
- const n = g[u] ? u : "sm";
25
+ const o = k[m] ? m : "sm";
26
26
  return /* @__PURE__ */ r(
27
- R,
27
+ T,
28
28
  {
29
- className: ({ isFocusWithin: a, isDisabled: p }) => i(
29
+ className: ({ isFocusWithin: a, isDisabled: h }) => c(
30
30
  "relative flex w-full items-center gap-2 rounded-md bg-primary outline-hidden transition-shadow duration-100 ease-linear ring-inset",
31
- h && "border border-secondary",
32
- p && "cursor-not-allowed bg-disabled_subtle",
31
+ g && "border border-secondary",
32
+ h && "cursor-not-allowed bg-disabled_subtle",
33
33
  a && "ring-1 ring-brand",
34
- M[n],
35
- g[n].root,
36
- s
34
+ Q[o],
35
+ k[o].root,
36
+ l
37
37
  ),
38
- children: ({ isDisabled: a }) => /* @__PURE__ */ F(z, { children: [
38
+ children: ({ isDisabled: a }) => /* @__PURE__ */ _(M, { children: [
39
39
  /* @__PURE__ */ r(
40
- A,
40
+ B,
41
41
  {
42
42
  color: "var(--color-utility-gray-300)",
43
43
  className: "pointer-events-none size-4 flex-shrink-0"
44
44
  }
45
45
  ),
46
46
  /* @__PURE__ */ r("div", { className: "relative flex w-full items-center gap-2", children: /* @__PURE__ */ r(
47
- j,
47
+ V,
48
48
  {
49
- placeholder: y,
50
- onKeyDown: d,
51
- className: i(
49
+ placeholder: x,
50
+ onKeyDown: f,
51
+ className: c(
52
52
  "z-10 w-full appearance-none bg-transparent text-xs text-primary caret-alpha-black/90 placeholder:text-placeholder_subtle focus:outline-hidden disabled:cursor-not-allowed disabled:text-disabled disabled:placeholder:text-disabled",
53
- o && "pr-6",
54
- l && !o && "pr-12"
53
+ i && "pr-6",
54
+ u && !i && "pr-12"
55
55
  )
56
56
  }
57
57
  ) }),
58
- /* @__PURE__ */ r("div", { className: "flex-shrink-0", children: o && !a && /* @__PURE__ */ r(
59
- G,
58
+ /* @__PURE__ */ r("div", { className: "flex-shrink-0", children: i && !a && /* @__PURE__ */ r(
59
+ H,
60
60
  {
61
- icon: /* @__PURE__ */ r(E, { size: 14 }),
61
+ icon: /* @__PURE__ */ r(G, { size: 14 }),
62
62
  color: "tertiary",
63
- onClick: m,
63
+ onClick: p,
64
64
  "aria-label": "Clear search"
65
65
  }
66
66
  ) }),
67
- l && !o && /* @__PURE__ */ r(
67
+ u && !i && /* @__PURE__ */ r(
68
68
  "div",
69
69
  {
70
- className: i(
70
+ className: c(
71
71
  "pointer-events-none absolute inset-y-0.5 right-0.5 z-10 flex items-center rounded-r-[inherit] bg-linear-to-r from-transparent pl-8",
72
- g[n].shortcut,
73
- x
72
+ k[o].shortcut,
73
+ b
74
74
  ),
75
75
  children: /* @__PURE__ */ r(
76
76
  "span",
77
77
  {
78
- className: i(
78
+ className: c(
79
79
  "pointer-events-none rounded px-1 py-px text-xs font-medium text-quaternary ring-1 ring-secondary select-none ring-inset",
80
80
  a && "bg-transparent text-disabled"
81
81
  ),
82
82
  "aria-hidden": "true",
83
- children: B(["meta"], "K")
83
+ children: X(["meta"], "K")
84
84
  }
85
85
  )
86
86
  }
@@ -89,46 +89,63 @@ const M = {
89
89
  }
90
90
  );
91
91
  };
92
- function Y({
93
- size: u = "sm",
94
- shortcut: l = !1,
95
- registerShortcut: h,
96
- bordered: y = !1,
97
- innerClassName: x,
98
- autoFocus: d = !1,
99
- placeholder: m,
100
- shortcutClassName: o,
101
- value: s,
102
- onChange: n,
92
+ function oe({
93
+ size: m = "sm",
94
+ shortcut: u = !1,
95
+ registerShortcut: g,
96
+ bordered: x = !1,
97
+ innerClassName: b,
98
+ autoFocus: f = !1,
99
+ placeholder: p,
100
+ shortcutClassName: i,
101
+ value: l,
102
+ onChange: o,
103
103
  onKeyDown: a,
104
- className: p,
105
- isDisabled: c = !1,
106
- "aria-label": v,
107
- ...K
104
+ className: h,
105
+ isDisabled: d = !1,
106
+ "aria-label": q,
107
+ ...z
108
108
  }) {
109
- const w = L(null), S = h ?? l, f = b(() => {
109
+ const y = U(null), E = g ?? u, K = S(() => {
110
110
  var e, t;
111
- (t = (e = w.current) == null ? void 0 : e.querySelector("input")) == null || t.focus();
111
+ (t = (e = y.current) == null ? void 0 : e.querySelector("input")) == null || t.focus();
112
112
  }, []);
113
- k(() => {
114
- if (!d || c) return;
115
- let e = 0;
116
- const t = requestAnimationFrame(() => {
117
- e = requestAnimationFrame(() => f());
118
- });
119
- return () => {
120
- cancelAnimationFrame(t), cancelAnimationFrame(e);
113
+ F(() => {
114
+ if (!f || d) return;
115
+ let e = 0, t = J, v = !1;
116
+ const w = () => {
117
+ v = !0;
118
+ }, L = (n) => {
119
+ const s = y.current, I = (s == null ? void 0 : s.closest('[role="dialog"]')) ?? s;
120
+ I && n.target instanceof Node && !I.contains(n.target) && w();
121
+ }, N = [
122
+ "keydown",
123
+ "pointerdown",
124
+ "touchstart",
125
+ "compositionstart"
126
+ ];
127
+ N.forEach((n) => document.addEventListener(n, w, !0)), document.addEventListener("focusin", L, !0);
128
+ const C = () => {
129
+ var s;
130
+ if (v) return;
131
+ const n = (s = y.current) == null ? void 0 : s.querySelector("input");
132
+ n && document.activeElement !== n && n.focus(), --t > 0 && (e = requestAnimationFrame(C));
133
+ };
134
+ return e = requestAnimationFrame(C), () => {
135
+ cancelAnimationFrame(e), N.forEach(
136
+ (n) => document.removeEventListener(n, w, !0)
137
+ ), document.removeEventListener("focusin", L, !0);
121
138
  };
122
- }, [d, c, f]), k(() => {
123
- if (!S || c) return;
139
+ }, [f, d]), F(() => {
140
+ if (!E || d) return;
124
141
  const e = (t) => {
125
- (t.metaKey || t.ctrlKey) && !t.shiftKey && !t.altKey && t.key.toLowerCase() === "k" && (t.preventDefault(), t.stopPropagation(), f());
142
+ (t.metaKey || t.ctrlKey) && !t.shiftKey && !t.altKey && t.key.toLowerCase() === "k" && (t.preventDefault(), t.stopPropagation(), K());
126
143
  };
127
144
  return window.addEventListener("keydown", e, { capture: !0 }), () => window.removeEventListener("keydown", e, {
128
145
  capture: !0
129
146
  });
130
- }, [S, c, f]);
131
- const N = b(
147
+ }, [E, d, K]);
148
+ const A = S(
132
149
  (e) => {
133
150
  if ((e.metaKey || e.ctrlKey) && !e.shiftKey && !e.altKey && e.key.toLowerCase() === "k") {
134
151
  e.preventDefault(), e.stopPropagation();
@@ -137,39 +154,39 @@ function Y({
137
154
  e.key === "Enter" && (e.preventDefault(), e.stopPropagation()), a == null || a(e);
138
155
  },
139
156
  [a]
140
- ), I = b(() => {
141
- n == null || n("");
142
- }, [n]), C = q(() => !!s && s.length > 0, [s]);
157
+ ), P = S(() => {
158
+ o == null || o("");
159
+ }, [o]), R = j(() => !!l && l.length > 0, [l]);
143
160
  return /* @__PURE__ */ r(
144
- P,
161
+ O,
145
162
  {
146
- ...K,
147
- ref: w,
148
- inputValue: s,
149
- onInputChange: n,
163
+ ...z,
164
+ ref: y,
165
+ inputValue: l,
166
+ onInputChange: o,
150
167
  menuTrigger: "manual",
151
168
  items: [],
152
169
  allowsCustomValue: !0,
153
- isDisabled: c,
154
- "aria-label": v || m || "Search",
155
- className: i("w-xs", p),
170
+ isDisabled: d,
171
+ "aria-label": q || p || "Search",
172
+ className: c("w-xs", h),
156
173
  children: () => /* @__PURE__ */ r(
157
- _,
174
+ W,
158
175
  {
159
- size: u,
160
- shortcut: l,
161
- bordered: y,
162
- placeholder: m,
163
- shortcutClassName: o,
164
- onKeyDown: N,
165
- onClear: I,
166
- hasValue: C,
167
- className: i(p, x)
176
+ size: m,
177
+ shortcut: u,
178
+ bordered: x,
179
+ placeholder: p,
180
+ shortcutClassName: i,
181
+ onKeyDown: A,
182
+ onClear: P,
183
+ hasValue: R,
184
+ className: c(h, b)
168
185
  }
169
186
  )
170
187
  }
171
188
  );
172
189
  }
173
190
  export {
174
- Y as default
191
+ oe as default
175
192
  };
@@ -1 +1 @@
1
- {"version":3,"file":"searchable-select.d.ts","sourceRoot":"","sources":["../../../src/primitives/select/searchable-select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AAG1D,OAAO,KAAK,EAEV,WAAW,IAAI,eAAe,EAC/B,MAAM,uBAAuB,CAAC;AAW/B,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAC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