@purpurds/autocomplete 7.5.0 → 7.5.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.
@@ -1,6 +1,6 @@
1
1
  import { jsx as l, jsxs as j, Fragment as et } from "react/jsx-runtime";
2
2
  import * as m from "react";
3
- import { forwardRef as X, Children as qt, isValidElement as nt, useId as kt, useRef as K, useCallback as Ct, useEffect as Pt, useState as ar, cloneElement as Mt } from "react";
3
+ import { forwardRef as J, Children as qt, isValidElement as nt, useId as kt, useRef as Y, useCallback as Ct, useEffect as Pt, useState as ar, cloneElement as Mt } from "react";
4
4
  import "react-dom";
5
5
  function Rt(t) {
6
6
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
@@ -275,7 +275,7 @@ function ie() {
275
275
  }(Nr)), Nr.exports;
276
276
  }
277
277
  var oe = ie();
278
- const pe = /* @__PURE__ */ ae(oe), V = {
278
+ const pe = /* @__PURE__ */ ae(oe), Z = {
279
279
  "purpur-paragraph": "_purpur-paragraph_1rh57_1",
280
280
  "purpur-paragraph--disabled": "_purpur-paragraph--disabled_1rh57_7",
281
281
  "purpur-paragraph--hyphens": "_purpur-paragraph--hyphens_1rh57_10",
@@ -292,7 +292,7 @@ const pe = /* @__PURE__ */ ae(oe), V = {
292
292
  "purpur-paragraph--overline-200": "_purpur-paragraph--overline-200_1rh57_75"
293
293
  }, le = {
294
294
  PARAGRAPH100: "paragraph-100"
295
- }, Z = "purpur-paragraph", st = ({
295
+ }, H = "purpur-paragraph", st = ({
296
296
  ["data-testid"]: t,
297
297
  children: a,
298
298
  className: n,
@@ -304,18 +304,18 @@ const pe = /* @__PURE__ */ ae(oe), V = {
304
304
  }) => {
305
305
  const f = pe([
306
306
  n,
307
- V[Z],
308
- V[`${Z}--${e}`],
307
+ Z[H],
308
+ Z[`${H}--${e}`],
309
309
  {
310
- [V[`${Z}--hyphens`]]: o,
311
- [V[`${Z}--disabled`]]: i,
312
- [V[`${Z}--negative`]]: r
310
+ [Z[`${H}--hyphens`]]: o,
311
+ [Z[`${H}--disabled`]]: i,
312
+ [Z[`${H}--negative`]]: r
313
313
  }
314
314
  ]);
315
315
  return /* @__PURE__ */ l("p", { ...u, className: f, "data-testid": t, children: a });
316
316
  };
317
317
  st.displayName = "Paragraph";
318
- const Ar = it.bind(ot), B = "purpur-listbox", sr = X(
318
+ const Ar = it.bind(ot), B = "purpur-listbox", sr = J(
319
319
  (t, a) => {
320
320
  const { disabled: n, highlighted: i, hovered: o, selected: r, children: e, noninteractive: u, ...f } = t, y = Ar(`${B}-item`, f.className, {
321
321
  [`${B}-item--highlighted`]: i,
@@ -342,7 +342,7 @@ const Ar = it.bind(ot), B = "purpur-listbox", sr = X(
342
342
  }
343
343
  ), se = (t) => nt(t) && (t == null ? void 0 : t.type) === sr;
344
344
  sr.displayName = "ListBoxItem";
345
- const ce = it.bind(ot), de = "purpur-listbox", Y = X(
345
+ const ce = it.bind(ot), de = "purpur-listbox", X = J(
346
346
  ({ children: t, ...a }, n) => /* @__PURE__ */ l(
347
347
  "ul",
348
348
  {
@@ -354,8 +354,8 @@ const ce = it.bind(ot), de = "purpur-listbox", Y = X(
354
354
  }
355
355
  )
356
356
  );
357
- Y.Item = sr;
358
- Y.displayName = "ListBox";
357
+ X.Item = sr;
358
+ X.displayName = "ListBox";
359
359
  const _e = {
360
360
  LG: "lg"
361
361
  };
@@ -402,7 +402,7 @@ function ve() {
402
402
  }(Or)), Or.exports;
403
403
  }
404
404
  var me = ve();
405
- const kr = /* @__PURE__ */ fe(me), ge = "_rotate_12t9p_1", he = "_dash_12t9p_1", H = {
405
+ const kr = /* @__PURE__ */ fe(me), ge = "_rotate_12t9p_1", he = "_dash_12t9p_1", F = {
406
406
  "purpur-spinner": "_purpur-spinner_12t9p_2",
407
407
  rotate: ge,
408
408
  "purpur-spinner--xxs": "_purpur-spinner--xxs_12t9p_6",
@@ -414,7 +414,7 @@ const kr = /* @__PURE__ */ fe(me), ge = "_rotate_12t9p_1", he = "_dash_12t9p_1",
414
414
  dash: he,
415
415
  "purpur-spinner__circle--disabled": "_purpur-spinner__circle--disabled_12t9p_41",
416
416
  "purpur-spinner__circle--negative": "_purpur-spinner__circle--negative_12t9p_44"
417
- }, F = "purpur-spinner", be = {
417
+ }, W = "purpur-spinner", be = {
418
418
  SM: "sm"
419
419
  }, ye = ({
420
420
  ["data-testid"]: t,
@@ -425,15 +425,15 @@ const kr = /* @__PURE__ */ fe(me), ge = "_rotate_12t9p_1", he = "_dash_12t9p_1",
425
425
  }) => /* @__PURE__ */ l(
426
426
  "div",
427
427
  {
428
- className: kr([H[F], H[`${F}--${i}`]]),
428
+ className: kr([F[W], F[`${W}--${i}`]]),
429
429
  "data-testid": t,
430
430
  ...o,
431
431
  children: /* @__PURE__ */ l("svg", { viewBox: "0 0 50 50", children: /* @__PURE__ */ l(
432
432
  "circle",
433
433
  {
434
- className: kr(H[`${F}__circle`], {
435
- [H[`${F}__circle--disabled`]]: a,
436
- [H[`${F}__circle--negative`]]: n
434
+ className: kr(F[`${W}__circle`], {
435
+ [F[`${W}__circle--disabled`]]: a,
436
+ [F[`${W}__circle--negative`]]: n
437
437
  }),
438
438
  cx: "25",
439
439
  cy: "25",
@@ -557,7 +557,7 @@ const Se = /* @__PURE__ */ xe($e), Ne = {
557
557
  ]
558
558
  }
559
559
  );
560
- }, ct = X(Ae);
560
+ }, ct = J(Ae);
561
561
  ct.displayName = "Button";
562
562
  function Oe(t) {
563
563
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
@@ -1070,7 +1070,7 @@ function $n() {
1070
1070
  }(Yr)), Yr.exports;
1071
1071
  }
1072
1072
  var Sn = $n();
1073
- const Jr = /* @__PURE__ */ wn(Sn), Nn = "_rotate_12t9p_1", jn = "_dash_12t9p_1", W = {
1073
+ const Jr = /* @__PURE__ */ wn(Sn), Nn = "_rotate_12t9p_1", jn = "_dash_12t9p_1", G = {
1074
1074
  "purpur-spinner": "_purpur-spinner_12t9p_2",
1075
1075
  rotate: Nn,
1076
1076
  "purpur-spinner--xxs": "_purpur-spinner--xxs_12t9p_6",
@@ -1082,7 +1082,7 @@ const Jr = /* @__PURE__ */ wn(Sn), Nn = "_rotate_12t9p_1", jn = "_dash_12t9p_1",
1082
1082
  dash: jn,
1083
1083
  "purpur-spinner__circle--disabled": "_purpur-spinner__circle--disabled_12t9p_41",
1084
1084
  "purpur-spinner__circle--negative": "_purpur-spinner__circle--negative_12t9p_44"
1085
- }, G = "purpur-spinner", An = {
1085
+ }, U = "purpur-spinner", An = {
1086
1086
  SM: "sm"
1087
1087
  }, On = ({
1088
1088
  ["data-testid"]: t,
@@ -1093,15 +1093,15 @@ const Jr = /* @__PURE__ */ wn(Sn), Nn = "_rotate_12t9p_1", jn = "_dash_12t9p_1",
1093
1093
  }) => /* @__PURE__ */ l(
1094
1094
  "div",
1095
1095
  {
1096
- className: Jr([W[G], W[`${G}--${i}`]]),
1096
+ className: Jr([G[U], G[`${U}--${i}`]]),
1097
1097
  "data-testid": t,
1098
1098
  ...o,
1099
1099
  children: /* @__PURE__ */ l("svg", { viewBox: "0 0 50 50", children: /* @__PURE__ */ l(
1100
1100
  "circle",
1101
1101
  {
1102
- className: Jr(W[`${G}__circle`], {
1103
- [W[`${G}__circle--disabled`]]: a,
1104
- [W[`${G}__circle--negative`]]: n
1102
+ className: Jr(G[`${U}__circle`], {
1103
+ [G[`${U}__circle--disabled`]]: a,
1104
+ [G[`${U}__circle--negative`]]: n
1105
1105
  }),
1106
1106
  cx: "25",
1107
1107
  cy: "25",
@@ -1170,7 +1170,7 @@ const Pn = /* @__PURE__ */ qn(Cn), Mn = {
1170
1170
  "purpur-text-field__input--error": "_purpur-text-field__input--error_3gl1k_94",
1171
1171
  "purpur-text-field__adornment-container": "_purpur-text-field__adornment-container_3gl1k_106",
1172
1172
  "purpur-text-field__valid-icon": "_purpur-text-field__valid-icon_3gl1k_111"
1173
- }, Rn = (t) => K(t), k = Pn.bind(Mn), v = "purpur-text-field", Ln = ({
1173
+ }, Rn = (t) => Y(t), k = Pn.bind(Mn), v = "purpur-text-field", Ln = ({
1174
1174
  ["data-testid"]: t,
1175
1175
  className: a,
1176
1176
  clearButtonAriaLabel: n,
@@ -1189,7 +1189,7 @@ const Pn = /* @__PURE__ */ qn(Cn), Mn = {
1189
1189
  var N;
1190
1190
  const w = kt(), s = _.id ?? w, g = (h) => t ? `${t}-${h}` : void 0, C = S && !e, M = u ? `${s}-helper-text` : void 0, T = [A].filter((h) => !!h), d = (typeof _.value == "number" ? _.value !== void 0 : (N = _.value) == null ? void 0 : N.length) && !_.disabled && !_.readOnly && !y && x && n, O = Rn(null), I = (h) => {
1191
1191
  O.current = h, typeof $ == "function" ? $(h) : $ && ($.current = h);
1192
- }, J = () => {
1192
+ }, Q = () => {
1193
1193
  var h;
1194
1194
  x == null || x(), (h = O.current) == null || h.focus();
1195
1195
  }, R = [
@@ -1206,7 +1206,7 @@ const Pn = /* @__PURE__ */ qn(Cn), Mn = {
1206
1206
  ct,
1207
1207
  {
1208
1208
  variant: "tertiary-purple",
1209
- onClick: J,
1209
+ onClick: Q,
1210
1210
  iconOnly: !0,
1211
1211
  "aria-label": n ?? "",
1212
1212
  "data-testid": g("clear-button"),
@@ -1294,7 +1294,7 @@ const Pn = /* @__PURE__ */ qn(Cn), Mn = {
1294
1294
  M && /* @__PURE__ */ l(Ue, { "data-testid": g("helper-text"), id: M, children: u }),
1295
1295
  e && /* @__PURE__ */ l(Ze, { "data-testid": g("error-text"), children: e })
1296
1296
  ] });
1297
- }, gt = X(Ln);
1297
+ }, gt = J(Ln);
1298
1298
  gt.displayName = "TextField";
1299
1299
  const Bn = (t) => nt(t) && t.type.displayName === gt.displayName;
1300
1300
  function En(t) {
@@ -1346,7 +1346,7 @@ const zn = /* @__PURE__ */ En(In), Dn = {
1346
1346
  "purpur-autocomplete__chevron-button": "_purpur-autocomplete__chevron-button_1u8x6_9",
1347
1347
  "purpur-autocomplete__chevron-icon": "_purpur-autocomplete__chevron-icon_1u8x6_15",
1348
1348
  "purpur-autocomplete__chevron-icon--up": "_purpur-autocomplete__chevron-icon--up_1u8x6_19"
1349
- }, Vn = (t) => K(t), Zn = (t, a) => {
1349
+ }, Vn = (t) => Y(t), Zn = (t, a) => {
1350
1350
  const n = Ct(
1351
1351
  (i) => {
1352
1352
  t && !t.contains(i.target) && a();
@@ -1379,15 +1379,15 @@ const zn = /* @__PURE__ */ En(In), Dn = {
1379
1379
  }) => {
1380
1380
  const [C, M] = ar(
1381
1381
  ((typeof i == "string" ? i : n) || (s == null ? void 0 : s.label)) ?? ""
1382
- ), T = typeof i == "string" ? i : C, [d, O] = ar(a ? w[0] : void 0), I = K(null), J = Vn(null), R = K(null), z = K({}), [h, dr] = ar(!1);
1382
+ ), T = typeof i == "string" ? i : C, [d, O] = ar(a ? w[0] : void 0), I = Y(null), Q = Vn(null), R = Y(null), z = Y({}), [h, dr] = ar(!1);
1383
1383
  function tr(p) {
1384
1384
  return g ? `${g}-${p}` : void 0;
1385
1385
  }
1386
- const Q = () => {
1386
+ const D = () => {
1387
1387
  dr(!1), O(void 0);
1388
1388
  };
1389
- Zn(J.current, Q);
1390
- const D = ({ eventType: p }) => {
1389
+ Zn(Q.current, D);
1390
+ const V = ({ eventType: p }) => {
1391
1391
  dr(!0), s && requestAnimationFrame(() => {
1392
1392
  O({ ...s, isSetByClickEvent: p === "CLICK" }), nr(z.current[s.id]);
1393
1393
  });
@@ -1412,12 +1412,12 @@ const zn = /* @__PURE__ */ En(In), Dn = {
1412
1412
  }
1413
1413
  }, fr = (p) => {
1414
1414
  var c;
1415
- p && ((c = I.current) == null || c.focus(), er(p.label), N == null || N(p)), Q();
1415
+ p && ((c = I.current) == null || c.focus(), er(p.label), N == null || N(p)), D();
1416
1416
  }, bt = (p) => {
1417
1417
  const c = a && !d ? 0 : P.findIndex((q) => q && (d == null ? void 0 : d.id) === q.id), b = P.length;
1418
1418
  return p === "ArrowDown" ? P[(c ?? -1) + 1] || P[0] : P[(c ?? b) - 1] || P[b - 1];
1419
1419
  }, L = h && (!!P.length || !!$), yt = (p) => {
1420
- !L && D({ eventType: "KEYBOARD" });
1420
+ !L && V({ eventType: "KEYBOARD" });
1421
1421
  const c = bt(p);
1422
1422
  O(c), c && nr(z.current[c.id]);
1423
1423
  }, xt = (p) => {
@@ -1428,26 +1428,26 @@ const zn = /* @__PURE__ */ En(In), Dn = {
1428
1428
  break;
1429
1429
  case "Enter": {
1430
1430
  const c = d || (a ? w[0] : void 0);
1431
- L && fr(c), !L && D({ eventType: "KEYBOARD" });
1431
+ L && fr(c), !L && V({ eventType: "KEYBOARD" });
1432
1432
  break;
1433
1433
  }
1434
1434
  case "Escape":
1435
1435
  case "Tab":
1436
- Q();
1436
+ D();
1437
1437
  break;
1438
1438
  }
1439
1439
  }, wt = (p) => {
1440
1440
  const c = _r(p.target.value);
1441
- er(p.target.value), O(void 0), !L && D({ eventType: "KEYBOARD" }), a && c[0] && nr(z.current[c[0].id]);
1441
+ er(p.target.value), O(void 0), !L && V({ eventType: "KEYBOARD" }), a && c[0] && nr(z.current[c[0].id]);
1442
1442
  }, $t = (p) => {
1443
- S == null || S(p), L ? Q() : D({ eventType: "CLICK" });
1443
+ S == null || S(p), L ? D() : V({ eventType: "CLICK" });
1444
1444
  }, St = (p) => {
1445
1445
  var c;
1446
- x == null || x(p), !h && _ && D({ eventType: "KEYBOARD" }), (c = I.current) == null || c.select();
1446
+ x == null || x(p), !h && _ && V({ eventType: "KEYBOARD" }), (c = I.current) == null || c.select();
1447
1447
  }, Nt = (p) => {
1448
- f == null || f(p), t && setTimeout(() => {
1448
+ f == null || f(p), setTimeout(() => {
1449
1449
  var c, b;
1450
- !((c = I.current) != null && c.contains(document.activeElement)) && !((b = R.current) != null && b.contains(document.activeElement)) && er(s ? s.label : "");
1450
+ !((c = I.current) != null && c.contains(document.activeElement)) && !((b = R.current) != null && b.contains(document.activeElement)) && (D(), t && er(s ? s.label : ""));
1451
1451
  });
1452
1452
  }, jt = {
1453
1453
  maxHeight: typeof u == "number" ? `${u}px` : u
@@ -1495,7 +1495,7 @@ const zn = /* @__PURE__ */ En(In), Dn = {
1495
1495
  return {
1496
1496
  id: r,
1497
1497
  inputProps: Ot,
1498
- internalRef: J,
1498
+ internalRef: Q,
1499
1499
  optionsToShow: P,
1500
1500
  showListbox: L,
1501
1501
  noOptionsText: $,
@@ -1503,7 +1503,7 @@ const zn = /* @__PURE__ */ En(In), Dn = {
1503
1503
  getListBoxItemProps: At,
1504
1504
  listboxProps: vr
1505
1505
  };
1506
- }, rr = zn.bind(Dn), U = "purpur-autocomplete", Fn = ({ className: t, renderInput: a, renderOption: n, ...i }, o) => {
1506
+ }, rr = zn.bind(Dn), K = "purpur-autocomplete", Fn = ({ className: t, renderInput: a, renderOption: n, ...i }, o) => {
1507
1507
  const {
1508
1508
  id: r,
1509
1509
  inputProps: e,
@@ -1516,7 +1516,7 @@ const zn = /* @__PURE__ */ En(In), Dn = {
1516
1516
  listboxProps: _
1517
1517
  } = Hn(i), $ = (s, g) => {
1518
1518
  const { key: C, ...M } = S(s, g);
1519
- return /* @__PURE__ */ l(Y.Item, { ...M, children: n ? n == null ? void 0 : n(s) : s.label }, C);
1519
+ return /* @__PURE__ */ l(X.Item, { ...M, children: n ? n == null ? void 0 : n(s) : s.label }, C);
1520
1520
  }, N = (s) => {
1521
1521
  u.current = s, typeof o == "function" ? o(s) : o && (o.current = s);
1522
1522
  }, w = () => {
@@ -1529,7 +1529,7 @@ const zn = /* @__PURE__ */ En(In), Dn = {
1529
1529
  {
1530
1530
  "data-testid": "chevron button",
1531
1531
  type: "button",
1532
- className: rr(`${U}__chevron-button`),
1532
+ className: rr(`${K}__chevron-button`),
1533
1533
  onClick: () => {
1534
1534
  e.onFocus(void 0), e.onMouseDown(void 0);
1535
1535
  },
@@ -1538,8 +1538,8 @@ const zn = /* @__PURE__ */ En(In), Dn = {
1538
1538
  at,
1539
1539
  {
1540
1540
  size: "sm",
1541
- className: rr(`${U}__chevron-icon`, {
1542
- [`${U}__chevron-icon--up`]: y
1541
+ className: rr(`${K}__chevron-icon`, {
1542
+ [`${K}__chevron-icon--up`]: y
1543
1543
  })
1544
1544
  }
1545
1545
  )
@@ -1550,11 +1550,11 @@ const zn = /* @__PURE__ */ En(In), Dn = {
1550
1550
  }
1551
1551
  return s;
1552
1552
  };
1553
- return /* @__PURE__ */ j("div", { id: r, ref: N, className: rr([t, U]), children: [
1553
+ return /* @__PURE__ */ j("div", { id: r, ref: N, className: rr([t, K]), children: [
1554
1554
  w(),
1555
- y && /* @__PURE__ */ l(Y, { ..._, className: rr(`${U}__listbox`), children: f.length ? f.filter((s) => !!s).map($) : /* @__PURE__ */ l(Y.Item, { noninteractive: !0, children: x }) })
1555
+ y && /* @__PURE__ */ l(X, { ..._, className: rr(`${K}__listbox`), children: f.length ? f.filter((s) => !!s).map($) : /* @__PURE__ */ l(X.Item, { noninteractive: !0, children: x }) })
1556
1556
  ] });
1557
- }, Wn = X(Fn);
1557
+ }, Wn = J(Fn);
1558
1558
  Wn.displayName = "Autocomplete";
1559
1559
  export {
1560
1560
  Wn as Autocomplete,