bianic-ui 2.14.0-beta.8 → 2.15.0-beta.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 (202) hide show
  1. package/dist/cjs/index.js +2068 -246
  2. package/dist/cjs/lib.css +1 -1
  3. package/dist/cjs/types/components/Button/ContextualButton/ContextualButton.d.ts +4 -1
  4. package/dist/cjs/types/components/Button/ContextualButton/config.d.ts +4 -0
  5. package/dist/cjs/types/components/Button/PropInterfaceButton.d.ts +1 -0
  6. package/dist/cjs/types/components/Button/buttonConfigs.d.ts +6 -0
  7. package/dist/cjs/types/components/Button/index.d.ts +1 -0
  8. package/dist/cjs/types/components/FileTree/TreeItem.d.ts +3 -2
  9. package/dist/cjs/types/components/FileTree/configs.d.ts +7 -0
  10. package/dist/cjs/types/components/FileTree/types.d.ts +1 -0
  11. package/dist/cjs/types/components/Forms/DatePicker/DateInputDisplay.d.ts +4 -1
  12. package/dist/cjs/types/components/Forms/DatePicker/PickerCalendar/components/DateDisplay.d.ts +4 -1
  13. package/dist/cjs/types/components/Forms/DatePicker/PickerCalendar/components/PickerContent.d.ts +2 -1
  14. package/dist/cjs/types/components/Forms/DatePicker/PickerCalendar/components/SinglePicker.d.ts +2 -1
  15. package/dist/cjs/types/components/Forms/DatePicker/PickerCalendar/hooks/useGridKeyboard.d.ts +11 -0
  16. package/dist/cjs/types/components/Forms/Dropdown/DropdownItem.d.ts +1 -1
  17. package/dist/cjs/types/components/Forms/DropdownItem/Custom.d.ts +3 -1
  18. package/dist/cjs/types/components/Forms/DropdownItem/Default.d.ts +3 -1
  19. package/dist/cjs/types/components/Forms/LiveSearch/hooks/useLiveSearch.d.ts +4 -0
  20. package/dist/cjs/types/components/Forms/LiveSearch/index.d.ts +1 -1
  21. package/dist/cjs/types/components/Forms/LiveSearch/types/index.d.ts +1 -0
  22. package/dist/cjs/types/components/Forms/LiveSearch/utils/dropdownUtils.d.ts +7 -2
  23. package/dist/cjs/types/components/Forms/SelectInput/index.d.ts +1 -1
  24. package/dist/cjs/types/components/Forms/TagLabelInput/hooks/useLiveSearch.d.ts +2 -0
  25. package/dist/cjs/types/components/Forms/TagLabelInput/index.d.ts +1 -0
  26. package/dist/cjs/types/components/Forms/TagLabelInput/utils/dropdownUtils.d.ts +7 -2
  27. package/dist/cjs/types/components/InfoPanel/config.d.ts +2 -5
  28. package/dist/cjs/types/components/InfoPanel/index.d.ts +7 -3
  29. package/dist/cjs/types/components/Menu/MenuItem.d.ts +1 -1
  30. package/dist/cjs/types/components/Table/DataTable/DataTable.d.ts +4 -0
  31. package/dist/cjs/types/components/Table/DataTable/SortableHeadCell.d.ts +11 -0
  32. package/dist/cjs/types/components/Table/DataTable/configs.d.ts +5 -0
  33. package/dist/cjs/types/components/Table/DataTable/index.d.ts +5 -0
  34. package/dist/cjs/types/components/Table/DataTable/types.d.ts +100 -0
  35. package/dist/cjs/types/components/Table/DataTable/useDataTable.d.ts +4 -0
  36. package/dist/cjs/types/components/Table/DataTable/utils.d.ts +7 -0
  37. package/dist/cjs/types/components/Table/TableFilter/TableFilterButton.d.ts +4 -0
  38. package/dist/cjs/types/components/Table/TableFilter/TableFilterPanel.d.ts +4 -0
  39. package/dist/cjs/types/components/Table/TableFilter/configs.d.ts +6 -0
  40. package/dist/cjs/types/components/Table/TableFilter/index.d.ts +3 -0
  41. package/dist/cjs/types/components/Table/TableFilter/types.d.ts +19 -0
  42. package/dist/cjs/types/components/Table/index.d.ts +4 -0
  43. package/dist/cjs/types/components/TagLabel/configs.d.ts +8 -1
  44. package/dist/cjs/types/components/index.d.ts +7 -1
  45. package/dist/cjs/types/stories/Button/Button.stories.d.ts +19 -0
  46. package/dist/cjs/types/stories/Button/ContextualButton.stories.d.ts +90 -0
  47. package/dist/cjs/types/stories/Button/ContextualButton.test.stories.d.ts +28 -0
  48. package/dist/cjs/types/stories/FileTree/FileTree.test.stories.d.ts +40 -0
  49. package/dist/cjs/types/stories/FileTree/FileTreeSimulation.stories.d.ts +3 -0
  50. package/dist/cjs/types/stories/Form/DatePicker/DatePicker.test.stories.d.ts +50 -0
  51. package/dist/cjs/types/stories/Form/DatePicker/Datepicker.stories.d.ts +162 -2
  52. package/dist/cjs/types/stories/Form/DatePicker/YearPicker.stories.d.ts +2 -1
  53. package/dist/cjs/types/stories/Form/Dropdown/DropdownContainer.stories.d.ts +1 -0
  54. package/dist/cjs/types/stories/Form/Dropdown/DropdownContainer.test.stories.d.ts +8 -0
  55. package/dist/cjs/types/stories/Form/LiveSearch/Livesearch.stories.d.ts +3 -0
  56. package/dist/cjs/types/stories/Form/LiveSearch/Livesearch.test.stories.d.ts +10 -0
  57. package/dist/cjs/types/stories/Form/SelectInput/SelectInput.stories.d.ts +3 -0
  58. package/dist/cjs/types/stories/Form/SelectInput/SelectInput.test.stories.d.ts +30 -0
  59. package/dist/cjs/types/stories/Form/TagLabelInput/TagLabelInput.stories.d.ts +14 -0
  60. package/dist/cjs/types/stories/Form/TagLabelInput/TagLabelInput.test.stories.d.ts +28 -0
  61. package/dist/cjs/types/stories/Form/TextInput/TextInput.stories.d.ts +1 -0
  62. package/dist/cjs/types/stories/Form/TextInput/TextInput.test.stories.d.ts +26 -0
  63. package/dist/cjs/types/stories/InfoPanel/InfoPanel.stories.d.ts +95 -1
  64. package/dist/cjs/types/stories/InfoPanel/InfoPanel.test.stories.d.ts +33 -0
  65. package/dist/cjs/types/stories/Menu/Menu.test.stories.d.ts +28 -0
  66. package/dist/cjs/types/stories/Menu/NestedExample.stories.d.ts +2 -0
  67. package/dist/cjs/types/stories/PaginationBar/PaginationBar.test.stories.d.ts +27 -0
  68. package/dist/cjs/types/stories/Progress/Bar/ProgressBar.stories.d.ts +13 -0
  69. package/dist/cjs/types/stories/Progress/Bar/ProgressBarSimulation.stories.d.ts +6 -0
  70. package/dist/cjs/types/stories/Table/AppliedFilterExample.d.ts +3 -0
  71. package/dist/cjs/types/stories/Table/DataTable.stories.d.ts +245 -0
  72. package/dist/cjs/types/stories/Table/DataTable.test.stories.d.ts +76 -0
  73. package/dist/cjs/types/stories/Table/TableFilterButton.stories.d.ts +76 -0
  74. package/dist/cjs/types/stories/Table/TableFilterButton.test.stories.d.ts +28 -0
  75. package/dist/cjs/types/stories/Table/TableFilterPanel.stories.d.ts +122 -0
  76. package/dist/cjs/types/stories/Table/TableFilterPanel.test.stories.d.ts +39 -0
  77. package/dist/cjs/types/stories/Table/tableFilterSamples.d.ts +55 -0
  78. package/dist/cjs/types/stories/Table/useTableDataHandler.test.stories.d.ts +19 -0
  79. package/dist/cjs/types/stories/TagLabel/TagLabel.stories.d.ts +4 -0
  80. package/dist/cjs/types/stories/TagLabel/TagLabel.test.stories.d.ts +38 -0
  81. package/dist/cjs/types/stories/Tooltip/Tooltip.stories.d.ts +19 -0
  82. package/dist/cjs/types/stories/Tooltip/Tooltip.test.stories.d.ts +33 -0
  83. package/dist/cjs/types/stories/Utility/Formatters.stories.d.ts +18 -0
  84. package/dist/cjs/types/stories/Utility/Formatters.test.stories.d.ts +21 -0
  85. package/dist/cjs/types/stories/Utility/cleanParams.stories.d.ts +33 -0
  86. package/dist/cjs/types/stories/Utility/filterSamples.d.ts +62 -0
  87. package/dist/cjs/types/stories/Utility/useAppliedFilter.stories.d.ts +46 -0
  88. package/dist/cjs/types/stories/Utility/useDebounce.stories.d.ts +31 -0
  89. package/dist/cjs/types/stories/Utility/useDebounce.test.stories.d.ts +19 -0
  90. package/dist/cjs/types/stories/Utility/usePersistentState.stories.d.ts +44 -0
  91. package/dist/cjs/types/stories/Utility/usePersistentState.test.stories.d.ts +21 -0
  92. package/dist/cjs/types/utility/hooks/useAppliedFilter.d.ts +19 -0
  93. package/dist/cjs/types/utility/hooks/useDebounce.d.ts +3 -0
  94. package/dist/cjs/types/utility/hooks/useListKeyboard.d.ts +14 -0
  95. package/dist/cjs/types/utility/hooks/usePersistentState.d.ts +8 -0
  96. package/dist/cjs/types/utility/hooks/useTableDataHandler.d.ts +1 -1
  97. package/dist/cjs/types/utility/index.d.ts +8 -0
  98. package/dist/cjs/types/utility/public/filterParams.d.ts +4 -0
  99. package/dist/cjs/types/utility/public/formatters.d.ts +2 -0
  100. package/dist/cjs/types/utility/public/highlightMatch.d.ts +3 -0
  101. package/dist/esm/index.js +2056 -248
  102. package/dist/esm/lib.css +1 -1
  103. package/dist/esm/types/components/Button/ContextualButton/ContextualButton.d.ts +4 -1
  104. package/dist/esm/types/components/Button/ContextualButton/config.d.ts +4 -0
  105. package/dist/esm/types/components/Button/PropInterfaceButton.d.ts +1 -0
  106. package/dist/esm/types/components/Button/buttonConfigs.d.ts +6 -0
  107. package/dist/esm/types/components/Button/index.d.ts +1 -0
  108. package/dist/esm/types/components/FileTree/TreeItem.d.ts +3 -2
  109. package/dist/esm/types/components/FileTree/configs.d.ts +7 -0
  110. package/dist/esm/types/components/FileTree/types.d.ts +1 -0
  111. package/dist/esm/types/components/Forms/DatePicker/DateInputDisplay.d.ts +4 -1
  112. package/dist/esm/types/components/Forms/DatePicker/PickerCalendar/components/DateDisplay.d.ts +4 -1
  113. package/dist/esm/types/components/Forms/DatePicker/PickerCalendar/components/PickerContent.d.ts +2 -1
  114. package/dist/esm/types/components/Forms/DatePicker/PickerCalendar/components/SinglePicker.d.ts +2 -1
  115. package/dist/esm/types/components/Forms/DatePicker/PickerCalendar/hooks/useGridKeyboard.d.ts +11 -0
  116. package/dist/esm/types/components/Forms/Dropdown/DropdownItem.d.ts +1 -1
  117. package/dist/esm/types/components/Forms/DropdownItem/Custom.d.ts +3 -1
  118. package/dist/esm/types/components/Forms/DropdownItem/Default.d.ts +3 -1
  119. package/dist/esm/types/components/Forms/LiveSearch/hooks/useLiveSearch.d.ts +4 -0
  120. package/dist/esm/types/components/Forms/LiveSearch/index.d.ts +1 -1
  121. package/dist/esm/types/components/Forms/LiveSearch/types/index.d.ts +1 -0
  122. package/dist/esm/types/components/Forms/LiveSearch/utils/dropdownUtils.d.ts +7 -2
  123. package/dist/esm/types/components/Forms/SelectInput/index.d.ts +1 -1
  124. package/dist/esm/types/components/Forms/TagLabelInput/hooks/useLiveSearch.d.ts +2 -0
  125. package/dist/esm/types/components/Forms/TagLabelInput/index.d.ts +1 -0
  126. package/dist/esm/types/components/Forms/TagLabelInput/utils/dropdownUtils.d.ts +7 -2
  127. package/dist/esm/types/components/InfoPanel/config.d.ts +2 -5
  128. package/dist/esm/types/components/InfoPanel/index.d.ts +7 -3
  129. package/dist/esm/types/components/Menu/MenuItem.d.ts +1 -1
  130. package/dist/esm/types/components/Table/DataTable/DataTable.d.ts +4 -0
  131. package/dist/esm/types/components/Table/DataTable/SortableHeadCell.d.ts +11 -0
  132. package/dist/esm/types/components/Table/DataTable/configs.d.ts +5 -0
  133. package/dist/esm/types/components/Table/DataTable/index.d.ts +5 -0
  134. package/dist/esm/types/components/Table/DataTable/types.d.ts +100 -0
  135. package/dist/esm/types/components/Table/DataTable/useDataTable.d.ts +4 -0
  136. package/dist/esm/types/components/Table/DataTable/utils.d.ts +7 -0
  137. package/dist/esm/types/components/Table/TableFilter/TableFilterButton.d.ts +4 -0
  138. package/dist/esm/types/components/Table/TableFilter/TableFilterPanel.d.ts +4 -0
  139. package/dist/esm/types/components/Table/TableFilter/configs.d.ts +6 -0
  140. package/dist/esm/types/components/Table/TableFilter/index.d.ts +3 -0
  141. package/dist/esm/types/components/Table/TableFilter/types.d.ts +19 -0
  142. package/dist/esm/types/components/Table/index.d.ts +4 -0
  143. package/dist/esm/types/components/TagLabel/configs.d.ts +8 -1
  144. package/dist/esm/types/components/index.d.ts +7 -1
  145. package/dist/esm/types/stories/Button/Button.stories.d.ts +19 -0
  146. package/dist/esm/types/stories/Button/ContextualButton.stories.d.ts +90 -0
  147. package/dist/esm/types/stories/Button/ContextualButton.test.stories.d.ts +28 -0
  148. package/dist/esm/types/stories/FileTree/FileTree.test.stories.d.ts +40 -0
  149. package/dist/esm/types/stories/FileTree/FileTreeSimulation.stories.d.ts +3 -0
  150. package/dist/esm/types/stories/Form/DatePicker/DatePicker.test.stories.d.ts +50 -0
  151. package/dist/esm/types/stories/Form/DatePicker/Datepicker.stories.d.ts +162 -2
  152. package/dist/esm/types/stories/Form/DatePicker/YearPicker.stories.d.ts +2 -1
  153. package/dist/esm/types/stories/Form/Dropdown/DropdownContainer.stories.d.ts +1 -0
  154. package/dist/esm/types/stories/Form/Dropdown/DropdownContainer.test.stories.d.ts +8 -0
  155. package/dist/esm/types/stories/Form/LiveSearch/Livesearch.stories.d.ts +3 -0
  156. package/dist/esm/types/stories/Form/LiveSearch/Livesearch.test.stories.d.ts +10 -0
  157. package/dist/esm/types/stories/Form/SelectInput/SelectInput.stories.d.ts +3 -0
  158. package/dist/esm/types/stories/Form/SelectInput/SelectInput.test.stories.d.ts +30 -0
  159. package/dist/esm/types/stories/Form/TagLabelInput/TagLabelInput.stories.d.ts +14 -0
  160. package/dist/esm/types/stories/Form/TagLabelInput/TagLabelInput.test.stories.d.ts +28 -0
  161. package/dist/esm/types/stories/Form/TextInput/TextInput.stories.d.ts +1 -0
  162. package/dist/esm/types/stories/Form/TextInput/TextInput.test.stories.d.ts +26 -0
  163. package/dist/esm/types/stories/InfoPanel/InfoPanel.stories.d.ts +95 -1
  164. package/dist/esm/types/stories/InfoPanel/InfoPanel.test.stories.d.ts +33 -0
  165. package/dist/esm/types/stories/Menu/Menu.test.stories.d.ts +28 -0
  166. package/dist/esm/types/stories/Menu/NestedExample.stories.d.ts +2 -0
  167. package/dist/esm/types/stories/PaginationBar/PaginationBar.test.stories.d.ts +27 -0
  168. package/dist/esm/types/stories/Progress/Bar/ProgressBar.stories.d.ts +13 -0
  169. package/dist/esm/types/stories/Progress/Bar/ProgressBarSimulation.stories.d.ts +6 -0
  170. package/dist/esm/types/stories/Table/AppliedFilterExample.d.ts +3 -0
  171. package/dist/esm/types/stories/Table/DataTable.stories.d.ts +245 -0
  172. package/dist/esm/types/stories/Table/DataTable.test.stories.d.ts +76 -0
  173. package/dist/esm/types/stories/Table/TableFilterButton.stories.d.ts +76 -0
  174. package/dist/esm/types/stories/Table/TableFilterButton.test.stories.d.ts +28 -0
  175. package/dist/esm/types/stories/Table/TableFilterPanel.stories.d.ts +122 -0
  176. package/dist/esm/types/stories/Table/TableFilterPanel.test.stories.d.ts +39 -0
  177. package/dist/esm/types/stories/Table/tableFilterSamples.d.ts +55 -0
  178. package/dist/esm/types/stories/Table/useTableDataHandler.test.stories.d.ts +19 -0
  179. package/dist/esm/types/stories/TagLabel/TagLabel.stories.d.ts +4 -0
  180. package/dist/esm/types/stories/TagLabel/TagLabel.test.stories.d.ts +38 -0
  181. package/dist/esm/types/stories/Tooltip/Tooltip.stories.d.ts +19 -0
  182. package/dist/esm/types/stories/Tooltip/Tooltip.test.stories.d.ts +33 -0
  183. package/dist/esm/types/stories/Utility/Formatters.stories.d.ts +18 -0
  184. package/dist/esm/types/stories/Utility/Formatters.test.stories.d.ts +21 -0
  185. package/dist/esm/types/stories/Utility/cleanParams.stories.d.ts +33 -0
  186. package/dist/esm/types/stories/Utility/filterSamples.d.ts +62 -0
  187. package/dist/esm/types/stories/Utility/useAppliedFilter.stories.d.ts +46 -0
  188. package/dist/esm/types/stories/Utility/useDebounce.stories.d.ts +31 -0
  189. package/dist/esm/types/stories/Utility/useDebounce.test.stories.d.ts +19 -0
  190. package/dist/esm/types/stories/Utility/usePersistentState.stories.d.ts +44 -0
  191. package/dist/esm/types/stories/Utility/usePersistentState.test.stories.d.ts +21 -0
  192. package/dist/esm/types/utility/hooks/useAppliedFilter.d.ts +19 -0
  193. package/dist/esm/types/utility/hooks/useDebounce.d.ts +3 -0
  194. package/dist/esm/types/utility/hooks/useListKeyboard.d.ts +14 -0
  195. package/dist/esm/types/utility/hooks/usePersistentState.d.ts +8 -0
  196. package/dist/esm/types/utility/hooks/useTableDataHandler.d.ts +1 -1
  197. package/dist/esm/types/utility/index.d.ts +8 -0
  198. package/dist/esm/types/utility/public/filterParams.d.ts +4 -0
  199. package/dist/esm/types/utility/public/formatters.d.ts +2 -0
  200. package/dist/esm/types/utility/public/highlightMatch.d.ts +3 -0
  201. package/dist/index.d.ts +192 -11
  202. package/package.json +1 -1
package/dist/cjs/index.js CHANGED
@@ -111,6 +111,8 @@ function TbCircleFilled (props) {
111
111
  return GenIcon({"tag":"svg","attr":{"viewBox":"0 0 24 24","fill":"none","stroke":"currentColor","strokeWidth":"2","strokeLinecap":"round","strokeLinejoin":"round"},"child":[{"tag":"path","attr":{"d":"M12 3a9 9 0 1 0 9 9"},"child":[]}]})(props);
112
112
  }function TbFolderOpen (props) {
113
113
  return GenIcon({"tag":"svg","attr":{"viewBox":"0 0 24 24","fill":"none","stroke":"currentColor","strokeWidth":"2","strokeLinecap":"round","strokeLinejoin":"round"},"child":[{"tag":"path","attr":{"d":"M5 19l2.757 -7.351a1 1 0 0 1 .936 -.649h12.307a1 1 0 0 1 .986 1.164l-.996 5.211a2 2 0 0 1 -1.964 1.625h-14.026a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v2"},"child":[]}]})(props);
114
+ }function TbFilter (props) {
115
+ return GenIcon({"tag":"svg","attr":{"viewBox":"0 0 24 24","fill":"none","stroke":"currentColor","strokeWidth":"2","strokeLinecap":"round","strokeLinejoin":"round"},"child":[{"tag":"path","attr":{"d":"M4 4h16v2.172a2 2 0 0 1 -.586 1.414l-4.414 4.414v7l-6 2v-8.5l-4.48 -4.928a2 2 0 0 1 -.52 -1.345v-2.227z"},"child":[]}]})(props);
114
116
  }function TbFile (props) {
115
117
  return GenIcon({"tag":"svg","attr":{"viewBox":"0 0 24 24","fill":"none","stroke":"currentColor","strokeWidth":"2","strokeLinecap":"round","strokeLinejoin":"round"},"child":[{"tag":"path","attr":{"d":"M14 3v4a1 1 0 0 0 1 1h4"},"child":[]},{"tag":"path","attr":{"d":"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z"},"child":[]}]})(props);
116
118
  }function TbEye (props) {
@@ -321,7 +323,7 @@ var useDetectOutsideClick = function (ref, initialState, ignoreRef, event) {
321
323
  return [isActive, setIsActive];
322
324
  };
323
325
 
324
- var variantUnion$1 = [
326
+ var variantUnion$2 = [
325
327
  'normal-text', // default
326
328
  'large-text',
327
329
  'large-text-semibold',
@@ -341,7 +343,7 @@ var variantUnion$1 = [
341
343
  ];
342
344
  function Text(_a) {
343
345
  var _b = _a.extended, extended = _b === void 0 ? '' : _b, variant = _a.variant, children = _a.children, _c = _a.className, className = _c === void 0 ? '' : _c;
344
- var validatedVariant = validUnion(variant, variantUnion$1);
346
+ var validatedVariant = validUnion(variant, variantUnion$2);
345
347
  var defaultColor = extended.includes('text-bia') || (className === null || className === void 0 ? void 0 : className.includes('text-bia'))
346
348
  ? ''
347
349
  : 'text-bia-black';
@@ -482,6 +484,12 @@ var minWidthConfig$1 = {
482
484
  sm: 'min-w-[72px]',
483
485
  tn: 'min-w-[64px]',
484
486
  };
487
+ var iconSizeConfig = {
488
+ lg: 22,
489
+ md: 18,
490
+ sm: 14,
491
+ tn: 14,
492
+ };
485
493
  var iconOnlySizeConfig$1 = {
486
494
  lg: 'py-[13px] h-[48px] w-[48px] flex items-center justify-center gap-[10px]',
487
495
  md: 'py-[11px] h-[40px] w-[40px] flex items-center justify-center gap-[5px]',
@@ -533,11 +541,11 @@ var BUTTON_VARIANT_UNION = [
533
541
  'form-group',
534
542
  ];
535
543
  var RADIUS_UNION = ['default', 'full-rounded'];
536
- var SIZE_UNION = ['md', 'lg', 'sm', 'tn'];
544
+ var SIZE_UNION$1 = ['md', 'lg', 'sm', 'tn'];
537
545
  var Button = React.forwardRef(function (_a, ref) {
538
- var label = _a.label, _b = _a.className, className = _b === void 0 ? '' : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.radius, radius = _d === void 0 ? 'default' : _d, _e = _a.size, size = _e === void 0 ? 'md' : _e, _f = _a.variant, variant = _f === void 0 ? 'default' : _f, _g = _a.iconLeft, iconLeft = _g === void 0 ? null : _g, _h = _a.iconRight, iconRight = _h === void 0 ? null : _h, _j = _a.left, left = _j === void 0 ? null : _j, _k = _a.right, right = _k === void 0 ? null : _k, minWidth = _a.minWidth, props = __rest(_a, ["label", "className", "disabled", "radius", "size", "variant", "iconLeft", "iconRight", "left", "right", "minWidth"]);
546
+ var label = _a.label, _b = _a.className, className = _b === void 0 ? '' : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.radius, radius = _d === void 0 ? 'default' : _d, _e = _a.size, size = _e === void 0 ? 'md' : _e, _f = _a.variant, variant = _f === void 0 ? 'default' : _f, _g = _a.iconLeft, iconLeft = _g === void 0 ? null : _g, _h = _a.iconRight, iconRight = _h === void 0 ? null : _h, _j = _a.left, left = _j === void 0 ? null : _j, _k = _a.right, right = _k === void 0 ? null : _k, minWidth = _a.minWidth, _l = _a.iconSize, iconSize = _l === void 0 ? undefined : _l, props = __rest(_a, ["label", "className", "disabled", "radius", "size", "variant", "iconLeft", "iconRight", "left", "right", "minWidth", "iconSize"]);
539
547
  var validatedVariant = validUnion(variant, BUTTON_VARIANT_UNION);
540
- var validatedSize = validUnion(size, SIZE_UNION);
548
+ var validatedSize = validUnion(size, SIZE_UNION$1);
541
549
  var validatedRadius = validUnion(radius, RADIUS_UNION);
542
550
  var variantTextColorClasses = variantConfig$3[validatedVariant]
543
551
  .split(/\s+/)
@@ -548,10 +556,22 @@ var Button = React.forwardRef(function (_a, ref) {
548
556
  if (React.isValidElement(element)) {
549
557
  var iconProps = element.props;
550
558
  var existingClassName = iconProps.className || '';
551
- return React.cloneElement(element, {
552
- className: __spreadArray(__spreadArray([], variantTextColorClasses, true), [existingClassName], false).filter(Boolean)
553
- .join(' '),
554
- });
559
+ var hasOwnSize = iconProps.size !== undefined ||
560
+ iconProps.width !== undefined ||
561
+ iconProps.height !== undefined;
562
+ var px = iconSize !== null && iconSize !== void 0 ? iconSize : iconSizeConfig[validatedSize];
563
+ var sizeProps = {};
564
+ if (iconSize !== undefined || !hasOwnSize) {
565
+ if (element.type === 'svg') {
566
+ sizeProps.width = px;
567
+ sizeProps.height = px;
568
+ }
569
+ else if (typeof element.type !== 'string') {
570
+ sizeProps.size = px;
571
+ }
572
+ }
573
+ return React.cloneElement(element, __assign(__assign({}, sizeProps), { className: __spreadArray(__spreadArray([], variantTextColorClasses, true), [existingClassName], false).filter(Boolean)
574
+ .join(' ') }));
555
575
  }
556
576
  return element;
557
577
  };
@@ -596,6 +616,7 @@ Button.defaultProps = {
596
616
  variant: 'default',
597
617
  iconLeft: undefined,
598
618
  iconRight: undefined,
619
+ iconSize: undefined,
599
620
  left: undefined,
600
621
  right: undefined,
601
622
  };
@@ -1626,24 +1647,36 @@ function ButtonApp(_a) {
1626
1647
  return (React.createElement("button", __assign({ className: "button-app flex max-h-[30px] items-center justify-center px-[10px] pb-[8.3px] pt-[8.5px] font-arial text-size-tiny ".concat(colorConfig$2[color][buttonState], " ").concat(extended), type: "button", disabled: disabled }, rest), label));
1627
1648
  }
1628
1649
 
1650
+ var sizeUnion$6 = ['tn', 'sm'];
1651
+ var minHeightConfig$1 = {
1652
+ tn: 'min-h-[23px]',
1653
+ sm: 'min-h-[30px]',
1654
+ };
1655
+ var paddingConfig = {
1656
+ tn: 'p-[1px]',
1657
+ sm: 'px-1 py-[1px]',
1658
+ };
1629
1659
  var textColorConfig = {
1630
1660
  dark: 'text-primary-black disabled:text-bia-coolgrey-disabled',
1631
1661
  light: 'text-primary-white disabled:opacity-30',
1632
1662
  };
1633
1663
  var stateColorConfig = {
1634
- selected: 'bg-black/15 cursor-default',
1664
+ selected: 'bg-black/15 cursor-default focus-visible:border-bia-blue-disabled focus-visible:outline-2 focus-visible:-outline-offset-1 focus-visible:outline-bia-blue-disabled',
1635
1665
  default: 'enabled:hover:bg-black/10 enabled:focus-visible:border-bia-blue-disabled enabled:focus-visible:outline-2 enabled:focus-visible:-outline-offset-1 enabled:focus-visible:outline-bia-blue-disabled enabled:active:bg-black/15',
1636
1666
  };
1637
1667
 
1638
1668
  function ContextualButtonInner(_a, ref) {
1639
- var _b = _a.actionElement, actionElement = _b === void 0 ? undefined : _b, _c = _a.label, label = _c === void 0 ? '' : _c, _d = _a.icon, icon = _d === void 0 ? undefined : _d, _e = _a.variant, variant = _e === void 0 ? 'dark' : _e, disabled = _a.disabled, _f = _a.isSelected, isSelected = _f === void 0 ? false : _f, props = __rest(_a, ["actionElement", "label", "icon", "variant", "disabled", "isSelected"]);
1669
+ var _b = _a.actionElement, actionElement = _b === void 0 ? undefined : _b, _c = _a.label, label = _c === void 0 ? '' : _c, _d = _a.icon, icon = _d === void 0 ? undefined : _d, _e = _a.variant, variant = _e === void 0 ? 'dark' : _e, _f = _a.size, size = _f === void 0 ? 'tn' : _f, disabled = _a.disabled, _g = _a.isSelected, isSelected = _g === void 0 ? false : _g, _h = _a.isNotified, isNotified = _h === void 0 ? false : _h, props = __rest(_a, ["actionElement", "label", "icon", "variant", "size", "disabled", "isSelected", "isNotified"]);
1640
1670
  var textColor = textColorConfig[variant];
1641
1671
  if (isSelected) {
1642
1672
  textColor = variant === 'dark' ? 'text-primary-black' : 'text-primary-white';
1643
1673
  }
1644
1674
  var stateColor = stateColorConfig[isSelected ? 'selected' : 'default'];
1645
- return (React.createElement("button", __assign({ ref: ref, type: "button", className: "bianic-contextual-button box-border flex min-h-[23px] flex-row items-center rounded-radius-sm border border-transparent p-[1px] outline-none ".concat(stateColor, " ").concat(textColor) }, props, { disabled: disabled }),
1675
+ var notifiedClass = isNotified ? 'relative ' : '';
1676
+ var validSize = validUnion(size, sizeUnion$6);
1677
+ return (React.createElement("button", __assign({ ref: ref, type: "button", className: "bianic-contextual-button ".concat(notifiedClass, "box-border flex ").concat(minHeightConfig$1[validSize], " flex-row items-center rounded-radius-sm border border-transparent ").concat(paddingConfig[validSize], " outline-none ").concat(stateColor, " ").concat(textColor) }, props, { disabled: disabled }),
1646
1678
  icon,
1679
+ isNotified && (React.createElement("span", { "aria-hidden": "true", className: "absolute -right-[3px] -top-[3px] size-1.5 rounded-radius-full bg-bia-red" })),
1647
1680
  label && (React.createElement("div", { className: "label flex max-h-[46px] items-center gap-x-0.5 px-[5px] text-[12px] leading-none" },
1648
1681
  React.createElement("span", null, label),
1649
1682
  actionElement))));
@@ -1828,8 +1861,31 @@ function Divider(_a) {
1828
1861
  return (React.createElement("div", { className: "bianic-divider bg-bia-grey-light-50 ".concat(margin, " ").concat(config, " ").concat(className) }));
1829
1862
  }
1830
1863
 
1864
+ var TREE_ITEM_SIZES = ['sm', 'md'];
1865
+ var headerSizeConfig = {
1866
+ sm: '',
1867
+ md: 'py-[3px]',
1868
+ };
1869
+ var chevronIconSize = {
1870
+ sm: 18,
1871
+ md: 20,
1872
+ };
1873
+ var placeholderSizeConfig = {
1874
+ sm: 'min-w-[18px]',
1875
+ md: 'min-w-5',
1876
+ };
1877
+ var labelSizeConfig$1 = {
1878
+ sm: 'px-0.5 py-[0.5px] text-size-sm',
1879
+ md: 'min-h-5 px-[3px] text-size-base leading-5',
1880
+ };
1881
+ var childrenSizeConfig = {
1882
+ sm: 'gap-0.5 pl-[18px]',
1883
+ md: 'pl-5',
1884
+ };
1885
+
1831
1886
  function TreeItem(_a) {
1832
- var data = _a.data, expandedData = _a.expandedData, setExpandedData = _a.setExpandedData, dataMap = _a.dataMap, _b = _a.activeUnitId, activeUnitId = _b === void 0 ? undefined : _b, _c = _a.handleChevronClick, handleChevronClick = _c === void 0 ? undefined : _c, _d = _a.handleRightClick, handleRightClick = _d === void 0 ? undefined : _d, _e = _a.handleClick, handleClick = _e === void 0 ? undefined : _e;
1887
+ var data = _a.data, expandedData = _a.expandedData, setExpandedData = _a.setExpandedData, dataMap = _a.dataMap, _b = _a.activeUnitId, activeUnitId = _b === void 0 ? undefined : _b, _c = _a.size, size = _c === void 0 ? 'sm' : _c, _d = _a.handleChevronClick, handleChevronClick = _d === void 0 ? undefined : _d, _e = _a.handleRightClick, handleRightClick = _e === void 0 ? undefined : _e, _f = _a.handleClick, handleClick = _f === void 0 ? undefined : _f;
1888
+ var validSize = validUnion(size, TREE_ITEM_SIZES);
1833
1889
  var isExpanded = !!expandedData.get(data.id);
1834
1890
  var hasActiveDescendant = function (unit) {
1835
1891
  var _a;
@@ -1870,14 +1926,16 @@ function TreeItem(_a) {
1870
1926
  handleChevronClick === null || handleChevronClick === void 0 ? void 0 : handleChevronClick(data);
1871
1927
  };
1872
1928
  return (React.createElement("div", { className: "tree-item", role: "treeitem", "aria-expanded": data.children ? isExpanded : undefined, "aria-selected": activeUnitId === data.id },
1873
- React.createElement("div", { className: "tree-item-header flex items-center justify-start" },
1929
+ React.createElement("div", { className: cn$1('tree-item-header flex items-center justify-start', headerSizeConfig[validSize]) },
1874
1930
  data.children ? (React.createElement("button", { className: "tree-item-chevron", onClick: chevronClickHandler, type: "button", "aria-label": isExpanded ? 'Collapse' : 'Expand' },
1875
- React.createElement(TbChevronRight, { className: "chevron ".concat(isChevronActive ? 'text-bia-green hover:text-bia-green-light-10' : 'text-bia-coolgrey-light-50 hover:text-bia-coolgrey-light-20', " ").concat(isExpanded ? 'rotate-90' : ''), size: 18, "aria-hidden": "true" }))) : (React.createElement("div", { className: "chevron-placeholder aspect-square min-w-[18px]" })),
1876
- React.createElement("button", { className: "tree-item-label rounded-radius-sm px-0.5 py-[0.5px] text-start font-segoe text-size-sm font-normal text-bia-black ".concat(activeUnitId === data.id ? 'bg-bia-green-light-70' : 'hover:bg-bia-coolgrey-light-90'), onClick: clickItemHandler, type: "button", onContextMenu: function (e) {
1931
+ React.createElement(TbChevronRight, { className: "chevron ".concat(isChevronActive ? 'text-bia-green hover:text-bia-green-light-10' : 'text-bia-coolgrey-light-50 hover:text-bia-coolgrey-light-20', " ").concat(isExpanded ? 'rotate-90' : ''), size: chevronIconSize[validSize], "aria-hidden": "true" }))) : (React.createElement("div", { className: cn$1('chevron-placeholder aspect-square', placeholderSizeConfig[validSize]) })),
1932
+ React.createElement("button", { className: cn$1('tree-item-label rounded-radius-sm text-start font-segoe font-normal text-bia-black', labelSizeConfig$1[validSize], activeUnitId === data.id
1933
+ ? 'bg-bia-green-light-70'
1934
+ : 'hover:bg-bia-coolgrey-light-90'), onClick: clickItemHandler, type: "button", onContextMenu: function (e) {
1877
1935
  e.preventDefault();
1878
1936
  handleRightClick === null || handleRightClick === void 0 ? void 0 : handleRightClick(data);
1879
1937
  } }, data.label)),
1880
- isExpanded && data.children && (React.createElement("div", { className: "tree-item-children flex flex-col gap-0.5 rounded-radius-sm pl-[18px]", role: "group" }, data.children.map(function (childUnit) { return (React.createElement(TreeItem, { key: childUnit.id, data: childUnit, expandedData: expandedData, setExpandedData: setExpandedData, dataMap: dataMap, activeUnitId: activeUnitId, handleChevronClick: handleChevronClick, handleRightClick: handleRightClick, handleClick: handleClick })); })))));
1938
+ isExpanded && data.children && (React.createElement("div", { className: cn$1('tree-item-children flex flex-col rounded-radius-sm', childrenSizeConfig[validSize]), role: "group" }, data.children.map(function (childUnit) { return (React.createElement(TreeItem, { key: childUnit.id, data: childUnit, expandedData: expandedData, setExpandedData: setExpandedData, dataMap: dataMap, activeUnitId: activeUnitId, size: validSize, handleChevronClick: handleChevronClick, handleRightClick: handleRightClick, handleClick: handleClick })); })))));
1881
1939
  }
1882
1940
  var TreeItem$1 = React.memo(TreeItem);
1883
1941
 
@@ -2085,6 +2143,151 @@ var usePopupPosition = function (anchorRef, popupRef, position) {
2085
2143
  return [positionStyle, calcPosition];
2086
2144
  };
2087
2145
 
2146
+ // Internal helpers for keyboard navigation in dropdowns and menus (BIAN-259).
2147
+ // Not exported from any index file.
2148
+ // Top-level items of a list, matched against the existing markup:
2149
+ // - DropdownItem: `.bianic-dropdown-item > button`
2150
+ // - MenuItem: the `[role="button"]` child of each direct child div
2151
+ // - DefaultDropdownItem / CustomDropdownItem: direct `[role="button"]` children
2152
+ var ITEM_SELECTOR = [
2153
+ ':scope > .bianic-dropdown-item > button:not(:disabled)',
2154
+ ':scope > div > [role="button"]:not([aria-disabled="true"])',
2155
+ ':scope > [role="button"]:not([aria-disabled="true"])',
2156
+ ].join(', ');
2157
+ function getEnabledItems(list) {
2158
+ if (!list)
2159
+ return [];
2160
+ return Array.from(list.querySelectorAll(ITEM_SELECTOR));
2161
+ }
2162
+ // Wraps around. `current` -1 means nothing is highlighted.
2163
+ function nextIndex(current, delta, count) {
2164
+ if (count <= 0)
2165
+ return -1;
2166
+ if (current < 0)
2167
+ return delta > 0 ? 0 : count - 1;
2168
+ return (current + delta + count) % count;
2169
+ }
2170
+ // Highlight for the option picked by arrow keys in a form field list
2171
+ var OPTION_HIGHLIGHT_CLASS = '!bg-bia-blue-pastel outline outline-[3px] -outline-offset-[3px] outline-bia-blue-light-50';
2172
+ function getOptionId(baseId, index) {
2173
+ return "".concat(baseId, "-option-").concat(index);
2174
+ }
2175
+ function scrollOptionIntoView(id) {
2176
+ var _a, _b;
2177
+ (_b = (_a = document.getElementById(id)) === null || _a === void 0 ? void 0 : _a.scrollIntoView) === null || _b === void 0 ? void 0 : _b.call(_a, { block: 'nearest' });
2178
+ }
2179
+ function isEditable(target) {
2180
+ if (!(target instanceof HTMLElement))
2181
+ return false;
2182
+ return (target.isContentEditable ||
2183
+ target instanceof HTMLTextAreaElement ||
2184
+ target instanceof HTMLSelectElement ||
2185
+ target instanceof HTMLInputElement);
2186
+ }
2187
+ // Open menus in the order they opened. Only one menu reacts to a key press.
2188
+ var openMenus = [];
2189
+ function holdsFocus(entry) {
2190
+ var _a, _b;
2191
+ var active = document.activeElement;
2192
+ if (!active || active === document.body)
2193
+ return false;
2194
+ return !!(((_a = entry.getList()) === null || _a === void 0 ? void 0 : _a.contains(active)) || ((_b = entry.getAnchor()) === null || _b === void 0 ? void 0 : _b.contains(active)));
2195
+ }
2196
+ function shouldReact(entry) {
2197
+ var focused = openMenus.filter(holdsFocus);
2198
+ if (focused.length > 0)
2199
+ return focused[focused.length - 1] === entry;
2200
+ return openMenus[openMenus.length - 1] === entry;
2201
+ }
2202
+ // Arrow keys, Escape and Tab for a menu that is open.
2203
+ // Enter and Space are handled by the items themselves.
2204
+ function useMenuKeyboard(_a) {
2205
+ var open = _a.open, onClose = _a.onClose, listRef = _a.listRef, _b = _a.anchorRef, anchorRef = _b === void 0 ? undefined : _b;
2206
+ var onCloseRef = React.useRef(onClose);
2207
+ onCloseRef.current = onClose;
2208
+ var returnFocusRef = React.useRef(null);
2209
+ var skipRestoreRef = React.useRef(false);
2210
+ var wasOpenRef = React.useRef(false);
2211
+ React.useEffect(function () {
2212
+ var _a, _b;
2213
+ if (!open) {
2214
+ if (wasOpenRef.current) {
2215
+ wasOpenRef.current = false;
2216
+ // Give focus back when it was lost on a hidden item
2217
+ var active_1 = document.activeElement;
2218
+ var list = listRef.current;
2219
+ var lost = !active_1 ||
2220
+ active_1 === document.body ||
2221
+ (list !== null && list.contains(active_1));
2222
+ var target = (_a = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) !== null && _a !== void 0 ? _a : returnFocusRef.current;
2223
+ if (!skipRestoreRef.current && lost && (target === null || target === void 0 ? void 0 : target.isConnected)) {
2224
+ target.focus();
2225
+ }
2226
+ }
2227
+ return undefined;
2228
+ }
2229
+ wasOpenRef.current = true;
2230
+ skipRestoreRef.current = false;
2231
+ var active = document.activeElement;
2232
+ returnFocusRef.current =
2233
+ active && active !== document.body && !((_b = listRef.current) === null || _b === void 0 ? void 0 : _b.contains(active))
2234
+ ? active
2235
+ : null;
2236
+ var entry = {
2237
+ getList: function () { return listRef.current; },
2238
+ getAnchor: function () { var _a; return (_a = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) !== null && _a !== void 0 ? _a : null; },
2239
+ };
2240
+ openMenus.push(entry);
2241
+ var onKeyDown = function (e) {
2242
+ var _a;
2243
+ if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey)
2244
+ return;
2245
+ var key = e.key;
2246
+ if (key !== 'ArrowDown' &&
2247
+ key !== 'ArrowUp' &&
2248
+ key !== 'Escape' &&
2249
+ key !== 'Tab')
2250
+ return;
2251
+ if (!shouldReact(entry))
2252
+ return;
2253
+ if (key === 'Tab') {
2254
+ skipRestoreRef.current = true;
2255
+ onCloseRef.current();
2256
+ return;
2257
+ }
2258
+ if (key === 'Escape') {
2259
+ e.preventDefault();
2260
+ onCloseRef.current();
2261
+ return;
2262
+ }
2263
+ var list = listRef.current;
2264
+ if (!list)
2265
+ return;
2266
+ var target = e.target;
2267
+ var anchor = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current;
2268
+ if (isEditable(target) &&
2269
+ !list.contains(target) &&
2270
+ !(anchor === null || anchor === void 0 ? void 0 : anchor.contains(target)))
2271
+ return;
2272
+ var items = getEnabledItems(list);
2273
+ if (items.length === 0)
2274
+ return;
2275
+ e.preventDefault();
2276
+ var current = document.activeElement;
2277
+ var index = items.findIndex(function (item) { return item === current || item.contains(current); });
2278
+ var next = nextIndex(index, key === 'ArrowDown' ? 1 : -1, items.length);
2279
+ (_a = items[next]) === null || _a === void 0 ? void 0 : _a.focus();
2280
+ };
2281
+ document.addEventListener('keydown', onKeyDown);
2282
+ return function () {
2283
+ document.removeEventListener('keydown', onKeyDown);
2284
+ var at = openMenus.indexOf(entry);
2285
+ if (at >= 0)
2286
+ openMenus.splice(at, 1);
2287
+ };
2288
+ }, [open, listRef, anchorRef]);
2289
+ }
2290
+
2088
2291
  function MenuElementInner(_a) {
2089
2292
  var isTopFlat = _a.isTopFlat, children = _a.children, className = _a.className, zIndex = _a.zIndex, menuRef = _a.menuRef, onClose = _a.onClose, onClickItem = _a.onClickItem, _b = _a.style, style = _b === void 0 ? undefined : _b, _c = _a.onContextMenu, onContextMenu = _c === void 0 ? undefined : _c, restProps = __rest(_a, ["isTopFlat", "children", "className", "zIndex", "menuRef", "onClose", "onClickItem", "style", "onContextMenu"]);
2090
2293
  var radiusClass = "rounded-b-radius-sm ".concat(!isTopFlat && 'rounded-t-radius-sm');
@@ -2103,6 +2306,7 @@ function MenuContainer(_a) {
2103
2306
  var _b = _a.isTopFlat, isTopFlat = _b === void 0 ? false : _b, children = _a.children, _c = _a.open, open = _c === void 0 ? true : _c, _d = _a.onClose, onClose = _d === void 0 ? function () { } : _d, _e = _a.className, className = _e === void 0 ? '' : _e, _f = _a.isWithOverlay, isWithOverlay = _f === void 0 ? true : _f, _g = _a.zIndex, zIndex = _g === void 0 ? 100 : _g, _h = _a.onClickItem, onClickItem = _h === void 0 ? function () { } : _h, _j = _a.anchorRef, anchorRef = _j === void 0 ? undefined : _j, _k = _a.matchAnchorWidth, matchAnchorWidth = _k === void 0 ? undefined : _k, _l = _a.onContextMenu, onContextMenu = _l === void 0 ? undefined : _l, restProps = __rest(_a, ["isTopFlat", "children", "open", "onClose", "className", "isWithOverlay", "zIndex", "onClickItem", "anchorRef", "matchAnchorWidth", "onContextMenu"]);
2104
2307
  var MenuContainerRef = React.useRef(null);
2105
2308
  var positionStyle = usePopupPosition(anchorRef, MenuContainerRef)[0];
2309
+ useMenuKeyboard({ open: open, onClose: onClose, listRef: MenuContainerRef, anchorRef: anchorRef });
2106
2310
  var newStyle = React.useMemo(function () {
2107
2311
  var _a, _b;
2108
2312
  if (!(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)) {
@@ -2167,9 +2371,12 @@ function MenuContainerNoAnchorInner(propsComp, ref) {
2167
2371
  var MenuContainerNoAnchor = React.forwardRef(MenuContainerNoAnchorInner);
2168
2372
 
2169
2373
  function MenuItem(_a) {
2170
- var _b = _a.className, className = _b === void 0 ? '' : _b, label = _a.label, _c = _a.onClick, onClick = _c === void 0 ? function () { } : _c, _d = _a.caption, caption = _d === void 0 ? undefined : _d, _e = _a.isChecked, isChecked = _e === void 0 ? undefined : _e, _f = _a.onClose, onClose = _f === void 0 ? function () { } : _f, _g = _a.children, children = _g === void 0 ? undefined : _g, _h = _a.zIndex, zIndex = _h === void 0 ? 100 : _h, _j = _a.inheritedOnClick, inheritedOnClick = _j === void 0 ? function () { } : _j, _k = _a.disabled, disabled = _k === void 0 ? false : _k, props = __rest(_a, ["className", "label", "onClick", "caption", "isChecked", "onClose", "children", "zIndex", "inheritedOnClick", "disabled"]);
2171
- var _l = React.useState(false), isHovered = _l[0], setIsHovered = _l[1];
2172
- var _m = React.useState(false), isLeft = _m[0], setIsLeft = _m[1];
2374
+ var _b = _a.className, className = _b === void 0 ? '' : _b, label = _a.label, _c = _a.onClick, onClick = _c === void 0 ? function () { } : _c, _d = _a.caption, caption = _d === void 0 ? undefined : _d, _e = _a.isChecked, isChecked = _e === void 0 ? undefined : _e, _f = _a.onClose, onClose = _f === void 0 ? function () { } : _f, _g = _a.children, children = _g === void 0 ? undefined : _g, _h = _a.zIndex, zIndex = _h === void 0 ? 100 : _h, _j = _a.inheritedOnClick, inheritedOnClick = _j === void 0 ? function () { } : _j, _k = _a.disabled, disabled = _k === void 0 ? false : _k, _l = _a.onKeyDown, consumerOnKeyDown = _l === void 0 ? undefined : _l, _m = _a.onFocus, consumerOnFocus = _m === void 0 ? undefined : _m, _o = _a.onBlur, consumerOnBlur = _o === void 0 ? undefined : _o, props = __rest(_a, ["className", "label", "onClick", "caption", "isChecked", "onClose", "children", "zIndex", "inheritedOnClick", "disabled", "onKeyDown", "onFocus", "onBlur"]);
2375
+ var _p = React.useState(false), isHovered = _p[0], setIsHovered = _p[1];
2376
+ var _q = React.useState(false), isKeyboardOpen = _q[0], setIsKeyboardOpen = _q[1];
2377
+ var _r = React.useState(false), isKeyFocused = _r[0], setIsKeyFocused = _r[1];
2378
+ var outerRef = React.useRef(null);
2379
+ var _s = React.useState(false), isLeft = _s[0], setIsLeft = _s[1];
2173
2380
  var isWithChecked = isChecked !== undefined;
2174
2381
  var leftPadding = isWithChecked ? 'pl-[5px]' : 'pl-[10px]';
2175
2382
  var rightPadding = caption || children ? 'pr-[5px]' : 'pr-[10px]';
@@ -2186,24 +2393,87 @@ function MenuItem(_a) {
2186
2393
  else
2187
2394
  setIsLeft(false);
2188
2395
  }
2189
- }, [isHovered]);
2396
+ }, [isHovered, isKeyboardOpen]);
2190
2397
  var translateClass = isLeft
2191
2398
  ? 'left-0 -translate-x-full'
2192
2399
  : 'right-0 translate-x-full';
2193
2400
  var currentZIndex = zIndex + 10;
2194
- return (React.createElement("div", { className: "group/main relative cursor-pointer first:rounded-t-radius-sm first:pt-[6px] last:rounded-b-radius-sm last:pb-[6px]", onMouseEnter: function () { return !disabled && setIsHovered(true); }, onMouseLeave: function () { return !disabled && setIsHovered(false); } },
2195
- React.createElement("div", __assign({ className: "relative flex items-center bg-bia-white py-[5px] ".concat(itemClass, " ").concat(disabled ? 'cursor-not-allowed' : 'hover:bg-bia-blue-pastel'), role: "button", "aria-disabled": disabled, tabIndex: disabled ? -1 : 0, onClick: function (e) {
2401
+ var handleKeyDown = function (e) {
2402
+ if (e.target === e.currentTarget && !disabled) {
2403
+ var isActivateKey = e.key === 'Enter' || e.key === ' ';
2404
+ if (children && (isActivateKey || e.key === 'ArrowRight')) {
2405
+ e.preventDefault();
2406
+ setIsKeyboardOpen(true);
2407
+ requestAnimationFrame(function () {
2408
+ var _a;
2409
+ (_a = getEnabledItems(MenuContRef.current)[0]) === null || _a === void 0 ? void 0 : _a.focus();
2410
+ });
2411
+ }
2412
+ else if (!children && isActivateKey) {
2413
+ // Same code as a mouse click (R34)
2414
+ e.preventDefault();
2415
+ e.currentTarget.click();
2416
+ }
2417
+ }
2418
+ consumerOnKeyDown === null || consumerOnKeyDown === void 0 ? void 0 : consumerOnKeyDown(e);
2419
+ };
2420
+ var handleSubMenuKeyDown = function (e) {
2421
+ var _a, _b, _c;
2422
+ if (e.key === 'ArrowLeft' || e.key === 'Escape') {
2423
+ e.preventDefault();
2424
+ e.stopPropagation();
2425
+ setIsKeyboardOpen(false);
2426
+ setIsHovered(false);
2427
+ (_b = (_a = outerRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(':scope > [role="button"]')) === null || _b === void 0 ? void 0 : _b.focus();
2428
+ }
2429
+ else if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
2430
+ e.preventDefault();
2431
+ e.stopPropagation();
2432
+ var items = getEnabledItems(e.currentTarget);
2433
+ var index = items.findIndex(function (item) {
2434
+ return item === document.activeElement ||
2435
+ item.contains(document.activeElement);
2436
+ });
2437
+ (_c = items[nextIndex(index, e.key === 'ArrowDown' ? 1 : -1, items.length)]) === null || _c === void 0 ? void 0 : _c.focus();
2438
+ }
2439
+ };
2440
+ var handleFocus = function (e) {
2441
+ try {
2442
+ if (e.currentTarget.matches(':focus-visible'))
2443
+ setIsKeyFocused(true);
2444
+ }
2445
+ catch (_a) {
2446
+ // :focus-visible is not supported here, so there is no keyboard highlight
2447
+ }
2448
+ consumerOnFocus === null || consumerOnFocus === void 0 ? void 0 : consumerOnFocus(e);
2449
+ };
2450
+ var handleBlur = function (e) {
2451
+ setIsKeyFocused(false);
2452
+ consumerOnBlur === null || consumerOnBlur === void 0 ? void 0 : consumerOnBlur(e);
2453
+ };
2454
+ var keyFocusClass = isKeyFocused
2455
+ ? ' !bg-bia-blue-pastel outline outline-[3px] -outline-offset-[3px] outline-bia-blue-light-50'
2456
+ : '';
2457
+ return (React.createElement("div", { ref: outerRef, className: "group/main relative cursor-pointer first:rounded-t-radius-sm first:pt-[6px] last:rounded-b-radius-sm last:pb-[6px]", onMouseEnter: function () { return !disabled && setIsHovered(true); }, onMouseLeave: function () { return !disabled && setIsHovered(false); }, onBlur: function (e) {
2458
+ // Focus left the whole item, so close a sub-menu opened by keyboard
2459
+ if (!e.currentTarget.contains(e.relatedTarget))
2460
+ setIsKeyboardOpen(false);
2461
+ } },
2462
+ React.createElement("div", __assign({ className: "relative flex items-center bg-bia-white py-[5px] ".concat(itemClass, " ").concat(disabled ? 'cursor-not-allowed' : 'hover:bg-bia-blue-pastel').concat(keyFocusClass), role: "button", "aria-disabled": disabled, tabIndex: disabled ? -1 : 0, onClick: function (e) {
2196
2463
  if (disabled)
2197
2464
  return;
2198
2465
  inheritedOnClick();
2199
2466
  onClick(e);
2200
- }, onKeyDown: function () { }, style: { zIndex: currentZIndex + 15 } }, props),
2467
+ }, onKeyDown: handleKeyDown, onFocus: handleFocus, onBlur: handleBlur, style: { zIndex: currentZIndex + 15 } }, props),
2201
2468
  isWithChecked && (React.createElement("div", { className: "mr-[5px] aspect-square w-[14px]" }, isChecked && React.createElement(TbCheck, { className: "text-primary-black", size: 14 }))),
2202
2469
  React.createElement("span", { className: "whitespace-nowrap font-arial text-[11px] ".concat(disabled ? 'text-bia-coolgrey-light-50' : 'text-bia-black') }, label),
2203
2470
  React.createElement("div", { className: "ml-auto flex items-center" },
2204
2471
  children && (React.createElement(TbChevronRight, { className: "ml-[10px] text-bia-coolgrey" })),
2205
2472
  children === undefined && caption && (React.createElement("span", { className: "ml-[30px] whitespace-nowrap text-[11px] ".concat(disabled ? 'text-bia-coolgrey-light-50' : 'text-bia-coolgrey') }, caption)))),
2206
- children && !disabled && (React.createElement(MenuContainerNoAnchor, { open: isHovered, onClose: onClose, className: "absolute top-0 bg-primary-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] group-first/main:top-[6px] ".concat(translateClass), ref: MenuContRef, zIndex: currentZIndex + 10, onClickItem: function () { return inheritedOnClick(); } }, children))));
2473
+ children && !disabled && (React.createElement(MenuContainerNoAnchor, { open: isHovered || isKeyboardOpen, onKeyDown: handleSubMenuKeyDown, onClose: function () {
2474
+ setIsKeyboardOpen(false);
2475
+ onClose();
2476
+ }, className: "absolute top-0 bg-primary-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] group-first/main:top-[6px] ".concat(translateClass), ref: MenuContRef, zIndex: currentZIndex + 10, onClickItem: function () { return inheritedOnClick(); } }, children))));
2207
2477
  }
2208
2478
 
2209
2479
  var TooltipItem = function (_a) {
@@ -2249,17 +2519,31 @@ var TooltipItem = function (_a) {
2249
2519
  };
2250
2520
  function Tooltip(props) {
2251
2521
  var children = props.children, content = props.content, delay = props.delay, _a = props.direction, direction = _a === void 0 ? 'top' : _a, _b = props.maxWidth, maxWidth = _b === void 0 ? undefined : _b, _c = props.zIndex, zIndex = _c === void 0 ? 150 : _c, bgColor = props.bgColor, textColor = props.textColor, className = props.className, style = props.style;
2252
- var timeout;
2522
+ var timeoutRef = React.useRef(null);
2253
2523
  var _d = React.useState(false), active = _d[0], setActive = _d[1];
2254
2524
  var anchorRef = React.useRef(null);
2255
2525
  var tooltipContainerRef = React.useRef(null);
2526
+ var clearTimer = function () {
2527
+ if (timeoutRef.current !== null) {
2528
+ clearTimeout(timeoutRef.current);
2529
+ timeoutRef.current = null;
2530
+ }
2531
+ };
2532
+ React.useEffect(function () { return function () {
2533
+ if (timeoutRef.current !== null) {
2534
+ clearTimeout(timeoutRef.current);
2535
+ timeoutRef.current = null;
2536
+ }
2537
+ }; }, []);
2256
2538
  var showTip = function () {
2257
- timeout = setTimeout(function () {
2539
+ clearTimer();
2540
+ timeoutRef.current = setTimeout(function () {
2541
+ timeoutRef.current = null;
2258
2542
  setActive(true);
2259
2543
  }, delay || 400);
2260
2544
  };
2261
2545
  var hideTip = function () {
2262
- clearInterval(timeout);
2546
+ clearTimer();
2263
2547
  setActive(false);
2264
2548
  };
2265
2549
  return (React.createElement("div", { className: "tooltip-wrapper relative inline-flex h-fit w-fit flex-col", onMouseEnter: showTip, onMouseLeave: hideTip, ref: anchorRef },
@@ -2283,14 +2567,8 @@ function FormLabel(_a) {
2283
2567
 
2284
2568
  function PasswordIcon(_a) {
2285
2569
  var isShow = _a.isShow, showHandler = _a.showHandler, iconSize = _a.iconSize, disabled = _a.disabled;
2286
- var iconColor = disabled ? '#8b8ba6' : '#5E5EEA';
2287
- if (isShow) {
2288
- return (React.createElement(TbEye, { onClick: function () { return showHandler(false); }, style: {
2289
- fontSize: iconSize,
2290
- color: iconColor,
2291
- } }));
2292
- }
2293
- return (React.createElement(TbEyeOff, { onClick: function () { return showHandler(true); }, style: { fontSize: iconSize, color: iconColor } }));
2570
+ var iconColor = disabled ? 'text-bia-coolgrey' : 'text-bia-blue';
2571
+ return (React.createElement("button", { type: "button", "aria-label": isShow ? 'Hide password' : 'Show password', disabled: disabled, onClick: function () { return showHandler(!isShow); }, className: "flex items-center rounded focus-visible:outline focus-visible:outline-[3px] focus-visible:outline-offset-0 focus-visible:outline-bia-blue-light-50 ".concat(iconColor) }, isShow ? (React.createElement(TbEye, { size: iconSize, "aria-hidden": "true" })) : (React.createElement(TbEyeOff, { size: iconSize, "aria-hidden": "true" }))));
2294
2572
  }
2295
2573
 
2296
2574
  function ValidationIcon(_a) {
@@ -2379,7 +2657,7 @@ var TextInput = React.forwardRef(function (_a, ref) {
2379
2657
  return (React.createElement("div", { className: "bianic-text-input-container bianic-fgc-container group/form flex w-full flex-col gap-y-2 text-bia-black" },
2380
2658
  label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
2381
2659
  React.createElement("div", { className: "relative w-full ".concat(disabledClass) },
2382
- React.createElement("input", __assign({ className: "bianic-text-input bianic-fgc-target w-full rounded read-only:pointer-events-none read-only:border-bia-grey-light-50 hover:rounded-b-none focus:rounded-b-none focus-visible:outline-none disabled:cursor-not-allowed disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-grey-active ".concat(extendedInputClassName), disabled: disabled, id: id, placeholder: placeholder || label, readOnly: readOnly, required: required, type: typeVariant, value: value, onChange: function (e) { return onChange(e); }, maxLength: maxLength, autoComplete: autoComplete, ref: ref, style: {
2660
+ React.createElement("input", __assign({ className: "bianic-text-input bianic-fgc-target w-full rounded read-only:pointer-events-none read-only:border-bia-grey-light-50 hover:rounded-b-none focus:rounded-b-none focus-visible:outline-none disabled:cursor-not-allowed disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-coolgrey ".concat(extendedInputClassName), disabled: disabled, id: id, placeholder: placeholder || label, readOnly: readOnly, required: required, type: typeVariant, value: value, onChange: function (e) { return onChange(e); }, maxLength: maxLength, autoComplete: autoComplete, ref: ref, style: {
2383
2661
  paddingRight: iconElement
2384
2662
  ? "".concat(10 + Number(iconSize), "px")
2385
2663
  : undefined,
@@ -2425,10 +2703,10 @@ var sizeConfig$c = {
2425
2703
  },
2426
2704
  };
2427
2705
 
2428
- var sizeUnion$4 = ['md', 'sm', 'tn'];
2706
+ var sizeUnion$5 = ['md', 'sm', 'tn'];
2429
2707
  var Radio = React.forwardRef(function Radio(_a, ref) {
2430
2708
  var _b = _a.label, label = _b === void 0 ? '' : _b, _c = _a.size, size = _c === void 0 ? 'md' : _c, _d = _a.id, id = _d === void 0 ? '' : _d, _e = _a.onChange, onChange = _e === void 0 ? function () { } : _e, _f = _a.onClick, onClick = _f === void 0 ? function () { } : _f, _g = _a.disabled, disabled = _g === void 0 ? false : _g, _h = _a.checked, checked = _h === void 0 ? false : _h, _j = _a.containerClassName, containerClassName = _j === void 0 ? '' : _j, _k = _a.inputClassName, inputClassName = _k === void 0 ? '' : _k, _l = _a.labelClassName, labelClassName = _l === void 0 ? '' : _l, className = _a.className, name = _a.name, value = _a.value, _m = _a.required, required = _m === void 0 ? false : _m, _o = _a.readOnly, readOnly = _o === void 0 ? false : _o, autoComplete = _a.autoComplete, tabIndex = _a.tabIndex, role = _a.role, ariaLabel = _a["aria-label"], ariaLabelledby = _a["aria-labelledby"], onFocus = _a.onFocus, onBlur = _a.onBlur, onKeyDown = _a.onKeyDown, defaultChecked = _a.defaultChecked;
2431
- var validatedSize = validUnion(size, sizeUnion$4);
2709
+ var validatedSize = validUnion(size, sizeUnion$5);
2432
2710
  var _p = sizeConfig$c[validatedSize], checkSize = _p.checkSize, labelSize = _p.labelSize;
2433
2711
  var backgroundClass = size === 'tn' && checked ? 'bg-bia-blue' : 'bg-bia-white';
2434
2712
  var peerCheckedClass = size === 'tn'
@@ -2439,8 +2717,8 @@ var Radio = React.forwardRef(function Radio(_a, ref) {
2439
2717
  : 'focus-visible:ring-offset-2';
2440
2718
  return (React.createElement("div", { className: cn$1('flex items-center', containerClassName) },
2441
2719
  React.createElement("div", { className: cn$1('relative flex flex-shrink-0 items-center justify-center rounded-full', checkSize, backgroundClass) },
2442
- React.createElement("input", { ref: ref, id: id, type: "radio", className: cn$1('checkbox peer absolute box-content h-full w-full cursor-pointer appearance-none rounded-full border-2 border-bia-coolgrey-light-50 checked:border-bia-blue hover:border-bia-blue-hover focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-bia-blue disabled:cursor-not-allowed disabled:border-bia-coolgrey-light-50 disabled:checked:border-bia-blue-light-50', inputFocusClass, inputClassName, className), name: name, value: value, required: required, readOnly: readOnly, autoComplete: autoComplete, tabIndex: tabIndex, role: role, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, onChange: onChange, onClick: onClick, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, checked: checked, defaultChecked: defaultChecked, disabled: disabled }),
2443
- React.createElement("div", { className: cn$1('check-icon z-1 group flex h-full w-full justify-center rounded-full border-2 border-primary-white text-bia-grey outline-2 outline-transparent peer-checked:bg-bia-blue peer-checked:hover:border-bia-blue-hover peer-checked:hover:outline-bia-blue-hover peer-focus-visible:outline-bia-blue peer-disabled:border-transparent peer-disabled:bg-bia-grey-light-80 peer-disabled:peer-checked:border-primary-white peer-disabled:peer-checked:bg-bia-blue-disabled', peerCheckedClass) })),
2720
+ React.createElement("input", { ref: ref, id: id, type: "radio", className: cn$1('checkbox peer absolute box-content h-full w-full cursor-pointer appearance-none rounded-full border-2 border-bia-coolgrey-light-50 checked:border-bia-blue hover:border-bia-blue-hover focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-bia-blue disabled:cursor-not-allowed disabled:border-bia-grey-dark-10 disabled:checked:border-bia-blue-disabled', inputFocusClass, inputClassName, className), name: name, value: value, required: required, readOnly: readOnly, autoComplete: autoComplete, tabIndex: tabIndex, role: role, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, onChange: onChange, onClick: onClick, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, checked: checked, defaultChecked: defaultChecked, disabled: disabled }),
2721
+ React.createElement("div", { className: cn$1('check-icon z-1 group flex h-full w-full justify-center rounded-full border-2 border-primary-white text-bia-grey outline-2 outline-transparent peer-checked:bg-bia-blue peer-checked:hover:border-bia-blue-hover peer-checked:hover:outline-bia-blue-hover peer-focus-visible:outline-bia-blue peer-disabled:border-bia-grey-dark-10 peer-disabled:bg-bia-grey-light-80 peer-disabled:peer-checked:border-primary-white peer-disabled:peer-checked:bg-bia-blue-disabled', peerCheckedClass) })),
2444
2722
  label && (React.createElement("label", { htmlFor: id, className: cn$1('ml-2 leading-4', disabled ? 'text-bia-coolgrey' : 'text-bia-black', labelSize, labelClassName) }, childrenElement(label)))));
2445
2723
  });
2446
2724
  Radio.defaultProps = {
@@ -2501,7 +2779,7 @@ function TextAreaInner(_a, ref) {
2501
2779
  label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
2502
2780
  React.createElement("div", { className: "relative h-fit w-full min-w-[250px] ".concat(disabledClass) },
2503
2781
  React.createElement(ResizeIcon, { className: "absolute bottom-[11px] right-[5px]" }),
2504
- React.createElement("textarea", __assign({ className: "field bianic-text-area w-full rounded border border-bia-grey-dark-10 bg-primary-white p-2.5 read-only:pointer-events-none focus-visible:outline-none enabled:hover:rounded-b-none enabled:focus:rounded-b-none disabled:cursor-not-allowed disabled:bg-bia-grey-light-80 disabled:text-bia-grey-active ".concat(extendedInputClassName), rows: inputRow, id: id, placeholder: placeholder, disabled: disabled, maxLength: maxLength, value: value, autoComplete: autoComplete, readOnly: readOnly, ref: ref }, props))),
2782
+ React.createElement("textarea", __assign({ className: "field bianic-text-area w-full rounded border border-bia-grey-dark-10 bg-primary-white p-2.5 read-only:pointer-events-none focus-visible:outline-none enabled:hover:rounded-b-none enabled:focus:rounded-b-none disabled:cursor-not-allowed disabled:bg-bia-grey-light-80 disabled:text-bia-coolgrey ".concat(extendedInputClassName), rows: inputRow, id: id, placeholder: placeholder, disabled: disabled, maxLength: maxLength, value: value, autoComplete: autoComplete, readOnly: readOnly, ref: ref }, props))),
2505
2783
  React.createElement("div", { className: "desc flex justify-between gap-1 text-xs ".concat(descColor) },
2506
2784
  descText && React.createElement("span", null, descText),
2507
2785
  maxLength && (React.createElement("span", null,
@@ -2527,18 +2805,18 @@ var sizeConfig$a = {
2527
2805
  },
2528
2806
  };
2529
2807
 
2530
- var sizeUnion$3 = ['md', 'sm', 'tn'];
2808
+ var sizeUnion$4 = ['md', 'sm', 'tn'];
2531
2809
  function Checkbox(_a) {
2532
2810
  var _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.id, id = _c === void 0 ? '' : _c, _d = _a.size, size = _d === void 0 ? 'md' : _d, _e = _a.label, label = _e === void 0 ? '' : _e, _f = _a.onChange, onChange = _f === void 0 ? function () { } : _f, _g = _a.isIndeterminate, isIndeterminate = _g === void 0 ? false : _g, props = __rest(_a, ["disabled", "id", "size", "label", "onChange", "isIndeterminate"]);
2533
- var _h = sizeConfig$a[validUnion(size, sizeUnion$3)], checkClass = _h.checkClass, labelClass = _h.labelClass;
2811
+ var _h = sizeConfig$a[validUnion(size, sizeUnion$4)], checkClass = _h.checkClass, labelClass = _h.labelClass;
2534
2812
  var isValidIndeterminate = isIndeterminate && props.checked;
2535
2813
  var backgroundClass = size === 'tn' && props.checked ? 'bg-bia-blue' : 'bg-bia-white';
2536
2814
  var peerCheckedClass = size === 'tn' ? '' : 'peer-checked:border-2';
2537
2815
  return (React.createElement("div", { className: "inline-flex items-center" },
2538
2816
  React.createElement("div", { className: "relative flex flex-shrink-0 items-center justify-center rounded-full ".concat(backgroundClass, " ").concat(checkClass) },
2539
- React.createElement("input", __assign({ id: id, type: "checkbox", className: "checkbox peer absolute box-content h-full w-full cursor-pointer appearance-none rounded-full border-2 border-bia-coolgrey-light-50 checked:border-bia-blue hover:border-bia-blue-hover focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-bia-blue focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:border-bia-coolgrey-light-50 disabled:checked:border-bia-blue-light-50", onChange: function (e) { return onChange(e); }, disabled: disabled }, props)),
2540
- React.createElement("div", { className: "check-icon z-1 group flex h-full w-full items-center justify-center rounded-full text-bia-grey outline-2 outline-transparent peer-checked:border-primary-white peer-checked:bg-bia-blue peer-checked:hover:border-bia-blue-hover peer-checked:hover:outline-bia-blue-hover peer-checked:peer-hover:bg-bia-blue-hover peer-focus-visible:outline-bia-blue peer-disabled:bg-bia-grey-light-80 peer-disabled:peer-checked:bg-bia-blue-light-50 peer-disabled:peer-checked:outline-bia-blue-light-50 ".concat(peerCheckedClass) }, isValidIndeterminate ? (React.createElement(TbMinus, { className: "stroke-[3px] text-bia-grey-dark-10 peer-checked:group-[]:text-bia-white peer-hover:group-[]:text-bia-blue-hover peer-checked:peer-hover:group-[]:text-bia-white peer-disabled:group-[]:text-bia-grey-dark-10 peer-disabled:peer-checked:group-[]:text-bia-white", size: 14 })) : (React.createElement(TbCheck, { className: "stroke-[3px] text-bia-grey-dark-10 peer-checked:group-[]:text-bia-white peer-hover:group-[]:text-bia-blue-hover peer-checked:peer-hover:group-[]:text-bia-white peer-disabled:group-[]:text-bia-grey-dark-10 peer-disabled:peer-checked:group-[]:text-bia-white", size: 14 })))),
2541
- label && (React.createElement("label", { htmlFor: id, className: "ml-2 leading-4 text-primary-black ".concat(labelClass), style: { color: disabled ? '#8C8CA6' : '' } }, childrenElement(label)))));
2817
+ React.createElement("input", __assign({ id: id, type: "checkbox", className: "checkbox peer absolute box-content h-full w-full cursor-pointer appearance-none rounded-full border-2 border-bia-coolgrey-light-50 checked:border-bia-blue hover:border-bia-blue-hover focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-bia-blue focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:border-bia-grey-dark-10 disabled:checked:border-bia-blue-disabled", onChange: function (e) { return onChange(e); }, disabled: disabled }, props)),
2818
+ React.createElement("div", { className: "check-icon z-1 group flex h-full w-full items-center justify-center rounded-full text-bia-grey outline-2 outline-transparent peer-checked:border-primary-white peer-checked:bg-bia-blue peer-checked:hover:border-bia-blue-hover peer-checked:hover:outline-bia-blue-hover peer-checked:peer-hover:bg-bia-blue-hover peer-focus-visible:outline-bia-blue peer-disabled:bg-bia-grey-light-80 peer-disabled:peer-checked:bg-bia-blue-disabled peer-disabled:peer-checked:outline-bia-blue-disabled ".concat(peerCheckedClass) }, isValidIndeterminate ? (React.createElement(TbMinus, { className: "stroke-[3px] text-bia-grey-dark-10 peer-checked:group-[]:text-bia-white peer-hover:group-[]:text-bia-blue-hover peer-checked:peer-hover:group-[]:text-bia-white peer-disabled:group-[]:text-bia-grey-dark-10 peer-disabled:peer-checked:group-[]:text-bia-white", size: 14 })) : (React.createElement(TbCheck, { className: "stroke-[3px] text-bia-grey-dark-10 peer-checked:group-[]:text-bia-white peer-hover:group-[]:text-bia-blue-hover peer-checked:peer-hover:group-[]:text-bia-white peer-disabled:group-[]:text-bia-grey-dark-10 peer-disabled:peer-checked:group-[]:text-bia-white", size: 14 })))),
2819
+ label && (React.createElement("label", { htmlFor: id, className: "ml-2 leading-4 text-primary-black ".concat(disabled ? '!text-bia-coolgrey' : '', " ").concat(labelClass) }, childrenElement(label)))));
2542
2820
  }
2543
2821
 
2544
2822
  var sizeConfig$9 = {
@@ -2565,16 +2843,27 @@ var sizeConfig$8 = {
2565
2843
 
2566
2844
  /* eslint-disable @typescript-eslint/no-explicit-any */
2567
2845
  function CustomDropdownItem(_a) {
2568
- var _b = _a.className, className = _b === void 0 ? '' : _b, _c = _a.onClick, onClick = _c === void 0 ? function () { } : _c, _d = _a.size, size = _d === void 0 ? 'md' : _d, _e = _a.isSelected, isSelected = _e === void 0 ? false : _e, _f = _a.options, options = _f === void 0 ? [] : _f, _g = _a.children, children = _g === void 0 ? undefined : _g;
2569
- var _h = React.useState(false), isHovered = _h[0], setisHovered = _h[1];
2570
- var _j = React.useState(false), isHoveredSubMenu = _j[0], setIsHoveredSubMenu = _j[1];
2846
+ var _b = _a.className, className = _b === void 0 ? '' : _b, _c = _a.onClick, onClick = _c === void 0 ? function () { } : _c, _d = _a.size, size = _d === void 0 ? 'md' : _d, _e = _a.isSelected, isSelected = _e === void 0 ? false : _e, _f = _a.isHighlighted, isHighlighted = _f === void 0 ? false : _f, _g = _a.id, id = _g === void 0 ? undefined : _g, _h = _a.options, options = _h === void 0 ? [] : _h, _j = _a.children, children = _j === void 0 ? undefined : _j;
2847
+ var _k = React.useState(false), isHovered = _k[0], setisHovered = _k[1];
2848
+ var _l = React.useState(false), isHoveredSubMenu = _l[0], setIsHoveredSubMenu = _l[1];
2571
2849
  var isOpenDropdown = isHovered || isHoveredSubMenu;
2572
2850
  var selectedClass = isSelected ? 'font-semibold' : 'font-normal';
2573
- var _k = sizeConfig$8[size], containerClass = _k.container, item = _k.item;
2851
+ var _m = sizeConfig$8[size], containerClass = _m.container, item = _m.item;
2574
2852
  var itemClass = "".concat(item, " ").concat(selectedClass, " ").concat(className);
2575
2853
  var isExistSubDropdown = options.length !== 0;
2576
- return (React.createElement("div", { className: "relative w-full focus-visible:outline-bia-blue-light-50 ".concat(containerClass), tabIndex: 0, role: "button", onClick: function (e) { return onClick(e); }, onMouseEnter: function () { return setisHovered(true); }, onMouseLeave: function () { return setisHovered(false); }, onKeyDown: function () { } },
2577
- React.createElement("div", { className: "flex select-none flex-col hover:bg-bia-blue-light-90 active:bg-bia-blue-light-80 ".concat(itemClass) },
2854
+ var highlightOuterClass = isHighlighted
2855
+ ? ' outline outline-[3px] -outline-offset-[3px] outline-bia-blue-light-50'
2856
+ : '';
2857
+ var highlightInnerClass = isHighlighted ? ' bg-bia-blue-light-90' : '';
2858
+ return (React.createElement("div", { id: id, className: "relative w-full focus-visible:outline-bia-blue-light-50 ".concat(containerClass).concat(highlightOuterClass), tabIndex: 0, role: "button", onClick: function (e) { return onClick(e); }, onMouseEnter: function () { return setisHovered(true); }, onMouseLeave: function () { return setisHovered(false); }, onKeyDown: function (e) {
2859
+ if (e.target !== e.currentTarget)
2860
+ return;
2861
+ if (e.key === 'Enter' || e.key === ' ') {
2862
+ e.preventDefault();
2863
+ e.currentTarget.click();
2864
+ }
2865
+ } },
2866
+ React.createElement("div", { className: "flex select-none flex-col hover:bg-bia-blue-light-90 active:bg-bia-blue-light-80 ".concat(itemClass).concat(highlightInnerClass) },
2578
2867
  children,
2579
2868
  isExistSubDropdown && (React.createElement(TbChevronRight, { className: "float-right text-bia-grey" }))),
2580
2869
  isOpenDropdown && options && isExistSubDropdown && (React.createElement("div", { className: "absolute right-0 top-0 z-50 w-full translate-x-full rounded-md border border-bia-grey-dark-10 bg-primary-white shadow-lg", onMouseEnter: function () { return setIsHoveredSubMenu(true); }, onMouseLeave: function () { return setIsHoveredSubMenu(false); } }, options.map(function (option) {
@@ -2584,16 +2873,27 @@ function CustomDropdownItem(_a) {
2584
2873
 
2585
2874
  /* eslint-disable @typescript-eslint/no-explicit-any */
2586
2875
  function DefaultDropdownItem(_a) {
2587
- var _b = _a.className, className = _b === void 0 ? '' : _b, label = _a.label, _c = _a.onClick, onClick = _c === void 0 ? function () { } : _c, _d = _a.size, size = _d === void 0 ? 'md' : _d, _e = _a.isSelected, isSelected = _e === void 0 ? false : _e, _f = _a.options, options = _f === void 0 ? [] : _f, _g = _a.caption, caption = _g === void 0 ? '' : _g;
2588
- var _h = React.useState(false), isHovered = _h[0], setisHovered = _h[1];
2589
- var _j = React.useState(false), isHoveredSubMenu = _j[0], setIsHoveredSubMenu = _j[1];
2876
+ var _b = _a.className, className = _b === void 0 ? '' : _b, label = _a.label, _c = _a.onClick, onClick = _c === void 0 ? function () { } : _c, _d = _a.size, size = _d === void 0 ? 'md' : _d, _e = _a.isSelected, isSelected = _e === void 0 ? false : _e, _f = _a.isHighlighted, isHighlighted = _f === void 0 ? false : _f, _g = _a.id, id = _g === void 0 ? undefined : _g, _h = _a.options, options = _h === void 0 ? [] : _h, _j = _a.caption, caption = _j === void 0 ? '' : _j;
2877
+ var _k = React.useState(false), isHovered = _k[0], setisHovered = _k[1];
2878
+ var _l = React.useState(false), isHoveredSubMenu = _l[0], setIsHoveredSubMenu = _l[1];
2590
2879
  var isOpenDropdown = isHovered || isHoveredSubMenu;
2591
2880
  var selectedClass = isSelected ? 'font-semibold' : 'font-normal';
2592
- var _k = sizeConfig$8[size], containerClass = _k.container, item = _k.item;
2881
+ var _m = sizeConfig$8[size], containerClass = _m.container, item = _m.item;
2593
2882
  var itemClass = "".concat(item, " ").concat(selectedClass, " ").concat(className);
2594
2883
  var isExistSubDropdown = options.length !== 0;
2595
- return (React.createElement("div", { className: "relative w-full focus-visible:outline-bia-blue-light-50 ".concat(containerClass), tabIndex: 0, role: "button", onClick: function (e) { return onClick(e); }, onMouseEnter: function () { return setisHovered(true); }, onMouseLeave: function () { return setisHovered(false); }, onKeyDown: function () { } },
2596
- React.createElement("div", { className: "flex select-none flex-col hover:bg-bia-blue-light-90 active:bg-bia-blue-light-80 ".concat(itemClass) },
2884
+ var highlightOuterClass = isHighlighted
2885
+ ? ' outline outline-[3px] -outline-offset-[3px] outline-bia-blue-light-50'
2886
+ : '';
2887
+ var highlightInnerClass = isHighlighted ? ' bg-bia-blue-light-90' : '';
2888
+ return (React.createElement("div", { id: id, className: "relative w-full focus-visible:outline-bia-blue-light-50 ".concat(containerClass).concat(highlightOuterClass), tabIndex: 0, role: "button", onClick: function (e) { return onClick(e); }, onMouseEnter: function () { return setisHovered(true); }, onMouseLeave: function () { return setisHovered(false); }, onKeyDown: function (e) {
2889
+ if (e.target !== e.currentTarget)
2890
+ return;
2891
+ if (e.key === 'Enter' || e.key === ' ') {
2892
+ e.preventDefault();
2893
+ e.currentTarget.click();
2894
+ }
2895
+ } },
2896
+ React.createElement("div", { className: "flex select-none flex-col hover:bg-bia-blue-light-90 active:bg-bia-blue-light-80 ".concat(itemClass).concat(highlightInnerClass) },
2597
2897
  React.createElement("span", null,
2598
2898
  label,
2599
2899
  isExistSubDropdown && (React.createElement(TbChevronRight, { className: "float-right text-bia-grey" }))),
@@ -2644,6 +2944,7 @@ function DropdownContainer(propsComp) {
2644
2944
  if (open)
2645
2945
  recalcPosition();
2646
2946
  }, [open, recalcPosition]);
2947
+ useMenuKeyboard({ open: open, onClose: onClose, listRef: dropdownRef, anchorRef: anchorRef });
2647
2948
  var newStyle = React.useMemo(function () {
2648
2949
  var _a, _b, _c;
2649
2950
  if (!(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)) {
@@ -2691,18 +2992,98 @@ var getItemLabel = function (value) {
2691
2992
  return isObjectWithLabel(value) ? ((_a = value.label) !== null && _a !== void 0 ? _a : '') : String(value !== null && value !== void 0 ? value : '');
2692
2993
  };
2693
2994
 
2694
- var sizeUnion$2 = ['md', 'sm'];
2995
+ var sizeUnion$3 = ['md', 'sm'];
2996
+ var getOptionKey$1 = function (option) {
2997
+ return isObjectWithLabel(option) && option.id != null
2998
+ ? String(option.id)
2999
+ : getItemLabel(option);
3000
+ };
2695
3001
  function SelectInput(_a) {
2696
3002
  var _b;
2697
- var _c = _a.descText, descText = _c === void 0 ? undefined : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.size, size = _e === void 0 ? 'md' : _e, _f = _a.id, id = _f === void 0 ? undefined : _f, _g = _a.isValid, isValid = _g === void 0 ? null : _g, _h = _a.label, label = _h === void 0 ? undefined : _h, _j = _a.options, options = _j === void 0 ? [] : _j, _k = _a.readOnly, readOnly = _k === void 0 ? false : _k, _l = _a.required, required = _l === void 0 ? false : _l, _m = _a.selected, selected = _m === void 0 ? undefined : _m, _o = _a.setSelected, setSelected = _o === void 0 ? function () { } : _o, _p = _a.onClickDropdown, onClickDropdown = _p === void 0 ? function () { } : _p, _q = _a.children, children = _q === void 0 ? undefined : _q, _r = _a.dropContProps, _s = _r === void 0 ? {} : _r, _t = _s.className, dropContClassName = _t === void 0 ? '' : _t, restDropContProps = __rest(_s, ["className"]), props = __rest(_a, ["descText", "disabled", "size", "id", "isValid", "label", "options", "readOnly", "required", "selected", "setSelected", "onClickDropdown", "children", "dropContProps"]);
2698
- var _u = React.useState(false), isOpen = _u[0], setIsOpen = _u[1];
2699
- var validatedSize = validUnion(size, sizeUnion$2);
2700
- var _v = sizeConfig$9[validatedSize], searchSize = _v.searchSize, iconSize = _v.iconSize;
3003
+ var _c = _a.descText, descText = _c === void 0 ? undefined : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.size, size = _e === void 0 ? 'md' : _e, _f = _a.id, id = _f === void 0 ? undefined : _f, _g = _a.isValid, isValid = _g === void 0 ? null : _g, _h = _a.label, label = _h === void 0 ? undefined : _h, _j = _a.options, options = _j === void 0 ? [] : _j, _k = _a.readOnly, readOnly = _k === void 0 ? false : _k, _l = _a.required, required = _l === void 0 ? false : _l, _m = _a.selected, selected = _m === void 0 ? undefined : _m, _o = _a.setSelected, setSelected = _o === void 0 ? function () { } : _o, _p = _a.onClickDropdown, onClickDropdown = _p === void 0 ? function () { } : _p, _q = _a.children, children = _q === void 0 ? undefined : _q, _r = _a.dropContProps, _s = _r === void 0 ? {} : _r, _t = _s.className, dropContClassName = _t === void 0 ? '' : _t, restDropContProps = __rest(_s, ["className"]), _u = _a.onKeyDown, consumerOnKeyDown = _u === void 0 ? undefined : _u, props = __rest(_a, ["descText", "disabled", "size", "id", "isValid", "label", "options", "readOnly", "required", "selected", "setSelected", "onClickDropdown", "children", "dropContProps", "onKeyDown"]);
3004
+ var _v = React.useState(false), isOpen = _v[0], setIsOpen = _v[1];
3005
+ // Option picked by arrow keys (-1 = none)
3006
+ var _w = React.useState(-1), highlightedIndex = _w[0], setHighlightedIndex = _w[1];
3007
+ var baseId = React.useId();
3008
+ var validatedSize = validUnion(size, sizeUnion$3);
3009
+ var _x = sizeConfig$9[validatedSize], searchSize = _x.searchSize, iconSize = _x.iconSize;
2701
3010
  var inputRef = React.useRef(null);
2702
3011
  var selectedLabel = selected !== undefined && isObjectWithLabel(selected)
2703
3012
  ? ((_b = selected.label) !== null && _b !== void 0 ? _b : '')
2704
3013
  : selected;
2705
3014
  var optionsRef = React.useRef(null);
3015
+ React.useEffect(function () {
3016
+ if (!isOpen)
3017
+ setHighlightedIndex(-1);
3018
+ }, [isOpen]);
3019
+ // Enabled top-level children, in order (the arrow keys skip disabled ones)
3020
+ var enabledChildren = children === undefined
3021
+ ? []
3022
+ : React.Children.toArray(children).filter(function (child) {
3023
+ return React.isValidElement(child) &&
3024
+ !child.props.disabled;
3025
+ });
3026
+ var optionCount = children === undefined ? options.length : enabledChildren.length;
3027
+ var activeIndex = isOpen && highlightedIndex >= 0 && highlightedIndex < optionCount
3028
+ ? highlightedIndex
3029
+ : -1;
3030
+ var activeId = activeIndex >= 0 ? getOptionId(baseId, activeIndex) : undefined;
3031
+ React.useEffect(function () {
3032
+ if (activeId)
3033
+ scrollOptionIntoView(activeId);
3034
+ }, [activeId]);
3035
+ var getSelectedIndex = function () {
3036
+ if (children === undefined) {
3037
+ return options.findIndex(function (option) { return JSON.stringify(option) === JSON.stringify(selected); });
3038
+ }
3039
+ return enabledChildren.findIndex(function (child) {
3040
+ var childValue = child
3041
+ .props.value;
3042
+ return (isObjectWithLabel(selected) &&
3043
+ isObjectWithLabel(childValue) &&
3044
+ selected.id === childValue.id);
3045
+ });
3046
+ };
3047
+ // Opens the list and highlights the selected option, or the first / last one
3048
+ var openByKeyboard = function (delta) {
3049
+ setIsOpen(true);
3050
+ var selectedIndex = getSelectedIndex();
3051
+ if (delta < 0)
3052
+ setHighlightedIndex(optionCount - 1);
3053
+ else
3054
+ setHighlightedIndex(optionCount > 0 ? Math.max(selectedIndex, 0) : -1);
3055
+ };
3056
+ var handleKeyDown = function (e) {
3057
+ var _a;
3058
+ if (!disabled) {
3059
+ if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
3060
+ e.preventDefault();
3061
+ var delta = e.key === 'ArrowDown' ? 1 : -1;
3062
+ if (!isOpen)
3063
+ openByKeyboard(delta);
3064
+ else
3065
+ setHighlightedIndex(nextIndex(activeIndex, delta, optionCount));
3066
+ }
3067
+ else if (e.key === 'Enter' || e.key === ' ') {
3068
+ if (!isOpen) {
3069
+ e.preventDefault();
3070
+ openByKeyboard(1);
3071
+ }
3072
+ else if (e.key === 'Enter' && activeId) {
3073
+ e.preventDefault();
3074
+ (_a = document.getElementById(activeId)) === null || _a === void 0 ? void 0 : _a.click();
3075
+ }
3076
+ }
3077
+ else if (e.key === 'Escape' && isOpen) {
3078
+ e.preventDefault();
3079
+ setIsOpen(false);
3080
+ }
3081
+ else if (e.key === 'Tab' && isOpen) {
3082
+ setIsOpen(false);
3083
+ }
3084
+ }
3085
+ consumerOnKeyDown === null || consumerOnKeyDown === void 0 ? void 0 : consumerOnKeyDown(e);
3086
+ };
2706
3087
  var descColor = 'text-primary-cool';
2707
3088
  var isExistValidation = isValid !== null && isValid !== undefined;
2708
3089
  if (!disabled && isExistValidation && isValid)
@@ -2710,46 +3091,55 @@ function SelectInput(_a) {
2710
3091
  if (!disabled && isExistValidation && !isValid)
2711
3092
  descColor = 'text-bia-red';
2712
3093
  var disabledClass = disabled ? 'cursor-not-allowed' : '';
3094
+ var enabledPosition = 0;
2713
3095
  return (React.createElement("div", { className: "bianic-fgc-container bianic-text-input-container field-group flex w-full flex-col gap-y-2" },
2714
3096
  label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
2715
3097
  React.createElement("div", { className: "group relative w-full ".concat(disabledClass) },
2716
- React.createElement("input", __assign({ className: "bianic-fgc-target field peer w-full cursor-pointer rounded border border-bia-grey-dark-10 bg-primary-white pe-8 focus-visible:outline-none enabled:hover:rounded-b-none enabled:hover:border-b-bia-blue enabled:focus:rounded-b-none enabled:focus:border-b-bia-blue disabled:cursor-not-allowed disabled:bg-bia-grey-light-80 disabled:text-bia-coolgrey ".concat(searchSize), onClick: function () { return setIsOpen(!isOpen); }, value: selectedLabel, readOnly: true, id: id, disabled: disabled, ref: inputRef }, props)),
3098
+ React.createElement("input", __assign({ className: "bianic-fgc-target field peer w-full cursor-pointer rounded border border-bia-grey-dark-10 bg-primary-white pe-8 focus-visible:outline-none enabled:hover:rounded-b-none enabled:hover:border-b-bia-blue enabled:focus:rounded-b-none enabled:focus:border-b-bia-blue disabled:cursor-not-allowed disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-coolgrey ".concat(searchSize), onClick: function () { return setIsOpen(!isOpen); }, value: selectedLabel, readOnly: true, id: id, disabled: disabled, ref: inputRef, onKeyDown: handleKeyDown, "aria-activedescendant": activeId }, props)),
2717
3099
  React.createElement("div", { className: "pointer-events-none absolute inset-y-0 flex items-center pl-3 text-bia-coolgrey peer-disabled:text-bia-coolgrey-light-50 ".concat(iconSize) }, isOpen ? React.createElement(TbChevronUp, null) : React.createElement(TbChevronDown, null)),
2718
3100
  children === undefined && isOpen && (
2719
3101
  // Consumer-provided click-catcher; each rendered option below is its own interactive control
2720
3102
  // eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
2721
- React.createElement("div", { className: "absolute z-10 w-full rounded-b-md border border-bia-grey-dark-10 bg-primary-white shadow-lg", ref: optionsRef, onClick: onClickDropdown }, options.map(function (option) {
3103
+ React.createElement("div", { className: "absolute z-10 w-full rounded-b-md border border-bia-grey-dark-10 bg-primary-white shadow-lg", ref: optionsRef, onClick: onClickDropdown }, options.map(function (option, index) {
2722
3104
  var isSelected = JSON.stringify(option) === JSON.stringify(selected);
2723
3105
  var optionCaption = isObjectWithLabel(option)
2724
3106
  ? option.caption
2725
3107
  : '';
2726
- return isObjectWithLabel(option) && option.custom ? (React.createElement(CustomDropdownItem, { caption: optionCaption, size: validatedSize, isSelected: isSelected, onClick: function () {
3108
+ return isObjectWithLabel(option) && option.custom ? (React.createElement(CustomDropdownItem, { key: getOptionKey$1(option), isHighlighted: index === activeIndex, id: index === activeIndex ? activeId : undefined, caption: optionCaption, size: validatedSize, isSelected: isSelected, onClick: function () {
2727
3109
  setSelected === null || setSelected === void 0 ? void 0 : setSelected(option);
2728
3110
  setIsOpen(false);
2729
- } }, option.custom)) : (React.createElement(DefaultDropdownItem, { label: getItemLabel(option), caption: optionCaption, size: validatedSize, isSelected: isSelected, onClick: function () {
3111
+ } }, option.custom)) : (React.createElement(DefaultDropdownItem, { key: getOptionKey$1(option), isHighlighted: index === activeIndex, id: index === activeIndex ? activeId : undefined, label: getItemLabel(option), caption: optionCaption, size: validatedSize, isSelected: isSelected, onClick: function () {
2730
3112
  setSelected === null || setSelected === void 0 ? void 0 : setSelected(option);
2731
3113
  setIsOpen(false);
2732
3114
  } }));
2733
3115
  }))),
2734
3116
  children && isOpen && (React.createElement(DropdownContainer, __assign({ open: isOpen, onClose: function () { return setIsOpen(false); }, size: size, isTopFlat: true, className: "bianic-livesearch-dropdown absolute z-10 mt-1 w-full overflow-hidden rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none ".concat(dropContClassName), anchorRef: inputRef, matchAnchorWidth: "min" }, restDropContProps), React.Children.map(children, function (child) {
2735
3117
  if (React.isValidElement(child)) {
3118
+ var isDisabledChild = child.props
3119
+ .disabled;
3120
+ var position = isDisabledChild ? -1 : enabledPosition;
3121
+ if (!isDisabledChild)
3122
+ enabledPosition += 1;
3123
+ var highlightProps = position >= 0 && position === activeIndex
3124
+ ? {
3125
+ className: cn$1(child.props.className, OPTION_HIGHLIGHT_CLASS),
3126
+ id: activeId,
3127
+ }
3128
+ : {};
2736
3129
  // Consumer-supplied children are expected to carry a `value`
2737
3130
  // prop matching the DropdownItem convention, but arbitrary
2738
3131
  // JSX children have no statically-known prop shape.
2739
3132
  var childValue_1 = child.props
2740
3133
  .value;
2741
- return React.cloneElement(child, {
2742
- isSelected: isObjectWithLabel(selected) &&
3134
+ return React.cloneElement(child, __assign({ isSelected: isObjectWithLabel(selected) &&
2743
3135
  isObjectWithLabel(childValue_1) &&
2744
- selected.id === childValue_1.id,
2745
- onClick: function () {
3136
+ selected.id === childValue_1.id, onClick: function () {
2746
3137
  // Same trust boundary as before: consumer children are
2747
3138
  // expected to always carry a value, matching the exact
2748
3139
  // runtime behavior this already had.
2749
3140
  setSelected === null || setSelected === void 0 ? void 0 : setSelected(childValue_1);
2750
3141
  setIsOpen(false);
2751
- },
2752
- });
3142
+ } }, highlightProps));
2753
3143
  }
2754
3144
  return child;
2755
3145
  })))),
@@ -2802,9 +3192,12 @@ function DropdownContNoAnchorInner(propsComp, ref) {
2802
3192
  var DropdownContNoAnchor = React.forwardRef(DropdownContNoAnchorInner);
2803
3193
 
2804
3194
  function DropdownItem(_a) {
2805
- var _b = _a.children, children = _b === void 0 ? undefined : _b, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.onClickItem, onClickItem = _d === void 0 ? function () { } : _d, _e = _a.onClose, onClose = _e === void 0 ? function () { } : _e, _f = _a.size, size = _f === void 0 ? 'md' : _f, _g = _a.value, value = _g === void 0 ? '' : _g, content = _a.content, _h = _a.disabled, disabled = _h === void 0 ? false : _h, _j = _a.zIndex, zIndex = _j === void 0 ? 100 : _j, props = __rest(_a, ["children", "className", "onClickItem", "onClose", "size", "value", "content", "disabled", "zIndex"]);
2806
- var _k = React.useState(false), isHovered = _k[0], setIsHovered = _k[1];
2807
- var _l = React.useState(false), isLeft = _l[0], setIsLeft = _l[1];
3195
+ var _b = _a.children, children = _b === void 0 ? undefined : _b, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.onClickItem, onClickItem = _d === void 0 ? function () { } : _d, _e = _a.onClose, onClose = _e === void 0 ? function () { } : _e, _f = _a.size, size = _f === void 0 ? 'md' : _f, _g = _a.value, value = _g === void 0 ? '' : _g, content = _a.content, _h = _a.disabled, disabled = _h === void 0 ? false : _h, _j = _a.zIndex, zIndex = _j === void 0 ? 100 : _j, _k = _a.onKeyDown, consumerOnKeyDown = _k === void 0 ? undefined : _k, _l = _a.onFocus, consumerOnFocus = _l === void 0 ? undefined : _l, _m = _a.onBlur, consumerOnBlur = _m === void 0 ? undefined : _m, props = __rest(_a, ["children", "className", "onClickItem", "onClose", "size", "value", "content", "disabled", "zIndex", "onKeyDown", "onFocus", "onBlur"]);
3196
+ var _o = React.useState(false), isHovered = _o[0], setIsHovered = _o[1];
3197
+ var _p = React.useState(false), isKeyboardOpen = _p[0], setIsKeyboardOpen = _p[1];
3198
+ var _q = React.useState(false), isKeyFocused = _q[0], setIsKeyFocused = _q[1];
3199
+ var _r = React.useState(false), isLeft = _r[0], setIsLeft = _r[1];
3200
+ var outerRef = React.useRef(null);
2808
3201
  var fontClass = fontConfig[size] || fontConfig.md;
2809
3202
  var itemSizeClass = itemSizeConfig[size] || itemSizeConfig.md;
2810
3203
  var itemClass = "".concat(itemSizeClass, " ").concat(fontClass, " ").concat(className);
@@ -2822,16 +3215,71 @@ function DropdownItem(_a) {
2822
3215
  else
2823
3216
  setIsLeft(false);
2824
3217
  }
2825
- }, [isHovered]);
3218
+ }, [isHovered, isKeyboardOpen]);
2826
3219
  var translateClass = isLeft
2827
3220
  ? 'left-0 -translate-x-full'
2828
3221
  : 'right-0 translate-x-full';
2829
3222
  var currentZIndex = zIndex + 10;
2830
- return (React.createElement("div", { className: "bianic-dropdown-item group/main relative cursor-pointer first:rounded-t-radius-sm first:pt-[5px] last:rounded-b-radius-sm last:pb-[5px]", onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); } },
2831
- React.createElement("button", __assign({ className: "relative flex w-full !min-w-fit items-center justify-start whitespace-nowrap bg-bia-white px-[15px] py-[5px] text-left text-bia-black disabled:cursor-not-allowed disabled:text-bia-coolgrey-light-50 hover:[&:not(:disabled)]:bg-bia-blue-pastel ".concat(itemClass), style: { zIndex: currentZIndex + 15 }, onClick: function (e) { return onClickItem(e, value); }, onKeyDown: function () { }, disabled: disabled, type: "button" }, props),
3223
+ var handleKeyDown = function (e) {
3224
+ if (children && (e.key === 'ArrowRight' || e.key === 'Enter')) {
3225
+ e.preventDefault();
3226
+ setIsKeyboardOpen(true);
3227
+ requestAnimationFrame(function () {
3228
+ var _a;
3229
+ (_a = getEnabledItems(DropdownContRef.current)[0]) === null || _a === void 0 ? void 0 : _a.focus();
3230
+ });
3231
+ }
3232
+ consumerOnKeyDown === null || consumerOnKeyDown === void 0 ? void 0 : consumerOnKeyDown(e);
3233
+ };
3234
+ var handleSubMenuKeyDown = function (e) {
3235
+ var _a, _b, _c;
3236
+ if (e.key === 'ArrowLeft' || e.key === 'Escape') {
3237
+ e.preventDefault();
3238
+ e.stopPropagation();
3239
+ setIsKeyboardOpen(false);
3240
+ setIsHovered(false);
3241
+ (_b = (_a = outerRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(':scope > button')) === null || _b === void 0 ? void 0 : _b.focus();
3242
+ }
3243
+ else if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
3244
+ e.preventDefault();
3245
+ e.stopPropagation();
3246
+ var items = getEnabledItems(e.currentTarget);
3247
+ var index = items.findIndex(function (item) {
3248
+ return item === document.activeElement ||
3249
+ item.contains(document.activeElement);
3250
+ });
3251
+ (_c = items[nextIndex(index, e.key === 'ArrowDown' ? 1 : -1, items.length)]) === null || _c === void 0 ? void 0 : _c.focus();
3252
+ }
3253
+ };
3254
+ var handleFocus = function (e) {
3255
+ try {
3256
+ if (e.currentTarget.matches(':focus-visible'))
3257
+ setIsKeyFocused(true);
3258
+ }
3259
+ catch (_a) {
3260
+ // :focus-visible is not supported here, so there is no keyboard highlight
3261
+ }
3262
+ consumerOnFocus === null || consumerOnFocus === void 0 ? void 0 : consumerOnFocus(e);
3263
+ };
3264
+ var handleBlur = function (e) {
3265
+ setIsKeyFocused(false);
3266
+ consumerOnBlur === null || consumerOnBlur === void 0 ? void 0 : consumerOnBlur(e);
3267
+ };
3268
+ var keyFocusClass = isKeyFocused
3269
+ ? ' !bg-bia-blue-pastel outline outline-[3px] -outline-offset-[3px] outline-bia-blue-light-50'
3270
+ : '';
3271
+ return (React.createElement("div", { ref: outerRef, className: "bianic-dropdown-item group/main relative cursor-pointer first:rounded-t-radius-sm first:pt-[5px] last:rounded-b-radius-sm last:pb-[5px]", onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onBlur: function (e) {
3272
+ // Focus left the whole item, so close a sub-menu opened by keyboard
3273
+ if (!e.currentTarget.contains(e.relatedTarget))
3274
+ setIsKeyboardOpen(false);
3275
+ } },
3276
+ React.createElement("button", __assign({ className: "relative flex w-full !min-w-fit items-center justify-start whitespace-nowrap bg-bia-white px-[15px] py-[5px] text-left text-bia-black disabled:cursor-not-allowed disabled:text-bia-coolgrey-light-50 hover:[&:not(:disabled)]:bg-bia-blue-pastel ".concat(itemClass).concat(keyFocusClass), style: { zIndex: currentZIndex + 15 }, onClick: function (e) { return onClickItem(e, value); }, onKeyDown: handleKeyDown, onFocus: handleFocus, onBlur: handleBlur, disabled: disabled, type: "button" }, props),
2832
3277
  content,
2833
3278
  React.createElement("div", { className: "ml-auto flex items-center" }, children && (React.createElement(TbChevronRight, { className: "ml-[10px] text-bia-coolgrey", size: chevronSize })))),
2834
- children && (React.createElement(DropdownContNoAnchor, { className: "absolute top-0 bg-primary-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] group-first/main:top-[6px] ".concat(translateClass), onClose: onClose, open: isHovered, onClickItem: function (e, itemValue) { return onClickItem(e, itemValue); }, size: size, ref: DropdownContRef, zIndex: currentZIndex + 10 }, children))));
3279
+ children && (React.createElement(DropdownContNoAnchor, { className: "absolute top-0 bg-primary-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] group-first/main:top-[6px] ".concat(translateClass), onClose: function () {
3280
+ setIsKeyboardOpen(false);
3281
+ onClose();
3282
+ }, onKeyDown: handleSubMenuKeyDown, open: isHovered || isKeyboardOpen, onClickItem: function (e, itemValue) { return onClickItem(e, itemValue); }, size: size, ref: DropdownContRef, zIndex: currentZIndex + 10 }, children))));
2835
3283
  }
2836
3284
 
2837
3285
  var matchSearchTerm = function (content, term, variant) {
@@ -2855,8 +3303,11 @@ var filterOptions = function (options, searchTerm) {
2855
3303
  });
2856
3304
  };
2857
3305
 
2858
- var processDropdownChildren$1 = function (nodes, currentSearchTerm, includeAllIfNoSearch, handleDropdownItemClick, searchVariant) {
3306
+ var processDropdownChildren$1 = function (nodes, currentSearchTerm, includeAllIfNoSearch, handleDropdownItemClick, searchVariant, highlight) {
2859
3307
  if (searchVariant === void 0) { searchVariant = 'include'; }
3308
+ if (highlight === void 0) { highlight = undefined; }
3309
+ // Counts the enabled top-level items, so arrow keys can skip disabled ones
3310
+ var enabledCount = 0;
2860
3311
  return React.Children.map(nodes, function (child) {
2861
3312
  if (!React.isValidElement(child) || child.type !== DropdownItem) {
2862
3313
  return child;
@@ -2877,12 +3328,20 @@ var processDropdownChildren$1 = function (nodes, currentSearchTerm, includeAllIf
2877
3328
  var clonedChildren = itemProps.children
2878
3329
  ? processDropdownChildren$1(itemProps.children, currentSearchTerm, includeAllIfNoSearch, handleDropdownItemClick, searchVariant)
2879
3330
  : null;
3331
+ var position = isDisabled ? -1 : enabledCount;
3332
+ if (!isDisabled)
3333
+ enabledCount += 1;
3334
+ var highlightProps = highlight && position >= 0 && position === highlight.index
3335
+ ? {
3336
+ className: cn$1(itemProps.className, OPTION_HIGHLIGHT_CLASS),
3337
+ id: getOptionId(highlight.baseId, position),
3338
+ }
3339
+ : {};
2880
3340
  // Clone and Inject Click Handler
2881
3341
  // DropdownItem renders a <button>, but handleDropdownItemClick's event
2882
3342
  // type is HTMLDivElement to match its other callers (the event's
2883
3343
  // specific target type is never used here, only forwarded).
2884
- return React.cloneElement(child, {
2885
- onClick: function (e) {
3344
+ return React.cloneElement(child, __assign({ onClick: function (e) {
2886
3345
  var divEvent = e;
2887
3346
  if (!isDisabled) {
2888
3347
  if (itemValue === undefined &&
@@ -2898,31 +3357,41 @@ var processDropdownChildren$1 = function (nodes, currentSearchTerm, includeAllIf
2898
3357
  if (itemProps.onClickItem) {
2899
3358
  itemProps.onClickItem(e, itemValue !== undefined ? itemValue : itemContent);
2900
3359
  }
2901
- },
2902
- children: clonedChildren,
2903
- });
3360
+ }, children: clonedChildren }, highlightProps));
2904
3361
  });
2905
3362
  };
2906
- var processRenderedChildren$1 = function (children, searchTerm, searchVariant, handleDropdownItemClick) {
3363
+ var processRenderedChildren$1 = function (children, searchTerm, searchVariant, handleDropdownItemClick, highlight) {
3364
+ if (highlight === void 0) { highlight = undefined; }
2907
3365
  var renderedChildren = null;
2908
3366
  var hasFilteredResults = false;
2909
3367
  if (searchTerm) {
2910
- renderedChildren = processDropdownChildren$1(children, searchTerm, false, handleDropdownItemClick, searchVariant);
3368
+ renderedChildren = processDropdownChildren$1(children, searchTerm, false, handleDropdownItemClick, searchVariant, highlight);
2911
3369
  hasFilteredResults =
2912
3370
  React.Children.toArray(renderedChildren).filter(Boolean).length > 0;
2913
3371
  }
2914
3372
  else {
2915
- renderedChildren = processDropdownChildren$1(children, '', true, handleDropdownItemClick, searchVariant);
3373
+ renderedChildren = processDropdownChildren$1(children, '', true, handleDropdownItemClick, searchVariant, highlight);
2916
3374
  hasFilteredResults =
2917
3375
  React.Children.toArray(renderedChildren).filter(Boolean).length > 0;
2918
3376
  }
2919
- return { renderedChildren: renderedChildren, hasFilteredResults: hasFilteredResults };
3377
+ var enabledCount = React.Children.toArray(renderedChildren).filter(function (child) {
3378
+ return React.isValidElement(child) &&
3379
+ child.type === DropdownItem &&
3380
+ !child.props.disabled;
3381
+ }).length;
3382
+ return { renderedChildren: renderedChildren, hasFilteredResults: hasFilteredResults, enabledCount: enabledCount };
2920
3383
  };
2921
3384
 
2922
3385
  var useLiveSearch$1 = function (_a) {
2923
3386
  var value = _a.value, setValue = _a.setValue, onChangeText = _a.onChangeText, dropContOnClickItem = _a.dropContOnClickItem;
2924
3387
  var _b = React.useState(false), isOpen = _b[0], setIsOpen = _b[1];
2925
3388
  var _c = React.useState(getItemLabel(value)), searchTerm = _c[0], setSearchTerm = _c[1];
3389
+ // Option picked by arrow keys (-1 = none)
3390
+ var _d = React.useState(-1), highlightedIndex = _d[0], setHighlightedIndex = _d[1];
3391
+ React.useEffect(function () {
3392
+ if (!isOpen)
3393
+ setHighlightedIndex(-1);
3394
+ }, [isOpen]);
2926
3395
  React.useEffect(function () {
2927
3396
  if (!isOpen && searchTerm !== getItemLabel(value)) {
2928
3397
  setSearchTerm(getItemLabel(value));
@@ -2934,9 +3403,25 @@ var useLiveSearch$1 = function (_a) {
2934
3403
  var handleInputChange = function (e) {
2935
3404
  var newSearchTerm = e.target.value;
2936
3405
  setSearchTerm(newSearchTerm);
3406
+ setHighlightedIndex(-1);
2937
3407
  setIsOpen(true);
2938
3408
  onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(e);
2939
3409
  };
3410
+ var handleCancel = React.useCallback(function () {
3411
+ setIsOpen(false);
3412
+ setSearchTerm(getItemLabel(value));
3413
+ }, [value]);
3414
+ var handleClear = React.useCallback(function (inputEl) {
3415
+ setSearchTerm('');
3416
+ setValue({ id: null, label: '' });
3417
+ setIsOpen(false);
3418
+ // Tell the app the search text is now empty, as if the user deleted it
3419
+ onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText({
3420
+ target: { value: '' },
3421
+ currentTarget: { value: '' },
3422
+ });
3423
+ inputEl === null || inputEl === void 0 ? void 0 : inputEl.focus();
3424
+ }, [setValue, onChangeText]);
2940
3425
  var handleDropdownItemClick = React.useCallback(function (event, clickedValue) {
2941
3426
  dropContOnClickItem === null || dropContOnClickItem === void 0 ? void 0 : dropContOnClickItem(event, clickedValue);
2942
3427
  var newLabel = getItemLabel(clickedValue);
@@ -2948,22 +3433,46 @@ var useLiveSearch$1 = function (_a) {
2948
3433
  isOpen: isOpen,
2949
3434
  setIsOpen: setIsOpen,
2950
3435
  searchTerm: searchTerm,
3436
+ highlightedIndex: highlightedIndex,
3437
+ setHighlightedIndex: setHighlightedIndex,
2951
3438
  handleInputChange: handleInputChange,
3439
+ handleCancel: handleCancel,
3440
+ handleClear: handleClear,
2952
3441
  handleDropdownItemClick: handleDropdownItemClick,
2953
3442
  };
2954
3443
  };
2955
3444
 
3445
+ var getOptionKey = function (option) {
3446
+ return isObjectWithLabel(option) && option.id != null
3447
+ ? String(option.id)
3448
+ : getItemLabel(option);
3449
+ };
2956
3450
  function LiveSearch(_a) {
2957
- var _b = _a.autoComplete, autoComplete = _b === void 0 ? 'off' : _b, _c = _a.children, children = _c === void 0 ? undefined : _c, _d = _a.descText, descText = _d === void 0 ? undefined : _d, _e = _a.disabled, disabled = _e === void 0 ? false : _e, _f = _a.dropContProps, dropContProps = _f === void 0 ? undefined : _f, _g = _a.id, id = _g === void 0 ? undefined : _g, _h = _a.label, label = _h === void 0 ? undefined : _h, _j = _a.onChangeText, onChangeText = _j === void 0 ? function () { } : _j, _k = _a.onChangeButton, onChangeButton = _k === void 0 ? undefined : _k, _l = _a.onClickDropdown, onClickDropdown = _l === void 0 ? function () { } : _l, _m = _a.options, options = _m === void 0 ? undefined : _m, _o = _a.placeholder, placeholder = _o === void 0 ? undefined : _o, _p = _a.readOnly, readOnly = _p === void 0 ? false : _p, _q = _a.required, required = _q === void 0 ? false : _q, _r = _a.searchVariant, searchVariant = _r === void 0 ? 'include' : _r, setValue = _a.setValue, _s = _a.size, size = _s === void 0 ? 'md' : _s, _t = _a.isValid, isValid = _t === void 0 ? null : _t, value = _a.value;
3451
+ var _b = _a.autoComplete, autoComplete = _b === void 0 ? 'off' : _b, _c = _a.children, children = _c === void 0 ? undefined : _c, _d = _a.descText, descText = _d === void 0 ? undefined : _d, _e = _a.disabled, disabled = _e === void 0 ? false : _e, _f = _a.dropContProps, dropContProps = _f === void 0 ? undefined : _f, _g = _a.id, id = _g === void 0 ? undefined : _g, _h = _a.label, label = _h === void 0 ? undefined : _h, _j = _a.noResultsContent, noResultsContent = _j === void 0 ? undefined : _j, _k = _a.onChangeText, onChangeText = _k === void 0 ? function () { } : _k, _l = _a.onChangeButton, onChangeButton = _l === void 0 ? undefined : _l, _m = _a.onClickDropdown, onClickDropdown = _m === void 0 ? function () { } : _m, _o = _a.options, options = _o === void 0 ? undefined : _o, _p = _a.placeholder, placeholder = _p === void 0 ? undefined : _p, _q = _a.readOnly, readOnly = _q === void 0 ? false : _q, _r = _a.required, required = _r === void 0 ? false : _r, _s = _a.searchVariant, searchVariant = _s === void 0 ? 'include' : _s, setValue = _a.setValue, _t = _a.size, size = _t === void 0 ? 'md' : _t, _u = _a.isValid, isValid = _u === void 0 ? null : _u, value = _a.value;
2958
3452
  var inputRef = React.useRef(null);
2959
- var _u = useLiveSearch$1({
3453
+ var wrapperRef = React.useRef(null);
3454
+ var baseId = React.useId();
3455
+ var _v = useLiveSearch$1({
2960
3456
  value: value,
2961
3457
  setValue: setValue,
2962
3458
  onChangeText: onChangeText,
2963
3459
  dropContOnClickItem: dropContProps === null || dropContProps === void 0 ? void 0 : dropContProps.onClickItem,
2964
- }), isOpen = _u.isOpen, setIsOpen = _u.setIsOpen, searchTerm = _u.searchTerm, handleInputChange = _u.handleInputChange, handleDropdownItemClick = _u.handleDropdownItemClick;
2965
- var _v = sizeConfig$7[size], iconClass = _v.iconClass, iconSize = _v.iconSize, inputClass = _v.inputClass;
2966
- var _w = dropContProps || {}, dropContClassName = _w.className; _w.onClickItem; _w.anchorRef; var restDropContProps = __rest(_w, ["className", "onClickItem", "anchorRef"]);
3460
+ }), isOpen = _v.isOpen, setIsOpen = _v.setIsOpen, searchTerm = _v.searchTerm, highlightedIndex = _v.highlightedIndex, setHighlightedIndex = _v.setHighlightedIndex, handleInputChange = _v.handleInputChange, handleCancel = _v.handleCancel, handleClear = _v.handleClear, handleDropdownItemClick = _v.handleDropdownItemClick;
3461
+ // The plain `options` list has no overlay, so close it when the user clicks away.
3462
+ // The `children` list is closed by its own overlay.
3463
+ React.useEffect(function () {
3464
+ if (!isOpen || children !== undefined)
3465
+ return undefined;
3466
+ var onMouseDown = function (e) {
3467
+ var _a;
3468
+ if (!((_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target)))
3469
+ handleCancel();
3470
+ };
3471
+ document.addEventListener('mousedown', onMouseDown);
3472
+ return function () { return document.removeEventListener('mousedown', onMouseDown); };
3473
+ }, [isOpen, children, handleCancel]);
3474
+ var _w = sizeConfig$7[size], iconClass = _w.iconClass, iconSize = _w.iconSize, inputClass = _w.inputClass;
3475
+ var _x = dropContProps || {}, dropContClassName = _x.className; _x.onClickItem; _x.anchorRef; var restDropContProps = __rest(_x, ["className", "onClickItem", "anchorRef"]);
2967
3476
  var isSearchTermExist = searchTerm && searchTerm !== '';
2968
3477
  var descColor = 'text-primary-cool';
2969
3478
  var isExistValidation = isValid !== null && isValid !== undefined;
@@ -2972,12 +3481,54 @@ function LiveSearch(_a) {
2972
3481
  if (!disabled && isExistValidation && !isValid)
2973
3482
  descColor = 'text-bia-red';
2974
3483
  var filteredOptions = filterOptions(options || [], getItemLabel(value));
2975
- var _x = processRenderedChildren$1(children, searchTerm, searchVariant, handleDropdownItemClick), renderedChildren = _x.renderedChildren, hasFilteredResults = _x.hasFilteredResults;
3484
+ var _y = processRenderedChildren$1(children, searchTerm, searchVariant, handleDropdownItemClick, { index: highlightedIndex, baseId: baseId }), renderedChildren = _y.renderedChildren, hasFilteredResults = _y.hasFilteredResults, enabledCount = _y.enabledCount;
3485
+ // Number of options the arrow keys can move through
3486
+ var optionCount = hasFilteredResults ? enabledCount : 0;
3487
+ if (children === undefined)
3488
+ optionCount = filteredOptions.length;
3489
+ var activeIndex = isOpen && highlightedIndex >= 0 && highlightedIndex < optionCount
3490
+ ? highlightedIndex
3491
+ : -1;
3492
+ var activeId = activeIndex >= 0 ? getOptionId(baseId, activeIndex) : undefined;
3493
+ React.useEffect(function () {
3494
+ if (activeId)
3495
+ scrollOptionIntoView(activeId);
3496
+ }, [activeId]);
3497
+ var handleKeyDown = function (e) {
3498
+ var _a;
3499
+ if (e.key === 'Escape' && isOpen) {
3500
+ e.preventDefault();
3501
+ handleCancel();
3502
+ return;
3503
+ }
3504
+ if (disabled || readOnly)
3505
+ return;
3506
+ if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
3507
+ e.preventDefault();
3508
+ var delta = e.key === 'ArrowDown' ? 1 : -1;
3509
+ if (!isOpen) {
3510
+ setIsOpen(true);
3511
+ setHighlightedIndex(nextIndex(-1, delta, optionCount));
3512
+ }
3513
+ else {
3514
+ setHighlightedIndex(nextIndex(activeIndex, delta, optionCount));
3515
+ }
3516
+ }
3517
+ else if (e.key === 'Enter') {
3518
+ if (activeId) {
3519
+ e.preventDefault();
3520
+ (_a = document.getElementById(activeId)) === null || _a === void 0 ? void 0 : _a.click();
3521
+ }
3522
+ }
3523
+ else if (e.key === 'Tab' && isOpen) {
3524
+ handleCancel();
3525
+ }
3526
+ };
2976
3527
  var disabledClass = disabled ? 'cursor-not-allowed' : '';
2977
3528
  return (React.createElement("div", { className: "bianic-livesearch bianic-fgc-container bianic-text-input-container field-group group/form flex w-full flex-col gap-y-2" },
2978
3529
  label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
2979
- React.createElement("div", { className: "group relative w-full ".concat(disabledClass) },
2980
- React.createElement("input", { className: "bianic-livesearch-input bianic-fgc-target field peer w-full rounded border border-bia-grey-dark-10 bg-primary-white text-bia-black read-only:pointer-events-none read-only:border-bia-grey-light-50 focus-visible:outline-none enabled:hover:rounded-b-none enabled:hover:border-b-bia-blue enabled:focus:rounded-b-none enabled:focus:border-b-bia-blue disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-coolgrey ".concat(inputClass), style: { paddingRight: "".concat(10 + Number(iconSize), "px") }, onClick: function () { return setIsOpen(!isOpen); }, value: searchTerm, required: required, disabled: disabled, id: id, placeholder: placeholder, ref: inputRef, onChange: function (e) {
3530
+ React.createElement("div", { ref: wrapperRef, className: "group relative w-full ".concat(disabledClass) },
3531
+ React.createElement("input", { className: "bianic-livesearch-input bianic-fgc-target field peer w-full rounded border border-bia-grey-dark-10 bg-primary-white text-bia-black read-only:pointer-events-none read-only:border-bia-grey-light-50 focus-visible:outline-none enabled:hover:rounded-b-none enabled:hover:border-b-bia-blue enabled:focus:rounded-b-none enabled:focus:border-b-bia-blue disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-coolgrey ".concat(inputClass), style: { paddingRight: "".concat(10 + Number(iconSize), "px") }, onClick: function () { return setIsOpen(!isOpen); }, value: searchTerm, required: required, disabled: disabled, id: id, placeholder: placeholder, ref: inputRef, onKeyDown: handleKeyDown, "aria-activedescendant": activeId, onChange: function (e) {
2981
3532
  onChangeText(e);
2982
3533
  handleInputChange(e);
2983
3534
  }, type: "text", readOnly: readOnly, autoComplete: autoComplete }),
@@ -2987,21 +3538,21 @@ function LiveSearch(_a) {
2987
3538
  : 20,
2988
3539
  } },
2989
3540
  !isSearchTermExist && (React.createElement(TbZoom, { className: "text-primary-black", style: { fontSize: iconSize } })),
2990
- isSearchTermExist && !onChangeButton && (React.createElement("button", { type: "button", "aria-label": "Clear search", onClick: function () { return setValue({ id: null, label: '' }); }, className: "flex h-full w-full items-center disabled:cursor-not-allowed", disabled: disabled },
3541
+ isSearchTermExist && !onChangeButton && (React.createElement("button", { type: "button", "aria-label": "Clear search", onClick: function () { return handleClear(inputRef.current); }, className: "flex h-full w-full items-center disabled:cursor-not-allowed", disabled: disabled },
2991
3542
  React.createElement(TbX, { className: "text-primary-black", style: { fontSize: iconSize } }))),
2992
3543
  isSearchTermExist && onChangeButton),
2993
3544
  children === undefined && isOpen && (
2994
3545
  // Consumer-provided click-catcher; each rendered option below is its own interactive control
2995
3546
  // eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
2996
- React.createElement("div", { className: "border-grey-100 absolute z-10 max-h-60 w-full overflow-y-auto rounded-b-md border bg-primary-white shadow-lg", onClick: onClickDropdown }, filteredOptions.map(function (option) {
3547
+ React.createElement("div", { className: "border-grey-100 absolute z-10 max-h-60 w-full overflow-y-auto rounded-b-md border bg-primary-white shadow-lg", onClick: onClickDropdown }, filteredOptions.map(function (option, index) {
2997
3548
  var isSelected = isObjectWithLabel(value) &&
2998
3549
  isObjectWithLabel(option) &&
2999
3550
  value.id &&
3000
3551
  option.id === value.id;
3001
- return isObjectWithLabel(option) && option.custom ? (React.createElement(CustomDropdownItem, { size: size, isSelected: isSelected, className: dropContClassName, onClick: function () {
3552
+ return isObjectWithLabel(option) && option.custom ? (React.createElement(CustomDropdownItem, { key: getOptionKey(option), size: size, isSelected: isSelected, isHighlighted: index === activeIndex, id: index === activeIndex ? activeId : undefined, className: dropContClassName, onClick: function () {
3002
3553
  setValue(option);
3003
3554
  setIsOpen(false);
3004
- } }, option.custom)) : (React.createElement(DefaultDropdownItem, { label: getItemLabel(option), size: size, isSelected: isSelected, className: dropContClassName, onClick: function () {
3555
+ } }, option.custom)) : (React.createElement(DefaultDropdownItem, { key: getOptionKey(option), label: getItemLabel(option), size: size, isSelected: isSelected, isHighlighted: index === activeIndex, id: index === activeIndex ? activeId : undefined, className: dropContClassName, onClick: function () {
3005
3556
  setValue(option);
3006
3557
  setIsOpen(false);
3007
3558
  } }));
@@ -3009,7 +3560,10 @@ function LiveSearch(_a) {
3009
3560
  children && (React.createElement(DropdownContainer, __assign({ open: isOpen, onClose: function () { return setIsOpen(false); }, size: size, isTopFlat: true, zIndex: 10, className: "bianic-livesearch-dropdown absolute w-full overflow-hidden bg-white shadow-lg ".concat(dropContClassName), anchorRef: inputRef, matchAnchorWidth: "min" }, restDropContProps), hasFilteredResults
3010
3561
  ? renderedChildren
3011
3562
  : // If no results and searchTerm is present
3012
- searchTerm.length > 0 && (React.createElement(DropdownItem, { content: React.createElement("div", { className: "px-4 py-2 text-gray-500" }, "Tidak ada hasil ditemukan.") }))))),
3563
+ searchTerm.length > 0 &&
3564
+ (noResultsContent !== undefined ? (React.createElement("div", { className: "bianic-livesearch-no-results" }, typeof noResultsContent === 'function'
3565
+ ? noResultsContent(searchTerm)
3566
+ : noResultsContent)) : (React.createElement(DropdownItem, { content: React.createElement("div", { className: "px-4 py-2 text-gray-500" }, "Tidak ada hasil ditemukan.") })))))),
3013
3567
  descText && (React.createElement("span", { className: "bianic-livesearch-desc bianic-text-input-desc text-xs ".concat(descColor) }, descText))));
3014
3568
  }
3015
3569
 
@@ -3039,8 +3593,11 @@ var isMatchValue = function (existingValue, optionValue) {
3039
3593
  }
3040
3594
  return existingValue === null || existingValue === void 0 ? void 0 : existingValue.includes(optionValue);
3041
3595
  };
3042
- var processDropdownChildren = function (nodes, currentSearchTerm, includeAllIfNoSearch, handleDropdownItemClick, existingValues, searchVariant) {
3596
+ var processDropdownChildren = function (nodes, currentSearchTerm, includeAllIfNoSearch, handleDropdownItemClick, existingValues, searchVariant, highlight) {
3043
3597
  if (searchVariant === void 0) { searchVariant = 'include'; }
3598
+ if (highlight === void 0) { highlight = undefined; }
3599
+ // Counts the enabled top-level items, so arrow keys can skip disabled ones
3600
+ var enabledCount = 0;
3044
3601
  return React.Children.map(nodes, function (child) {
3045
3602
  if (!React.isValidElement(child) || child.type !== DropdownItem) {
3046
3603
  return child;
@@ -3068,12 +3625,20 @@ var processDropdownChildren = function (nodes, currentSearchTerm, includeAllIfNo
3068
3625
  var clonedChildren = itemProps.children
3069
3626
  ? processDropdownChildren(itemProps.children, currentSearchTerm, includeAllIfNoSearch, handleDropdownItemClick, existingValues, searchVariant)
3070
3627
  : null;
3628
+ var position = isDisabled ? -1 : enabledCount;
3629
+ if (!isDisabled)
3630
+ enabledCount += 1;
3631
+ var highlightProps = highlight && position >= 0 && position === highlight.index
3632
+ ? {
3633
+ className: cn$1(itemProps.className, OPTION_HIGHLIGHT_CLASS),
3634
+ id: getOptionId(highlight.baseId, position),
3635
+ }
3636
+ : {};
3071
3637
  // Clone and Inject Click Handler
3072
3638
  // DropdownItem renders a <button>, but handleDropdownItemClick's event
3073
3639
  // type is HTMLDivElement to match its other callers (the event's
3074
3640
  // specific target type is never used here, only forwarded).
3075
- return React.cloneElement(child, {
3076
- onClick: function (e) {
3641
+ return React.cloneElement(child, __assign({ onClick: function (e) {
3077
3642
  var divEvent = e;
3078
3643
  if (!isDisabled) {
3079
3644
  if (itemValue === undefined &&
@@ -3089,32 +3654,43 @@ var processDropdownChildren = function (nodes, currentSearchTerm, includeAllIfNo
3089
3654
  if (itemProps.onClickItem) {
3090
3655
  itemProps.onClickItem(e, itemValue !== undefined ? itemValue : itemContent);
3091
3656
  }
3092
- },
3093
- children: clonedChildren,
3094
- });
3657
+ }, children: clonedChildren }, highlightProps));
3095
3658
  });
3096
3659
  };
3097
- var processRenderedChildren = function (children, searchTerm, searchVariant, handleDropdownItemClick, existingValues) {
3660
+ var processRenderedChildren = function (children, searchTerm, searchVariant, handleDropdownItemClick, existingValues, highlight) {
3661
+ if (highlight === void 0) { highlight = undefined; }
3098
3662
  var renderedChildren = null;
3099
3663
  var hasFilteredResults = false;
3100
3664
  if (searchTerm || (existingValues === null || existingValues === void 0 ? void 0 : existingValues.length) > 0) {
3101
- renderedChildren = processDropdownChildren(children, searchTerm, false, handleDropdownItemClick, existingValues, searchVariant);
3665
+ renderedChildren = processDropdownChildren(children, searchTerm, false, handleDropdownItemClick, existingValues, searchVariant, highlight);
3102
3666
  }
3103
3667
  else {
3104
- renderedChildren = processDropdownChildren(children, '', true, handleDropdownItemClick, [], searchVariant);
3668
+ renderedChildren = processDropdownChildren(children, '', true, handleDropdownItemClick, [], searchVariant, highlight);
3105
3669
  }
3106
3670
  hasFilteredResults =
3107
3671
  React.Children.toArray(renderedChildren).filter(Boolean).length > 0;
3108
- return { renderedChildren: renderedChildren, hasFilteredResults: hasFilteredResults };
3672
+ var enabledCount = React.Children.toArray(renderedChildren).filter(function (child) {
3673
+ return React.isValidElement(child) &&
3674
+ child.type === DropdownItem &&
3675
+ !child.props.disabled;
3676
+ }).length;
3677
+ return { renderedChildren: renderedChildren, hasFilteredResults: hasFilteredResults, enabledCount: enabledCount };
3109
3678
  };
3110
3679
 
3111
3680
  var useLiveSearch = function (_a) {
3112
3681
  var value = _a.value, setValue = _a.setValue, onChangeText = _a.onChangeText, dropContOnClickItem = _a.dropContOnClickItem;
3113
3682
  var _b = React.useState(false), isOpen = _b[0], setIsOpen = _b[1];
3114
3683
  var _c = React.useState(''), searchTerm = _c[0], setSearchTerm = _c[1];
3684
+ // Option picked by arrow keys (-1 = none)
3685
+ var _d = React.useState(-1), highlightedIndex = _d[0], setHighlightedIndex = _d[1];
3686
+ React.useEffect(function () {
3687
+ if (!isOpen)
3688
+ setHighlightedIndex(-1);
3689
+ }, [isOpen]);
3115
3690
  var handleInputChange = function (e) {
3116
3691
  var newSearchTerm = e.target.value;
3117
3692
  setSearchTerm(newSearchTerm);
3693
+ setHighlightedIndex(-1);
3118
3694
  setIsOpen(true);
3119
3695
  onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(e);
3120
3696
  };
@@ -3130,6 +3706,8 @@ var useLiveSearch = function (_a) {
3130
3706
  isOpen: isOpen,
3131
3707
  setIsOpen: setIsOpen,
3132
3708
  searchTerm: searchTerm,
3709
+ highlightedIndex: highlightedIndex,
3710
+ setHighlightedIndex: setHighlightedIndex,
3133
3711
  handleInputChange: handleInputChange,
3134
3712
  handleDropdownItemClick: handleDropdownItemClick,
3135
3713
  };
@@ -3147,15 +3725,21 @@ var colorConfig$1 = {
3147
3725
  white: 'bg-primary-white text-primary-black border border-primary-black',
3148
3726
  };
3149
3727
  var sizeConfig$5 = {
3150
- md: 'px-[10px] py-[7px] h-[34px] text-size-base',
3728
+ md: 'px-[7px] py-[3px] h-[24px] text-size-base',
3151
3729
  sm: 'px-[10px] py-[4px] h-[22px] text-size-sm',
3152
3730
  tn: 'px-[8px] py-[2px] h-[18px] text-size-sm',
3153
3731
  };
3154
3732
  var iconOnlySizeConfig = {
3155
- md: 'p-[7px]',
3733
+ md: 'p-[4px]',
3156
3734
  sm: 'p-[4px]',
3157
3735
  tn: 'p-[2px]',
3158
3736
  };
3737
+ // md icon-only with a 1px border: 3px padding + 1px border keeps the box 24x24
3738
+ var iconOnlyBorderSizeConfig = {
3739
+ md: 'p-[3px]',
3740
+ sm: iconOnlySizeConfig.sm,
3741
+ tn: iconOnlySizeConfig.tn,
3742
+ };
3159
3743
  var closeColorConfig = {
3160
3744
  default: 'bg-bia-grey-dark-30 text-primary-white',
3161
3745
  blue: 'bg-bia-white-transparent-50 text-bia-blue',
@@ -3167,15 +3751,46 @@ var closeColorConfig = {
3167
3751
  white: 'bg-bia-grey-dark-30 text-primary-white',
3168
3752
  };
3169
3753
  var closeSizeConfig = {
3170
- md: 'w-[18px] h-[18px] text-[14px]',
3754
+ md: 'w-[14px] h-[14px] text-[11px]',
3171
3755
  sm: 'w-[12px] h-[12px] text-[9.33px]',
3172
3756
  tn: 'w-[12px] h-[12px] text-[9.33px]',
3173
3757
  };
3174
3758
  var rightPaddingConfig = {
3175
- md: 'pr-[8px]',
3759
+ md: 'pr-[5px]',
3176
3760
  sm: 'pr-[5px]',
3177
3761
  tn: 'pr-[3px]',
3178
3762
  };
3763
+ var monospaceSizeConfig = {
3764
+ md: 'px-[8px] py-[3px] h-[24px] text-size-base',
3765
+ sm: sizeConfig$5.sm,
3766
+ tn: sizeConfig$5.tn,
3767
+ };
3768
+ var gapConfig = {
3769
+ md: 'gap-x-0',
3770
+ sm: 'gap-x-[5px]',
3771
+ tn: 'gap-x-[5px]',
3772
+ };
3773
+ var monospaceGapConfig = {
3774
+ md: 'gap-x-[3px]',
3775
+ sm: 'gap-x-[5px]',
3776
+ tn: 'gap-x-[5px]',
3777
+ };
3778
+ var textPaddingConfig = {
3779
+ md: 'px-[5px]',
3780
+ sm: '',
3781
+ tn: '',
3782
+ };
3783
+ // 1em icons become 16px at md; an icon with its own size keeps it
3784
+ var iconWrapperConfig = {
3785
+ md: 'text-[16px]',
3786
+ sm: '',
3787
+ tn: '',
3788
+ };
3789
+ var rightIconWrapperConfig = {
3790
+ md: 'flex items-center text-[16px]',
3791
+ sm: 'block',
3792
+ tn: 'block',
3793
+ };
3179
3794
 
3180
3795
  var colorUnion$1 = [
3181
3796
  'default',
@@ -3188,8 +3803,8 @@ var colorUnion$1 = [
3188
3803
  'white',
3189
3804
  'custom',
3190
3805
  ];
3191
- var sizeUnion$1 = ['md', 'sm', 'tn'];
3192
- var variantUnion = ['label', 'icon', 'closeable', 'monospace'];
3806
+ var sizeUnion$2 = ['md', 'sm', 'tn'];
3807
+ var variantUnion$1 = ['label', 'icon', 'closeable', 'monospace'];
3193
3808
  function TagLabel(_a) {
3194
3809
  var color = _a.color, _b = _a.size, size = _b === void 0 ? 'md' : _b, _c = _a.variant, variant = _c === void 0 ? undefined : _c, _d = _a.closeHandler, closeHandler = _d === void 0 ? undefined : _d, _e = _a.open, open = _e === void 0 ? undefined : _e, text = _a.text, _f = _a.leftIcon, leftIcon = _f === void 0 ? undefined : _f, _g = _a.rightIcon, rightIcon = _g === void 0 ? undefined : _g;
3195
3810
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
@@ -3198,8 +3813,8 @@ function TagLabel(_a) {
3198
3813
  _a.right;
3199
3814
  var _k = _a.bgColor, bgColor = _k === void 0 ? 'grey-light-50' : _k, _l = _a.textColor, textColor = _l === void 0 ? 'black' : _l, _m = _a.outlineColor, outlineColor = _m === void 0 ? undefined : _m, _o = _a.isBlock, isBlock = _o === void 0 ? undefined : _o, _p = _a.maxWidth, maxWidth = _p === void 0 ? undefined : _p, _q = _a.isDark, isDark = _q === void 0 ? undefined : _q; _a.style; var props = __rest(_a, ["color", "size", "variant", "closeHandler", "open", "text", "leftIcon", "rightIcon", "left", "right", "bgColor", "textColor", "outlineColor", "isBlock", "maxWidth", "isDark", "style"]);
3200
3815
  var validatedColor = validUnion(color, colorUnion$1);
3201
- var validatedSize = validUnion(size, sizeUnion$1);
3202
- var validatedVariant = validUnion(variant, variantUnion);
3816
+ var validatedSize = validUnion(size, sizeUnion$2);
3817
+ var validatedVariant = validUnion(variant, variantUnion$1);
3203
3818
  var containerRef = React.useRef(null);
3204
3819
  var _r = React.useState(null), sizeCount = _r[0], setSizeCount = _r[1];
3205
3820
  React.useEffect(function () {
@@ -3221,9 +3836,19 @@ function TagLabel(_a) {
3221
3836
  var defaultIconSize = validatedSize === 'md' ? 'text-xl' : 'text-sm';
3222
3837
  var borderColorRules = outlineColor || bgColor;
3223
3838
  var roundedClass = validatedVariant === 'icon' ? 'rounded-full' : 'rounded-[50px]';
3224
- var sizeClass = validatedVariant === 'icon'
3225
- ? iconOnlySizeConfig[validatedSize]
3226
- : sizeConfig$5[validatedSize];
3839
+ var sizeKey = validatedSize;
3840
+ var isMonospace = validatedVariant === 'monospace';
3841
+ var sizeClass = sizeConfig$5[validatedSize];
3842
+ var hasBorder = validatedColor === 'white' || validatedColor === 'custom';
3843
+ if (validatedVariant === 'icon')
3844
+ sizeClass = cn$1(hasBorder
3845
+ ? iconOnlyBorderSizeConfig[sizeKey]
3846
+ : iconOnlySizeConfig[validatedSize]);
3847
+ else if (isMonospace)
3848
+ sizeClass = monospaceSizeConfig[sizeKey];
3849
+ var gapClass = isMonospace
3850
+ ? monospaceGapConfig[sizeKey]
3851
+ : gapConfig[sizeKey];
3227
3852
  var isCloseableClass = isCloseable && rightPaddingConfig[validatedSize];
3228
3853
  var colorClass = validatedColor === 'custom'
3229
3854
  ? "bg-bia-".concat(bgColor, " text-bia-").concat(textColor, " border border-bia-").concat(borderColorRules)
@@ -3231,8 +3856,8 @@ function TagLabel(_a) {
3231
3856
  var blockclass = isBlock && validatedVariant !== 'icon' ? 'w-full' : "w-fit";
3232
3857
  var maxWidthStyle = !isBlock ? "".concat(maxWidth, "px") : '';
3233
3858
  var alignTextClass = isBlock ? 'text-center' : 'text-left';
3234
- var fontClass = validatedVariant === 'monospace' ? 'font-sans-code' : 'font-segoe pb-[1px]';
3235
- var textClass = "".concat(alignTextClass, " ").concat(fontClass);
3859
+ var fontClass = isMonospace ? 'font-sans-code' : 'font-segoe pb-[1px]';
3860
+ var textClass = cn$1(alignTextClass, fontClass, !isMonospace && textPaddingConfig[sizeKey]);
3236
3861
  var containerClass = "".concat(sizeClass, " ").concat(colorClass, " ").concat(roundedClass, " ").concat(isCloseableClass, " ").concat(blockclass);
3237
3862
  var closeColor = closeColorConfig[validatedColor];
3238
3863
  if (validatedColor === 'custom') {
@@ -3242,29 +3867,29 @@ function TagLabel(_a) {
3242
3867
  }
3243
3868
  var closeClass = "".concat(closeColor, " ").concat(closeSizeConfig[validatedSize]);
3244
3869
  var isOpen = isCloseable ? open : true;
3245
- return (isOpen && (React.createElement("div", __assign({ className: "tag-label flex items-center gap-x-[5px] text-size-base ".concat(containerClass), style: {
3870
+ return (isOpen && (React.createElement("div", __assign({ className: "tag-label flex items-center ".concat(gapClass, " text-size-base ").concat(containerClass), style: {
3246
3871
  maxWidth: maxWidthStyle,
3247
3872
  } }, props),
3248
3873
  leftIcon && (React.createElement("div", { style: {
3249
3874
  width: "".concat(sizeCount, "px"),
3250
3875
  height: "".concat(sizeCount, "px"),
3251
- }, className: "flex items-center justify-center", ref: containerRef }, leftIcon ||
3876
+ }, className: cn$1('flex items-center justify-center', iconWrapperConfig[sizeKey]), ref: containerRef }, leftIcon ||
3252
3877
  (validatedVariant === 'icon' && (React.createElement(TbCheck, { className: defaultIconSize }))))),
3253
3878
  validatedVariant !== 'icon' && text && (React.createElement("span", { className: "w-full truncate ".concat(textClass) }, text)),
3254
- validatedVariant === 'label' && rightIcon && (React.createElement("div", { className: "block" },
3879
+ validatedVariant === 'label' && rightIcon && (React.createElement("div", { className: rightIconWrapperConfig[sizeKey] },
3255
3880
  " ",
3256
3881
  rightIcon,
3257
3882
  " ")),
3258
- isCloseable && (React.createElement("button", { type: "button", onClick: closeHandler, className: "flex aspect-square items-center justify-center rounded-full pt-[1px] ".concat(closeClass) },
3883
+ isCloseable && (React.createElement("button", { type: "button", "aria-label": "Close tag", onClick: closeHandler, className: "flex aspect-square items-center justify-center rounded-full pt-[1px] ".concat(closeClass) },
3259
3884
  React.createElement(TbX, null))))));
3260
3885
  }
3261
3886
 
3262
3887
  function TagLabelInputInner(_a, ref) {
3263
- var _b = _a.children, children = _b === void 0 ? undefined : _b, className = _a.className, _c = _a.description, description = _c === void 0 ? '' : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.dropContProps, dropContProps = _e === void 0 ? {} : _e, _f = _a.id, customId = _f === void 0 ? undefined : _f, _g = _a.isValid, isValid = _g === void 0 ? null : _g, _h = _a.label, label = _h === void 0 ? '' : _h, onBlur = _a.onBlur, onChange = _a.onChange, _j = _a.onChangeText, onChangeText = _j === void 0 ? function () { } : _j, onFocus = _a.onFocus, placeholder = _a.placeholder, _k = _a.readOnly, readOnly = _k === void 0 ? false : _k, _l = _a.required, required = _l === void 0 ? false : _l, _m = _a.size, size = _m === void 0 ? 'md' : _m, value = _a.value, _o = _a.zIndex, zIndex = _o === void 0 ? 10 : _o, restInputProps = __rest(_a, ["children", "className", "description", "disabled", "dropContProps", "id", "isValid", "label", "onBlur", "onChange", "onChangeText", "onFocus", "placeholder", "readOnly", "required", "size", "value", "zIndex"]);
3888
+ var _b = _a.children, children = _b === void 0 ? undefined : _b, className = _a.className, _c = _a.description, description = _c === void 0 ? '' : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.dropContProps, dropContProps = _e === void 0 ? {} : _e, _f = _a.noResultsContent, noResultsContent = _f === void 0 ? undefined : _f, _g = _a.id, customId = _g === void 0 ? undefined : _g, _h = _a.isValid, isValid = _h === void 0 ? null : _h, _j = _a.label, label = _j === void 0 ? '' : _j, onBlur = _a.onBlur, onChange = _a.onChange, _k = _a.onChangeText, onChangeText = _k === void 0 ? function () { } : _k, onFocus = _a.onFocus, placeholder = _a.placeholder, _l = _a.readOnly, readOnly = _l === void 0 ? false : _l, _m = _a.required, required = _m === void 0 ? false : _m, _o = _a.size, size = _o === void 0 ? 'md' : _o, value = _a.value, _p = _a.zIndex, zIndex = _p === void 0 ? 10 : _p, restInputProps = __rest(_a, ["children", "className", "description", "disabled", "dropContProps", "noResultsContent", "id", "isValid", "label", "onBlur", "onChange", "onChangeText", "onFocus", "placeholder", "readOnly", "required", "size", "value", "zIndex"]);
3264
3889
  var generatedId = React.useId();
3265
3890
  var inputId = customId || generatedId;
3266
- var _p = React.useState(false), isFocused = _p[0], setIsFocused = _p[1];
3267
- var _q = React.useState(false), isHovered = _q[0], setIsHovered = _q[1];
3891
+ var _q = React.useState(false), isFocused = _q[0], setIsFocused = _q[1];
3892
+ var _r = React.useState(false), isHovered = _r[0], setIsHovered = _r[1];
3268
3893
  var internalInputRef = React.useRef(null);
3269
3894
  var containerRef = React.useRef(null);
3270
3895
  React.useImperativeHandle(ref, function () { return internalInputRef.current; });
@@ -3288,19 +3913,12 @@ function TagLabelInputInner(_a, ref) {
3288
3913
  var updatedValues = value.filter(function (_, idx) { return idx !== indexToRemove; });
3289
3914
  onChange(updatedValues);
3290
3915
  };
3291
- var _r = useLiveSearch({
3916
+ var _s = useLiveSearch({
3292
3917
  value: value,
3293
3918
  setValue: onChange,
3294
3919
  onChangeText: onChangeText,
3295
3920
  dropContOnClickItem: dropContProps === null || dropContProps === void 0 ? void 0 : dropContProps.onClickItem,
3296
- }), isOpen = _r.isOpen, setIsOpen = _r.setIsOpen, searchTerm = _r.searchTerm, handleInputChange = _r.handleInputChange, handleDropdownItemClick = _r.handleDropdownItemClick;
3297
- var handleKeyDown = function (e) {
3298
- var _a;
3299
- if (e.key === 'Backspace' && searchTerm === '' && value.length > 0) {
3300
- handleRemoveTag(value.length - 1);
3301
- }
3302
- (_a = restInputProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(restInputProps, e);
3303
- };
3921
+ }), isOpen = _s.isOpen, setIsOpen = _s.setIsOpen, searchTerm = _s.searchTerm, highlightedIndex = _s.highlightedIndex, setHighlightedIndex = _s.setHighlightedIndex, handleInputChange = _s.handleInputChange, handleDropdownItemClick = _s.handleDropdownItemClick;
3304
3922
  var handleContainerClick = function () {
3305
3923
  var _a;
3306
3924
  if (!disabled && !readOnly) {
@@ -3326,9 +3944,52 @@ function TagLabelInputInner(_a, ref) {
3326
3944
  if (!disabled && isExistValidation) {
3327
3945
  descColor = isValid ? 'text-bia-green' : 'text-bia-red';
3328
3946
  }
3329
- var _s = sizeConfig$6[size], inputClass = _s.inputClass, paddingClass = _s.paddingClass, resizePosition = _s.resizePosition;
3330
- var _t = dropContProps || {}, dropContClassName = _t.className, restDropContProps = __rest(_t, ["className"]);
3331
- var _u = processRenderedChildren(children, searchTerm, 'include', handleDropdownItemClick, value), renderedChildren = _u.renderedChildren, hasFilteredResults = _u.hasFilteredResults;
3947
+ var _t = sizeConfig$6[size], inputClass = _t.inputClass, paddingClass = _t.paddingClass, resizePosition = _t.resizePosition;
3948
+ var _u = dropContProps || {}, dropContClassName = _u.className, restDropContProps = __rest(_u, ["className"]);
3949
+ var _v = processRenderedChildren(children, searchTerm, 'include', handleDropdownItemClick, value, { index: highlightedIndex, baseId: inputId }), renderedChildren = _v.renderedChildren, hasFilteredResults = _v.hasFilteredResults, enabledCount = _v.enabledCount;
3950
+ // Options the arrow keys can move through (chosen and disabled ones are out)
3951
+ var optionCount = hasFilteredResults ? enabledCount : 0;
3952
+ var activeIndex = isOpen && highlightedIndex >= 0 && highlightedIndex < optionCount
3953
+ ? highlightedIndex
3954
+ : -1;
3955
+ var activeId = activeIndex >= 0 ? getOptionId(inputId, activeIndex) : undefined;
3956
+ React.useEffect(function () {
3957
+ if (activeId)
3958
+ scrollOptionIntoView(activeId);
3959
+ }, [activeId]);
3960
+ var handleKeyDown = function (e) {
3961
+ var _a, _b;
3962
+ if (e.key === 'Backspace' && searchTerm === '' && value.length > 0) {
3963
+ handleRemoveTag(value.length - 1);
3964
+ }
3965
+ if (!disabled && !readOnly) {
3966
+ if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
3967
+ e.preventDefault();
3968
+ var delta = e.key === 'ArrowDown' ? 1 : -1;
3969
+ if (!isOpen) {
3970
+ setIsOpen(true);
3971
+ setHighlightedIndex(nextIndex(-1, delta, optionCount));
3972
+ }
3973
+ else {
3974
+ setHighlightedIndex(nextIndex(activeIndex, delta, optionCount));
3975
+ }
3976
+ }
3977
+ else if (e.key === 'Enter') {
3978
+ if (activeId) {
3979
+ e.preventDefault();
3980
+ (_a = document.getElementById(activeId)) === null || _a === void 0 ? void 0 : _a.click();
3981
+ }
3982
+ }
3983
+ else if (e.key === 'Escape' && isOpen) {
3984
+ e.preventDefault();
3985
+ setIsOpen(false);
3986
+ }
3987
+ else if (e.key === 'Tab' && isOpen) {
3988
+ setIsOpen(false);
3989
+ }
3990
+ }
3991
+ (_b = restInputProps.onKeyDown) === null || _b === void 0 ? void 0 : _b.call(restInputProps, e);
3992
+ };
3332
3993
  var showPlaceholder = !disabled && !readOnly && value.length === 0;
3333
3994
  console.log('showPlaceholder', showPlaceholder);
3334
3995
  return (React.createElement("div", { className: cn$1('relative w-full', className) },
@@ -3342,12 +4003,12 @@ function TagLabelInputInner(_a, ref) {
3342
4003
  handleBlur(e);
3343
4004
  onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
3344
4005
  }, className: cn$1('field bianic-text-area relative flex w-full flex-wrap items-center gap-1.5 rounded border border-bia-grey-dark-10 bg-primary-white align-top transition-all', readOnly && 'pointer-events-none', disabled
3345
- ? 'cursor-not-allowed bg-bia-grey-light-80 text-bia-grey-active'
4006
+ ? 'cursor-not-allowed bg-bia-grey-light-80 text-bia-coolgrey'
3346
4007
  : 'cursor-text', !disabled &&
3347
4008
  !readOnly &&
3348
4009
  'focus-within:rounded-b-none hover:rounded-b-none', isFocused && !disabled && !readOnly && 'rounded-b-none', getBottomBorderColor(), paddingClass) },
3349
4010
  value.map(function (tag, index) { return (React.createElement(TagLabel, __assign({ key: typeof tag === 'object' ? tag.id || tag.label : "".concat(tag, "-").concat(index), variant: "closeable", size: size, text: getTagLabel(tag), open: true, closeHandler: function () { return handleRemoveTag(index); } }, getTagStyles(tag)))); }),
3350
- React.createElement("input", __assign({}, restInputProps, { "aria-autocomplete": "list", "aria-expanded": isOpen, "aria-haspopup": "listbox", "aria-controls": "".concat(inputId, "-listbox"), disabled: disabled, id: inputId, onChange: function (e) {
4011
+ React.createElement("input", __assign({}, restInputProps, { "aria-autocomplete": "list", "aria-expanded": isOpen, "aria-haspopup": "listbox", "aria-controls": "".concat(inputId, "-listbox"), "aria-activedescendant": activeId, disabled: disabled, id: inputId, onChange: function (e) {
3351
4012
  if (disabled || readOnly)
3352
4013
  return;
3353
4014
  onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(e);
@@ -3357,7 +4018,10 @@ function TagLabelInputInner(_a, ref) {
3357
4018
  description && (React.createElement("p", { className: cn$1('mt-1.5 text-xs transition-colors', descColor) }, description)),
3358
4019
  children && (React.createElement(DropdownContainer, __assign({ id: "".concat(inputId, "-listbox"), role: "listbox", anchorRef: containerRef, className: cn$1('bianic-livesearch-dropdown w-full overflow-hidden bg-white shadow-lg', dropContClassName), isTopFlat: true, matchAnchorWidth: "min", onClose: function () { return setIsOpen(false); }, open: isOpen && !disabled && !readOnly, size: size, zIndex: zIndex }, restDropContProps), hasFilteredResults
3359
4020
  ? renderedChildren
3360
- : searchTerm.length > 0 && (React.createElement(DropdownItem, { content: React.createElement("div", { className: "px-4 py-2 text-gray-500" }, "Tidak ada hasil ditemukan.") }))))));
4021
+ : searchTerm.length > 0 &&
4022
+ (noResultsContent !== undefined ? (React.createElement("div", { className: "bianic-taglabelinput-no-results" }, typeof noResultsContent === 'function'
4023
+ ? noResultsContent(searchTerm)
4024
+ : noResultsContent)) : (React.createElement(DropdownItem, { content: React.createElement("div", { className: "px-4 py-2 text-gray-500" }, "Tidak ada hasil ditemukan.") })))))));
3361
4025
  }
3362
4026
  var TagLabelInput = React.forwardRef(TagLabelInputInner);
3363
4027
 
@@ -3392,9 +4056,9 @@ function Toggle(_a) {
3392
4056
  var containerClass = "".concat(checkedClass, " ").concat(containerSize);
3393
4057
  return (React.createElement("div", { className: "flex items-center" },
3394
4058
  React.createElement("div", { className: "relative flex flex-shrink-0 cursor-pointer items-center rounded-full ".concat(containerClass), onClick: onClick },
3395
- React.createElement("input", { id: id, checked: checked, disabled: disabled, className: "checkbox peer absolute h-full w-full cursor-pointer appearance-none rounded-full border-bia-grey bg-primary-white opacity-100 checked:border-bia-blue checked:bg-bia-blue hover:border-bia-blue-hover checked:hover:bg-bia-blue-hover focus:outline-none focus-visible:ring-1 focus-visible:ring-bia-blue focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:border-none disabled:bg-bia-grey-light-80 disabled:checked:bg-bia-blue-light-50 peer-hover:border-bia-blue-hover ".concat(trackBorder), type: "checkbox" }),
4059
+ React.createElement("input", { id: id, checked: checked, disabled: disabled, className: "checkbox peer absolute h-full w-full cursor-pointer appearance-none rounded-full border-bia-grey bg-primary-white opacity-100 checked:border-bia-blue checked:bg-bia-blue hover:border-bia-blue-hover checked:hover:bg-bia-blue-hover focus:outline-none focus-visible:ring-1 focus-visible:ring-bia-blue focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:checked:border-bia-blue-disabled disabled:checked:bg-bia-blue-disabled peer-hover:border-bia-blue-hover ".concat(trackBorder), type: "checkbox" }),
3396
4060
  React.createElement("div", { className: "check-icon group peer z-10 flex-shrink-0 rounded-full bg-bia-grey text-bia-grey peer-checked:bg-primary-white peer-checked:hover:bg-primary-white peer-hover:bg-bia-blue-hover peer-checked:peer-hover:bg-primary-white peer-disabled:cursor-not-allowed peer-disabled:bg-bia-grey-dark-10 peer-disabled:peer-checked:bg-bia-blue-light-90 ".concat(knobSize, " ").concat(knobInset) })),
3397
- React.createElement("label", { htmlFor: id, className: "ml-2 leading-4 text-bia-black ".concat(labelClass), style: { color: disabled ? '#8C8CA6' : '' } }, label)));
4061
+ React.createElement("label", { htmlFor: id, className: "ml-2 leading-4 text-bia-black ".concat(disabled ? '!text-bia-coolgrey' : '', " ").concat(labelClass) }, label)));
3398
4062
  }
3399
4063
 
3400
4064
  var isSelectedConfig = {
@@ -3434,7 +4098,7 @@ function SegmentButtonItem(_a) {
3434
4098
  : "".concat(sizeConfig$3[size], " ").concat(minWidthConfig[size], " ").concat(minHeightConfig[size]);
3435
4099
  var radiusStyle = "".concat(roundedConfig[size]);
3436
4100
  var selectedStyle = "".concat(isSelectedConfig[isSelected]);
3437
- return (React.createElement("button", { type: "button", onClick: onClick, disabled: disabled, className: "group:last:border-l-0 flex items-center justify-center border-[1px] border-l-0 border-bia-grey-dark-10 first:border-l-[1px] focus-visible:z-50 focus-visible:outline focus-visible:outline-[3px] focus-visible:-outline-offset-1 focus-visible:outline-bia-blue-light-50 disabled:cursor-not-allowed disabled:bg-bia-grey-light-80 disabled:text-bia-grey-dark-10 ".concat(selectedStyle, " ").concat(radiusStyle, " ").concat(sizingStyle, " ").concat(className) }, children));
4101
+ return (React.createElement("button", { type: "button", onClick: onClick, disabled: disabled, className: "group:last:border-l-0 flex items-center justify-center border-[1px] border-l-0 border-bia-grey-dark-10 first:border-l-[1px] focus-visible:z-50 focus-visible:outline focus-visible:outline-[3px] focus-visible:-outline-offset-1 focus-visible:outline-bia-blue-light-50 disabled:cursor-not-allowed disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-grey-dark-10".concat(selectedStyle, " ").concat(radiusStyle, " ").concat(sizingStyle, " ").concat(className) }, children));
3438
4102
  }
3439
4103
 
3440
4104
  function SegmentButtonGroup(_a) {
@@ -3442,10 +4106,10 @@ function SegmentButtonGroup(_a) {
3442
4106
  return React.createElement("div", { className: "flex" }, children);
3443
4107
  }
3444
4108
 
3445
- var sizeUnion = ['md', 'sm'];
4109
+ var sizeUnion$1 = ['md', 'sm'];
3446
4110
  function FormGroup(_a) {
3447
4111
  var _b = _a.children, children = _b === void 0 ? undefined : _b, _c = _a.size, size = _c === void 0 ? undefined : _c;
3448
- var validSize = validUnion(size, sizeUnion);
4112
+ var validSize = validUnion(size, sizeUnion$1);
3449
4113
  return (React.createElement("div", { className: "bianic-form-group flex items-end" }, React.Children.map(children, function (child) {
3450
4114
  var _a;
3451
4115
  if (!React.isValidElement(child))
@@ -3562,8 +4226,151 @@ var areMonthsAdjacent = function (leftMonth, leftYear, rightMonth, rightYear) {
3562
4226
  return rightMonth === leftMonth + 1 && rightYear === leftYear;
3563
4227
  };
3564
4228
 
4229
+ // Default focus ring (R38). Written as one literal so Tailwind scans it.
4230
+ var FOCUS_RING = 'focus-visible:outline focus-visible:outline-[3px] focus-visible:outline-offset-0 focus-visible:outline-bia-blue-light-50';
4231
+ // Marks a grid cell (day, month or year) inside the popup.
4232
+ var CELL_ATTRIBUTE = 'data-calendar-cell';
4233
+ var ACTIVE_CELL_SELECTOR = "[".concat(CELL_ATTRIBUTE, "][tabindex=\"0\"]");
4234
+ var FOCUSABLE_SELECTOR = 'button, [tabindex]';
4235
+ function getTabbableElements(root) {
4236
+ return Array.from(root.querySelectorAll(FOCUSABLE_SELECTOR)).filter(function (element) {
4237
+ if (element.tabIndex < 0)
4238
+ return false;
4239
+ if (element.disabled)
4240
+ return false;
4241
+ return element.getClientRects().length > 0;
4242
+ });
4243
+ }
4244
+ function focusActiveCell(root) {
4245
+ var cell = root === null || root === void 0 ? void 0 : root.querySelector(ACTIVE_CELL_SELECTOR);
4246
+ cell === null || cell === void 0 ? void 0 : cell.focus();
4247
+ }
4248
+ // Escape closes the popup. Tab and Shift+Tab wrap inside the popup.
4249
+ function handleDialogKeyDown(event, onClose) {
4250
+ if (event.key === 'Escape') {
4251
+ event.preventDefault();
4252
+ event.stopPropagation();
4253
+ onClose === null || onClose === void 0 ? void 0 : onClose();
4254
+ return;
4255
+ }
4256
+ if (event.key !== 'Tab')
4257
+ return;
4258
+ var tabbable = getTabbableElements(event.currentTarget);
4259
+ if (tabbable.length === 0)
4260
+ return;
4261
+ var first = tabbable[0];
4262
+ var last = tabbable[tabbable.length - 1];
4263
+ var activeElement = document.activeElement;
4264
+ if (event.shiftKey && (activeElement === first || !activeElement)) {
4265
+ event.preventDefault();
4266
+ last.focus();
4267
+ }
4268
+ else if (!event.shiftKey && activeElement === last) {
4269
+ event.preventDefault();
4270
+ first.focus();
4271
+ }
4272
+ }
4273
+ function isArrowKey(key) {
4274
+ return (key === 'ArrowLeft' ||
4275
+ key === 'ArrowRight' ||
4276
+ key === 'ArrowUp' ||
4277
+ key === 'ArrowDown');
4278
+ }
4279
+ function getArrowStep(key, columns) {
4280
+ switch (key) {
4281
+ case 'ArrowLeft':
4282
+ return -1;
4283
+ case 'ArrowRight':
4284
+ return 1;
4285
+ case 'ArrowUp':
4286
+ return -columns;
4287
+ default:
4288
+ return columns;
4289
+ }
4290
+ }
4291
+
3565
4292
  function DateDisplay(_a) {
3566
- var displayDays = _a.displayDays, viewMonthValue = _a.viewMonthValue, selectedDate = _a.selectedDate, onDateSelect = _a.onDateSelect, minDateValue = _a.minDateValue, maxDateValue = _a.maxDateValue;
4293
+ var displayDays = _a.displayDays, viewMonthValue = _a.viewMonthValue, selectedDate = _a.selectedDate, onDateSelect = _a.onDateSelect, minDateValue = _a.minDateValue, maxDateValue = _a.maxDateValue, _b = _a.viewYearValue, viewYearValue = _b === void 0 ? undefined : _b, _c = _a.onNavigateMonth, onNavigateMonth = _c === void 0 ? undefined : _c, _d = _a.isOpen, isOpen = _d === void 0 ? true : _d;
4294
+ var gridRef = React.useRef(null);
4295
+ // Day picked with the arrow keys, and the month view it was picked in.
4296
+ var _e = React.useState(null), activeState = _e[0], setActiveState = _e[1];
4297
+ // Day to focus once the panel has moved to another month.
4298
+ var pendingFocusRef = React.useRef(null);
4299
+ var viewKey = "".concat(viewYearValue, "-").concat(viewMonthValue);
4300
+ React.useEffect(function () {
4301
+ if (!isOpen)
4302
+ setActiveState(null);
4303
+ }, [isOpen]);
4304
+ var firstDayTime = displayDays[0] ? displayDays[0].getTime() : 0;
4305
+ React.useEffect(function () {
4306
+ var _a, _b;
4307
+ var key = pendingFocusRef.current;
4308
+ if (!key)
4309
+ return;
4310
+ pendingFocusRef.current = null;
4311
+ (_b = (_a = gridRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("[data-date=\"".concat(key, "\"]"))) === null || _b === void 0 ? void 0 : _b.focus();
4312
+ }, [firstDayTime]);
4313
+ var isDisabledDay = function (date) {
4314
+ return !!((minDateValue && date < minDateValue) ||
4315
+ (maxDateValue && date > maxDateValue));
4316
+ };
4317
+ var isShown = function (key) {
4318
+ return displayDays.some(function (day) { return dateToInputString(day) === key; });
4319
+ };
4320
+ // The day in the tab order: the one reached with the arrows, else the
4321
+ // selected day, else today, else the first enabled day of the month.
4322
+ var activeKey = null;
4323
+ if (activeState) {
4324
+ var activeDay = displayDays.find(function (day) { return dateToInputString(day) === activeState.key; });
4325
+ if (activeDay &&
4326
+ !isDisabledDay(activeDay) &&
4327
+ (activeState.view === viewKey || activeDay.getMonth() === viewMonthValue)) {
4328
+ activeKey = activeState.key;
4329
+ }
4330
+ }
4331
+ if (!activeKey) {
4332
+ var rangeDates = Array.isArray(selectedDate)
4333
+ ? selectedDate.filter(Boolean).sort()
4334
+ : [];
4335
+ var firstRangeDay = rangeDates[0];
4336
+ var selectedValue = Array.isArray(selectedDate)
4337
+ ? firstRangeDay
4338
+ : selectedDate;
4339
+ var candidates = [
4340
+ selectedValue ? new Date(selectedValue) : null,
4341
+ new Date(TODAY_VALUE),
4342
+ ];
4343
+ var found = candidates.find(function (candidate) {
4344
+ return candidate &&
4345
+ candidate.getMonth() === viewMonthValue &&
4346
+ isShown(dateToInputString(candidate)) &&
4347
+ !isDisabledDay(candidate);
4348
+ });
4349
+ var fallback = found ||
4350
+ displayDays.find(function (day) { return day.getMonth() === viewMonthValue && !isDisabledDay(day); });
4351
+ activeKey = fallback ? dateToInputString(fallback) : null;
4352
+ }
4353
+ var handleKeyDown = function (event, date) {
4354
+ var _a, _b;
4355
+ if (!isArrowKey(event.key))
4356
+ return;
4357
+ event.preventDefault();
4358
+ var target = new Date(date);
4359
+ target.setDate(target.getDate() + getArrowStep(event.key, 7));
4360
+ // A day outside minDate or maxDate does not take focus.
4361
+ if (isDisabledDay(target))
4362
+ return;
4363
+ var targetKey = dateToInputString(target);
4364
+ setActiveState({ key: targetKey, view: viewKey });
4365
+ if (isShown(targetKey)) {
4366
+ (_b = (_a = gridRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("[data-date=\"".concat(targetKey, "\"]"))) === null || _b === void 0 ? void 0 : _b.focus();
4367
+ }
4368
+ else if (onNavigateMonth) {
4369
+ pendingFocusRef.current = targetKey;
4370
+ var isBefore = getDayKey(target) < getDayKey(displayDays[0]);
4371
+ onNavigateMonth(isBefore ? 'prev' : 'next');
4372
+ }
4373
+ };
3567
4374
  var isRangeMode = Array.isArray(selectedDate) && selectedDate.length === 2;
3568
4375
  var firstRangeDate = isRangeMode && (selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate[0]) ? new Date(selectedDate[0]) : null;
3569
4376
  var secondRangeDate = isRangeMode && (selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate[1]) ? new Date(selectedDate[1]) : null;
@@ -3575,9 +4382,9 @@ function DateDisplay(_a) {
3575
4382
  return (React.createElement("div", null,
3576
4383
  React.createElement("div", { className: "bianic-datepicker-calendar-days-grid-header grid grid-cols-7 gap-[3px] pb-1.5" }, DAYS_MAP.map(function (day) { return (React.createElement("div", { key: day, className: "bianic-datepicker-calendar-day flex h-[18px] w-[31px] items-center justify-center" },
3577
4384
  React.createElement(Text, { variant: "small-text", extended: "text-bia-coolgrey" }, day.slice(0, 3)))); })),
3578
- React.createElement("div", { className: "bianic-datepicker-calendar-days-grid-body grid grid-cols-7 gap-y-1.5" }, displayDays.map(function (date) {
3579
- var isOutOfRange = !!((minDateValue && date < minDateValue) ||
3580
- (maxDateValue && date > maxDateValue));
4385
+ React.createElement("div", { ref: gridRef, className: "bianic-datepicker-calendar-days-grid-body grid grid-cols-7 gap-y-1.5" }, displayDays.map(function (date) {
4386
+ var isOutOfRange = isDisabledDay(date);
4387
+ var dateKey = dateToInputString(date);
3581
4388
  var isOutOfMonth = date.getMonth() !== viewMonthValue;
3582
4389
  var isStartRange = isRangeMode && checkDateEquals(date, startRangeDate);
3583
4390
  var isEndRange = isRangeMode && checkDateEquals(date, endRangeDate);
@@ -3629,7 +4436,10 @@ function DateDisplay(_a) {
3629
4436
  else if (isOutOfMonth) {
3630
4437
  textStyle = 'text-bia-coolgrey';
3631
4438
  }
3632
- return (React.createElement("button", { type: "button", key: date.toString(), className: "bianic-datepicker-calendar-day flex h-[31px] items-center justify-center ".concat(customClassname, " ").concat(dayStateClass), disabled: isOutOfRange, onClick: function () { return onDateSelect(date); } },
4439
+ return (React.createElement("button", { type: "button", key: date.toString(), className: "bianic-datepicker-calendar-day flex h-[31px] items-center justify-center ".concat(customClassname, " ").concat(dayStateClass, " ").concat(FOCUS_RING), disabled: isOutOfRange, "data-date": dateKey, "data-calendar-cell": "", tabIndex: dateKey === activeKey ? 0 : -1, onKeyDown: function (event) { return handleKeyDown(event, date); }, onClick: function () {
4440
+ setActiveState({ key: dateKey, view: viewKey });
4441
+ onDateSelect(date);
4442
+ } },
3633
4443
  React.createElement(Text, { variant: "small-text", extended: textStyle }, date.getDate())));
3634
4444
  }))));
3635
4445
  }
@@ -3652,8 +4462,10 @@ function MonthDisplay(_a) {
3652
4462
  return dateYear === viewYearValue && dateMonth === monthIndex;
3653
4463
  });
3654
4464
  };
3655
- return (React.createElement("div", { className: "bianic-datepicker-calendar-month-grid grid grid-cols-3 gap-y-1.5" }, MONTH_MAP.map(function (month, index) {
3656
- var isOutOfRange = !!((minDateValue &&
4465
+ var gridRef = React.useRef(null);
4466
+ var _b = React.useState(null), activeIndexState = _b[0], setActiveIndexState = _b[1];
4467
+ var isMonthOutOfRange = function (index) {
4468
+ return !!((minDateValue &&
3657
4469
  minDateValue.getFullYear() <= viewYearValue &&
3658
4470
  index <
3659
4471
  (minDateValue.getFullYear() === viewYearValue
@@ -3665,6 +4477,42 @@ function MonthDisplay(_a) {
3665
4477
  (maxDateValue.getFullYear() === viewYearValue
3666
4478
  ? maxDateValue.getMonth()
3667
4479
  : 11)));
4480
+ };
4481
+ // The month in the tab order: the one reached with the arrows, else the
4482
+ // selected month, else the current month, else the first enabled month.
4483
+ var todayDate = new Date(TODAY_VALUE);
4484
+ var selectedIndex = MONTH_MAP.findIndex(function (_, index) {
4485
+ return isMonthAlreadySelected(index);
4486
+ });
4487
+ var activeIndex = -1;
4488
+ var candidates = [
4489
+ activeIndexState,
4490
+ selectedIndex,
4491
+ todayDate.getFullYear() === viewYearValue ? todayDate.getMonth() : -1,
4492
+ ];
4493
+ var preferred = candidates.find(function (candidate) {
4494
+ return candidate !== null && candidate >= 0 && !isMonthOutOfRange(candidate);
4495
+ });
4496
+ if (preferred !== undefined && preferred !== null) {
4497
+ activeIndex = preferred;
4498
+ }
4499
+ else {
4500
+ activeIndex = MONTH_MAP.findIndex(function (_, index) { return !isMonthOutOfRange(index); });
4501
+ }
4502
+ var handleKeyDown = function (event, index) {
4503
+ var _a, _b;
4504
+ if (!isArrowKey(event.key))
4505
+ return;
4506
+ event.preventDefault();
4507
+ var target = index + getArrowStep(event.key, 3);
4508
+ // Stop at the edges of the grid and at months that are not allowed.
4509
+ if (target < 0 || target > 11 || isMonthOutOfRange(target))
4510
+ return;
4511
+ setActiveIndexState(target);
4512
+ (_b = (_a = gridRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("[data-index=\"".concat(target, "\"]"))) === null || _b === void 0 ? void 0 : _b.focus();
4513
+ };
4514
+ return (React.createElement("div", { ref: gridRef, className: "bianic-datepicker-calendar-month-grid grid grid-cols-3 gap-y-1.5" }, MONTH_MAP.map(function (month, index) {
4515
+ var isOutOfRange = isMonthOutOfRange(index);
3668
4516
  var isAlreadySelected = isMonthAlreadySelected(index);
3669
4517
  var isSelected = selectedDate &&
3670
4518
  (Array.isArray(selectedDate) ? selectedDate[0] : selectedDate) &&
@@ -3686,19 +4534,49 @@ function MonthDisplay(_a) {
3686
4534
  }
3687
4535
  return (React.createElement("button", { type: "button", key: month, onClick: function (e) {
3688
4536
  e.stopPropagation();
4537
+ setActiveIndexState(index);
3689
4538
  onMonthSelect(index);
3690
- }, disabled: isOutOfRange, className: "bianic-datepicker-calendar-month mx-[15px] flex h-[31px] items-center justify-center rounded-full ".concat(isSelected || isAlreadySelected
4539
+ }, onKeyDown: function (e) { return handleKeyDown(e, index); }, disabled: isOutOfRange, "data-index": index, "data-calendar-cell": "", tabIndex: index === activeIndex ? 0 : -1, className: "bianic-datepicker-calendar-month mx-[15px] flex h-[31px] items-center justify-center rounded-full ".concat(isSelected || isAlreadySelected
3691
4540
  ? 'border border-bia-blue-dark-10 bg-bia-blue-dark-10'
3692
- : 'enabled:hover:bg-bia-blue-pastel') },
4541
+ : 'enabled:hover:bg-bia-blue-pastel', " ").concat(FOCUS_RING) },
3693
4542
  React.createElement(Text, { variant: "small-text", extended: textStyle }, month.slice(0, 3))));
3694
4543
  })));
3695
4544
  }
3696
4545
 
3697
4546
  function YearDisplay(_a) {
3698
4547
  var yearDisplayRange = _a.yearDisplayRange, viewYearValue = _a.viewYearValue, minDateValue = _a.minDateValue, maxDateValue = _a.maxDateValue, onYearSelect = _a.onYearSelect;
3699
- return (React.createElement("div", { className: "bianic-datepicker-calendar-year-grid grid grid-cols-4 gap-y-1.5" }, yearDisplayRange.map(function (year, index) {
3700
- var isOutOfRange = !!((minDateValue && year < minDateValue.getFullYear()) ||
4548
+ var gridRef = React.useRef(null);
4549
+ var _b = React.useState(null), activeYearState = _b[0], setActiveYearState = _b[1];
4550
+ var isYearOutOfRange = function (year) {
4551
+ return !!((minDateValue && year < minDateValue.getFullYear()) ||
3701
4552
  (maxDateValue && year > maxDateValue.getFullYear()));
4553
+ };
4554
+ // The year in the tab order: the one reached with the arrows, else the
4555
+ // selected year, else the current year, else the first enabled year.
4556
+ var currentYear = new Date(TODAY_VALUE).getFullYear();
4557
+ var preferredYear = [activeYearState, viewYearValue, currentYear].find(function (candidate) {
4558
+ return candidate !== null &&
4559
+ yearDisplayRange.includes(candidate) &&
4560
+ !isYearOutOfRange(candidate);
4561
+ });
4562
+ var activeYear = preferredYear !== null && preferredYear !== void 0 ? preferredYear : yearDisplayRange.find(function (year) { return !isYearOutOfRange(year); });
4563
+ var handleKeyDown = function (event, index) {
4564
+ var _a, _b;
4565
+ if (!isArrowKey(event.key))
4566
+ return;
4567
+ event.preventDefault();
4568
+ var targetIndex = index + getArrowStep(event.key, 4);
4569
+ // Stop at the edges of the grid and at years that are not allowed.
4570
+ if (targetIndex < 0 || targetIndex >= yearDisplayRange.length)
4571
+ return;
4572
+ var targetYear = yearDisplayRange[targetIndex];
4573
+ if (isYearOutOfRange(targetYear))
4574
+ return;
4575
+ setActiveYearState(targetYear);
4576
+ (_b = (_a = gridRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("[data-year=\"".concat(targetYear, "\"]"))) === null || _b === void 0 ? void 0 : _b.focus();
4577
+ };
4578
+ return (React.createElement("div", { ref: gridRef, className: "bianic-datepicker-calendar-year-grid grid grid-cols-4 gap-y-1.5" }, yearDisplayRange.map(function (year, index) {
4579
+ var isOutOfRange = isYearOutOfRange(year);
3702
4580
  var isSelected = year === viewYearValue;
3703
4581
  var isEdgeYear = index === 0 || index === 11;
3704
4582
  var textStyle = 'text-bia-black';
@@ -3713,10 +4591,11 @@ function YearDisplay(_a) {
3713
4591
  }
3714
4592
  return (React.createElement("button", { type: "button", key: year, onClick: function (e) {
3715
4593
  e.stopPropagation();
4594
+ setActiveYearState(year);
3716
4595
  onYearSelect(year);
3717
- }, disabled: isOutOfRange, className: "bianic-datepicker-calendar-month mx-[6px] flex h-[31px] items-center justify-center rounded-full ".concat(isSelected
4596
+ }, onKeyDown: function (e) { return handleKeyDown(e, index); }, disabled: isOutOfRange, "data-year": year, "data-calendar-cell": "", tabIndex: year === activeYear ? 0 : -1, className: "bianic-datepicker-calendar-month mx-[6px] flex h-[31px] items-center justify-center rounded-full ".concat(isSelected
3718
4597
  ? 'border border-bia-blue-dark-10 bg-bia-blue-dark-10'
3719
- : 'enabled:hover:bg-bia-blue-pastel', " ").concat(isEdgeYear ? 'text-bia-coolgrey' : '') },
4598
+ : 'enabled:hover:bg-bia-blue-pastel', " ").concat(isEdgeYear ? 'text-bia-coolgrey' : '', " ").concat(FOCUS_RING) },
3720
4599
  React.createElement(Text, { variant: "small-text", extended: textStyle }, year)));
3721
4600
  })));
3722
4601
  }
@@ -3737,26 +4616,36 @@ function PickerHeader(_a) {
3737
4616
  else if (pickerMode === 'month') {
3738
4617
  handleNext = handleNextYear;
3739
4618
  }
4619
+ var prevLabels = {
4620
+ date: 'Previous month',
4621
+ month: 'Previous year',
4622
+ year: 'Previous years',
4623
+ };
4624
+ var nextLabels = {
4625
+ date: 'Next month',
4626
+ month: 'Next year',
4627
+ year: 'Next years',
4628
+ };
3740
4629
  return (React.createElement("div", { className: "bianic-datepicker-calendar-controller flex w-full items-center justify-between" },
3741
- React.createElement("button", { type: "button", className: "bianic-datepicker-calendar-prev-button text-bia-coolgrey disabled:text-bia-coolgrey-light-50", disabled: isPrevDisabled ? isPrevDisabled() : false, onClick: handlePrev },
3742
- React.createElement(TbChevronLeft, { size: 18 })),
4630
+ React.createElement("button", { type: "button", "aria-label": prevLabels[pickerMode], className: "bianic-datepicker-calendar-prev-button rounded text-bia-coolgrey disabled:text-bia-coolgrey-light-50 ".concat(FOCUS_RING), disabled: isPrevDisabled ? isPrevDisabled() : false, onClick: handlePrev },
4631
+ React.createElement(TbChevronLeft, { size: 18, "aria-hidden": "true" })),
3743
4632
  React.createElement("div", { className: "bianic-datepicker-calendar-current-month flex items-center justify-center gap-1" },
3744
- React.createElement("button", { type: "button", className: pickerMode === 'date' ? '' : 'hidden', onClick: function (e) {
4633
+ React.createElement("button", { type: "button", className: "".concat(pickerMode === 'date' ? '' : 'hidden', " rounded ").concat(FOCUS_RING), onClick: function (e) {
3745
4634
  e.stopPropagation();
3746
4635
  handlePickerMode('month');
3747
4636
  } },
3748
4637
  React.createElement(Text, { variant: "normal-text-semibold" },
3749
4638
  MONTH_MAP[viewMonthValue],
3750
4639
  ' ')),
3751
- React.createElement("button", { type: "button", className: pickerMode === 'date' || pickerMode === 'month' ? '' : 'hidden', onClick: function (e) {
4640
+ React.createElement("button", { type: "button", className: "".concat(pickerMode === 'date' || pickerMode === 'month' ? '' : 'hidden', " rounded ").concat(FOCUS_RING), onClick: function (e) {
3752
4641
  e.stopPropagation();
3753
4642
  handlePickerMode('year');
3754
4643
  } },
3755
4644
  React.createElement(Text, { variant: "normal-text" }, viewYearValue)),
3756
- React.createElement("button", { type: "button", className: pickerMode === 'year' ? '' : 'hidden' },
4645
+ React.createElement("button", { type: "button", className: "".concat(pickerMode === 'year' ? '' : 'hidden', " rounded ").concat(FOCUS_RING) },
3757
4646
  React.createElement(Text, { variant: "normal-text" }, "".concat(yearDisplayRange[1], " - ").concat(yearDisplayRange[10])))),
3758
- React.createElement("button", { type: "button", className: "bianic-datepicker-calendar-next-button text-bia-coolgrey disabled:text-bia-coolgrey-light-50", disabled: isNextDisabled ? isNextDisabled() : false, onClick: handleNext },
3759
- React.createElement(TbChevronRight, { size: 18 }))));
4647
+ React.createElement("button", { type: "button", "aria-label": nextLabels[pickerMode], className: "bianic-datepicker-calendar-next-button rounded text-bia-coolgrey disabled:text-bia-coolgrey-light-50 ".concat(FOCUS_RING), disabled: isNextDisabled ? isNextDisabled() : false, onClick: handleNext },
4648
+ React.createElement(TbChevronRight, { size: 18, "aria-hidden": "true" }))));
3760
4649
  }
3761
4650
 
3762
4651
  var useCalendarLogic = function (selectedDate, minDate, maxDate) {
@@ -3900,12 +4789,12 @@ var useCalendarLogic = function (selectedDate, minDate, maxDate) {
3900
4789
  };
3901
4790
 
3902
4791
  function PickerContent(_a) {
3903
- var selectedDate = _a.selectedDate, onDateSelect = _a.onDateSelect, _b = _a.initialViewMonth, initialViewMonth = _b === void 0 ? undefined : _b, _c = _a.initialViewYear, initialViewYear = _c === void 0 ? undefined : _c, minDate = _a.minDate, maxDate = _a.maxDate, _d = _a.onPrevMonth, onPrevMonth = _d === void 0 ? undefined : _d, _e = _a.onNextMonth, onNextMonth = _e === void 0 ? undefined : _e, _f = _a.onMonthSelect, onMonthSelect = _f === void 0 ? undefined : _f, _g = _a.onYearSelect, onYearSelect = _g === void 0 ? undefined : _g;
3904
- var _h = useCalendarLogic(
4792
+ var selectedDate = _a.selectedDate, onDateSelect = _a.onDateSelect, _b = _a.initialViewMonth, initialViewMonth = _b === void 0 ? undefined : _b, _c = _a.initialViewYear, initialViewYear = _c === void 0 ? undefined : _c, minDate = _a.minDate, maxDate = _a.maxDate, _d = _a.onPrevMonth, onPrevMonth = _d === void 0 ? undefined : _d, _e = _a.onNextMonth, onNextMonth = _e === void 0 ? undefined : _e, _f = _a.onMonthSelect, onMonthSelect = _f === void 0 ? undefined : _f, _g = _a.onYearSelect, onYearSelect = _g === void 0 ? undefined : _g, _h = _a.isOpen, isOpen = _h === void 0 ? true : _h;
4793
+ var _j = useCalendarLogic(
3905
4794
  // use first selectedDate if array
3906
4795
  Array.isArray(selectedDate)
3907
4796
  ? selectedDate[0]
3908
- : selectedDate, minDate, maxDate), pickerMode = _h.pickerMode, viewMonthValue = _h.viewMonthValue, viewYearValue = _h.viewYearValue, yearDisplayRange = _h.yearDisplayRange, isPrevDisabled = _h.isPrevDisabled, isNextDisabled = _h.isNextDisabled, internalHandlePrevMonth = _h.handlePrevMonth, handlePrevYear = _h.handlePrevYear, handlePrevDecade = _h.handlePrevDecade, internalHandleNextMonth = _h.handleNextMonth, handleNextYear = _h.handleNextYear, handleNextDecade = _h.handleNextDecade, handlePickerMode = _h.handlePickerMode, getDisplayDays = _h.getDisplayDays, setViewMonthValue = _h.setViewMonthValue, setViewYearValue = _h.setViewYearValue, maxDateValue = _h.maxDateValue, minDateValue = _h.minDateValue;
4797
+ : selectedDate, minDate, maxDate), pickerMode = _j.pickerMode, viewMonthValue = _j.viewMonthValue, viewYearValue = _j.viewYearValue, yearDisplayRange = _j.yearDisplayRange, isPrevDisabled = _j.isPrevDisabled, isNextDisabled = _j.isNextDisabled, internalHandlePrevMonth = _j.handlePrevMonth, handlePrevYear = _j.handlePrevYear, handlePrevDecade = _j.handlePrevDecade, internalHandleNextMonth = _j.handleNextMonth, handleNextYear = _j.handleNextYear, handleNextDecade = _j.handleNextDecade, handlePickerMode = _j.handlePickerMode, getDisplayDays = _j.getDisplayDays, setViewMonthValue = _j.setViewMonthValue, setViewYearValue = _j.setViewYearValue, maxDateValue = _j.maxDateValue, minDateValue = _j.minDateValue;
3909
4798
  React.useEffect(function () {
3910
4799
  if (typeof initialViewMonth === 'number') {
3911
4800
  setViewMonthValue(initialViewMonth);
@@ -3918,32 +4807,58 @@ function PickerContent(_a) {
3918
4807
  var handlePrevMonth = onPrevMonth || internalHandlePrevMonth;
3919
4808
  var handleNextMonth = onNextMonth || internalHandleNextMonth;
3920
4809
  var days = getDisplayDays(viewMonthValue, viewYearValue);
3921
- return (React.createElement("div", { className: "picker-body flex w-[250px] flex-col gap-[15px]" },
3922
- React.createElement(PickerHeader, { pickerMode: pickerMode, viewMonthValue: viewMonthValue, viewYearValue: viewYearValue, yearDisplayRange: yearDisplayRange, isPrevDisabled: isPrevDisabled, isNextDisabled: isNextDisabled, handlePrevMonth: handlePrevMonth, handlePrevYear: handlePrevYear, handlePrevDecade: handlePrevDecade, handleNextMonth: handleNextMonth, handleNextYear: handleNextYear, handleNextDecade: handleNextDecade, handlePickerMode: handlePickerMode }),
3923
- pickerMode === 'date' && (React.createElement(DateDisplay, { displayDays: days, maxDateValue: maxDateValue, minDateValue: minDateValue, onDateSelect: onDateSelect, selectedDate: selectedDate, viewMonthValue: viewMonthValue })),
4810
+ var rootRef = React.useRef(null);
4811
+ // Set when the view changes, so focus follows to the new grid.
4812
+ var focusGridRef = React.useRef(false);
4813
+ var changePickerMode = function (mode) {
4814
+ focusGridRef.current = true;
4815
+ handlePickerMode(mode);
4816
+ };
4817
+ React.useEffect(function () {
4818
+ if (!focusGridRef.current)
4819
+ return;
4820
+ focusGridRef.current = false;
4821
+ focusActiveCell(rootRef.current);
4822
+ }, [pickerMode]);
4823
+ var prevDisabled = isPrevDisabled();
4824
+ var nextDisabled = isNextDisabled();
4825
+ React.useEffect(function () {
4826
+ var _a;
4827
+ var active = document.activeElement;
4828
+ if (active instanceof HTMLButtonElement &&
4829
+ active.disabled &&
4830
+ ((_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.contains(active))) {
4831
+ focusActiveCell(rootRef.current);
4832
+ }
4833
+ }, [prevDisabled, nextDisabled]);
4834
+ return (React.createElement("div", { ref: rootRef, className: "picker-body flex w-[250px] flex-col gap-[15px]" },
4835
+ React.createElement(PickerHeader, { pickerMode: pickerMode, viewMonthValue: viewMonthValue, viewYearValue: viewYearValue, yearDisplayRange: yearDisplayRange, isPrevDisabled: isPrevDisabled, isNextDisabled: isNextDisabled, handlePrevMonth: handlePrevMonth, handlePrevYear: handlePrevYear, handlePrevDecade: handlePrevDecade, handleNextMonth: handleNextMonth, handleNextYear: handleNextYear, handleNextDecade: handleNextDecade, handlePickerMode: changePickerMode }),
4836
+ pickerMode === 'date' && (React.createElement(DateDisplay, { displayDays: days, maxDateValue: maxDateValue, minDateValue: minDateValue, onDateSelect: onDateSelect, selectedDate: selectedDate, viewMonthValue: viewMonthValue, viewYearValue: viewYearValue, isOpen: isOpen, onNavigateMonth: function (direction) {
4837
+ return direction === 'prev' ? handlePrevMonth() : handleNextMonth();
4838
+ } })),
3924
4839
  pickerMode === 'month' && (React.createElement(MonthDisplay, { maxDateValue: maxDateValue, minDateValue: minDateValue, onMonthSelect: function (m) {
3925
4840
  if (onMonthSelect)
3926
4841
  onMonthSelect(m);
3927
4842
  else
3928
4843
  setViewMonthValue(m);
3929
- handlePickerMode('date');
4844
+ changePickerMode('date');
3930
4845
  }, selectedDate: selectedDate, viewMonthValue: viewMonthValue, viewYearValue: viewYearValue })),
3931
4846
  pickerMode === 'year' && (React.createElement(YearDisplay, { maxDateValue: maxDateValue, minDateValue: minDateValue, onYearSelect: function (y) {
3932
4847
  if (onYearSelect)
3933
4848
  onYearSelect(y);
3934
4849
  else
3935
4850
  setViewYearValue(y);
3936
- handlePickerMode('month');
4851
+ changePickerMode('month');
3937
4852
  }, viewYearValue: viewYearValue, yearDisplayRange: yearDisplayRange }))));
3938
4853
  }
3939
4854
 
3940
4855
  function SinglePicker(_a) {
3941
- var selectedDate = _a.selectedDate, onDateChange = _a.onDateChange, minDate = _a.minDate, maxDate = _a.maxDate;
4856
+ var selectedDate = _a.selectedDate, onDateChange = _a.onDateChange, minDate = _a.minDate, maxDate = _a.maxDate, _b = _a.isOpen, isOpen = _b === void 0 ? true : _b;
3942
4857
  var handleDateSelect = function (date) {
3943
4858
  onDateChange(dateToInputString(date));
3944
4859
  };
3945
4860
  return (React.createElement("div", { className: "single-picker picker-body" },
3946
- React.createElement(PickerContent, { selectedDate: selectedDate !== null && selectedDate !== void 0 ? selectedDate : null, onDateSelect: handleDateSelect, minDate: minDate, maxDate: maxDate })));
4861
+ React.createElement(PickerContent, { selectedDate: selectedDate !== null && selectedDate !== void 0 ? selectedDate : null, onDateSelect: handleDateSelect, minDate: minDate, maxDate: maxDate, isOpen: isOpen })));
3947
4862
  }
3948
4863
 
3949
4864
  function RangePicker(_a) {
@@ -4140,8 +5055,8 @@ function RangePicker(_a) {
4140
5055
  };
4141
5056
  return (React.createElement("div", { className: "space-y-[30px]" },
4142
5057
  React.createElement("div", { className: "range-picker picker-body flex gap-x-[22px]" },
4143
- React.createElement(PickerContent, { selectedDate: tempSelectedDate, minDate: minDate, maxDate: maxDate, onDateSelect: handleDateSelect, initialViewMonth: leftMonth, initialViewYear: leftYear, onPrevMonth: handleLeftPrevMonth, onNextMonth: handleLeftNextMonth, onMonthSelect: handleMonthSelect(0, leftYear), onYearSelect: handleYearSelectLeft }),
4144
- React.createElement(PickerContent, { selectedDate: tempSelectedDate, minDate: minDate, maxDate: maxDate, onDateSelect: handleDateSelect, initialViewMonth: rightMonth, initialViewYear: rightYear, onPrevMonth: handleRightPrevMonth, onNextMonth: handleRightNextMonth, onMonthSelect: handleMonthSelect(1, rightYear), onYearSelect: handleYearSelectRight })),
5058
+ React.createElement(PickerContent, { selectedDate: tempSelectedDate, minDate: minDate, maxDate: maxDate, onDateSelect: handleDateSelect, initialViewMonth: leftMonth, initialViewYear: leftYear, onPrevMonth: handleLeftPrevMonth, onNextMonth: handleLeftNextMonth, onMonthSelect: handleMonthSelect(0, leftYear), onYearSelect: handleYearSelectLeft, isOpen: isPickerOpen }),
5059
+ React.createElement(PickerContent, { selectedDate: tempSelectedDate, minDate: minDate, maxDate: maxDate, onDateSelect: handleDateSelect, initialViewMonth: rightMonth, initialViewYear: rightYear, onPrevMonth: handleRightPrevMonth, onNextMonth: handleRightNextMonth, onMonthSelect: handleMonthSelect(1, rightYear), onYearSelect: handleYearSelectRight, isOpen: isPickerOpen })),
4145
5060
  React.createElement("div", { className: "flex justify-between" },
4146
5061
  React.createElement(Button, { label: "Reset", size: "sm", variant: "primary-outlined", iconLeft: React.createElement(TbRefresh, { className: "text-bia-blue", size: 14 }), onClick: function () { return setTempSelectedDate([]); } }),
4147
5062
  React.createElement("div", { className: "flex gap-x-2.5" },
@@ -4161,19 +5076,26 @@ function PickerBody(_a) {
4161
5076
  onCloseRef.current();
4162
5077
  }
4163
5078
  }, [isPickerOpen]);
4164
- return (React.createElement("div", { className: "picker-body flex gap-x-5" }, pickerVariant === 'single' ? (React.createElement(SinglePicker, { selectedDate: selectedDate, onDateChange: onDateChange, minDate: minDate, maxDate: maxDate })) : (React.createElement(RangePicker, { selectedDate: selectedDate, onDateChange: onDateChange, minDate: minDate, maxDate: maxDate, onClose: onClose, isPickerOpen: isOpen }))));
5079
+ return (React.createElement("div", { className: "picker-body flex gap-x-5" }, pickerVariant === 'single' ? (React.createElement(SinglePicker, { selectedDate: selectedDate, onDateChange: onDateChange, minDate: minDate, maxDate: maxDate, isOpen: isOpen })) : (React.createElement(RangePicker, { selectedDate: selectedDate, onDateChange: onDateChange, minDate: minDate, maxDate: maxDate, onClose: onClose, isPickerOpen: isOpen }))));
4165
5080
  }
4166
5081
  var PickerCalendar = function (_a) {
4167
5082
  var _b = _a.zIndex, zIndex = _b === void 0 ? 100 : _b, anchorRef = _a.anchorRef, maxDate = _a.maxDate, minDate = _a.minDate, onDateChange = _a.onDateChange; _a.ref; var _c = _a.selectedDate, selectedDate = _c === void 0 ? null : _c, _d = _a.isOpen, isOpen = _d === void 0 ? false : _d, _e = _a.onClose, onClose = _e === void 0 ? function () { } : _e, _f = _a.pickerVariant, pickerVariant = _f === void 0 ? 'range' : _f, props = __rest(_a, ["zIndex", "anchorRef", "maxDate", "minDate", "onDateChange", "ref", "selectedDate", "isOpen", "onClose", "pickerVariant"]);
4168
5083
  // Hooks & States
4169
5084
  var pickerCalendarRef = React.useRef(null);
4170
5085
  var _g = useDetectOutsideClick(anchorRef, false, pickerCalendarRef), isPickerOpen = _g[0], setIsPickerOpen = _g[1];
4171
- var style = props.style, className = props.className, restProps = __rest(props, ["style", "className"]);
5086
+ var style = props.style, className = props.className, onKeyDown = props.onKeyDown, restProps = __rest(props, ["style", "className", "onKeyDown"]);
4172
5087
  var positionStyle = usePopupPosition(anchorRef, pickerCalendarRef)[0];
4173
5088
  React.useEffect(function () {
4174
5089
  setIsPickerOpen(isOpen);
4175
5090
  }, [isOpen, setIsPickerOpen]);
4176
- return reactDom.createPortal(React.createElement("div", __assign({ className: "bianic-datepicker-calendar absolute rounded-b-radius-sm bg-bia-white px-1.5 pb-[17px] pt-[15px] text-bia-black shadow-md ".concat(className), ref: pickerCalendarRef, style: __assign(__assign({ zIndex: zIndex, display: isPickerOpen ? 'flex' : 'none' }, positionStyle), style) }, restProps),
5091
+ return reactDom.createPortal(
5092
+ // Escape and Tab are handled on the dialog root, not on a control.
5093
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
5094
+ React.createElement("div", __assign({ className: "bianic-datepicker-calendar absolute rounded-b-radius-sm bg-bia-white px-1.5 pb-[17px] pt-[15px] text-bia-black shadow-md ".concat(className), ref: pickerCalendarRef, role: "dialog", "aria-label": pickerVariant === 'single' ? 'Choose date' : 'Choose date range', style: __assign(__assign({ zIndex: zIndex, display: isPickerOpen ? 'flex' : 'none' }, positionStyle), style) }, restProps, { onKeyDown: function (event) {
5095
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
5096
+ if (!event.defaultPrevented)
5097
+ handleDialogKeyDown(event, onClose);
5098
+ } }),
4177
5099
  React.createElement(PickerBody, { selectedDate: selectedDate, minDate: minDate, maxDate: maxDate, onDateChange: onDateChange, isPickerOpen: isPickerOpen, pickerVariant: pickerVariant, onClose: onClose, isOpen: isOpen })), document.body);
4178
5100
  };
4179
5101
 
@@ -4200,7 +5122,7 @@ var displayDateFormatter = function (date) {
4200
5122
  return "".concat(date.getDate(), " ").concat(monthMap[date.getMonth()].slice(0, 3), " '").concat(date.getFullYear().toString().slice(2, 4));
4201
5123
  };
4202
5124
  var DateInputDisplay = React.forwardRef(function (_a, ref) {
4203
- var value = _a.value, _b = _a.setValue, setValue = _b === void 0 ? function () { } : _b, _c = _a.placeholder, placeholder = _c === void 0 ? 'YYYY-MM-DD' : _c, _d = _a.label, label = _d === void 0 ? '' : _d, required = _a.required, readOnly = _a.readOnly, id = _a.id, _e = _a.size, size = _e === void 0 ? 'sm' : _e, className = _a.className, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.buttonAction, buttonAction = _g === void 0 ? function () { } : _g, _h = _a.nullDisplay, nullDisplay = _h === void 0 ? '' : _h;
5125
+ var value = _a.value, _b = _a.setValue, setValue = _b === void 0 ? function () { } : _b, _c = _a.placeholder, placeholder = _c === void 0 ? 'YYYY-MM-DD' : _c, _d = _a.label, label = _d === void 0 ? '' : _d, required = _a.required, readOnly = _a.readOnly, id = _a.id, _e = _a.size, size = _e === void 0 ? 'sm' : _e, className = _a.className, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.buttonAction, buttonAction = _g === void 0 ? function () { } : _g, _h = _a.nullDisplay, nullDisplay = _h === void 0 ? '' : _h, _j = _a.toggleButtonRef, toggleButtonRef = _j === void 0 ? undefined : _j, _k = _a.toggleLabel, toggleLabel = _k === void 0 ? 'Choose date' : _k, _l = _a.isOpen, isOpen = _l === void 0 ? false : _l;
4204
5126
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
4205
5127
  _a.isActive;
4206
5128
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
@@ -4224,10 +5146,10 @@ var DateInputDisplay = React.forwardRef(function (_a, ref) {
4224
5146
  viewValue = displayDateFormatter(new Date(value));
4225
5147
  }
4226
5148
  }
4227
- var _j = React.useState(false), isEditing = _j[0], setIsEditing = _j[1];
4228
- var _k = React.useState(inputValue), dateString = _k[0], setDateString = _k[1];
5149
+ var _m = React.useState(false), isEditing = _m[0], setIsEditing = _m[1];
5150
+ var _o = React.useState(inputValue), dateString = _o[0], setDateString = _o[1];
4229
5151
  var fieldStyle = styleConfig.text.fieldStyle;
4230
- var _l = sizeConfig$d[size], iconSize = _l.iconSize, fieldSize = _l.fieldSize, iconPosition = _l.iconPosition;
5152
+ var _p = sizeConfig$d[size], iconSize = _p.iconSize, fieldSize = _p.fieldSize, iconPosition = _p.iconPosition;
4231
5153
  var borderStyle = 'border border-bia-grey-dark-10 bg-primary-white';
4232
5154
  var extendedInputClassName = "w-full ".concat(fieldStyle, " ").concat(fieldSize, " ").concat(borderStyle, " ").concat(className);
4233
5155
  var handleTextChange = function (event) {
@@ -4247,23 +5169,28 @@ var DateInputDisplay = React.forwardRef(function (_a, ref) {
4247
5169
  if (setValue)
4248
5170
  setValue('');
4249
5171
  };
4250
- var handleBlur = function () {
5172
+ // Runs when focus leaves the whole field. Moving from the text to the
5173
+ // icon stays inside the field, so editing continues.
5174
+ var handleBlur = function (event) {
5175
+ if (event.currentTarget.contains(event.relatedTarget)) {
5176
+ return;
5177
+ }
4251
5178
  setIsEditing(false);
4252
5179
  setDateString(inputValue);
4253
5180
  };
4254
- var input = isEditing || disabled ? (React.createElement(TextInput, { type: "text", value: dateString !== null && dateString !== void 0 ? dateString : '', onChange: handleTextChange, onBlur: handleBlur, placeholder: placeholder, size: size, inputClassName: extendedInputClassName, autoFocus: true, disabled: disabled, actionElement: React.createElement("button", { type: "button", className: "bianic-datepicker-toggle-button text-bia-coolgrey disabled:cursor-not-allowed", disabled: disabled, onClick: function () {
4255
- buttonAction === null || buttonAction === void 0 ? void 0 : buttonAction();
5181
+ var input = isEditing || disabled ? (React.createElement(TextInput, { type: "text", value: dateString !== null && dateString !== void 0 ? dateString : '', onChange: handleTextChange, placeholder: placeholder, size: size, inputClassName: extendedInputClassName, autoFocus: true, disabled: disabled, actionElement: React.createElement("button", { type: "button", ref: toggleButtonRef, "aria-label": toggleLabel, "aria-haspopup": "dialog", "aria-expanded": isOpen, className: "bianic-datepicker-toggle-button rounded text-bia-coolgrey disabled:cursor-not-allowed ".concat(FOCUS_RING), disabled: disabled, onClick: function (event) {
5182
+ buttonAction === null || buttonAction === void 0 ? void 0 : buttonAction(event);
4256
5183
  } },
4257
- React.createElement(TbCalendar, { size: iconSize })) })) : (React.createElement(React.Fragment, null,
5184
+ React.createElement(TbCalendar, { size: iconSize, "aria-hidden": "true" })) })) : (React.createElement(React.Fragment, null,
4258
5185
  React.createElement("div", { role: "button", tabIndex: 0, onClick: function () { return setIsEditing(true); }, onKeyDown: function (e) {
4259
5186
  if (e.key === 'Enter' || e.key === ' ') {
4260
5187
  e.preventDefault();
4261
5188
  setIsEditing(true);
4262
5189
  }
4263
- }, className: "bianic-text-input bianic-fgc-target w-full rounded hover:rounded-b-none hover:border-b-bia-blue focus:rounded-b-none focus-visible:outline-none disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-grey-active ".concat(extendedInputClassName, " ").concat(inputValue || nullDisplay ? 'text-bia-black' : 'text-bia-coolgrey') }, viewValue),
5190
+ }, className: "bianic-text-input bianic-fgc-target w-full rounded hover:rounded-b-none hover:border-b-bia-blue focus:rounded-b-none focus-visible:outline-none disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-coolgrey ".concat(extendedInputClassName, " ").concat(inputValue || nullDisplay ? 'text-bia-black' : 'text-bia-coolgrey') }, viewValue),
4264
5191
  React.createElement("div", { className: "absolute inset-y-0 flex items-center pl-3 text-bia-coolgrey ".concat(iconPosition) },
4265
- React.createElement("button", { type: "button", className: "bianic-datepicker-toggle-button", disabled: disabled, onClick: function () { return buttonAction && buttonAction(); } },
4266
- React.createElement(TbCalendar, { size: iconSize })))));
5192
+ React.createElement("button", { type: "button", ref: toggleButtonRef, "aria-label": toggleLabel, "aria-haspopup": "dialog", "aria-expanded": isOpen, className: "bianic-datepicker-toggle-button rounded ".concat(FOCUS_RING), disabled: disabled, onClick: function (event) { return buttonAction === null || buttonAction === void 0 ? void 0 : buttonAction(event); } },
5193
+ React.createElement(TbCalendar, { size: iconSize, "aria-hidden": "true" })))));
4267
5194
  React.useEffect(function () {
4268
5195
  // Only update dateString if we are NOT currently editing.
4269
5196
  if (!isEditing)
@@ -4271,7 +5198,7 @@ var DateInputDisplay = React.forwardRef(function (_a, ref) {
4271
5198
  }, [inputValue, isEditing]);
4272
5199
  return (React.createElement("div", { className: "bianic-date-input-container bianic-fgc-container flex w-full flex-col gap-y-2 text-bia-black" },
4273
5200
  label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
4274
- React.createElement("div", { className: "relative w-full", ref: ref }, input)));
5201
+ React.createElement("div", { className: "relative w-full", ref: ref, onBlur: handleBlur }, input)));
4275
5202
  });
4276
5203
  DateInputDisplay.defaultProps = {
4277
5204
  setValue: undefined,
@@ -4281,26 +5208,68 @@ DateInputDisplay.defaultProps = {
4281
5208
  setIsActive: undefined,
4282
5209
  buttonAction: undefined,
4283
5210
  nullDisplay: undefined,
5211
+ toggleButtonRef: undefined,
5212
+ toggleLabel: undefined,
5213
+ isOpen: undefined,
4284
5214
  };
4285
5215
 
4286
5216
  function DatePicker(_a) {
4287
5217
  var _b = _a.zIndexCalendar, zIndexCalendar = _b === void 0 ? 100 : _b, _c = _a.value, value = _c === void 0 ? '' : _c, _d = _a.onChange, onChange = _d === void 0 ? function () { } : _d, _e = _a.variant, variant = _e === void 0 ? 'single' : _e, _f = _a.size, size = _f === void 0 ? 'sm' : _f, _g = _a.disabled, disabled = _g === void 0 ? false : _g, _h = _a.placeholder, placeholder = _h === void 0 ? '"YYYY-MM-DD"' : _h, _j = _a.label, label = _j === void 0 ? '' : _j, _k = _a.minDate, minDate = _k === void 0 ? '' : _k, _l = _a.maxDate, maxDate = _l === void 0 ? '' : _l, _m = _a.required, required = _m === void 0 ? false : _m, _o = _a.nullDisplay, nullDisplay = _o === void 0 ? '' : _o, _p = _a.inputClassName, inputClassName = _p === void 0 ? '' : _p, _q = _a.containerClassName, containerClassName = _q === void 0 ? '' : _q;
4288
5218
  // State and Ref
4289
5219
  var inputRef = React.useRef(null);
5220
+ var toggleButtonRef = React.useRef(null);
5221
+ var focusOnOpenRef = React.useRef(false);
5222
+ var calendarId = React.useId();
4290
5223
  var _r = React.useState(false), isPickerOpen = _r[0], setIsPickerOpen = _r[1];
5224
+ // Enter or Space on the icon fires a click with detail 0. Only then does
5225
+ // focus move into the popup, so mouse use keeps focus where it is.
5226
+ var handleButtonAction = function (event) {
5227
+ var willOpen = !isPickerOpen;
5228
+ focusOnOpenRef.current = willOpen && (event === null || event === void 0 ? void 0 : event.detail) === 0;
5229
+ setIsPickerOpen(willOpen);
5230
+ };
5231
+ React.useEffect(function () {
5232
+ if (!isPickerOpen || !focusOnOpenRef.current)
5233
+ return undefined;
5234
+ var frame = 0;
5235
+ var attempts = 0;
5236
+ // The popup may not be visible yet, so retry for a few frames.
5237
+ var tryFocus = function () {
5238
+ var popup = document.getElementById(calendarId);
5239
+ focusActiveCell(popup);
5240
+ attempts += 1;
5241
+ if ((popup === null || popup === void 0 ? void 0 : popup.contains(document.activeElement)) || attempts >= 30) {
5242
+ focusOnOpenRef.current = false;
5243
+ return;
5244
+ }
5245
+ frame = requestAnimationFrame(tryFocus);
5246
+ };
5247
+ frame = requestAnimationFrame(tryFocus);
5248
+ return function () { return cancelAnimationFrame(frame); };
5249
+ }, [isPickerOpen, calendarId]);
5250
+ // Closing while focus is inside the popup puts focus back on the icon.
5251
+ var handleClose = function () {
5252
+ var _a;
5253
+ var popup = document.getElementById(calendarId);
5254
+ var wasInside = !!popup && popup.contains(document.activeElement);
5255
+ setIsPickerOpen(false);
5256
+ if (wasInside)
5257
+ (_a = toggleButtonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
5258
+ };
5259
+ var toggleLabel = variant === 'range' ? 'Choose date range' : 'Choose date';
4291
5260
  return (React.createElement("div", { className: "bianic-datepicker-container relative ".concat(containerClassName) },
4292
5261
  React.createElement("div", { className: "bianic-datepicker-field-container" },
4293
- React.createElement(DateInputDisplay, { className: inputClassName || '', value: value, setValue: onChange, placeholder: placeholder, nullDisplay: nullDisplay, size: size, label: label, required: required, buttonAction: function () { return setIsPickerOpen(!isPickerOpen); }, ref: inputRef, disabled: disabled })),
4294
- React.createElement(PickerCalendar, { zIndex: zIndexCalendar, anchorRef: inputRef, selectedDate: value, pickerVariant: variant, onDateChange: onChange, minDate: minDate, maxDate: maxDate, isOpen: isPickerOpen, onClose: function () { return setIsPickerOpen(false); } })));
5262
+ React.createElement(DateInputDisplay, { className: inputClassName || '', value: value, setValue: onChange, placeholder: placeholder, nullDisplay: nullDisplay, size: size, label: label, required: required, buttonAction: handleButtonAction, toggleButtonRef: toggleButtonRef, toggleLabel: toggleLabel, isOpen: isPickerOpen, ref: inputRef, disabled: disabled })),
5263
+ React.createElement(PickerCalendar, { id: calendarId, "aria-label": toggleLabel, zIndex: zIndexCalendar, anchorRef: inputRef, selectedDate: value, pickerVariant: variant, onDateChange: onChange, minDate: minDate, maxDate: maxDate, isOpen: isPickerOpen, onClose: handleClose })));
4295
5264
  }
4296
5265
 
4297
5266
  var YearPickerDisplay = React.forwardRef(function (_a, ref) {
4298
- var value = _a.value, setValue = _a.setValue, _b = _a.placeholder, placeholder = _b === void 0 ? 'YYYY' : _b, label = _a.label, required = _a.required, readOnly = _a.readOnly, id = _a.id, _c = _a.size, size = _c === void 0 ? 'sm' : _c, className = _a.className, _d = _a.disabled, disabled = _d === void 0 ? false : _d, buttonAction = _a.buttonAction, nullDisplay = _a.nullDisplay, minYear = _a.minYear, maxYear = _a.maxYear, customErrorMessage = _a.errorMessage, onErrorChange = _a.onErrorChange, props = __rest(_a, ["value", "setValue", "placeholder", "label", "required", "readOnly", "id", "size", "className", "disabled", "buttonAction", "nullDisplay", "minYear", "maxYear", "errorMessage", "onErrorChange"]);
5267
+ var value = _a.value, setValue = _a.setValue, _b = _a.placeholder, placeholder = _b === void 0 ? 'YYYY' : _b, label = _a.label, required = _a.required, readOnly = _a.readOnly, id = _a.id, _c = _a.size, size = _c === void 0 ? 'sm' : _c, className = _a.className, _d = _a.disabled, disabled = _d === void 0 ? false : _d, buttonAction = _a.buttonAction, nullDisplay = _a.nullDisplay, _e = _a.toggleButtonRef, toggleButtonRef = _e === void 0 ? undefined : _e, _f = _a.toggleLabel, toggleLabel = _f === void 0 ? 'Choose year' : _f, _g = _a.isOpen, isOpen = _g === void 0 ? false : _g, minYear = _a.minYear, maxYear = _a.maxYear, customErrorMessage = _a.errorMessage, onErrorChange = _a.onErrorChange, props = __rest(_a, ["value", "setValue", "placeholder", "label", "required", "readOnly", "id", "size", "className", "disabled", "buttonAction", "nullDisplay", "toggleButtonRef", "toggleLabel", "isOpen", "minYear", "maxYear", "errorMessage", "onErrorChange"]);
4299
5268
  var inputRef = React.useRef(null);
4300
5269
  React.useImperativeHandle(ref, function () { return inputRef.current; });
4301
- var _e = React.useState(false), isEditing = _e[0], setIsEditing = _e[1];
4302
- var _f = React.useState(value ? value.toString() : ''), inputValue = _f[0], setInputValue = _f[1];
4303
- var _g = React.useState(null), internalError = _g[0], setInternalError = _g[1];
5270
+ var _h = React.useState(false), isEditing = _h[0], setIsEditing = _h[1];
5271
+ var _j = React.useState(value ? value.toString() : ''), inputValue = _j[0], setInputValue = _j[1];
5272
+ var _k = React.useState(null), internalError = _k[0], setInternalError = _k[1];
4304
5273
  var setError = function (msg) {
4305
5274
  setInternalError(msg);
4306
5275
  onErrorChange === null || onErrorChange === void 0 ? void 0 : onErrorChange(msg);
@@ -4356,7 +5325,14 @@ var YearPickerDisplay = React.forwardRef(function (_a, ref) {
4356
5325
  }
4357
5326
  }
4358
5327
  };
4359
- var handleBlur = function () {
5328
+ // Runs when focus leaves the whole field. Moving from the text to the
5329
+ // icon stays inside the field, so editing continues.
5330
+ var handleBlur = function (event) {
5331
+ if (!isEditing)
5332
+ return;
5333
+ if (event.currentTarget.contains(event.relatedTarget)) {
5334
+ return;
5335
+ }
4360
5336
  setIsEditing(false);
4361
5337
  // Case A: User left field incomplete (< 4 digits)
4362
5338
  if (inputValue.length > 0 && inputValue.length < 4) {
@@ -4382,30 +5358,30 @@ var YearPickerDisplay = React.forwardRef(function (_a, ref) {
4382
5358
  }
4383
5359
  }
4384
5360
  };
4385
- var _h = sizeConfig$d[size], iconSize = _h.iconSize, fieldSize = _h.fieldSize, iconPosition = _h.iconPosition;
5361
+ var _l = sizeConfig$d[size], iconSize = _l.iconSize, fieldSize = _l.fieldSize, iconPosition = _l.iconPosition;
4386
5362
  var fieldStyle = styleConfig.text.fieldStyle;
4387
5363
  var displayError = customErrorMessage || internalError;
4388
5364
  var borderStyle = displayError
4389
5365
  ? 'border border-bia-red bg-primary-white'
4390
5366
  : 'border border-bia-grey-dark-10 bg-primary-white';
4391
5367
  var extendedInputClassName = "w-full ".concat(fieldStyle, " ").concat(fieldSize, " ").concat(borderStyle, " ").concat(className);
4392
- var input = isEditing || disabled ? (React.createElement(TextInput, __assign({ type: "text", id: id, value: inputValue, placeholder: placeholder, size: size, inputClassName: extendedInputClassName, onChange: handleChange, onBlur: handleBlur, autoFocus: true, required: required, disabled: disabled, actionElement: React.createElement("button", { type: "button", className: "bianic-datepicker-toggle-button text-bia-coolgrey disabled:cursor-not-allowed", disabled: disabled, onClick: function () {
4393
- buttonAction === null || buttonAction === void 0 ? void 0 : buttonAction();
5368
+ var input = isEditing || disabled ? (React.createElement(TextInput, __assign({ type: "text", id: id, value: inputValue, placeholder: placeholder, size: size, inputClassName: extendedInputClassName, onChange: handleChange, autoFocus: true, required: required, disabled: disabled, actionElement: React.createElement("button", { type: "button", ref: toggleButtonRef, "aria-label": toggleLabel, "aria-haspopup": "dialog", "aria-expanded": isOpen, className: "bianic-datepicker-toggle-button rounded text-bia-coolgrey disabled:cursor-not-allowed ".concat(FOCUS_RING), disabled: disabled, onClick: function (event) {
5369
+ buttonAction === null || buttonAction === void 0 ? void 0 : buttonAction(event);
4394
5370
  } },
4395
- React.createElement(TbCalendar, { size: iconSize })) }, props))) : (React.createElement(React.Fragment, null,
5371
+ React.createElement(TbCalendar, { size: iconSize, "aria-hidden": "true" })) }, props))) : (React.createElement(React.Fragment, null,
4396
5372
  React.createElement("div", { role: "button", tabIndex: disabled ? -1 : 0, onClick: function () { return !disabled && setIsEditing(true); }, onKeyDown: function (e) {
4397
5373
  if (e.key === 'Enter' || e.key === ' ') {
4398
5374
  e.preventDefault();
4399
5375
  if (!disabled)
4400
5376
  setIsEditing(true);
4401
5377
  }
4402
- }, className: "bianic-text-input bianic-fgc-target flex w-full items-center rounded hover:rounded-b-none hover:border-b-bia-blue focus:rounded-b-none focus-visible:outline-none disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-grey-active ".concat(extendedInputClassName, " ").concat(value || nullDisplay ? 'text-bia-black' : 'text-bia-coolgrey', " ").concat(disabled ? 'cursor-not-allowed opacity-60' : 'cursor-text') }, value || nullDisplay || placeholder),
5378
+ }, className: "bianic-text-input bianic-fgc-target flex w-full items-center rounded hover:rounded-b-none hover:border-b-bia-blue focus:rounded-b-none focus-visible:outline-none disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-coolgrey ".concat(extendedInputClassName, " ").concat(value || nullDisplay ? 'text-bia-black' : 'text-bia-coolgrey', " ").concat(disabled ? 'cursor-not-allowed opacity-60' : 'cursor-text') }, value || nullDisplay || placeholder),
4403
5379
  React.createElement("div", { className: "absolute inset-y-0 right-0 flex items-center pl-3 text-bia-coolgrey ".concat(iconPosition) },
4404
- React.createElement("button", { type: "button", className: "bianic-datepicker-toggle-button", disabled: disabled, onClick: function () { return buttonAction && buttonAction(); } },
4405
- React.createElement(TbCalendar, { size: iconSize })))));
5380
+ React.createElement("button", { type: "button", ref: toggleButtonRef, "aria-label": toggleLabel, "aria-haspopup": "dialog", "aria-expanded": isOpen, className: "bianic-datepicker-toggle-button rounded ".concat(FOCUS_RING), disabled: disabled, onClick: function (event) { return buttonAction === null || buttonAction === void 0 ? void 0 : buttonAction(event); } },
5381
+ React.createElement(TbCalendar, { size: iconSize, "aria-hidden": "true" })))));
4406
5382
  return (React.createElement("div", { className: "bianic-year-input-container bianic-fgc-container flex w-full flex-col gap-y-1 text-bia-black" },
4407
5383
  label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
4408
- React.createElement("div", { className: "relative w-full", ref: inputRef }, input),
5384
+ React.createElement("div", { className: "relative w-full", ref: inputRef, onBlur: handleBlur }, input),
4409
5385
  displayError && (React.createElement("span", { className: "text-xs text-bia-red" }, displayError))));
4410
5386
  });
4411
5387
  YearPickerDisplay.defaultProps = {
@@ -4478,14 +5454,21 @@ var PickerYear = function (_a) {
4478
5454
  var _d = useYearLogic(selectedYear, minYear, maxYear), viewYearValue = _d.viewYearValue, yearDisplayRange = _d.yearDisplayRange, isNextDisabled = _d.isNextDisabled, isPrevDisabled = _d.isPrevDisabled, handleNextDecade = _d.handleNextDecade, handleNextYear = _d.handleNextYear, handlePrevDecade = _d.handlePrevDecade, handlePrevYear = _d.handlePrevYear;
4479
5455
  var pickerCalendarRef = React.useRef(null);
4480
5456
  var _e = useDetectOutsideClick(anchorRef, false, pickerCalendarRef), isPickerOpen = _e[0], setIsPickerOpen = _e[1];
4481
- var style = props.style, className = props.className, restProps = __rest(props, ["style", "className"]);
5457
+ var style = props.style, className = props.className, onKeyDown = props.onKeyDown, restProps = __rest(props, ["style", "className", "onKeyDown"]);
4482
5458
  var positionStyle = usePopupPosition(anchorRef, pickerCalendarRef)[0];
4483
5459
  var substituteMaxDate = maxYear ? new Date(maxYear, 0, 1) : null;
4484
5460
  var substituteMinDate = minYear ? new Date(minYear, 0, 1) : null;
4485
5461
  React.useEffect(function () {
4486
5462
  setIsPickerOpen(isOpen);
4487
5463
  }, [isOpen, setIsPickerOpen]);
4488
- return reactDom.createPortal(React.createElement("div", __assign({ className: "bianic-datepicker-calendar absolute rounded-b-radius-sm bg-bia-white px-1.5 pb-[17px] pt-[15px] text-bia-black shadow-md ".concat(className), ref: pickerCalendarRef, style: __assign(__assign({ zIndex: zIndex, display: isPickerOpen ? 'flex' : 'none' }, positionStyle), style) }, restProps),
5464
+ return reactDom.createPortal(
5465
+ // Escape and Tab are handled on the dialog root, not on a control.
5466
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
5467
+ React.createElement("div", __assign({ className: "bianic-datepicker-calendar absolute rounded-b-radius-sm bg-bia-white px-1.5 pb-[17px] pt-[15px] text-bia-black shadow-md ".concat(className), ref: pickerCalendarRef, role: "dialog", "aria-label": "Choose year", style: __assign(__assign({ zIndex: zIndex, display: isPickerOpen ? 'flex' : 'none' }, positionStyle), style) }, restProps, { onKeyDown: function (event) {
5468
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
5469
+ if (!event.defaultPrevented)
5470
+ handleDialogKeyDown(event, onClose);
5471
+ } }),
4489
5472
  React.createElement("div", { className: "picker-body flex w-[250px] flex-col gap-[15px]" },
4490
5473
  React.createElement(PickerHeader, { pickerMode: "year", handlePickerMode: function () { }, viewYearValue: viewYearValue, yearDisplayRange: yearDisplayRange, isPrevDisabled: isPrevDisabled, isNextDisabled: isNextDisabled, handlePrevYear: handlePrevYear, handlePrevDecade: handlePrevDecade, handleNextYear: handleNextYear, handleNextDecade: handleNextDecade, viewMonthValue: 0 }),
4491
5474
  React.createElement(YearDisplay, { maxDateValue: substituteMaxDate, minDateValue: substituteMinDate, onYearSelect: function (y) {
@@ -4497,11 +5480,49 @@ var PickerYear = function (_a) {
4497
5480
  function YearPicker(_a) {
4498
5481
  var value = _a.value, onChange = _a.onChange, _b = _a.zIndexCalendar, zIndexCalendar = _b === void 0 ? 100 : _b, _c = _a.minYear, minYear = _c === void 0 ? undefined : _c, _d = _a.maxYear, maxYear = _d === void 0 ? undefined : _d, _e = _a.size, size = _e === void 0 ? 'md' : _e, disabled = _a.disabled, _f = _a.placeholder, placeholder = _f === void 0 ? '"YYYY-MM-DD"' : _f, label = _a.label, required = _a.required, nullDisplay = _a.nullDisplay, inputClassName = _a.inputClassName, containerClassName = _a.containerClassName;
4499
5482
  var inputRef = React.useRef(null);
5483
+ var toggleButtonRef = React.useRef(null);
5484
+ var focusOnOpenRef = React.useRef(false);
5485
+ var calendarId = React.useId();
4500
5486
  var _g = React.useState(false), isPickerOpen = _g[0], setIsPickerOpen = _g[1];
5487
+ // Enter or Space on the icon fires a click with detail 0. Only then does
5488
+ // focus move into the popup, so mouse use keeps focus where it is.
5489
+ var handleButtonAction = function (event) {
5490
+ var willOpen = !isPickerOpen;
5491
+ focusOnOpenRef.current = willOpen && (event === null || event === void 0 ? void 0 : event.detail) === 0;
5492
+ setIsPickerOpen(willOpen);
5493
+ };
5494
+ React.useEffect(function () {
5495
+ if (!isPickerOpen || !focusOnOpenRef.current)
5496
+ return undefined;
5497
+ var frame = 0;
5498
+ var attempts = 0;
5499
+ // The popup may not be visible yet, so retry for a few frames.
5500
+ var tryFocus = function () {
5501
+ var popup = document.getElementById(calendarId);
5502
+ focusActiveCell(popup);
5503
+ attempts += 1;
5504
+ if ((popup === null || popup === void 0 ? void 0 : popup.contains(document.activeElement)) || attempts >= 30) {
5505
+ focusOnOpenRef.current = false;
5506
+ return;
5507
+ }
5508
+ frame = requestAnimationFrame(tryFocus);
5509
+ };
5510
+ frame = requestAnimationFrame(tryFocus);
5511
+ return function () { return cancelAnimationFrame(frame); };
5512
+ }, [isPickerOpen, calendarId]);
5513
+ // Closing while focus is inside the popup puts focus back on the icon.
5514
+ var handleClose = function () {
5515
+ var _a;
5516
+ var popup = document.getElementById(calendarId);
5517
+ var wasInside = !!popup && popup.contains(document.activeElement);
5518
+ setIsPickerOpen(false);
5519
+ if (wasInside)
5520
+ (_a = toggleButtonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
5521
+ };
4501
5522
  return (React.createElement("div", { className: "bianic-yearpicker-container relative ".concat(containerClassName) },
4502
5523
  React.createElement("div", { className: "bianic-yearpicker-field-container" },
4503
- React.createElement(YearPickerDisplay, { className: inputClassName || '', value: value, setValue: onChange, placeholder: placeholder, nullDisplay: nullDisplay, size: size, label: label, required: required, buttonAction: function () { return setIsPickerOpen(!isPickerOpen); }, ref: inputRef, disabled: disabled, minYear: minYear, maxYear: maxYear })),
4504
- React.createElement(PickerYear, { maxYear: maxYear, minYear: minYear, zIndex: zIndexCalendar, anchorRef: inputRef, selectedYear: value, setSelectedYear: onChange, isOpen: isPickerOpen, onClose: function () { return setIsPickerOpen(false); } })));
5524
+ React.createElement(YearPickerDisplay, { className: inputClassName || '', value: value, setValue: onChange, placeholder: placeholder, nullDisplay: nullDisplay, size: size, label: label, required: required, buttonAction: handleButtonAction, toggleButtonRef: toggleButtonRef, toggleLabel: "Choose year", isOpen: isPickerOpen, ref: inputRef, disabled: disabled, minYear: minYear, maxYear: maxYear })),
5525
+ React.createElement(PickerYear, { id: calendarId, "aria-label": "Choose year", maxYear: maxYear, minYear: minYear, zIndex: zIndexCalendar, anchorRef: inputRef, selectedYear: value, setSelectedYear: onChange, isOpen: isPickerOpen, onClose: handleClose })));
4505
5526
  }
4506
5527
 
4507
5528
  /**
@@ -4665,9 +5686,11 @@ function DropzoneFileUploader(_a) {
4665
5686
  e.preventDefault();
4666
5687
  triggerClick();
4667
5688
  }
4668
- }, className: cn$1('relative flex cursor-pointer select-none flex-col items-center justify-center rounded-xl border border-dashed bg-bia-white pb-5 pt-4 text-center transition-all', disabled && 'cursor-not-allowed bg-bia-grey-light-50 opacity-60', activeError ? 'border-red-500 bg-red-50/20' : '', isDragging
5689
+ }, className: cn$1('relative flex cursor-pointer select-none flex-col items-center justify-center rounded-xl border border-dashed bg-bia-white pb-5 pt-4 text-center transition-all', disabled &&
5690
+ 'cursor-not-allowed border-bia-grey-dark-10 bg-bia-grey-light-80 opacity-60', activeError ? 'border-red-500 bg-red-50/20' : '', isDragging
4669
5691
  ? 'bg-blue-50/50 border-bia-blue'
4670
5692
  : !activeError &&
5693
+ !disabled &&
4671
5694
  'border-bia-grey-dark-10 hover:border-bia-blue hover:bg-gray-50') },
4672
5695
  React.createElement(TbPhotoUp, { size: 36, className: "mb-2 text-bia-coolgrey" }),
4673
5696
  React.createElement("div", { className: "mb-3 flex flex-col items-center justify-center" },
@@ -4894,34 +5917,62 @@ function VirtualPort(_a) {
4894
5917
  }
4895
5918
 
4896
5919
  var colorConfig = {
4897
- yellow: 'bg-bia-yellow-light-80',
4898
- blue: 'bg-bia-sky-light-90',
4899
- grey: 'bg-bia-grey-light-80',
4900
- white: 'bg-bia-white border border-bia-grey',
5920
+ yellow: 'bg-bia-yellow-light-80 text-bia-black',
5921
+ blue: 'bg-bia-sky-light-90 text-bia-black',
5922
+ green: 'bg-bia-green-light-90 text-bia-black',
5923
+ grey: 'bg-bia-grey-light-80 text-bia-black',
5924
+ white: 'bg-bia-white border border-bia-grey text-bia-black',
4901
5925
  };
4902
5926
  var sizeConfig$2 = {
4903
- container: 'min-h-fit p-5 text-wrap',
4904
- 'form-sm': 'min-h-[30px] h-fit whitespace-nowrap p-[7px]',
4905
- 'form-md': 'min-h-[40px] h-fit whitespace-nowrap px-2.5 py-[9.5px]',
5927
+ container: 'min-h-fit p-5 text-wrap text-size-base leading-[21px] rounded-radius-md',
5928
+ 'container-sm': 'min-h-fit p-[15px] text-wrap text-size-sm leading-4 rounded-radius-sm',
5929
+ 'form-md': 'min-h-[40px] h-fit whitespace-nowrap px-2.5 py-[9.5px] text-size-base leading-[21px] rounded-radius-md',
5930
+ 'form-sm': 'min-h-[30px] h-fit whitespace-nowrap p-[7px] text-size-sm leading-4 rounded-radius-sm',
4906
5931
  };
4907
5932
 
4908
- var colorUnion = ['yellow', 'blue', 'grey', 'white', 'custom'];
5933
+ var variantUnion = [
5934
+ 'container',
5935
+ 'form',
5936
+ 'form-sm',
5937
+ 'form-md',
5938
+ ];
5939
+ var sizeUnion = ['md', 'sm'];
5940
+ var colorUnion = [
5941
+ 'yellow',
5942
+ 'blue',
5943
+ 'green',
5944
+ 'grey',
5945
+ 'white',
5946
+ 'custom',
5947
+ ];
4909
5948
  function InfoPanel(_a) {
4910
- var _b = _a.variant, variant = _b === void 0 ? 'container' : _b, _c = _a.color, color = _c === void 0 ? 'yellow' : _c, _d = _a.bgColor, bgColor = _d === void 0 ? undefined : _d, _e = _a.textColor, textColor = _e === void 0 ? undefined : _e, _f = _a.outlineColor, outlineColor = _f === void 0 ? undefined : _f, _g = _a.className, className = _g === void 0 ? '' : _g, _h = _a.children, children = _h === void 0 ? null : _h;
4911
- var sizeClass = sizeConfig$2[variant || 'container'];
5949
+ var _b = _a.variant, variant = _b === void 0 ? 'container' : _b, _c = _a.size, size = _c === void 0 ? 'md' : _c, _d = _a.color, color = _d === void 0 ? 'yellow' : _d, _e = _a.bgColor, bgColor = _e === void 0 ? undefined : _e, _f = _a.textColor, textColor = _f === void 0 ? undefined : _f, _g = _a.outlineColor, outlineColor = _g === void 0 ? undefined : _g, _h = _a.className, className = _h === void 0 ? '' : _h, _j = _a.children, children = _j === void 0 ? null : _j;
5950
+ var validVariant = validUnion(variant, variantUnion);
5951
+ var validSize = validUnion(size, sizeUnion);
5952
+ var sizeKey;
5953
+ if (validVariant === 'form') {
5954
+ sizeKey = "form-".concat(validSize);
5955
+ }
5956
+ else if (validVariant === 'container') {
5957
+ sizeKey = validSize === 'sm' ? 'container-sm' : 'container';
5958
+ }
5959
+ else {
5960
+ sizeKey = validVariant;
5961
+ }
5962
+ var sizeClass = sizeConfig$2[sizeKey];
4912
5963
  var validColor = validUnion(color, colorUnion);
4913
5964
  var presetColor = validColor === 'custom' ? 'yellow' : validColor;
4914
5965
  var colorClass = validColor === 'custom' && bgColor
4915
5966
  ? [
4916
5967
  "bg-bia-".concat(bgColor),
4917
- textColor && "text-bia-".concat(textColor),
5968
+ "text-bia-".concat(textColor || 'black'),
4918
5969
  outlineColor && "border border-bia-".concat(outlineColor),
4919
5970
  ]
4920
5971
  .filter(Boolean)
4921
5972
  .join(' ')
4922
5973
  : colorConfig[presetColor];
4923
5974
  var allClasses = "".concat(sizeClass, " ").concat(colorClass, " ").concat(className);
4924
- return (React.createElement("div", { className: "flex items-center justify-center rounded-radius-md ".concat(allClasses) }, children));
5975
+ return (React.createElement("div", { className: "flex items-center justify-center ".concat(allClasses) }, children));
4925
5976
  }
4926
5977
 
4927
5978
  function Modal(_a) {
@@ -5024,15 +6075,22 @@ function PaginationBar(_a) {
5024
6075
  var newPages = Array.from({ length: totalPages }, function (_, i) { return i + 1; }).slice(start, start + PAGE_SIZE);
5025
6076
  setShowedPages(newPages);
5026
6077
  }, [startIndex, totalPages]);
6078
+ React.useEffect(function () {
6079
+ if (totalPages > 0 && !showedPages.includes(currentPage)) {
6080
+ setStartIndex(Math.max(0, Math.min(currentPage - 1, totalPages - 5)));
6081
+ }
6082
+ // Only react to outside page changes, not to the window moving itself.
6083
+ // eslint-disable-next-line react-hooks/exhaustive-deps
6084
+ }, [currentPage, totalPages]);
5027
6085
  return (React.createElement("div", { className: "flex ".concat(positionConfig[position], " gap-[5px]") },
5028
- totalPages > 5 && (React.createElement(Button, { variant: "subtle", size: size, type: "button", onClick: handlePrevRange, className: showedPages[0] === 1 ? ' cursor-not-allowed' : 'cursor-pointer', iconLeft: React.createElement(TbChevronsLeft, { size: iconSize }), disabled: showedPages[0] === 1 })),
6086
+ totalPages > 5 && (React.createElement(Button, { variant: "subtle", size: size, type: "button", onClick: handlePrevRange, className: showedPages[0] === 1 ? ' cursor-not-allowed' : 'cursor-pointer', iconLeft: React.createElement(TbChevronsLeft, { size: iconSize }), "aria-label": "Previous pages", disabled: showedPages[0] === 1 })),
5029
6087
  React.createElement(Button, { variant: "subtle", size: size, type: "button", onClick: function () {
5030
6088
  handlePageChange(currentPage - 1);
5031
6089
  if (showedPages[0] === currentPage)
5032
6090
  setStartIndex(function (old) { return old - 1; });
5033
6091
  if (!showedPages.includes(currentPage))
5034
6092
  setStartIndex(currentPage - 2);
5035
- }, className: currentPage === 1 ? 'cursor-not-allowed' : 'cursor-pointer', iconLeft: React.createElement(TbChevronLeft, { size: iconSize }), disabled: currentPage === 1 }),
6093
+ }, className: currentPage === 1 ? 'cursor-not-allowed' : 'cursor-pointer', iconLeft: React.createElement(TbChevronLeft, { size: iconSize }), "aria-label": "Previous page", disabled: currentPage === 1 }),
5036
6094
  showedPages.map(function (page) {
5037
6095
  if (page === currentPage) {
5038
6096
  return React.createElement(SelectedPage, { key: page, label: page.toString(), size: size });
@@ -5047,10 +6105,10 @@ function PaginationBar(_a) {
5047
6105
  setStartIndex(function (old) { return old + 1; });
5048
6106
  if (!showedPages.includes(currentPage))
5049
6107
  setStartIndex(currentPage - 4);
5050
- }, className: currentPage === totalPages ? 'cursor-not-allowed' : 'cursor-pointer', iconLeft: React.createElement(TbChevronRight, { size: iconSize }), disabled: currentPage === totalPages }),
6108
+ }, className: currentPage === totalPages ? 'cursor-not-allowed' : 'cursor-pointer', iconLeft: React.createElement(TbChevronRight, { size: iconSize }), "aria-label": "Next page", disabled: currentPage === totalPages }),
5051
6109
  totalPages > 5 && (React.createElement(Button, { variant: "subtle", size: size, type: "button", onClick: handleNextRange, className: showedPages[showedPages.length - 1] === totalPages
5052
6110
  ? 'cursor-not-allowed'
5053
- : 'cursor-pointer', iconLeft: React.createElement(TbChevronsRight, { size: iconSize }), disabled: showedPages[showedPages.length - 1] === totalPages }))));
6111
+ : 'cursor-pointer', iconLeft: React.createElement(TbChevronsRight, { size: iconSize }), "aria-label": "Next pages", disabled: showedPages[showedPages.length - 1] === totalPages }))));
5054
6112
  }
5055
6113
 
5056
6114
  var activeConfig = {
@@ -5248,7 +6306,7 @@ function ProgressBar(_a) {
5248
6306
  iconElement = icon; // Use the provided icon
5249
6307
  }
5250
6308
  }
5251
- return (React.createElement("div", { className: "bianic-progress-bar-container flex w-[320px] flex-col rounded-radius-lg bg-bia-grey-light-80 p-[10px] " },
6309
+ return (React.createElement("div", { className: "bianic-progress-bar-container flex w-full flex-col rounded-radius-lg bg-bia-grey-light-80 p-[10px] " },
5252
6310
  React.createElement("div", { className: "flex items-center justify-between text-primary-black" },
5253
6311
  React.createElement(Text, { variant: "small-text-semibold", extended: "bianic-progress-bar-title" }, title),
5254
6312
  React.createElement("div", { className: "flex gap-1" },
@@ -5854,9 +6912,9 @@ var verticalAlignConfig = {
5854
6912
  bottom: 'align-bottom',
5855
6913
  };
5856
6914
  function TableCell(_a) {
5857
- var _b = _a.variant, variant = _b === void 0 ? 'body' : _b, className = _a.className, children = _a.children, _c = _a.size, size = _c === void 0 ? 'md' : _c, _d = _a.lined, lined = _d === void 0 ? false : _d, _e = _a.bgColor, bgColor = _e === void 0 ? '' : _e, _f = _a.verticalAlign, verticalAlign = _f === void 0 ? 'top' : _f, props = __rest(_a, ["variant", "className", "children", "size", "lined", "bgColor", "verticalAlign"]);
6915
+ var _b = _a.variant, variant = _b === void 0 ? 'body' : _b, _c = _a.className, className = _c === void 0 ? '' : _c, children = _a.children, _d = _a.size, size = _d === void 0 ? 'md' : _d, _e = _a.lined, lined = _e === void 0 ? false : _e, _f = _a.bgColor, bgColor = _f === void 0 ? '' : _f, _g = _a.verticalAlign, verticalAlign = _g === void 0 ? 'top' : _g, props = __rest(_a, ["variant", "className", "children", "size", "lined", "bgColor", "verticalAlign"]);
5858
6916
  var bottomLined = lined ? 'border-b border-bia-grey' : '';
5859
- var bgColorClass = "bg-bia-".concat(bgColor);
6917
+ var bgColorClass = bgColor ? "bg-bia-".concat(bgColor) : '';
5860
6918
  var isHead = variant === 'head';
5861
6919
  var textConfig = isHead ? headTextConfig[size] : bodyTextConfig[size];
5862
6920
  var columnClass = "p-0 h-[30px] ".concat(verticalAlignConfig[verticalAlign], " ").concat(sizeConfig[size], " ").concat(bottomLined, " ").concat(bgColorClass, " ").concat(textConfig, " ").concat(className);
@@ -5896,7 +6954,7 @@ function EmptyTable(_a) {
5896
6954
  React.createElement("img", { src: EmptyIcon, alt: "Empty State", style: { height: 72, width: 72 } }),
5897
6955
  React.createElement("div", { className: "mt-5 text-center" },
5898
6956
  content && (React.createElement(Text, { variant: "small-text-semibold", extended: "block text-bia-black" }, content)),
5899
- subContent && (React.createElement(Text, { variant: "small-text", extended: "mt-2 block text-bia-coolgrey'}" }, subContent))))));
6957
+ subContent && (React.createElement(Text, { variant: "small-text", extended: "mt-2 block text-bia-coolgrey" }, subContent))))));
5900
6958
  }
5901
6959
 
5902
6960
  var tableSizeOption = [10, 20, 50, 100, 999];
@@ -5923,11 +6981,14 @@ function TableFooterController(_a) {
5923
6981
 
5924
6982
  function TableHeaderController(_a) {
5925
6983
  var _b = _a.size, size = _b === void 0 ? 'sm' : _b, _c = _a.buttonActions, buttonActions = _c === void 0 ? undefined : _c, _d = _a.totalData, totalData = _d === void 0 ? undefined : _d, _e = _a.firstIndex, firstIndex = _e === void 0 ? undefined : _e, _f = _a.lastIndex, lastIndex = _f === void 0 ? undefined : _f;
5926
- var isShowHelperText = totalData || firstIndex || lastIndex;
6984
+ // Boolean(): a bare 0 would be printed by React when there are no results.
6985
+ var isShowHelperText = Boolean(totalData || firstIndex || lastIndex);
5927
6986
  var paddingSize = size === 'md' ? 'py-[13px] pt-[14px] ' : 'py-[7px] pt-2';
5928
6987
  var textSize = size === 'md' ? 'normal-text' : 'small-text';
5929
6988
  return (React.createElement("div", { className: "table-controller-header flex w-full justify-between rounded-t-radius-lg border-b border-bia-grey bg-bia-grey-light-80 px-2.5 ".concat(paddingSize) },
5930
- React.createElement("div", { className: "action-container flex grow gap-[5px] pe-2.5" }, buttonActions && (buttonActions === null || buttonActions === void 0 ? void 0 : buttonActions.map(function (button) { return button; }))),
6989
+ React.createElement("div", { className: "action-container flex grow gap-[5px] pe-2.5" }, buttonActions === null || buttonActions === void 0 ? void 0 : buttonActions.map(function (button, index) { return (
6990
+ // eslint-disable-next-line react/no-array-index-key
6991
+ React.createElement(React.Fragment, { key: index }, button)); })),
5931
6992
  isShowHelperText && (React.createElement("div", { className: "flex max-h-[22px] items-center font-segoe" },
5932
6993
  React.createElement(Text, { variant: textSize, className: "text-bia-coolgrey" },
5933
6994
  "View ",
@@ -5946,6 +7007,497 @@ function TableSearchInput(_a) {
5946
7007
  React.createElement(TextInput, { size: "sm", variant: "text-transparent", className: "w-full bg-transparent text-size-sm focus:border-bia-grey focus:outline-none focus:ring-0", placeholder: placeholder, value: value, onChange: onChange, autoFocus: true })));
5947
7008
  }
5948
7009
 
7010
+ var ALL_PAGE_SIZE = 999;
7011
+ var alignConfig = {
7012
+ start: 'text-left',
7013
+ center: 'text-center',
7014
+ end: 'text-right',
7015
+ };
7016
+ var headerJustifyConfig = {
7017
+ start: 'justify-between',
7018
+ center: 'justify-center gap-[5px]',
7019
+ end: 'justify-end gap-[5px]',
7020
+ };
7021
+ var fitWidthConfig = {
7022
+ fit: 'whitespace-nowrap',
7023
+ other: '',
7024
+ };
7025
+
7026
+ var ariaSortConfig = {
7027
+ asc: 'ascending',
7028
+ desc: 'descending',
7029
+ };
7030
+ function SortableHeadCell(_a) {
7031
+ var label = _a.label, _b = _a.sortOrder, sortOrder = _b === void 0 ? null : _b, _c = _a.onSort, onSort = _c === void 0 ? undefined : _c, _d = _a.align, align = _d === void 0 ? 'start' : _d, _e = _a.className, className = _e === void 0 ? '' : _e, rest = __rest(_a, ["label", "sortOrder", "onSort", "align", "className"]);
7032
+ var ariaSort;
7033
+ if (onSort)
7034
+ ariaSort = sortOrder ? ariaSortConfig[sortOrder] : 'none';
7035
+ var icon = (React.createElement(TbChevronDown, { size: 18, className: "text-bia-grey-dark-10", "aria-hidden": "true" }));
7036
+ if (sortOrder === 'asc') {
7037
+ icon = (React.createElement(TbChevronDown, { size: 18, className: "text-bia-blue", "aria-hidden": "true" }));
7038
+ }
7039
+ else if (sortOrder === 'desc') {
7040
+ icon = (React.createElement(TbChevronUp, { size: 18, className: "text-bia-blue", "aria-hidden": "true" }));
7041
+ }
7042
+ return (React.createElement(TableCell, __assign({ variant: "head", "aria-sort": ariaSort }, rest, { className: cn$1(alignConfig[align], className) }), onSort ? (React.createElement("button", { type: "button", onClick: onSort, className: "flex w-full cursor-pointer select-none items-center whitespace-nowrap bg-transparent focus-visible:outline focus-visible:outline-[3px] focus-visible:outline-offset-0 focus-visible:outline-bia-blue-light-50 ".concat(headerJustifyConfig[align]) },
7043
+ React.createElement(Text, { variant: "normal-text-semibold" }, label),
7044
+ icon)) : (React.createElement(Text, { variant: "normal-text-semibold" }, label))));
7045
+ }
7046
+
7047
+ function useDebounce(value, delay) {
7048
+ if (delay === void 0) { delay = 500; }
7049
+ var _a = React.useState(value), debouncedValue = _a[0], setDebouncedValue = _a[1];
7050
+ React.useEffect(function () {
7051
+ var timer = setTimeout(function () { return setDebouncedValue(value); }, delay);
7052
+ return function () { return clearTimeout(timer); };
7053
+ }, [value, delay]);
7054
+ return debouncedValue;
7055
+ }
7056
+
7057
+ function getValueAtPath(row, path) {
7058
+ return path.split('.').reduce(function (current, part) {
7059
+ if (current === null || current === undefined)
7060
+ return undefined;
7061
+ return current[part];
7062
+ }, row);
7063
+ }
7064
+ function getColumnValue(row, column) {
7065
+ return column.accessor
7066
+ ? column.accessor(row)
7067
+ : getValueAtPath(row, column.key);
7068
+ }
7069
+ function toSize(value) {
7070
+ if (value === undefined)
7071
+ return undefined;
7072
+ return typeof value === 'number' ? "".concat(value, "px") : value;
7073
+ }
7074
+ function getColumnStyle(column) {
7075
+ var style = {};
7076
+ var width = column.width;
7077
+ if (width === 'fit') {
7078
+ style.width = '1%';
7079
+ }
7080
+ else if (width !== undefined && width !== 'auto') {
7081
+ style.width = toSize(width);
7082
+ }
7083
+ var minWidth = toSize(column.minWidth);
7084
+ var maxWidth = toSize(column.maxWidth);
7085
+ if (minWidth)
7086
+ style.minWidth = minWidth;
7087
+ if (maxWidth)
7088
+ style.maxWidth = maxWidth;
7089
+ return style;
7090
+ }
7091
+ function isEmptyValue(value) {
7092
+ return value === null || value === undefined || value === '';
7093
+ }
7094
+ function compareValues(a, b, direction) {
7095
+ var emptyA = isEmptyValue(a);
7096
+ var emptyB = isEmptyValue(b);
7097
+ if (emptyA && emptyB)
7098
+ return 0;
7099
+ if (emptyA)
7100
+ return 1;
7101
+ if (emptyB)
7102
+ return -1;
7103
+ if (typeof a === 'string' && typeof b === 'string') {
7104
+ return (a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base' }) *
7105
+ direction);
7106
+ }
7107
+ if (a < b)
7108
+ return -1 * direction;
7109
+ if (a > b)
7110
+ return 1 * direction;
7111
+ return 0;
7112
+ }
7113
+ function matchesSearch(row, columns, keyword) {
7114
+ return columns.some(function (column) {
7115
+ var value = getColumnValue(row, column);
7116
+ return ((typeof value === 'string' || typeof value === 'number') &&
7117
+ String(value).toLowerCase().includes(keyword));
7118
+ });
7119
+ }
7120
+
7121
+ var MODE_UNION = ['client', 'server'];
7122
+ function useDataTable(options) {
7123
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
7124
+ var data = options.data, columns = options.columns, pagination = options.pagination, search = options.search, sort = options.sort;
7125
+ var paginationMode = validUnion(pagination === null || pagination === void 0 ? void 0 : pagination.mode, MODE_UNION);
7126
+ var isServerPaging = paginationMode === 'server';
7127
+ var searchMode = validUnion(search === null || search === void 0 ? void 0 : search.mode, MODE_UNION);
7128
+ var sortMode = validUnion((_a = sort === null || sort === void 0 ? void 0 : sort.mode) !== null && _a !== void 0 ? _a : paginationMode, MODE_UNION);
7129
+ var debounceMs = (_b = search === null || search === void 0 ? void 0 : search.debounceMs) !== null && _b !== void 0 ? _b : 500;
7130
+ // ---- Search state ----
7131
+ var initialSearch = (_c = search === null || search === void 0 ? void 0 : search.defaultValue) !== null && _c !== void 0 ? _c : '';
7132
+ var _k = React.useState(initialSearch), searchText = _k[0], setSearchTextState = _k[1];
7133
+ var _l = React.useState(initialSearch), sentSearch = _l[0], setSentSearch = _l[1];
7134
+ var lastSentSearchRef = React.useRef(initialSearch);
7135
+ var debouncedText = useDebounce(searchText, debounceMs);
7136
+ // ---- Sort state ----
7137
+ var isSortControlled = (sort === null || sort === void 0 ? void 0 : sort.value) !== undefined;
7138
+ var _m = React.useState((_d = sort === null || sort === void 0 ? void 0 : sort.defaultValue) !== null && _d !== void 0 ? _d : null), innerSort = _m[0], setInnerSort = _m[1];
7139
+ var currentSort = isSortControlled ? ((_e = sort === null || sort === void 0 ? void 0 : sort.value) !== null && _e !== void 0 ? _e : null) : innerSort;
7140
+ // ---- Page state ----
7141
+ var isPageControlled = (pagination === null || pagination === void 0 ? void 0 : pagination.page) !== undefined;
7142
+ var isSizeControlled = (pagination === null || pagination === void 0 ? void 0 : pagination.pageSize) !== undefined;
7143
+ var _o = React.useState((_f = pagination === null || pagination === void 0 ? void 0 : pagination.defaultPage) !== null && _f !== void 0 ? _f : 1), innerPage = _o[0], setInnerPage = _o[1];
7144
+ var _p = React.useState((_g = pagination === null || pagination === void 0 ? void 0 : pagination.defaultPageSize) !== null && _g !== void 0 ? _g : 10), innerSize = _p[0], setInnerSize = _p[1];
7145
+ var size = (_h = pagination === null || pagination === void 0 ? void 0 : pagination.pageSize) !== null && _h !== void 0 ? _h : innerSize;
7146
+ // ---- Derived data ----
7147
+ var searchColumns = React.useMemo(function () {
7148
+ if (search === null || search === void 0 ? void 0 : search.keys) {
7149
+ return search.keys.map(function (key) { var _a; return (_a = columns.find(function (column) { return column.key === key; })) !== null && _a !== void 0 ? _a : { key: key, label: '' }; });
7150
+ }
7151
+ return columns.filter(function (column) { return column.type !== 'index' && column.type !== 'actions'; });
7152
+ }, [columns, search === null || search === void 0 ? void 0 : search.keys]);
7153
+ var searched = React.useMemo(function () {
7154
+ if (searchMode !== 'client')
7155
+ return data;
7156
+ var keyword = searchText.trim().toLowerCase();
7157
+ if (!keyword)
7158
+ return data;
7159
+ return data.filter(function (row) { return matchesSearch(row, searchColumns, keyword); });
7160
+ }, [data, searchMode, searchText, searchColumns]);
7161
+ var sorted = React.useMemo(function () {
7162
+ if (sortMode !== 'client' || !currentSort)
7163
+ return searched;
7164
+ var column = columns.find(function (item) { var _a; return ((_a = item.sortKey) !== null && _a !== void 0 ? _a : item.key) === currentSort.key; });
7165
+ var direction = currentSort.order === 'asc' ? 1 : -1;
7166
+ return __spreadArray([], searched, true).sort(function (a, b) {
7167
+ return column
7168
+ ? compareValues(getColumnValue(a, column), getColumnValue(b, column), direction)
7169
+ : compareValues(getValueAtPath(a, currentSort.key), getValueAtPath(b, currentSort.key), direction);
7170
+ });
7171
+ }, [searched, sortMode, currentSort, columns]);
7172
+ var totalCount = isServerPaging
7173
+ ? ((_j = pagination === null || pagination === void 0 ? void 0 : pagination.totalCount) !== null && _j !== void 0 ? _j : data.length)
7174
+ : sorted.length;
7175
+ var effectiveSize = !isServerPaging && size === ALL_PAGE_SIZE
7176
+ ? Math.max(1, totalCount)
7177
+ : Math.max(1, size);
7178
+ var totalPages = totalCount === 0 ? 0 : Math.ceil(totalCount / effectiveSize);
7179
+ var rawPage;
7180
+ if (isPageControlled)
7181
+ rawPage = pagination === null || pagination === void 0 ? void 0 : pagination.page;
7182
+ else if (innerPage === 'last') {
7183
+ rawPage = isServerPaging ? 1 : Math.max(1, totalPages);
7184
+ }
7185
+ else
7186
+ rawPage = innerPage;
7187
+ var page = Math.min(Math.max(1, rawPage), Math.max(1, totalPages));
7188
+ var rowOffset = (page - 1) * effectiveSize;
7189
+ var rows = React.useMemo(function () {
7190
+ return isServerPaging
7191
+ ? data
7192
+ : sorted.slice(rowOffset, rowOffset + effectiveSize);
7193
+ }, [isServerPaging, data, sorted, rowOffset, effectiveSize]);
7194
+ // ---- Page commits (one onChange per real change) ----
7195
+ var currentRef = React.useRef({ page: 1, pageSize: size });
7196
+ currentRef.current = { page: rawPage, pageSize: size };
7197
+ var onPageChangeRef = React.useRef(pagination === null || pagination === void 0 ? void 0 : pagination.onChange);
7198
+ onPageChangeRef.current = pagination === null || pagination === void 0 ? void 0 : pagination.onChange;
7199
+ var commit = React.useCallback(function (next) {
7200
+ var _a;
7201
+ var previous = currentRef.current;
7202
+ currentRef.current = next;
7203
+ if (!isPageControlled)
7204
+ setInnerPage(next.page);
7205
+ if (!isSizeControlled)
7206
+ setInnerSize(next.pageSize);
7207
+ if (previous.page !== next.page || previous.pageSize !== next.pageSize) {
7208
+ (_a = onPageChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onPageChangeRef, next);
7209
+ }
7210
+ }, [isPageControlled, isSizeControlled]);
7211
+ var setPage = React.useCallback(function (nextPage) {
7212
+ return commit({ page: nextPage, pageSize: currentRef.current.pageSize });
7213
+ }, [commit]);
7214
+ var setPageSize = React.useCallback(function (nextSize) { return commit({ page: 1, pageSize: nextSize }); }, [commit]);
7215
+ // "last" in client mode settles to a real number once the total is known.
7216
+ React.useEffect(function () {
7217
+ if (!isPageControlled && !isServerPaging && innerPage === 'last') {
7218
+ if (totalPages > 0)
7219
+ setInnerPage(totalPages);
7220
+ }
7221
+ }, [isPageControlled, isServerPaging, innerPage, totalPages]);
7222
+ // "last" in server mode reports the last page once the total is known.
7223
+ React.useEffect(function () {
7224
+ if (!isPageControlled && isServerPaging && innerPage === 'last') {
7225
+ if (totalPages > 0)
7226
+ commit({ page: totalPages, pageSize: size });
7227
+ }
7228
+ }, [isPageControlled, isServerPaging, innerPage, totalPages, size, commit]);
7229
+ // The page moves back when the data shrinks.
7230
+ React.useEffect(function () {
7231
+ if (innerPage === 'last' && !isPageControlled)
7232
+ return;
7233
+ if (isServerPaging && totalCount === 0)
7234
+ return;
7235
+ if (rawPage !== page)
7236
+ commit({ page: page, pageSize: size });
7237
+ }, [
7238
+ rawPage,
7239
+ page,
7240
+ size,
7241
+ innerPage,
7242
+ isPageControlled,
7243
+ isServerPaging,
7244
+ totalCount,
7245
+ commit,
7246
+ ]);
7247
+ // ---- Search handlers ----
7248
+ var sendSearch = function (text) {
7249
+ var _a;
7250
+ if (text === lastSentSearchRef.current)
7251
+ return;
7252
+ lastSentSearchRef.current = text;
7253
+ setSentSearch(text);
7254
+ (_a = search === null || search === void 0 ? void 0 : search.onChange) === null || _a === void 0 ? void 0 : _a.call(search, text);
7255
+ };
7256
+ React.useEffect(function () {
7257
+ var _a;
7258
+ if (searchMode !== 'server')
7259
+ return;
7260
+ if (debouncedText !== lastSentSearchRef.current) {
7261
+ lastSentSearchRef.current = debouncedText;
7262
+ setSentSearch(debouncedText);
7263
+ (_a = search === null || search === void 0 ? void 0 : search.onChange) === null || _a === void 0 ? void 0 : _a.call(search, debouncedText);
7264
+ }
7265
+ // eslint-disable-next-line react-hooks/exhaustive-deps
7266
+ }, [debouncedText, searchMode]);
7267
+ var setSearchText = function (text) {
7268
+ var _a;
7269
+ setSearchTextState(text);
7270
+ if (searchMode === 'client') {
7271
+ (_a = search === null || search === void 0 ? void 0 : search.onChange) === null || _a === void 0 ? void 0 : _a.call(search, text);
7272
+ setPage(1);
7273
+ }
7274
+ else if (text === '') {
7275
+ // Clearing the text is sent at once.
7276
+ sendSearch('');
7277
+ }
7278
+ };
7279
+ var submitSearch = function () {
7280
+ if (searchMode === 'server')
7281
+ sendSearch(searchText);
7282
+ };
7283
+ var appliedSearch = searchMode === 'server' ? sentSearch : searchText;
7284
+ var isSearchActive = appliedSearch.trim() !== '';
7285
+ var isNoResults = isSearchActive && rows.length === 0;
7286
+ // ---- Sort handler ----
7287
+ var toggleSort = function (columnKey) {
7288
+ var _a, _b;
7289
+ var column = columns.find(function (item) { return item.key === columnKey; });
7290
+ var key = (_a = column === null || column === void 0 ? void 0 : column.sortKey) !== null && _a !== void 0 ? _a : columnKey;
7291
+ var next;
7292
+ if (!currentSort || currentSort.key !== key)
7293
+ next = { key: key, order: 'asc' };
7294
+ else if (currentSort.order === 'asc')
7295
+ next = { key: key, order: 'desc' };
7296
+ else
7297
+ next = null;
7298
+ if (!isSortControlled)
7299
+ setInnerSort(next);
7300
+ (_b = sort === null || sort === void 0 ? void 0 : sort.onChange) === null || _b === void 0 ? void 0 : _b.call(sort, next);
7301
+ if (sortMode === 'client')
7302
+ setPage(1);
7303
+ };
7304
+ var firstIndex = rows.length === 0 ? 0 : rowOffset + 1;
7305
+ var lastIndex = rows.length === 0 ? 0 : rowOffset + rows.length;
7306
+ return {
7307
+ rows: rows,
7308
+ rowOffset: rowOffset,
7309
+ page: page,
7310
+ pageSize: size,
7311
+ totalPages: totalPages,
7312
+ totalCount: totalCount,
7313
+ firstIndex: firstIndex,
7314
+ lastIndex: lastIndex,
7315
+ setPage: setPage,
7316
+ setPageSize: setPageSize,
7317
+ searchText: searchText,
7318
+ setSearchText: setSearchText,
7319
+ submitSearch: submitSearch,
7320
+ isSearchActive: isSearchActive,
7321
+ isNoResults: isNoResults,
7322
+ sort: currentSort,
7323
+ toggleSort: toggleSort,
7324
+ getValue: getColumnValue,
7325
+ };
7326
+ }
7327
+
7328
+ function getRowKey(row, rowKey) {
7329
+ if (typeof rowKey === 'function')
7330
+ return rowKey(row);
7331
+ return String(row[rowKey]);
7332
+ }
7333
+ function toDisplayValue(value, emptyValue) {
7334
+ if (value === null || value === undefined || value === '')
7335
+ return emptyValue;
7336
+ if (typeof value === 'string' || typeof value === 'number')
7337
+ return value;
7338
+ if (React.isValidElement(value))
7339
+ return value;
7340
+ return String(value);
7341
+ }
7342
+ function DataTable(_a) {
7343
+ var _b, _c;
7344
+ var columns = _a.columns, data = _a.data, rowKey = _a.rowKey, _d = _a.pagination, pagination = _d === void 0 ? undefined : _d, _e = _a.search, search = _e === void 0 ? undefined : _e, _f = _a.sort, sort = _f === void 0 ? undefined : _f, _g = _a.isLoading, isLoading = _g === void 0 ? false : _g, _h = _a.buttonActions, buttonActions = _h === void 0 ? undefined : _h, _j = _a.middleSection, middleSection = _j === void 0 ? undefined : _j, _k = _a.rowClassName, rowClassName = _k === void 0 ? undefined : _k, _l = _a.rowProps, rowProps = _l === void 0 ? undefined : _l, _m = _a.renderRow, renderRow = _m === void 0 ? undefined : _m, _o = _a.emptyValue, emptyValue = _o === void 0 ? '-' : _o, _p = _a.emptyContent, emptyContent = _p === void 0 ? 'No data available' : _p, _q = _a.emptySubContent, emptySubContent = _q === void 0 ? '' : _q, _r = _a.noResultsContent, noResultsContent = _r === void 0 ? 'No results found' : _r, _s = _a.noResultsSubContent, noResultsSubContent = _s === void 0 ? 'Try a different search term.' : _s, _t = _a.customEmptyContent, customEmptyContent = _t === void 0 ? undefined : _t, _u = _a.tableClassName, tableClassName = _u === void 0 ? '' : _u, _v = _a.className, className = _v === void 0 ? '' : _v, rest = __rest(_a, ["columns", "data", "rowKey", "pagination", "search", "sort", "isLoading", "buttonActions", "middleSection", "rowClassName", "rowProps", "renderRow", "emptyValue", "emptyContent", "emptySubContent", "noResultsContent", "noResultsSubContent", "customEmptyContent", "tableClassName", "className"]);
7345
+ var table = useDataTable({ data: data, columns: columns, pagination: pagination, search: search, sort: sort });
7346
+ var _w = React.useState(((_b = search === null || search === void 0 ? void 0 : search.defaultValue) !== null && _b !== void 0 ? _b : '') !== ''), isSearchOpen = _w[0], setIsSearchOpen = _w[1];
7347
+ var setCurrentPage = function (value) {
7348
+ return table.setPage(typeof value === 'function' ? value(table.page) : value);
7349
+ };
7350
+ var setPageSize = function (value) {
7351
+ return table.setPageSize(typeof value === 'function' ? value(table.pageSize) : value);
7352
+ };
7353
+ var toggleSearch = function () {
7354
+ if (isSearchOpen)
7355
+ table.setSearchText('');
7356
+ setIsSearchOpen(function (old) { return !old; });
7357
+ };
7358
+ var headerActions = __spreadArray([], (buttonActions !== null && buttonActions !== void 0 ? buttonActions : []), true);
7359
+ if (search) {
7360
+ headerActions.push(React.createElement(Tooltip, { key: "search-toggle", content: "Search", direction: "bottom-left" },
7361
+ React.createElement(ContextualButton, { icon: React.createElement(TbZoom, { size: 18, "aria-hidden": "true" }), "aria-label": "Search", "aria-expanded": isSearchOpen, isSelected: isSearchOpen, onClick: toggleSearch })));
7362
+ if (isSearchOpen) {
7363
+ headerActions.push(
7364
+ // The wrapper only listens for Enter; the real control is the input.
7365
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
7366
+ React.createElement("div", { key: "search-input", className: "min-w-0 grow", onKeyDown: function (e) {
7367
+ if (e.key === 'Enter')
7368
+ table.submitSearch();
7369
+ } },
7370
+ React.createElement(TableSearchInput, { isShow: true, value: table.searchText, onChange: function (e) { return table.setSearchText(e.target.value); }, placeholder: (_c = search.placeholder) !== null && _c !== void 0 ? _c : 'Search' })));
7371
+ }
7372
+ }
7373
+ var renderHeadCell = function (column) {
7374
+ var _a, _b;
7375
+ var canSort = Boolean(column.sortable) && column.type !== 'actions';
7376
+ var sortKey = (_a = column.sortKey) !== null && _a !== void 0 ? _a : column.key;
7377
+ return (React.createElement(SortableHeadCell, { key: column.key, label: column.label, align: column.align, sortOrder: ((_b = table.sort) === null || _b === void 0 ? void 0 : _b.key) === sortKey ? table.sort.order : null, onSort: canSort ? function () { return table.toggleSort(column.key); } : undefined, style: getColumnStyle(column), className: cn$1(fitWidthConfig[column.width === 'fit' ? 'fit' : 'other'], column.headerClassName) }));
7378
+ };
7379
+ var renderCells = function (row, position) {
7380
+ var index = table.rowOffset + position;
7381
+ return columns.map(function (column) {
7382
+ var _a, _b;
7383
+ var align = (_a = column.align) !== null && _a !== void 0 ? _a : 'start';
7384
+ var value = table.getValue(row, column);
7385
+ var extra = typeof column.cellClassName === 'function'
7386
+ ? column.cellClassName(row, index)
7387
+ : column.cellClassName;
7388
+ var content;
7389
+ if (column.type === 'index') {
7390
+ content = (React.createElement(Text, { variant: "normal-text", className: "pt-[4px]" }, index + 1));
7391
+ }
7392
+ else if (column.type === 'actions') {
7393
+ content = (React.createElement("div", { className: "px-[9px]" }, (_b = column.render) === null || _b === void 0 ? void 0 : _b.call(column, value, row, index)));
7394
+ }
7395
+ else if (column.render) {
7396
+ content = column.render(value, row, index);
7397
+ }
7398
+ else {
7399
+ content = (React.createElement(Text, { variant: "normal-text", className: "pt-[4px]" }, toDisplayValue(value, emptyValue)));
7400
+ }
7401
+ return (React.createElement(TableCell, { key: column.key, size: "sm", variant: "body", style: getColumnStyle(column), className: cn$1(alignConfig[align], fitWidthConfig[column.width === 'fit' ? 'fit' : 'other'], extra) }, content));
7402
+ });
7403
+ };
7404
+ var headRow = (React.createElement(TableHead, null,
7405
+ React.createElement(TableRow, { variant: "head" }, columns.map(renderHeadCell))));
7406
+ var renderRows = function () {
7407
+ return table.rows.map(function (row, position) {
7408
+ var _a;
7409
+ var index = table.rowOffset + position;
7410
+ var key = getRowKey(row, rowKey);
7411
+ var cells = renderCells(row, position);
7412
+ if (renderRow) {
7413
+ return React.createElement(React.Fragment, { key: key }, renderRow(row, index, cells));
7414
+ }
7415
+ var _b = (_a = rowProps === null || rowProps === void 0 ? void 0 : rowProps(row, index)) !== null && _a !== void 0 ? _a : {}, extraClassName = _b.className, extraProps = __rest(_b, ["className"]);
7416
+ return (React.createElement(TableRow, __assign({ key: key, variant: "body" }, extraProps, { className: cn$1(rowClassName === null || rowClassName === void 0 ? void 0 : rowClassName(row, index), extraClassName) || undefined }), cells));
7417
+ });
7418
+ };
7419
+ var body;
7420
+ if (isLoading) {
7421
+ body = (React.createElement(Table, { className: "h-full w-full font-segoe" },
7422
+ headRow,
7423
+ React.createElement(TableBody, null,
7424
+ React.createElement(TableRow, { variant: "body" },
7425
+ React.createElement("td", { colSpan: columns.length, className: "p-0" },
7426
+ React.createElement(BlockLoading, { className: "p-5" }))))));
7427
+ }
7428
+ else if (table.rows.length === 0) {
7429
+ if (table.isNoResults) {
7430
+ body = (React.createElement(EmptyTable, { content: noResultsContent, subContent: noResultsSubContent }));
7431
+ }
7432
+ else {
7433
+ body = customEmptyContent !== null && customEmptyContent !== void 0 ? customEmptyContent : (React.createElement(EmptyTable, { content: emptyContent, subContent: emptySubContent }));
7434
+ }
7435
+ }
7436
+ else {
7437
+ body = (React.createElement(Table, { className: "h-full w-full font-segoe" },
7438
+ headRow,
7439
+ React.createElement(TableBody, null, renderRows())));
7440
+ }
7441
+ return (React.createElement("div", __assign({}, rest, { className: "bianic-data-table w-full ".concat(className) }),
7442
+ React.createElement(TableHeaderController, { buttonActions: headerActions, totalData: table.totalCount, firstIndex: table.firstIndex, lastIndex: table.lastIndex }),
7443
+ middleSection,
7444
+ React.createElement("div", { className: "h-full w-full overflow-x-auto ".concat(tableClassName) }, body),
7445
+ React.createElement(TableFooterController, { size: "md", currentPage: table.page, totalPages: table.totalPages, pageSize: table.pageSize, setCurrentPage: setCurrentPage, setPageSize: setPageSize, isLoading: isLoading })));
7446
+ }
7447
+
7448
+ var openStateConfig = {
7449
+ open: 'visible grid-rows-[1fr] opacity-100',
7450
+ closed: 'invisible grid-rows-[0fr] opacity-0',
7451
+ };
7452
+ var columnsConfig = {
7453
+ auto: 'grid-cols-[repeat(3,minmax(0,1fr))_auto]',
7454
+ 2: 'grid-cols-2',
7455
+ 3: 'grid-cols-3',
7456
+ 4: 'grid-cols-4',
7457
+ 5: 'grid-cols-5',
7458
+ 6: 'grid-cols-6',
7459
+ };
7460
+ var panelSizeConfig = {
7461
+ md: 'gap-5 px-5 py-[25px]',
7462
+ sm: 'gap-4 px-5 py-6',
7463
+ };
7464
+ var actionsGapConfig = {
7465
+ md: 'gap-2.5',
7466
+ sm: 'gap-2',
7467
+ };
7468
+ // The buttons sit in the last column. In 'auto' that column is as wide as the
7469
+ // two buttons, so they stay on one line.
7470
+ var actionsColumnConfig = {
7471
+ auto: 'col-start-4 flex-nowrap whitespace-nowrap',
7472
+ 2: 'col-start-2 flex-wrap',
7473
+ 3: 'col-start-3 flex-wrap',
7474
+ 4: 'col-start-4 flex-wrap',
7475
+ 5: 'col-start-5 flex-wrap',
7476
+ 6: 'col-start-6 flex-wrap',
7477
+ };
7478
+
7479
+ var SIZE_UNION = ['md', 'sm'];
7480
+ var COLUMNS_UNION = ['auto', 2, 3, 4, 5, 6];
7481
+ function TableFilterPanel(_a) {
7482
+ var isOpen = _a.isOpen, onApply = _a.onApply, onReset = _a.onReset, children = _a.children, _b = _a.columns, columns = _b === void 0 ? 'auto' : _b, _c = _a.size, size = _c === void 0 ? 'md' : _c, _d = _a.applyLabel, applyLabel = _d === void 0 ? 'Apply Filter' : _d, _e = _a.resetLabel, resetLabel = _e === void 0 ? 'Reset' : _e, _f = _a.className, className = _f === void 0 ? '' : _f, rest = __rest(_a, ["isOpen", "onApply", "onReset", "children", "columns", "size", "applyLabel", "resetLabel", "className"]);
7483
+ var safeSize = validUnion(size, SIZE_UNION);
7484
+ var safeColumns = validUnion(columns, COLUMNS_UNION);
7485
+ return (React.createElement("div", __assign({}, rest, { "data-state": isOpen ? 'open' : 'closed', className: "bianic-table-filter-panel grid transition-all duration-300 ease-in-out motion-reduce:transition-none ".concat(openStateConfig[isOpen ? 'open' : 'closed'], " ").concat(className) }),
7486
+ React.createElement("div", { className: "min-h-0 overflow-hidden" },
7487
+ React.createElement("div", { className: "grid items-end border-b border-bia-grey bg-bia-grey-light-80 ".concat(columnsConfig[safeColumns], " ").concat(panelSizeConfig[safeSize]) },
7488
+ children,
7489
+ React.createElement("div", { className: "flex items-end justify-start ".concat(actionsColumnConfig[safeColumns], " ").concat(actionsGapConfig[safeSize]) },
7490
+ React.createElement(Button, { variant: "default-outlined", size: safeSize, label: applyLabel, iconLeft: React.createElement(TbCheck, { size: 14, "aria-hidden": "true" }), onClick: onApply }),
7491
+ React.createElement(Button, { variant: "default-outlined", size: safeSize, label: resetLabel, iconLeft: React.createElement(TbRefresh, { size: 14, "aria-hidden": "true" }), onClick: onReset }))))));
7492
+ }
7493
+
7494
+ var TableFilterButton = React.forwardRef(function (_a, ref) {
7495
+ var isOpen = _a.isOpen, _b = _a.isActive, isActive = _b === void 0 ? false : _b, _c = _a.label, label = _c === void 0 ? 'Filter' : _c, rest = __rest(_a, ["isOpen", "isActive", "label"]);
7496
+ return (React.createElement(Tooltip, { content: label, direction: "bottom-left" },
7497
+ React.createElement(ContextualButton, __assign({ ref: ref }, rest, { icon: React.createElement(TbFilter, { size: 18, "aria-hidden": "true" }), isSelected: isOpen, isNotified: isActive, "aria-expanded": isOpen, "aria-label": isActive ? "".concat(label, " (active)") : label }))));
7498
+ });
7499
+ TableFilterButton.displayName = 'TableFilterButton';
7500
+
5949
7501
  var colorConfigs = {
5950
7502
  default: 'bg-bia-black',
5951
7503
  info: 'bg-bia-teal',
@@ -9587,6 +11139,259 @@ var formatDateTime = function (dateString, type) {
9587
11139
  }
9588
11140
  };
9589
11141
 
11142
+ function getStorage(type) {
11143
+ if (typeof window === 'undefined')
11144
+ return null;
11145
+ try {
11146
+ return type === 'local' ? window.localStorage : window.sessionStorage;
11147
+ }
11148
+ catch (_a) {
11149
+ return null;
11150
+ }
11151
+ }
11152
+ function resolveInitial(initialValue) {
11153
+ return typeof initialValue === 'function'
11154
+ ? initialValue()
11155
+ : initialValue;
11156
+ }
11157
+ function readValue(key, type, initialValue) {
11158
+ var _a;
11159
+ if (key) {
11160
+ try {
11161
+ var raw = (_a = getStorage(type)) === null || _a === void 0 ? void 0 : _a.getItem(key);
11162
+ if (raw !== null && raw !== undefined)
11163
+ return JSON.parse(raw);
11164
+ }
11165
+ catch (_b) {
11166
+ // Blocked storage or broken JSON: use the initial value.
11167
+ }
11168
+ }
11169
+ return resolveInitial(initialValue);
11170
+ }
11171
+ function usePersistentState(key, initialValue, options) {
11172
+ if (options === void 0) { options = {}; }
11173
+ var _a = options.storage, storage = _a === void 0 ? 'session' : _a;
11174
+ var _b = React.useState(function () {
11175
+ return readValue(key, storage, initialValue);
11176
+ }), value = _b[0], setValue = _b[1];
11177
+ var initialRef = React.useRef(initialValue);
11178
+ initialRef.current = initialValue;
11179
+ var isFirstRun = React.useRef(true);
11180
+ var lastKeyRef = React.useRef(key);
11181
+ var skipWriteRef = React.useRef(false);
11182
+ // Re-read when the key or the storage type changes.
11183
+ var lastStorageRef = React.useRef(storage);
11184
+ React.useEffect(function () {
11185
+ if (lastKeyRef.current === key && lastStorageRef.current === storage)
11186
+ return;
11187
+ lastKeyRef.current = key;
11188
+ lastStorageRef.current = storage;
11189
+ skipWriteRef.current = true;
11190
+ setValue(readValue(key, storage, initialRef.current));
11191
+ }, [key, storage]);
11192
+ React.useEffect(function () {
11193
+ var _a;
11194
+ if (isFirstRun.current) {
11195
+ isFirstRun.current = false;
11196
+ return;
11197
+ }
11198
+ if (skipWriteRef.current) {
11199
+ skipWriteRef.current = false;
11200
+ return;
11201
+ }
11202
+ if (!key)
11203
+ return;
11204
+ try {
11205
+ (_a = getStorage(storage)) === null || _a === void 0 ? void 0 : _a.setItem(key, JSON.stringify(value));
11206
+ }
11207
+ catch (_b) {
11208
+ // Storage is full or blocked: keep the value in memory only.
11209
+ }
11210
+ }, [key, storage, value]);
11211
+ var clear = React.useCallback(function () {
11212
+ var _a;
11213
+ if (key) {
11214
+ try {
11215
+ (_a = getStorage(storage)) === null || _a === void 0 ? void 0 : _a.removeItem(key);
11216
+ }
11217
+ catch (_b) {
11218
+ // Ignore blocked storage.
11219
+ }
11220
+ }
11221
+ skipWriteRef.current = true;
11222
+ setValue(resolveInitial(initialRef.current));
11223
+ }, [key, storage]);
11224
+ return [value, setValue, clear];
11225
+ }
11226
+
11227
+ function isEmptyFilterValue(value) {
11228
+ if (value === null || value === undefined)
11229
+ return true;
11230
+ if (typeof value === 'string') {
11231
+ var text = value.trim();
11232
+ return text === '' || text === 'all';
11233
+ }
11234
+ if (Array.isArray(value))
11235
+ return value.every(isEmptyFilterValue);
11236
+ return false;
11237
+ }
11238
+ function cleanParams(filter) {
11239
+ var result = {};
11240
+ if (!filter)
11241
+ return result;
11242
+ Object.entries(filter).forEach(function (_a) {
11243
+ var key = _a[0], value = _a[1];
11244
+ if (typeof value === 'string') {
11245
+ var text = value.trim();
11246
+ if (!isEmptyFilterValue(text))
11247
+ result[key] = text;
11248
+ return;
11249
+ }
11250
+ if (Array.isArray(value)) {
11251
+ var items = value
11252
+ .map(function (item) { return (typeof item === 'string' ? item.trim() : item); })
11253
+ .filter(function (item) { return !isEmptyFilterValue(item); });
11254
+ if (items.length > 0)
11255
+ result[key] = items;
11256
+ return;
11257
+ }
11258
+ if (!isEmptyFilterValue(value))
11259
+ result[key] = value;
11260
+ });
11261
+ return result;
11262
+ }
11263
+ function isFilterActive(filter) {
11264
+ return Object.keys(cleanParams(filter)).length > 0;
11265
+ }
11266
+
11267
+ function isPlainObject(value) {
11268
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
11269
+ }
11270
+ // Keep only the keys that exist in `initial`. Missing keys take the initial value.
11271
+ function mergeSaved(initial, stored) {
11272
+ if (stored === initial)
11273
+ return initial;
11274
+ if (!isPlainObject(stored))
11275
+ return initial;
11276
+ var merged = __assign({}, initial);
11277
+ Object.keys(initial).forEach(function (key) {
11278
+ if (key in stored)
11279
+ merged[key] = stored[key];
11280
+ });
11281
+ return merged;
11282
+ }
11283
+ function useAppliedFilter(initial, options) {
11284
+ if (options === void 0) { options = {}; }
11285
+ var _a = options.storageKey, storageKey = _a === void 0 ? undefined : _a, _b = options.storage, storage = _b === void 0 ? 'session' : _b;
11286
+ var initialRef = React.useRef(initial);
11287
+ initialRef.current = initial;
11288
+ // usePersistentState reads storage in its first render, so a saved filter
11289
+ // is there from the start.
11290
+ var _c = usePersistentState(storageKey || undefined, initial, { storage: storage }), stored = _c[0], setStored = _c[1], clearStored = _c[2];
11291
+ var storedRef = React.useRef(stored);
11292
+ storedRef.current = stored;
11293
+ var applied = React.useMemo(function () { return mergeSaved(initialRef.current, stored); }, [stored]);
11294
+ var _d = React.useState(function () { return applied; }), draft = _d[0], setDraftState = _d[1];
11295
+ var draftRef = React.useRef(draft);
11296
+ var setDraft = React.useCallback(function (next) {
11297
+ var resolved = typeof next === 'function'
11298
+ ? next(draftRef.current)
11299
+ : next;
11300
+ draftRef.current = resolved;
11301
+ setDraftState(resolved);
11302
+ }, []);
11303
+ var setDraftValue = React.useCallback(function (key, value) {
11304
+ setDraft(function (old) {
11305
+ var _a;
11306
+ return (__assign(__assign({}, old), (_a = {}, _a[key] = value, _a)));
11307
+ });
11308
+ }, [setDraft]);
11309
+ // When the key or the storage type changes, the draft follows the new value.
11310
+ // usePersistentState reads the new key in its own effect, so `applied`
11311
+ // changes one render later. The flag makes the draft follow that change.
11312
+ var lastKeyRef = React.useRef({ storageKey: storageKey, storage: storage });
11313
+ var followRef = React.useRef(false);
11314
+ React.useEffect(function () {
11315
+ var last = lastKeyRef.current;
11316
+ if (last.storageKey === storageKey && last.storage === storage)
11317
+ return;
11318
+ lastKeyRef.current = { storageKey: storageKey, storage: storage };
11319
+ followRef.current = true;
11320
+ }, [storageKey, storage]);
11321
+ React.useEffect(function () {
11322
+ if (!followRef.current)
11323
+ return;
11324
+ followRef.current = false;
11325
+ setDraft(applied);
11326
+ }, [applied, setDraft]);
11327
+ var apply = React.useCallback(function () {
11328
+ setStored(draftRef.current);
11329
+ }, [setStored]);
11330
+ var reset = React.useCallback(function () {
11331
+ // Nothing was saved when the stored value is still the initial object.
11332
+ // Calling clear then would leave usePersistentState skipping its next save.
11333
+ if (storedRef.current !== initialRef.current)
11334
+ clearStored();
11335
+ setDraft(initialRef.current);
11336
+ }, [clearStored, setDraft]);
11337
+ var params = React.useMemo(function () { return cleanParams(applied); }, [applied]);
11338
+ var isActive = Object.keys(params).length > 0;
11339
+ return {
11340
+ draft: draft,
11341
+ setDraft: setDraft,
11342
+ setDraftValue: setDraftValue,
11343
+ applied: applied,
11344
+ params: params,
11345
+ isActive: isActive,
11346
+ apply: apply,
11347
+ reset: reset,
11348
+ };
11349
+ }
11350
+
11351
+ var FILE_SIZE_UNITS = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
11352
+ function formatFileSize(bytes) {
11353
+ if (bytes === void 0) { bytes = 0; }
11354
+ if (!Number.isFinite(bytes) || bytes <= 0)
11355
+ return '0 Bytes';
11356
+ var base = 1024;
11357
+ var index = Math.min(FILE_SIZE_UNITS.length - 1, Math.max(0, Math.floor(Math.log(bytes) / Math.log(base))));
11358
+ return "".concat((bytes / Math.pow(base, index)).toFixed(2), " ").concat(FILE_SIZE_UNITS[index]);
11359
+ }
11360
+ function truncateText(text, maxLength) {
11361
+ if (!text)
11362
+ return '';
11363
+ if (text.length <= maxLength)
11364
+ return text;
11365
+ var cut = text.slice(0, maxLength);
11366
+ var lastSpace = cut.lastIndexOf(' ');
11367
+ var end = lastSpace > 0 ? lastSpace : maxLength;
11368
+ return "".concat(text.slice(0, end), "...");
11369
+ }
11370
+
11371
+ function escapeRegExp(text) {
11372
+ return text.replace(/[-.*+?^${}()|[\]\\]/g, '\\$&');
11373
+ }
11374
+ function highlightMatch(text, keyword) {
11375
+ if (text === null || text === undefined)
11376
+ return '';
11377
+ var source = String(text);
11378
+ if (!keyword)
11379
+ return source;
11380
+ var parts = source.split(new RegExp("(".concat(escapeRegExp(keyword), ")"), 'gi'));
11381
+ if (parts.length === 1)
11382
+ return source;
11383
+ var lowerKeyword = keyword.toLowerCase();
11384
+ var offset = 0;
11385
+ return parts.map(function (part) {
11386
+ var key = "".concat(offset, "-").concat(part);
11387
+ offset += part.length;
11388
+ if (part.toLowerCase() === lowerKeyword) {
11389
+ return (React.createElement("span", { key: key, className: "font-bold" }, part));
11390
+ }
11391
+ return React.createElement(React.Fragment, { key: key }, part);
11392
+ });
11393
+ }
11394
+
9590
11395
  /**
9591
11396
  * A custom hook to handle data processing for tables, managing internal states
9592
11397
  * for client-side filtering (searching) and sorting. It can also safely yield control
@@ -9627,7 +11432,10 @@ var useTableDataHandler = function (initialData, options) {
9627
11432
  return configSearchKeys;
9628
11433
  if (initialData && initialData.length > 0) {
9629
11434
  var allKeys = Object.keys(initialData[0]);
9630
- return allKeys.filter(function (key) { return typeof initialData[0][key] === 'string'; });
11435
+ return allKeys.filter(function (key) {
11436
+ var firstValue = initialData[0][key];
11437
+ return typeof firstValue === 'string' || typeof firstValue === 'number';
11438
+ });
9631
11439
  }
9632
11440
  return [];
9633
11441
  }, [initialData, configSearchKeys, isFilterable, isServerSide]);
@@ -9643,8 +11451,8 @@ var useTableDataHandler = function (initialData, options) {
9643
11451
  result = result.filter(function (item) {
9644
11452
  return searchKeys.some(function (key) {
9645
11453
  var itemValue = item[key];
9646
- return (typeof itemValue === 'string' &&
9647
- itemValue.toLowerCase().includes(keyword_1));
11454
+ return ((typeof itemValue === 'string' || typeof itemValue === 'number') &&
11455
+ String(itemValue).toLowerCase().includes(keyword_1));
9648
11456
  });
9649
11457
  });
9650
11458
  }
@@ -9745,6 +11553,7 @@ exports.Checkbox = Checkbox;
9745
11553
  exports.Color = Color;
9746
11554
  exports.ContextualButton = ContextualButton;
9747
11555
  exports.Countdown = Countdown;
11556
+ exports.DataTable = DataTable;
9748
11557
  exports.DatePicker = DatePicker;
9749
11558
  exports.Display = Display;
9750
11559
  exports.Divider = Divider;
@@ -9784,12 +11593,15 @@ exports.SidebarMenu = SidebarMenu;
9784
11593
  exports.SidebarProfile = SidebarProfile;
9785
11594
  exports.SimpleFileUploader = SimpleFileUploader;
9786
11595
  exports.Slider = Slider;
11596
+ exports.SortableHeadCell = SortableHeadCell;
9787
11597
  exports.Spinner = Spinner;
9788
11598
  exports.Tab = Tab;
9789
11599
  exports.TabMenu = TabMenu;
9790
11600
  exports.Table = Table;
9791
11601
  exports.TableBody = TableBody;
9792
11602
  exports.TableCell = TableCell;
11603
+ exports.TableFilterButton = TableFilterButton;
11604
+ exports.TableFilterPanel = TableFilterPanel;
9793
11605
  exports.TableFooterController = TableFooterController;
9794
11606
  exports.TableHead = TableHead;
9795
11607
  exports.TableHeaderController = TableHeaderController;
@@ -9807,7 +11619,17 @@ exports.TreeItem = TreeItem$1;
9807
11619
  exports.VerticalStepper = StepperItem;
9808
11620
  exports.Window = Window;
9809
11621
  exports.YearPicker = YearPicker;
11622
+ exports.cleanParams = cleanParams;
9810
11623
  exports.formatDateTime = formatDateTime;
11624
+ exports.formatFileSize = formatFileSize;
9811
11625
  exports.getRelativeTime = getRelativeTime;
11626
+ exports.highlightMatch = highlightMatch;
11627
+ exports.isEmptyFilterValue = isEmptyFilterValue;
11628
+ exports.isFilterActive = isFilterActive;
11629
+ exports.truncateText = truncateText;
11630
+ exports.useAppliedFilter = useAppliedFilter;
11631
+ exports.useDataTable = useDataTable;
11632
+ exports.useDebounce = useDebounce;
9812
11633
  exports.useFileTree = useFileTree;
11634
+ exports.usePersistentState = usePersistentState;
9813
11635
  exports.useTableDataHandler = useTableDataHandler;