bianic-ui 2.14.0-beta.7 → 2.14.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 (104) hide show
  1. package/dist/cjs/index.js +958 -93
  2. package/dist/cjs/lib.css +1 -1
  3. package/dist/cjs/types/components/Button/PropInterfaceButton.d.ts +1 -0
  4. package/dist/cjs/types/components/Button/buttonConfigs.d.ts +6 -0
  5. package/dist/cjs/types/components/Forms/LiveSearch/hooks/useLiveSearch.d.ts +2 -0
  6. package/dist/cjs/types/components/Forms/LiveSearch/index.d.ts +1 -1
  7. package/dist/cjs/types/components/Forms/LiveSearch/types/index.d.ts +1 -0
  8. package/dist/cjs/types/components/Forms/TagLabelInput/index.d.ts +1 -0
  9. package/dist/cjs/types/components/InfoPanel/config.d.ts +2 -5
  10. package/dist/cjs/types/components/InfoPanel/index.d.ts +7 -3
  11. package/dist/cjs/types/components/Table/DataTable/DataTable.d.ts +4 -0
  12. package/dist/cjs/types/components/Table/DataTable/SortableHeadCell.d.ts +11 -0
  13. package/dist/cjs/types/components/Table/DataTable/configs.d.ts +5 -0
  14. package/dist/cjs/types/components/Table/DataTable/index.d.ts +5 -0
  15. package/dist/cjs/types/components/Table/DataTable/types.d.ts +100 -0
  16. package/dist/cjs/types/components/Table/DataTable/useDataTable.d.ts +4 -0
  17. package/dist/cjs/types/components/Table/DataTable/utils.d.ts +7 -0
  18. package/dist/cjs/types/components/Table/index.d.ts +2 -0
  19. package/dist/cjs/types/components/TagLabel/configs.d.ts +8 -1
  20. package/dist/cjs/types/components/index.d.ts +5 -1
  21. package/dist/cjs/types/stories/Button/Button.stories.d.ts +19 -0
  22. package/dist/cjs/types/stories/Form/LiveSearch/Livesearch.stories.d.ts +1 -0
  23. package/dist/cjs/types/stories/Form/LiveSearch/Livesearch.test.stories.d.ts +3 -0
  24. package/dist/cjs/types/stories/Form/TagLabelInput/TagLabelInput.stories.d.ts +13 -0
  25. package/dist/cjs/types/stories/InfoPanel/InfoPanel.stories.d.ts +95 -1
  26. package/dist/cjs/types/stories/InfoPanel/InfoPanel.test.stories.d.ts +33 -0
  27. package/dist/cjs/types/stories/PaginationBar/PaginationBar.test.stories.d.ts +27 -0
  28. package/dist/cjs/types/stories/Table/DataTable.stories.d.ts +245 -0
  29. package/dist/cjs/types/stories/Table/DataTable.test.stories.d.ts +76 -0
  30. package/dist/cjs/types/stories/Table/useTableDataHandler.test.stories.d.ts +19 -0
  31. package/dist/cjs/types/stories/TagLabel/TagLabel.stories.d.ts +4 -0
  32. package/dist/cjs/types/stories/TagLabel/TagLabel.test.stories.d.ts +38 -0
  33. package/dist/cjs/types/stories/Tooltip/Tooltip.stories.d.ts +19 -0
  34. package/dist/cjs/types/stories/Tooltip/Tooltip.test.stories.d.ts +33 -0
  35. package/dist/cjs/types/stories/Utility/Formatters.stories.d.ts +18 -0
  36. package/dist/cjs/types/stories/Utility/Formatters.test.stories.d.ts +21 -0
  37. package/dist/cjs/types/stories/Utility/cleanParams.stories.d.ts +33 -0
  38. package/dist/cjs/types/stories/Utility/filterSamples.d.ts +62 -0
  39. package/dist/cjs/types/stories/Utility/useAppliedFilter.stories.d.ts +46 -0
  40. package/dist/cjs/types/stories/Utility/useDebounce.stories.d.ts +31 -0
  41. package/dist/cjs/types/stories/Utility/useDebounce.test.stories.d.ts +19 -0
  42. package/dist/cjs/types/stories/Utility/usePersistentState.stories.d.ts +44 -0
  43. package/dist/cjs/types/stories/Utility/usePersistentState.test.stories.d.ts +21 -0
  44. package/dist/cjs/types/utility/hooks/useAppliedFilter.d.ts +19 -0
  45. package/dist/cjs/types/utility/hooks/useDebounce.d.ts +3 -0
  46. package/dist/cjs/types/utility/hooks/usePersistentState.d.ts +8 -0
  47. package/dist/cjs/types/utility/hooks/useTableDataHandler.d.ts +1 -1
  48. package/dist/cjs/types/utility/index.d.ts +8 -0
  49. package/dist/cjs/types/utility/public/filterParams.d.ts +4 -0
  50. package/dist/cjs/types/utility/public/formatters.d.ts +2 -0
  51. package/dist/cjs/types/utility/public/highlightMatch.d.ts +3 -0
  52. package/dist/esm/index.js +948 -95
  53. package/dist/esm/lib.css +1 -1
  54. package/dist/esm/types/components/Button/PropInterfaceButton.d.ts +1 -0
  55. package/dist/esm/types/components/Button/buttonConfigs.d.ts +6 -0
  56. package/dist/esm/types/components/Forms/LiveSearch/hooks/useLiveSearch.d.ts +2 -0
  57. package/dist/esm/types/components/Forms/LiveSearch/index.d.ts +1 -1
  58. package/dist/esm/types/components/Forms/LiveSearch/types/index.d.ts +1 -0
  59. package/dist/esm/types/components/Forms/TagLabelInput/index.d.ts +1 -0
  60. package/dist/esm/types/components/InfoPanel/config.d.ts +2 -5
  61. package/dist/esm/types/components/InfoPanel/index.d.ts +7 -3
  62. package/dist/esm/types/components/Table/DataTable/DataTable.d.ts +4 -0
  63. package/dist/esm/types/components/Table/DataTable/SortableHeadCell.d.ts +11 -0
  64. package/dist/esm/types/components/Table/DataTable/configs.d.ts +5 -0
  65. package/dist/esm/types/components/Table/DataTable/index.d.ts +5 -0
  66. package/dist/esm/types/components/Table/DataTable/types.d.ts +100 -0
  67. package/dist/esm/types/components/Table/DataTable/useDataTable.d.ts +4 -0
  68. package/dist/esm/types/components/Table/DataTable/utils.d.ts +7 -0
  69. package/dist/esm/types/components/Table/index.d.ts +2 -0
  70. package/dist/esm/types/components/TagLabel/configs.d.ts +8 -1
  71. package/dist/esm/types/components/index.d.ts +5 -1
  72. package/dist/esm/types/stories/Button/Button.stories.d.ts +19 -0
  73. package/dist/esm/types/stories/Form/LiveSearch/Livesearch.stories.d.ts +1 -0
  74. package/dist/esm/types/stories/Form/LiveSearch/Livesearch.test.stories.d.ts +3 -0
  75. package/dist/esm/types/stories/Form/TagLabelInput/TagLabelInput.stories.d.ts +13 -0
  76. package/dist/esm/types/stories/InfoPanel/InfoPanel.stories.d.ts +95 -1
  77. package/dist/esm/types/stories/InfoPanel/InfoPanel.test.stories.d.ts +33 -0
  78. package/dist/esm/types/stories/PaginationBar/PaginationBar.test.stories.d.ts +27 -0
  79. package/dist/esm/types/stories/Table/DataTable.stories.d.ts +245 -0
  80. package/dist/esm/types/stories/Table/DataTable.test.stories.d.ts +76 -0
  81. package/dist/esm/types/stories/Table/useTableDataHandler.test.stories.d.ts +19 -0
  82. package/dist/esm/types/stories/TagLabel/TagLabel.stories.d.ts +4 -0
  83. package/dist/esm/types/stories/TagLabel/TagLabel.test.stories.d.ts +38 -0
  84. package/dist/esm/types/stories/Tooltip/Tooltip.stories.d.ts +19 -0
  85. package/dist/esm/types/stories/Tooltip/Tooltip.test.stories.d.ts +33 -0
  86. package/dist/esm/types/stories/Utility/Formatters.stories.d.ts +18 -0
  87. package/dist/esm/types/stories/Utility/Formatters.test.stories.d.ts +21 -0
  88. package/dist/esm/types/stories/Utility/cleanParams.stories.d.ts +33 -0
  89. package/dist/esm/types/stories/Utility/filterSamples.d.ts +62 -0
  90. package/dist/esm/types/stories/Utility/useAppliedFilter.stories.d.ts +46 -0
  91. package/dist/esm/types/stories/Utility/useDebounce.stories.d.ts +31 -0
  92. package/dist/esm/types/stories/Utility/useDebounce.test.stories.d.ts +19 -0
  93. package/dist/esm/types/stories/Utility/usePersistentState.stories.d.ts +44 -0
  94. package/dist/esm/types/stories/Utility/usePersistentState.test.stories.d.ts +21 -0
  95. package/dist/esm/types/utility/hooks/useAppliedFilter.d.ts +19 -0
  96. package/dist/esm/types/utility/hooks/useDebounce.d.ts +3 -0
  97. package/dist/esm/types/utility/hooks/usePersistentState.d.ts +8 -0
  98. package/dist/esm/types/utility/hooks/useTableDataHandler.d.ts +1 -1
  99. package/dist/esm/types/utility/index.d.ts +8 -0
  100. package/dist/esm/types/utility/public/filterParams.d.ts +4 -0
  101. package/dist/esm/types/utility/public/formatters.d.ts +2 -0
  102. package/dist/esm/types/utility/public/highlightMatch.d.ts +3 -0
  103. package/dist/index.d.ts +160 -7
  104. package/package.json +1 -1
package/dist/cjs/index.js CHANGED
@@ -321,7 +321,7 @@ var useDetectOutsideClick = function (ref, initialState, ignoreRef, event) {
321
321
  return [isActive, setIsActive];
322
322
  };
323
323
 
324
- var variantUnion$1 = [
324
+ var variantUnion$2 = [
325
325
  'normal-text', // default
326
326
  'large-text',
327
327
  'large-text-semibold',
@@ -341,7 +341,7 @@ var variantUnion$1 = [
341
341
  ];
342
342
  function Text(_a) {
343
343
  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);
344
+ var validatedVariant = validUnion(variant, variantUnion$2);
345
345
  var defaultColor = extended.includes('text-bia') || (className === null || className === void 0 ? void 0 : className.includes('text-bia'))
346
346
  ? ''
347
347
  : 'text-bia-black';
@@ -482,6 +482,12 @@ var minWidthConfig$1 = {
482
482
  sm: 'min-w-[72px]',
483
483
  tn: 'min-w-[64px]',
484
484
  };
485
+ var iconSizeConfig = {
486
+ lg: 22,
487
+ md: 18,
488
+ sm: 14,
489
+ tn: 14,
490
+ };
485
491
  var iconOnlySizeConfig$1 = {
486
492
  lg: 'py-[13px] h-[48px] w-[48px] flex items-center justify-center gap-[10px]',
487
493
  md: 'py-[11px] h-[40px] w-[40px] flex items-center justify-center gap-[5px]',
@@ -535,7 +541,7 @@ var BUTTON_VARIANT_UNION = [
535
541
  var RADIUS_UNION = ['default', 'full-rounded'];
536
542
  var SIZE_UNION = ['md', 'lg', 'sm', 'tn'];
537
543
  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"]);
544
+ 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
545
  var validatedVariant = validUnion(variant, BUTTON_VARIANT_UNION);
540
546
  var validatedSize = validUnion(size, SIZE_UNION);
541
547
  var validatedRadius = validUnion(radius, RADIUS_UNION);
@@ -548,10 +554,22 @@ var Button = React.forwardRef(function (_a, ref) {
548
554
  if (React.isValidElement(element)) {
549
555
  var iconProps = element.props;
550
556
  var existingClassName = iconProps.className || '';
551
- return React.cloneElement(element, {
552
- className: __spreadArray(__spreadArray([], variantTextColorClasses, true), [existingClassName], false).filter(Boolean)
553
- .join(' '),
554
- });
557
+ var hasOwnSize = iconProps.size !== undefined ||
558
+ iconProps.width !== undefined ||
559
+ iconProps.height !== undefined;
560
+ var px = iconSize !== null && iconSize !== void 0 ? iconSize : iconSizeConfig[validatedSize];
561
+ var sizeProps = {};
562
+ if (iconSize !== undefined || !hasOwnSize) {
563
+ if (element.type === 'svg') {
564
+ sizeProps.width = px;
565
+ sizeProps.height = px;
566
+ }
567
+ else if (typeof element.type !== 'string') {
568
+ sizeProps.size = px;
569
+ }
570
+ }
571
+ return React.cloneElement(element, __assign(__assign({}, sizeProps), { className: __spreadArray(__spreadArray([], variantTextColorClasses, true), [existingClassName], false).filter(Boolean)
572
+ .join(' ') }));
555
573
  }
556
574
  return element;
557
575
  };
@@ -596,6 +614,7 @@ Button.defaultProps = {
596
614
  variant: 'default',
597
615
  iconLeft: undefined,
598
616
  iconRight: undefined,
617
+ iconSize: undefined,
599
618
  left: undefined,
600
619
  right: undefined,
601
620
  };
@@ -2249,17 +2268,31 @@ var TooltipItem = function (_a) {
2249
2268
  };
2250
2269
  function Tooltip(props) {
2251
2270
  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;
2271
+ var timeoutRef = React.useRef(null);
2253
2272
  var _d = React.useState(false), active = _d[0], setActive = _d[1];
2254
2273
  var anchorRef = React.useRef(null);
2255
2274
  var tooltipContainerRef = React.useRef(null);
2275
+ var clearTimer = function () {
2276
+ if (timeoutRef.current !== null) {
2277
+ clearTimeout(timeoutRef.current);
2278
+ timeoutRef.current = null;
2279
+ }
2280
+ };
2281
+ React.useEffect(function () { return function () {
2282
+ if (timeoutRef.current !== null) {
2283
+ clearTimeout(timeoutRef.current);
2284
+ timeoutRef.current = null;
2285
+ }
2286
+ }; }, []);
2256
2287
  var showTip = function () {
2257
- timeout = setTimeout(function () {
2288
+ clearTimer();
2289
+ timeoutRef.current = setTimeout(function () {
2290
+ timeoutRef.current = null;
2258
2291
  setActive(true);
2259
2292
  }, delay || 400);
2260
2293
  };
2261
2294
  var hideTip = function () {
2262
- clearInterval(timeout);
2295
+ clearTimer();
2263
2296
  setActive(false);
2264
2297
  };
2265
2298
  return (React.createElement("div", { className: "tooltip-wrapper relative inline-flex h-fit w-fit flex-col", onMouseEnter: showTip, onMouseLeave: hideTip, ref: anchorRef },
@@ -2283,7 +2316,7 @@ function FormLabel(_a) {
2283
2316
 
2284
2317
  function PasswordIcon(_a) {
2285
2318
  var isShow = _a.isShow, showHandler = _a.showHandler, iconSize = _a.iconSize, disabled = _a.disabled;
2286
- var iconColor = disabled ? '#8b8ba6' : '#5E5EEA';
2319
+ var iconColor = disabled ? '#8c8ca6' : '#5E5EEA';
2287
2320
  if (isShow) {
2288
2321
  return (React.createElement(TbEye, { onClick: function () { return showHandler(false); }, style: {
2289
2322
  fontSize: iconSize,
@@ -2379,7 +2412,7 @@ var TextInput = React.forwardRef(function (_a, ref) {
2379
2412
  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
2413
  label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
2381
2414
  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: {
2415
+ 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
2416
  paddingRight: iconElement
2384
2417
  ? "".concat(10 + Number(iconSize), "px")
2385
2418
  : undefined,
@@ -2425,10 +2458,10 @@ var sizeConfig$c = {
2425
2458
  },
2426
2459
  };
2427
2460
 
2428
- var sizeUnion$4 = ['md', 'sm', 'tn'];
2461
+ var sizeUnion$5 = ['md', 'sm', 'tn'];
2429
2462
  var Radio = React.forwardRef(function Radio(_a, ref) {
2430
2463
  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);
2464
+ var validatedSize = validUnion(size, sizeUnion$5);
2432
2465
  var _p = sizeConfig$c[validatedSize], checkSize = _p.checkSize, labelSize = _p.labelSize;
2433
2466
  var backgroundClass = size === 'tn' && checked ? 'bg-bia-blue' : 'bg-bia-white';
2434
2467
  var peerCheckedClass = size === 'tn'
@@ -2439,8 +2472,8 @@ var Radio = React.forwardRef(function Radio(_a, ref) {
2439
2472
  : 'focus-visible:ring-offset-2';
2440
2473
  return (React.createElement("div", { className: cn$1('flex items-center', containerClassName) },
2441
2474
  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) })),
2475
+ 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 }),
2476
+ 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
2477
  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
2478
  });
2446
2479
  Radio.defaultProps = {
@@ -2501,7 +2534,7 @@ function TextAreaInner(_a, ref) {
2501
2534
  label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
2502
2535
  React.createElement("div", { className: "relative h-fit w-full min-w-[250px] ".concat(disabledClass) },
2503
2536
  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))),
2537
+ 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
2538
  React.createElement("div", { className: "desc flex justify-between gap-1 text-xs ".concat(descColor) },
2506
2539
  descText && React.createElement("span", null, descText),
2507
2540
  maxLength && (React.createElement("span", null,
@@ -2527,18 +2560,18 @@ var sizeConfig$a = {
2527
2560
  },
2528
2561
  };
2529
2562
 
2530
- var sizeUnion$3 = ['md', 'sm', 'tn'];
2563
+ var sizeUnion$4 = ['md', 'sm', 'tn'];
2531
2564
  function Checkbox(_a) {
2532
2565
  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;
2566
+ var _h = sizeConfig$a[validUnion(size, sizeUnion$4)], checkClass = _h.checkClass, labelClass = _h.labelClass;
2534
2567
  var isValidIndeterminate = isIndeterminate && props.checked;
2535
2568
  var backgroundClass = size === 'tn' && props.checked ? 'bg-bia-blue' : 'bg-bia-white';
2536
2569
  var peerCheckedClass = size === 'tn' ? '' : 'peer-checked:border-2';
2537
2570
  return (React.createElement("div", { className: "inline-flex items-center" },
2538
2571
  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)))));
2572
+ 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)),
2573
+ 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 })))),
2574
+ label && (React.createElement("label", { htmlFor: id, className: "ml-2 leading-4 text-primary-black ".concat(disabled ? '!text-bia-coolgrey' : '', " ").concat(labelClass) }, childrenElement(label)))));
2542
2575
  }
2543
2576
 
2544
2577
  var sizeConfig$9 = {
@@ -2691,12 +2724,12 @@ var getItemLabel = function (value) {
2691
2724
  return isObjectWithLabel(value) ? ((_a = value.label) !== null && _a !== void 0 ? _a : '') : String(value !== null && value !== void 0 ? value : '');
2692
2725
  };
2693
2726
 
2694
- var sizeUnion$2 = ['md', 'sm'];
2727
+ var sizeUnion$3 = ['md', 'sm'];
2695
2728
  function SelectInput(_a) {
2696
2729
  var _b;
2697
2730
  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
2731
  var _u = React.useState(false), isOpen = _u[0], setIsOpen = _u[1];
2699
- var validatedSize = validUnion(size, sizeUnion$2);
2732
+ var validatedSize = validUnion(size, sizeUnion$3);
2700
2733
  var _v = sizeConfig$9[validatedSize], searchSize = _v.searchSize, iconSize = _v.iconSize;
2701
2734
  var inputRef = React.useRef(null);
2702
2735
  var selectedLabel = selected !== undefined && isObjectWithLabel(selected)
@@ -2713,7 +2746,7 @@ function SelectInput(_a) {
2713
2746
  return (React.createElement("div", { className: "bianic-fgc-container bianic-text-input-container field-group flex w-full flex-col gap-y-2" },
2714
2747
  label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
2715
2748
  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)),
2749
+ 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 }, props)),
2717
2750
  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
2751
  children === undefined && isOpen && (
2719
2752
  // Consumer-provided click-catcher; each rendered option below is its own interactive control
@@ -2937,6 +2970,21 @@ var useLiveSearch$1 = function (_a) {
2937
2970
  setIsOpen(true);
2938
2971
  onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(e);
2939
2972
  };
2973
+ var handleCancel = React.useCallback(function () {
2974
+ setIsOpen(false);
2975
+ setSearchTerm(getItemLabel(value));
2976
+ }, [value]);
2977
+ var handleClear = React.useCallback(function (inputEl) {
2978
+ setSearchTerm('');
2979
+ setValue({ id: null, label: '' });
2980
+ setIsOpen(false);
2981
+ // Tell the app the search text is now empty, as if the user deleted it
2982
+ onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText({
2983
+ target: { value: '' },
2984
+ currentTarget: { value: '' },
2985
+ });
2986
+ inputEl === null || inputEl === void 0 ? void 0 : inputEl.focus();
2987
+ }, [setValue, onChangeText]);
2940
2988
  var handleDropdownItemClick = React.useCallback(function (event, clickedValue) {
2941
2989
  dropContOnClickItem === null || dropContOnClickItem === void 0 ? void 0 : dropContOnClickItem(event, clickedValue);
2942
2990
  var newLabel = getItemLabel(clickedValue);
@@ -2949,21 +2997,37 @@ var useLiveSearch$1 = function (_a) {
2949
2997
  setIsOpen: setIsOpen,
2950
2998
  searchTerm: searchTerm,
2951
2999
  handleInputChange: handleInputChange,
3000
+ handleCancel: handleCancel,
3001
+ handleClear: handleClear,
2952
3002
  handleDropdownItemClick: handleDropdownItemClick,
2953
3003
  };
2954
3004
  };
2955
3005
 
2956
3006
  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;
3007
+ 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
3008
  var inputRef = React.useRef(null);
2959
- var _u = useLiveSearch$1({
3009
+ var wrapperRef = React.useRef(null);
3010
+ var _v = useLiveSearch$1({
2960
3011
  value: value,
2961
3012
  setValue: setValue,
2962
3013
  onChangeText: onChangeText,
2963
3014
  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"]);
3015
+ }), isOpen = _v.isOpen, setIsOpen = _v.setIsOpen, searchTerm = _v.searchTerm, handleInputChange = _v.handleInputChange, handleCancel = _v.handleCancel, handleClear = _v.handleClear, handleDropdownItemClick = _v.handleDropdownItemClick;
3016
+ // The plain `options` list has no overlay, so close it when the user clicks away.
3017
+ // The `children` list is closed by its own overlay.
3018
+ React.useEffect(function () {
3019
+ if (!isOpen || children !== undefined)
3020
+ return undefined;
3021
+ var onMouseDown = function (e) {
3022
+ var _a;
3023
+ if (!((_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target)))
3024
+ handleCancel();
3025
+ };
3026
+ document.addEventListener('mousedown', onMouseDown);
3027
+ return function () { return document.removeEventListener('mousedown', onMouseDown); };
3028
+ }, [isOpen, children, handleCancel]);
3029
+ var _w = sizeConfig$7[size], iconClass = _w.iconClass, iconSize = _w.iconSize, inputClass = _w.inputClass;
3030
+ var _x = dropContProps || {}, dropContClassName = _x.className; _x.onClickItem; _x.anchorRef; var restDropContProps = __rest(_x, ["className", "onClickItem", "anchorRef"]);
2967
3031
  var isSearchTermExist = searchTerm && searchTerm !== '';
2968
3032
  var descColor = 'text-primary-cool';
2969
3033
  var isExistValidation = isValid !== null && isValid !== undefined;
@@ -2972,12 +3036,15 @@ function LiveSearch(_a) {
2972
3036
  if (!disabled && isExistValidation && !isValid)
2973
3037
  descColor = 'text-bia-red';
2974
3038
  var filteredOptions = filterOptions(options || [], getItemLabel(value));
2975
- var _x = processRenderedChildren$1(children, searchTerm, searchVariant, handleDropdownItemClick), renderedChildren = _x.renderedChildren, hasFilteredResults = _x.hasFilteredResults;
3039
+ var _y = processRenderedChildren$1(children, searchTerm, searchVariant, handleDropdownItemClick), renderedChildren = _y.renderedChildren, hasFilteredResults = _y.hasFilteredResults;
2976
3040
  var disabledClass = disabled ? 'cursor-not-allowed' : '';
2977
3041
  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
3042
  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) {
3043
+ React.createElement("div", { ref: wrapperRef, className: "group relative w-full ".concat(disabledClass) },
3044
+ 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: function (e) {
3045
+ if (e.key === 'Escape' && isOpen)
3046
+ handleCancel();
3047
+ }, onChange: function (e) {
2981
3048
  onChangeText(e);
2982
3049
  handleInputChange(e);
2983
3050
  }, type: "text", readOnly: readOnly, autoComplete: autoComplete }),
@@ -2987,7 +3054,7 @@ function LiveSearch(_a) {
2987
3054
  : 20,
2988
3055
  } },
2989
3056
  !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 },
3057
+ 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
3058
  React.createElement(TbX, { className: "text-primary-black", style: { fontSize: iconSize } }))),
2992
3059
  isSearchTermExist && onChangeButton),
2993
3060
  children === undefined && isOpen && (
@@ -3009,7 +3076,10 @@ function LiveSearch(_a) {
3009
3076
  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
3077
  ? renderedChildren
3011
3078
  : // 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.") }))))),
3079
+ searchTerm.length > 0 &&
3080
+ (noResultsContent !== undefined ? (React.createElement("div", { className: "bianic-livesearch-no-results" }, typeof noResultsContent === 'function'
3081
+ ? noResultsContent(searchTerm)
3082
+ : noResultsContent)) : (React.createElement(DropdownItem, { content: React.createElement("div", { className: "px-4 py-2 text-gray-500" }, "Tidak ada hasil ditemukan.") })))))),
3013
3083
  descText && (React.createElement("span", { className: "bianic-livesearch-desc bianic-text-input-desc text-xs ".concat(descColor) }, descText))));
3014
3084
  }
3015
3085
 
@@ -3147,15 +3217,21 @@ var colorConfig$1 = {
3147
3217
  white: 'bg-primary-white text-primary-black border border-primary-black',
3148
3218
  };
3149
3219
  var sizeConfig$5 = {
3150
- md: 'px-[10px] py-[7px] h-[34px] text-size-base',
3220
+ md: 'px-[7px] py-[3px] h-[24px] text-size-base',
3151
3221
  sm: 'px-[10px] py-[4px] h-[22px] text-size-sm',
3152
3222
  tn: 'px-[8px] py-[2px] h-[18px] text-size-sm',
3153
3223
  };
3154
3224
  var iconOnlySizeConfig = {
3155
- md: 'p-[7px]',
3225
+ md: 'p-[4px]',
3156
3226
  sm: 'p-[4px]',
3157
3227
  tn: 'p-[2px]',
3158
3228
  };
3229
+ // md icon-only with a 1px border: 3px padding + 1px border keeps the box 24x24
3230
+ var iconOnlyBorderSizeConfig = {
3231
+ md: 'p-[3px]',
3232
+ sm: iconOnlySizeConfig.sm,
3233
+ tn: iconOnlySizeConfig.tn,
3234
+ };
3159
3235
  var closeColorConfig = {
3160
3236
  default: 'bg-bia-grey-dark-30 text-primary-white',
3161
3237
  blue: 'bg-bia-white-transparent-50 text-bia-blue',
@@ -3167,15 +3243,46 @@ var closeColorConfig = {
3167
3243
  white: 'bg-bia-grey-dark-30 text-primary-white',
3168
3244
  };
3169
3245
  var closeSizeConfig = {
3170
- md: 'w-[18px] h-[18px] text-[14px]',
3246
+ md: 'w-[14px] h-[14px] text-[11px]',
3171
3247
  sm: 'w-[12px] h-[12px] text-[9.33px]',
3172
3248
  tn: 'w-[12px] h-[12px] text-[9.33px]',
3173
3249
  };
3174
3250
  var rightPaddingConfig = {
3175
- md: 'pr-[8px]',
3251
+ md: 'pr-[5px]',
3176
3252
  sm: 'pr-[5px]',
3177
3253
  tn: 'pr-[3px]',
3178
3254
  };
3255
+ var monospaceSizeConfig = {
3256
+ md: 'px-[8px] py-[3px] h-[24px] text-size-base',
3257
+ sm: sizeConfig$5.sm,
3258
+ tn: sizeConfig$5.tn,
3259
+ };
3260
+ var gapConfig = {
3261
+ md: 'gap-x-0',
3262
+ sm: 'gap-x-[5px]',
3263
+ tn: 'gap-x-[5px]',
3264
+ };
3265
+ var monospaceGapConfig = {
3266
+ md: 'gap-x-[3px]',
3267
+ sm: 'gap-x-[5px]',
3268
+ tn: 'gap-x-[5px]',
3269
+ };
3270
+ var textPaddingConfig = {
3271
+ md: 'px-[5px]',
3272
+ sm: '',
3273
+ tn: '',
3274
+ };
3275
+ // 1em icons become 16px at md; an icon with its own size keeps it
3276
+ var iconWrapperConfig = {
3277
+ md: 'text-[16px]',
3278
+ sm: '',
3279
+ tn: '',
3280
+ };
3281
+ var rightIconWrapperConfig = {
3282
+ md: 'flex items-center text-[16px]',
3283
+ sm: 'block',
3284
+ tn: 'block',
3285
+ };
3179
3286
 
3180
3287
  var colorUnion$1 = [
3181
3288
  'default',
@@ -3188,8 +3295,8 @@ var colorUnion$1 = [
3188
3295
  'white',
3189
3296
  'custom',
3190
3297
  ];
3191
- var sizeUnion$1 = ['md', 'sm', 'tn'];
3192
- var variantUnion = ['label', 'icon', 'closeable', 'monospace'];
3298
+ var sizeUnion$2 = ['md', 'sm', 'tn'];
3299
+ var variantUnion$1 = ['label', 'icon', 'closeable', 'monospace'];
3193
3300
  function TagLabel(_a) {
3194
3301
  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
3302
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
@@ -3198,8 +3305,8 @@ function TagLabel(_a) {
3198
3305
  _a.right;
3199
3306
  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
3307
  var validatedColor = validUnion(color, colorUnion$1);
3201
- var validatedSize = validUnion(size, sizeUnion$1);
3202
- var validatedVariant = validUnion(variant, variantUnion);
3308
+ var validatedSize = validUnion(size, sizeUnion$2);
3309
+ var validatedVariant = validUnion(variant, variantUnion$1);
3203
3310
  var containerRef = React.useRef(null);
3204
3311
  var _r = React.useState(null), sizeCount = _r[0], setSizeCount = _r[1];
3205
3312
  React.useEffect(function () {
@@ -3221,9 +3328,19 @@ function TagLabel(_a) {
3221
3328
  var defaultIconSize = validatedSize === 'md' ? 'text-xl' : 'text-sm';
3222
3329
  var borderColorRules = outlineColor || bgColor;
3223
3330
  var roundedClass = validatedVariant === 'icon' ? 'rounded-full' : 'rounded-[50px]';
3224
- var sizeClass = validatedVariant === 'icon'
3225
- ? iconOnlySizeConfig[validatedSize]
3226
- : sizeConfig$5[validatedSize];
3331
+ var sizeKey = validatedSize;
3332
+ var isMonospace = validatedVariant === 'monospace';
3333
+ var sizeClass = sizeConfig$5[validatedSize];
3334
+ var hasBorder = validatedColor === 'white' || validatedColor === 'custom';
3335
+ if (validatedVariant === 'icon')
3336
+ sizeClass = cn$1(hasBorder
3337
+ ? iconOnlyBorderSizeConfig[sizeKey]
3338
+ : iconOnlySizeConfig[validatedSize]);
3339
+ else if (isMonospace)
3340
+ sizeClass = monospaceSizeConfig[sizeKey];
3341
+ var gapClass = isMonospace
3342
+ ? monospaceGapConfig[sizeKey]
3343
+ : gapConfig[sizeKey];
3227
3344
  var isCloseableClass = isCloseable && rightPaddingConfig[validatedSize];
3228
3345
  var colorClass = validatedColor === 'custom'
3229
3346
  ? "bg-bia-".concat(bgColor, " text-bia-").concat(textColor, " border border-bia-").concat(borderColorRules)
@@ -3231,8 +3348,8 @@ function TagLabel(_a) {
3231
3348
  var blockclass = isBlock && validatedVariant !== 'icon' ? 'w-full' : "w-fit";
3232
3349
  var maxWidthStyle = !isBlock ? "".concat(maxWidth, "px") : '';
3233
3350
  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);
3351
+ var fontClass = isMonospace ? 'font-sans-code' : 'font-segoe pb-[1px]';
3352
+ var textClass = cn$1(alignTextClass, fontClass, !isMonospace && textPaddingConfig[sizeKey]);
3236
3353
  var containerClass = "".concat(sizeClass, " ").concat(colorClass, " ").concat(roundedClass, " ").concat(isCloseableClass, " ").concat(blockclass);
3237
3354
  var closeColor = closeColorConfig[validatedColor];
3238
3355
  if (validatedColor === 'custom') {
@@ -3242,29 +3359,29 @@ function TagLabel(_a) {
3242
3359
  }
3243
3360
  var closeClass = "".concat(closeColor, " ").concat(closeSizeConfig[validatedSize]);
3244
3361
  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: {
3362
+ return (isOpen && (React.createElement("div", __assign({ className: "tag-label flex items-center ".concat(gapClass, " text-size-base ").concat(containerClass), style: {
3246
3363
  maxWidth: maxWidthStyle,
3247
3364
  } }, props),
3248
3365
  leftIcon && (React.createElement("div", { style: {
3249
3366
  width: "".concat(sizeCount, "px"),
3250
3367
  height: "".concat(sizeCount, "px"),
3251
- }, className: "flex items-center justify-center", ref: containerRef }, leftIcon ||
3368
+ }, className: cn$1('flex items-center justify-center', iconWrapperConfig[sizeKey]), ref: containerRef }, leftIcon ||
3252
3369
  (validatedVariant === 'icon' && (React.createElement(TbCheck, { className: defaultIconSize }))))),
3253
3370
  validatedVariant !== 'icon' && text && (React.createElement("span", { className: "w-full truncate ".concat(textClass) }, text)),
3254
- validatedVariant === 'label' && rightIcon && (React.createElement("div", { className: "block" },
3371
+ validatedVariant === 'label' && rightIcon && (React.createElement("div", { className: rightIconWrapperConfig[sizeKey] },
3255
3372
  " ",
3256
3373
  rightIcon,
3257
3374
  " ")),
3258
- isCloseable && (React.createElement("button", { type: "button", onClick: closeHandler, className: "flex aspect-square items-center justify-center rounded-full pt-[1px] ".concat(closeClass) },
3375
+ 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
3376
  React.createElement(TbX, null))))));
3260
3377
  }
3261
3378
 
3262
3379
  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"]);
3380
+ 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
3381
  var generatedId = React.useId();
3265
3382
  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];
3383
+ var _q = React.useState(false), isFocused = _q[0], setIsFocused = _q[1];
3384
+ var _r = React.useState(false), isHovered = _r[0], setIsHovered = _r[1];
3268
3385
  var internalInputRef = React.useRef(null);
3269
3386
  var containerRef = React.useRef(null);
3270
3387
  React.useImperativeHandle(ref, function () { return internalInputRef.current; });
@@ -3288,12 +3405,12 @@ function TagLabelInputInner(_a, ref) {
3288
3405
  var updatedValues = value.filter(function (_, idx) { return idx !== indexToRemove; });
3289
3406
  onChange(updatedValues);
3290
3407
  };
3291
- var _r = useLiveSearch({
3408
+ var _s = useLiveSearch({
3292
3409
  value: value,
3293
3410
  setValue: onChange,
3294
3411
  onChangeText: onChangeText,
3295
3412
  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;
3413
+ }), isOpen = _s.isOpen, setIsOpen = _s.setIsOpen, searchTerm = _s.searchTerm, handleInputChange = _s.handleInputChange, handleDropdownItemClick = _s.handleDropdownItemClick;
3297
3414
  var handleKeyDown = function (e) {
3298
3415
  var _a;
3299
3416
  if (e.key === 'Backspace' && searchTerm === '' && value.length > 0) {
@@ -3326,9 +3443,9 @@ function TagLabelInputInner(_a, ref) {
3326
3443
  if (!disabled && isExistValidation) {
3327
3444
  descColor = isValid ? 'text-bia-green' : 'text-bia-red';
3328
3445
  }
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;
3446
+ var _t = sizeConfig$6[size], inputClass = _t.inputClass, paddingClass = _t.paddingClass, resizePosition = _t.resizePosition;
3447
+ var _u = dropContProps || {}, dropContClassName = _u.className, restDropContProps = __rest(_u, ["className"]);
3448
+ var _v = processRenderedChildren(children, searchTerm, 'include', handleDropdownItemClick, value), renderedChildren = _v.renderedChildren, hasFilteredResults = _v.hasFilteredResults;
3332
3449
  var showPlaceholder = !disabled && !readOnly && value.length === 0;
3333
3450
  console.log('showPlaceholder', showPlaceholder);
3334
3451
  return (React.createElement("div", { className: cn$1('relative w-full', className) },
@@ -3342,7 +3459,7 @@ function TagLabelInputInner(_a, ref) {
3342
3459
  handleBlur(e);
3343
3460
  onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
3344
3461
  }, 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'
3462
+ ? 'cursor-not-allowed bg-bia-grey-light-80 text-bia-coolgrey'
3346
3463
  : 'cursor-text', !disabled &&
3347
3464
  !readOnly &&
3348
3465
  'focus-within:rounded-b-none hover:rounded-b-none', isFocused && !disabled && !readOnly && 'rounded-b-none', getBottomBorderColor(), paddingClass) },
@@ -3357,7 +3474,10 @@ function TagLabelInputInner(_a, ref) {
3357
3474
  description && (React.createElement("p", { className: cn$1('mt-1.5 text-xs transition-colors', descColor) }, description)),
3358
3475
  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
3476
  ? renderedChildren
3360
- : searchTerm.length > 0 && (React.createElement(DropdownItem, { content: React.createElement("div", { className: "px-4 py-2 text-gray-500" }, "Tidak ada hasil ditemukan.") }))))));
3477
+ : searchTerm.length > 0 &&
3478
+ (noResultsContent !== undefined ? (React.createElement("div", { className: "bianic-taglabelinput-no-results" }, typeof noResultsContent === 'function'
3479
+ ? noResultsContent(searchTerm)
3480
+ : noResultsContent)) : (React.createElement(DropdownItem, { content: React.createElement("div", { className: "px-4 py-2 text-gray-500" }, "Tidak ada hasil ditemukan.") })))))));
3361
3481
  }
3362
3482
  var TagLabelInput = React.forwardRef(TagLabelInputInner);
3363
3483
 
@@ -3392,9 +3512,9 @@ function Toggle(_a) {
3392
3512
  var containerClass = "".concat(checkedClass, " ").concat(containerSize);
3393
3513
  return (React.createElement("div", { className: "flex items-center" },
3394
3514
  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" }),
3515
+ 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
3516
  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)));
3517
+ React.createElement("label", { htmlFor: id, className: "ml-2 leading-4 text-bia-black ".concat(disabled ? '!text-bia-coolgrey' : '', " ").concat(labelClass) }, label)));
3398
3518
  }
3399
3519
 
3400
3520
  var isSelectedConfig = {
@@ -3434,7 +3554,7 @@ function SegmentButtonItem(_a) {
3434
3554
  : "".concat(sizeConfig$3[size], " ").concat(minWidthConfig[size], " ").concat(minHeightConfig[size]);
3435
3555
  var radiusStyle = "".concat(roundedConfig[size]);
3436
3556
  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));
3557
+ 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-coolgrey ".concat(selectedStyle, " ").concat(radiusStyle, " ").concat(sizingStyle, " ").concat(className) }, children));
3438
3558
  }
3439
3559
 
3440
3560
  function SegmentButtonGroup(_a) {
@@ -3442,10 +3562,10 @@ function SegmentButtonGroup(_a) {
3442
3562
  return React.createElement("div", { className: "flex" }, children);
3443
3563
  }
3444
3564
 
3445
- var sizeUnion = ['md', 'sm'];
3565
+ var sizeUnion$1 = ['md', 'sm'];
3446
3566
  function FormGroup(_a) {
3447
3567
  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);
3568
+ var validSize = validUnion(size, sizeUnion$1);
3449
3569
  return (React.createElement("div", { className: "bianic-form-group flex items-end" }, React.Children.map(children, function (child) {
3450
3570
  var _a;
3451
3571
  if (!React.isValidElement(child))
@@ -4260,7 +4380,7 @@ var DateInputDisplay = React.forwardRef(function (_a, ref) {
4260
4380
  e.preventDefault();
4261
4381
  setIsEditing(true);
4262
4382
  }
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),
4383
+ }, 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
4384
  React.createElement("div", { className: "absolute inset-y-0 flex items-center pl-3 text-bia-coolgrey ".concat(iconPosition) },
4265
4385
  React.createElement("button", { type: "button", className: "bianic-datepicker-toggle-button", disabled: disabled, onClick: function () { return buttonAction && buttonAction(); } },
4266
4386
  React.createElement(TbCalendar, { size: iconSize })))));
@@ -4399,7 +4519,7 @@ var YearPickerDisplay = React.forwardRef(function (_a, ref) {
4399
4519
  if (!disabled)
4400
4520
  setIsEditing(true);
4401
4521
  }
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),
4522
+ }, 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
4523
  React.createElement("div", { className: "absolute inset-y-0 right-0 flex items-center pl-3 text-bia-coolgrey ".concat(iconPosition) },
4404
4524
  React.createElement("button", { type: "button", className: "bianic-datepicker-toggle-button", disabled: disabled, onClick: function () { return buttonAction && buttonAction(); } },
4405
4525
  React.createElement(TbCalendar, { size: iconSize })))));
@@ -4665,9 +4785,11 @@ function DropzoneFileUploader(_a) {
4665
4785
  e.preventDefault();
4666
4786
  triggerClick();
4667
4787
  }
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
4788
+ }, 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 &&
4789
+ '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
4790
  ? 'bg-blue-50/50 border-bia-blue'
4670
4791
  : !activeError &&
4792
+ !disabled &&
4671
4793
  'border-bia-grey-dark-10 hover:border-bia-blue hover:bg-gray-50') },
4672
4794
  React.createElement(TbPhotoUp, { size: 36, className: "mb-2 text-bia-coolgrey" }),
4673
4795
  React.createElement("div", { className: "mb-3 flex flex-col items-center justify-center" },
@@ -4894,34 +5016,62 @@ function VirtualPort(_a) {
4894
5016
  }
4895
5017
 
4896
5018
  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',
5019
+ yellow: 'bg-bia-yellow-light-80 text-bia-black',
5020
+ blue: 'bg-bia-sky-light-90 text-bia-black',
5021
+ green: 'bg-bia-green-light-90 text-bia-black',
5022
+ grey: 'bg-bia-grey-light-80 text-bia-black',
5023
+ white: 'bg-bia-white border border-bia-grey text-bia-black',
4901
5024
  };
4902
5025
  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]',
5026
+ container: 'min-h-fit p-5 text-wrap text-size-base leading-[21px] rounded-radius-md',
5027
+ 'container-sm': 'min-h-fit p-[15px] text-wrap text-size-sm leading-4 rounded-radius-sm',
5028
+ 'form-md': 'min-h-[40px] h-fit whitespace-nowrap px-2.5 py-[9.5px] text-size-base leading-[21px] rounded-radius-md',
5029
+ 'form-sm': 'min-h-[30px] h-fit whitespace-nowrap p-[7px] text-size-sm leading-4 rounded-radius-sm',
4906
5030
  };
4907
5031
 
4908
- var colorUnion = ['yellow', 'blue', 'grey', 'white', 'custom'];
5032
+ var variantUnion = [
5033
+ 'container',
5034
+ 'form',
5035
+ 'form-sm',
5036
+ 'form-md',
5037
+ ];
5038
+ var sizeUnion = ['md', 'sm'];
5039
+ var colorUnion = [
5040
+ 'yellow',
5041
+ 'blue',
5042
+ 'green',
5043
+ 'grey',
5044
+ 'white',
5045
+ 'custom',
5046
+ ];
4909
5047
  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'];
5048
+ 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;
5049
+ var validVariant = validUnion(variant, variantUnion);
5050
+ var validSize = validUnion(size, sizeUnion);
5051
+ var sizeKey;
5052
+ if (validVariant === 'form') {
5053
+ sizeKey = "form-".concat(validSize);
5054
+ }
5055
+ else if (validVariant === 'container') {
5056
+ sizeKey = validSize === 'sm' ? 'container-sm' : 'container';
5057
+ }
5058
+ else {
5059
+ sizeKey = validVariant;
5060
+ }
5061
+ var sizeClass = sizeConfig$2[sizeKey];
4912
5062
  var validColor = validUnion(color, colorUnion);
4913
5063
  var presetColor = validColor === 'custom' ? 'yellow' : validColor;
4914
5064
  var colorClass = validColor === 'custom' && bgColor
4915
5065
  ? [
4916
5066
  "bg-bia-".concat(bgColor),
4917
- textColor && "text-bia-".concat(textColor),
5067
+ "text-bia-".concat(textColor || 'black'),
4918
5068
  outlineColor && "border border-bia-".concat(outlineColor),
4919
5069
  ]
4920
5070
  .filter(Boolean)
4921
5071
  .join(' ')
4922
5072
  : colorConfig[presetColor];
4923
5073
  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));
5074
+ return (React.createElement("div", { className: "flex items-center justify-center ".concat(allClasses) }, children));
4925
5075
  }
4926
5076
 
4927
5077
  function Modal(_a) {
@@ -5024,15 +5174,22 @@ function PaginationBar(_a) {
5024
5174
  var newPages = Array.from({ length: totalPages }, function (_, i) { return i + 1; }).slice(start, start + PAGE_SIZE);
5025
5175
  setShowedPages(newPages);
5026
5176
  }, [startIndex, totalPages]);
5177
+ React.useEffect(function () {
5178
+ if (totalPages > 0 && !showedPages.includes(currentPage)) {
5179
+ setStartIndex(Math.max(0, Math.min(currentPage - 1, totalPages - 5)));
5180
+ }
5181
+ // Only react to outside page changes, not to the window moving itself.
5182
+ // eslint-disable-next-line react-hooks/exhaustive-deps
5183
+ }, [currentPage, totalPages]);
5027
5184
  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 })),
5185
+ 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
5186
  React.createElement(Button, { variant: "subtle", size: size, type: "button", onClick: function () {
5030
5187
  handlePageChange(currentPage - 1);
5031
5188
  if (showedPages[0] === currentPage)
5032
5189
  setStartIndex(function (old) { return old - 1; });
5033
5190
  if (!showedPages.includes(currentPage))
5034
5191
  setStartIndex(currentPage - 2);
5035
- }, className: currentPage === 1 ? 'cursor-not-allowed' : 'cursor-pointer', iconLeft: React.createElement(TbChevronLeft, { size: iconSize }), disabled: currentPage === 1 }),
5192
+ }, className: currentPage === 1 ? 'cursor-not-allowed' : 'cursor-pointer', iconLeft: React.createElement(TbChevronLeft, { size: iconSize }), "aria-label": "Previous page", disabled: currentPage === 1 }),
5036
5193
  showedPages.map(function (page) {
5037
5194
  if (page === currentPage) {
5038
5195
  return React.createElement(SelectedPage, { key: page, label: page.toString(), size: size });
@@ -5047,10 +5204,10 @@ function PaginationBar(_a) {
5047
5204
  setStartIndex(function (old) { return old + 1; });
5048
5205
  if (!showedPages.includes(currentPage))
5049
5206
  setStartIndex(currentPage - 4);
5050
- }, className: currentPage === totalPages ? 'cursor-not-allowed' : 'cursor-pointer', iconLeft: React.createElement(TbChevronRight, { size: iconSize }), disabled: currentPage === totalPages }),
5207
+ }, className: currentPage === totalPages ? 'cursor-not-allowed' : 'cursor-pointer', iconLeft: React.createElement(TbChevronRight, { size: iconSize }), "aria-label": "Next page", disabled: currentPage === totalPages }),
5051
5208
  totalPages > 5 && (React.createElement(Button, { variant: "subtle", size: size, type: "button", onClick: handleNextRange, className: showedPages[showedPages.length - 1] === totalPages
5052
5209
  ? 'cursor-not-allowed'
5053
- : 'cursor-pointer', iconLeft: React.createElement(TbChevronsRight, { size: iconSize }), disabled: showedPages[showedPages.length - 1] === totalPages }))));
5210
+ : 'cursor-pointer', iconLeft: React.createElement(TbChevronsRight, { size: iconSize }), "aria-label": "Next pages", disabled: showedPages[showedPages.length - 1] === totalPages }))));
5054
5211
  }
5055
5212
 
5056
5213
  var activeConfig = {
@@ -5854,9 +6011,9 @@ var verticalAlignConfig = {
5854
6011
  bottom: 'align-bottom',
5855
6012
  };
5856
6013
  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"]);
6014
+ 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
6015
  var bottomLined = lined ? 'border-b border-bia-grey' : '';
5859
- var bgColorClass = "bg-bia-".concat(bgColor);
6016
+ var bgColorClass = bgColor ? "bg-bia-".concat(bgColor) : '';
5860
6017
  var isHead = variant === 'head';
5861
6018
  var textConfig = isHead ? headTextConfig[size] : bodyTextConfig[size];
5862
6019
  var columnClass = "p-0 h-[30px] ".concat(verticalAlignConfig[verticalAlign], " ").concat(sizeConfig[size], " ").concat(bottomLined, " ").concat(bgColorClass, " ").concat(textConfig, " ").concat(className);
@@ -5896,7 +6053,7 @@ function EmptyTable(_a) {
5896
6053
  React.createElement("img", { src: EmptyIcon, alt: "Empty State", style: { height: 72, width: 72 } }),
5897
6054
  React.createElement("div", { className: "mt-5 text-center" },
5898
6055
  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))))));
6056
+ subContent && (React.createElement(Text, { variant: "small-text", extended: "mt-2 block text-bia-coolgrey" }, subContent))))));
5900
6057
  }
5901
6058
 
5902
6059
  var tableSizeOption = [10, 20, 50, 100, 999];
@@ -5927,7 +6084,9 @@ function TableHeaderController(_a) {
5927
6084
  var paddingSize = size === 'md' ? 'py-[13px] pt-[14px] ' : 'py-[7px] pt-2';
5928
6085
  var textSize = size === 'md' ? 'normal-text' : 'small-text';
5929
6086
  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; }))),
6087
+ 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 (
6088
+ // eslint-disable-next-line react/no-array-index-key
6089
+ React.createElement(React.Fragment, { key: index }, button)); })),
5931
6090
  isShowHelperText && (React.createElement("div", { className: "flex max-h-[22px] items-center font-segoe" },
5932
6091
  React.createElement(Text, { variant: textSize, className: "text-bia-coolgrey" },
5933
6092
  "View ",
@@ -5946,6 +6105,444 @@ function TableSearchInput(_a) {
5946
6105
  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
6106
  }
5948
6107
 
6108
+ var ALL_PAGE_SIZE = 999;
6109
+ var alignConfig = {
6110
+ start: 'text-left',
6111
+ center: 'text-center',
6112
+ end: 'text-right',
6113
+ };
6114
+ var headerJustifyConfig = {
6115
+ start: 'justify-between',
6116
+ center: 'justify-center gap-[5px]',
6117
+ end: 'justify-end gap-[5px]',
6118
+ };
6119
+ var fitWidthConfig = {
6120
+ fit: 'whitespace-nowrap',
6121
+ other: '',
6122
+ };
6123
+
6124
+ var ariaSortConfig = {
6125
+ asc: 'ascending',
6126
+ desc: 'descending',
6127
+ };
6128
+ function SortableHeadCell(_a) {
6129
+ 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"]);
6130
+ var ariaSort;
6131
+ if (onSort)
6132
+ ariaSort = sortOrder ? ariaSortConfig[sortOrder] : 'none';
6133
+ var icon = (React.createElement(TbChevronDown, { size: 18, className: "text-bia-grey-dark-10", "aria-hidden": "true" }));
6134
+ if (sortOrder === 'asc') {
6135
+ icon = (React.createElement(TbChevronDown, { size: 18, className: "text-bia-blue", "aria-hidden": "true" }));
6136
+ }
6137
+ else if (sortOrder === 'desc') {
6138
+ icon = (React.createElement(TbChevronUp, { size: 18, className: "text-bia-blue", "aria-hidden": "true" }));
6139
+ }
6140
+ 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]) },
6141
+ React.createElement(Text, { variant: "normal-text-semibold" }, label),
6142
+ icon)) : (React.createElement(Text, { variant: "normal-text-semibold" }, label))));
6143
+ }
6144
+
6145
+ function useDebounce(value, delay) {
6146
+ if (delay === void 0) { delay = 500; }
6147
+ var _a = React.useState(value), debouncedValue = _a[0], setDebouncedValue = _a[1];
6148
+ React.useEffect(function () {
6149
+ var timer = setTimeout(function () { return setDebouncedValue(value); }, delay);
6150
+ return function () { return clearTimeout(timer); };
6151
+ }, [value, delay]);
6152
+ return debouncedValue;
6153
+ }
6154
+
6155
+ function getValueAtPath(row, path) {
6156
+ return path.split('.').reduce(function (current, part) {
6157
+ if (current === null || current === undefined)
6158
+ return undefined;
6159
+ return current[part];
6160
+ }, row);
6161
+ }
6162
+ function getColumnValue(row, column) {
6163
+ return column.accessor
6164
+ ? column.accessor(row)
6165
+ : getValueAtPath(row, column.key);
6166
+ }
6167
+ function toSize(value) {
6168
+ if (value === undefined)
6169
+ return undefined;
6170
+ return typeof value === 'number' ? "".concat(value, "px") : value;
6171
+ }
6172
+ function getColumnStyle(column) {
6173
+ var style = {};
6174
+ var width = column.width;
6175
+ if (width === 'fit') {
6176
+ style.width = '1%';
6177
+ }
6178
+ else if (width !== undefined && width !== 'auto') {
6179
+ style.width = toSize(width);
6180
+ }
6181
+ var minWidth = toSize(column.minWidth);
6182
+ var maxWidth = toSize(column.maxWidth);
6183
+ if (minWidth)
6184
+ style.minWidth = minWidth;
6185
+ if (maxWidth)
6186
+ style.maxWidth = maxWidth;
6187
+ return style;
6188
+ }
6189
+ function isEmptyValue(value) {
6190
+ return value === null || value === undefined || value === '';
6191
+ }
6192
+ function compareValues(a, b, direction) {
6193
+ var emptyA = isEmptyValue(a);
6194
+ var emptyB = isEmptyValue(b);
6195
+ if (emptyA && emptyB)
6196
+ return 0;
6197
+ if (emptyA)
6198
+ return 1;
6199
+ if (emptyB)
6200
+ return -1;
6201
+ if (typeof a === 'string' && typeof b === 'string') {
6202
+ return (a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base' }) *
6203
+ direction);
6204
+ }
6205
+ if (a < b)
6206
+ return -1 * direction;
6207
+ if (a > b)
6208
+ return 1 * direction;
6209
+ return 0;
6210
+ }
6211
+ function matchesSearch(row, columns, keyword) {
6212
+ return columns.some(function (column) {
6213
+ var value = getColumnValue(row, column);
6214
+ return ((typeof value === 'string' || typeof value === 'number') &&
6215
+ String(value).toLowerCase().includes(keyword));
6216
+ });
6217
+ }
6218
+
6219
+ var MODE_UNION = ['client', 'server'];
6220
+ function useDataTable(options) {
6221
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
6222
+ var data = options.data, columns = options.columns, pagination = options.pagination, search = options.search, sort = options.sort;
6223
+ var paginationMode = validUnion(pagination === null || pagination === void 0 ? void 0 : pagination.mode, MODE_UNION);
6224
+ var isServerPaging = paginationMode === 'server';
6225
+ var searchMode = validUnion(search === null || search === void 0 ? void 0 : search.mode, MODE_UNION);
6226
+ var sortMode = validUnion((_a = sort === null || sort === void 0 ? void 0 : sort.mode) !== null && _a !== void 0 ? _a : paginationMode, MODE_UNION);
6227
+ var debounceMs = (_b = search === null || search === void 0 ? void 0 : search.debounceMs) !== null && _b !== void 0 ? _b : 500;
6228
+ // ---- Search state ----
6229
+ var initialSearch = (_c = search === null || search === void 0 ? void 0 : search.defaultValue) !== null && _c !== void 0 ? _c : '';
6230
+ var _k = React.useState(initialSearch), searchText = _k[0], setSearchTextState = _k[1];
6231
+ var _l = React.useState(initialSearch), sentSearch = _l[0], setSentSearch = _l[1];
6232
+ var lastSentSearchRef = React.useRef(initialSearch);
6233
+ var debouncedText = useDebounce(searchText, debounceMs);
6234
+ // ---- Sort state ----
6235
+ var isSortControlled = (sort === null || sort === void 0 ? void 0 : sort.value) !== undefined;
6236
+ 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];
6237
+ var currentSort = isSortControlled ? ((_e = sort === null || sort === void 0 ? void 0 : sort.value) !== null && _e !== void 0 ? _e : null) : innerSort;
6238
+ // ---- Page state ----
6239
+ var isPageControlled = (pagination === null || pagination === void 0 ? void 0 : pagination.page) !== undefined;
6240
+ var isSizeControlled = (pagination === null || pagination === void 0 ? void 0 : pagination.pageSize) !== undefined;
6241
+ 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];
6242
+ 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];
6243
+ var size = (_h = pagination === null || pagination === void 0 ? void 0 : pagination.pageSize) !== null && _h !== void 0 ? _h : innerSize;
6244
+ // ---- Derived data ----
6245
+ var searchColumns = React.useMemo(function () {
6246
+ if (search === null || search === void 0 ? void 0 : search.keys) {
6247
+ 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: '' }; });
6248
+ }
6249
+ return columns.filter(function (column) { return column.type !== 'index' && column.type !== 'actions'; });
6250
+ }, [columns, search === null || search === void 0 ? void 0 : search.keys]);
6251
+ var searched = React.useMemo(function () {
6252
+ if (searchMode !== 'client')
6253
+ return data;
6254
+ var keyword = searchText.trim().toLowerCase();
6255
+ if (!keyword)
6256
+ return data;
6257
+ return data.filter(function (row) { return matchesSearch(row, searchColumns, keyword); });
6258
+ }, [data, searchMode, searchText, searchColumns]);
6259
+ var sorted = React.useMemo(function () {
6260
+ if (sortMode !== 'client' || !currentSort)
6261
+ return searched;
6262
+ var column = columns.find(function (item) { var _a; return ((_a = item.sortKey) !== null && _a !== void 0 ? _a : item.key) === currentSort.key; });
6263
+ var direction = currentSort.order === 'asc' ? 1 : -1;
6264
+ return __spreadArray([], searched, true).sort(function (a, b) {
6265
+ return column
6266
+ ? compareValues(getColumnValue(a, column), getColumnValue(b, column), direction)
6267
+ : compareValues(getValueAtPath(a, currentSort.key), getValueAtPath(b, currentSort.key), direction);
6268
+ });
6269
+ }, [searched, sortMode, currentSort, columns]);
6270
+ var totalCount = isServerPaging
6271
+ ? ((_j = pagination === null || pagination === void 0 ? void 0 : pagination.totalCount) !== null && _j !== void 0 ? _j : data.length)
6272
+ : sorted.length;
6273
+ var effectiveSize = !isServerPaging && size === ALL_PAGE_SIZE
6274
+ ? Math.max(1, totalCount)
6275
+ : Math.max(1, size);
6276
+ var totalPages = totalCount === 0 ? 0 : Math.ceil(totalCount / effectiveSize);
6277
+ var rawPage;
6278
+ if (isPageControlled)
6279
+ rawPage = pagination === null || pagination === void 0 ? void 0 : pagination.page;
6280
+ else if (innerPage === 'last') {
6281
+ rawPage = isServerPaging ? 1 : Math.max(1, totalPages);
6282
+ }
6283
+ else
6284
+ rawPage = innerPage;
6285
+ var page = Math.min(Math.max(1, rawPage), Math.max(1, totalPages));
6286
+ var rowOffset = (page - 1) * effectiveSize;
6287
+ var rows = React.useMemo(function () {
6288
+ return isServerPaging
6289
+ ? data
6290
+ : sorted.slice(rowOffset, rowOffset + effectiveSize);
6291
+ }, [isServerPaging, data, sorted, rowOffset, effectiveSize]);
6292
+ // ---- Page commits (one onChange per real change) ----
6293
+ var currentRef = React.useRef({ page: 1, pageSize: size });
6294
+ currentRef.current = { page: rawPage, pageSize: size };
6295
+ var onPageChangeRef = React.useRef(pagination === null || pagination === void 0 ? void 0 : pagination.onChange);
6296
+ onPageChangeRef.current = pagination === null || pagination === void 0 ? void 0 : pagination.onChange;
6297
+ var commit = React.useCallback(function (next) {
6298
+ var _a;
6299
+ var previous = currentRef.current;
6300
+ currentRef.current = next;
6301
+ if (!isPageControlled)
6302
+ setInnerPage(next.page);
6303
+ if (!isSizeControlled)
6304
+ setInnerSize(next.pageSize);
6305
+ if (previous.page !== next.page || previous.pageSize !== next.pageSize) {
6306
+ (_a = onPageChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onPageChangeRef, next);
6307
+ }
6308
+ }, [isPageControlled, isSizeControlled]);
6309
+ var setPage = React.useCallback(function (nextPage) {
6310
+ return commit({ page: nextPage, pageSize: currentRef.current.pageSize });
6311
+ }, [commit]);
6312
+ var setPageSize = React.useCallback(function (nextSize) { return commit({ page: 1, pageSize: nextSize }); }, [commit]);
6313
+ // "last" in client mode settles to a real number once the total is known.
6314
+ React.useEffect(function () {
6315
+ if (!isPageControlled && !isServerPaging && innerPage === 'last') {
6316
+ if (totalPages > 0)
6317
+ setInnerPage(totalPages);
6318
+ }
6319
+ }, [isPageControlled, isServerPaging, innerPage, totalPages]);
6320
+ // "last" in server mode reports the last page once the total is known.
6321
+ React.useEffect(function () {
6322
+ if (!isPageControlled && isServerPaging && innerPage === 'last') {
6323
+ if (totalPages > 0)
6324
+ commit({ page: totalPages, pageSize: size });
6325
+ }
6326
+ }, [isPageControlled, isServerPaging, innerPage, totalPages, size, commit]);
6327
+ // The page moves back when the data shrinks.
6328
+ React.useEffect(function () {
6329
+ if (innerPage === 'last' && !isPageControlled)
6330
+ return;
6331
+ if (isServerPaging && totalCount === 0)
6332
+ return;
6333
+ if (rawPage !== page)
6334
+ commit({ page: page, pageSize: size });
6335
+ }, [
6336
+ rawPage,
6337
+ page,
6338
+ size,
6339
+ innerPage,
6340
+ isPageControlled,
6341
+ isServerPaging,
6342
+ totalCount,
6343
+ commit,
6344
+ ]);
6345
+ // ---- Search handlers ----
6346
+ var sendSearch = function (text) {
6347
+ var _a;
6348
+ if (text === lastSentSearchRef.current)
6349
+ return;
6350
+ lastSentSearchRef.current = text;
6351
+ setSentSearch(text);
6352
+ (_a = search === null || search === void 0 ? void 0 : search.onChange) === null || _a === void 0 ? void 0 : _a.call(search, text);
6353
+ };
6354
+ React.useEffect(function () {
6355
+ var _a;
6356
+ if (searchMode !== 'server')
6357
+ return;
6358
+ if (debouncedText !== lastSentSearchRef.current) {
6359
+ lastSentSearchRef.current = debouncedText;
6360
+ setSentSearch(debouncedText);
6361
+ (_a = search === null || search === void 0 ? void 0 : search.onChange) === null || _a === void 0 ? void 0 : _a.call(search, debouncedText);
6362
+ }
6363
+ // eslint-disable-next-line react-hooks/exhaustive-deps
6364
+ }, [debouncedText, searchMode]);
6365
+ var setSearchText = function (text) {
6366
+ var _a;
6367
+ setSearchTextState(text);
6368
+ if (searchMode === 'client') {
6369
+ (_a = search === null || search === void 0 ? void 0 : search.onChange) === null || _a === void 0 ? void 0 : _a.call(search, text);
6370
+ setPage(1);
6371
+ }
6372
+ else if (text === '') {
6373
+ // Clearing the text is sent at once.
6374
+ sendSearch('');
6375
+ }
6376
+ };
6377
+ var submitSearch = function () {
6378
+ if (searchMode === 'server')
6379
+ sendSearch(searchText);
6380
+ };
6381
+ var appliedSearch = searchMode === 'server' ? sentSearch : searchText;
6382
+ var isSearchActive = appliedSearch.trim() !== '';
6383
+ var isNoResults = isSearchActive && rows.length === 0;
6384
+ // ---- Sort handler ----
6385
+ var toggleSort = function (columnKey) {
6386
+ var _a, _b;
6387
+ var column = columns.find(function (item) { return item.key === columnKey; });
6388
+ var key = (_a = column === null || column === void 0 ? void 0 : column.sortKey) !== null && _a !== void 0 ? _a : columnKey;
6389
+ var next;
6390
+ if (!currentSort || currentSort.key !== key)
6391
+ next = { key: key, order: 'asc' };
6392
+ else if (currentSort.order === 'asc')
6393
+ next = { key: key, order: 'desc' };
6394
+ else
6395
+ next = null;
6396
+ if (!isSortControlled)
6397
+ setInnerSort(next);
6398
+ (_b = sort === null || sort === void 0 ? void 0 : sort.onChange) === null || _b === void 0 ? void 0 : _b.call(sort, next);
6399
+ if (sortMode === 'client')
6400
+ setPage(1);
6401
+ };
6402
+ var firstIndex = rows.length === 0 ? 0 : rowOffset + 1;
6403
+ var lastIndex = rows.length === 0 ? 0 : rowOffset + rows.length;
6404
+ return {
6405
+ rows: rows,
6406
+ rowOffset: rowOffset,
6407
+ page: page,
6408
+ pageSize: size,
6409
+ totalPages: totalPages,
6410
+ totalCount: totalCount,
6411
+ firstIndex: firstIndex,
6412
+ lastIndex: lastIndex,
6413
+ setPage: setPage,
6414
+ setPageSize: setPageSize,
6415
+ searchText: searchText,
6416
+ setSearchText: setSearchText,
6417
+ submitSearch: submitSearch,
6418
+ isSearchActive: isSearchActive,
6419
+ isNoResults: isNoResults,
6420
+ sort: currentSort,
6421
+ toggleSort: toggleSort,
6422
+ getValue: getColumnValue,
6423
+ };
6424
+ }
6425
+
6426
+ function getRowKey(row, rowKey) {
6427
+ if (typeof rowKey === 'function')
6428
+ return rowKey(row);
6429
+ return String(row[rowKey]);
6430
+ }
6431
+ function toDisplayValue(value, emptyValue) {
6432
+ if (value === null || value === undefined || value === '')
6433
+ return emptyValue;
6434
+ if (typeof value === 'string' || typeof value === 'number')
6435
+ return value;
6436
+ if (React.isValidElement(value))
6437
+ return value;
6438
+ return String(value);
6439
+ }
6440
+ function DataTable(_a) {
6441
+ var _b, _c;
6442
+ 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"]);
6443
+ var table = useDataTable({ data: data, columns: columns, pagination: pagination, search: search, sort: sort });
6444
+ 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];
6445
+ var setCurrentPage = function (value) {
6446
+ return table.setPage(typeof value === 'function' ? value(table.page) : value);
6447
+ };
6448
+ var setPageSize = function (value) {
6449
+ return table.setPageSize(typeof value === 'function' ? value(table.pageSize) : value);
6450
+ };
6451
+ var toggleSearch = function () {
6452
+ if (isSearchOpen)
6453
+ table.setSearchText('');
6454
+ setIsSearchOpen(function (old) { return !old; });
6455
+ };
6456
+ var headerActions = __spreadArray([], (buttonActions !== null && buttonActions !== void 0 ? buttonActions : []), true);
6457
+ if (search) {
6458
+ headerActions.push(React.createElement(Tooltip, { key: "search-toggle", content: "Search", direction: "bottom-left" },
6459
+ React.createElement(ContextualButton, { icon: React.createElement(TbZoom, { size: 18, "aria-hidden": "true" }), "aria-label": "Search", "aria-expanded": isSearchOpen, isSelected: isSearchOpen, onClick: toggleSearch })));
6460
+ if (isSearchOpen) {
6461
+ headerActions.push(
6462
+ // The wrapper only listens for Enter; the real control is the input.
6463
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
6464
+ React.createElement("div", { key: "search-input", className: "min-w-0 grow", onKeyDown: function (e) {
6465
+ if (e.key === 'Enter')
6466
+ table.submitSearch();
6467
+ } },
6468
+ 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' })));
6469
+ }
6470
+ }
6471
+ var renderHeadCell = function (column) {
6472
+ var _a, _b;
6473
+ var canSort = Boolean(column.sortable) && column.type !== 'actions';
6474
+ var sortKey = (_a = column.sortKey) !== null && _a !== void 0 ? _a : column.key;
6475
+ 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) }));
6476
+ };
6477
+ var renderCells = function (row, position) {
6478
+ var index = table.rowOffset + position;
6479
+ return columns.map(function (column) {
6480
+ var _a, _b;
6481
+ var align = (_a = column.align) !== null && _a !== void 0 ? _a : 'start';
6482
+ var value = table.getValue(row, column);
6483
+ var extra = typeof column.cellClassName === 'function'
6484
+ ? column.cellClassName(row, index)
6485
+ : column.cellClassName;
6486
+ var content;
6487
+ if (column.type === 'index') {
6488
+ content = (React.createElement(Text, { variant: "normal-text", className: "pt-[4px]" }, index + 1));
6489
+ }
6490
+ else if (column.type === 'actions') {
6491
+ content = (React.createElement("div", { className: "px-[9px]" }, (_b = column.render) === null || _b === void 0 ? void 0 : _b.call(column, value, row, index)));
6492
+ }
6493
+ else if (column.render) {
6494
+ content = column.render(value, row, index);
6495
+ }
6496
+ else {
6497
+ content = (React.createElement(Text, { variant: "normal-text", className: "pt-[4px]" }, toDisplayValue(value, emptyValue)));
6498
+ }
6499
+ 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));
6500
+ });
6501
+ };
6502
+ var headRow = (React.createElement(TableHead, null,
6503
+ React.createElement(TableRow, { variant: "head" }, columns.map(renderHeadCell))));
6504
+ var renderRows = function () {
6505
+ return table.rows.map(function (row, position) {
6506
+ var _a;
6507
+ var index = table.rowOffset + position;
6508
+ var key = getRowKey(row, rowKey);
6509
+ var cells = renderCells(row, position);
6510
+ if (renderRow) {
6511
+ return React.createElement(React.Fragment, { key: key }, renderRow(row, index, cells));
6512
+ }
6513
+ 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"]);
6514
+ 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));
6515
+ });
6516
+ };
6517
+ var body;
6518
+ if (isLoading) {
6519
+ body = (React.createElement(Table, { className: "h-full w-full font-segoe" },
6520
+ headRow,
6521
+ React.createElement(TableBody, null,
6522
+ React.createElement(TableRow, { variant: "body" },
6523
+ React.createElement("td", { colSpan: columns.length, className: "p-0" },
6524
+ React.createElement(BlockLoading, { className: "p-5" }))))));
6525
+ }
6526
+ else if (table.rows.length === 0) {
6527
+ if (table.isNoResults) {
6528
+ body = (React.createElement(EmptyTable, { content: noResultsContent, subContent: noResultsSubContent }));
6529
+ }
6530
+ else {
6531
+ body = customEmptyContent !== null && customEmptyContent !== void 0 ? customEmptyContent : (React.createElement(EmptyTable, { content: emptyContent, subContent: emptySubContent }));
6532
+ }
6533
+ }
6534
+ else {
6535
+ body = (React.createElement(Table, { className: "h-full w-full font-segoe" },
6536
+ headRow,
6537
+ React.createElement(TableBody, null, renderRows())));
6538
+ }
6539
+ return (React.createElement("div", __assign({}, rest, { className: "bianic-data-table w-full ".concat(className) }),
6540
+ React.createElement(TableHeaderController, { buttonActions: headerActions, totalData: table.totalCount, firstIndex: table.firstIndex, lastIndex: table.lastIndex }),
6541
+ middleSection,
6542
+ React.createElement("div", { className: "h-full w-full overflow-x-auto ".concat(tableClassName) }, body),
6543
+ React.createElement(TableFooterController, { size: "md", currentPage: table.page, totalPages: table.totalPages, pageSize: table.pageSize, setCurrentPage: setCurrentPage, setPageSize: setPageSize, isLoading: isLoading })));
6544
+ }
6545
+
5949
6546
  var colorConfigs = {
5950
6547
  default: 'bg-bia-black',
5951
6548
  info: 'bg-bia-teal',
@@ -9587,6 +10184,259 @@ var formatDateTime = function (dateString, type) {
9587
10184
  }
9588
10185
  };
9589
10186
 
10187
+ function getStorage(type) {
10188
+ if (typeof window === 'undefined')
10189
+ return null;
10190
+ try {
10191
+ return type === 'local' ? window.localStorage : window.sessionStorage;
10192
+ }
10193
+ catch (_a) {
10194
+ return null;
10195
+ }
10196
+ }
10197
+ function resolveInitial(initialValue) {
10198
+ return typeof initialValue === 'function'
10199
+ ? initialValue()
10200
+ : initialValue;
10201
+ }
10202
+ function readValue(key, type, initialValue) {
10203
+ var _a;
10204
+ if (key) {
10205
+ try {
10206
+ var raw = (_a = getStorage(type)) === null || _a === void 0 ? void 0 : _a.getItem(key);
10207
+ if (raw !== null && raw !== undefined)
10208
+ return JSON.parse(raw);
10209
+ }
10210
+ catch (_b) {
10211
+ // Blocked storage or broken JSON: use the initial value.
10212
+ }
10213
+ }
10214
+ return resolveInitial(initialValue);
10215
+ }
10216
+ function usePersistentState(key, initialValue, options) {
10217
+ if (options === void 0) { options = {}; }
10218
+ var _a = options.storage, storage = _a === void 0 ? 'session' : _a;
10219
+ var _b = React.useState(function () {
10220
+ return readValue(key, storage, initialValue);
10221
+ }), value = _b[0], setValue = _b[1];
10222
+ var initialRef = React.useRef(initialValue);
10223
+ initialRef.current = initialValue;
10224
+ var isFirstRun = React.useRef(true);
10225
+ var lastKeyRef = React.useRef(key);
10226
+ var skipWriteRef = React.useRef(false);
10227
+ // Re-read when the key or the storage type changes.
10228
+ var lastStorageRef = React.useRef(storage);
10229
+ React.useEffect(function () {
10230
+ if (lastKeyRef.current === key && lastStorageRef.current === storage)
10231
+ return;
10232
+ lastKeyRef.current = key;
10233
+ lastStorageRef.current = storage;
10234
+ skipWriteRef.current = true;
10235
+ setValue(readValue(key, storage, initialRef.current));
10236
+ }, [key, storage]);
10237
+ React.useEffect(function () {
10238
+ var _a;
10239
+ if (isFirstRun.current) {
10240
+ isFirstRun.current = false;
10241
+ return;
10242
+ }
10243
+ if (skipWriteRef.current) {
10244
+ skipWriteRef.current = false;
10245
+ return;
10246
+ }
10247
+ if (!key)
10248
+ return;
10249
+ try {
10250
+ (_a = getStorage(storage)) === null || _a === void 0 ? void 0 : _a.setItem(key, JSON.stringify(value));
10251
+ }
10252
+ catch (_b) {
10253
+ // Storage is full or blocked: keep the value in memory only.
10254
+ }
10255
+ }, [key, storage, value]);
10256
+ var clear = React.useCallback(function () {
10257
+ var _a;
10258
+ if (key) {
10259
+ try {
10260
+ (_a = getStorage(storage)) === null || _a === void 0 ? void 0 : _a.removeItem(key);
10261
+ }
10262
+ catch (_b) {
10263
+ // Ignore blocked storage.
10264
+ }
10265
+ }
10266
+ skipWriteRef.current = true;
10267
+ setValue(resolveInitial(initialRef.current));
10268
+ }, [key, storage]);
10269
+ return [value, setValue, clear];
10270
+ }
10271
+
10272
+ function isEmptyFilterValue(value) {
10273
+ if (value === null || value === undefined)
10274
+ return true;
10275
+ if (typeof value === 'string') {
10276
+ var text = value.trim();
10277
+ return text === '' || text === 'all';
10278
+ }
10279
+ if (Array.isArray(value))
10280
+ return value.every(isEmptyFilterValue);
10281
+ return false;
10282
+ }
10283
+ function cleanParams(filter) {
10284
+ var result = {};
10285
+ if (!filter)
10286
+ return result;
10287
+ Object.entries(filter).forEach(function (_a) {
10288
+ var key = _a[0], value = _a[1];
10289
+ if (typeof value === 'string') {
10290
+ var text = value.trim();
10291
+ if (!isEmptyFilterValue(text))
10292
+ result[key] = text;
10293
+ return;
10294
+ }
10295
+ if (Array.isArray(value)) {
10296
+ var items = value
10297
+ .map(function (item) { return (typeof item === 'string' ? item.trim() : item); })
10298
+ .filter(function (item) { return !isEmptyFilterValue(item); });
10299
+ if (items.length > 0)
10300
+ result[key] = items;
10301
+ return;
10302
+ }
10303
+ if (!isEmptyFilterValue(value))
10304
+ result[key] = value;
10305
+ });
10306
+ return result;
10307
+ }
10308
+ function isFilterActive(filter) {
10309
+ return Object.keys(cleanParams(filter)).length > 0;
10310
+ }
10311
+
10312
+ function isPlainObject(value) {
10313
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
10314
+ }
10315
+ // Keep only the keys that exist in `initial`. Missing keys take the initial value.
10316
+ function mergeSaved(initial, stored) {
10317
+ if (stored === initial)
10318
+ return initial;
10319
+ if (!isPlainObject(stored))
10320
+ return initial;
10321
+ var merged = __assign({}, initial);
10322
+ Object.keys(initial).forEach(function (key) {
10323
+ if (key in stored)
10324
+ merged[key] = stored[key];
10325
+ });
10326
+ return merged;
10327
+ }
10328
+ function useAppliedFilter(initial, options) {
10329
+ if (options === void 0) { options = {}; }
10330
+ var _a = options.storageKey, storageKey = _a === void 0 ? undefined : _a, _b = options.storage, storage = _b === void 0 ? 'session' : _b;
10331
+ var initialRef = React.useRef(initial);
10332
+ initialRef.current = initial;
10333
+ // usePersistentState reads storage in its first render, so a saved filter
10334
+ // is there from the start.
10335
+ var _c = usePersistentState(storageKey || undefined, initial, { storage: storage }), stored = _c[0], setStored = _c[1], clearStored = _c[2];
10336
+ var storedRef = React.useRef(stored);
10337
+ storedRef.current = stored;
10338
+ var applied = React.useMemo(function () { return mergeSaved(initialRef.current, stored); }, [stored]);
10339
+ var _d = React.useState(function () { return applied; }), draft = _d[0], setDraftState = _d[1];
10340
+ var draftRef = React.useRef(draft);
10341
+ var setDraft = React.useCallback(function (next) {
10342
+ var resolved = typeof next === 'function'
10343
+ ? next(draftRef.current)
10344
+ : next;
10345
+ draftRef.current = resolved;
10346
+ setDraftState(resolved);
10347
+ }, []);
10348
+ var setDraftValue = React.useCallback(function (key, value) {
10349
+ setDraft(function (old) {
10350
+ var _a;
10351
+ return (__assign(__assign({}, old), (_a = {}, _a[key] = value, _a)));
10352
+ });
10353
+ }, [setDraft]);
10354
+ // When the key or the storage type changes, the draft follows the new value.
10355
+ // usePersistentState reads the new key in its own effect, so `applied`
10356
+ // changes one render later. The flag makes the draft follow that change.
10357
+ var lastKeyRef = React.useRef({ storageKey: storageKey, storage: storage });
10358
+ var followRef = React.useRef(false);
10359
+ React.useEffect(function () {
10360
+ var last = lastKeyRef.current;
10361
+ if (last.storageKey === storageKey && last.storage === storage)
10362
+ return;
10363
+ lastKeyRef.current = { storageKey: storageKey, storage: storage };
10364
+ followRef.current = true;
10365
+ }, [storageKey, storage]);
10366
+ React.useEffect(function () {
10367
+ if (!followRef.current)
10368
+ return;
10369
+ followRef.current = false;
10370
+ setDraft(applied);
10371
+ }, [applied, setDraft]);
10372
+ var apply = React.useCallback(function () {
10373
+ setStored(draftRef.current);
10374
+ }, [setStored]);
10375
+ var reset = React.useCallback(function () {
10376
+ // Nothing was saved when the stored value is still the initial object.
10377
+ // Calling clear then would leave usePersistentState skipping its next save.
10378
+ if (storedRef.current !== initialRef.current)
10379
+ clearStored();
10380
+ setDraft(initialRef.current);
10381
+ }, [clearStored, setDraft]);
10382
+ var params = React.useMemo(function () { return cleanParams(applied); }, [applied]);
10383
+ var isActive = Object.keys(params).length > 0;
10384
+ return {
10385
+ draft: draft,
10386
+ setDraft: setDraft,
10387
+ setDraftValue: setDraftValue,
10388
+ applied: applied,
10389
+ params: params,
10390
+ isActive: isActive,
10391
+ apply: apply,
10392
+ reset: reset,
10393
+ };
10394
+ }
10395
+
10396
+ var FILE_SIZE_UNITS = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
10397
+ function formatFileSize(bytes) {
10398
+ if (bytes === void 0) { bytes = 0; }
10399
+ if (!Number.isFinite(bytes) || bytes <= 0)
10400
+ return '0 Bytes';
10401
+ var base = 1024;
10402
+ var index = Math.min(FILE_SIZE_UNITS.length - 1, Math.max(0, Math.floor(Math.log(bytes) / Math.log(base))));
10403
+ return "".concat((bytes / Math.pow(base, index)).toFixed(2), " ").concat(FILE_SIZE_UNITS[index]);
10404
+ }
10405
+ function truncateText(text, maxLength) {
10406
+ if (!text)
10407
+ return '';
10408
+ if (text.length <= maxLength)
10409
+ return text;
10410
+ var cut = text.slice(0, maxLength);
10411
+ var lastSpace = cut.lastIndexOf(' ');
10412
+ var end = lastSpace > 0 ? lastSpace : maxLength;
10413
+ return "".concat(text.slice(0, end), "...");
10414
+ }
10415
+
10416
+ function escapeRegExp(text) {
10417
+ return text.replace(/[-.*+?^${}()|[\]\\]/g, '\\$&');
10418
+ }
10419
+ function highlightMatch(text, keyword) {
10420
+ if (text === null || text === undefined)
10421
+ return '';
10422
+ var source = String(text);
10423
+ if (!keyword)
10424
+ return source;
10425
+ var parts = source.split(new RegExp("(".concat(escapeRegExp(keyword), ")"), 'gi'));
10426
+ if (parts.length === 1)
10427
+ return source;
10428
+ var lowerKeyword = keyword.toLowerCase();
10429
+ var offset = 0;
10430
+ return parts.map(function (part) {
10431
+ var key = "".concat(offset, "-").concat(part);
10432
+ offset += part.length;
10433
+ if (part.toLowerCase() === lowerKeyword) {
10434
+ return (React.createElement("span", { key: key, className: "font-bold" }, part));
10435
+ }
10436
+ return React.createElement(React.Fragment, { key: key }, part);
10437
+ });
10438
+ }
10439
+
9590
10440
  /**
9591
10441
  * A custom hook to handle data processing for tables, managing internal states
9592
10442
  * for client-side filtering (searching) and sorting. It can also safely yield control
@@ -9627,7 +10477,10 @@ var useTableDataHandler = function (initialData, options) {
9627
10477
  return configSearchKeys;
9628
10478
  if (initialData && initialData.length > 0) {
9629
10479
  var allKeys = Object.keys(initialData[0]);
9630
- return allKeys.filter(function (key) { return typeof initialData[0][key] === 'string'; });
10480
+ return allKeys.filter(function (key) {
10481
+ var firstValue = initialData[0][key];
10482
+ return typeof firstValue === 'string' || typeof firstValue === 'number';
10483
+ });
9631
10484
  }
9632
10485
  return [];
9633
10486
  }, [initialData, configSearchKeys, isFilterable, isServerSide]);
@@ -9643,8 +10496,8 @@ var useTableDataHandler = function (initialData, options) {
9643
10496
  result = result.filter(function (item) {
9644
10497
  return searchKeys.some(function (key) {
9645
10498
  var itemValue = item[key];
9646
- return (typeof itemValue === 'string' &&
9647
- itemValue.toLowerCase().includes(keyword_1));
10499
+ return ((typeof itemValue === 'string' || typeof itemValue === 'number') &&
10500
+ String(itemValue).toLowerCase().includes(keyword_1));
9648
10501
  });
9649
10502
  });
9650
10503
  }
@@ -9745,6 +10598,7 @@ exports.Checkbox = Checkbox;
9745
10598
  exports.Color = Color;
9746
10599
  exports.ContextualButton = ContextualButton;
9747
10600
  exports.Countdown = Countdown;
10601
+ exports.DataTable = DataTable;
9748
10602
  exports.DatePicker = DatePicker;
9749
10603
  exports.Display = Display;
9750
10604
  exports.Divider = Divider;
@@ -9784,6 +10638,7 @@ exports.SidebarMenu = SidebarMenu;
9784
10638
  exports.SidebarProfile = SidebarProfile;
9785
10639
  exports.SimpleFileUploader = SimpleFileUploader;
9786
10640
  exports.Slider = Slider;
10641
+ exports.SortableHeadCell = SortableHeadCell;
9787
10642
  exports.Spinner = Spinner;
9788
10643
  exports.Tab = Tab;
9789
10644
  exports.TabMenu = TabMenu;
@@ -9807,7 +10662,17 @@ exports.TreeItem = TreeItem$1;
9807
10662
  exports.VerticalStepper = StepperItem;
9808
10663
  exports.Window = Window;
9809
10664
  exports.YearPicker = YearPicker;
10665
+ exports.cleanParams = cleanParams;
9810
10666
  exports.formatDateTime = formatDateTime;
10667
+ exports.formatFileSize = formatFileSize;
9811
10668
  exports.getRelativeTime = getRelativeTime;
10669
+ exports.highlightMatch = highlightMatch;
10670
+ exports.isEmptyFilterValue = isEmptyFilterValue;
10671
+ exports.isFilterActive = isFilterActive;
10672
+ exports.truncateText = truncateText;
10673
+ exports.useAppliedFilter = useAppliedFilter;
10674
+ exports.useDataTable = useDataTable;
10675
+ exports.useDebounce = useDebounce;
9812
10676
  exports.useFileTree = useFileTree;
10677
+ exports.usePersistentState = usePersistentState;
9813
10678
  exports.useTableDataHandler = useTableDataHandler;