@caspeco/casper-ui-library 4.0.0 → 4.0.1

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.
Files changed (51) hide show
  1. package/dist/components/combobox/combobox-button.js +72 -73
  2. package/dist/components/combobox/combobox-menu.js +68 -69
  3. package/dist/components/combobox/combobox.js +104 -109
  4. package/dist/components/date-picker/base-date-picker.js +175 -176
  5. package/dist/components/date-picker/date-picker-header.js +10 -10
  6. package/dist/components/date-picker/helper.js +9 -9
  7. package/dist/components/image-upload/image-cropper.js +112 -113
  8. package/dist/components/image-upload/image-upload-dropzone.js +35 -36
  9. package/dist/components/menu/menu-group.js +44 -45
  10. package/dist/components/segmented-control/segmented-control.js +29 -29
  11. package/dist/components/table/table-cell.js +25 -26
  12. package/dist/components/table/table-header-dropdown.js +60 -60
  13. package/dist/components/table/table-header-row.js +19 -20
  14. package/dist/components/table/table-toolbar.js +63 -64
  15. package/dist/components/table/use-controllable-state.js +7 -7
  16. package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +1 -1
  17. package/dist/node_modules/@tanstack/table-core/build/lib/index.js +41 -41
  18. package/dist/node_modules/date-fns/addDays.js +7 -7
  19. package/dist/node_modules/date-fns/addMonths.js +13 -13
  20. package/dist/node_modules/date-fns/differenceInCalendarDays.js +11 -11
  21. package/dist/node_modules/date-fns/endOfDay.js +6 -6
  22. package/dist/node_modules/date-fns/endOfMonth.js +6 -6
  23. package/dist/node_modules/date-fns/format.js +46 -47
  24. package/dist/node_modules/date-fns/getDayOfYear.js +8 -8
  25. package/dist/node_modules/date-fns/getISOWeek.js +9 -9
  26. package/dist/node_modules/date-fns/getISOWeekYear.js +10 -10
  27. package/dist/node_modules/date-fns/getWeek.js +9 -9
  28. package/dist/node_modules/date-fns/getWeekYear.js +13 -14
  29. package/dist/node_modules/date-fns/isSameDay.js +9 -9
  30. package/dist/node_modules/date-fns/isSameMonth.js +9 -9
  31. package/dist/node_modules/date-fns/isSameWeek.js +8 -8
  32. package/dist/node_modules/date-fns/isSameYear.js +9 -9
  33. package/dist/node_modules/date-fns/locale/_lib/buildLocalizeFn.js +12 -12
  34. package/dist/node_modules/date-fns/locale/da/_lib/formatDistance.js +4 -4
  35. package/dist/node_modules/date-fns/locale/en-US/_lib/formatDistance.js +3 -3
  36. package/dist/node_modules/date-fns/locale/es/_lib/formatDistance.js +4 -4
  37. package/dist/node_modules/date-fns/locale/et/_lib/formatDistance.js +6 -6
  38. package/dist/node_modules/date-fns/locale/fi/_lib/formatDistance.js +17 -17
  39. package/dist/node_modules/date-fns/locale/lt/_lib/formatDistance.js +47 -47
  40. package/dist/node_modules/date-fns/locale/lv/_lib/formatDistance.js +11 -11
  41. package/dist/node_modules/date-fns/locale/nb/_lib/formatDistance.js +3 -3
  42. package/dist/node_modules/date-fns/locale/nl/_lib/formatDistance.js +4 -4
  43. package/dist/node_modules/date-fns/locale/sv/_lib/formatDistance.js +5 -5
  44. package/dist/node_modules/date-fns/startOfDay.js +6 -6
  45. package/dist/node_modules/date-fns/startOfMonth.js +6 -6
  46. package/dist/node_modules/date-fns/startOfWeek.js +7 -8
  47. package/dist/node_modules/date-fns/startOfWeekYear.js +9 -10
  48. package/dist/node_modules/date-fns/startOfYear.js +5 -5
  49. package/dist/theme/theme-config/components/modal-theme.js +13 -15
  50. package/dist/theme/theme-config/components/select-theme.js +15 -19
  51. package/package.json +2 -2
@@ -1,15 +1,14 @@
1
- import { jsxs as te, jsx as U } from "react/jsx-runtime";
2
- import { Box as re } from "@chakra-ui/react";
3
- import { useState as b, useRef as W, useEffect as P, useMemo as z } from "react";
4
- import { ComboboxButton as oe } from "./combobox-button.js";
5
- import { ComboboxMenu as le } from "./combobox-menu.js";
6
- import { translations as ie } from "./translations.js";
7
- const ce = (o, s) => {
8
- const [n, e] = b(0), c = (l) => {
9
- var p;
1
+ import { jsxs as T, jsx as F } from "react/jsx-runtime";
2
+ import { Box as D } from "@chakra-ui/react";
3
+ import { useState as g, useRef as V, useEffect as M, useMemo as _ } from "react";
4
+ import { ComboboxButton as ee } from "./combobox-button.js";
5
+ import { ComboboxMenu as ne } from "./combobox-menu.js";
6
+ import { translations as te } from "./translations.js";
7
+ const re = (o, s) => {
8
+ const [n, e] = g(0), c = (l) => {
10
9
  if (!s.current) return;
11
- const S = [...s.current.querySelectorAll("li")];
12
- S[l] && ((p = S[l]) == null || p.scrollIntoView({
10
+ const b = [...s.current.querySelectorAll("li")];
11
+ b[l] && (b[l]?.scrollIntoView({
13
12
  behavior: "smooth",
14
13
  block: "nearest"
15
14
  }), e(l));
@@ -20,147 +19,143 @@ const ce = (o, s) => {
20
19
  next: () => c((n + 1) % o.length),
21
20
  previous: () => c((n - 1 + o.length) % o.length)
22
21
  };
23
- }, se = (o, s, n, e) => {
24
- const [c, r] = b(!1);
25
- return P(() => {
26
- e && r(!1);
27
- }, [e, r]), { isOpen: c, close: () => {
28
- s || n(""), r(!1);
22
+ }, oe = (o, s, n, e) => {
23
+ const [c, t] = g(!1);
24
+ return M(() => {
25
+ e && t(!1);
26
+ }, [e, t]), { isOpen: c, close: () => {
27
+ s || n(""), t(!1);
29
28
  }, open: () => {
30
- c || e || (r(!0), o.set(0));
29
+ c || e || (t(!0), o.set(0));
31
30
  } };
32
- }, ae = (o, s) => {
33
- const [n, e] = b([]), c = z(() => {
31
+ }, le = (o, s) => {
32
+ const [n, e] = g([]), c = _(() => {
34
33
  if (!n.length) return o;
35
- const r = n[n.length - 1], f = {
34
+ const t = n[n.length - 1], h = {
36
35
  id: "_back",
37
36
  label: s.back
38
37
  }, l = n[n.length - 1].children || [];
39
- return r.isSelectableParent ? [f, r, ...l] : [f, ...l];
38
+ return t.isSelectableParent ? [h, t, ...l] : [h, ...l];
40
39
  }, [n, o, s]);
41
40
  return {
42
- open: (r) => {
43
- e((f) => [...f, r]);
41
+ open: (t) => {
42
+ e((h) => [...h, t]);
44
43
  },
45
44
  back: () => {
46
- n.length && e((r) => [...r.slice(0, n.length - 1)]);
45
+ n.length && e((t) => [...t.slice(0, n.length - 1)]);
47
46
  },
48
47
  opened: n,
49
48
  current: c
50
49
  };
51
- }, ue = (o) => z(() => {
50
+ }, ie = (o) => _(() => {
52
51
  const s = {};
53
52
  function n(e, c) {
54
- s[e.id] = [...c], e.children && e.children.forEach((r) => n(r, [...c, e.label]));
53
+ s[e.id] = [...c], e.children && e.children.forEach((t) => n(t, [...c, e.label]));
55
54
  }
56
55
  return o.forEach((e) => n(e, [])), s;
57
56
  }, [o]);
58
- function xe({
57
+ function pe({
59
58
  id: o,
60
59
  label: s = "",
61
60
  isSingleSelect: n = !1,
62
61
  selectedItems: e = [],
63
62
  locale: c = "en-US",
64
- size: r = "md",
65
- variant: f = "outline",
63
+ size: t = "md",
64
+ variant: h = "outline",
66
65
  asPlainText: l = !1,
67
- onSearch: S,
68
- items: p,
69
- maxVisibleItems: B,
70
- onChange: j,
71
- onBlur: y,
72
- isDisabled: x,
73
- isReadOnly: v,
74
- isRequired: G,
75
- placeholder: J,
76
- isInvalid: A,
77
- footerContent: K,
78
- popoverWidth: Q,
79
- popoverPlacement: X,
80
- collapsed: Y = !1,
81
- ...Z
66
+ onSearch: b,
67
+ items: I,
68
+ maxVisibleItems: L,
69
+ onChange: N,
70
+ onBlur: P,
71
+ isDisabled: S,
72
+ isReadOnly: x,
73
+ isRequired: m,
74
+ placeholder: U,
75
+ isInvalid: B,
76
+ footerContent: W,
77
+ popoverWidth: z,
78
+ popoverPlacement: G,
79
+ collapsed: J = !1,
80
+ ...K
82
81
  }) {
83
- var _;
84
- const [C, g] = b(""), k = ie[c], w = W(null), O = W(null), d = ae(p, k), $ = C.toLowerCase() === ((_ = e[0]) == null ? void 0 : _.label.toLowerCase()), H = C.length > 0 && !(l && $);
85
- let u = d.current;
86
- if (H) {
87
- const t = [], h = (i) => {
88
- t.push(i), i.children && i.children.forEach(h);
82
+ const [v, p] = g(""), k = te[c], w = V(null), O = V(null), f = le(I, k), Q = v.toLowerCase() === e[0]?.label.toLowerCase(), C = v.length > 0 && !(l && Q);
83
+ let u = f.current;
84
+ if (C) {
85
+ const r = [], d = (i) => {
86
+ r.push(i), i.children && i.children.forEach(d);
89
87
  };
90
- p.forEach(h), u = t.filter((i) => {
91
- const I = i.label.toLowerCase().includes(C.toLowerCase());
92
- return (!(i.children && i.children.length > 0) || i.isSelectableParent) && I;
88
+ I.forEach(d), u = r.filter((i) => {
89
+ const A = i.label.toLowerCase().includes(v.toLowerCase());
90
+ return (!(i.children && i.children.length > 0) || i.isSelectableParent) && A;
93
91
  });
94
92
  }
95
- const E = ce(u, O), a = se(E, l, g, x);
96
- P(() => {
97
- var t;
98
- l && !a.isOpen && g(((t = e[0]) == null ? void 0 : t.label) || "");
93
+ const E = re(u, O), a = oe(E, l, p, S);
94
+ M(() => {
95
+ l && !a.isOpen && p(e[0]?.label || "");
99
96
  }, [a.isOpen, e, l]);
100
- const [q, R] = b([]);
101
- P(() => {
102
- !a.isOpen || n || R(e);
103
- }, [a.isOpen]), H || (u = [
97
+ const [q, X] = g([]);
98
+ M(() => {
99
+ !a.isOpen || n || X(e);
100
+ }, [a.isOpen]), C || (u = [
104
101
  ...q,
105
- ...u.filter((t) => !q.find((h) => h.label === t.label))
102
+ ...u.filter((r) => !q.find((d) => d.label === r.label))
106
103
  ]);
107
- let F = !1;
108
- v ? u = e : (F = u.length > (B ?? 1 / 0), u = u.slice(0, B));
109
- const T = ue(p), D = (t) => {
110
- var I, M, L, m;
111
- if (v || x)
104
+ let j = !1;
105
+ x ? u = e : (j = u.length > (L ?? 1 / 0), u = u.slice(0, L));
106
+ const Y = ie(I), Z = (r) => {
107
+ if (x || S)
112
108
  return;
113
- if (t.id === "_back") {
114
- d.back();
109
+ if (r.id === "_back") {
110
+ f.back();
115
111
  return;
116
112
  }
117
- (L = (M = (I = O.current) == null ? void 0 : I.parentNode) == null ? void 0 : M.querySelector("input")) == null || L.focus();
118
- const h = d.opened.length > 0 && d.opened[d.opened.length - 1].id === t.id;
119
- if (!H && !h && t.children && t.children.length > 0) {
120
- d.open(t), requestAnimationFrame(() => E.set(1));
113
+ O.current?.parentNode?.querySelector("input")?.focus();
114
+ const d = f.opened.length > 0 && f.opened[f.opened.length - 1].id === r.id;
115
+ if (!C && !d && r.children && r.children.length > 0) {
116
+ f.open(r), requestAnimationFrame(() => E.set(1));
121
117
  return;
122
118
  }
123
- let i = [t];
124
- n || (e.some((N) => N.id === t.id) ? i = e.filter((N) => N.id !== t.id) : i = [...e, t]), g(l ? (m = i[0]) == null ? void 0 : m.label : ""), n && (i.length === 0 ? a.open() : a.close()), j && j(i);
125
- }, ee = e.length === 0 ? J ?? k.search : void 0, ne = (t) => {
126
- var h;
127
- (h = w.current) != null && h.contains(t.relatedTarget) || (a.close(), y && y(e));
128
- }, V = {
119
+ let i = [r];
120
+ n || (e.some((H) => H.id === r.id) ? i = e.filter((H) => H.id !== r.id) : i = [...e, r]), p(l ? i[0]?.label : ""), n && (i.length === 0 ? a.open() : a.close()), N && N(i);
121
+ }, $ = e.length === 0 ? U ?? k.search : void 0, R = (r) => {
122
+ w.current?.contains(r.relatedTarget) || (a.close(), P && P(e));
123
+ }, y = {
129
124
  id: o,
130
125
  asPlainText: l,
131
- inputValue: C,
126
+ inputValue: v,
132
127
  selectedItems: e,
133
128
  displayItems: u,
134
- toggleItem: D,
129
+ toggleItem: Z,
135
130
  highlightState: E,
136
131
  openState: a,
137
- parentStrings: T,
132
+ parentStrings: Y,
138
133
  // Button
139
- size: r,
140
- variant: f,
134
+ size: t,
135
+ variant: h,
141
136
  label: s,
142
- placeHolderText: ee,
143
- isDisabled: x,
144
- isReadOnly: v,
145
- isInvalid: A,
146
- collapsed: Y,
147
- setInputValue: g,
148
- onSearch: S,
137
+ placeHolderText: $,
138
+ isDisabled: S,
139
+ isReadOnly: x,
140
+ isInvalid: B,
141
+ collapsed: J,
142
+ setInputValue: p,
143
+ onSearch: b,
149
144
  // Menu
150
145
  isSingleSelect: n,
151
- isSearching: H,
152
- isHidingItems: F,
153
- popoverWidth: Q,
154
- popoverPlacement: X,
146
+ isSearching: C,
147
+ isHidingItems: j,
148
+ popoverWidth: z,
149
+ popoverPlacement: G,
155
150
  previousSelectedItems: q,
156
151
  parentRef: w,
157
152
  popupRef: O,
158
- footerContent: K,
159
- subMenuState: d,
153
+ footerContent: W,
154
+ subMenuState: f,
160
155
  translation: k
161
156
  };
162
- return /* @__PURE__ */ te(
163
- re,
157
+ return /* @__PURE__ */ T(
158
+ D,
164
159
  {
165
160
  role: "combobox",
166
161
  as: "label",
@@ -168,22 +163,22 @@ function xe({
168
163
  className: "combobox",
169
164
  ref: w,
170
165
  onClick: a.open,
171
- onBlur: ne,
166
+ onBlur: R,
172
167
  overflow: "visible",
173
168
  width: "100%",
174
169
  "aria-expanded": a.isOpen,
175
- "aria-invalid": A,
176
- "aria-required": G,
177
- "aria-disabled": x,
178
- "aria-readonly": v,
179
- ...Z,
170
+ "aria-invalid": B,
171
+ "aria-required": m,
172
+ "aria-disabled": S,
173
+ "aria-readonly": x,
174
+ ...K,
180
175
  children: [
181
- /* @__PURE__ */ U(oe, { ...V }),
182
- a.isOpen && /* @__PURE__ */ U(le, { ...V })
176
+ /* @__PURE__ */ F(ee, { ...y }),
177
+ a.isOpen && /* @__PURE__ */ F(ne, { ...y })
183
178
  ]
184
179
  }
185
180
  );
186
181
  }
187
182
  export {
188
- xe as Combobox
183
+ pe as Combobox
189
184
  };