meticulous-ui 2.1.1 → 2.1.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,13 +1,13 @@
1
1
  import { j as r } from "../../_virtual/jsx-runtime.js";
2
- import { useState as C, useRef as S, useMemo as L, useEffect as d, useLayoutEffect as M, useCallback as ee, createElement as te } from "react";
3
- import ne from "../../node_modules/lodash-es/get.js";
2
+ import { useState as C, useRef as S, useMemo as M, useEffect as d, useLayoutEffect as ee, useCallback as te, createElement as ne } from "react";
3
+ import re from "../../node_modules/lodash-es/get.js";
4
4
  import I from "../../colors/grey.js";
5
- import re from "../MenuItem/MenuItem.js";
6
- import oe from "../../colors/index.js";
7
- import se from "../../colors/blue.js";
5
+ import oe from "../MenuItem/MenuItem.js";
6
+ import se from "../../colors/index.js";
7
+ import ie from "../../colors/blue.js";
8
8
  import F from "../Spinner/Spinner.js";
9
- import { DropdownWrapper as ie, Box as ce, PWrapper as le, ChevronDownWrapper as fe, OptionWrapper as ue, SearchContainer as ae, SearchIcon as pe, SearchInput as de, OptionsList as me, LoadMoreSentinel as he, SpinnerWrapper as xe } from "./styles.js";
10
- const be = (o) => {
9
+ import { DropdownWrapper as ce, Box as le, PWrapper as fe, ChevronDownWrapper as ue, OptionWrapper as ae, SearchContainer as pe, SearchIcon as de, SearchInput as me, OptionsList as he, LoadMoreSentinel as xe, SpinnerWrapper as be } from "./styles.js";
10
+ const ge = (o) => {
11
11
  if (typeof o != "string") return o;
12
12
  if (o.endsWith("px")) return parseFloat(o);
13
13
  if (o.endsWith("rem")) {
@@ -15,7 +15,7 @@ const be = (o) => {
15
15
  return E * i;
16
16
  }
17
17
  return parseFloat(o);
18
- }, ve = ({
18
+ }, ye = ({
19
19
  options: o,
20
20
  onChange: E,
21
21
  value: i,
@@ -29,11 +29,12 @@ const be = (o) => {
29
29
  searchable: h = !1,
30
30
  onLoadMore: l,
31
31
  hasMore: x = !1,
32
- isLoadingMore: a = !1
32
+ isLoadingMore: a = !1,
33
+ searchPh: B = "Search..."
33
34
  }) => {
34
- const [n, j] = C(!1), [B, H] = C("bottom"), [b, D] = C(""), [f, p] = C(-1), g = S(null), w = S(null), k = S(null), R = S(null), V = S(!0), K = () => j((e) => !e), z = (e) => {
35
+ const [n, j] = C(!1), [H, V] = C("bottom"), [b, D] = C(""), [f, p] = C(-1), g = S(null), w = S(null), k = S(null), R = S(null), K = S(!0), Q = () => j((e) => !e), z = (e) => {
35
36
  e !== i && (E(e), j(!1));
36
- }, c = L(() => {
37
+ }, c = M(() => {
37
38
  if (!h || !b.trim()) return o;
38
39
  const e = b.toLowerCase();
39
40
  return o.filter(({ label: t }) => t.toLowerCase().includes(e));
@@ -60,44 +61,44 @@ const be = (o) => {
60
61
  }, [f, n]), d(() => {
61
62
  n && h && k.current && k.current.focus();
62
63
  }, [n, h]), d(() => {
63
- n || (V.current = !0);
64
+ n || (K.current = !0);
64
65
  }, [n]), d(() => {
65
66
  const e = (t) => {
66
67
  g.current && !g.current.contains(t.target) && j(!1);
67
68
  };
68
69
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
69
- }, []), M(() => {
70
+ }, []), ee(() => {
70
71
  if (n && w.current && g.current) {
71
- const e = g.current.getBoundingClientRect(), t = window.innerHeight, s = be(O), u = t - e.bottom;
72
- H(
72
+ const e = g.current.getBoundingClientRect(), t = window.innerHeight, s = ge(O), u = t - e.bottom;
73
+ V(
73
74
  u < s + 8 && e.top > u ? "top" : "bottom"
74
75
  );
75
76
  }
76
77
  }, [n, O]);
77
- const Q = (e) => {
78
+ const q = (e) => {
78
79
  let t = e + 1;
79
80
  for (; t < c.length; ) {
80
81
  if (!c[t].disabled) return t;
81
82
  t++;
82
83
  }
83
84
  return e;
84
- }, q = (e) => {
85
+ }, N = (e) => {
85
86
  let t = e - 1;
86
87
  for (; t >= 0; ) {
87
88
  if (!c[t].disabled) return t;
88
89
  t--;
89
90
  }
90
91
  return e;
91
- }, N = (e) => {
92
+ }, U = (e) => {
92
93
  if (n)
93
94
  switch (e.key) {
94
95
  case "ArrowDown":
95
96
  e.preventDefault();
96
- const t = Q(f);
97
+ const t = q(f);
97
98
  t === f && x && !a && l?.(), p(t);
98
99
  break;
99
100
  case "ArrowUp":
100
- e.preventDefault(), p((u) => q(u));
101
+ e.preventDefault(), p((u) => N(u));
101
102
  break;
102
103
  case "Enter":
103
104
  e.preventDefault();
@@ -108,7 +109,7 @@ const be = (o) => {
108
109
  j(!1);
109
110
  break;
110
111
  }
111
- }, W = ee(() => {
112
+ }, W = te(() => {
112
113
  x && !a && l && l();
113
114
  }, [x, a, l]);
114
115
  d(() => {
@@ -129,68 +130,68 @@ const be = (o) => {
129
130
  return t.observe(e), () => t.disconnect();
130
131
  }, [W, l, x, a]);
131
132
  const {
132
- m50: U,
133
- m100: G,
134
- m200: J,
135
- m500: T
136
- } = ne(oe, A, se), X = (e, t) => () => !e && p(t), Y = ({ value: e, label: t, disabled: s }, u) => /* @__PURE__ */ te(
137
- re,
133
+ m50: G,
134
+ m100: J,
135
+ m200: T,
136
+ m500: X
137
+ } = re(se, A, ie), Y = (e, t) => () => !e && p(t), Z = ({ value: e, label: t, disabled: s }, u) => /* @__PURE__ */ ne(
138
+ oe,
138
139
  {
139
140
  value: e,
140
141
  label: t,
141
142
  isDisabled: s,
142
143
  onSelect: z,
143
- onMouseEnter: X(s, u),
144
+ onMouseEnter: Y(s, u),
144
145
  isSelected: e === i,
145
146
  isHighlighted: u === f,
146
147
  key: e,
147
148
  width: m,
148
- selectedColor: J,
149
- hoverColor: U,
150
- activeColor: G
149
+ selectedColor: T,
150
+ hoverColor: G,
151
+ activeColor: J
151
152
  }
152
- ), Z = (e) => {
153
+ ), _ = (e) => {
153
154
  D(e.target.value);
154
- }, _ = (e) => {
155
+ }, L = (e) => {
155
156
  e.stopPropagation();
156
157
  };
157
158
  return /* @__PURE__ */ r.jsxs(
158
- ie,
159
+ ce,
159
160
  {
160
161
  ref: g,
161
162
  $width: m,
162
163
  tabIndex: v ? -1 : 0,
163
- onKeyDown: N,
164
+ onKeyDown: U,
164
165
  $isLoading: $,
165
166
  $isDisabled: v,
166
167
  children: [
167
- /* @__PURE__ */ r.jsxs(ce, { $width: m, onClick: K, $isOpen: n, $border: T, children: [
168
- /* @__PURE__ */ r.jsx(le, { $width: m, color: i ? I.m700 : I.m500, size: "1.2rem", children: i ? o.find(({ value: e }) => i === e)?.label : P }),
169
- /* @__PURE__ */ r.jsx(fe, { color: I.m500, size: 22, $isOpen: n })
168
+ /* @__PURE__ */ r.jsxs(le, { $width: m, onClick: Q, $isOpen: n, $border: X, children: [
169
+ /* @__PURE__ */ r.jsx(fe, { $width: m, color: i ? I.m700 : I.m500, size: "1.2rem", children: i ? o.find(({ value: e }) => i === e)?.label : P }),
170
+ /* @__PURE__ */ r.jsx(ue, { color: I.m500, size: 22, $isOpen: n })
170
171
  ] }),
171
- /* @__PURE__ */ r.jsxs(ue, { $isOpen: n, $width: m, $height: O, $top: B === "top", children: [
172
- h && /* @__PURE__ */ r.jsxs(ae, { onClick: _, children: [
173
- /* @__PURE__ */ r.jsx(pe, { size: 18, color: I.m800 }),
172
+ /* @__PURE__ */ r.jsxs(ae, { $isOpen: n, $width: m, $height: O, $top: H === "top", children: [
173
+ h && /* @__PURE__ */ r.jsxs(pe, { onClick: L, children: [
174
+ /* @__PURE__ */ r.jsx(de, { size: 20, color: I.m600 }),
174
175
  /* @__PURE__ */ r.jsx(
175
- de,
176
+ me,
176
177
  {
177
178
  ref: k,
178
179
  value: b,
179
- onChange: Z,
180
- placeholder: "Search..."
180
+ onChange: _,
181
+ placeholder: B
181
182
  }
182
183
  )
183
184
  ] }),
184
- /* @__PURE__ */ r.jsxs(me, { ref: w, children: [
185
- c.map(Y),
186
- l && /* @__PURE__ */ r.jsx(he, { ref: R, children: a && /* @__PURE__ */ r.jsx(F, { size: "small", color: y }) })
185
+ /* @__PURE__ */ r.jsxs(he, { ref: w, children: [
186
+ c.map(Z),
187
+ l && /* @__PURE__ */ r.jsx(xe, { ref: R, children: a && /* @__PURE__ */ r.jsx(F, { size: "small", color: y }) })
187
188
  ] })
188
189
  ] }),
189
- $ && /* @__PURE__ */ r.jsx(xe, { children: /* @__PURE__ */ r.jsx(F, { size: "small", color: y }) })
190
+ $ && /* @__PURE__ */ r.jsx(be, { children: /* @__PURE__ */ r.jsx(F, { size: "small", color: y }) })
190
191
  ]
191
192
  }
192
193
  );
193
194
  };
194
195
  export {
195
- ve as default
196
+ ye as default
196
197
  };
@@ -115,7 +115,7 @@ const c = n`
115
115
  color: ${t.m400};
116
116
  }
117
117
  `, L = e(d)`
118
- margin: 0 1.2rem;
118
+ margin: 0 0.8rem;
119
119
  `, O = e.div`
120
120
  display: flex;
121
121
  justify-content: center;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meticulous-ui",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "repository": {