@purpurds/autocomplete 5.6.0 → 5.8.0

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.
@@ -97,7 +97,7 @@ const $r = /* @__PURE__ */ Ar(Rr), Ir = {
97
97
  svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M21.06 3.795a.9.9 0 0 1 .145 1.264l-11.5 14.5a.9.9 0 0 1-1.341.077l-6-6a.9.9 0 0 1 1.272-1.272l5.286 5.286L19.795 3.94a.9.9 0 0 1 1.264-.145Z" clip-rule="evenodd"/></svg>',
98
98
  keywords: ["checkmark"],
99
99
  category: "utility"
100
- }, Er = $r.bind(Ir), J = "purpur-icon", Nr = "md", Pr = (t) => t.filter((s) => Object.keys(s).length >= 1).map((s) => `${s.name}="${s.value}"`).join(" "), Sr = ({ content: t = "", title: s } = {}) => {
100
+ }, Er = $r.bind(Ir), Z = "purpur-icon", Nr = "md", Pr = (t) => t.filter((s) => Object.keys(s).length >= 1).map((s) => `${s.name}="${s.value}"`).join(" "), Sr = ({ content: t = "", title: s } = {}) => {
101
101
  const n = [
102
102
  { name: "xmlns", value: "http://www.w3.org/2000/svg" },
103
103
  { name: "fill", value: "currentColor" },
@@ -116,7 +116,7 @@ const $r = /* @__PURE__ */ Ar(Rr), Ir = {
116
116
  const e = Sr({
117
117
  content: Cr(s.svg),
118
118
  title: n
119
- }), o = Er(l, J, `${J}--${i}`);
119
+ }), o = Er(l, Z, `${Z}--${i}`);
120
120
  return /* @__PURE__ */ g(
121
121
  "span",
122
122
  {
@@ -128,7 +128,7 @@ const $r = /* @__PURE__ */ Ar(Rr), Ir = {
128
128
  }
129
129
  );
130
130
  };
131
- function Dr(t) {
131
+ function kr(t) {
132
132
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
133
133
  }
134
134
  var nr = { exports: {} };
@@ -167,8 +167,8 @@ var nr = { exports: {} };
167
167
  t.exports ? (n.default = n, t.exports = n) : window.classNames = n;
168
168
  })();
169
169
  })(nr);
170
- var kr = nr.exports;
171
- const Mr = /* @__PURE__ */ Dr(kr), $ = {
170
+ var Dr = nr.exports;
171
+ const Mr = /* @__PURE__ */ kr(Dr), $ = {
172
172
  "purpur-paragraph": "_purpur-paragraph_1rh57_1",
173
173
  "purpur-paragraph--disabled": "_purpur-paragraph--disabled_1rh57_7",
174
174
  "purpur-paragraph--hyphens": "_purpur-paragraph--hyphens_1rh57_10",
@@ -223,7 +223,7 @@ const Mr = /* @__PURE__ */ Dr(kr), $ = {
223
223
  "purpur-listbox-item--noninteractive": "_purpur-listbox-item--noninteractive_qhoi7_41",
224
224
  "purpur-listbox-item--disabled": "_purpur-listbox-item--disabled_qhoi7_44",
225
225
  "purpur-listbox-item__icon": "_purpur-listbox-item__icon_qhoi7_51"
226
- }, Vr = (t) => S(t), Kr = (t, s) => {
226
+ }, Or = (t) => S(t), Vr = (t, s) => {
227
227
  const n = hr(
228
228
  (l) => {
229
229
  t && !t.contains(l.target) && s();
@@ -233,7 +233,7 @@ const Mr = /* @__PURE__ */ Dr(kr), $ = {
233
233
  br(() => (document.addEventListener("mousedown", n), () => {
234
234
  document.removeEventListener("mousedown", n);
235
235
  }), [n]);
236
- }, Or = ({
236
+ }, Kr = ({
237
237
  highlightFirstOption: t,
238
238
  defaultInputValue: s,
239
239
  inputValue: n,
@@ -249,19 +249,19 @@ const Mr = /* @__PURE__ */ Dr(kr), $ = {
249
249
  selectedOption: c,
250
250
  ["data-testid"]: L
251
251
  }) => {
252
- const [V, m] = M(
252
+ const [O, m] = M(
253
253
  (typeof n == "string" ? n : s) || (c == null ? void 0 : c.label)
254
- ), E = typeof n == "string" ? n : V, [u, b] = M(t ? h[0] : void 0), C = S(null), K = Vr(null), O = S(null), N = S({}), [H, U] = M(!1);
254
+ ), E = typeof n == "string" ? n : O, [u, b] = M(t ? h[0] : void 0), C = S(null), V = Or(null), K = S(null), N = S({}), [H, U] = M(!1);
255
255
  function B(a) {
256
256
  return L ? `${L}-${a}` : void 0;
257
257
  }
258
258
  const P = () => {
259
259
  U(!1), b(void 0);
260
260
  };
261
- Kr(K.current, P);
261
+ Vr(V.current, P);
262
262
  const R = ({ eventType: a }) => {
263
263
  U(!0), c && requestAnimationFrame(() => {
264
- b({ ...c, isSetByClickEvent: a === "CLICK" }), D(N.current[c.id]);
264
+ b({ ...c, isSetByClickEvent: a === "CLICK" }), k(N.current[c.id]);
265
265
  });
266
266
  }, sr = (a) => {
267
267
  if (l)
@@ -276,10 +276,10 @@ const Mr = /* @__PURE__ */ Dr(kr), $ = {
276
276
  );
277
277
  }, G = (a) => c && (c == null ? void 0 : c.label) === a ? h : sr(a), v = G(E), Y = (a) => {
278
278
  o == null || o(a), m(a);
279
- }, D = (a) => {
279
+ }, k = (a) => {
280
280
  var p;
281
281
  if (a) {
282
- const d = a.getBoundingClientRect(), f = ((p = O.current) == null ? void 0 : p.getBoundingClientRect()) || { top: 0, bottom: 0 };
282
+ const d = a.getBoundingClientRect(), f = ((p = K.current) == null ? void 0 : p.getBoundingClientRect()) || { top: 0, bottom: 0 };
283
283
  (d.top < f.top || d.bottom > f.bottom) && a.scrollIntoView({ block: "nearest" });
284
284
  }
285
285
  }, z = (a) => {
@@ -291,7 +291,7 @@ const Mr = /* @__PURE__ */ Dr(kr), $ = {
291
291
  }, y = H && (!!v.length || !!w), ir = (a) => {
292
292
  !y && R({ eventType: "KEYBOARD" });
293
293
  const p = ur(a);
294
- b(p), p && D(N.current[p.id]);
294
+ b(p), p && k(N.current[p.id]);
295
295
  }, pr = (a) => {
296
296
  switch (a.key) {
297
297
  case "ArrowUp":
@@ -310,7 +310,7 @@ const Mr = /* @__PURE__ */ Dr(kr), $ = {
310
310
  }
311
311
  }, lr = (a) => {
312
312
  const p = G(a.target.value);
313
- Y(a.target.value), b(void 0), !y && R({ eventType: "KEYBOARD" }), t && p[0] && D(N.current[p[0].id]);
313
+ Y(a.target.value), b(void 0), !y && R({ eventType: "KEYBOARD" }), t && p[0] && k(N.current[p[0].id]);
314
314
  }, cr = () => {
315
315
  y ? P() : R({ eventType: "CLICK" });
316
316
  }, dr = () => {
@@ -323,18 +323,18 @@ const Mr = /* @__PURE__ */ Dr(kr), $ = {
323
323
  "aria-expanded": y,
324
324
  "data-testid": B("listbox"),
325
325
  id: `${i}-listbox`,
326
- ref: O,
326
+ ref: K,
327
327
  onMouseLeave: () => b(void 0),
328
328
  style: e ? mr : void 0
329
- }, Z = (a) => `${i}-listbox-item-${a.id}`, _r = (a, p) => {
329
+ }, W = (a) => `${i}-listbox-item-${a.id}`, _r = (a, p) => {
330
330
  const d = () => a.id !== (u == null ? void 0 : u.id) && b({ ...a, isSetByClickEvent: !0 }), f = (a.id === (u == null ? void 0 : u.id) || !!t && !u && p === 0) && !(u != null && u.isSetByClickEvent);
331
331
  return {
332
332
  "data-testid": B(`listbox-item-${a.id}`),
333
- id: Z(a),
333
+ id: W(a),
334
334
  key: a.id,
335
335
  onMouseMove: d,
336
336
  onMouseUp: () => z(a),
337
- ref: (k) => k && (N.current[a.id] = k),
337
+ ref: (D) => D && (N.current[a.id] = D),
338
338
  tabIndex: -1,
339
339
  selected: a.id === (c == null ? void 0 : c.id),
340
340
  disabled: a.disabled,
@@ -342,7 +342,7 @@ const Mr = /* @__PURE__ */ Dr(kr), $ = {
342
342
  hovered: a.id === (u == null ? void 0 : u.id) && !!(u != null && u.isSetByClickEvent)
343
343
  };
344
344
  }, fr = {
345
- "aria-activedescendant": u ? Z(u) : void 0,
345
+ "aria-activedescendant": u ? W(u) : void 0,
346
346
  "aria-autocomplete": "list",
347
347
  "aria-controls": F.id,
348
348
  "data-testid": B("input"),
@@ -359,7 +359,7 @@ const Mr = /* @__PURE__ */ Dr(kr), $ = {
359
359
  return {
360
360
  id: i,
361
361
  inputProps: fr,
362
- internalRef: K,
362
+ internalRef: V,
363
363
  optionsToShow: v,
364
364
  showListbox: y,
365
365
  noOptionsText: w,
@@ -407,7 +407,7 @@ T.displayName = "ListBoxItem";
407
407
  function Hr(t) {
408
408
  return xr(t) && (t == null ? void 0 : t.type) === T;
409
409
  }
410
- const Ur = or, Q = T, W = er.bind(wr), X = "purpur-autocomplete", Gr = ({ className: t, renderInput: s, renderOption: n, ...l }, i) => {
410
+ const Ur = or, J = T, Q = er.bind(wr), X = "purpur-autocomplete", Gr = ({ className: t, renderInput: s, renderOption: n, ...l }, i) => {
411
411
  const {
412
412
  id: r,
413
413
  inputProps: e,
@@ -417,20 +417,20 @@ const Ur = or, Q = T, W = er.bind(wr), X = "purpur-autocomplete", Gr = ({ classN
417
417
  noOptionsText: A,
418
418
  getListBoxItemProps: h,
419
419
  listboxProps: c
420
- } = Or(l), L = (m, E) => {
420
+ } = Kr(l), L = (m, E) => {
421
421
  const { key: u, ...b } = h(m, E);
422
- return /* @__PURE__ */ g(Q, { ...b, children: n ? n == null ? void 0 : n(m) : m.label }, u);
422
+ return /* @__PURE__ */ g(J, { ...b, children: n ? n == null ? void 0 : n(m) : m.label }, u);
423
423
  };
424
424
  return /* @__PURE__ */ rr("div", { id: r, ref: (m) => {
425
425
  o.current = m, typeof i == "function" ? i(m) : i && (i.current = m);
426
- }, className: W([t, X]), children: [
426
+ }, className: Q([t, X]), children: [
427
427
  s(e),
428
- w && /* @__PURE__ */ g(Ur, { ...c, className: W(`${X}__listbox`), children: _.length ? _.filter((m) => !!m).map(L) : /* @__PURE__ */ g(Q, { noninteractive: !0, children: A }) })
428
+ w && /* @__PURE__ */ g(Ur, { ...c, className: Q(`${X}__listbox`), children: _.length ? _.filter((m) => !!m).map(L) : /* @__PURE__ */ g(J, { noninteractive: !0, children: A }) })
429
429
  ] });
430
430
  }, Yr = q(Gr);
431
431
  Yr.displayName = "Autocomplete";
432
432
  export {
433
433
  Yr as Autocomplete,
434
- Or as useAutocomplete
434
+ Kr as useAutocomplete
435
435
  };
436
436
  //# sourceMappingURL=autocomplete.es.js.map