@purpurds/autocomplete 5.4.1 → 5.4.2

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,4 +1,4 @@
1
- import { jsx as y, jsxs as rr } from "react/jsx-runtime";
1
+ import { jsx as g, jsxs as rr } from "react/jsx-runtime";
2
2
  import { useRef as S, useCallback as hr, useEffect as br, useState as M, forwardRef as q, Children as vr, isValidElement as xr } from "react";
3
3
  function gr(t) {
4
4
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
@@ -117,7 +117,7 @@ const $r = /* @__PURE__ */ Ar(Rr), Ir = {
117
117
  content: Cr(s.svg),
118
118
  title: n
119
119
  }), o = Er(l, J, `${J}--${i}`);
120
- return /* @__PURE__ */ y(
120
+ return /* @__PURE__ */ g(
121
121
  "span",
122
122
  {
123
123
  "aria-label": n,
@@ -214,7 +214,7 @@ const Mr = /* @__PURE__ */ Dr(kr), $ = {
214
214
  [$[`${I}--negative`]]: r
215
215
  }
216
216
  ]);
217
- return /* @__PURE__ */ y("p", { ...o, className: _, "data-testid": t, children: s });
217
+ return /* @__PURE__ */ g("p", { ...o, className: _, "data-testid": t, children: s });
218
218
  }, Tr = {
219
219
  "purpur-listbox": "_purpur-listbox_qhoi7_1",
220
220
  "purpur-listbox-item": "_purpur-listbox-item_qhoi7_15",
@@ -288,8 +288,8 @@ const Mr = /* @__PURE__ */ Dr(kr), $ = {
288
288
  }, ur = (a) => {
289
289
  const p = t && !u ? 0 : v.findIndex((f) => f && (u == null ? void 0 : u.id) === f.id), d = v.length;
290
290
  return a === "ArrowDown" ? v[(p ?? -1) + 1] || v[0] : v[(p ?? d) - 1] || v[d - 1];
291
- }, x = H && (!!v.length || !!w), ir = (a) => {
292
- !x && R({ eventType: "KEYBOARD" });
291
+ }, y = H && (!!v.length || !!w), ir = (a) => {
292
+ !y && R({ eventType: "KEYBOARD" });
293
293
  const p = ur(a);
294
294
  b(p), p && D(N.current[p.id]);
295
295
  }, pr = (a) => {
@@ -300,7 +300,7 @@ const Mr = /* @__PURE__ */ Dr(kr), $ = {
300
300
  break;
301
301
  case "Enter": {
302
302
  const p = u || (t ? h[0] : void 0);
303
- x && z(p), !x && R({ eventType: "KEYBOARD" });
303
+ y && z(p), !y && R({ eventType: "KEYBOARD" });
304
304
  break;
305
305
  }
306
306
  case "Escape":
@@ -310,9 +310,9 @@ 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), !x && 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] && D(N.current[p[0].id]);
314
314
  }, cr = () => {
315
- x ? P() : R({ eventType: "CLICK" });
315
+ y ? P() : R({ eventType: "CLICK" });
316
316
  }, dr = () => {
317
317
  var a;
318
318
  !H && _ && R({ eventType: "KEYBOARD" }), (a = C.current) == null || a.select();
@@ -320,7 +320,7 @@ const Mr = /* @__PURE__ */ Dr(kr), $ = {
320
320
  maxHeight: typeof e == "number" ? `${e}px` : e
321
321
  }, F = {
322
322
  "aria-label": r,
323
- "aria-expanded": x,
323
+ "aria-expanded": y,
324
324
  "data-testid": B("listbox"),
325
325
  id: `${i}-listbox`,
326
326
  ref: O,
@@ -345,7 +345,6 @@ const Mr = /* @__PURE__ */ Dr(kr), $ = {
345
345
  "aria-activedescendant": u ? Z(u) : void 0,
346
346
  "aria-autocomplete": "list",
347
347
  "aria-controls": F.id,
348
- "aria-expanded": x,
349
348
  "data-testid": B("input"),
350
349
  autoComplete: "off",
351
350
  id: `${i}-input`,
@@ -362,18 +361,18 @@ const Mr = /* @__PURE__ */ Dr(kr), $ = {
362
361
  inputProps: fr,
363
362
  internalRef: K,
364
363
  optionsToShow: v,
365
- showListbox: x,
364
+ showListbox: y,
366
365
  noOptionsText: w,
367
366
  getListBoxItemProps: _r,
368
367
  listboxProps: F
369
368
  };
370
- }, j = er.bind(Tr), g = "purpur-listbox", or = q(
371
- ({ children: t, ...s }, n) => /* @__PURE__ */ y(
369
+ }, j = er.bind(Tr), x = "purpur-listbox", or = q(
370
+ ({ children: t, ...s }, n) => /* @__PURE__ */ g(
372
371
  "ul",
373
372
  {
374
373
  ...s,
375
374
  ref: n,
376
- className: j(g, s.className),
375
+ className: j(x, s.className),
377
376
  role: "listbox",
378
377
  children: vr.toArray(t).filter(Hr)
379
378
  }
@@ -381,12 +380,12 @@ const Mr = /* @__PURE__ */ Dr(kr), $ = {
381
380
  );
382
381
  or.displayName = "ListBox";
383
382
  const T = q((t, s) => {
384
- const { disabled: n, highlighted: l, hovered: i, selected: r, children: e, noninteractive: o, ..._ } = t, w = j(`${g}-item`, _.className, {
385
- [`${g}-item--highlighted`]: l,
386
- [`${g}-item--selected`]: r,
387
- [`${g}-item--hovered`]: i,
388
- [`${g}-item--disabled`]: n,
389
- [`${g}-item--noninteractive`]: o
383
+ const { disabled: n, highlighted: l, hovered: i, selected: r, children: e, noninteractive: o, ..._ } = t, w = j(`${x}-item`, _.className, {
384
+ [`${x}-item--highlighted`]: l,
385
+ [`${x}-item--selected`]: r,
386
+ [`${x}-item--hovered`]: i,
387
+ [`${x}-item--disabled`]: n,
388
+ [`${x}-item--noninteractive`]: o
390
389
  });
391
390
  return /* @__PURE__ */ rr(
392
391
  "li",
@@ -398,8 +397,8 @@ const T = q((t, s) => {
398
397
  role: "option",
399
398
  "aria-disabled": !!n,
400
399
  children: [
401
- typeof e == "string" ? /* @__PURE__ */ y(qr, { children: e }) : e,
402
- r && /* @__PURE__ */ y(Br, { svg: Lr, size: "xs", className: j(`${g}-item__icon`) })
400
+ typeof e == "string" ? /* @__PURE__ */ g(qr, { children: e }) : e,
401
+ r && /* @__PURE__ */ g(Br, { svg: Lr, size: "xs", className: j(`${x}-item__icon`) })
403
402
  ]
404
403
  }
405
404
  );
@@ -420,13 +419,13 @@ const Ur = or, Q = T, W = er.bind(wr), X = "purpur-autocomplete", Gr = ({ classN
420
419
  listboxProps: c
421
420
  } = Or(l), L = (m, E) => {
422
421
  const { key: u, ...b } = h(m, E);
423
- return /* @__PURE__ */ y(Q, { ...b, children: n ? n == null ? void 0 : n(m) : m.label }, u);
422
+ return /* @__PURE__ */ g(Q, { ...b, children: n ? n == null ? void 0 : n(m) : m.label }, u);
424
423
  };
425
424
  return /* @__PURE__ */ rr("div", { id: r, ref: (m) => {
426
425
  o.current = m, typeof i == "function" ? i(m) : i && (i.current = m);
427
426
  }, className: W([t, X]), children: [
428
427
  s(e),
429
- w && /* @__PURE__ */ y(Ur, { ...c, className: W(`${X}__listbox`), children: _.length ? _.filter((m) => !!m).map(L) : /* @__PURE__ */ y(Q, { noninteractive: !0, children: A }) })
428
+ w && /* @__PURE__ */ g(Ur, { ...c, className: W(`${X}__listbox`), children: _.length ? _.filter((m) => !!m).map(L) : /* @__PURE__ */ g(Q, { noninteractive: !0, children: A }) })
430
429
  ] });
431
430
  }, Yr = q(Gr);
432
431
  Yr.displayName = "Autocomplete";