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