@jirawatpyk/aura-react 5.1.0 → 5.2.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.
Files changed (48) hide show
  1. package/README.md +10 -0
  2. package/dist/aura.bundle.js +562 -183
  3. package/dist/cjs/index.cjs +562 -183
  4. package/dist/esm/AppShell.js +10 -2
  5. package/dist/esm/Avatar.js +4 -3
  6. package/dist/esm/BottomNav.js +2 -1
  7. package/dist/esm/Checkbox.js +3 -2
  8. package/dist/esm/Combobox.js +19 -19
  9. package/dist/esm/Command.js +1 -0
  10. package/dist/esm/DataTable.js +116 -29
  11. package/dist/esm/DatePicker.js +85 -22
  12. package/dist/esm/DropdownMenu.js +12 -0
  13. package/dist/esm/FileUpload.js +17 -1
  14. package/dist/esm/FormErrorSummary.js +19 -4
  15. package/dist/esm/Menu.js +20 -7
  16. package/dist/esm/NumberField.js +3 -1
  17. package/dist/esm/Pagination.js +3 -3
  18. package/dist/esm/Popover.js +26 -5
  19. package/dist/esm/RadioGroup.js +14 -1
  20. package/dist/esm/SideNav.js +2 -1
  21. package/dist/esm/Switch.js +1 -1
  22. package/dist/esm/Table.js +3 -2
  23. package/dist/esm/Tabs.js +11 -7
  24. package/dist/esm/TextField.js +2 -2
  25. package/dist/esm/Textarea.js +2 -2
  26. package/dist/esm/ThemeStyle.js +13 -3
  27. package/dist/esm/TimePicker.js +2 -1
  28. package/dist/esm/Toaster.js +1 -0
  29. package/dist/esm/Tooltip.js +54 -29
  30. package/dist/esm/colorScheme.js +7 -3
  31. package/dist/esm/colorSchemeScript.js +3 -3
  32. package/dist/esm/dates.js +34 -13
  33. package/dist/esm/internal.js +18 -7
  34. package/dist/esm/locale.js +6 -5
  35. package/dist/esm/strings.js +21 -0
  36. package/dist/esm/text.js +1 -0
  37. package/dist/esm/theme.js +3 -1
  38. package/dist/esm/useModal.js +31 -8
  39. package/dist/index.d.cts +1513 -0
  40. package/dist/index.d.ts +6 -1
  41. package/dist/server/index.cjs +51 -10
  42. package/dist/server/index.d.cts +182 -0
  43. package/dist/server/index.d.ts +6 -0
  44. package/dist/server/index.js +51 -10
  45. package/dist/styles.css +26 -5
  46. package/dist/styles.layer.css +26 -5
  47. package/package.json +19 -8
  48. package/scripts/aura-theme.mjs +31 -6
@@ -138,14 +138,21 @@ function omit(src, keys) {
138
138
  }
139
139
  function useMaybeControlled(value, initial, onChange) {
140
140
  const s = React.useState(initial);
141
+ const wasSet = React.useState(value !== void 0);
142
+ if (value !== void 0 && !wasSet[0]) wasSet[1](true);
143
+ else if (value === void 0 && wasSet[0]) {
144
+ wasSet[1](false);
145
+ s[1](initial);
146
+ }
141
147
  const controlled = value !== void 0;
142
- return [
143
- controlled ? value : s[0],
144
- function(next) {
145
- if (!controlled) s[1](next);
146
- if (onChange) onChange(next);
147
- }
148
- ];
148
+ const latest = React.useRef({ controlled, onChange, set: s[1] });
149
+ latest.current = { controlled, onChange, set: s[1] };
150
+ const set = React.useCallback(function(next) {
151
+ const l = latest.current;
152
+ if (!l.controlled) l.set(next);
153
+ if (l.onChange) l.onChange(next);
154
+ }, []);
155
+ return [controlled ? value : s[0], set];
149
156
  }
150
157
  var collator = typeof Intl !== "undefined" ? new Intl.Collator(["th", "en"], { numeric: true, sensitivity: "base" }) : null;
151
158
  function compare(a, b) {
@@ -210,6 +217,9 @@ function tone(t) {
210
217
  return TONES.indexOf(t) >= 0 ? t : "neutral";
211
218
  }
212
219
  var warned = {};
220
+ function plainClick(e) {
221
+ return !e.defaultPrevented && e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey;
222
+ }
213
223
  function devWarnOnce(key, message) {
214
224
  if (warned[key]) return;
215
225
  let dev = false;
@@ -350,6 +360,12 @@ var STRINGS = {
350
360
  page: function(p, total) {
351
361
  return "Page " + p + " of " + total;
352
362
  },
363
+ rangeOpen: function(a, b) {
364
+ return a + "\u2013" + b + " of many";
365
+ },
366
+ pageOpen: function(p) {
367
+ return "Page " + p;
368
+ },
353
369
  prevPage: "Previous page",
354
370
  nextPage: "Next page",
355
371
  totals: "Totals",
@@ -363,6 +379,7 @@ var STRINGS = {
363
379
  timeOutOfRange: function(a, b) {
364
380
  return "Choose a time between " + a + " and " + b;
365
381
  },
382
+ timeUnavailable: "That time isn't available. Choose another.",
366
383
  dropFiles: "Drag files here or",
367
384
  browse: "Choose files",
368
385
  browseOne: "Choose a file",
@@ -464,6 +481,12 @@ var STRINGS = {
464
481
  page: function(p, total) {
465
482
  return "\u0E2B\u0E19\u0E49\u0E32 " + p + " / " + total;
466
483
  },
484
+ rangeOpen: function(a, b) {
485
+ return a + "\u2013" + b + " \u0E08\u0E32\u0E01\u0E2B\u0E25\u0E32\u0E22\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23";
486
+ },
487
+ pageOpen: function(p) {
488
+ return "\u0E2B\u0E19\u0E49\u0E32 " + p;
489
+ },
467
490
  prevPage: "\u0E2B\u0E19\u0E49\u0E32\u0E01\u0E48\u0E2D\u0E19\u0E2B\u0E19\u0E49\u0E32",
468
491
  nextPage: "\u0E2B\u0E19\u0E49\u0E32\u0E16\u0E31\u0E14\u0E44\u0E1B",
469
492
  totals: "\u0E23\u0E27\u0E21",
@@ -477,6 +500,7 @@ var STRINGS = {
477
500
  timeOutOfRange: function(a, b) {
478
501
  return "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E40\u0E27\u0E25\u0E32\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07 " + a + "\u2013" + b + " \u0E19.";
479
502
  },
503
+ timeUnavailable: "\u0E40\u0E27\u0E25\u0E32\u0E19\u0E35\u0E49\u0E44\u0E21\u0E48\u0E27\u0E48\u0E32\u0E07 \u0E40\u0E25\u0E37\u0E2D\u0E01\u0E40\u0E27\u0E25\u0E32\u0E2D\u0E37\u0E48\u0E19",
480
504
  dropFiles: "\u0E25\u0E32\u0E01\u0E44\u0E1F\u0E25\u0E4C\u0E21\u0E32\u0E27\u0E32\u0E07 \u0E2B\u0E23\u0E37\u0E2D",
481
505
  browse: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E1F\u0E25\u0E4C",
482
506
  browseOne: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E1F\u0E25\u0E4C",
@@ -578,6 +602,12 @@ var STRINGS = {
578
602
  page: function(p, total) {
579
603
  return "Sida " + p + " av " + total;
580
604
  },
605
+ rangeOpen: function(a, b) {
606
+ return a + "\u2013" + b + " av m\xE5nga";
607
+ },
608
+ pageOpen: function(p) {
609
+ return "Sida " + p;
610
+ },
581
611
  prevPage: "F\xF6reg\xE5ende sida",
582
612
  nextPage: "N\xE4sta sida",
583
613
  totals: "Summa",
@@ -591,6 +621,7 @@ var STRINGS = {
591
621
  timeOutOfRange: function(a, b) {
592
622
  return "V\xE4lj en tid mellan " + a + " och " + b;
593
623
  },
624
+ timeUnavailable: "Den tiden \xE4r inte ledig. V\xE4lj en annan.",
594
625
  dropFiles: "Dra filer hit eller",
595
626
  browse: "V\xE4lj filer",
596
627
  browseOne: "V\xE4lj en fil",
@@ -634,17 +665,18 @@ function AuraProvider(props) {
634
665
  const timeZone = props.timeZone || outer && outer.timeZone || null;
635
666
  const value = React3.useMemo(
636
667
  function() {
637
- const base = props.locale && STRINGS[props.locale] || STRINGS.en;
668
+ const own = !!props.locale || !outer || !outer.locale;
669
+ const base = own ? props.locale && STRINGS[props.locale] || STRINGS.en : outer.strings;
638
670
  return {
639
- locale: props.locale || "en",
640
- calendar: props.calendar || null,
671
+ locale: props.locale || outer && outer.locale || "en",
672
+ calendar: props.calendar || (own ? null : outer.calendar),
641
673
  strings: props.strings ? Object.assign({}, base, props.strings) : base,
642
- linkComponent: props.linkComponent || null,
674
+ linkComponent: props.linkComponent || outer && outer.linkComponent || null,
643
675
  density,
644
676
  timeZone
645
677
  };
646
678
  },
647
- [props.locale, props.calendar, props.strings, props.linkComponent, density, timeZone]
679
+ [props.locale, props.calendar, props.strings, props.linkComponent, density, timeZone, outer]
648
680
  );
649
681
  return /* @__PURE__ */ React3.createElement(LocaleContext.Provider, { value }, props.density ? /* @__PURE__ */ React3.createElement("div", { className: "aura-density", "data-density": props.density }, props.children) : props.children);
650
682
  }
@@ -783,11 +815,17 @@ var Menu = React6.forwardRef(function Menu2(props, ref) {
783
815
  function() {
784
816
  const a = props.anchor, m = own.current;
785
817
  if (!a || !m) return;
786
- const r = a.getBoundingClientRect(), mh = m.offsetHeight, mw = m.offsetWidth;
787
- let top = r.bottom + 4;
788
- if (top + mh > window.innerHeight - 8 && r.top - mh - 4 > 8) top = r.top - mh - 4;
818
+ const r = a.getBoundingClientRect(), mh = m.scrollHeight, mw = m.offsetWidth, below2 = window.innerHeight - r.bottom - 12, above = r.top - 12;
819
+ let top = r.bottom + 4, maxHeight;
820
+ if (mh > below2) {
821
+ if (mh <= above) top = r.top - mh - 4;
822
+ else if (above > below2) {
823
+ maxHeight = above;
824
+ top = r.top - above - 4;
825
+ } else maxHeight = below2;
826
+ }
789
827
  const left = Math.max(8, Math.min(r.right - mw, window.innerWidth - mw - 8));
790
- setPos({ top, left });
828
+ setPos({ top, left, maxHeight });
791
829
  },
792
830
  [props.anchor, mounted]
793
831
  );
@@ -831,6 +869,9 @@ var Menu = React6.forwardRef(function Menu2(props, ref) {
831
869
  } else if (e.key === "End") {
832
870
  e.preventDefault();
833
871
  list[list.length - 1].focus();
872
+ } else if (e.key === " " && document.activeElement && document.activeElement.tagName === "A") {
873
+ e.preventDefault();
874
+ document.activeElement.click();
834
875
  } else if (e.key === "Escape") {
835
876
  e.preventDefault();
836
877
  props.onClose(true);
@@ -871,9 +912,9 @@ var Menu = React6.forwardRef(function Menu2(props, ref) {
871
912
  tabIndex: -1,
872
913
  role: "menuitem",
873
914
  className: cls,
874
- onClick: function() {
915
+ onClick: function(e) {
875
916
  if (it.onSelect) it.onSelect();
876
- props.onClose(false);
917
+ props.onClose(e.detail === 0);
877
918
  }
878
919
  },
879
920
  body
@@ -904,7 +945,11 @@ var Menu = React6.forwardRef(function Menu2(props, ref) {
904
945
  "aria-label": props.label,
905
946
  className: "aura-menu",
906
947
  onKeyDown,
907
- style: { top: pos ? pos.top : -9999, left: pos ? pos.left : -9999 }
948
+ style: {
949
+ top: pos ? pos.top : -9999,
950
+ left: pos ? pos.left : -9999,
951
+ maxHeight: pos && pos.maxHeight ? pos.maxHeight : void 0
952
+ }
908
953
  },
909
954
  groupItems(items2).map(function(block, bi) {
910
955
  const rendered = block.items.map(function(x) {
@@ -922,6 +967,16 @@ var DropdownMenu = React7.forwardRef(function DropdownMenu2(props, ref) {
922
967
  const st = React7.useState(null), anchor = st[0], setAnchor = st[1];
923
968
  const wrap = React7.useRef(null), wrapMerged = useMergedRef(ref, wrap);
924
969
  const child = React7.Children.only(props.trigger);
970
+ const menuRef = React7.useRef(null), toLast = React7.useRef(false);
971
+ React7.useEffect(
972
+ function() {
973
+ if (!anchor || !toLast.current || !menuRef.current) return;
974
+ toLast.current = false;
975
+ const list = menuRef.current.querySelectorAll('[role^="menuitem"]:not([disabled])');
976
+ if (list.length) list[list.length - 1].focus();
977
+ },
978
+ [anchor]
979
+ );
925
980
  function toggle(e) {
926
981
  if (child.props.onClick) child.props.onClick(e);
927
982
  const el = wrap.current && (wrap.current.querySelector('button, [role="button"], a') || wrap.current);
@@ -930,12 +985,14 @@ var DropdownMenu = React7.forwardRef(function DropdownMenu2(props, ref) {
930
985
  function onKeyDown(e) {
931
986
  if ((e.key === "ArrowDown" || e.key === "ArrowUp") && !anchor) {
932
987
  e.preventDefault();
988
+ toLast.current = e.key === "ArrowUp";
933
989
  setAnchor(wrap.current.querySelector('button, [role="button"], a') || wrap.current);
934
990
  }
935
991
  }
936
992
  return /* @__PURE__ */ React7.createElement("span", { ref: wrapMerged, className: "aura-dropdown", onKeyDown }, React7.cloneElement(child, { onClick: toggle, "aria-haspopup": "menu", "aria-expanded": anchor ? true : false }), anchor ? /* @__PURE__ */ React7.createElement(
937
993
  Menu,
938
994
  {
995
+ ref: menuRef,
939
996
  anchor,
940
997
  label: props.label,
941
998
  items: props.items,
@@ -954,6 +1011,7 @@ var Checkbox = React8.forwardRef(function Checkbox2(props, ref) {
954
1011
  const own = React8.useRef(null), merged = useMergedRef(ref, own);
955
1012
  const st = useMaybeControlled(props.checked, !!props.defaultChecked, props.onChange);
956
1013
  const on = !!st[0];
1014
+ const auto = uid();
957
1015
  React8.useEffect(function() {
958
1016
  if (own.current) own.current.indeterminate = !!props.indeterminate;
959
1017
  });
@@ -977,7 +1035,7 @@ var Checkbox = React8.forwardRef(function Checkbox2(props, ref) {
977
1035
  "checkbox-label",
978
1036
  "Checkbox `label` is only the accessible name: it is not shown. In 6.0 it will be shown beside the box, like Switch and TextField. For visible text now pass it as children; for a bare box (a table row) add `hideLabel`."
979
1037
  );
980
- const descId = props.description && props.id ? props.id + "-desc" : void 0;
1038
+ const descId = props.description ? (props.id || auto) + "-desc" : void 0;
981
1039
  return /* @__PURE__ */ React8.createElement(
982
1040
  "label",
983
1041
  {
@@ -1105,8 +1163,8 @@ var TextField = React11.forwardRef(function TextField2(props, ref) {
1105
1163
  className: "aura-input__control",
1106
1164
  placeholder: props.placeholder,
1107
1165
  required: props.required,
1108
- "aria-invalid": props.error ? true : void 0,
1109
- "aria-describedby": describedBy(id, props)
1166
+ "aria-invalid": props.error ? true : rest["aria-invalid"],
1167
+ "aria-describedby": [describedBy(id, props), rest["aria-describedby"]].filter(Boolean).join(" ") || void 0
1110
1168
  }
1111
1169
  ), props.suffix ? /* @__PURE__ */ React11.createElement("span", { className: "aura-input__suffix" }, props.suffix) : null)
1112
1170
  );
@@ -1139,8 +1197,8 @@ var Textarea = React12.forwardRef(function Textarea2(props, ref) {
1139
1197
  className: "aura-input aura-textarea",
1140
1198
  placeholder: props.placeholder,
1141
1199
  required: props.required,
1142
- "aria-invalid": props.error ? true : void 0,
1143
- "aria-describedby": describedBy(id, props)
1200
+ "aria-invalid": props.error ? true : rest["aria-invalid"],
1201
+ "aria-describedby": [describedBy(id, props), rest["aria-describedby"]].filter(Boolean).join(" ") || void 0
1144
1202
  }
1145
1203
  )
1146
1204
  );
@@ -1199,10 +1257,22 @@ var RadioGroup = React14.forwardRef(function RadioGroup2(props, ref) {
1199
1257
  props.onChange
1200
1258
  );
1201
1259
  const name = props.name || id;
1260
+ const setRef = React14.useCallback(
1261
+ function(el) {
1262
+ if (el)
1263
+ el.focus = function(opts) {
1264
+ const r = el.querySelector('input[type="radio"]:checked') || el.querySelector('input[type="radio"]:not(:disabled)');
1265
+ if (r) r.focus(opts);
1266
+ };
1267
+ if (typeof ref === "function") ref(el);
1268
+ else if (ref) ref.current = el;
1269
+ },
1270
+ [ref]
1271
+ );
1202
1272
  return /* @__PURE__ */ React14.createElement(
1203
1273
  "fieldset",
1204
1274
  {
1205
- ref,
1275
+ ref: setRef,
1206
1276
  className: cx("aura-field aura-radio-group", props.error && "is-invalid", props.className),
1207
1277
  "aria-describedby": describedBy(id, props),
1208
1278
  "aria-invalid": props.error ? true : void 0,
@@ -1219,6 +1289,7 @@ var RadioGroup = React14.forwardRef(function RadioGroup2(props, ref) {
1219
1289
  name,
1220
1290
  value: v.value,
1221
1291
  disabled: v.disabled,
1292
+ required: props.required || void 0,
1222
1293
  checked: st[0] === v.value,
1223
1294
  onChange: function() {
1224
1295
  st[1](v.value);
@@ -1265,7 +1336,7 @@ var Switch = React15.forwardRef(function Switch2(props, ref) {
1265
1336
  },
1266
1337
  /* @__PURE__ */ React15.createElement("span", { className: "aura-switch__thumb" })
1267
1338
  ),
1268
- props.label ? /* @__PURE__ */ React15.createElement("span", { className: "aura-choice__text" }, /* @__PURE__ */ React15.createElement("label", { className: "aura-choice__label", id: id + "-label", htmlFor: id }, props.label), props.description ? /* @__PURE__ */ React15.createElement("span", { className: "aura-choice__desc", id: id + "-desc" }, props.description) : null) : null
1339
+ props.label ? /* @__PURE__ */ React15.createElement("span", { className: "aura-choice__text" }, /* @__PURE__ */ React15.createElement("label", { className: "aura-choice__label", id: id + "-label", htmlFor: id }, props.label), props.description ? /* @__PURE__ */ React15.createElement("span", { className: "aura-choice__desc", id: id + "-desc" }, props.description) : null) : props.description ? /* @__PURE__ */ React15.createElement("span", { className: "aura-sr-only", id: id + "-desc" }, props.description) : null
1269
1340
  );
1270
1341
  });
1271
1342
 
@@ -1349,7 +1420,7 @@ var Combobox = React16.forwardRef(
1349
1420
  function() {
1350
1421
  if (open) place();
1351
1422
  },
1352
- [open, shown.length]
1423
+ [open, shown.length, values.length]
1353
1424
  );
1354
1425
  React16.useEffect(
1355
1426
  function() {
@@ -1381,6 +1452,7 @@ var Combobox = React16.forwardRef(
1381
1452
  },
1382
1453
  [activeIdx, open]
1383
1454
  );
1455
+ const live = props.loading ? [] : shown;
1384
1456
  function openList() {
1385
1457
  if (!open && !props.disabled && !props.readOnly) {
1386
1458
  setOpen(true);
@@ -1416,7 +1488,7 @@ var Combobox = React16.forwardRef(
1416
1488
  if (k === "ArrowDown") {
1417
1489
  e.preventDefault();
1418
1490
  if (!open) openList();
1419
- else setActive(Math.min(activeIdx + 1, shown.length - 1));
1491
+ else setActive(Math.max(0, Math.min(activeIdx + 1, live.length - 1)));
1420
1492
  } else if (k === "ArrowUp") {
1421
1493
  e.preventDefault();
1422
1494
  if (!open) openList();
@@ -1426,21 +1498,22 @@ var Combobox = React16.forwardRef(
1426
1498
  setActive(0);
1427
1499
  } else if (k === "End" && open) {
1428
1500
  e.preventDefault();
1429
- setActive(shown.length - 1);
1501
+ setActive(Math.max(0, live.length - 1));
1430
1502
  } else if (k === "Enter") {
1431
- if (open && shown[activeIdx]) {
1503
+ if (e.nativeEvent.isComposing || e.keyCode === 229) return;
1504
+ if (open && live[activeIdx]) {
1432
1505
  e.preventDefault();
1433
- choose(shown[activeIdx]);
1506
+ choose(live[activeIdx]);
1434
1507
  }
1435
1508
  } else if (k === "Escape") {
1436
1509
  if (open) {
1437
1510
  e.preventDefault();
1438
1511
  e.stopPropagation();
1439
1512
  close();
1440
- } else if (!multi && props.clearable !== false && value != null && query == null) {
1513
+ } else if (!multi && !props.readOnly && props.clearable !== false && value != null && query == null) {
1441
1514
  setValue(null);
1442
1515
  }
1443
- } else if (k === "Backspace" && multi && !text && values.length) {
1516
+ } else if (k === "Backspace" && multi && !props.readOnly && !text && values.length) {
1444
1517
  setValues(values.slice(0, -1));
1445
1518
  } else if (k === "Tab") {
1446
1519
  if (open) close();
@@ -1452,7 +1525,7 @@ var Combobox = React16.forwardRef(
1452
1525
  return id + "-opt-" + i;
1453
1526
  };
1454
1527
  const list = open && mounted && posState[0] ? (0, import_react_dom2.createPortal)(
1455
- /* @__PURE__ */ React16.createElement("div", { ref: listRef, className: "aura-combo__popover", style: posState[0] }, /* @__PURE__ */ React16.createElement(
1528
+ /* @__PURE__ */ React16.createElement("div", { ref: listRef, className: "aura-combo__popover", style: posState[0] }, live.length ? /* @__PURE__ */ React16.createElement(
1456
1529
  "ul",
1457
1530
  {
1458
1531
  id: listId,
@@ -1461,7 +1534,7 @@ var Combobox = React16.forwardRef(
1461
1534
  "aria-multiselectable": multi || void 0,
1462
1535
  className: "aura-combo__list"
1463
1536
  },
1464
- props.loading ? /* @__PURE__ */ React16.createElement("li", { className: "aura-combo__note", role: "presentation" }, /* @__PURE__ */ React16.createElement(Icon, { name: "loader-circle", className: "aura-spin" }), props.loadingText || t.searching) : !shown.length ? /* @__PURE__ */ React16.createElement("li", { className: "aura-combo__note", role: "presentation" }, props.emptyText || t.noMatches) : shown.map(function(o, i) {
1537
+ live.map(function(o, i) {
1465
1538
  const isSel = multi ? isPicked(o.value) : !!selected && o.value === selected.value;
1466
1539
  const blocked = o.disabled || multi && full && !isSel;
1467
1540
  return /* @__PURE__ */ React16.createElement(
@@ -1493,9 +1566,8 @@ var Combobox = React16.forwardRef(
1493
1566
  /* @__PURE__ */ React16.createElement("span", { className: "aura-combo__text" }, /* @__PURE__ */ React16.createElement("span", { className: "aura-combo__label" }, o.label), o.description ? /* @__PURE__ */ React16.createElement("span", { className: "aura-combo__desc" }, o.description) : null),
1494
1567
  isSel ? /* @__PURE__ */ React16.createElement(Icon, { name: "check", className: "aura-combo__check" }) : null
1495
1568
  );
1496
- }),
1497
- more && !props.loading ? /* @__PURE__ */ React16.createElement("li", { className: "aura-combo__note", role: "presentation" }, t.keepTyping((props.options || []).length)) : null
1498
- )),
1569
+ })
1570
+ ) : null, props.loading || !live.length || more ? /* @__PURE__ */ React16.createElement("div", { className: "aura-combo__list", role: "status" }, props.loading ? /* @__PURE__ */ React16.createElement("div", { className: "aura-combo__note" }, /* @__PURE__ */ React16.createElement(Icon, { name: "loader-circle", className: "aura-spin" }), props.loadingText || t.searching) : !live.length ? /* @__PURE__ */ React16.createElement("div", { className: "aura-combo__note" }, props.emptyText || t.noMatches) : /* @__PURE__ */ React16.createElement("div", { className: "aura-combo__note" }, t.keepTyping((props.options || []).length))) : null),
1499
1571
  document.body
1500
1572
  ) : null;
1501
1573
  return /* @__PURE__ */ React16.createElement(
@@ -1534,9 +1606,9 @@ var Combobox = React16.forwardRef(
1534
1606
  ));
1535
1607
  })) : null, multi ? /* @__PURE__ */ React16.createElement("span", { id: summaryId, className: "aura-sr-only" }, picked.length ? t.selectedCount(picked.length) + ": " + picked.map(function(o) {
1536
1608
  return o.label;
1537
- }).join(", ") : "") : null, multi && props.name ? values.map(function(v) {
1609
+ }).join(", ") : "") : null, props.name ? multi ? values.map(function(v) {
1538
1610
  return /* @__PURE__ */ React16.createElement("input", { key: v, type: "hidden", name: props.name, value: v });
1539
- }) : null, /* @__PURE__ */ React16.createElement(
1611
+ }) : /* @__PURE__ */ React16.createElement("input", { type: "hidden", name: props.name, value: value == null ? "" : value }) : null, /* @__PURE__ */ React16.createElement(
1540
1612
  "input",
1541
1613
  {
1542
1614
  ref: inputMerged,
@@ -1545,17 +1617,16 @@ var Combobox = React16.forwardRef(
1545
1617
  role: "combobox",
1546
1618
  className: "aura-input__control",
1547
1619
  autoComplete: "off",
1548
- "aria-expanded": open,
1549
- "aria-controls": listId,
1620
+ "aria-expanded": open && live.length > 0,
1621
+ "aria-controls": open && live.length ? listId : void 0,
1550
1622
  "aria-autocomplete": "list",
1551
- "aria-activedescendant": open && shown[activeIdx] ? optId(activeIdx) : void 0,
1623
+ "aria-activedescendant": open && live[activeIdx] ? optId(activeIdx) : void 0,
1552
1624
  "aria-invalid": props.error ? true : void 0,
1553
1625
  "aria-describedby": [props.error ? id + "-error" : props.hint ? id + "-hint" : "", multi && picked.length ? summaryId : ""].filter(Boolean).join(" ") || void 0,
1554
1626
  placeholder: multi && values.length ? void 0 : props.placeholder,
1555
1627
  disabled: props.disabled,
1556
1628
  readOnly: props.readOnly,
1557
1629
  required: props.required && (!multi || !values.length),
1558
- name: multi ? void 0 : props.name,
1559
1630
  value: text,
1560
1631
  onChange: function(e) {
1561
1632
  setQuery(e.target.value);
@@ -1573,7 +1644,7 @@ var Combobox = React16.forwardRef(
1573
1644
  }, 0);
1574
1645
  }
1575
1646
  }
1576
- ), props.clearable !== false && values.length && !props.disabled ? /* @__PURE__ */ React16.createElement(
1647
+ ), props.clearable !== false && values.length && !props.disabled && !props.readOnly ? /* @__PURE__ */ React16.createElement(
1577
1648
  "button",
1578
1649
  {
1579
1650
  type: "button",
@@ -1622,20 +1693,29 @@ var pad = function(n2) {
1622
1693
  return (n2 < 10 ? "0" : "") + n2;
1623
1694
  };
1624
1695
  function toISO(d) {
1625
- return d ? d.getFullYear() + "-" + pad(d.getMonth() + 1) + "-" + pad(d.getDate()) : null;
1696
+ if (!d) return null;
1697
+ const y = String(d.getFullYear());
1698
+ return ("000" + y).slice(-Math.max(4, y.length)) + "-" + pad(d.getMonth() + 1) + "-" + pad(d.getDate());
1699
+ }
1700
+ function makeDate(y, monthIndex2, day) {
1701
+ const d = new Date(2e3, 0, 1);
1702
+ d.setFullYear(y, monthIndex2, day);
1703
+ return d;
1626
1704
  }
1627
1705
  function fromISO(s) {
1628
1706
  if (!s) return null;
1629
1707
  const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(s);
1630
- return m ? new Date(+m[1], +m[2] - 1, +m[3]) : null;
1708
+ if (!m) return null;
1709
+ const d = makeDate(+m[1], +m[2] - 1, +m[3]);
1710
+ return d.getMonth() === +m[2] - 1 && d.getDate() === +m[3] ? d : null;
1631
1711
  }
1632
1712
  function addDays(d, n2) {
1633
- return new Date(d.getFullYear(), d.getMonth(), d.getDate() + n2);
1713
+ return makeDate(d.getFullYear(), d.getMonth(), d.getDate() + n2);
1634
1714
  }
1635
1715
  function addMonths(d, n2) {
1636
- const t = new Date(d.getFullYear(), d.getMonth() + n2, 1);
1637
- const last = new Date(t.getFullYear(), t.getMonth() + 1, 0).getDate();
1638
- return new Date(t.getFullYear(), t.getMonth(), Math.min(d.getDate(), last));
1716
+ const t = makeDate(d.getFullYear(), d.getMonth() + n2, 1);
1717
+ const last = makeDate(t.getFullYear(), t.getMonth() + 1, 0).getDate();
1718
+ return makeDate(t.getFullYear(), t.getMonth(), Math.min(d.getDate(), last));
1639
1719
  }
1640
1720
  function same(a, b) {
1641
1721
  return !!a && !!b && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
@@ -1664,7 +1744,8 @@ var DATE_TEXT = {
1664
1744
  rangePlaceholder: "\u0E27\u0E27/\u0E14\u0E14/\u0E1B\u0E1B\u0E1B\u0E1B \u2013 \u0E27\u0E27/\u0E14\u0E14/\u0E1B\u0E1B\u0E1B\u0E1B",
1665
1745
  clearDates: "\u0E25\u0E49\u0E32\u0E07\u0E0A\u0E48\u0E27\u0E07\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48",
1666
1746
  chooseStart: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E27\u0E31\u0E19\u0E40\u0E23\u0E34\u0E48\u0E21\u0E15\u0E49\u0E19",
1667
- chooseEnd: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E27\u0E31\u0E19\u0E2A\u0E34\u0E49\u0E19\u0E2A\u0E38\u0E14"
1747
+ chooseEnd: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E27\u0E31\u0E19\u0E2A\u0E34\u0E49\u0E19\u0E2A\u0E38\u0E14",
1748
+ dateUnavailable: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E19\u0E35\u0E49\u0E44\u0E21\u0E48\u0E44\u0E14\u0E49 \u0E25\u0E2D\u0E07\u0E40\u0E1B\u0E34\u0E14\u0E1B\u0E0F\u0E34\u0E17\u0E34\u0E19\u0E14\u0E39\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E14\u0E49"
1668
1749
  },
1669
1750
  en: {
1670
1751
  prevYears: "Previous years",
@@ -1681,7 +1762,8 @@ var DATE_TEXT = {
1681
1762
  rangePlaceholder: "DD/MM/YYYY \u2013 DD/MM/YYYY",
1682
1763
  clearDates: "Clear dates",
1683
1764
  chooseStart: "Choose the start date",
1684
- chooseEnd: "Choose the end date"
1765
+ chooseEnd: "Choose the end date",
1766
+ dateUnavailable: "That date can't be chosen. Open the calendar to see the dates you can pick."
1685
1767
  },
1686
1768
  sv: {
1687
1769
  prevYears: "Tidigare \xE5r",
@@ -1698,7 +1780,8 @@ var DATE_TEXT = {
1698
1780
  rangePlaceholder: "\xE5\xE5\xE5\xE5-mm-dd \u2013 \xE5\xE5\xE5\xE5-mm-dd",
1699
1781
  clearDates: "Rensa datumen",
1700
1782
  chooseStart: "V\xE4lj startdatum",
1701
- chooseEnd: "V\xE4lj slutdatum"
1783
+ chooseEnd: "V\xE4lj slutdatum",
1784
+ dateUnavailable: "Det datumet g\xE5r inte att v\xE4lja. \xD6ppna kalendern f\xF6r att se vilka datum som g\xE5r."
1702
1785
  }
1703
1786
  };
1704
1787
  function dateText(locale) {
@@ -1740,7 +1823,15 @@ function monthIndex(word) {
1740
1823
  return MONTHS[k] != null ? MONTHS[k] : -1;
1741
1824
  }
1742
1825
  function parseDate(text) {
1743
- const s = String(text || "").trim();
1826
+ const raw = String(text || "").trim();
1827
+ const gregorian = /ค\.ศ\.|\d\s*(AD|CE)\b|^\s*(AD|CE)\s/i.test(raw);
1828
+ let s = raw.replace(/พ\.ศ\.|ค\.ศ\./g, " ").replace(/(\d)\s*(BE|AD|CE)\b/gi, "$1 ").replace(/^\s*(BE|AD|CE)\s+/i, " ").replace(/\s+/g, " ").trim();
1829
+ const eight = /^(\d{2})(\d{2})(\d{4})$/.exec(s);
1830
+ if (eight) {
1831
+ const a = +eight[3] >= 1e3 ? parseDate(eight[1] + "/" + eight[2] + "/" + eight[3] + (gregorian ? " \u0E04.\u0E28." : "")) : null;
1832
+ if (a) return a;
1833
+ s = s.slice(0, 4) + "-" + s.slice(4, 6) + "-" + s.slice(6);
1834
+ }
1744
1835
  let m = /^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(s), y, mo, d;
1745
1836
  if (m) {
1746
1837
  y = +m[1];
@@ -1750,13 +1841,13 @@ function parseDate(text) {
1750
1841
  d = +m[1];
1751
1842
  mo = +m[2];
1752
1843
  y = +m[3];
1753
- } else if ((m = /^(\d{1,2})\s+(\S+)\s+(\d{4})$/.exec(s.replace(ERA, "").trim())) && monthIndex(m[2]) >= 0) {
1844
+ } else if ((m = /^(\d{1,2})\s+(\S+)\s+(\d{4})$/.exec(s)) && monthIndex(m[2]) >= 0) {
1754
1845
  d = +m[1];
1755
1846
  mo = monthIndex(m[2]) + 1;
1756
1847
  y = +m[3];
1757
1848
  } else return null;
1758
- if (y >= 2400) y -= 543;
1759
- const dt = new Date(y, mo - 1, d);
1849
+ if (y >= 2400 && !gregorian) y -= 543;
1850
+ const dt = makeDate(y, mo - 1, d);
1760
1851
  return dt.getMonth() === mo - 1 && dt.getDate() === d ? toISO(dt) : null;
1761
1852
  }
1762
1853
  function todayIn(timeZone) {
@@ -1791,14 +1882,37 @@ function useFormatDate() {
1791
1882
  [locale, calendar]
1792
1883
  );
1793
1884
  }
1885
+ function allowedDate(iso, o) {
1886
+ const t = o.min === "today" || o.max === "today" ? o.today && fromISO(o.today) ? o.today : todayIn(o.timeZone) : "";
1887
+ const lo = o.min === "today" ? t : o.min, hi = o.max === "today" ? t : o.max;
1888
+ if (lo && fromISO(lo) && iso < lo) return false;
1889
+ if (hi && fromISO(hi) && iso > hi) return false;
1890
+ return !(o.isDateDisabled && o.isDateDisabled(iso));
1891
+ }
1794
1892
  var Calendar = React17.forwardRef(function Calendar2(props, ref) {
1795
1893
  const ctx = useAuraLocale(), locale = props.locale || ctx.locale || "en", calendar = props.calendar || ctx.calendar || defaultCalendar(locale), tag = localeTag(locale, calendar);
1796
1894
  const weekStart = props.weekStartsOn == null ? locale === "sv" ? 1 : 0 : props.weekStartsOn;
1797
- const todayISO = (props.today && fromISO(props.today) ? props.today : null) || todayIn(props.timeZone || ctx.timeZone);
1895
+ const given = props.today && fromISO(props.today) ? props.today : null, zone = props.timeZone || ctx.timeZone;
1896
+ const todayISO = given || todayIn(zone);
1798
1897
  const today = fromISO(todayISO);
1898
+ const mounted = useMounted(), gridKey = given || mounted ? "client" : "server";
1799
1899
  const min = fromISO(props.min === "today" ? todayISO : props.min), max = fromISO(props.max === "today" ? todayISO : props.max);
1800
1900
  const start = fromISO(props.start), end = fromISO(props.end);
1801
- const focusState = React17.useState(fromISO(props.focus) || start || today);
1901
+ function disabledAt(d) {
1902
+ return !!(min && d < min || max && d > max || props.isDateDisabled && props.isDateDisabled(toISO(d)));
1903
+ }
1904
+ function select(iso) {
1905
+ if (props.onSelect) props.onSelect(iso);
1906
+ }
1907
+ const focusState = React17.useState(function() {
1908
+ const d0 = fromISO(props.focus) || start || today;
1909
+ if (!disabledAt(d0)) return d0;
1910
+ for (let i = 1; i <= 366; i++) {
1911
+ if (!disabledAt(addDays(d0, i))) return addDays(d0, i);
1912
+ if (!disabledAt(addDays(d0, -i))) return addDays(d0, -i);
1913
+ }
1914
+ return d0;
1915
+ });
1802
1916
  const focusDate = focusState[0], setFocus = focusState[1];
1803
1917
  const viewState = React17.useState("days"), view = viewState[0], setView = viewState[1];
1804
1918
  const hoverState = React17.useState(null);
@@ -1806,7 +1920,7 @@ var Calendar = React17.forwardRef(function Calendar2(props, ref) {
1806
1920
  const th = locale === "th";
1807
1921
  const dt = dateText(locale);
1808
1922
  function disabled(d) {
1809
- return !!(min && d < min || max && d > max || props.isDateDisabled && props.isDateDisabled(toISO(d)));
1923
+ return disabledAt(d);
1810
1924
  }
1811
1925
  React17.useEffect(function() {
1812
1926
  if (!moved.current) return;
@@ -1814,11 +1928,14 @@ var Calendar = React17.forwardRef(function Calendar2(props, ref) {
1814
1928
  const el = gridRef.current && gridRef.current.querySelector('[data-date="' + toISO(focusDate) + '"]');
1815
1929
  if (el) el.focus();
1816
1930
  });
1817
- React17.useEffect(function() {
1818
- if (props.autoFocus === false) return;
1819
- const el = gridRef.current && gridRef.current.querySelector('[tabindex="0"]');
1820
- if (el) el.focus();
1821
- }, []);
1931
+ React17.useEffect(
1932
+ function() {
1933
+ if (props.autoFocus === false) return;
1934
+ const el = gridRef.current && gridRef.current.querySelector('[tabindex="0"]');
1935
+ if (el) el.focus();
1936
+ },
1937
+ [gridKey]
1938
+ );
1822
1939
  function move(d) {
1823
1940
  moved.current = true;
1824
1941
  setFocus(d);
@@ -1843,7 +1960,7 @@ var Calendar = React17.forwardRef(function Calendar2(props, ref) {
1843
1960
  else if (k === "PageDown") n2 = addMonths(d, e.shiftKey ? 12 : 1);
1844
1961
  else if (k === "Enter" || k === " ") {
1845
1962
  e.preventDefault();
1846
- if (!disabled(d)) props.onSelect(toISO(d));
1963
+ if (!disabled(d)) select(toISO(d));
1847
1964
  return;
1848
1965
  }
1849
1966
  if (n2) {
@@ -1866,7 +1983,7 @@ var Calendar = React17.forwardRef(function Calendar2(props, ref) {
1866
1983
  const yr = focusDate.getFullYear(), base = yr - yr % 12;
1867
1984
  const years = [];
1868
1985
  for (let y = base; y < base + 12; y++) years.push(y);
1869
- return /* @__PURE__ */ React17.createElement("div", { className: "aura-cal", ref: gridMerged }, /* @__PURE__ */ React17.createElement("div", { className: "aura-cal__head" }, /* @__PURE__ */ React17.createElement(
1986
+ return /* @__PURE__ */ React17.createElement("div", { className: "aura-cal", ref: gridMerged, key: gridKey }, /* @__PURE__ */ React17.createElement("div", { className: "aura-cal__head" }, /* @__PURE__ */ React17.createElement(
1870
1987
  IconButton,
1871
1988
  {
1872
1989
  icon: "chevron-left",
@@ -1913,7 +2030,7 @@ var Calendar = React17.forwardRef(function Calendar2(props, ref) {
1913
2030
  );
1914
2031
  })));
1915
2032
  }
1916
- return /* @__PURE__ */ React17.createElement("div", { className: "aura-cal", ref: gridMerged }, /* @__PURE__ */ React17.createElement("div", { className: "aura-cal__head" }, /* @__PURE__ */ React17.createElement(
2033
+ return /* @__PURE__ */ React17.createElement("div", { className: "aura-cal", ref: gridMerged, key: gridKey }, /* @__PURE__ */ React17.createElement("div", { className: "aura-cal__head" }, /* @__PURE__ */ React17.createElement(
1917
2034
  IconButton,
1918
2035
  {
1919
2036
  icon: "chevron-left",
@@ -1975,7 +2092,7 @@ var Calendar = React17.forwardRef(function Calendar2(props, ref) {
1975
2092
  type: "button",
1976
2093
  "data-date": iso,
1977
2094
  tabIndex: same(d, focusDate) ? 0 : -1,
1978
- disabled: dis,
2095
+ "aria-disabled": dis || void 0,
1979
2096
  "aria-label": fmt(tag, { weekday: "long", day: "numeric", month: "long", year: "numeric" }, d),
1980
2097
  suppressHydrationWarning: true,
1981
2098
  "aria-current": same(d, today) ? "date" : void 0,
@@ -1988,7 +2105,7 @@ var Calendar = React17.forwardRef(function Calendar2(props, ref) {
1988
2105
  ),
1989
2106
  onClick: function() {
1990
2107
  setFocus(d);
1991
- props.onSelect(iso);
2108
+ if (!dis) select(iso);
1992
2109
  },
1993
2110
  onKeyDown: function(e) {
1994
2111
  onKey(e, d);
@@ -2010,7 +2127,7 @@ var Calendar = React17.forwardRef(function Calendar2(props, ref) {
2010
2127
  disabled: disabled(today),
2011
2128
  onClick: function() {
2012
2129
  move(today);
2013
- props.onSelect(toISO(today));
2130
+ select(toISO(today));
2014
2131
  }
2015
2132
  },
2016
2133
  dt.today
@@ -2021,16 +2138,16 @@ function useCalendarPopover(boxRef) {
2021
2138
  const pos = React17.useState(null), popRef = React17.useRef(null), mounted = useMounted();
2022
2139
  function place() {
2023
2140
  if (!boxRef.current) return;
2024
- const r = boxRef.current.getBoundingClientRect(), H = 380;
2025
- const up = window.innerHeight - r.bottom < H && r.top > H;
2026
- const left = Math.max(8, Math.min(r.left, window.innerWidth - 320 - 8));
2141
+ const el = popRef.current, r = boxRef.current.getBoundingClientRect(), W = el ? el.offsetWidth : 320, H = el ? el.offsetHeight : 380;
2142
+ const up = window.innerHeight - r.bottom < H + 12 && r.top > H + 12;
2143
+ const left = Math.max(8, Math.min(r.left, window.innerWidth - W - 8));
2027
2144
  pos[1](up ? { left, bottom: window.innerHeight - r.top + 4 } : { left, top: r.bottom + 4 });
2028
2145
  }
2029
2146
  useIsoLayoutEffect(
2030
2147
  function() {
2031
2148
  if (open) place();
2032
2149
  },
2033
- [open]
2150
+ [open, !!pos[0]]
2034
2151
  );
2035
2152
  React17.useEffect(
2036
2153
  function() {
@@ -2144,13 +2261,30 @@ var DatePicker = React17.forwardRef(function DatePicker2(props, ref) {
2144
2261
  );
2145
2262
  const boxRef = React17.useRef(null), inputRef = React17.useRef(null), inputMerged = useMergedRef(ref, inputRef);
2146
2263
  const pop = useCalendarPopover(boxRef);
2264
+ const limits = {
2265
+ min: props.min,
2266
+ max: props.max,
2267
+ today: props.today,
2268
+ timeZone: props.timeZone || ctx.timeZone,
2269
+ isDateDisabled: props.isDateDisabled
2270
+ };
2271
+ const bad = React17.useState(null);
2272
+ React17.useEffect(
2273
+ function() {
2274
+ bad[1](null);
2275
+ },
2276
+ [st[0]]
2277
+ );
2147
2278
  function commit(text) {
2279
+ bad[1](null);
2148
2280
  if (!text.trim()) {
2149
2281
  st[1](null);
2150
2282
  return;
2151
2283
  }
2152
2284
  const iso = parseDate(text);
2153
- if (iso) st[1](iso);
2285
+ if (!iso) return;
2286
+ if (allowedDate(iso, limits)) st[1](iso);
2287
+ else bad[1](dt.dateUnavailable);
2154
2288
  }
2155
2289
  function close() {
2156
2290
  pop.setOpen(false);
@@ -2188,6 +2322,7 @@ var DatePicker = React17.forwardRef(function DatePicker2(props, ref) {
2188
2322
  start: st[0],
2189
2323
  focus: st[0],
2190
2324
  onSelect: function(iso) {
2325
+ bad[1](null);
2191
2326
  st[1](iso);
2192
2327
  close();
2193
2328
  }
@@ -2203,7 +2338,7 @@ var DatePicker = React17.forwardRef(function DatePicker2(props, ref) {
2203
2338
  dialogId,
2204
2339
  label: props.label,
2205
2340
  hint: props.hint,
2206
- error: props.error,
2341
+ error: bad[0] || props.error,
2207
2342
  required: props.required,
2208
2343
  optional: props.optional,
2209
2344
  disabled: props.disabled,
@@ -2217,6 +2352,7 @@ var DatePicker = React17.forwardRef(function DatePicker2(props, ref) {
2217
2352
  hasValue: st[0] != null,
2218
2353
  clearable: props.clearable,
2219
2354
  onClear: function() {
2355
+ bad[1](null);
2220
2356
  st[1](null);
2221
2357
  inputRef.current && inputRef.current.focus();
2222
2358
  },
@@ -2243,20 +2379,36 @@ var DateRangePicker = React17.forwardRef(
2243
2379
  const draft = React17.useState(null);
2244
2380
  const boxRef = React17.useRef(null), inputRef = React17.useRef(null), inputMerged = useMergedRef(ref, inputRef);
2245
2381
  const pop = useCalendarPopover(boxRef);
2382
+ const limits = {
2383
+ min: props.min,
2384
+ max: props.max,
2385
+ today: props.today,
2386
+ timeZone: props.timeZone || ctx.timeZone,
2387
+ isDateDisabled: props.isDateDisabled
2388
+ };
2246
2389
  const o = { locale, calendar };
2247
2390
  function show2(r) {
2248
2391
  if (!r.start) return "";
2249
2392
  if (!r.end) return formatDate(r.start, o) + " \u2013";
2250
2393
  return formatDate(r.start, o) + " \u2013 " + formatDate(r.end, o);
2251
2394
  }
2395
+ const bad = React17.useState(null);
2396
+ React17.useEffect(
2397
+ function() {
2398
+ bad[1](null);
2399
+ },
2400
+ [v.start, v.end]
2401
+ );
2252
2402
  function commit(text) {
2403
+ bad[1](null);
2253
2404
  const parts = String(text).split(/\s[–-]\s|\s*–\s*/);
2254
2405
  if (!text.trim()) {
2255
2406
  st[1]({ start: null, end: null });
2256
2407
  return;
2257
2408
  }
2258
2409
  const a = parseDate(parts[0]), b = parseDate(parts[1] || "");
2259
- if (a && b) st[1](a <= b ? { start: a, end: b } : { start: b, end: a });
2410
+ if (a && b && !(allowedDate(a, limits) && allowedDate(b, limits))) bad[1](dt.dateUnavailable);
2411
+ else if (a && b) st[1](a <= b ? { start: a, end: b } : { start: b, end: a });
2260
2412
  }
2261
2413
  function close() {
2262
2414
  pop.setOpen(false);
@@ -2269,6 +2421,7 @@ var DateRangePicker = React17.forwardRef(
2269
2421
  return;
2270
2422
  }
2271
2423
  const a = draft[0], b = iso;
2424
+ bad[1](null);
2272
2425
  st[1](a <= b ? { start: a, end: b } : { start: b, end: a });
2273
2426
  close();
2274
2427
  }
@@ -2319,7 +2472,7 @@ var DateRangePicker = React17.forwardRef(
2319
2472
  dialogId,
2320
2473
  label: props.label,
2321
2474
  hint: props.hint,
2322
- error: props.error,
2475
+ error: bad[0] || props.error,
2323
2476
  required: props.required,
2324
2477
  optional: props.optional,
2325
2478
  disabled: props.disabled,
@@ -2333,6 +2486,7 @@ var DateRangePicker = React17.forwardRef(
2333
2486
  hasValue: v.start != null,
2334
2487
  clearable: props.clearable,
2335
2488
  onClear: function() {
2489
+ bad[1](null);
2336
2490
  st[1]({ start: null, end: null });
2337
2491
  inputRef.current && inputRef.current.focus();
2338
2492
  },
@@ -2528,6 +2682,7 @@ function Toaster(props) {
2528
2682
  const s = React19.useState(toastState.list);
2529
2683
  React19.useEffect(function() {
2530
2684
  toastState.subs.push(s[1]);
2685
+ s[1](toastState.list.slice());
2531
2686
  return function() {
2532
2687
  toastState.subs = toastState.subs.filter(function(f) {
2533
2688
  return f !== s[1];
@@ -2589,15 +2744,30 @@ var React21 = __toESM(require("react"), 1);
2589
2744
  function items(errors) {
2590
2745
  if (Array.isArray(errors)) return errors;
2591
2746
  const out = [];
2592
- for (const k in errors || {}) {
2593
- const e = errors[k];
2594
- if (e && e.message) out.push({ field: k, message: e.message });
2747
+ function walk(e, path, depth) {
2748
+ if (!e || typeof e !== "object" || depth > 8) return;
2749
+ const o = e;
2750
+ if (o.message) out.push({ field: path, message: o.message });
2751
+ for (const k in o) {
2752
+ if (k === "ref" || k === "type" || k === "types" || k === "message") continue;
2753
+ walk(o[k], path ? path + "." + k : k, depth + 1);
2754
+ }
2595
2755
  }
2756
+ walk(errors, "", 0);
2596
2757
  return out;
2597
2758
  }
2598
2759
  function fieldElement(field) {
2599
2760
  if (typeof document === "undefined") return null;
2600
- return document.getElementById(field) || document.querySelector('[name="' + field.replace(/"/g, '\\"') + '"]');
2761
+ const byId = document.getElementById(field);
2762
+ if (byId) return byId;
2763
+ const named = document.querySelector('[name="' + field.replace(/"/g, '\\"') + '"]');
2764
+ if (named && named.getAttribute("type") === "hidden") {
2765
+ const box = named.closest(".aura-field") || named.parentElement;
2766
+ return box && box.querySelector(
2767
+ 'input:not([type="hidden"]), [role="combobox"], select, textarea, button:not([tabindex="-1"])'
2768
+ ) || named;
2769
+ }
2770
+ return named;
2601
2771
  }
2602
2772
  var FormErrorSummary = React21.forwardRef(
2603
2773
  function FormErrorSummary2(props, ref) {
@@ -2805,6 +2975,30 @@ var import_react_dom5 = require("react-dom");
2805
2975
 
2806
2976
  // src/useModal.tsx
2807
2977
  var React24 = __toESM(require("react"), 1);
2978
+ var locks = 0;
2979
+ var savedOverflow = "";
2980
+ function lockScroll() {
2981
+ const body = document.body;
2982
+ if (locks === 0) savedOverflow = body.style.overflow;
2983
+ locks++;
2984
+ body.style.overflow = "hidden";
2985
+ let done = false;
2986
+ return function() {
2987
+ if (done) return;
2988
+ done = true;
2989
+ locks--;
2990
+ if (locks === 0) body.style.overflow = savedOverflow;
2991
+ };
2992
+ }
2993
+ function tabbable(el) {
2994
+ const all = Array.prototype.filter.call(el.querySelectorAll(FOCUSABLE), function(c) {
2995
+ return c.tabIndex >= 0;
2996
+ });
2997
+ const shown = all.filter(function(c) {
2998
+ return c.getClientRects().length > 0;
2999
+ });
3000
+ return shown.length ? shown : all;
3001
+ }
2808
3002
  function useModal(open, ref, opts) {
2809
3003
  const mounted = useMounted();
2810
3004
  const prev = React24.useRef(null);
@@ -2813,8 +3007,7 @@ function useModal(open, ref, opts) {
2813
3007
  function() {
2814
3008
  if (!open || !mounted) return;
2815
3009
  prev.current = document.activeElement;
2816
- const body = document.body, overflow = body.style.overflow;
2817
- body.style.overflow = "hidden";
3010
+ const unlock = lockScroll();
2818
3011
  const el = ref.current;
2819
3012
  const firstIn = function(scope) {
2820
3013
  if (!scope || !el) return null;
@@ -2829,7 +3022,7 @@ function useModal(open, ref, opts) {
2829
3022
  const target = el && (el.querySelector("[data-autofocus]") || firstIn(o.bodySelector) || firstIn(o.footSelector) || el);
2830
3023
  if (target && o.autoFocus !== false) target.focus();
2831
3024
  return function() {
2832
- body.style.overflow = overflow;
3025
+ unlock();
2833
3026
  if (prev.current && prev.current.focus) prev.current.focus();
2834
3027
  };
2835
3028
  },
@@ -2841,17 +3034,18 @@ function useModal(open, ref, opts) {
2841
3034
  if (o.onEscape) o.onEscape();
2842
3035
  return;
2843
3036
  }
2844
- if (e.key !== "Tab" || !ref.current) return;
2845
- const list = Array.prototype.slice.call(ref.current.querySelectorAll(FOCUSABLE));
3037
+ if (e.key !== "Tab" || !ref.current || e.defaultPrevented) return;
3038
+ if (!ref.current.contains(e.target)) return;
3039
+ const list = tabbable(ref.current);
2846
3040
  if (!list.length) {
2847
3041
  e.preventDefault();
2848
3042
  return;
2849
3043
  }
2850
- const first = list[0], last = list[list.length - 1];
2851
- if (e.shiftKey && (document.activeElement === first || document.activeElement === ref.current)) {
3044
+ const first = list[0], last = list[list.length - 1], active = document.activeElement, stray = active === ref.current;
3045
+ if (e.shiftKey && (active === first || stray)) {
2852
3046
  e.preventDefault();
2853
3047
  last.focus();
2854
- } else if (!e.shiftKey && document.activeElement === last) {
3048
+ } else if (!e.shiftKey && (active === last || stray)) {
2855
3049
  e.preventDefault();
2856
3050
  first.focus();
2857
3051
  }
@@ -2974,6 +3168,7 @@ function Command(props) {
2974
3168
  e.preventDefault();
2975
3169
  move("last");
2976
3170
  } else if (e.key === "Enter") {
3171
+ if (e.nativeEvent.isComposing || e.keyCode === 229) return;
2977
3172
  e.preventDefault();
2978
3173
  if (active >= 0) run(flat[active]);
2979
3174
  }
@@ -3093,7 +3288,7 @@ var import_react_dom6 = require("react-dom");
3093
3288
  var Tooltip = React26.forwardRef(function Tooltip2(props, ref) {
3094
3289
  const id = uid(), st = React26.useState(false), open = props.open !== void 0 ? props.open : st[0], set = st[1];
3095
3290
  const anchor = React26.useRef(null), anchorMerged = useMergedRef(ref, anchor), tip = React26.useRef(null), timer = React26.useRef(void 0);
3096
- const pos = React26.useState(null);
3291
+ const pos = React26.useState(null), mounted = useMounted();
3097
3292
  function show2(now) {
3098
3293
  clearTimeout(timer.current);
3099
3294
  timer.current = setTimeout(
@@ -3107,34 +3302,55 @@ var Tooltip = React26.forwardRef(function Tooltip2(props, ref) {
3107
3302
  clearTimeout(timer.current);
3108
3303
  set(false);
3109
3304
  }
3305
+ function hideSoon() {
3306
+ clearTimeout(timer.current);
3307
+ timer.current = setTimeout(function() {
3308
+ set(false);
3309
+ }, 120);
3310
+ }
3311
+ React26.useEffect(function() {
3312
+ return function() {
3313
+ clearTimeout(timer.current);
3314
+ };
3315
+ }, []);
3316
+ function place() {
3317
+ if (!anchor.current || !tip.current) return;
3318
+ const r = anchor.current.getBoundingClientRect(), t = tip.current.getBoundingClientRect();
3319
+ const vw = window.innerWidth, vh = window.innerHeight, gap = 8, m = 8;
3320
+ let side = props.side || "top";
3321
+ if (side === "top" && r.top - t.height - gap < m && r.bottom + gap + t.height <= vh - m) side = "bottom";
3322
+ else if (side === "bottom" && r.bottom + gap + t.height > vh - m && r.top - t.height - gap >= m) side = "top";
3323
+ else if (side === "left" && r.left - t.width - gap < m && r.right + gap + t.width <= vw - m) side = "right";
3324
+ else if (side === "right" && r.right + gap + t.width > vw - m && r.left - t.width - gap >= m) side = "left";
3325
+ const clampX = function(x) {
3326
+ return Math.max(m, Math.min(x, vw - t.width - m));
3327
+ };
3328
+ const clampY = function(y) {
3329
+ return Math.max(m, Math.min(y, vh - t.height - m));
3330
+ };
3331
+ let top, left;
3332
+ if (side === "top" || side === "bottom") {
3333
+ top = clampY(side === "top" ? r.top - t.height - gap : r.bottom + gap);
3334
+ left = clampX(r.left + r.width / 2 - t.width / 2);
3335
+ } else {
3336
+ left = side === "left" ? r.left - t.width - gap : r.right + gap;
3337
+ left = clampX(left);
3338
+ top = clampY(r.top + r.height / 2 - t.height / 2);
3339
+ }
3340
+ pos[1]({ top, left });
3341
+ }
3110
3342
  useIsoLayoutEffect(
3111
3343
  function() {
3112
- if (!open || !anchor.current || !tip.current) return;
3113
- const r = anchor.current.getBoundingClientRect(), t = tip.current.getBoundingClientRect();
3114
- const vw = window.innerWidth, vh = window.innerHeight, gap = 8, m = 8;
3115
- let side = props.side || "top";
3116
- if (side === "top" && r.top - t.height - gap < m && r.bottom + gap + t.height <= vh - m) side = "bottom";
3117
- else if (side === "bottom" && r.bottom + gap + t.height > vh - m && r.top - t.height - gap >= m) side = "top";
3118
- else if (side === "left" && r.left - t.width - gap < m && r.right + gap + t.width <= vw - m) side = "right";
3119
- else if (side === "right" && r.right + gap + t.width > vw - m && r.left - t.width - gap >= m) side = "left";
3120
- const clampX = function(x) {
3121
- return Math.max(m, Math.min(x, vw - t.width - m));
3122
- };
3123
- const clampY = function(y) {
3124
- return Math.max(m, Math.min(y, vh - t.height - m));
3344
+ if (!open) return;
3345
+ place();
3346
+ window.addEventListener("scroll", place, true);
3347
+ window.addEventListener("resize", place);
3348
+ return function() {
3349
+ window.removeEventListener("scroll", place, true);
3350
+ window.removeEventListener("resize", place);
3125
3351
  };
3126
- let top, left;
3127
- if (side === "top" || side === "bottom") {
3128
- top = clampY(side === "top" ? r.top - t.height - gap : r.bottom + gap);
3129
- left = clampX(r.left + r.width / 2 - t.width / 2);
3130
- } else {
3131
- left = side === "left" ? r.left - t.width - gap : r.right + gap;
3132
- left = clampX(left);
3133
- top = clampY(r.top + r.height / 2 - t.height / 2);
3134
- }
3135
- pos[1]({ top, left });
3136
3352
  },
3137
- [open]
3353
+ [open, mounted]
3138
3354
  );
3139
3355
  React26.useEffect(
3140
3356
  function() {
@@ -3158,7 +3374,7 @@ var Tooltip = React26.forwardRef(function Tooltip2(props, ref) {
3158
3374
  onMouseEnter: function() {
3159
3375
  show2(false);
3160
3376
  },
3161
- onMouseLeave: hide,
3377
+ onMouseLeave: hideSoon,
3162
3378
  onFocus: function() {
3163
3379
  show2(true);
3164
3380
  },
@@ -3166,14 +3382,18 @@ var Tooltip = React26.forwardRef(function Tooltip2(props, ref) {
3166
3382
  },
3167
3383
  React26.cloneElement(child, { "aria-describedby": open ? id : child.props["aria-describedby"] })
3168
3384
  );
3169
- return /* @__PURE__ */ React26.createElement(React26.Fragment, null, trigger, open ? (0, import_react_dom6.createPortal)(
3385
+ return /* @__PURE__ */ React26.createElement(React26.Fragment, null, trigger, open && mounted ? (0, import_react_dom6.createPortal)(
3170
3386
  /* @__PURE__ */ React26.createElement(
3171
3387
  "div",
3172
3388
  {
3173
3389
  ref: tip,
3174
3390
  id,
3175
3391
  role: "tooltip",
3176
- className: "aura-tooltip",
3392
+ onMouseEnter: function() {
3393
+ clearTimeout(timer.current);
3394
+ },
3395
+ onMouseLeave: hideSoon,
3396
+ className: "aura-tooltip aura-tooltip--hoverable",
3177
3397
  style: { top: pos[0] ? pos[0].top : -9999, left: pos[0] ? pos[0].left : -9999 }
3178
3398
  },
3179
3399
  props.content
@@ -3288,7 +3508,7 @@ var DataTable = React28.forwardRef(function DataTable2(props, ref) {
3288
3508
  byKey[c.key] = c;
3289
3509
  });
3290
3510
  const rows = props.rows || [];
3291
- const rowKey = props.rowKey || columns[0].key;
3511
+ const rowKey = props.rowKey || (columns[0] ? columns[0].key : "id");
3292
3512
  const manual = !!props.manual;
3293
3513
  const Link = useLinkComponent(props.linkComponent);
3294
3514
  const busy = !!props.loading;
@@ -3496,11 +3716,12 @@ var DataTable = React28.forwardRef(function DataTable2(props, ref) {
3496
3716
  if (lv && boxWidth[0] == null) hideTerms += " + " + w + "px * var(--aura-h" + lv + "-on, 1)";
3497
3717
  else fixedSum += w;
3498
3718
  });
3499
- let pinOffsets = {}, acc = 0;
3719
+ let pinOffsets = {}, acc = "0px";
3500
3720
  vis.forEach(function(c) {
3501
3721
  if (isPinned(c)) {
3502
3722
  pinOffsets[c.key] = acc;
3503
- acc += widthOf(c);
3723
+ const lv = hideLevel(c);
3724
+ acc += " + " + widthOf(c) + "px" + (lv && boxWidth[0] == null ? " * var(--aura-h" + lv + "-on, 1)" : "");
3504
3725
  }
3505
3726
  });
3506
3727
  const selW = selectable ? " + var(--aura-table-select-width)" : "";
@@ -3515,9 +3736,10 @@ var DataTable = React28.forwardRef(function DataTable2(props, ref) {
3515
3736
  s["--aura-cell-flex"] = !hasFlex && i === vis.length - 1 ? "1 0 auto" : "none";
3516
3737
  s["--aura-cell-w"] = w + "px";
3517
3738
  }
3518
- if (isPinned(c)) s["--aura-cell-left"] = "calc(var(--aura-space-6)" + selW + " + " + pinOffsets[c.key] + "px)";
3739
+ if (isPinned(c)) s["--aura-cell-left"] = "calc(var(--aura-space-6)" + selW + " + " + pinOffsets[c.key] + ")";
3519
3740
  return s;
3520
3741
  }
3742
+ const sortCol = sort && sort.key ? byKey[sort.key] : void 0;
3521
3743
  const view = React28.useMemo(
3522
3744
  function() {
3523
3745
  if (manual || !sort || !sort.key || !byKey[sort.key]) return rows;
@@ -3536,7 +3758,16 @@ var DataTable = React28.forwardRef(function DataTable2(props, ref) {
3536
3758
  return p[0];
3537
3759
  });
3538
3760
  },
3539
- [rows, manual, sort && sort.key, sort && sort.dir]
3761
+ [
3762
+ rows,
3763
+ manual,
3764
+ sort && sort.key,
3765
+ sort && sort.dir,
3766
+ !!sortCol,
3767
+ sortCol && sortCol.sortValue,
3768
+ sortCol && sortCol.pill,
3769
+ sortCol && sortCol.tones
3770
+ ]
3540
3771
  );
3541
3772
  function nextSort(key) {
3542
3773
  if (!sort || sort.key !== key) return { key, dir: "asc" };
@@ -3545,14 +3776,37 @@ var DataTable = React28.forwardRef(function DataTable2(props, ref) {
3545
3776
  }
3546
3777
  const pageSize = props.pageSize || 0;
3547
3778
  const total = manual ? props.totalRows != null ? props.totalRows : (Math.max(1, pageState[0] || 1) - 1) * pageSize + rows.length + (pageSize && rows.length >= pageSize ? 1 : 0) : view.length;
3548
- const pageCount = pageSize ? Math.max(1, Math.ceil(total / pageSize)) : 1;
3779
+ const pageCount = pageSize ? Math.max(1, Math.ceil(total / pageSize), manual && props.totalRows == null ? pageState[0] || 1 : 1) : 1;
3549
3780
  const page = Math.min(Math.max(1, pageState[0] || 1), pageCount);
3550
3781
  const first = pageSize ? (page - 1) * pageSize : 0;
3551
3782
  const pageRows = pageSize && !manual ? view.slice(first, first + pageSize) : view;
3552
3783
  const canSortAny = !busy && (manual ? total > 1 : rows.length > 1);
3553
3784
  const shownTotal = manual && props.totalRows == null ? first + rows.length : total;
3785
+ const prevCount = React28.useRef(pageCount);
3786
+ React28.useEffect(
3787
+ function() {
3788
+ if (busy) return;
3789
+ const before = prevCount.current;
3790
+ prevCount.current = pageCount;
3791
+ const asked = pageState[0] || 1;
3792
+ if (asked === page || pageCount >= before || asked > before) return;
3793
+ if (props.getPageHref && !props.onPageChange && !props.onStateChange) return;
3794
+ pageState[1](page);
3795
+ emit(sort, page);
3796
+ },
3797
+ [pageState[0], page, busy, pageCount]
3798
+ );
3554
3799
  const linkPaging = !!props.getPageHref && !props.onPageChange && !oneCallback;
3555
- const prevLink = React28.useRef(null), nextLink = React28.useRef(null);
3800
+ const prevLink = React28.useRef(null), nextLink = React28.useRef(null), jumpLink = React28.useRef(null);
3801
+ const jumpState = React28.useState(null);
3802
+ React28.useEffect(
3803
+ function() {
3804
+ if (jumpState[0] == null) return;
3805
+ if (jumpLink.current) jumpLink.current.click();
3806
+ jumpState[1](null);
3807
+ },
3808
+ [jumpState[0]]
3809
+ );
3556
3810
  function emit(s, p) {
3557
3811
  if (props.onStateChange) props.onStateChange({ sort: s, page: p });
3558
3812
  }
@@ -3563,6 +3817,7 @@ var DataTable = React28.forwardRef(function DataTable2(props, ref) {
3563
3817
  if (linkPaging) {
3564
3818
  const a = next === page - 1 ? prevLink.current : next === page + 1 ? nextLink.current : null;
3565
3819
  if (a) a.click();
3820
+ else jumpState[1](next);
3566
3821
  return false;
3567
3822
  }
3568
3823
  if (focus) pending.current = focus;
@@ -3599,7 +3854,8 @@ var DataTable = React28.forwardRef(function DataTable2(props, ref) {
3599
3854
  }
3600
3855
  const height = props.height || 0;
3601
3856
  const virtual = !!height && !loading && pageRows.length > 0 && !stacked;
3602
- const bodyH = Math.max(ROW_H, height - ROW_H);
3857
+ const stickyTotal = !!(props.footer && props.stickyFooter && rows.length && !loading);
3858
+ const bodyH = Math.max(ROW_H, height - ROW_H - (stickyTotal ? ROW_H : 0));
3603
3859
  let start = 0, end = pageRows.length;
3604
3860
  if (virtual) {
3605
3861
  start = Math.max(0, Math.floor(scrollTop / ROW_H) - OVERSCAN);
@@ -3608,9 +3864,10 @@ var DataTable = React28.forwardRef(function DataTable2(props, ref) {
3608
3864
  const visibleRows = Math.max(1, Math.floor(bodyH / ROW_H));
3609
3865
  const nCols = vis.length + (selectable ? 1 : 0);
3610
3866
  const nRows = loading ? 0 : pageRows.length;
3867
+ const hasTotal = !!(props.footer && rows.length && !loading), T = nRows + 1, lastR = nRows + (hasTotal ? 1 : 0);
3611
3868
  const active = activeState[0];
3612
- const ar = Math.min(active.r, nRows), ac = Math.min(active.c, nCols - 1);
3613
- const activeRendered = ar === 0 || ar - 1 >= start && ar - 1 < end;
3869
+ const ar = Math.min(active.r, lastR), ac = Math.min(active.c, nCols - 1);
3870
+ const activeRendered = ar === 0 || hasTotal && ar === T || ar - 1 >= start && ar - 1 < end;
3614
3871
  function colAt(ci) {
3615
3872
  return selectable ? ci === 0 ? null : vis[ci - 1] : vis[ci];
3616
3873
  }
@@ -3629,6 +3886,11 @@ var DataTable = React28.forwardRef(function DataTable2(props, ref) {
3629
3886
  });
3630
3887
  c = at >= 0 ? at + (selectable ? 1 : 0) : Math.min(p.c || 0, nCols - 1);
3631
3888
  }
3889
+ const ae = document.activeElement;
3890
+ if (ae && ae !== document.body && !gridRef.current.contains(ae)) {
3891
+ pending.current = null;
3892
+ return;
3893
+ }
3632
3894
  const el = gridRef.current.querySelector('[data-rc="' + p.r + ":" + c + '"]');
3633
3895
  if (el) {
3634
3896
  pending.current = null;
@@ -3636,12 +3898,33 @@ var DataTable = React28.forwardRef(function DataTable2(props, ref) {
3636
3898
  }
3637
3899
  });
3638
3900
  function focusCell(r, c) {
3639
- r = Math.max(0, Math.min(r, nRows));
3901
+ r = Math.max(0, Math.min(r, lastR));
3640
3902
  c = Math.max(0, Math.min(c, nCols - 1));
3641
3903
  if (stacked && r === 0 && nRows > 0 && !(selectable && c === 0)) r = 1;
3904
+ if (gridRef.current && r === T && hasTotal) {
3905
+ const shown2 = function(cc) {
3906
+ const e = gridRef.current.querySelector('[data-rc="' + r + ":" + cc + '"]');
3907
+ return !!e && e.getClientRects().length > 0;
3908
+ };
3909
+ if (!shown2(c))
3910
+ for (let d = 1; d < nCols; d++) {
3911
+ if (c + d < nCols && shown2(c + d)) {
3912
+ c = c + d;
3913
+ break;
3914
+ }
3915
+ if (c - d >= 0 && shown2(c - d)) {
3916
+ c = c - d;
3917
+ break;
3918
+ }
3919
+ }
3920
+ }
3642
3921
  activeState[1]({ r, c });
3643
3922
  pending.current = { r, c };
3644
- if (virtual && r > 0) {
3923
+ if (virtual && hasTotal && r === T && !props.stickyFooter) {
3924
+ const sc = scrollRef.current;
3925
+ sc.scrollTop = sc.scrollHeight;
3926
+ setScrollTop(sc.scrollTop);
3927
+ } else if (virtual && r > 0 && r <= nRows) {
3645
3928
  const sc = scrollRef.current, top = (r - 1) * ROW_H;
3646
3929
  if (top < sc.scrollTop) sc.scrollTop = top;
3647
3930
  else if (top + ROW_H > sc.scrollTop + bodyH) sc.scrollTop = top + ROW_H - bodyH;
@@ -3658,26 +3941,28 @@ var DataTable = React28.forwardRef(function DataTable2(props, ref) {
3658
3941
  });
3659
3942
  const selSet = {};
3660
3943
  selected.forEach(function(k) {
3661
- selSet[k] = true;
3944
+ selSet[String(k)] = true;
3662
3945
  });
3663
3946
  const nSel = pageKeys.filter(function(k) {
3664
- return selSet[k];
3947
+ return selSet[String(k)];
3665
3948
  }).length;
3666
3949
  const all = nSel > 0 && nSel === pageKeys.length;
3667
3950
  function toggle(k, on) {
3668
3951
  setSelected(
3669
3952
  on ? selected.concat([k]) : selected.filter(function(x) {
3670
- return x !== k;
3953
+ return String(x) !== String(k);
3671
3954
  })
3672
3955
  );
3673
3956
  }
3674
3957
  function toggleAll() {
3675
3958
  setSelected(
3676
3959
  all ? selected.filter(function(k) {
3677
- return pageKeys.indexOf(k) < 0;
3960
+ return !pageKeys.some(function(p) {
3961
+ return String(p) === String(k);
3962
+ });
3678
3963
  }) : selected.concat(
3679
3964
  pageKeys.filter(function(k) {
3680
- return !selSet[k];
3965
+ return !selSet[String(k)];
3681
3966
  })
3682
3967
  )
3683
3968
  );
@@ -3882,7 +4167,7 @@ var DataTable = React28.forwardRef(function DataTable2(props, ref) {
3882
4167
  return;
3883
4168
  }
3884
4169
  const p = rc.split(":"), r = +p[0], c = +p[1], k = e.key, col = colAt(c);
3885
- const row = r > 0 ? pageRows[r - 1] : null;
4170
+ const row = r > 0 && r <= nRows ? pageRows[r - 1] : null, isTotal = hasTotal && r === T;
3886
4171
  let handled = true;
3887
4172
  if (r === 0 && col && e.altKey && (k === "ArrowLeft" || k === "ArrowRight") && canResize(col))
3888
4173
  setW(col, widthOf(col) + (k === "ArrowLeft" ? -1 : 1) * (e.shiftKey ? 48 : 16), true);
@@ -3893,21 +4178,23 @@ var DataTable = React28.forwardRef(function DataTable2(props, ref) {
3893
4178
  else if (k === "ArrowRight") focusCell(r, c + 1);
3894
4179
  else if (k === "ArrowLeft") focusCell(r, c - 1);
3895
4180
  else if (k === "ArrowDown") {
3896
- if (r < nRows) focusCell(r + 1, c);
4181
+ if (r < lastR) focusCell(r + 1, c);
3897
4182
  else if (pageSize && page < pageCount && goPage(page + 1, { r: 1, c })) activeState[1]({ r: 1, c });
3898
4183
  } else if (k === "ArrowUp") {
3899
4184
  if (r > 1 || r === 1 && !(pageSize && page > 1)) focusCell(r - 1, c);
3900
4185
  else if (r === 1 && goPage(page - 1, { r: pageSize, c })) activeState[1]({ r: pageSize, c });
3901
4186
  } else if (k === "Home") focusCell(e.ctrlKey ? 1 : r, 0);
3902
- else if (k === "End") focusCell(e.ctrlKey ? nRows : r, nCols - 1);
4187
+ else if (k === "End") focusCell(e.ctrlKey ? lastR : r, nCols - 1);
3903
4188
  else if (k === "PageDown") {
3904
4189
  if (pageSize) {
3905
4190
  if (goPage(page + 1, { r: 1, c })) activeState[1]({ r: 1, c });
3906
- } else focusCell(Math.min(nRows, r + visibleRows), c);
4191
+ } else focusCell(Math.min(lastR, r + visibleRows), c);
3907
4192
  } else if (k === "PageUp") {
3908
4193
  if (pageSize) {
3909
4194
  if (goPage(page - 1, { r: 1, c })) activeState[1]({ r: 1, c });
3910
4195
  } else focusCell(Math.max(1, r - visibleRows), c);
4196
+ } else if (isTotal && (k === " " || k === "Enter" || k === "F2")) {
4197
+ handled = false;
3911
4198
  } else if (k === "F2" && r > 0) {
3912
4199
  const inner = target.querySelector("button, a[href], input, select, textarea");
3913
4200
  if (inner) inner.focus();
@@ -4278,9 +4565,10 @@ var DataTable = React28.forwardRef(function DataTable2(props, ref) {
4278
4565
  }
4279
4566
  );
4280
4567
  }
4281
- if (pageSize && (rows.length || busy)) {
4568
+ const openTotal = manual && props.totalRows == null && !!pageSize && rows.length >= pageSize;
4569
+ if (pageSize && (rows.length || busy || page > 1)) {
4282
4570
  const from = rows.length ? first + 1 : 0, to = manual ? first + rows.length : Math.min(first + pageSize, view.length);
4283
- foot = /* @__PURE__ */ React28.createElement("div", { className: "aura-table__foot" }, /* @__PURE__ */ React28.createElement("span", { "aria-live": "polite" }, busy ? t.loading : t.range(from, to, shownTotal)), /* @__PURE__ */ React28.createElement("span", { className: "aura-table__pager" }, /* @__PURE__ */ React28.createElement("span", null, t.page(page, pageCount)), pagerButton(-1), pagerButton(1)));
4571
+ foot = /* @__PURE__ */ React28.createElement("div", { className: "aura-table__foot" }, /* @__PURE__ */ React28.createElement("span", { "aria-live": "polite" }, busy ? t.loading : openTotal ? t.rangeOpen(from, to) : t.range(from, to, shownTotal)), /* @__PURE__ */ React28.createElement("span", { className: "aura-table__pager" }, /* @__PURE__ */ React28.createElement("span", null, openTotal ? t.pageOpen(page) : t.page(page, pageCount)), pagerButton(-1), pagerButton(1)));
4284
4572
  } else if (height && rows.length && !loading) {
4285
4573
  foot = /* @__PURE__ */ React28.createElement("div", { className: "aura-table__foot" }, /* @__PURE__ */ React28.createElement("span", null, t.rowCount(shownTotal)), selectable && selected.length ? /* @__PURE__ */ React28.createElement("span", null, t.selectedCount(selected.length)) : /* @__PURE__ */ React28.createElement("span", null));
4286
4574
  }
@@ -4294,15 +4582,32 @@ var DataTable = React28.forwardRef(function DataTable2(props, ref) {
4294
4582
  style: rowStyle
4295
4583
  },
4296
4584
  /* @__PURE__ */ React28.createElement("span", { className: "aura-table__gutter", "aria-hidden": true }),
4297
- selectable ? /* @__PURE__ */ React28.createElement("span", { className: cx("aura-table__sel", nPinned && "is-pinned"), "aria-hidden": true }) : null,
4585
+ selectable ? /* @__PURE__ */ React28.createElement(
4586
+ "span",
4587
+ {
4588
+ role: "gridcell",
4589
+ "aria-colindex": 1,
4590
+ className: cx("aura-table__sel", nPinned && "is-pinned"),
4591
+ tabIndex: tabFor(T, 0),
4592
+ "data-rc": T + ":0",
4593
+ onFocus: function() {
4594
+ activeState[1]({ r: T, c: 0 });
4595
+ }
4596
+ }
4597
+ ) : null,
4298
4598
  vis.map(function(c, j) {
4299
- const pin = isPinned(c);
4599
+ const pin = isPinned(c), ci = j + (selectable ? 1 : 0);
4300
4600
  return /* @__PURE__ */ React28.createElement(
4301
4601
  "span",
4302
4602
  {
4303
4603
  key: c.key,
4304
4604
  role: "gridcell",
4305
4605
  "aria-colindex": j + (selectable ? 2 : 1),
4606
+ tabIndex: tabFor(T, ci),
4607
+ "data-rc": T + ":" + ci,
4608
+ onFocus: function() {
4609
+ if (activeState[0].r !== T || activeState[0].c !== ci) activeState[1]({ r: T, c: ci });
4610
+ },
4306
4611
  className: cx(
4307
4612
  "aura-table__td",
4308
4613
  c.mono && "aura-table__mono",
@@ -4328,8 +4633,9 @@ var DataTable = React28.forwardRef(function DataTable2(props, ref) {
4328
4633
  )
4329
4634
  ) : null;
4330
4635
  const scrollStyle = {
4331
- scrollPaddingLeft: "calc(var(--aura-space-6)" + selW + " + " + acc + "px)",
4332
- scrollPaddingTop: ROW_H + "px"
4636
+ scrollPaddingLeft: "calc(var(--aura-space-6)" + selW + " + " + acc + ")",
4637
+ scrollPaddingTop: ROW_H + "px",
4638
+ scrollPaddingBottom: stickyTotal ? ROW_H + "px" : void 0
4333
4639
  };
4334
4640
  if (height) scrollStyle["--aura-table-h"] = height + "px";
4335
4641
  const gridEl = /* @__PURE__ */ React28.createElement(
@@ -4363,7 +4669,7 @@ var DataTable = React28.forwardRef(function DataTable2(props, ref) {
4363
4669
  role: "grid",
4364
4670
  "aria-label": props.label,
4365
4671
  "aria-busy": busy || void 0,
4366
- "aria-rowcount": loading ? -1 : shownTotal + 1 + (totalRow ? 1 : 0),
4672
+ "aria-rowcount": loading || manual && props.totalRows == null && pageSize && rows.length >= pageSize ? -1 : shownTotal + 1 + (totalRow ? 1 : 0),
4367
4673
  "aria-colcount": nCols,
4368
4674
  "aria-multiselectable": selectable || void 0,
4369
4675
  onKeyDown: onGridKey,
@@ -4411,7 +4717,8 @@ var DataTable = React28.forwardRef(function DataTable2(props, ref) {
4411
4717
  items: menu.kind === "picker" ? pickerItems() : byKey[menu.key] ? columnMenuItems(byKey[menu.key]) : []
4412
4718
  }
4413
4719
  ) : null,
4414
- tipEl
4720
+ tipEl,
4721
+ jumpState[0] != null && props.getPageHref ? /* @__PURE__ */ React28.createElement(Link, { ref: jumpLink, href: props.getPageHref(jumpState[0]), hidden: true, tabIndex: -1, "aria-hidden": true }) : null
4415
4722
  );
4416
4723
  if (!levels.length) return gridEl;
4417
4724
  let out = gridEl;
@@ -4456,19 +4763,23 @@ var Card = React29.forwardRef(function Card2(props, ref) {
4456
4763
  var React30 = __toESM(require("react"), 1);
4457
4764
  var Tabs = React30.forwardRef(function Tabs2(props, ref) {
4458
4765
  const items2 = props.tabs || [], base = uid();
4766
+ const asLinks = items2.length > 0 && items2.every(function(t) {
4767
+ return !!t.href;
4768
+ });
4769
+ const firstOn = items2.filter(function(t) {
4770
+ return !t.disabled;
4771
+ })[0];
4459
4772
  const st = useMaybeControlled(
4460
4773
  props.value,
4461
- props.defaultValue || items2[0] && items2[0].id,
4774
+ props.defaultValue || (asLinks ? void 0 : firstOn && firstOn.id),
4462
4775
  props.onChange
4463
4776
  );
4777
+ const cur = asLinks && "value" in props ? props.value : st[0];
4464
4778
  const refs = React30.useRef({});
4465
4779
  const current2 = items2.filter(function(t) {
4466
- return t.id === st[0];
4467
- })[0] || items2[0];
4780
+ return t.id === cur;
4781
+ })[0] || firstOn || items2[0];
4468
4782
  const Link = useLinkComponent(props.linkComponent);
4469
- const asLinks = items2.length > 0 && items2.every(function(t) {
4470
- return !!t.href;
4471
- });
4472
4783
  if (asLinks)
4473
4784
  return /* @__PURE__ */ React30.createElement(
4474
4785
  "nav",
@@ -4478,7 +4789,7 @@ var Tabs = React30.forwardRef(function Tabs2(props, ref) {
4478
4789
  className: cx("aura-tabs aura-tabs--links", props.className)
4479
4790
  },
4480
4791
  /* @__PURE__ */ React30.createElement("div", { className: "aura-tabs__list" }, items2.map(function(t) {
4481
- const on = t.id === st[0];
4792
+ const on = t.id === cur;
4482
4793
  const inner = [
4483
4794
  t.icon ? /* @__PURE__ */ React30.createElement(Icon, { key: "i", name: t.icon }) : null,
4484
4795
  t.label,
@@ -4724,6 +5035,7 @@ var SideNav = React31.forwardRef(function SideNav2(props, ref) {
4724
5035
  style: depth ? { ["--aura-nav-depth"]: depth } : void 0,
4725
5036
  onClick: function(e) {
4726
5037
  if (!it.href) e.preventDefault();
5038
+ else if (!plainClick(e)) return;
4727
5039
  st[1](it.id);
4728
5040
  }
4729
5041
  };
@@ -4801,7 +5113,7 @@ function initials(name) {
4801
5113
  return ((parts[0] || "?")[0] + (parts.length > 1 ? parts[parts.length - 1][0] : parts[0][1] || "")).toUpperCase();
4802
5114
  }
4803
5115
  var Avatar = React33.forwardRef(function Avatar2(props, ref) {
4804
- const size = props.size || "md", errState = React33.useState(false);
5116
+ const size = props.size || "md", errState = React33.useState(null);
4805
5117
  let hash = 0;
4806
5118
  String(props.name || "").split("").forEach(function(ch) {
4807
5119
  hash = hash * 31 + ch.charCodeAt(0) >>> 0;
@@ -4815,13 +5127,14 @@ var Avatar = React33.forwardRef(function Avatar2(props, ref) {
4815
5127
  role: "img",
4816
5128
  "aria-label": props.name + (props.status ? ", " + props.status : "")
4817
5129
  },
4818
- props.src && !errState[0] ? /* @__PURE__ */ React33.createElement(
5130
+ props.src && errState[0] !== props.src ? /* @__PURE__ */ React33.createElement(
4819
5131
  "img",
4820
5132
  {
5133
+ key: props.src,
4821
5134
  src: props.src,
4822
5135
  alt: "",
4823
5136
  onError: function() {
4824
- errState[1](true);
5137
+ errState[1](props.src || null);
4825
5138
  }
4826
5139
  }
4827
5140
  ) : /* @__PURE__ */ React33.createElement("span", { "aria-hidden": true }, initials(props.name)),
@@ -4941,16 +5254,24 @@ var AppShell = React38.forwardRef(function AppShell2(props, ref) {
4941
5254
  [wide]
4942
5255
  );
4943
5256
  const navEl = props.nav && React38.isValidElement(props.nav) ? props.nav : null;
5257
+ const shared = !!navEl && navEl.props.value === void 0 && (navEl.props.defaultValue !== void 0 || navEl.props.sections !== void 0 || navEl.props.items !== void 0);
5258
+ const navState = React38.useState(navEl ? navEl.props.defaultValue : void 0);
5259
+ function onNav(id) {
5260
+ if (shared) navState[1](id);
5261
+ if (navEl && navEl.props.onChange) navEl.props.onChange(id);
5262
+ }
5263
+ const deskNav = navEl && shared ? React38.cloneElement(navEl, { value: navState[0], onChange: onNav }) : props.nav;
4944
5264
  const drawerNav = navEl ? React38.cloneElement(navEl, {
5265
+ value: shared ? navState[0] : navEl.props.value,
4945
5266
  onChange: function(id) {
4946
- if (navEl.props.onChange) navEl.props.onChange(id);
5267
+ onNav(id);
4947
5268
  setOpen(false);
4948
5269
  },
4949
5270
  className: cx(navEl.props.className, "is-in-drawer"),
4950
5271
  collapsed: false,
4951
5272
  collapsible: false
4952
5273
  }) : props.nav;
4953
- return /* @__PURE__ */ React38.createElement("div", { ref, className: cx("aura-shell", props.bottomNav && "aura-shell--bottomnav", props.className) }, props.nav ? /* @__PURE__ */ React38.createElement("div", { className: "aura-shell__nav" }, props.nav) : null, props.nav ? /* @__PURE__ */ React38.createElement(
5274
+ return /* @__PURE__ */ React38.createElement("div", { ref, className: cx("aura-shell", props.bottomNav && "aura-shell--bottomnav", props.className) }, props.nav ? /* @__PURE__ */ React38.createElement("div", { className: "aura-shell__nav" }, deskNav) : null, props.nav ? /* @__PURE__ */ React38.createElement(
4954
5275
  Drawer,
4955
5276
  {
4956
5277
  open,
@@ -5064,8 +5385,9 @@ var Table = React41.forwardRef(function Table2(props, ref) {
5064
5385
  className: "aura-tbl-wrap",
5065
5386
  "data-density": density,
5066
5387
  tabIndex: scrolls ? 0 : void 0,
5067
- role: scrolls ? "region" : void 0,
5068
- "aria-labelledby": scrolls && caption != null ? capId : void 0
5388
+ role: scrolls && (caption != null || rest["aria-label"]) ? "region" : void 0,
5389
+ "aria-labelledby": scrolls && caption != null ? capId : void 0,
5390
+ "aria-label": scrolls && caption == null ? rest["aria-label"] : void 0
5069
5391
  },
5070
5392
  /* @__PURE__ */ React41.createElement("table", { ref, className: cx("aura-tbl", className), ...rest }, caption != null ? /* @__PURE__ */ React41.createElement("caption", { id: capId, className: cx("aura-tbl__caption", captionHidden && "aura-sr-only") }, caption) : null, children)
5071
5393
  );
@@ -5134,6 +5456,7 @@ var BottomNav = React42.forwardRef(function BottomNav2(props, ref) {
5134
5456
  "aria-current": on ? "page" : void 0,
5135
5457
  onClick: function(e) {
5136
5458
  if (!it.href) e.preventDefault();
5459
+ else if (!plainClick(e)) return;
5137
5460
  st[1](it.id);
5138
5461
  }
5139
5462
  };
@@ -5222,6 +5545,7 @@ function parseTime(text) {
5222
5545
  const m = /^(\d{1,2})(?:[:.](\d{2}))?$/.exec(s) || /^(\d{1,2})(\d{2})$/.exec(s);
5223
5546
  if (!m) return null;
5224
5547
  let hh = +m[1], mm = m[2] ? +m[2] : 0;
5548
+ if ((am || pm) && (hh < 1 || hh > 12)) return null;
5225
5549
  if (pm && hh < 12) hh += 12;
5226
5550
  if (am && hh === 12) hh = 0;
5227
5551
  if (hh > 23 || mm > 59) return null;
@@ -5336,7 +5660,8 @@ var TimePicker = React45.forwardRef(function TimePicker2(props, ref) {
5336
5660
  return true;
5337
5661
  }
5338
5662
  if (blocked(v)) {
5339
- errState[1](t.timeOutOfRange(fromMin(lo), fromMin(hi)));
5663
+ const n2 = toMin(v);
5664
+ errState[1](n2 != null && n2 >= lo && n2 <= hi ? t.timeUnavailable : t.timeOutOfRange(fromMin(lo), fromMin(hi)));
5340
5665
  return false;
5341
5666
  }
5342
5667
  errState[1](null);
@@ -5579,7 +5904,23 @@ var FileUpload = React46.forwardRef(function FileUpload2(props, ref) {
5579
5904
  });
5580
5905
  };
5581
5906
  }, []);
5907
+ React46.useEffect(
5908
+ function() {
5909
+ const el = inputRef.current;
5910
+ if (!el || !props.name || typeof DataTransfer === "undefined") return;
5911
+ try {
5912
+ const dt = new DataTransfer();
5913
+ items2.forEach(function(i) {
5914
+ if (i.file && !i.error) dt.items.add(i.file);
5915
+ });
5916
+ el.files = dt.files;
5917
+ } catch (e) {
5918
+ }
5919
+ },
5920
+ [items2, props.name]
5921
+ );
5582
5922
  function thumb(it) {
5923
+ if (!it.file && it.url && /^image\//.test(it.type || "")) return it.url;
5583
5924
  if (!it.file || !/^image\//.test(it.type || "") || typeof URL === "undefined" || !URL.createObjectURL) return null;
5584
5925
  if (!urls.current[it.id]) urls.current[it.id] = URL.createObjectURL(it.file);
5585
5926
  return urls.current[it.id];
@@ -5685,7 +6026,7 @@ var FileUpload = React46.forwardRef(function FileUpload2(props, ref) {
5685
6026
  ),
5686
6027
  items2.length ? /* @__PURE__ */ React46.createElement("ul", { className: "aura-upload__list", "aria-live": "polite" }, items2.map(function(it) {
5687
6028
  const src = thumb(it);
5688
- return /* @__PURE__ */ React46.createElement("li", { key: it.id, className: cx("aura-upload__item", it.error && "is-error") }, src ? /* @__PURE__ */ React46.createElement("img", { className: "aura-upload__thumb", src, alt: "" }) : /* @__PURE__ */ React46.createElement("span", { className: "aura-upload__thumb is-icon", "aria-hidden": true }, /* @__PURE__ */ React46.createElement(Icon, { name: /^image\//.test(it.type || "") ? "image" : "file", size: "md" })), /* @__PURE__ */ React46.createElement("span", { className: "aura-upload__meta" }, /* @__PURE__ */ React46.createElement("span", { className: "aura-upload__name" }, it.name), /* @__PURE__ */ React46.createElement("span", { className: "aura-upload__sub" }, it.error ? /* @__PURE__ */ React46.createElement(React46.Fragment, null, /* @__PURE__ */ React46.createElement(Icon, { name: "circle-alert", size: 12 }), it.error) : it.status === "uploading" ? t.uploading + (it.progress != null ? " " + Math.round(it.progress) + "%" : "") : it.status === "done" ? /* @__PURE__ */ React46.createElement(React46.Fragment, null, /* @__PURE__ */ React46.createElement(Icon, { name: "circle-check", size: 12 }), formatBytes(it.size)) : formatBytes(it.size)), it.status === "uploading" ? /* @__PURE__ */ React46.createElement(
6029
+ return /* @__PURE__ */ React46.createElement("li", { key: it.id, className: cx("aura-upload__item", it.error && "is-error") }, src ? /* @__PURE__ */ React46.createElement("img", { className: "aura-upload__thumb", src, alt: "" }) : /* @__PURE__ */ React46.createElement("span", { className: "aura-upload__thumb is-icon", "aria-hidden": true }, /* @__PURE__ */ React46.createElement(Icon, { name: /^image\//.test(it.type || "") ? "image" : "file", size: "md" })), /* @__PURE__ */ React46.createElement("span", { className: "aura-upload__meta" }, it.url && !it.error ? /* @__PURE__ */ React46.createElement("a", { className: "aura-upload__name", href: it.url, target: "_blank", rel: "noreferrer" }, it.name) : /* @__PURE__ */ React46.createElement("span", { className: "aura-upload__name" }, it.name), /* @__PURE__ */ React46.createElement("span", { className: "aura-upload__sub" }, it.error ? /* @__PURE__ */ React46.createElement(React46.Fragment, null, /* @__PURE__ */ React46.createElement(Icon, { name: "circle-alert", size: 12 }), it.error) : it.status === "uploading" ? t.uploading + (it.progress != null ? " " + Math.round(it.progress) + "%" : "") : it.status === "done" ? /* @__PURE__ */ React46.createElement(React46.Fragment, null, /* @__PURE__ */ React46.createElement(Icon, { name: "circle-check", size: 12 }), formatBytes(it.size)) : formatBytes(it.size)), it.status === "uploading" ? /* @__PURE__ */ React46.createElement(
5689
6030
  "span",
5690
6031
  {
5691
6032
  className: "aura-upload__bar",
@@ -5957,6 +6298,8 @@ function createTheme(opts) {
5957
6298
  }
5958
6299
  if (s) check("light", "ink", "accent-lime (signal)", 4.5, INK, s[200]);
5959
6300
  function css(selector) {
6301
+ if (selector !== void 0 && /[<{};@\r\n]|\/\*|\*\//.test(selector))
6302
+ throw new Error('createTheme: "' + selector + '" is not a plain CSS selector');
5960
6303
  const light = selector ? selector : ':root, [data-theme="light"]';
5961
6304
  const dark = selector ? selector + ".dark, .dark " + selector + ", " + selector + '[data-theme="dark"], [data-theme="dark"] ' + selector : '.dark, [data-theme="dark"]';
5962
6305
  const system = selector ? '[data-theme="system"] ' + selector + ", " + selector + '[data-theme="system"]' : '[data-theme="system"]';
@@ -5965,7 +6308,7 @@ function createTheme(opts) {
5965
6308
  return " --aura-" + k + ": " + m[k] + ";";
5966
6309
  }).join("\n") + "\n}";
5967
6310
  }
5968
- return "/* AURA theme" + (o.name ? ' "' + o.name + '"' : "") + ": brand " + o.brand + (o.signal ? ", signal " + o.signal : "") + (o.primary === "brand" ? ", brand primary buttons" : "") + ". Load after aura.css. Generated by createTheme. */\n" + block(light, L) + "\n" + block(dark, D) + "\n@media (prefers-color-scheme: dark) {\n" + block(system, D) + "\n}\n";
6311
+ return "/* AURA theme" + (o.name ? ' "' + String(o.name).replace(/[*/<>\\]/g, "") + '"' : "") + ": brand " + o.brand + (o.signal ? ", signal " + o.signal : "") + (o.primary === "brand" ? ", brand primary buttons" : "") + ". Load after aura.css. Generated by createTheme. */\n" + block(light, L) + "\n" + block(dark, D) + "\n@media (prefers-color-scheme: dark) {\n" + block(system, D) + "\n}\n";
5969
6312
  }
5970
6313
  return {
5971
6314
  name: o.name || null,
@@ -5986,12 +6329,21 @@ var React47 = __toESM(require("react"), 1);
5986
6329
  function ThemeStyle(props) {
5987
6330
  const css = React47.useMemo(
5988
6331
  function() {
5989
- return createTheme({ brand: props.brand, signal: props.signal, primary: props.primary, name: props.name }).css(
5990
- props.selector
5991
- );
6332
+ try {
6333
+ return createTheme({
6334
+ brand: props.brand,
6335
+ signal: props.signal,
6336
+ primary: props.primary,
6337
+ name: props.name
6338
+ }).css(props.selector);
6339
+ } catch (e) {
6340
+ devWarnOnce("theme-style", "ThemeStyle ignored: " + e.message);
6341
+ return null;
6342
+ }
5992
6343
  },
5993
6344
  [props.brand, props.signal, props.primary, props.name, props.selector]
5994
6345
  );
6346
+ if (css === null) return null;
5995
6347
  return /* @__PURE__ */ React47.createElement("style", { "data-aura-theme": props.name || props.brand, dangerouslySetInnerHTML: { __html: css } });
5996
6348
  }
5997
6349
 
@@ -6006,9 +6358,9 @@ function valid(v) {
6006
6358
  return typeof v === "string" && SCHEMES.indexOf(v) >= 0;
6007
6359
  }
6008
6360
  function colorSchemeScript(options) {
6009
- const key = JSON.stringify(options && options.storageKey || DEFAULT_KEY);
6010
- const fallback = JSON.stringify(options && options.defaultScheme || "system");
6011
- return "(function(){try{var s=localStorage.getItem(" + key + ");if(s!=='light'&&s!=='dark'&&s!=='system')s=" + fallback + `;var d=document.documentElement;d.setAttribute("data-theme",s);var dark=s==='dark'||(s==='system'&&window.matchMedia('(prefers-color-scheme: dark)').matches);d.classList.toggle("dark",dark);}catch(e){}})();`;
6361
+ const key = JSON.stringify(options && options.storageKey || DEFAULT_KEY).replace(/</g, "\\u003c");
6362
+ const fallback = JSON.stringify(options && options.defaultScheme || "system").replace(/</g, "\\u003c");
6363
+ return "(function(){try{var s=localStorage.getItem(" + key + ");if(s!=='light'&&s!=='dark'&&s!=='system')s=" + fallback + `;var d=document.documentElement;d.setAttribute("data-theme",s);var m=window.matchMedia('(prefers-color-scheme: dark)');d.classList.toggle('dark',s==='dark'||(s==='system'&&m.matches));if(m.addEventListener)m.addEventListener('change',function(e){if(d.getAttribute('data-theme')==='system')d.classList.toggle('dark',e.matches)});}catch(e){}})();`;
6012
6364
  }
6013
6365
 
6014
6366
  // src/colorScheme.tsx
@@ -6045,16 +6397,20 @@ function useColorScheme(options) {
6045
6397
  if (readScheme(fallback) === "system") apply("system");
6046
6398
  cb();
6047
6399
  }
6400
+ function onStorage(e) {
6401
+ if (e.key === key) apply(valid(e.newValue) ? e.newValue : fallback);
6402
+ cb();
6403
+ }
6048
6404
  if (mq) mq.addEventListener("change", onSystem);
6049
6405
  window.addEventListener(EVENT, cb);
6050
- window.addEventListener("storage", cb);
6406
+ window.addEventListener("storage", onStorage);
6051
6407
  return function() {
6052
6408
  if (mq) mq.removeEventListener("change", onSystem);
6053
6409
  window.removeEventListener(EVENT, cb);
6054
- window.removeEventListener("storage", cb);
6410
+ window.removeEventListener("storage", onStorage);
6055
6411
  };
6056
6412
  },
6057
- [fallback]
6413
+ [fallback, key]
6058
6414
  );
6059
6415
  const snapshot = React48.useSyncExternalStore(
6060
6416
  subscribe2,
@@ -6254,7 +6610,7 @@ var Pagination = React53.forwardRef(function Pagination2(props, ref) {
6254
6610
  {
6255
6611
  href: link(p),
6256
6612
  onClick: function(e) {
6257
- if (props.onChange) {
6613
+ if (props.onChange && plainClick(e)) {
6258
6614
  e.preventDefault();
6259
6615
  go(p);
6260
6616
  }
@@ -6296,7 +6652,7 @@ var Pagination = React53.forwardRef(function Pagination2(props, ref) {
6296
6652
  "aria-label": label,
6297
6653
  title: label,
6298
6654
  onClick: function(e) {
6299
- if (props.onChange) {
6655
+ if (props.onChange && plainClick(e)) {
6300
6656
  e.preventDefault();
6301
6657
  go(p);
6302
6658
  }
@@ -6375,13 +6731,20 @@ var Accordion = React54.forwardRef(function Accordion2(props, ref) {
6375
6731
  var React55 = __toESM(require("react"), 1);
6376
6732
  var import_react_dom11 = require("react-dom");
6377
6733
  function position(anchor, pop, placement) {
6378
- const r = anchor.getBoundingClientRect(), pw = pop.offsetWidth, ph = pop.offsetHeight, vw = window.innerWidth, vh = window.innerHeight, gap = 6;
6734
+ const r = anchor.getBoundingClientRect(), pw = pop.offsetWidth, ph = pop.scrollHeight, vw = window.innerWidth, vh = window.innerHeight, gap = 6;
6379
6735
  let side = (placement || "bottom-start").split("-")[0], align = (placement || "bottom-start").split("-")[1] || "start";
6380
6736
  if (side === "bottom" && r.bottom + gap + ph > vh - 8 && r.top - gap - ph > 8) side = "top";
6381
6737
  else if (side === "top" && r.top - gap - ph < 8 && r.bottom + gap + ph < vh - 8) side = "bottom";
6382
- const top = side === "top" ? r.top - gap - ph : r.bottom + gap;
6738
+ const below2 = vh - r.bottom - gap - 8, above = r.top - gap - 8;
6739
+ let maxHeight;
6740
+ if (ph > below2 && ph > above) {
6741
+ side = above > below2 ? "top" : "bottom";
6742
+ maxHeight = Math.max(120, side === "top" ? above : below2);
6743
+ }
6744
+ const h9 = maxHeight ? Math.min(ph, maxHeight) : ph;
6745
+ const top = side === "top" ? r.top - gap - h9 : r.bottom + gap;
6383
6746
  const left = align === "end" ? r.right - pw : align === "center" ? r.left + r.width / 2 - pw / 2 : r.left;
6384
- return { top: Math.max(8, top), left: Math.max(8, Math.min(left, vw - pw - 8)), side };
6747
+ return { top: Math.max(8, top), left: Math.max(8, Math.min(left, vw - pw - 8)), side, maxHeight };
6385
6748
  }
6386
6749
  var Popover = React55.forwardRef(function Popover2(props, ref) {
6387
6750
  const t = useStrings();
@@ -6391,6 +6754,7 @@ var Popover = React55.forwardRef(function Popover2(props, ref) {
6391
6754
  const open = !!st[0];
6392
6755
  const wrap = React55.useRef(null), pop = React55.useRef(null), popMerged = useMergedRef(ref, pop);
6393
6756
  const pos = React55.useState(null), mounted = useMounted();
6757
+ const inTree = React55.useRef(false);
6394
6758
  function trigger() {
6395
6759
  return wrap.current && (wrap.current.querySelector('button, [role="button"], a, input') || wrap.current.firstElementChild);
6396
6760
  }
@@ -6424,13 +6788,19 @@ var Popover = React55.forwardRef(function Popover2(props, ref) {
6424
6788
  const f = pop.current.querySelector("[data-autofocus]") || pop.current.querySelector(FOCUSABLE);
6425
6789
  (f || pop.current).focus();
6426
6790
  }
6791
+ let timer;
6427
6792
  function outside(e) {
6428
6793
  if (pop.current && pop.current.contains(e.target)) return;
6429
6794
  if (wrap.current && wrap.current.contains(e.target)) return;
6430
- close(false);
6795
+ inTree.current = false;
6796
+ clearTimeout(timer);
6797
+ timer = setTimeout(function() {
6798
+ if (!inTree.current) close(false);
6799
+ }, 0);
6431
6800
  }
6432
6801
  document.addEventListener("pointerdown", outside, true);
6433
6802
  return function() {
6803
+ clearTimeout(timer);
6434
6804
  document.removeEventListener("pointerdown", outside, true);
6435
6805
  };
6436
6806
  },
@@ -6449,9 +6819,16 @@ var Popover = React55.forwardRef(function Popover2(props, ref) {
6449
6819
  "aria-label": props.title ? void 0 : props.label,
6450
6820
  "aria-labelledby": props.title ? id + "-title" : void 0,
6451
6821
  tabIndex: -1,
6822
+ onPointerDownCapture: function() {
6823
+ inTree.current = true;
6824
+ },
6452
6825
  className: cx("aura-popover", pos[0] && "is-" + pos[0].side, props.className),
6453
6826
  style: Object.assign(
6454
- { top: pos[0] ? pos[0].top : -9999, left: pos[0] ? pos[0].left : -9999 },
6827
+ {
6828
+ top: pos[0] ? pos[0].top : -9999,
6829
+ left: pos[0] ? pos[0].left : -9999,
6830
+ maxHeight: pos[0] && pos[0].maxHeight ? pos[0].maxHeight : void 0
6831
+ },
6455
6832
  props.width ? { width: props.width } : null
6456
6833
  ),
6457
6834
  onKeyDown: function(e) {
@@ -6498,7 +6875,9 @@ function decimalsOf(n2) {
6498
6875
  return i < 0 ? 0 : s.length - i - 1;
6499
6876
  }
6500
6877
  function parse(text) {
6501
- const s = text.replace(/[,\s ]/g, "");
6878
+ let t = text.trim();
6879
+ if (t.indexOf(".") < 0 && /^-?\d+,\d+$/.test(t.replace(/[\s ]/g, "")) && !/,\d{3}$/.test(t)) t = t.replace(",", ".");
6880
+ const s = t.replace(/[,\s ]/g, "");
6502
6881
  if (!/^-?(\d+\.?\d*|\.\d+)$/.test(s)) return NaN;
6503
6882
  return Number(s);
6504
6883
  }