@caspeco/casper-ui-library 7.7.2 → 7.7.3

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 +1 @@
1
- {"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../../lib/components/combobox/combobox.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAIX,aAAa,EAKb,MAAM,SAAS,CAAC;AAiGjB;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,EACxB,EAAE,EACF,KAAU,EACV,cAAsB,EACtB,aAAkB,EAClB,MAAgB,EAChB,IAAW,EACX,OAAmB,EACnB,WAAmB,EACnB,QAAQ,EACR,KAAK,EACL,eAAe,EACf,QAAQ,EACR,MAAM,EACN,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,SAAS,EACT,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,SAAiB,EACjB,GAAG,KAAK,EACR,EAAE,aAAa,2CA+Lf"}
1
+ {"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../../lib/components/combobox/combobox.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAIX,aAAa,EAKb,MAAM,SAAS,CAAC;AAqGjB;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,EACxB,EAAE,EACF,KAAU,EACV,cAAsB,EACtB,aAAkB,EAClB,MAAgB,EAChB,IAAW,EACX,OAAmB,EACnB,WAAmB,EACnB,QAAQ,EACR,KAAK,EACL,eAAe,EACf,QAAQ,EACR,MAAM,EACN,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,SAAS,EACT,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,SAAiB,EACjB,GAAG,KAAK,EACR,EAAE,aAAa,2CAgMf"}
@@ -1,69 +1,69 @@
1
1
  import { jsxs as ee, jsx as V } from "react/jsx-runtime";
2
2
  import { Box as ne } from "@chakra-ui/react";
3
- import { useState as p, useRef as _, useEffect as q, useMemo as U } from "react";
3
+ import { useState as g, useRef as _, useEffect as q, useMemo as U } from "react";
4
4
  import { ComboboxButton as te } from "./combobox-button.js";
5
5
  import { ComboboxMenu as re } from "./combobox-menu.js";
6
6
  import { translations as oe } from "./translations.js";
7
- const le = (o, c) => {
8
- const [n, e] = p(0), i = (l) => {
9
- if (!c.current) return;
10
- const b = [...c.current.querySelectorAll("li")];
11
- b[l] && (b[l]?.scrollIntoView({
7
+ const le = (r, i) => {
8
+ const [n, e] = g(0), c = (l) => {
9
+ if (!i.current) return;
10
+ const f = [...i.current.querySelectorAll("li")];
11
+ f[l] && (f[l]?.scrollIntoView({
12
12
  behavior: "smooth",
13
13
  block: "nearest"
14
14
  }), e(l));
15
15
  };
16
16
  return {
17
17
  index: n,
18
- set: i,
19
- next: () => i((n + 1) % o.length),
20
- previous: () => i((n - 1 + o.length) % o.length)
18
+ set: c,
19
+ next: () => c((n + 1) % r.length),
20
+ previous: () => c((n - 1 + r.length) % r.length)
21
21
  };
22
- }, se = (o, c, n, e) => {
23
- const [i, r] = p(!1);
22
+ }, se = (r, i, n, e, c) => {
23
+ const [o, a] = g(!1);
24
24
  return q(() => {
25
- e && r(!1);
26
- }, [e, r]), { isOpen: i, close: () => {
27
- c || n(""), r(!1);
25
+ e && a(!1);
26
+ }, [e, a]), { isOpen: o, close: () => {
27
+ i || (n(""), c?.("")), a(!1);
28
28
  }, open: () => {
29
- i || e || (r(!0), o.set(0));
29
+ o || e || (a(!0), r.set(0));
30
30
  } };
31
- }, ie = (o, c) => {
32
- const [n, e] = p([]), i = U(() => {
33
- if (!n.length) return o;
34
- const r = n[n.length - 1], h = {
31
+ }, ie = (r, i) => {
32
+ const [n, e] = g([]), c = U(() => {
33
+ if (!n.length) return r;
34
+ const o = n[n.length - 1], a = {
35
35
  id: "_back",
36
- label: c.back
36
+ label: i.back
37
37
  }, l = n[n.length - 1]?.children || [];
38
- return r?.isSelectableParent ? [h, r, ...l] : [h, ...l];
39
- }, [n, o, c]);
38
+ return o?.isSelectableParent ? [a, o, ...l] : [a, ...l];
39
+ }, [n, r, i]);
40
40
  return {
41
- open: (r) => {
42
- e((h) => [...h, r]);
41
+ open: (o) => {
42
+ e((a) => [...a, o]);
43
43
  },
44
44
  back: () => {
45
- n.length && e((r) => [...r.slice(0, n.length - 1)]);
45
+ n.length && e((o) => [...o.slice(0, n.length - 1)]);
46
46
  },
47
47
  opened: n,
48
- current: i
48
+ current: c
49
49
  };
50
- }, ce = (o) => U(() => {
51
- const c = {};
52
- function n(e, i) {
53
- c[e.id] = [...i], e.children && e.children.forEach((r) => n(r, [...i, e.label]));
50
+ }, ce = (r) => U(() => {
51
+ const i = {};
52
+ function n(e, c) {
53
+ i[e.id] = [...c], e.children && e.children.forEach((o) => n(o, [...c, e.label]));
54
54
  }
55
- return o.forEach((e) => n(e, [])), c;
56
- }, [o]);
55
+ return r.forEach((e) => n(e, [])), i;
56
+ }, [r]);
57
57
  function be({
58
- id: o,
59
- label: c = "",
58
+ id: r,
59
+ label: i = "",
60
60
  isSingleSelect: n = !1,
61
61
  selectedItems: e = [],
62
- locale: i = "en-US",
63
- size: r = "md",
64
- variant: h = "outline",
62
+ locale: c = "en-US",
63
+ size: o = "md",
64
+ variant: a = "outline",
65
65
  asPlainText: l = !1,
66
- onSearch: b,
66
+ onSearch: f,
67
67
  items: I,
68
68
  maxVisibleItems: M,
69
69
  onChange: L,
@@ -79,60 +79,60 @@ function be({
79
79
  collapsed: K = !1,
80
80
  ...Q
81
81
  }) {
82
- const [H, g] = p(""), [X, j] = p(!1), k = oe[i], w = _(null), O = _(null), f = ie(I, k), Y = H.toLowerCase() === e[0]?.label.toLowerCase(), v = H.length > 0 && !(l && Y);
83
- let u = f.current;
82
+ const [H, b] = g(""), [X, j] = g(!1), k = oe[c], w = _(null), O = _(null), d = ie(I, k), Y = H.toLowerCase() === e[0]?.label.toLowerCase(), v = H.length > 0 && !(l && Y);
83
+ let h = d.current;
84
84
  if (v) {
85
- const t = [], d = (s) => {
86
- t.push(s), s.children && s.children.forEach(d);
85
+ const t = [], p = (s) => {
86
+ t.push(s), s.children && s.children.forEach(p);
87
87
  };
88
- I.forEach(d), u = t.filter((s) => {
88
+ I.forEach(p), h = t.filter((s) => {
89
89
  const F = s.label.toLowerCase().includes(H.toLowerCase());
90
90
  return (!(s.children && s.children.length > 0) || s.isSelectableParent) && F;
91
91
  });
92
92
  }
93
- const E = le(u, O), a = se(E, l, g, S);
93
+ const E = le(h, O), u = se(E, l, b, S, f);
94
94
  q(() => {
95
- l && !a.isOpen && g(e[0]?.label || "");
96
- }, [a.isOpen, e, l]);
97
- const [P, Z] = p([]);
95
+ l && !u.isOpen && b(e[0]?.label || "");
96
+ }, [u.isOpen, e, l]);
97
+ const [P, Z] = g([]);
98
98
  q(() => {
99
- !a.isOpen || n || Z(e);
100
- }, [a.isOpen]), v || (u = [
99
+ !u.isOpen || n || Z(e);
100
+ }, [u.isOpen]), v || (h = [
101
101
  ...P,
102
- ...u.filter((t) => !P.find((d) => d.label === t.label))
102
+ ...h.filter((t) => !P.find((p) => p.label === t.label))
103
103
  ]);
104
104
  let y = !1;
105
- x ? u = e : (y = u.length > (M ?? 1 / 0), u = u.slice(0, M));
105
+ x ? h = e : (y = h.length > (M ?? 1 / 0), h = h.slice(0, M));
106
106
  const $ = ce(I), R = (t) => {
107
107
  if (!t || x || S)
108
108
  return;
109
109
  if (O.current?.parentNode?.querySelector("input")?.focus(), t.id === "_back") {
110
- f.back();
110
+ d.back();
111
111
  return;
112
112
  }
113
- const d = f.opened.length > 0 && f.opened[f.opened.length - 1]?.id === t.id;
114
- if (!v && !d && t.children && t.children.length > 0) {
115
- f.open(t), requestAnimationFrame(() => E.set(1));
113
+ const p = d.opened.length > 0 && d.opened[d.opened.length - 1]?.id === t.id;
114
+ if (!v && !p && t.children && t.children.length > 0) {
115
+ d.open(t), requestAnimationFrame(() => E.set(1));
116
116
  return;
117
117
  }
118
118
  let s = [t];
119
- n || (e.some((C) => C.id === t.id) ? s = e.filter((C) => C.id !== t.id) : s = [...e, t]), g(l ? s[0]?.label ?? "" : ""), n && (s.length === 0 ? a.open() : a.close()), L && L(s);
119
+ n || (e.some((C) => C.id === t.id) ? s = e.filter((C) => C.id !== t.id) : s = [...e, t]), l ? b(s[0]?.label ?? "") : (b(""), f?.("")), n && (s.length === 0 ? u.open() : u.close()), L && L(s);
120
120
  }, T = e.length === 0 ? m ?? k.search : void 0, D = (t) => {
121
- w.current?.contains(t.relatedTarget) || (a.close(), j(!1), N && N(e));
121
+ w.current?.contains(t.relatedTarget) || (u.close(), j(!1), N && N(e));
122
122
  }, A = {
123
- id: o,
123
+ id: r,
124
124
  asPlainText: l,
125
125
  inputValue: H,
126
126
  selectedItems: e,
127
- displayItems: u,
127
+ displayItems: h,
128
128
  toggleItem: R,
129
129
  highlightState: E,
130
- openState: a,
130
+ openState: u,
131
131
  parentStrings: $,
132
132
  // Button
133
- size: r,
134
- variant: h,
135
- label: c,
133
+ size: o,
134
+ variant: a,
135
+ label: i,
136
136
  placeHolderText: T,
137
137
  isDisabled: S,
138
138
  isReadOnly: x,
@@ -140,8 +140,8 @@ function be({
140
140
  collapsed: K,
141
141
  hasPendingDelete: X,
142
142
  setHasPendingDelete: j,
143
- setInputValue: g,
144
- onSearch: b,
143
+ setInputValue: b,
144
+ onSearch: f,
145
145
  // Menu
146
146
  isSingleSelect: n,
147
147
  isSearching: v,
@@ -152,7 +152,7 @@ function be({
152
152
  parentRef: w,
153
153
  popupRef: O,
154
154
  footerContent: z,
155
- subMenuState: f,
155
+ subMenuState: d,
156
156
  translation: k
157
157
  };
158
158
  return /* @__PURE__ */ ee(
@@ -160,14 +160,14 @@ function be({
160
160
  {
161
161
  role: "combobox",
162
162
  as: "label",
163
- htmlFor: o,
163
+ htmlFor: r,
164
164
  className: "combobox",
165
165
  ref: w,
166
- onClick: a.open,
166
+ onClick: u.open,
167
167
  onBlur: D,
168
168
  overflow: "visible",
169
169
  width: "100%",
170
- "aria-expanded": a.isOpen,
170
+ "aria-expanded": u.isOpen,
171
171
  "aria-invalid": B,
172
172
  "aria-required": W,
173
173
  "aria-disabled": S,
@@ -175,7 +175,7 @@ function be({
175
175
  ...Q,
176
176
  children: [
177
177
  /* @__PURE__ */ V(te, { ...A }),
178
- a.isOpen && /* @__PURE__ */ V(re, { ...A })
178
+ u.isOpen && /* @__PURE__ */ V(re, { ...A })
179
179
  ]
180
180
  }
181
181
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caspeco/casper-ui-library",
3
- "version": "7.7.2",
3
+ "version": "7.7.3",
4
4
  "prettier": "@caspeco/prettier-config",
5
5
  "type": "module",
6
6
  "sideEffects": false,