bianic-ui 2.14.0 → 2.15.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1121 -164
- package/dist/cjs/lib.css +1 -1
- package/dist/cjs/types/components/Button/ContextualButton/ContextualButton.d.ts +4 -1
- package/dist/cjs/types/components/Button/ContextualButton/config.d.ts +4 -0
- package/dist/cjs/types/components/Button/index.d.ts +1 -0
- package/dist/cjs/types/components/FileTree/TreeItem.d.ts +3 -2
- package/dist/cjs/types/components/FileTree/configs.d.ts +7 -0
- package/dist/cjs/types/components/FileTree/types.d.ts +1 -0
- package/dist/cjs/types/components/Forms/DatePicker/DateInputDisplay.d.ts +4 -1
- package/dist/cjs/types/components/Forms/DatePicker/PickerCalendar/components/DateDisplay.d.ts +4 -1
- package/dist/cjs/types/components/Forms/DatePicker/PickerCalendar/components/PickerContent.d.ts +2 -1
- package/dist/cjs/types/components/Forms/DatePicker/PickerCalendar/components/SinglePicker.d.ts +2 -1
- package/dist/cjs/types/components/Forms/DatePicker/PickerCalendar/hooks/useGridKeyboard.d.ts +11 -0
- package/dist/cjs/types/components/Forms/Dropdown/DropdownItem.d.ts +1 -1
- package/dist/cjs/types/components/Forms/DropdownItem/Custom.d.ts +3 -1
- package/dist/cjs/types/components/Forms/DropdownItem/Default.d.ts +3 -1
- package/dist/cjs/types/components/Forms/LiveSearch/hooks/useLiveSearch.d.ts +2 -0
- package/dist/cjs/types/components/Forms/LiveSearch/utils/dropdownUtils.d.ts +7 -2
- package/dist/cjs/types/components/Forms/SelectInput/index.d.ts +1 -1
- package/dist/cjs/types/components/Forms/TagLabelInput/hooks/useLiveSearch.d.ts +2 -0
- package/dist/cjs/types/components/Forms/TagLabelInput/utils/dropdownUtils.d.ts +7 -2
- package/dist/cjs/types/components/Menu/MenuItem.d.ts +1 -1
- package/dist/cjs/types/components/Table/TableFilter/TableFilterButton.d.ts +4 -0
- package/dist/cjs/types/components/Table/TableFilter/TableFilterPanel.d.ts +4 -0
- package/dist/cjs/types/components/Table/TableFilter/configs.d.ts +6 -0
- package/dist/cjs/types/components/Table/TableFilter/index.d.ts +3 -0
- package/dist/cjs/types/components/Table/TableFilter/types.d.ts +19 -0
- package/dist/cjs/types/components/Table/index.d.ts +2 -0
- package/dist/cjs/types/components/index.d.ts +4 -2
- package/dist/cjs/types/stories/Button/ContextualButton.stories.d.ts +90 -0
- package/dist/cjs/types/stories/Button/ContextualButton.test.stories.d.ts +28 -0
- package/dist/cjs/types/stories/FileTree/FileTree.test.stories.d.ts +40 -0
- package/dist/cjs/types/stories/FileTree/FileTreeSimulation.stories.d.ts +3 -0
- package/dist/cjs/types/stories/Form/DatePicker/DatePicker.test.stories.d.ts +50 -0
- package/dist/cjs/types/stories/Form/DatePicker/Datepicker.stories.d.ts +162 -2
- package/dist/cjs/types/stories/Form/DatePicker/YearPicker.stories.d.ts +2 -1
- package/dist/cjs/types/stories/Form/Dropdown/DropdownContainer.stories.d.ts +1 -0
- package/dist/cjs/types/stories/Form/Dropdown/DropdownContainer.test.stories.d.ts +8 -0
- package/dist/cjs/types/stories/Form/LiveSearch/Livesearch.stories.d.ts +2 -0
- package/dist/cjs/types/stories/Form/LiveSearch/Livesearch.test.stories.d.ts +7 -0
- package/dist/cjs/types/stories/Form/SelectInput/SelectInput.stories.d.ts +3 -0
- package/dist/cjs/types/stories/Form/SelectInput/SelectInput.test.stories.d.ts +30 -0
- package/dist/cjs/types/stories/Form/TagLabelInput/TagLabelInput.stories.d.ts +1 -0
- package/dist/cjs/types/stories/Form/TagLabelInput/TagLabelInput.test.stories.d.ts +28 -0
- package/dist/cjs/types/stories/Form/TextInput/TextInput.stories.d.ts +1 -0
- package/dist/cjs/types/stories/Form/TextInput/TextInput.test.stories.d.ts +26 -0
- package/dist/cjs/types/stories/Menu/Menu.test.stories.d.ts +28 -0
- package/dist/cjs/types/stories/Menu/NestedExample.stories.d.ts +2 -0
- package/dist/cjs/types/stories/Progress/Bar/ProgressBar.stories.d.ts +13 -0
- package/dist/cjs/types/stories/Progress/Bar/ProgressBarSimulation.stories.d.ts +6 -0
- package/dist/cjs/types/stories/Table/AppliedFilterExample.d.ts +3 -0
- package/dist/cjs/types/stories/Table/TableFilterButton.stories.d.ts +76 -0
- package/dist/cjs/types/stories/Table/TableFilterButton.test.stories.d.ts +28 -0
- package/dist/cjs/types/stories/Table/TableFilterPanel.stories.d.ts +122 -0
- package/dist/cjs/types/stories/Table/TableFilterPanel.test.stories.d.ts +39 -0
- package/dist/cjs/types/stories/Table/tableFilterSamples.d.ts +55 -0
- package/dist/cjs/types/utility/hooks/useListKeyboard.d.ts +14 -0
- package/dist/esm/index.js +1120 -165
- package/dist/esm/lib.css +1 -1
- package/dist/esm/types/components/Button/ContextualButton/ContextualButton.d.ts +4 -1
- package/dist/esm/types/components/Button/ContextualButton/config.d.ts +4 -0
- package/dist/esm/types/components/Button/index.d.ts +1 -0
- package/dist/esm/types/components/FileTree/TreeItem.d.ts +3 -2
- package/dist/esm/types/components/FileTree/configs.d.ts +7 -0
- package/dist/esm/types/components/FileTree/types.d.ts +1 -0
- package/dist/esm/types/components/Forms/DatePicker/DateInputDisplay.d.ts +4 -1
- package/dist/esm/types/components/Forms/DatePicker/PickerCalendar/components/DateDisplay.d.ts +4 -1
- package/dist/esm/types/components/Forms/DatePicker/PickerCalendar/components/PickerContent.d.ts +2 -1
- package/dist/esm/types/components/Forms/DatePicker/PickerCalendar/components/SinglePicker.d.ts +2 -1
- package/dist/esm/types/components/Forms/DatePicker/PickerCalendar/hooks/useGridKeyboard.d.ts +11 -0
- package/dist/esm/types/components/Forms/Dropdown/DropdownItem.d.ts +1 -1
- package/dist/esm/types/components/Forms/DropdownItem/Custom.d.ts +3 -1
- package/dist/esm/types/components/Forms/DropdownItem/Default.d.ts +3 -1
- package/dist/esm/types/components/Forms/LiveSearch/hooks/useLiveSearch.d.ts +2 -0
- package/dist/esm/types/components/Forms/LiveSearch/utils/dropdownUtils.d.ts +7 -2
- package/dist/esm/types/components/Forms/SelectInput/index.d.ts +1 -1
- package/dist/esm/types/components/Forms/TagLabelInput/hooks/useLiveSearch.d.ts +2 -0
- package/dist/esm/types/components/Forms/TagLabelInput/utils/dropdownUtils.d.ts +7 -2
- package/dist/esm/types/components/Menu/MenuItem.d.ts +1 -1
- package/dist/esm/types/components/Table/TableFilter/TableFilterButton.d.ts +4 -0
- package/dist/esm/types/components/Table/TableFilter/TableFilterPanel.d.ts +4 -0
- package/dist/esm/types/components/Table/TableFilter/configs.d.ts +6 -0
- package/dist/esm/types/components/Table/TableFilter/index.d.ts +3 -0
- package/dist/esm/types/components/Table/TableFilter/types.d.ts +19 -0
- package/dist/esm/types/components/Table/index.d.ts +2 -0
- package/dist/esm/types/components/index.d.ts +4 -2
- package/dist/esm/types/stories/Button/ContextualButton.stories.d.ts +90 -0
- package/dist/esm/types/stories/Button/ContextualButton.test.stories.d.ts +28 -0
- package/dist/esm/types/stories/FileTree/FileTree.test.stories.d.ts +40 -0
- package/dist/esm/types/stories/FileTree/FileTreeSimulation.stories.d.ts +3 -0
- package/dist/esm/types/stories/Form/DatePicker/DatePicker.test.stories.d.ts +50 -0
- package/dist/esm/types/stories/Form/DatePicker/Datepicker.stories.d.ts +162 -2
- package/dist/esm/types/stories/Form/DatePicker/YearPicker.stories.d.ts +2 -1
- package/dist/esm/types/stories/Form/Dropdown/DropdownContainer.stories.d.ts +1 -0
- package/dist/esm/types/stories/Form/Dropdown/DropdownContainer.test.stories.d.ts +8 -0
- package/dist/esm/types/stories/Form/LiveSearch/Livesearch.stories.d.ts +2 -0
- package/dist/esm/types/stories/Form/LiveSearch/Livesearch.test.stories.d.ts +7 -0
- package/dist/esm/types/stories/Form/SelectInput/SelectInput.stories.d.ts +3 -0
- package/dist/esm/types/stories/Form/SelectInput/SelectInput.test.stories.d.ts +30 -0
- package/dist/esm/types/stories/Form/TagLabelInput/TagLabelInput.stories.d.ts +1 -0
- package/dist/esm/types/stories/Form/TagLabelInput/TagLabelInput.test.stories.d.ts +28 -0
- package/dist/esm/types/stories/Form/TextInput/TextInput.stories.d.ts +1 -0
- package/dist/esm/types/stories/Form/TextInput/TextInput.test.stories.d.ts +26 -0
- package/dist/esm/types/stories/Menu/Menu.test.stories.d.ts +28 -0
- package/dist/esm/types/stories/Menu/NestedExample.stories.d.ts +2 -0
- package/dist/esm/types/stories/Progress/Bar/ProgressBar.stories.d.ts +13 -0
- package/dist/esm/types/stories/Progress/Bar/ProgressBarSimulation.stories.d.ts +6 -0
- package/dist/esm/types/stories/Table/AppliedFilterExample.d.ts +3 -0
- package/dist/esm/types/stories/Table/TableFilterButton.stories.d.ts +76 -0
- package/dist/esm/types/stories/Table/TableFilterButton.test.stories.d.ts +28 -0
- package/dist/esm/types/stories/Table/TableFilterPanel.stories.d.ts +122 -0
- package/dist/esm/types/stories/Table/TableFilterPanel.test.stories.d.ts +39 -0
- package/dist/esm/types/stories/Table/tableFilterSamples.d.ts +55 -0
- package/dist/esm/types/utility/hooks/useListKeyboard.d.ts +14 -0
- package/dist/index.d.ts +34 -6
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -109,6 +109,8 @@ function TbCircleFilled (props) {
|
|
|
109
109
|
return GenIcon({"tag":"svg","attr":{"viewBox":"0 0 24 24","fill":"none","stroke":"currentColor","strokeWidth":"2","strokeLinecap":"round","strokeLinejoin":"round"},"child":[{"tag":"path","attr":{"d":"M12 3a9 9 0 1 0 9 9"},"child":[]}]})(props);
|
|
110
110
|
}function TbFolderOpen (props) {
|
|
111
111
|
return GenIcon({"tag":"svg","attr":{"viewBox":"0 0 24 24","fill":"none","stroke":"currentColor","strokeWidth":"2","strokeLinecap":"round","strokeLinejoin":"round"},"child":[{"tag":"path","attr":{"d":"M5 19l2.757 -7.351a1 1 0 0 1 .936 -.649h12.307a1 1 0 0 1 .986 1.164l-.996 5.211a2 2 0 0 1 -1.964 1.625h-14.026a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v2"},"child":[]}]})(props);
|
|
112
|
+
}function TbFilter (props) {
|
|
113
|
+
return GenIcon({"tag":"svg","attr":{"viewBox":"0 0 24 24","fill":"none","stroke":"currentColor","strokeWidth":"2","strokeLinecap":"round","strokeLinejoin":"round"},"child":[{"tag":"path","attr":{"d":"M4 4h16v2.172a2 2 0 0 1 -.586 1.414l-4.414 4.414v7l-6 2v-8.5l-4.48 -4.928a2 2 0 0 1 -.52 -1.345v-2.227z"},"child":[]}]})(props);
|
|
112
114
|
}function TbFile (props) {
|
|
113
115
|
return GenIcon({"tag":"svg","attr":{"viewBox":"0 0 24 24","fill":"none","stroke":"currentColor","strokeWidth":"2","strokeLinecap":"round","strokeLinejoin":"round"},"child":[{"tag":"path","attr":{"d":"M14 3v4a1 1 0 0 0 1 1h4"},"child":[]},{"tag":"path","attr":{"d":"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z"},"child":[]}]})(props);
|
|
114
116
|
}function TbEye (props) {
|
|
@@ -537,11 +539,11 @@ var BUTTON_VARIANT_UNION = [
|
|
|
537
539
|
'form-group',
|
|
538
540
|
];
|
|
539
541
|
var RADIUS_UNION = ['default', 'full-rounded'];
|
|
540
|
-
var SIZE_UNION = ['md', 'lg', 'sm', 'tn'];
|
|
542
|
+
var SIZE_UNION$1 = ['md', 'lg', 'sm', 'tn'];
|
|
541
543
|
var Button = forwardRef(function (_a, ref) {
|
|
542
544
|
var label = _a.label, _b = _a.className, className = _b === void 0 ? '' : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.radius, radius = _d === void 0 ? 'default' : _d, _e = _a.size, size = _e === void 0 ? 'md' : _e, _f = _a.variant, variant = _f === void 0 ? 'default' : _f, _g = _a.iconLeft, iconLeft = _g === void 0 ? null : _g, _h = _a.iconRight, iconRight = _h === void 0 ? null : _h, _j = _a.left, left = _j === void 0 ? null : _j, _k = _a.right, right = _k === void 0 ? null : _k, minWidth = _a.minWidth, _l = _a.iconSize, iconSize = _l === void 0 ? undefined : _l, props = __rest(_a, ["label", "className", "disabled", "radius", "size", "variant", "iconLeft", "iconRight", "left", "right", "minWidth", "iconSize"]);
|
|
543
545
|
var validatedVariant = validUnion(variant, BUTTON_VARIANT_UNION);
|
|
544
|
-
var validatedSize = validUnion(size, SIZE_UNION);
|
|
546
|
+
var validatedSize = validUnion(size, SIZE_UNION$1);
|
|
545
547
|
var validatedRadius = validUnion(radius, RADIUS_UNION);
|
|
546
548
|
var variantTextColorClasses = variantConfig$3[validatedVariant]
|
|
547
549
|
.split(/\s+/)
|
|
@@ -1643,24 +1645,36 @@ function ButtonApp(_a) {
|
|
|
1643
1645
|
return (React.createElement("button", __assign({ className: "button-app flex max-h-[30px] items-center justify-center px-[10px] pb-[8.3px] pt-[8.5px] font-arial text-size-tiny ".concat(colorConfig$2[color][buttonState], " ").concat(extended), type: "button", disabled: disabled }, rest), label));
|
|
1644
1646
|
}
|
|
1645
1647
|
|
|
1648
|
+
var sizeUnion$6 = ['tn', 'sm'];
|
|
1649
|
+
var minHeightConfig$1 = {
|
|
1650
|
+
tn: 'min-h-[23px]',
|
|
1651
|
+
sm: 'min-h-[30px]',
|
|
1652
|
+
};
|
|
1653
|
+
var paddingConfig = {
|
|
1654
|
+
tn: 'p-[1px]',
|
|
1655
|
+
sm: 'px-1 py-[1px]',
|
|
1656
|
+
};
|
|
1646
1657
|
var textColorConfig = {
|
|
1647
1658
|
dark: 'text-primary-black disabled:text-bia-coolgrey-disabled',
|
|
1648
1659
|
light: 'text-primary-white disabled:opacity-30',
|
|
1649
1660
|
};
|
|
1650
1661
|
var stateColorConfig = {
|
|
1651
|
-
selected: 'bg-black/15 cursor-default',
|
|
1662
|
+
selected: 'bg-black/15 cursor-default focus-visible:border-bia-blue-disabled focus-visible:outline-2 focus-visible:-outline-offset-1 focus-visible:outline-bia-blue-disabled',
|
|
1652
1663
|
default: 'enabled:hover:bg-black/10 enabled:focus-visible:border-bia-blue-disabled enabled:focus-visible:outline-2 enabled:focus-visible:-outline-offset-1 enabled:focus-visible:outline-bia-blue-disabled enabled:active:bg-black/15',
|
|
1653
1664
|
};
|
|
1654
1665
|
|
|
1655
1666
|
function ContextualButtonInner(_a, ref) {
|
|
1656
|
-
var _b = _a.actionElement, actionElement = _b === void 0 ? undefined : _b, _c = _a.label, label = _c === void 0 ? '' : _c, _d = _a.icon, icon = _d === void 0 ? undefined : _d, _e = _a.variant, variant = _e === void 0 ? 'dark' : _e, disabled = _a.disabled,
|
|
1667
|
+
var _b = _a.actionElement, actionElement = _b === void 0 ? undefined : _b, _c = _a.label, label = _c === void 0 ? '' : _c, _d = _a.icon, icon = _d === void 0 ? undefined : _d, _e = _a.variant, variant = _e === void 0 ? 'dark' : _e, _f = _a.size, size = _f === void 0 ? 'tn' : _f, disabled = _a.disabled, _g = _a.isSelected, isSelected = _g === void 0 ? false : _g, _h = _a.isNotified, isNotified = _h === void 0 ? false : _h, props = __rest(_a, ["actionElement", "label", "icon", "variant", "size", "disabled", "isSelected", "isNotified"]);
|
|
1657
1668
|
var textColor = textColorConfig[variant];
|
|
1658
1669
|
if (isSelected) {
|
|
1659
1670
|
textColor = variant === 'dark' ? 'text-primary-black' : 'text-primary-white';
|
|
1660
1671
|
}
|
|
1661
1672
|
var stateColor = stateColorConfig[isSelected ? 'selected' : 'default'];
|
|
1662
|
-
|
|
1673
|
+
var notifiedClass = isNotified ? 'relative ' : '';
|
|
1674
|
+
var validSize = validUnion(size, sizeUnion$6);
|
|
1675
|
+
return (React.createElement("button", __assign({ ref: ref, type: "button", className: "bianic-contextual-button ".concat(notifiedClass, "box-border flex ").concat(minHeightConfig$1[validSize], " flex-row items-center rounded-radius-sm border border-transparent ").concat(paddingConfig[validSize], " outline-none ").concat(stateColor, " ").concat(textColor) }, props, { disabled: disabled }),
|
|
1663
1676
|
icon,
|
|
1677
|
+
isNotified && (React.createElement("span", { "aria-hidden": "true", className: "absolute -right-[3px] -top-[3px] size-1.5 rounded-radius-full bg-bia-red" })),
|
|
1664
1678
|
label && (React.createElement("div", { className: "label flex max-h-[46px] items-center gap-x-0.5 px-[5px] text-[12px] leading-none" },
|
|
1665
1679
|
React.createElement("span", null, label),
|
|
1666
1680
|
actionElement))));
|
|
@@ -1845,8 +1859,31 @@ function Divider(_a) {
|
|
|
1845
1859
|
return (React.createElement("div", { className: "bianic-divider bg-bia-grey-light-50 ".concat(margin, " ").concat(config, " ").concat(className) }));
|
|
1846
1860
|
}
|
|
1847
1861
|
|
|
1862
|
+
var TREE_ITEM_SIZES = ['sm', 'md'];
|
|
1863
|
+
var headerSizeConfig = {
|
|
1864
|
+
sm: '',
|
|
1865
|
+
md: 'py-[3px]',
|
|
1866
|
+
};
|
|
1867
|
+
var chevronIconSize = {
|
|
1868
|
+
sm: 18,
|
|
1869
|
+
md: 20,
|
|
1870
|
+
};
|
|
1871
|
+
var placeholderSizeConfig = {
|
|
1872
|
+
sm: 'min-w-[18px]',
|
|
1873
|
+
md: 'min-w-5',
|
|
1874
|
+
};
|
|
1875
|
+
var labelSizeConfig$1 = {
|
|
1876
|
+
sm: 'px-0.5 py-[0.5px] text-size-sm',
|
|
1877
|
+
md: 'min-h-5 px-[3px] text-size-base leading-5',
|
|
1878
|
+
};
|
|
1879
|
+
var childrenSizeConfig = {
|
|
1880
|
+
sm: 'gap-0.5 pl-[18px]',
|
|
1881
|
+
md: 'pl-5',
|
|
1882
|
+
};
|
|
1883
|
+
|
|
1848
1884
|
function TreeItem(_a) {
|
|
1849
|
-
var data = _a.data, expandedData = _a.expandedData, setExpandedData = _a.setExpandedData, dataMap = _a.dataMap, _b = _a.activeUnitId, activeUnitId = _b === void 0 ? undefined : _b, _c = _a.
|
|
1885
|
+
var data = _a.data, expandedData = _a.expandedData, setExpandedData = _a.setExpandedData, dataMap = _a.dataMap, _b = _a.activeUnitId, activeUnitId = _b === void 0 ? undefined : _b, _c = _a.size, size = _c === void 0 ? 'sm' : _c, _d = _a.handleChevronClick, handleChevronClick = _d === void 0 ? undefined : _d, _e = _a.handleRightClick, handleRightClick = _e === void 0 ? undefined : _e, _f = _a.handleClick, handleClick = _f === void 0 ? undefined : _f;
|
|
1886
|
+
var validSize = validUnion(size, TREE_ITEM_SIZES);
|
|
1850
1887
|
var isExpanded = !!expandedData.get(data.id);
|
|
1851
1888
|
var hasActiveDescendant = function (unit) {
|
|
1852
1889
|
var _a;
|
|
@@ -1887,14 +1924,16 @@ function TreeItem(_a) {
|
|
|
1887
1924
|
handleChevronClick === null || handleChevronClick === void 0 ? void 0 : handleChevronClick(data);
|
|
1888
1925
|
};
|
|
1889
1926
|
return (React.createElement("div", { className: "tree-item", role: "treeitem", "aria-expanded": data.children ? isExpanded : undefined, "aria-selected": activeUnitId === data.id },
|
|
1890
|
-
React.createElement("div", { className:
|
|
1927
|
+
React.createElement("div", { className: cn$1('tree-item-header flex items-center justify-start', headerSizeConfig[validSize]) },
|
|
1891
1928
|
data.children ? (React.createElement("button", { className: "tree-item-chevron", onClick: chevronClickHandler, type: "button", "aria-label": isExpanded ? 'Collapse' : 'Expand' },
|
|
1892
|
-
React.createElement(TbChevronRight, { className: "chevron ".concat(isChevronActive ? 'text-bia-green hover:text-bia-green-light-10' : 'text-bia-coolgrey-light-50 hover:text-bia-coolgrey-light-20', " ").concat(isExpanded ? 'rotate-90' : ''), size:
|
|
1893
|
-
React.createElement("button", { className:
|
|
1929
|
+
React.createElement(TbChevronRight, { className: "chevron ".concat(isChevronActive ? 'text-bia-green hover:text-bia-green-light-10' : 'text-bia-coolgrey-light-50 hover:text-bia-coolgrey-light-20', " ").concat(isExpanded ? 'rotate-90' : ''), size: chevronIconSize[validSize], "aria-hidden": "true" }))) : (React.createElement("div", { className: cn$1('chevron-placeholder aspect-square', placeholderSizeConfig[validSize]) })),
|
|
1930
|
+
React.createElement("button", { className: cn$1('tree-item-label rounded-radius-sm text-start font-segoe font-normal text-bia-black', labelSizeConfig$1[validSize], activeUnitId === data.id
|
|
1931
|
+
? 'bg-bia-green-light-70'
|
|
1932
|
+
: 'hover:bg-bia-coolgrey-light-90'), onClick: clickItemHandler, type: "button", onContextMenu: function (e) {
|
|
1894
1933
|
e.preventDefault();
|
|
1895
1934
|
handleRightClick === null || handleRightClick === void 0 ? void 0 : handleRightClick(data);
|
|
1896
1935
|
} }, data.label)),
|
|
1897
|
-
isExpanded && data.children && (React.createElement("div", { className:
|
|
1936
|
+
isExpanded && data.children && (React.createElement("div", { className: cn$1('tree-item-children flex flex-col rounded-radius-sm', childrenSizeConfig[validSize]), role: "group" }, data.children.map(function (childUnit) { return (React.createElement(TreeItem, { key: childUnit.id, data: childUnit, expandedData: expandedData, setExpandedData: setExpandedData, dataMap: dataMap, activeUnitId: activeUnitId, size: validSize, handleChevronClick: handleChevronClick, handleRightClick: handleRightClick, handleClick: handleClick })); })))));
|
|
1898
1937
|
}
|
|
1899
1938
|
var TreeItem$1 = React.memo(TreeItem);
|
|
1900
1939
|
|
|
@@ -2102,6 +2141,151 @@ var usePopupPosition = function (anchorRef, popupRef, position) {
|
|
|
2102
2141
|
return [positionStyle, calcPosition];
|
|
2103
2142
|
};
|
|
2104
2143
|
|
|
2144
|
+
// Internal helpers for keyboard navigation in dropdowns and menus (BIAN-259).
|
|
2145
|
+
// Not exported from any index file.
|
|
2146
|
+
// Top-level items of a list, matched against the existing markup:
|
|
2147
|
+
// - DropdownItem: `.bianic-dropdown-item > button`
|
|
2148
|
+
// - MenuItem: the `[role="button"]` child of each direct child div
|
|
2149
|
+
// - DefaultDropdownItem / CustomDropdownItem: direct `[role="button"]` children
|
|
2150
|
+
var ITEM_SELECTOR = [
|
|
2151
|
+
':scope > .bianic-dropdown-item > button:not(:disabled)',
|
|
2152
|
+
':scope > div > [role="button"]:not([aria-disabled="true"])',
|
|
2153
|
+
':scope > [role="button"]:not([aria-disabled="true"])',
|
|
2154
|
+
].join(', ');
|
|
2155
|
+
function getEnabledItems(list) {
|
|
2156
|
+
if (!list)
|
|
2157
|
+
return [];
|
|
2158
|
+
return Array.from(list.querySelectorAll(ITEM_SELECTOR));
|
|
2159
|
+
}
|
|
2160
|
+
// Wraps around. `current` -1 means nothing is highlighted.
|
|
2161
|
+
function nextIndex(current, delta, count) {
|
|
2162
|
+
if (count <= 0)
|
|
2163
|
+
return -1;
|
|
2164
|
+
if (current < 0)
|
|
2165
|
+
return delta > 0 ? 0 : count - 1;
|
|
2166
|
+
return (current + delta + count) % count;
|
|
2167
|
+
}
|
|
2168
|
+
// Highlight for the option picked by arrow keys in a form field list
|
|
2169
|
+
var OPTION_HIGHLIGHT_CLASS = '!bg-bia-blue-pastel outline outline-[3px] -outline-offset-[3px] outline-bia-blue-light-50';
|
|
2170
|
+
function getOptionId(baseId, index) {
|
|
2171
|
+
return "".concat(baseId, "-option-").concat(index);
|
|
2172
|
+
}
|
|
2173
|
+
function scrollOptionIntoView(id) {
|
|
2174
|
+
var _a, _b;
|
|
2175
|
+
(_b = (_a = document.getElementById(id)) === null || _a === void 0 ? void 0 : _a.scrollIntoView) === null || _b === void 0 ? void 0 : _b.call(_a, { block: 'nearest' });
|
|
2176
|
+
}
|
|
2177
|
+
function isEditable(target) {
|
|
2178
|
+
if (!(target instanceof HTMLElement))
|
|
2179
|
+
return false;
|
|
2180
|
+
return (target.isContentEditable ||
|
|
2181
|
+
target instanceof HTMLTextAreaElement ||
|
|
2182
|
+
target instanceof HTMLSelectElement ||
|
|
2183
|
+
target instanceof HTMLInputElement);
|
|
2184
|
+
}
|
|
2185
|
+
// Open menus in the order they opened. Only one menu reacts to a key press.
|
|
2186
|
+
var openMenus = [];
|
|
2187
|
+
function holdsFocus(entry) {
|
|
2188
|
+
var _a, _b;
|
|
2189
|
+
var active = document.activeElement;
|
|
2190
|
+
if (!active || active === document.body)
|
|
2191
|
+
return false;
|
|
2192
|
+
return !!(((_a = entry.getList()) === null || _a === void 0 ? void 0 : _a.contains(active)) || ((_b = entry.getAnchor()) === null || _b === void 0 ? void 0 : _b.contains(active)));
|
|
2193
|
+
}
|
|
2194
|
+
function shouldReact(entry) {
|
|
2195
|
+
var focused = openMenus.filter(holdsFocus);
|
|
2196
|
+
if (focused.length > 0)
|
|
2197
|
+
return focused[focused.length - 1] === entry;
|
|
2198
|
+
return openMenus[openMenus.length - 1] === entry;
|
|
2199
|
+
}
|
|
2200
|
+
// Arrow keys, Escape and Tab for a menu that is open.
|
|
2201
|
+
// Enter and Space are handled by the items themselves.
|
|
2202
|
+
function useMenuKeyboard(_a) {
|
|
2203
|
+
var open = _a.open, onClose = _a.onClose, listRef = _a.listRef, _b = _a.anchorRef, anchorRef = _b === void 0 ? undefined : _b;
|
|
2204
|
+
var onCloseRef = useRef(onClose);
|
|
2205
|
+
onCloseRef.current = onClose;
|
|
2206
|
+
var returnFocusRef = useRef(null);
|
|
2207
|
+
var skipRestoreRef = useRef(false);
|
|
2208
|
+
var wasOpenRef = useRef(false);
|
|
2209
|
+
useEffect(function () {
|
|
2210
|
+
var _a, _b;
|
|
2211
|
+
if (!open) {
|
|
2212
|
+
if (wasOpenRef.current) {
|
|
2213
|
+
wasOpenRef.current = false;
|
|
2214
|
+
// Give focus back when it was lost on a hidden item
|
|
2215
|
+
var active_1 = document.activeElement;
|
|
2216
|
+
var list = listRef.current;
|
|
2217
|
+
var lost = !active_1 ||
|
|
2218
|
+
active_1 === document.body ||
|
|
2219
|
+
(list !== null && list.contains(active_1));
|
|
2220
|
+
var target = (_a = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) !== null && _a !== void 0 ? _a : returnFocusRef.current;
|
|
2221
|
+
if (!skipRestoreRef.current && lost && (target === null || target === void 0 ? void 0 : target.isConnected)) {
|
|
2222
|
+
target.focus();
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
return undefined;
|
|
2226
|
+
}
|
|
2227
|
+
wasOpenRef.current = true;
|
|
2228
|
+
skipRestoreRef.current = false;
|
|
2229
|
+
var active = document.activeElement;
|
|
2230
|
+
returnFocusRef.current =
|
|
2231
|
+
active && active !== document.body && !((_b = listRef.current) === null || _b === void 0 ? void 0 : _b.contains(active))
|
|
2232
|
+
? active
|
|
2233
|
+
: null;
|
|
2234
|
+
var entry = {
|
|
2235
|
+
getList: function () { return listRef.current; },
|
|
2236
|
+
getAnchor: function () { var _a; return (_a = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) !== null && _a !== void 0 ? _a : null; },
|
|
2237
|
+
};
|
|
2238
|
+
openMenus.push(entry);
|
|
2239
|
+
var onKeyDown = function (e) {
|
|
2240
|
+
var _a;
|
|
2241
|
+
if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey)
|
|
2242
|
+
return;
|
|
2243
|
+
var key = e.key;
|
|
2244
|
+
if (key !== 'ArrowDown' &&
|
|
2245
|
+
key !== 'ArrowUp' &&
|
|
2246
|
+
key !== 'Escape' &&
|
|
2247
|
+
key !== 'Tab')
|
|
2248
|
+
return;
|
|
2249
|
+
if (!shouldReact(entry))
|
|
2250
|
+
return;
|
|
2251
|
+
if (key === 'Tab') {
|
|
2252
|
+
skipRestoreRef.current = true;
|
|
2253
|
+
onCloseRef.current();
|
|
2254
|
+
return;
|
|
2255
|
+
}
|
|
2256
|
+
if (key === 'Escape') {
|
|
2257
|
+
e.preventDefault();
|
|
2258
|
+
onCloseRef.current();
|
|
2259
|
+
return;
|
|
2260
|
+
}
|
|
2261
|
+
var list = listRef.current;
|
|
2262
|
+
if (!list)
|
|
2263
|
+
return;
|
|
2264
|
+
var target = e.target;
|
|
2265
|
+
var anchor = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current;
|
|
2266
|
+
if (isEditable(target) &&
|
|
2267
|
+
!list.contains(target) &&
|
|
2268
|
+
!(anchor === null || anchor === void 0 ? void 0 : anchor.contains(target)))
|
|
2269
|
+
return;
|
|
2270
|
+
var items = getEnabledItems(list);
|
|
2271
|
+
if (items.length === 0)
|
|
2272
|
+
return;
|
|
2273
|
+
e.preventDefault();
|
|
2274
|
+
var current = document.activeElement;
|
|
2275
|
+
var index = items.findIndex(function (item) { return item === current || item.contains(current); });
|
|
2276
|
+
var next = nextIndex(index, key === 'ArrowDown' ? 1 : -1, items.length);
|
|
2277
|
+
(_a = items[next]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
2278
|
+
};
|
|
2279
|
+
document.addEventListener('keydown', onKeyDown);
|
|
2280
|
+
return function () {
|
|
2281
|
+
document.removeEventListener('keydown', onKeyDown);
|
|
2282
|
+
var at = openMenus.indexOf(entry);
|
|
2283
|
+
if (at >= 0)
|
|
2284
|
+
openMenus.splice(at, 1);
|
|
2285
|
+
};
|
|
2286
|
+
}, [open, listRef, anchorRef]);
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2105
2289
|
function MenuElementInner(_a) {
|
|
2106
2290
|
var isTopFlat = _a.isTopFlat, children = _a.children, className = _a.className, zIndex = _a.zIndex, menuRef = _a.menuRef, onClose = _a.onClose, onClickItem = _a.onClickItem, _b = _a.style, style = _b === void 0 ? undefined : _b, _c = _a.onContextMenu, onContextMenu = _c === void 0 ? undefined : _c, restProps = __rest(_a, ["isTopFlat", "children", "className", "zIndex", "menuRef", "onClose", "onClickItem", "style", "onContextMenu"]);
|
|
2107
2291
|
var radiusClass = "rounded-b-radius-sm ".concat(!isTopFlat && 'rounded-t-radius-sm');
|
|
@@ -2120,6 +2304,7 @@ function MenuContainer(_a) {
|
|
|
2120
2304
|
var _b = _a.isTopFlat, isTopFlat = _b === void 0 ? false : _b, children = _a.children, _c = _a.open, open = _c === void 0 ? true : _c, _d = _a.onClose, onClose = _d === void 0 ? function () { } : _d, _e = _a.className, className = _e === void 0 ? '' : _e, _f = _a.isWithOverlay, isWithOverlay = _f === void 0 ? true : _f, _g = _a.zIndex, zIndex = _g === void 0 ? 100 : _g, _h = _a.onClickItem, onClickItem = _h === void 0 ? function () { } : _h, _j = _a.anchorRef, anchorRef = _j === void 0 ? undefined : _j, _k = _a.matchAnchorWidth, matchAnchorWidth = _k === void 0 ? undefined : _k, _l = _a.onContextMenu, onContextMenu = _l === void 0 ? undefined : _l, restProps = __rest(_a, ["isTopFlat", "children", "open", "onClose", "className", "isWithOverlay", "zIndex", "onClickItem", "anchorRef", "matchAnchorWidth", "onContextMenu"]);
|
|
2121
2305
|
var MenuContainerRef = useRef(null);
|
|
2122
2306
|
var positionStyle = usePopupPosition(anchorRef, MenuContainerRef)[0];
|
|
2307
|
+
useMenuKeyboard({ open: open, onClose: onClose, listRef: MenuContainerRef, anchorRef: anchorRef });
|
|
2123
2308
|
var newStyle = useMemo(function () {
|
|
2124
2309
|
var _a, _b;
|
|
2125
2310
|
if (!(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)) {
|
|
@@ -2184,9 +2369,12 @@ function MenuContainerNoAnchorInner(propsComp, ref) {
|
|
|
2184
2369
|
var MenuContainerNoAnchor = forwardRef(MenuContainerNoAnchorInner);
|
|
2185
2370
|
|
|
2186
2371
|
function MenuItem(_a) {
|
|
2187
|
-
var _b = _a.className, className = _b === void 0 ? '' : _b, label = _a.label, _c = _a.onClick, onClick = _c === void 0 ? function () { } : _c, _d = _a.caption, caption = _d === void 0 ? undefined : _d, _e = _a.isChecked, isChecked = _e === void 0 ? undefined : _e, _f = _a.onClose, onClose = _f === void 0 ? function () { } : _f, _g = _a.children, children = _g === void 0 ? undefined : _g, _h = _a.zIndex, zIndex = _h === void 0 ? 100 : _h, _j = _a.inheritedOnClick, inheritedOnClick = _j === void 0 ? function () { } : _j, _k = _a.disabled, disabled = _k === void 0 ? false : _k, props = __rest(_a, ["className", "label", "onClick", "caption", "isChecked", "onClose", "children", "zIndex", "inheritedOnClick", "disabled"]);
|
|
2188
|
-
var
|
|
2189
|
-
var
|
|
2372
|
+
var _b = _a.className, className = _b === void 0 ? '' : _b, label = _a.label, _c = _a.onClick, onClick = _c === void 0 ? function () { } : _c, _d = _a.caption, caption = _d === void 0 ? undefined : _d, _e = _a.isChecked, isChecked = _e === void 0 ? undefined : _e, _f = _a.onClose, onClose = _f === void 0 ? function () { } : _f, _g = _a.children, children = _g === void 0 ? undefined : _g, _h = _a.zIndex, zIndex = _h === void 0 ? 100 : _h, _j = _a.inheritedOnClick, inheritedOnClick = _j === void 0 ? function () { } : _j, _k = _a.disabled, disabled = _k === void 0 ? false : _k, _l = _a.onKeyDown, consumerOnKeyDown = _l === void 0 ? undefined : _l, _m = _a.onFocus, consumerOnFocus = _m === void 0 ? undefined : _m, _o = _a.onBlur, consumerOnBlur = _o === void 0 ? undefined : _o, props = __rest(_a, ["className", "label", "onClick", "caption", "isChecked", "onClose", "children", "zIndex", "inheritedOnClick", "disabled", "onKeyDown", "onFocus", "onBlur"]);
|
|
2373
|
+
var _p = useState(false), isHovered = _p[0], setIsHovered = _p[1];
|
|
2374
|
+
var _q = useState(false), isKeyboardOpen = _q[0], setIsKeyboardOpen = _q[1];
|
|
2375
|
+
var _r = useState(false), isKeyFocused = _r[0], setIsKeyFocused = _r[1];
|
|
2376
|
+
var outerRef = useRef(null);
|
|
2377
|
+
var _s = useState(false), isLeft = _s[0], setIsLeft = _s[1];
|
|
2190
2378
|
var isWithChecked = isChecked !== undefined;
|
|
2191
2379
|
var leftPadding = isWithChecked ? 'pl-[5px]' : 'pl-[10px]';
|
|
2192
2380
|
var rightPadding = caption || children ? 'pr-[5px]' : 'pr-[10px]';
|
|
@@ -2203,24 +2391,87 @@ function MenuItem(_a) {
|
|
|
2203
2391
|
else
|
|
2204
2392
|
setIsLeft(false);
|
|
2205
2393
|
}
|
|
2206
|
-
}, [isHovered]);
|
|
2394
|
+
}, [isHovered, isKeyboardOpen]);
|
|
2207
2395
|
var translateClass = isLeft
|
|
2208
2396
|
? 'left-0 -translate-x-full'
|
|
2209
2397
|
: 'right-0 translate-x-full';
|
|
2210
2398
|
var currentZIndex = zIndex + 10;
|
|
2211
|
-
|
|
2212
|
-
|
|
2399
|
+
var handleKeyDown = function (e) {
|
|
2400
|
+
if (e.target === e.currentTarget && !disabled) {
|
|
2401
|
+
var isActivateKey = e.key === 'Enter' || e.key === ' ';
|
|
2402
|
+
if (children && (isActivateKey || e.key === 'ArrowRight')) {
|
|
2403
|
+
e.preventDefault();
|
|
2404
|
+
setIsKeyboardOpen(true);
|
|
2405
|
+
requestAnimationFrame(function () {
|
|
2406
|
+
var _a;
|
|
2407
|
+
(_a = getEnabledItems(MenuContRef.current)[0]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
2408
|
+
});
|
|
2409
|
+
}
|
|
2410
|
+
else if (!children && isActivateKey) {
|
|
2411
|
+
// Same code as a mouse click (R34)
|
|
2412
|
+
e.preventDefault();
|
|
2413
|
+
e.currentTarget.click();
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
consumerOnKeyDown === null || consumerOnKeyDown === void 0 ? void 0 : consumerOnKeyDown(e);
|
|
2417
|
+
};
|
|
2418
|
+
var handleSubMenuKeyDown = function (e) {
|
|
2419
|
+
var _a, _b, _c;
|
|
2420
|
+
if (e.key === 'ArrowLeft' || e.key === 'Escape') {
|
|
2421
|
+
e.preventDefault();
|
|
2422
|
+
e.stopPropagation();
|
|
2423
|
+
setIsKeyboardOpen(false);
|
|
2424
|
+
setIsHovered(false);
|
|
2425
|
+
(_b = (_a = outerRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(':scope > [role="button"]')) === null || _b === void 0 ? void 0 : _b.focus();
|
|
2426
|
+
}
|
|
2427
|
+
else if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
2428
|
+
e.preventDefault();
|
|
2429
|
+
e.stopPropagation();
|
|
2430
|
+
var items = getEnabledItems(e.currentTarget);
|
|
2431
|
+
var index = items.findIndex(function (item) {
|
|
2432
|
+
return item === document.activeElement ||
|
|
2433
|
+
item.contains(document.activeElement);
|
|
2434
|
+
});
|
|
2435
|
+
(_c = items[nextIndex(index, e.key === 'ArrowDown' ? 1 : -1, items.length)]) === null || _c === void 0 ? void 0 : _c.focus();
|
|
2436
|
+
}
|
|
2437
|
+
};
|
|
2438
|
+
var handleFocus = function (e) {
|
|
2439
|
+
try {
|
|
2440
|
+
if (e.currentTarget.matches(':focus-visible'))
|
|
2441
|
+
setIsKeyFocused(true);
|
|
2442
|
+
}
|
|
2443
|
+
catch (_a) {
|
|
2444
|
+
// :focus-visible is not supported here, so there is no keyboard highlight
|
|
2445
|
+
}
|
|
2446
|
+
consumerOnFocus === null || consumerOnFocus === void 0 ? void 0 : consumerOnFocus(e);
|
|
2447
|
+
};
|
|
2448
|
+
var handleBlur = function (e) {
|
|
2449
|
+
setIsKeyFocused(false);
|
|
2450
|
+
consumerOnBlur === null || consumerOnBlur === void 0 ? void 0 : consumerOnBlur(e);
|
|
2451
|
+
};
|
|
2452
|
+
var keyFocusClass = isKeyFocused
|
|
2453
|
+
? ' !bg-bia-blue-pastel outline outline-[3px] -outline-offset-[3px] outline-bia-blue-light-50'
|
|
2454
|
+
: '';
|
|
2455
|
+
return (React.createElement("div", { ref: outerRef, className: "group/main relative cursor-pointer first:rounded-t-radius-sm first:pt-[6px] last:rounded-b-radius-sm last:pb-[6px]", onMouseEnter: function () { return !disabled && setIsHovered(true); }, onMouseLeave: function () { return !disabled && setIsHovered(false); }, onBlur: function (e) {
|
|
2456
|
+
// Focus left the whole item, so close a sub-menu opened by keyboard
|
|
2457
|
+
if (!e.currentTarget.contains(e.relatedTarget))
|
|
2458
|
+
setIsKeyboardOpen(false);
|
|
2459
|
+
} },
|
|
2460
|
+
React.createElement("div", __assign({ className: "relative flex items-center bg-bia-white py-[5px] ".concat(itemClass, " ").concat(disabled ? 'cursor-not-allowed' : 'hover:bg-bia-blue-pastel').concat(keyFocusClass), role: "button", "aria-disabled": disabled, tabIndex: disabled ? -1 : 0, onClick: function (e) {
|
|
2213
2461
|
if (disabled)
|
|
2214
2462
|
return;
|
|
2215
2463
|
inheritedOnClick();
|
|
2216
2464
|
onClick(e);
|
|
2217
|
-
}, onKeyDown:
|
|
2465
|
+
}, onKeyDown: handleKeyDown, onFocus: handleFocus, onBlur: handleBlur, style: { zIndex: currentZIndex + 15 } }, props),
|
|
2218
2466
|
isWithChecked && (React.createElement("div", { className: "mr-[5px] aspect-square w-[14px]" }, isChecked && React.createElement(TbCheck, { className: "text-primary-black", size: 14 }))),
|
|
2219
2467
|
React.createElement("span", { className: "whitespace-nowrap font-arial text-[11px] ".concat(disabled ? 'text-bia-coolgrey-light-50' : 'text-bia-black') }, label),
|
|
2220
2468
|
React.createElement("div", { className: "ml-auto flex items-center" },
|
|
2221
2469
|
children && (React.createElement(TbChevronRight, { className: "ml-[10px] text-bia-coolgrey" })),
|
|
2222
2470
|
children === undefined && caption && (React.createElement("span", { className: "ml-[30px] whitespace-nowrap text-[11px] ".concat(disabled ? 'text-bia-coolgrey-light-50' : 'text-bia-coolgrey') }, caption)))),
|
|
2223
|
-
children && !disabled && (React.createElement(MenuContainerNoAnchor, { open: isHovered
|
|
2471
|
+
children && !disabled && (React.createElement(MenuContainerNoAnchor, { open: isHovered || isKeyboardOpen, onKeyDown: handleSubMenuKeyDown, onClose: function () {
|
|
2472
|
+
setIsKeyboardOpen(false);
|
|
2473
|
+
onClose();
|
|
2474
|
+
}, className: "absolute top-0 bg-primary-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] group-first/main:top-[6px] ".concat(translateClass), ref: MenuContRef, zIndex: currentZIndex + 10, onClickItem: function () { return inheritedOnClick(); } }, children))));
|
|
2224
2475
|
}
|
|
2225
2476
|
|
|
2226
2477
|
var TooltipItem = function (_a) {
|
|
@@ -2314,14 +2565,8 @@ function FormLabel(_a) {
|
|
|
2314
2565
|
|
|
2315
2566
|
function PasswordIcon(_a) {
|
|
2316
2567
|
var isShow = _a.isShow, showHandler = _a.showHandler, iconSize = _a.iconSize, disabled = _a.disabled;
|
|
2317
|
-
var iconColor = disabled ? '
|
|
2318
|
-
|
|
2319
|
-
return (React.createElement(TbEye, { onClick: function () { return showHandler(false); }, style: {
|
|
2320
|
-
fontSize: iconSize,
|
|
2321
|
-
color: iconColor,
|
|
2322
|
-
} }));
|
|
2323
|
-
}
|
|
2324
|
-
return (React.createElement(TbEyeOff, { onClick: function () { return showHandler(true); }, style: { fontSize: iconSize, color: iconColor } }));
|
|
2568
|
+
var iconColor = disabled ? 'text-bia-coolgrey' : 'text-bia-blue';
|
|
2569
|
+
return (React.createElement("button", { type: "button", "aria-label": isShow ? 'Hide password' : 'Show password', disabled: disabled, onClick: function () { return showHandler(!isShow); }, className: "flex items-center rounded focus-visible:outline focus-visible:outline-[3px] focus-visible:outline-offset-0 focus-visible:outline-bia-blue-light-50 ".concat(iconColor) }, isShow ? (React.createElement(TbEye, { size: iconSize, "aria-hidden": "true" })) : (React.createElement(TbEyeOff, { size: iconSize, "aria-hidden": "true" }))));
|
|
2325
2570
|
}
|
|
2326
2571
|
|
|
2327
2572
|
function ValidationIcon(_a) {
|
|
@@ -2596,16 +2841,27 @@ var sizeConfig$8 = {
|
|
|
2596
2841
|
|
|
2597
2842
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2598
2843
|
function CustomDropdownItem(_a) {
|
|
2599
|
-
var _b = _a.className, className = _b === void 0 ? '' : _b, _c = _a.onClick, onClick = _c === void 0 ? function () { } : _c, _d = _a.size, size = _d === void 0 ? 'md' : _d, _e = _a.isSelected, isSelected = _e === void 0 ? false : _e, _f = _a.options, options =
|
|
2600
|
-
var
|
|
2601
|
-
var
|
|
2844
|
+
var _b = _a.className, className = _b === void 0 ? '' : _b, _c = _a.onClick, onClick = _c === void 0 ? function () { } : _c, _d = _a.size, size = _d === void 0 ? 'md' : _d, _e = _a.isSelected, isSelected = _e === void 0 ? false : _e, _f = _a.isHighlighted, isHighlighted = _f === void 0 ? false : _f, _g = _a.id, id = _g === void 0 ? undefined : _g, _h = _a.options, options = _h === void 0 ? [] : _h, _j = _a.children, children = _j === void 0 ? undefined : _j;
|
|
2845
|
+
var _k = useState(false), isHovered = _k[0], setisHovered = _k[1];
|
|
2846
|
+
var _l = useState(false), isHoveredSubMenu = _l[0], setIsHoveredSubMenu = _l[1];
|
|
2602
2847
|
var isOpenDropdown = isHovered || isHoveredSubMenu;
|
|
2603
2848
|
var selectedClass = isSelected ? 'font-semibold' : 'font-normal';
|
|
2604
|
-
var
|
|
2849
|
+
var _m = sizeConfig$8[size], containerClass = _m.container, item = _m.item;
|
|
2605
2850
|
var itemClass = "".concat(item, " ").concat(selectedClass, " ").concat(className);
|
|
2606
2851
|
var isExistSubDropdown = options.length !== 0;
|
|
2607
|
-
|
|
2608
|
-
|
|
2852
|
+
var highlightOuterClass = isHighlighted
|
|
2853
|
+
? ' outline outline-[3px] -outline-offset-[3px] outline-bia-blue-light-50'
|
|
2854
|
+
: '';
|
|
2855
|
+
var highlightInnerClass = isHighlighted ? ' bg-bia-blue-light-90' : '';
|
|
2856
|
+
return (React.createElement("div", { id: id, className: "relative w-full focus-visible:outline-bia-blue-light-50 ".concat(containerClass).concat(highlightOuterClass), tabIndex: 0, role: "button", onClick: function (e) { return onClick(e); }, onMouseEnter: function () { return setisHovered(true); }, onMouseLeave: function () { return setisHovered(false); }, onKeyDown: function (e) {
|
|
2857
|
+
if (e.target !== e.currentTarget)
|
|
2858
|
+
return;
|
|
2859
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
2860
|
+
e.preventDefault();
|
|
2861
|
+
e.currentTarget.click();
|
|
2862
|
+
}
|
|
2863
|
+
} },
|
|
2864
|
+
React.createElement("div", { className: "flex select-none flex-col hover:bg-bia-blue-light-90 active:bg-bia-blue-light-80 ".concat(itemClass).concat(highlightInnerClass) },
|
|
2609
2865
|
children,
|
|
2610
2866
|
isExistSubDropdown && (React.createElement(TbChevronRight, { className: "float-right text-bia-grey" }))),
|
|
2611
2867
|
isOpenDropdown && options && isExistSubDropdown && (React.createElement("div", { className: "absolute right-0 top-0 z-50 w-full translate-x-full rounded-md border border-bia-grey-dark-10 bg-primary-white shadow-lg", onMouseEnter: function () { return setIsHoveredSubMenu(true); }, onMouseLeave: function () { return setIsHoveredSubMenu(false); } }, options.map(function (option) {
|
|
@@ -2615,16 +2871,27 @@ function CustomDropdownItem(_a) {
|
|
|
2615
2871
|
|
|
2616
2872
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2617
2873
|
function DefaultDropdownItem(_a) {
|
|
2618
|
-
var _b = _a.className, className = _b === void 0 ? '' : _b, label = _a.label, _c = _a.onClick, onClick = _c === void 0 ? function () { } : _c, _d = _a.size, size = _d === void 0 ? 'md' : _d, _e = _a.isSelected, isSelected = _e === void 0 ? false : _e, _f = _a.options, options =
|
|
2619
|
-
var
|
|
2620
|
-
var
|
|
2874
|
+
var _b = _a.className, className = _b === void 0 ? '' : _b, label = _a.label, _c = _a.onClick, onClick = _c === void 0 ? function () { } : _c, _d = _a.size, size = _d === void 0 ? 'md' : _d, _e = _a.isSelected, isSelected = _e === void 0 ? false : _e, _f = _a.isHighlighted, isHighlighted = _f === void 0 ? false : _f, _g = _a.id, id = _g === void 0 ? undefined : _g, _h = _a.options, options = _h === void 0 ? [] : _h, _j = _a.caption, caption = _j === void 0 ? '' : _j;
|
|
2875
|
+
var _k = useState(false), isHovered = _k[0], setisHovered = _k[1];
|
|
2876
|
+
var _l = useState(false), isHoveredSubMenu = _l[0], setIsHoveredSubMenu = _l[1];
|
|
2621
2877
|
var isOpenDropdown = isHovered || isHoveredSubMenu;
|
|
2622
2878
|
var selectedClass = isSelected ? 'font-semibold' : 'font-normal';
|
|
2623
|
-
var
|
|
2879
|
+
var _m = sizeConfig$8[size], containerClass = _m.container, item = _m.item;
|
|
2624
2880
|
var itemClass = "".concat(item, " ").concat(selectedClass, " ").concat(className);
|
|
2625
2881
|
var isExistSubDropdown = options.length !== 0;
|
|
2626
|
-
|
|
2627
|
-
|
|
2882
|
+
var highlightOuterClass = isHighlighted
|
|
2883
|
+
? ' outline outline-[3px] -outline-offset-[3px] outline-bia-blue-light-50'
|
|
2884
|
+
: '';
|
|
2885
|
+
var highlightInnerClass = isHighlighted ? ' bg-bia-blue-light-90' : '';
|
|
2886
|
+
return (React.createElement("div", { id: id, className: "relative w-full focus-visible:outline-bia-blue-light-50 ".concat(containerClass).concat(highlightOuterClass), tabIndex: 0, role: "button", onClick: function (e) { return onClick(e); }, onMouseEnter: function () { return setisHovered(true); }, onMouseLeave: function () { return setisHovered(false); }, onKeyDown: function (e) {
|
|
2887
|
+
if (e.target !== e.currentTarget)
|
|
2888
|
+
return;
|
|
2889
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
2890
|
+
e.preventDefault();
|
|
2891
|
+
e.currentTarget.click();
|
|
2892
|
+
}
|
|
2893
|
+
} },
|
|
2894
|
+
React.createElement("div", { className: "flex select-none flex-col hover:bg-bia-blue-light-90 active:bg-bia-blue-light-80 ".concat(itemClass).concat(highlightInnerClass) },
|
|
2628
2895
|
React.createElement("span", null,
|
|
2629
2896
|
label,
|
|
2630
2897
|
isExistSubDropdown && (React.createElement(TbChevronRight, { className: "float-right text-bia-grey" }))),
|
|
@@ -2675,6 +2942,7 @@ function DropdownContainer(propsComp) {
|
|
|
2675
2942
|
if (open)
|
|
2676
2943
|
recalcPosition();
|
|
2677
2944
|
}, [open, recalcPosition]);
|
|
2945
|
+
useMenuKeyboard({ open: open, onClose: onClose, listRef: dropdownRef, anchorRef: anchorRef });
|
|
2678
2946
|
var newStyle = useMemo(function () {
|
|
2679
2947
|
var _a, _b, _c;
|
|
2680
2948
|
if (!(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)) {
|
|
@@ -2723,17 +2991,97 @@ var getItemLabel = function (value) {
|
|
|
2723
2991
|
};
|
|
2724
2992
|
|
|
2725
2993
|
var sizeUnion$3 = ['md', 'sm'];
|
|
2994
|
+
var getOptionKey$1 = function (option) {
|
|
2995
|
+
return isObjectWithLabel(option) && option.id != null
|
|
2996
|
+
? String(option.id)
|
|
2997
|
+
: getItemLabel(option);
|
|
2998
|
+
};
|
|
2726
2999
|
function SelectInput(_a) {
|
|
2727
3000
|
var _b;
|
|
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"]);
|
|
2729
|
-
var
|
|
3001
|
+
var _c = _a.descText, descText = _c === void 0 ? undefined : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.size, size = _e === void 0 ? 'md' : _e, _f = _a.id, id = _f === void 0 ? undefined : _f, _g = _a.isValid, isValid = _g === void 0 ? null : _g, _h = _a.label, label = _h === void 0 ? undefined : _h, _j = _a.options, options = _j === void 0 ? [] : _j, _k = _a.readOnly, readOnly = _k === void 0 ? false : _k, _l = _a.required, required = _l === void 0 ? false : _l, _m = _a.selected, selected = _m === void 0 ? undefined : _m, _o = _a.setSelected, setSelected = _o === void 0 ? function () { } : _o, _p = _a.onClickDropdown, onClickDropdown = _p === void 0 ? function () { } : _p, _q = _a.children, children = _q === void 0 ? undefined : _q, _r = _a.dropContProps, _s = _r === void 0 ? {} : _r, _t = _s.className, dropContClassName = _t === void 0 ? '' : _t, restDropContProps = __rest(_s, ["className"]), _u = _a.onKeyDown, consumerOnKeyDown = _u === void 0 ? undefined : _u, props = __rest(_a, ["descText", "disabled", "size", "id", "isValid", "label", "options", "readOnly", "required", "selected", "setSelected", "onClickDropdown", "children", "dropContProps", "onKeyDown"]);
|
|
3002
|
+
var _v = useState(false), isOpen = _v[0], setIsOpen = _v[1];
|
|
3003
|
+
// Option picked by arrow keys (-1 = none)
|
|
3004
|
+
var _w = useState(-1), highlightedIndex = _w[0], setHighlightedIndex = _w[1];
|
|
3005
|
+
var baseId = useId();
|
|
2730
3006
|
var validatedSize = validUnion(size, sizeUnion$3);
|
|
2731
|
-
var
|
|
3007
|
+
var _x = sizeConfig$9[validatedSize], searchSize = _x.searchSize, iconSize = _x.iconSize;
|
|
2732
3008
|
var inputRef = useRef(null);
|
|
2733
3009
|
var selectedLabel = selected !== undefined && isObjectWithLabel(selected)
|
|
2734
3010
|
? ((_b = selected.label) !== null && _b !== void 0 ? _b : '')
|
|
2735
3011
|
: selected;
|
|
2736
3012
|
var optionsRef = useRef(null);
|
|
3013
|
+
useEffect(function () {
|
|
3014
|
+
if (!isOpen)
|
|
3015
|
+
setHighlightedIndex(-1);
|
|
3016
|
+
}, [isOpen]);
|
|
3017
|
+
// Enabled top-level children, in order (the arrow keys skip disabled ones)
|
|
3018
|
+
var enabledChildren = children === undefined
|
|
3019
|
+
? []
|
|
3020
|
+
: React.Children.toArray(children).filter(function (child) {
|
|
3021
|
+
return React.isValidElement(child) &&
|
|
3022
|
+
!child.props.disabled;
|
|
3023
|
+
});
|
|
3024
|
+
var optionCount = children === undefined ? options.length : enabledChildren.length;
|
|
3025
|
+
var activeIndex = isOpen && highlightedIndex >= 0 && highlightedIndex < optionCount
|
|
3026
|
+
? highlightedIndex
|
|
3027
|
+
: -1;
|
|
3028
|
+
var activeId = activeIndex >= 0 ? getOptionId(baseId, activeIndex) : undefined;
|
|
3029
|
+
useEffect(function () {
|
|
3030
|
+
if (activeId)
|
|
3031
|
+
scrollOptionIntoView(activeId);
|
|
3032
|
+
}, [activeId]);
|
|
3033
|
+
var getSelectedIndex = function () {
|
|
3034
|
+
if (children === undefined) {
|
|
3035
|
+
return options.findIndex(function (option) { return JSON.stringify(option) === JSON.stringify(selected); });
|
|
3036
|
+
}
|
|
3037
|
+
return enabledChildren.findIndex(function (child) {
|
|
3038
|
+
var childValue = child
|
|
3039
|
+
.props.value;
|
|
3040
|
+
return (isObjectWithLabel(selected) &&
|
|
3041
|
+
isObjectWithLabel(childValue) &&
|
|
3042
|
+
selected.id === childValue.id);
|
|
3043
|
+
});
|
|
3044
|
+
};
|
|
3045
|
+
// Opens the list and highlights the selected option, or the first / last one
|
|
3046
|
+
var openByKeyboard = function (delta) {
|
|
3047
|
+
setIsOpen(true);
|
|
3048
|
+
var selectedIndex = getSelectedIndex();
|
|
3049
|
+
if (delta < 0)
|
|
3050
|
+
setHighlightedIndex(optionCount - 1);
|
|
3051
|
+
else
|
|
3052
|
+
setHighlightedIndex(optionCount > 0 ? Math.max(selectedIndex, 0) : -1);
|
|
3053
|
+
};
|
|
3054
|
+
var handleKeyDown = function (e) {
|
|
3055
|
+
var _a;
|
|
3056
|
+
if (!disabled) {
|
|
3057
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
3058
|
+
e.preventDefault();
|
|
3059
|
+
var delta = e.key === 'ArrowDown' ? 1 : -1;
|
|
3060
|
+
if (!isOpen)
|
|
3061
|
+
openByKeyboard(delta);
|
|
3062
|
+
else
|
|
3063
|
+
setHighlightedIndex(nextIndex(activeIndex, delta, optionCount));
|
|
3064
|
+
}
|
|
3065
|
+
else if (e.key === 'Enter' || e.key === ' ') {
|
|
3066
|
+
if (!isOpen) {
|
|
3067
|
+
e.preventDefault();
|
|
3068
|
+
openByKeyboard(1);
|
|
3069
|
+
}
|
|
3070
|
+
else if (e.key === 'Enter' && activeId) {
|
|
3071
|
+
e.preventDefault();
|
|
3072
|
+
(_a = document.getElementById(activeId)) === null || _a === void 0 ? void 0 : _a.click();
|
|
3073
|
+
}
|
|
3074
|
+
}
|
|
3075
|
+
else if (e.key === 'Escape' && isOpen) {
|
|
3076
|
+
e.preventDefault();
|
|
3077
|
+
setIsOpen(false);
|
|
3078
|
+
}
|
|
3079
|
+
else if (e.key === 'Tab' && isOpen) {
|
|
3080
|
+
setIsOpen(false);
|
|
3081
|
+
}
|
|
3082
|
+
}
|
|
3083
|
+
consumerOnKeyDown === null || consumerOnKeyDown === void 0 ? void 0 : consumerOnKeyDown(e);
|
|
3084
|
+
};
|
|
2737
3085
|
var descColor = 'text-primary-cool';
|
|
2738
3086
|
var isExistValidation = isValid !== null && isValid !== undefined;
|
|
2739
3087
|
if (!disabled && isExistValidation && isValid)
|
|
@@ -2741,46 +3089,55 @@ function SelectInput(_a) {
|
|
|
2741
3089
|
if (!disabled && isExistValidation && !isValid)
|
|
2742
3090
|
descColor = 'text-bia-red';
|
|
2743
3091
|
var disabledClass = disabled ? 'cursor-not-allowed' : '';
|
|
3092
|
+
var enabledPosition = 0;
|
|
2744
3093
|
return (React.createElement("div", { className: "bianic-fgc-container bianic-text-input-container field-group flex w-full flex-col gap-y-2" },
|
|
2745
3094
|
label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
|
|
2746
3095
|
React.createElement("div", { className: "group relative w-full ".concat(disabledClass) },
|
|
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)),
|
|
3096
|
+
React.createElement("input", __assign({ className: "bianic-fgc-target field peer w-full cursor-pointer rounded border border-bia-grey-dark-10 bg-primary-white pe-8 focus-visible:outline-none enabled:hover:rounded-b-none enabled:hover:border-b-bia-blue enabled:focus:rounded-b-none enabled:focus:border-b-bia-blue disabled:cursor-not-allowed disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-coolgrey ".concat(searchSize), onClick: function () { return setIsOpen(!isOpen); }, value: selectedLabel, readOnly: true, id: id, disabled: disabled, ref: inputRef, onKeyDown: handleKeyDown, "aria-activedescendant": activeId }, props)),
|
|
2748
3097
|
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)),
|
|
2749
3098
|
children === undefined && isOpen && (
|
|
2750
3099
|
// Consumer-provided click-catcher; each rendered option below is its own interactive control
|
|
2751
3100
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
|
|
2752
|
-
React.createElement("div", { className: "absolute z-10 w-full rounded-b-md border border-bia-grey-dark-10 bg-primary-white shadow-lg", ref: optionsRef, onClick: onClickDropdown }, options.map(function (option) {
|
|
3101
|
+
React.createElement("div", { className: "absolute z-10 w-full rounded-b-md border border-bia-grey-dark-10 bg-primary-white shadow-lg", ref: optionsRef, onClick: onClickDropdown }, options.map(function (option, index) {
|
|
2753
3102
|
var isSelected = JSON.stringify(option) === JSON.stringify(selected);
|
|
2754
3103
|
var optionCaption = isObjectWithLabel(option)
|
|
2755
3104
|
? option.caption
|
|
2756
3105
|
: '';
|
|
2757
|
-
return isObjectWithLabel(option) && option.custom ? (React.createElement(CustomDropdownItem, { caption: optionCaption, size: validatedSize, isSelected: isSelected, onClick: function () {
|
|
3106
|
+
return isObjectWithLabel(option) && option.custom ? (React.createElement(CustomDropdownItem, { key: getOptionKey$1(option), isHighlighted: index === activeIndex, id: index === activeIndex ? activeId : undefined, caption: optionCaption, size: validatedSize, isSelected: isSelected, onClick: function () {
|
|
2758
3107
|
setSelected === null || setSelected === void 0 ? void 0 : setSelected(option);
|
|
2759
3108
|
setIsOpen(false);
|
|
2760
|
-
} }, option.custom)) : (React.createElement(DefaultDropdownItem, { label: getItemLabel(option), caption: optionCaption, size: validatedSize, isSelected: isSelected, onClick: function () {
|
|
3109
|
+
} }, option.custom)) : (React.createElement(DefaultDropdownItem, { key: getOptionKey$1(option), isHighlighted: index === activeIndex, id: index === activeIndex ? activeId : undefined, label: getItemLabel(option), caption: optionCaption, size: validatedSize, isSelected: isSelected, onClick: function () {
|
|
2761
3110
|
setSelected === null || setSelected === void 0 ? void 0 : setSelected(option);
|
|
2762
3111
|
setIsOpen(false);
|
|
2763
3112
|
} }));
|
|
2764
3113
|
}))),
|
|
2765
3114
|
children && isOpen && (React.createElement(DropdownContainer, __assign({ open: isOpen, onClose: function () { return setIsOpen(false); }, size: size, isTopFlat: true, className: "bianic-livesearch-dropdown absolute z-10 mt-1 w-full overflow-hidden rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none ".concat(dropContClassName), anchorRef: inputRef, matchAnchorWidth: "min" }, restDropContProps), React.Children.map(children, function (child) {
|
|
2766
3115
|
if (React.isValidElement(child)) {
|
|
3116
|
+
var isDisabledChild = child.props
|
|
3117
|
+
.disabled;
|
|
3118
|
+
var position = isDisabledChild ? -1 : enabledPosition;
|
|
3119
|
+
if (!isDisabledChild)
|
|
3120
|
+
enabledPosition += 1;
|
|
3121
|
+
var highlightProps = position >= 0 && position === activeIndex
|
|
3122
|
+
? {
|
|
3123
|
+
className: cn$1(child.props.className, OPTION_HIGHLIGHT_CLASS),
|
|
3124
|
+
id: activeId,
|
|
3125
|
+
}
|
|
3126
|
+
: {};
|
|
2767
3127
|
// Consumer-supplied children are expected to carry a `value`
|
|
2768
3128
|
// prop matching the DropdownItem convention, but arbitrary
|
|
2769
3129
|
// JSX children have no statically-known prop shape.
|
|
2770
3130
|
var childValue_1 = child.props
|
|
2771
3131
|
.value;
|
|
2772
|
-
return React.cloneElement(child, {
|
|
2773
|
-
isSelected: isObjectWithLabel(selected) &&
|
|
3132
|
+
return React.cloneElement(child, __assign({ isSelected: isObjectWithLabel(selected) &&
|
|
2774
3133
|
isObjectWithLabel(childValue_1) &&
|
|
2775
|
-
selected.id === childValue_1.id,
|
|
2776
|
-
onClick: function () {
|
|
3134
|
+
selected.id === childValue_1.id, onClick: function () {
|
|
2777
3135
|
// Same trust boundary as before: consumer children are
|
|
2778
3136
|
// expected to always carry a value, matching the exact
|
|
2779
3137
|
// runtime behavior this already had.
|
|
2780
3138
|
setSelected === null || setSelected === void 0 ? void 0 : setSelected(childValue_1);
|
|
2781
3139
|
setIsOpen(false);
|
|
2782
|
-
},
|
|
2783
|
-
});
|
|
3140
|
+
} }, highlightProps));
|
|
2784
3141
|
}
|
|
2785
3142
|
return child;
|
|
2786
3143
|
})))),
|
|
@@ -2833,9 +3190,12 @@ function DropdownContNoAnchorInner(propsComp, ref) {
|
|
|
2833
3190
|
var DropdownContNoAnchor = forwardRef(DropdownContNoAnchorInner);
|
|
2834
3191
|
|
|
2835
3192
|
function DropdownItem(_a) {
|
|
2836
|
-
var _b = _a.children, children = _b === void 0 ? undefined : _b, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.onClickItem, onClickItem = _d === void 0 ? function () { } : _d, _e = _a.onClose, onClose = _e === void 0 ? function () { } : _e, _f = _a.size, size = _f === void 0 ? 'md' : _f, _g = _a.value, value = _g === void 0 ? '' : _g, content = _a.content, _h = _a.disabled, disabled = _h === void 0 ? false : _h, _j = _a.zIndex, zIndex = _j === void 0 ? 100 : _j, props = __rest(_a, ["children", "className", "onClickItem", "onClose", "size", "value", "content", "disabled", "zIndex"]);
|
|
2837
|
-
var
|
|
2838
|
-
var
|
|
3193
|
+
var _b = _a.children, children = _b === void 0 ? undefined : _b, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.onClickItem, onClickItem = _d === void 0 ? function () { } : _d, _e = _a.onClose, onClose = _e === void 0 ? function () { } : _e, _f = _a.size, size = _f === void 0 ? 'md' : _f, _g = _a.value, value = _g === void 0 ? '' : _g, content = _a.content, _h = _a.disabled, disabled = _h === void 0 ? false : _h, _j = _a.zIndex, zIndex = _j === void 0 ? 100 : _j, _k = _a.onKeyDown, consumerOnKeyDown = _k === void 0 ? undefined : _k, _l = _a.onFocus, consumerOnFocus = _l === void 0 ? undefined : _l, _m = _a.onBlur, consumerOnBlur = _m === void 0 ? undefined : _m, props = __rest(_a, ["children", "className", "onClickItem", "onClose", "size", "value", "content", "disabled", "zIndex", "onKeyDown", "onFocus", "onBlur"]);
|
|
3194
|
+
var _o = useState(false), isHovered = _o[0], setIsHovered = _o[1];
|
|
3195
|
+
var _p = useState(false), isKeyboardOpen = _p[0], setIsKeyboardOpen = _p[1];
|
|
3196
|
+
var _q = useState(false), isKeyFocused = _q[0], setIsKeyFocused = _q[1];
|
|
3197
|
+
var _r = useState(false), isLeft = _r[0], setIsLeft = _r[1];
|
|
3198
|
+
var outerRef = useRef(null);
|
|
2839
3199
|
var fontClass = fontConfig[size] || fontConfig.md;
|
|
2840
3200
|
var itemSizeClass = itemSizeConfig[size] || itemSizeConfig.md;
|
|
2841
3201
|
var itemClass = "".concat(itemSizeClass, " ").concat(fontClass, " ").concat(className);
|
|
@@ -2853,16 +3213,71 @@ function DropdownItem(_a) {
|
|
|
2853
3213
|
else
|
|
2854
3214
|
setIsLeft(false);
|
|
2855
3215
|
}
|
|
2856
|
-
}, [isHovered]);
|
|
3216
|
+
}, [isHovered, isKeyboardOpen]);
|
|
2857
3217
|
var translateClass = isLeft
|
|
2858
3218
|
? 'left-0 -translate-x-full'
|
|
2859
3219
|
: 'right-0 translate-x-full';
|
|
2860
3220
|
var currentZIndex = zIndex + 10;
|
|
2861
|
-
|
|
2862
|
-
|
|
3221
|
+
var handleKeyDown = function (e) {
|
|
3222
|
+
if (children && (e.key === 'ArrowRight' || e.key === 'Enter')) {
|
|
3223
|
+
e.preventDefault();
|
|
3224
|
+
setIsKeyboardOpen(true);
|
|
3225
|
+
requestAnimationFrame(function () {
|
|
3226
|
+
var _a;
|
|
3227
|
+
(_a = getEnabledItems(DropdownContRef.current)[0]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
3228
|
+
});
|
|
3229
|
+
}
|
|
3230
|
+
consumerOnKeyDown === null || consumerOnKeyDown === void 0 ? void 0 : consumerOnKeyDown(e);
|
|
3231
|
+
};
|
|
3232
|
+
var handleSubMenuKeyDown = function (e) {
|
|
3233
|
+
var _a, _b, _c;
|
|
3234
|
+
if (e.key === 'ArrowLeft' || e.key === 'Escape') {
|
|
3235
|
+
e.preventDefault();
|
|
3236
|
+
e.stopPropagation();
|
|
3237
|
+
setIsKeyboardOpen(false);
|
|
3238
|
+
setIsHovered(false);
|
|
3239
|
+
(_b = (_a = outerRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(':scope > button')) === null || _b === void 0 ? void 0 : _b.focus();
|
|
3240
|
+
}
|
|
3241
|
+
else if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
3242
|
+
e.preventDefault();
|
|
3243
|
+
e.stopPropagation();
|
|
3244
|
+
var items = getEnabledItems(e.currentTarget);
|
|
3245
|
+
var index = items.findIndex(function (item) {
|
|
3246
|
+
return item === document.activeElement ||
|
|
3247
|
+
item.contains(document.activeElement);
|
|
3248
|
+
});
|
|
3249
|
+
(_c = items[nextIndex(index, e.key === 'ArrowDown' ? 1 : -1, items.length)]) === null || _c === void 0 ? void 0 : _c.focus();
|
|
3250
|
+
}
|
|
3251
|
+
};
|
|
3252
|
+
var handleFocus = function (e) {
|
|
3253
|
+
try {
|
|
3254
|
+
if (e.currentTarget.matches(':focus-visible'))
|
|
3255
|
+
setIsKeyFocused(true);
|
|
3256
|
+
}
|
|
3257
|
+
catch (_a) {
|
|
3258
|
+
// :focus-visible is not supported here, so there is no keyboard highlight
|
|
3259
|
+
}
|
|
3260
|
+
consumerOnFocus === null || consumerOnFocus === void 0 ? void 0 : consumerOnFocus(e);
|
|
3261
|
+
};
|
|
3262
|
+
var handleBlur = function (e) {
|
|
3263
|
+
setIsKeyFocused(false);
|
|
3264
|
+
consumerOnBlur === null || consumerOnBlur === void 0 ? void 0 : consumerOnBlur(e);
|
|
3265
|
+
};
|
|
3266
|
+
var keyFocusClass = isKeyFocused
|
|
3267
|
+
? ' !bg-bia-blue-pastel outline outline-[3px] -outline-offset-[3px] outline-bia-blue-light-50'
|
|
3268
|
+
: '';
|
|
3269
|
+
return (React.createElement("div", { ref: outerRef, className: "bianic-dropdown-item group/main relative cursor-pointer first:rounded-t-radius-sm first:pt-[5px] last:rounded-b-radius-sm last:pb-[5px]", onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onBlur: function (e) {
|
|
3270
|
+
// Focus left the whole item, so close a sub-menu opened by keyboard
|
|
3271
|
+
if (!e.currentTarget.contains(e.relatedTarget))
|
|
3272
|
+
setIsKeyboardOpen(false);
|
|
3273
|
+
} },
|
|
3274
|
+
React.createElement("button", __assign({ className: "relative flex w-full !min-w-fit items-center justify-start whitespace-nowrap bg-bia-white px-[15px] py-[5px] text-left text-bia-black disabled:cursor-not-allowed disabled:text-bia-coolgrey-light-50 hover:[&:not(:disabled)]:bg-bia-blue-pastel ".concat(itemClass).concat(keyFocusClass), style: { zIndex: currentZIndex + 15 }, onClick: function (e) { return onClickItem(e, value); }, onKeyDown: handleKeyDown, onFocus: handleFocus, onBlur: handleBlur, disabled: disabled, type: "button" }, props),
|
|
2863
3275
|
content,
|
|
2864
3276
|
React.createElement("div", { className: "ml-auto flex items-center" }, children && (React.createElement(TbChevronRight, { className: "ml-[10px] text-bia-coolgrey", size: chevronSize })))),
|
|
2865
|
-
children && (React.createElement(DropdownContNoAnchor, { className: "absolute top-0 bg-primary-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] group-first/main:top-[6px] ".concat(translateClass), onClose:
|
|
3277
|
+
children && (React.createElement(DropdownContNoAnchor, { className: "absolute top-0 bg-primary-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] group-first/main:top-[6px] ".concat(translateClass), onClose: function () {
|
|
3278
|
+
setIsKeyboardOpen(false);
|
|
3279
|
+
onClose();
|
|
3280
|
+
}, onKeyDown: handleSubMenuKeyDown, open: isHovered || isKeyboardOpen, onClickItem: function (e, itemValue) { return onClickItem(e, itemValue); }, size: size, ref: DropdownContRef, zIndex: currentZIndex + 10 }, children))));
|
|
2866
3281
|
}
|
|
2867
3282
|
|
|
2868
3283
|
var matchSearchTerm = function (content, term, variant) {
|
|
@@ -2886,8 +3301,11 @@ var filterOptions = function (options, searchTerm) {
|
|
|
2886
3301
|
});
|
|
2887
3302
|
};
|
|
2888
3303
|
|
|
2889
|
-
var processDropdownChildren$1 = function (nodes, currentSearchTerm, includeAllIfNoSearch, handleDropdownItemClick, searchVariant) {
|
|
3304
|
+
var processDropdownChildren$1 = function (nodes, currentSearchTerm, includeAllIfNoSearch, handleDropdownItemClick, searchVariant, highlight) {
|
|
2890
3305
|
if (searchVariant === void 0) { searchVariant = 'include'; }
|
|
3306
|
+
if (highlight === void 0) { highlight = undefined; }
|
|
3307
|
+
// Counts the enabled top-level items, so arrow keys can skip disabled ones
|
|
3308
|
+
var enabledCount = 0;
|
|
2891
3309
|
return Children.map(nodes, function (child) {
|
|
2892
3310
|
if (!isValidElement(child) || child.type !== DropdownItem) {
|
|
2893
3311
|
return child;
|
|
@@ -2908,12 +3326,20 @@ var processDropdownChildren$1 = function (nodes, currentSearchTerm, includeAllIf
|
|
|
2908
3326
|
var clonedChildren = itemProps.children
|
|
2909
3327
|
? processDropdownChildren$1(itemProps.children, currentSearchTerm, includeAllIfNoSearch, handleDropdownItemClick, searchVariant)
|
|
2910
3328
|
: null;
|
|
3329
|
+
var position = isDisabled ? -1 : enabledCount;
|
|
3330
|
+
if (!isDisabled)
|
|
3331
|
+
enabledCount += 1;
|
|
3332
|
+
var highlightProps = highlight && position >= 0 && position === highlight.index
|
|
3333
|
+
? {
|
|
3334
|
+
className: cn$1(itemProps.className, OPTION_HIGHLIGHT_CLASS),
|
|
3335
|
+
id: getOptionId(highlight.baseId, position),
|
|
3336
|
+
}
|
|
3337
|
+
: {};
|
|
2911
3338
|
// Clone and Inject Click Handler
|
|
2912
3339
|
// DropdownItem renders a <button>, but handleDropdownItemClick's event
|
|
2913
3340
|
// type is HTMLDivElement to match its other callers (the event's
|
|
2914
3341
|
// specific target type is never used here, only forwarded).
|
|
2915
|
-
return cloneElement(child, {
|
|
2916
|
-
onClick: function (e) {
|
|
3342
|
+
return cloneElement(child, __assign({ onClick: function (e) {
|
|
2917
3343
|
var divEvent = e;
|
|
2918
3344
|
if (!isDisabled) {
|
|
2919
3345
|
if (itemValue === undefined &&
|
|
@@ -2929,31 +3355,41 @@ var processDropdownChildren$1 = function (nodes, currentSearchTerm, includeAllIf
|
|
|
2929
3355
|
if (itemProps.onClickItem) {
|
|
2930
3356
|
itemProps.onClickItem(e, itemValue !== undefined ? itemValue : itemContent);
|
|
2931
3357
|
}
|
|
2932
|
-
},
|
|
2933
|
-
children: clonedChildren,
|
|
2934
|
-
});
|
|
3358
|
+
}, children: clonedChildren }, highlightProps));
|
|
2935
3359
|
});
|
|
2936
3360
|
};
|
|
2937
|
-
var processRenderedChildren$1 = function (children, searchTerm, searchVariant, handleDropdownItemClick) {
|
|
3361
|
+
var processRenderedChildren$1 = function (children, searchTerm, searchVariant, handleDropdownItemClick, highlight) {
|
|
3362
|
+
if (highlight === void 0) { highlight = undefined; }
|
|
2938
3363
|
var renderedChildren = null;
|
|
2939
3364
|
var hasFilteredResults = false;
|
|
2940
3365
|
if (searchTerm) {
|
|
2941
|
-
renderedChildren = processDropdownChildren$1(children, searchTerm, false, handleDropdownItemClick, searchVariant);
|
|
3366
|
+
renderedChildren = processDropdownChildren$1(children, searchTerm, false, handleDropdownItemClick, searchVariant, highlight);
|
|
2942
3367
|
hasFilteredResults =
|
|
2943
3368
|
Children.toArray(renderedChildren).filter(Boolean).length > 0;
|
|
2944
3369
|
}
|
|
2945
3370
|
else {
|
|
2946
|
-
renderedChildren = processDropdownChildren$1(children, '', true, handleDropdownItemClick, searchVariant);
|
|
3371
|
+
renderedChildren = processDropdownChildren$1(children, '', true, handleDropdownItemClick, searchVariant, highlight);
|
|
2947
3372
|
hasFilteredResults =
|
|
2948
3373
|
Children.toArray(renderedChildren).filter(Boolean).length > 0;
|
|
2949
3374
|
}
|
|
2950
|
-
|
|
3375
|
+
var enabledCount = Children.toArray(renderedChildren).filter(function (child) {
|
|
3376
|
+
return isValidElement(child) &&
|
|
3377
|
+
child.type === DropdownItem &&
|
|
3378
|
+
!child.props.disabled;
|
|
3379
|
+
}).length;
|
|
3380
|
+
return { renderedChildren: renderedChildren, hasFilteredResults: hasFilteredResults, enabledCount: enabledCount };
|
|
2951
3381
|
};
|
|
2952
3382
|
|
|
2953
3383
|
var useLiveSearch$1 = function (_a) {
|
|
2954
3384
|
var value = _a.value, setValue = _a.setValue, onChangeText = _a.onChangeText, dropContOnClickItem = _a.dropContOnClickItem;
|
|
2955
3385
|
var _b = useState(false), isOpen = _b[0], setIsOpen = _b[1];
|
|
2956
3386
|
var _c = useState(getItemLabel(value)), searchTerm = _c[0], setSearchTerm = _c[1];
|
|
3387
|
+
// Option picked by arrow keys (-1 = none)
|
|
3388
|
+
var _d = useState(-1), highlightedIndex = _d[0], setHighlightedIndex = _d[1];
|
|
3389
|
+
useEffect(function () {
|
|
3390
|
+
if (!isOpen)
|
|
3391
|
+
setHighlightedIndex(-1);
|
|
3392
|
+
}, [isOpen]);
|
|
2957
3393
|
useEffect(function () {
|
|
2958
3394
|
if (!isOpen && searchTerm !== getItemLabel(value)) {
|
|
2959
3395
|
setSearchTerm(getItemLabel(value));
|
|
@@ -2965,6 +3401,7 @@ var useLiveSearch$1 = function (_a) {
|
|
|
2965
3401
|
var handleInputChange = function (e) {
|
|
2966
3402
|
var newSearchTerm = e.target.value;
|
|
2967
3403
|
setSearchTerm(newSearchTerm);
|
|
3404
|
+
setHighlightedIndex(-1);
|
|
2968
3405
|
setIsOpen(true);
|
|
2969
3406
|
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(e);
|
|
2970
3407
|
};
|
|
@@ -2994,6 +3431,8 @@ var useLiveSearch$1 = function (_a) {
|
|
|
2994
3431
|
isOpen: isOpen,
|
|
2995
3432
|
setIsOpen: setIsOpen,
|
|
2996
3433
|
searchTerm: searchTerm,
|
|
3434
|
+
highlightedIndex: highlightedIndex,
|
|
3435
|
+
setHighlightedIndex: setHighlightedIndex,
|
|
2997
3436
|
handleInputChange: handleInputChange,
|
|
2998
3437
|
handleCancel: handleCancel,
|
|
2999
3438
|
handleClear: handleClear,
|
|
@@ -3001,16 +3440,22 @@ var useLiveSearch$1 = function (_a) {
|
|
|
3001
3440
|
};
|
|
3002
3441
|
};
|
|
3003
3442
|
|
|
3443
|
+
var getOptionKey = function (option) {
|
|
3444
|
+
return isObjectWithLabel(option) && option.id != null
|
|
3445
|
+
? String(option.id)
|
|
3446
|
+
: getItemLabel(option);
|
|
3447
|
+
};
|
|
3004
3448
|
function LiveSearch(_a) {
|
|
3005
3449
|
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;
|
|
3006
3450
|
var inputRef = useRef(null);
|
|
3007
3451
|
var wrapperRef = useRef(null);
|
|
3452
|
+
var baseId = useId();
|
|
3008
3453
|
var _v = useLiveSearch$1({
|
|
3009
3454
|
value: value,
|
|
3010
3455
|
setValue: setValue,
|
|
3011
3456
|
onChangeText: onChangeText,
|
|
3012
3457
|
dropContOnClickItem: dropContProps === null || dropContProps === void 0 ? void 0 : dropContProps.onClickItem,
|
|
3013
|
-
}), isOpen = _v.isOpen, setIsOpen = _v.setIsOpen, searchTerm = _v.searchTerm, handleInputChange = _v.handleInputChange, handleCancel = _v.handleCancel, handleClear = _v.handleClear, handleDropdownItemClick = _v.handleDropdownItemClick;
|
|
3458
|
+
}), isOpen = _v.isOpen, setIsOpen = _v.setIsOpen, searchTerm = _v.searchTerm, highlightedIndex = _v.highlightedIndex, setHighlightedIndex = _v.setHighlightedIndex, handleInputChange = _v.handleInputChange, handleCancel = _v.handleCancel, handleClear = _v.handleClear, handleDropdownItemClick = _v.handleDropdownItemClick;
|
|
3014
3459
|
// The plain `options` list has no overlay, so close it when the user clicks away.
|
|
3015
3460
|
// The `children` list is closed by its own overlay.
|
|
3016
3461
|
useEffect(function () {
|
|
@@ -3034,15 +3479,54 @@ function LiveSearch(_a) {
|
|
|
3034
3479
|
if (!disabled && isExistValidation && !isValid)
|
|
3035
3480
|
descColor = 'text-bia-red';
|
|
3036
3481
|
var filteredOptions = filterOptions(options || [], getItemLabel(value));
|
|
3037
|
-
var _y = processRenderedChildren$1(children, searchTerm, searchVariant, handleDropdownItemClick), renderedChildren = _y.renderedChildren, hasFilteredResults = _y.hasFilteredResults;
|
|
3482
|
+
var _y = processRenderedChildren$1(children, searchTerm, searchVariant, handleDropdownItemClick, { index: highlightedIndex, baseId: baseId }), renderedChildren = _y.renderedChildren, hasFilteredResults = _y.hasFilteredResults, enabledCount = _y.enabledCount;
|
|
3483
|
+
// Number of options the arrow keys can move through
|
|
3484
|
+
var optionCount = hasFilteredResults ? enabledCount : 0;
|
|
3485
|
+
if (children === undefined)
|
|
3486
|
+
optionCount = filteredOptions.length;
|
|
3487
|
+
var activeIndex = isOpen && highlightedIndex >= 0 && highlightedIndex < optionCount
|
|
3488
|
+
? highlightedIndex
|
|
3489
|
+
: -1;
|
|
3490
|
+
var activeId = activeIndex >= 0 ? getOptionId(baseId, activeIndex) : undefined;
|
|
3491
|
+
useEffect(function () {
|
|
3492
|
+
if (activeId)
|
|
3493
|
+
scrollOptionIntoView(activeId);
|
|
3494
|
+
}, [activeId]);
|
|
3495
|
+
var handleKeyDown = function (e) {
|
|
3496
|
+
var _a;
|
|
3497
|
+
if (e.key === 'Escape' && isOpen) {
|
|
3498
|
+
e.preventDefault();
|
|
3499
|
+
handleCancel();
|
|
3500
|
+
return;
|
|
3501
|
+
}
|
|
3502
|
+
if (disabled || readOnly)
|
|
3503
|
+
return;
|
|
3504
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
3505
|
+
e.preventDefault();
|
|
3506
|
+
var delta = e.key === 'ArrowDown' ? 1 : -1;
|
|
3507
|
+
if (!isOpen) {
|
|
3508
|
+
setIsOpen(true);
|
|
3509
|
+
setHighlightedIndex(nextIndex(-1, delta, optionCount));
|
|
3510
|
+
}
|
|
3511
|
+
else {
|
|
3512
|
+
setHighlightedIndex(nextIndex(activeIndex, delta, optionCount));
|
|
3513
|
+
}
|
|
3514
|
+
}
|
|
3515
|
+
else if (e.key === 'Enter') {
|
|
3516
|
+
if (activeId) {
|
|
3517
|
+
e.preventDefault();
|
|
3518
|
+
(_a = document.getElementById(activeId)) === null || _a === void 0 ? void 0 : _a.click();
|
|
3519
|
+
}
|
|
3520
|
+
}
|
|
3521
|
+
else if (e.key === 'Tab' && isOpen) {
|
|
3522
|
+
handleCancel();
|
|
3523
|
+
}
|
|
3524
|
+
};
|
|
3038
3525
|
var disabledClass = disabled ? 'cursor-not-allowed' : '';
|
|
3039
3526
|
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" },
|
|
3040
3527
|
label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
|
|
3041
3528
|
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) {
|
|
3529
|
+
React.createElement("input", { className: "bianic-livesearch-input bianic-fgc-target field peer w-full rounded border border-bia-grey-dark-10 bg-primary-white text-bia-black read-only:pointer-events-none read-only:border-bia-grey-light-50 focus-visible:outline-none enabled:hover:rounded-b-none enabled:hover:border-b-bia-blue enabled:focus:rounded-b-none enabled:focus:border-b-bia-blue disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-coolgrey ".concat(inputClass), style: { paddingRight: "".concat(10 + Number(iconSize), "px") }, onClick: function () { return setIsOpen(!isOpen); }, value: searchTerm, required: required, disabled: disabled, id: id, placeholder: placeholder, ref: inputRef, onKeyDown: handleKeyDown, "aria-activedescendant": activeId, onChange: function (e) {
|
|
3046
3530
|
onChangeText(e);
|
|
3047
3531
|
handleInputChange(e);
|
|
3048
3532
|
}, type: "text", readOnly: readOnly, autoComplete: autoComplete }),
|
|
@@ -3058,15 +3542,15 @@ function LiveSearch(_a) {
|
|
|
3058
3542
|
children === undefined && isOpen && (
|
|
3059
3543
|
// Consumer-provided click-catcher; each rendered option below is its own interactive control
|
|
3060
3544
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
|
|
3061
|
-
React.createElement("div", { className: "border-grey-100 absolute z-10 max-h-60 w-full overflow-y-auto rounded-b-md border bg-primary-white shadow-lg", onClick: onClickDropdown }, filteredOptions.map(function (option) {
|
|
3545
|
+
React.createElement("div", { className: "border-grey-100 absolute z-10 max-h-60 w-full overflow-y-auto rounded-b-md border bg-primary-white shadow-lg", onClick: onClickDropdown }, filteredOptions.map(function (option, index) {
|
|
3062
3546
|
var isSelected = isObjectWithLabel(value) &&
|
|
3063
3547
|
isObjectWithLabel(option) &&
|
|
3064
3548
|
value.id &&
|
|
3065
3549
|
option.id === value.id;
|
|
3066
|
-
return isObjectWithLabel(option) && option.custom ? (React.createElement(CustomDropdownItem, { size: size, isSelected: isSelected, className: dropContClassName, onClick: function () {
|
|
3550
|
+
return isObjectWithLabel(option) && option.custom ? (React.createElement(CustomDropdownItem, { key: getOptionKey(option), size: size, isSelected: isSelected, isHighlighted: index === activeIndex, id: index === activeIndex ? activeId : undefined, className: dropContClassName, onClick: function () {
|
|
3067
3551
|
setValue(option);
|
|
3068
3552
|
setIsOpen(false);
|
|
3069
|
-
} }, option.custom)) : (React.createElement(DefaultDropdownItem, { label: getItemLabel(option), size: size, isSelected: isSelected, className: dropContClassName, onClick: function () {
|
|
3553
|
+
} }, option.custom)) : (React.createElement(DefaultDropdownItem, { key: getOptionKey(option), label: getItemLabel(option), size: size, isSelected: isSelected, isHighlighted: index === activeIndex, id: index === activeIndex ? activeId : undefined, className: dropContClassName, onClick: function () {
|
|
3070
3554
|
setValue(option);
|
|
3071
3555
|
setIsOpen(false);
|
|
3072
3556
|
} }));
|
|
@@ -3107,8 +3591,11 @@ var isMatchValue = function (existingValue, optionValue) {
|
|
|
3107
3591
|
}
|
|
3108
3592
|
return existingValue === null || existingValue === void 0 ? void 0 : existingValue.includes(optionValue);
|
|
3109
3593
|
};
|
|
3110
|
-
var processDropdownChildren = function (nodes, currentSearchTerm, includeAllIfNoSearch, handleDropdownItemClick, existingValues, searchVariant) {
|
|
3594
|
+
var processDropdownChildren = function (nodes, currentSearchTerm, includeAllIfNoSearch, handleDropdownItemClick, existingValues, searchVariant, highlight) {
|
|
3111
3595
|
if (searchVariant === void 0) { searchVariant = 'include'; }
|
|
3596
|
+
if (highlight === void 0) { highlight = undefined; }
|
|
3597
|
+
// Counts the enabled top-level items, so arrow keys can skip disabled ones
|
|
3598
|
+
var enabledCount = 0;
|
|
3112
3599
|
return Children.map(nodes, function (child) {
|
|
3113
3600
|
if (!isValidElement(child) || child.type !== DropdownItem) {
|
|
3114
3601
|
return child;
|
|
@@ -3136,12 +3623,20 @@ var processDropdownChildren = function (nodes, currentSearchTerm, includeAllIfNo
|
|
|
3136
3623
|
var clonedChildren = itemProps.children
|
|
3137
3624
|
? processDropdownChildren(itemProps.children, currentSearchTerm, includeAllIfNoSearch, handleDropdownItemClick, existingValues, searchVariant)
|
|
3138
3625
|
: null;
|
|
3626
|
+
var position = isDisabled ? -1 : enabledCount;
|
|
3627
|
+
if (!isDisabled)
|
|
3628
|
+
enabledCount += 1;
|
|
3629
|
+
var highlightProps = highlight && position >= 0 && position === highlight.index
|
|
3630
|
+
? {
|
|
3631
|
+
className: cn$1(itemProps.className, OPTION_HIGHLIGHT_CLASS),
|
|
3632
|
+
id: getOptionId(highlight.baseId, position),
|
|
3633
|
+
}
|
|
3634
|
+
: {};
|
|
3139
3635
|
// Clone and Inject Click Handler
|
|
3140
3636
|
// DropdownItem renders a <button>, but handleDropdownItemClick's event
|
|
3141
3637
|
// type is HTMLDivElement to match its other callers (the event's
|
|
3142
3638
|
// specific target type is never used here, only forwarded).
|
|
3143
|
-
return cloneElement(child, {
|
|
3144
|
-
onClick: function (e) {
|
|
3639
|
+
return cloneElement(child, __assign({ onClick: function (e) {
|
|
3145
3640
|
var divEvent = e;
|
|
3146
3641
|
if (!isDisabled) {
|
|
3147
3642
|
if (itemValue === undefined &&
|
|
@@ -3157,32 +3652,43 @@ var processDropdownChildren = function (nodes, currentSearchTerm, includeAllIfNo
|
|
|
3157
3652
|
if (itemProps.onClickItem) {
|
|
3158
3653
|
itemProps.onClickItem(e, itemValue !== undefined ? itemValue : itemContent);
|
|
3159
3654
|
}
|
|
3160
|
-
},
|
|
3161
|
-
children: clonedChildren,
|
|
3162
|
-
});
|
|
3655
|
+
}, children: clonedChildren }, highlightProps));
|
|
3163
3656
|
});
|
|
3164
3657
|
};
|
|
3165
|
-
var processRenderedChildren = function (children, searchTerm, searchVariant, handleDropdownItemClick, existingValues) {
|
|
3658
|
+
var processRenderedChildren = function (children, searchTerm, searchVariant, handleDropdownItemClick, existingValues, highlight) {
|
|
3659
|
+
if (highlight === void 0) { highlight = undefined; }
|
|
3166
3660
|
var renderedChildren = null;
|
|
3167
3661
|
var hasFilteredResults = false;
|
|
3168
3662
|
if (searchTerm || (existingValues === null || existingValues === void 0 ? void 0 : existingValues.length) > 0) {
|
|
3169
|
-
renderedChildren = processDropdownChildren(children, searchTerm, false, handleDropdownItemClick, existingValues, searchVariant);
|
|
3663
|
+
renderedChildren = processDropdownChildren(children, searchTerm, false, handleDropdownItemClick, existingValues, searchVariant, highlight);
|
|
3170
3664
|
}
|
|
3171
3665
|
else {
|
|
3172
|
-
renderedChildren = processDropdownChildren(children, '', true, handleDropdownItemClick, [], searchVariant);
|
|
3666
|
+
renderedChildren = processDropdownChildren(children, '', true, handleDropdownItemClick, [], searchVariant, highlight);
|
|
3173
3667
|
}
|
|
3174
3668
|
hasFilteredResults =
|
|
3175
3669
|
Children.toArray(renderedChildren).filter(Boolean).length > 0;
|
|
3176
|
-
|
|
3670
|
+
var enabledCount = Children.toArray(renderedChildren).filter(function (child) {
|
|
3671
|
+
return isValidElement(child) &&
|
|
3672
|
+
child.type === DropdownItem &&
|
|
3673
|
+
!child.props.disabled;
|
|
3674
|
+
}).length;
|
|
3675
|
+
return { renderedChildren: renderedChildren, hasFilteredResults: hasFilteredResults, enabledCount: enabledCount };
|
|
3177
3676
|
};
|
|
3178
3677
|
|
|
3179
3678
|
var useLiveSearch = function (_a) {
|
|
3180
3679
|
var value = _a.value, setValue = _a.setValue, onChangeText = _a.onChangeText, dropContOnClickItem = _a.dropContOnClickItem;
|
|
3181
3680
|
var _b = useState(false), isOpen = _b[0], setIsOpen = _b[1];
|
|
3182
3681
|
var _c = useState(''), searchTerm = _c[0], setSearchTerm = _c[1];
|
|
3682
|
+
// Option picked by arrow keys (-1 = none)
|
|
3683
|
+
var _d = useState(-1), highlightedIndex = _d[0], setHighlightedIndex = _d[1];
|
|
3684
|
+
useEffect(function () {
|
|
3685
|
+
if (!isOpen)
|
|
3686
|
+
setHighlightedIndex(-1);
|
|
3687
|
+
}, [isOpen]);
|
|
3183
3688
|
var handleInputChange = function (e) {
|
|
3184
3689
|
var newSearchTerm = e.target.value;
|
|
3185
3690
|
setSearchTerm(newSearchTerm);
|
|
3691
|
+
setHighlightedIndex(-1);
|
|
3186
3692
|
setIsOpen(true);
|
|
3187
3693
|
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(e);
|
|
3188
3694
|
};
|
|
@@ -3198,6 +3704,8 @@ var useLiveSearch = function (_a) {
|
|
|
3198
3704
|
isOpen: isOpen,
|
|
3199
3705
|
setIsOpen: setIsOpen,
|
|
3200
3706
|
searchTerm: searchTerm,
|
|
3707
|
+
highlightedIndex: highlightedIndex,
|
|
3708
|
+
setHighlightedIndex: setHighlightedIndex,
|
|
3201
3709
|
handleInputChange: handleInputChange,
|
|
3202
3710
|
handleDropdownItemClick: handleDropdownItemClick,
|
|
3203
3711
|
};
|
|
@@ -3408,14 +3916,7 @@ function TagLabelInputInner(_a, ref) {
|
|
|
3408
3916
|
setValue: onChange,
|
|
3409
3917
|
onChangeText: onChangeText,
|
|
3410
3918
|
dropContOnClickItem: dropContProps === null || dropContProps === void 0 ? void 0 : dropContProps.onClickItem,
|
|
3411
|
-
}), isOpen = _s.isOpen, setIsOpen = _s.setIsOpen, searchTerm = _s.searchTerm, handleInputChange = _s.handleInputChange, handleDropdownItemClick = _s.handleDropdownItemClick;
|
|
3412
|
-
var handleKeyDown = function (e) {
|
|
3413
|
-
var _a;
|
|
3414
|
-
if (e.key === 'Backspace' && searchTerm === '' && value.length > 0) {
|
|
3415
|
-
handleRemoveTag(value.length - 1);
|
|
3416
|
-
}
|
|
3417
|
-
(_a = restInputProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(restInputProps, e);
|
|
3418
|
-
};
|
|
3919
|
+
}), isOpen = _s.isOpen, setIsOpen = _s.setIsOpen, searchTerm = _s.searchTerm, highlightedIndex = _s.highlightedIndex, setHighlightedIndex = _s.setHighlightedIndex, handleInputChange = _s.handleInputChange, handleDropdownItemClick = _s.handleDropdownItemClick;
|
|
3419
3920
|
var handleContainerClick = function () {
|
|
3420
3921
|
var _a;
|
|
3421
3922
|
if (!disabled && !readOnly) {
|
|
@@ -3443,7 +3944,50 @@ function TagLabelInputInner(_a, ref) {
|
|
|
3443
3944
|
}
|
|
3444
3945
|
var _t = sizeConfig$6[size], inputClass = _t.inputClass, paddingClass = _t.paddingClass, resizePosition = _t.resizePosition;
|
|
3445
3946
|
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;
|
|
3947
|
+
var _v = processRenderedChildren(children, searchTerm, 'include', handleDropdownItemClick, value, { index: highlightedIndex, baseId: inputId }), renderedChildren = _v.renderedChildren, hasFilteredResults = _v.hasFilteredResults, enabledCount = _v.enabledCount;
|
|
3948
|
+
// Options the arrow keys can move through (chosen and disabled ones are out)
|
|
3949
|
+
var optionCount = hasFilteredResults ? enabledCount : 0;
|
|
3950
|
+
var activeIndex = isOpen && highlightedIndex >= 0 && highlightedIndex < optionCount
|
|
3951
|
+
? highlightedIndex
|
|
3952
|
+
: -1;
|
|
3953
|
+
var activeId = activeIndex >= 0 ? getOptionId(inputId, activeIndex) : undefined;
|
|
3954
|
+
useEffect(function () {
|
|
3955
|
+
if (activeId)
|
|
3956
|
+
scrollOptionIntoView(activeId);
|
|
3957
|
+
}, [activeId]);
|
|
3958
|
+
var handleKeyDown = function (e) {
|
|
3959
|
+
var _a, _b;
|
|
3960
|
+
if (e.key === 'Backspace' && searchTerm === '' && value.length > 0) {
|
|
3961
|
+
handleRemoveTag(value.length - 1);
|
|
3962
|
+
}
|
|
3963
|
+
if (!disabled && !readOnly) {
|
|
3964
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
3965
|
+
e.preventDefault();
|
|
3966
|
+
var delta = e.key === 'ArrowDown' ? 1 : -1;
|
|
3967
|
+
if (!isOpen) {
|
|
3968
|
+
setIsOpen(true);
|
|
3969
|
+
setHighlightedIndex(nextIndex(-1, delta, optionCount));
|
|
3970
|
+
}
|
|
3971
|
+
else {
|
|
3972
|
+
setHighlightedIndex(nextIndex(activeIndex, delta, optionCount));
|
|
3973
|
+
}
|
|
3974
|
+
}
|
|
3975
|
+
else if (e.key === 'Enter') {
|
|
3976
|
+
if (activeId) {
|
|
3977
|
+
e.preventDefault();
|
|
3978
|
+
(_a = document.getElementById(activeId)) === null || _a === void 0 ? void 0 : _a.click();
|
|
3979
|
+
}
|
|
3980
|
+
}
|
|
3981
|
+
else if (e.key === 'Escape' && isOpen) {
|
|
3982
|
+
e.preventDefault();
|
|
3983
|
+
setIsOpen(false);
|
|
3984
|
+
}
|
|
3985
|
+
else if (e.key === 'Tab' && isOpen) {
|
|
3986
|
+
setIsOpen(false);
|
|
3987
|
+
}
|
|
3988
|
+
}
|
|
3989
|
+
(_b = restInputProps.onKeyDown) === null || _b === void 0 ? void 0 : _b.call(restInputProps, e);
|
|
3990
|
+
};
|
|
3447
3991
|
var showPlaceholder = !disabled && !readOnly && value.length === 0;
|
|
3448
3992
|
console.log('showPlaceholder', showPlaceholder);
|
|
3449
3993
|
return (React.createElement("div", { className: cn$1('relative w-full', className) },
|
|
@@ -3462,7 +4006,7 @@ function TagLabelInputInner(_a, ref) {
|
|
|
3462
4006
|
!readOnly &&
|
|
3463
4007
|
'focus-within:rounded-b-none hover:rounded-b-none', isFocused && !disabled && !readOnly && 'rounded-b-none', getBottomBorderColor(), paddingClass) },
|
|
3464
4008
|
value.map(function (tag, index) { return (React.createElement(TagLabel, __assign({ key: typeof tag === 'object' ? tag.id || tag.label : "".concat(tag, "-").concat(index), variant: "closeable", size: size, text: getTagLabel(tag), open: true, closeHandler: function () { return handleRemoveTag(index); } }, getTagStyles(tag)))); }),
|
|
3465
|
-
React.createElement("input", __assign({}, restInputProps, { "aria-autocomplete": "list", "aria-expanded": isOpen, "aria-haspopup": "listbox", "aria-controls": "".concat(inputId, "-listbox"), disabled: disabled, id: inputId, onChange: function (e) {
|
|
4009
|
+
React.createElement("input", __assign({}, restInputProps, { "aria-autocomplete": "list", "aria-expanded": isOpen, "aria-haspopup": "listbox", "aria-controls": "".concat(inputId, "-listbox"), "aria-activedescendant": activeId, disabled: disabled, id: inputId, onChange: function (e) {
|
|
3466
4010
|
if (disabled || readOnly)
|
|
3467
4011
|
return;
|
|
3468
4012
|
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(e);
|
|
@@ -3552,7 +4096,7 @@ function SegmentButtonItem(_a) {
|
|
|
3552
4096
|
: "".concat(sizeConfig$3[size], " ").concat(minWidthConfig[size], " ").concat(minHeightConfig[size]);
|
|
3553
4097
|
var radiusStyle = "".concat(roundedConfig[size]);
|
|
3554
4098
|
var selectedStyle = "".concat(isSelectedConfig[isSelected]);
|
|
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-
|
|
4099
|
+
return (React.createElement("button", { type: "button", onClick: onClick, disabled: disabled, className: "group:last:border-l-0 flex items-center justify-center border-[1px] border-l-0 border-bia-grey-dark-10 first:border-l-[1px] focus-visible:z-50 focus-visible:outline focus-visible:outline-[3px] focus-visible:-outline-offset-1 focus-visible:outline-bia-blue-light-50 disabled:cursor-not-allowed disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-grey-dark-10".concat(selectedStyle, " ").concat(radiusStyle, " ").concat(sizingStyle, " ").concat(className) }, children));
|
|
3556
4100
|
}
|
|
3557
4101
|
|
|
3558
4102
|
function SegmentButtonGroup(_a) {
|
|
@@ -3680,8 +4224,151 @@ var areMonthsAdjacent = function (leftMonth, leftYear, rightMonth, rightYear) {
|
|
|
3680
4224
|
return rightMonth === leftMonth + 1 && rightYear === leftYear;
|
|
3681
4225
|
};
|
|
3682
4226
|
|
|
4227
|
+
// Default focus ring (R38). Written as one literal so Tailwind scans it.
|
|
4228
|
+
var FOCUS_RING = 'focus-visible:outline focus-visible:outline-[3px] focus-visible:outline-offset-0 focus-visible:outline-bia-blue-light-50';
|
|
4229
|
+
// Marks a grid cell (day, month or year) inside the popup.
|
|
4230
|
+
var CELL_ATTRIBUTE = 'data-calendar-cell';
|
|
4231
|
+
var ACTIVE_CELL_SELECTOR = "[".concat(CELL_ATTRIBUTE, "][tabindex=\"0\"]");
|
|
4232
|
+
var FOCUSABLE_SELECTOR = 'button, [tabindex]';
|
|
4233
|
+
function getTabbableElements(root) {
|
|
4234
|
+
return Array.from(root.querySelectorAll(FOCUSABLE_SELECTOR)).filter(function (element) {
|
|
4235
|
+
if (element.tabIndex < 0)
|
|
4236
|
+
return false;
|
|
4237
|
+
if (element.disabled)
|
|
4238
|
+
return false;
|
|
4239
|
+
return element.getClientRects().length > 0;
|
|
4240
|
+
});
|
|
4241
|
+
}
|
|
4242
|
+
function focusActiveCell(root) {
|
|
4243
|
+
var cell = root === null || root === void 0 ? void 0 : root.querySelector(ACTIVE_CELL_SELECTOR);
|
|
4244
|
+
cell === null || cell === void 0 ? void 0 : cell.focus();
|
|
4245
|
+
}
|
|
4246
|
+
// Escape closes the popup. Tab and Shift+Tab wrap inside the popup.
|
|
4247
|
+
function handleDialogKeyDown(event, onClose) {
|
|
4248
|
+
if (event.key === 'Escape') {
|
|
4249
|
+
event.preventDefault();
|
|
4250
|
+
event.stopPropagation();
|
|
4251
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
4252
|
+
return;
|
|
4253
|
+
}
|
|
4254
|
+
if (event.key !== 'Tab')
|
|
4255
|
+
return;
|
|
4256
|
+
var tabbable = getTabbableElements(event.currentTarget);
|
|
4257
|
+
if (tabbable.length === 0)
|
|
4258
|
+
return;
|
|
4259
|
+
var first = tabbable[0];
|
|
4260
|
+
var last = tabbable[tabbable.length - 1];
|
|
4261
|
+
var activeElement = document.activeElement;
|
|
4262
|
+
if (event.shiftKey && (activeElement === first || !activeElement)) {
|
|
4263
|
+
event.preventDefault();
|
|
4264
|
+
last.focus();
|
|
4265
|
+
}
|
|
4266
|
+
else if (!event.shiftKey && activeElement === last) {
|
|
4267
|
+
event.preventDefault();
|
|
4268
|
+
first.focus();
|
|
4269
|
+
}
|
|
4270
|
+
}
|
|
4271
|
+
function isArrowKey(key) {
|
|
4272
|
+
return (key === 'ArrowLeft' ||
|
|
4273
|
+
key === 'ArrowRight' ||
|
|
4274
|
+
key === 'ArrowUp' ||
|
|
4275
|
+
key === 'ArrowDown');
|
|
4276
|
+
}
|
|
4277
|
+
function getArrowStep(key, columns) {
|
|
4278
|
+
switch (key) {
|
|
4279
|
+
case 'ArrowLeft':
|
|
4280
|
+
return -1;
|
|
4281
|
+
case 'ArrowRight':
|
|
4282
|
+
return 1;
|
|
4283
|
+
case 'ArrowUp':
|
|
4284
|
+
return -columns;
|
|
4285
|
+
default:
|
|
4286
|
+
return columns;
|
|
4287
|
+
}
|
|
4288
|
+
}
|
|
4289
|
+
|
|
3683
4290
|
function DateDisplay(_a) {
|
|
3684
|
-
var displayDays = _a.displayDays, viewMonthValue = _a.viewMonthValue, selectedDate = _a.selectedDate, onDateSelect = _a.onDateSelect, minDateValue = _a.minDateValue, maxDateValue = _a.maxDateValue;
|
|
4291
|
+
var displayDays = _a.displayDays, viewMonthValue = _a.viewMonthValue, selectedDate = _a.selectedDate, onDateSelect = _a.onDateSelect, minDateValue = _a.minDateValue, maxDateValue = _a.maxDateValue, _b = _a.viewYearValue, viewYearValue = _b === void 0 ? undefined : _b, _c = _a.onNavigateMonth, onNavigateMonth = _c === void 0 ? undefined : _c, _d = _a.isOpen, isOpen = _d === void 0 ? true : _d;
|
|
4292
|
+
var gridRef = useRef(null);
|
|
4293
|
+
// Day picked with the arrow keys, and the month view it was picked in.
|
|
4294
|
+
var _e = useState(null), activeState = _e[0], setActiveState = _e[1];
|
|
4295
|
+
// Day to focus once the panel has moved to another month.
|
|
4296
|
+
var pendingFocusRef = useRef(null);
|
|
4297
|
+
var viewKey = "".concat(viewYearValue, "-").concat(viewMonthValue);
|
|
4298
|
+
useEffect(function () {
|
|
4299
|
+
if (!isOpen)
|
|
4300
|
+
setActiveState(null);
|
|
4301
|
+
}, [isOpen]);
|
|
4302
|
+
var firstDayTime = displayDays[0] ? displayDays[0].getTime() : 0;
|
|
4303
|
+
useEffect(function () {
|
|
4304
|
+
var _a, _b;
|
|
4305
|
+
var key = pendingFocusRef.current;
|
|
4306
|
+
if (!key)
|
|
4307
|
+
return;
|
|
4308
|
+
pendingFocusRef.current = null;
|
|
4309
|
+
(_b = (_a = gridRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("[data-date=\"".concat(key, "\"]"))) === null || _b === void 0 ? void 0 : _b.focus();
|
|
4310
|
+
}, [firstDayTime]);
|
|
4311
|
+
var isDisabledDay = function (date) {
|
|
4312
|
+
return !!((minDateValue && date < minDateValue) ||
|
|
4313
|
+
(maxDateValue && date > maxDateValue));
|
|
4314
|
+
};
|
|
4315
|
+
var isShown = function (key) {
|
|
4316
|
+
return displayDays.some(function (day) { return dateToInputString(day) === key; });
|
|
4317
|
+
};
|
|
4318
|
+
// The day in the tab order: the one reached with the arrows, else the
|
|
4319
|
+
// selected day, else today, else the first enabled day of the month.
|
|
4320
|
+
var activeKey = null;
|
|
4321
|
+
if (activeState) {
|
|
4322
|
+
var activeDay = displayDays.find(function (day) { return dateToInputString(day) === activeState.key; });
|
|
4323
|
+
if (activeDay &&
|
|
4324
|
+
!isDisabledDay(activeDay) &&
|
|
4325
|
+
(activeState.view === viewKey || activeDay.getMonth() === viewMonthValue)) {
|
|
4326
|
+
activeKey = activeState.key;
|
|
4327
|
+
}
|
|
4328
|
+
}
|
|
4329
|
+
if (!activeKey) {
|
|
4330
|
+
var rangeDates = Array.isArray(selectedDate)
|
|
4331
|
+
? selectedDate.filter(Boolean).sort()
|
|
4332
|
+
: [];
|
|
4333
|
+
var firstRangeDay = rangeDates[0];
|
|
4334
|
+
var selectedValue = Array.isArray(selectedDate)
|
|
4335
|
+
? firstRangeDay
|
|
4336
|
+
: selectedDate;
|
|
4337
|
+
var candidates = [
|
|
4338
|
+
selectedValue ? new Date(selectedValue) : null,
|
|
4339
|
+
new Date(TODAY_VALUE),
|
|
4340
|
+
];
|
|
4341
|
+
var found = candidates.find(function (candidate) {
|
|
4342
|
+
return candidate &&
|
|
4343
|
+
candidate.getMonth() === viewMonthValue &&
|
|
4344
|
+
isShown(dateToInputString(candidate)) &&
|
|
4345
|
+
!isDisabledDay(candidate);
|
|
4346
|
+
});
|
|
4347
|
+
var fallback = found ||
|
|
4348
|
+
displayDays.find(function (day) { return day.getMonth() === viewMonthValue && !isDisabledDay(day); });
|
|
4349
|
+
activeKey = fallback ? dateToInputString(fallback) : null;
|
|
4350
|
+
}
|
|
4351
|
+
var handleKeyDown = function (event, date) {
|
|
4352
|
+
var _a, _b;
|
|
4353
|
+
if (!isArrowKey(event.key))
|
|
4354
|
+
return;
|
|
4355
|
+
event.preventDefault();
|
|
4356
|
+
var target = new Date(date);
|
|
4357
|
+
target.setDate(target.getDate() + getArrowStep(event.key, 7));
|
|
4358
|
+
// A day outside minDate or maxDate does not take focus.
|
|
4359
|
+
if (isDisabledDay(target))
|
|
4360
|
+
return;
|
|
4361
|
+
var targetKey = dateToInputString(target);
|
|
4362
|
+
setActiveState({ key: targetKey, view: viewKey });
|
|
4363
|
+
if (isShown(targetKey)) {
|
|
4364
|
+
(_b = (_a = gridRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("[data-date=\"".concat(targetKey, "\"]"))) === null || _b === void 0 ? void 0 : _b.focus();
|
|
4365
|
+
}
|
|
4366
|
+
else if (onNavigateMonth) {
|
|
4367
|
+
pendingFocusRef.current = targetKey;
|
|
4368
|
+
var isBefore = getDayKey(target) < getDayKey(displayDays[0]);
|
|
4369
|
+
onNavigateMonth(isBefore ? 'prev' : 'next');
|
|
4370
|
+
}
|
|
4371
|
+
};
|
|
3685
4372
|
var isRangeMode = Array.isArray(selectedDate) && selectedDate.length === 2;
|
|
3686
4373
|
var firstRangeDate = isRangeMode && (selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate[0]) ? new Date(selectedDate[0]) : null;
|
|
3687
4374
|
var secondRangeDate = isRangeMode && (selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate[1]) ? new Date(selectedDate[1]) : null;
|
|
@@ -3693,9 +4380,9 @@ function DateDisplay(_a) {
|
|
|
3693
4380
|
return (React.createElement("div", null,
|
|
3694
4381
|
React.createElement("div", { className: "bianic-datepicker-calendar-days-grid-header grid grid-cols-7 gap-[3px] pb-1.5" }, DAYS_MAP.map(function (day) { return (React.createElement("div", { key: day, className: "bianic-datepicker-calendar-day flex h-[18px] w-[31px] items-center justify-center" },
|
|
3695
4382
|
React.createElement(Text, { variant: "small-text", extended: "text-bia-coolgrey" }, day.slice(0, 3)))); })),
|
|
3696
|
-
React.createElement("div", { className: "bianic-datepicker-calendar-days-grid-body grid grid-cols-7 gap-y-1.5" }, displayDays.map(function (date) {
|
|
3697
|
-
var isOutOfRange =
|
|
3698
|
-
|
|
4383
|
+
React.createElement("div", { ref: gridRef, className: "bianic-datepicker-calendar-days-grid-body grid grid-cols-7 gap-y-1.5" }, displayDays.map(function (date) {
|
|
4384
|
+
var isOutOfRange = isDisabledDay(date);
|
|
4385
|
+
var dateKey = dateToInputString(date);
|
|
3699
4386
|
var isOutOfMonth = date.getMonth() !== viewMonthValue;
|
|
3700
4387
|
var isStartRange = isRangeMode && checkDateEquals(date, startRangeDate);
|
|
3701
4388
|
var isEndRange = isRangeMode && checkDateEquals(date, endRangeDate);
|
|
@@ -3747,7 +4434,10 @@ function DateDisplay(_a) {
|
|
|
3747
4434
|
else if (isOutOfMonth) {
|
|
3748
4435
|
textStyle = 'text-bia-coolgrey';
|
|
3749
4436
|
}
|
|
3750
|
-
return (React.createElement("button", { type: "button", key: date.toString(), className: "bianic-datepicker-calendar-day flex h-[31px] items-center justify-center ".concat(customClassname, " ").concat(dayStateClass), disabled: isOutOfRange,
|
|
4437
|
+
return (React.createElement("button", { type: "button", key: date.toString(), className: "bianic-datepicker-calendar-day flex h-[31px] items-center justify-center ".concat(customClassname, " ").concat(dayStateClass, " ").concat(FOCUS_RING), disabled: isOutOfRange, "data-date": dateKey, "data-calendar-cell": "", tabIndex: dateKey === activeKey ? 0 : -1, onKeyDown: function (event) { return handleKeyDown(event, date); }, onClick: function () {
|
|
4438
|
+
setActiveState({ key: dateKey, view: viewKey });
|
|
4439
|
+
onDateSelect(date);
|
|
4440
|
+
} },
|
|
3751
4441
|
React.createElement(Text, { variant: "small-text", extended: textStyle }, date.getDate())));
|
|
3752
4442
|
}))));
|
|
3753
4443
|
}
|
|
@@ -3770,8 +4460,10 @@ function MonthDisplay(_a) {
|
|
|
3770
4460
|
return dateYear === viewYearValue && dateMonth === monthIndex;
|
|
3771
4461
|
});
|
|
3772
4462
|
};
|
|
3773
|
-
|
|
3774
|
-
|
|
4463
|
+
var gridRef = useRef(null);
|
|
4464
|
+
var _b = useState(null), activeIndexState = _b[0], setActiveIndexState = _b[1];
|
|
4465
|
+
var isMonthOutOfRange = function (index) {
|
|
4466
|
+
return !!((minDateValue &&
|
|
3775
4467
|
minDateValue.getFullYear() <= viewYearValue &&
|
|
3776
4468
|
index <
|
|
3777
4469
|
(minDateValue.getFullYear() === viewYearValue
|
|
@@ -3783,6 +4475,42 @@ function MonthDisplay(_a) {
|
|
|
3783
4475
|
(maxDateValue.getFullYear() === viewYearValue
|
|
3784
4476
|
? maxDateValue.getMonth()
|
|
3785
4477
|
: 11)));
|
|
4478
|
+
};
|
|
4479
|
+
// The month in the tab order: the one reached with the arrows, else the
|
|
4480
|
+
// selected month, else the current month, else the first enabled month.
|
|
4481
|
+
var todayDate = new Date(TODAY_VALUE);
|
|
4482
|
+
var selectedIndex = MONTH_MAP.findIndex(function (_, index) {
|
|
4483
|
+
return isMonthAlreadySelected(index);
|
|
4484
|
+
});
|
|
4485
|
+
var activeIndex = -1;
|
|
4486
|
+
var candidates = [
|
|
4487
|
+
activeIndexState,
|
|
4488
|
+
selectedIndex,
|
|
4489
|
+
todayDate.getFullYear() === viewYearValue ? todayDate.getMonth() : -1,
|
|
4490
|
+
];
|
|
4491
|
+
var preferred = candidates.find(function (candidate) {
|
|
4492
|
+
return candidate !== null && candidate >= 0 && !isMonthOutOfRange(candidate);
|
|
4493
|
+
});
|
|
4494
|
+
if (preferred !== undefined && preferred !== null) {
|
|
4495
|
+
activeIndex = preferred;
|
|
4496
|
+
}
|
|
4497
|
+
else {
|
|
4498
|
+
activeIndex = MONTH_MAP.findIndex(function (_, index) { return !isMonthOutOfRange(index); });
|
|
4499
|
+
}
|
|
4500
|
+
var handleKeyDown = function (event, index) {
|
|
4501
|
+
var _a, _b;
|
|
4502
|
+
if (!isArrowKey(event.key))
|
|
4503
|
+
return;
|
|
4504
|
+
event.preventDefault();
|
|
4505
|
+
var target = index + getArrowStep(event.key, 3);
|
|
4506
|
+
// Stop at the edges of the grid and at months that are not allowed.
|
|
4507
|
+
if (target < 0 || target > 11 || isMonthOutOfRange(target))
|
|
4508
|
+
return;
|
|
4509
|
+
setActiveIndexState(target);
|
|
4510
|
+
(_b = (_a = gridRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("[data-index=\"".concat(target, "\"]"))) === null || _b === void 0 ? void 0 : _b.focus();
|
|
4511
|
+
};
|
|
4512
|
+
return (React.createElement("div", { ref: gridRef, className: "bianic-datepicker-calendar-month-grid grid grid-cols-3 gap-y-1.5" }, MONTH_MAP.map(function (month, index) {
|
|
4513
|
+
var isOutOfRange = isMonthOutOfRange(index);
|
|
3786
4514
|
var isAlreadySelected = isMonthAlreadySelected(index);
|
|
3787
4515
|
var isSelected = selectedDate &&
|
|
3788
4516
|
(Array.isArray(selectedDate) ? selectedDate[0] : selectedDate) &&
|
|
@@ -3804,19 +4532,49 @@ function MonthDisplay(_a) {
|
|
|
3804
4532
|
}
|
|
3805
4533
|
return (React.createElement("button", { type: "button", key: month, onClick: function (e) {
|
|
3806
4534
|
e.stopPropagation();
|
|
4535
|
+
setActiveIndexState(index);
|
|
3807
4536
|
onMonthSelect(index);
|
|
3808
|
-
}, disabled: isOutOfRange, className: "bianic-datepicker-calendar-month mx-[15px] flex h-[31px] items-center justify-center rounded-full ".concat(isSelected || isAlreadySelected
|
|
4537
|
+
}, onKeyDown: function (e) { return handleKeyDown(e, index); }, disabled: isOutOfRange, "data-index": index, "data-calendar-cell": "", tabIndex: index === activeIndex ? 0 : -1, className: "bianic-datepicker-calendar-month mx-[15px] flex h-[31px] items-center justify-center rounded-full ".concat(isSelected || isAlreadySelected
|
|
3809
4538
|
? 'border border-bia-blue-dark-10 bg-bia-blue-dark-10'
|
|
3810
|
-
: 'enabled:hover:bg-bia-blue-pastel') },
|
|
4539
|
+
: 'enabled:hover:bg-bia-blue-pastel', " ").concat(FOCUS_RING) },
|
|
3811
4540
|
React.createElement(Text, { variant: "small-text", extended: textStyle }, month.slice(0, 3))));
|
|
3812
4541
|
})));
|
|
3813
4542
|
}
|
|
3814
4543
|
|
|
3815
4544
|
function YearDisplay(_a) {
|
|
3816
4545
|
var yearDisplayRange = _a.yearDisplayRange, viewYearValue = _a.viewYearValue, minDateValue = _a.minDateValue, maxDateValue = _a.maxDateValue, onYearSelect = _a.onYearSelect;
|
|
3817
|
-
|
|
3818
|
-
|
|
4546
|
+
var gridRef = useRef(null);
|
|
4547
|
+
var _b = useState(null), activeYearState = _b[0], setActiveYearState = _b[1];
|
|
4548
|
+
var isYearOutOfRange = function (year) {
|
|
4549
|
+
return !!((minDateValue && year < minDateValue.getFullYear()) ||
|
|
3819
4550
|
(maxDateValue && year > maxDateValue.getFullYear()));
|
|
4551
|
+
};
|
|
4552
|
+
// The year in the tab order: the one reached with the arrows, else the
|
|
4553
|
+
// selected year, else the current year, else the first enabled year.
|
|
4554
|
+
var currentYear = new Date(TODAY_VALUE).getFullYear();
|
|
4555
|
+
var preferredYear = [activeYearState, viewYearValue, currentYear].find(function (candidate) {
|
|
4556
|
+
return candidate !== null &&
|
|
4557
|
+
yearDisplayRange.includes(candidate) &&
|
|
4558
|
+
!isYearOutOfRange(candidate);
|
|
4559
|
+
});
|
|
4560
|
+
var activeYear = preferredYear !== null && preferredYear !== void 0 ? preferredYear : yearDisplayRange.find(function (year) { return !isYearOutOfRange(year); });
|
|
4561
|
+
var handleKeyDown = function (event, index) {
|
|
4562
|
+
var _a, _b;
|
|
4563
|
+
if (!isArrowKey(event.key))
|
|
4564
|
+
return;
|
|
4565
|
+
event.preventDefault();
|
|
4566
|
+
var targetIndex = index + getArrowStep(event.key, 4);
|
|
4567
|
+
// Stop at the edges of the grid and at years that are not allowed.
|
|
4568
|
+
if (targetIndex < 0 || targetIndex >= yearDisplayRange.length)
|
|
4569
|
+
return;
|
|
4570
|
+
var targetYear = yearDisplayRange[targetIndex];
|
|
4571
|
+
if (isYearOutOfRange(targetYear))
|
|
4572
|
+
return;
|
|
4573
|
+
setActiveYearState(targetYear);
|
|
4574
|
+
(_b = (_a = gridRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("[data-year=\"".concat(targetYear, "\"]"))) === null || _b === void 0 ? void 0 : _b.focus();
|
|
4575
|
+
};
|
|
4576
|
+
return (React.createElement("div", { ref: gridRef, className: "bianic-datepicker-calendar-year-grid grid grid-cols-4 gap-y-1.5" }, yearDisplayRange.map(function (year, index) {
|
|
4577
|
+
var isOutOfRange = isYearOutOfRange(year);
|
|
3820
4578
|
var isSelected = year === viewYearValue;
|
|
3821
4579
|
var isEdgeYear = index === 0 || index === 11;
|
|
3822
4580
|
var textStyle = 'text-bia-black';
|
|
@@ -3831,10 +4589,11 @@ function YearDisplay(_a) {
|
|
|
3831
4589
|
}
|
|
3832
4590
|
return (React.createElement("button", { type: "button", key: year, onClick: function (e) {
|
|
3833
4591
|
e.stopPropagation();
|
|
4592
|
+
setActiveYearState(year);
|
|
3834
4593
|
onYearSelect(year);
|
|
3835
|
-
}, disabled: isOutOfRange, className: "bianic-datepicker-calendar-month mx-[6px] flex h-[31px] items-center justify-center rounded-full ".concat(isSelected
|
|
4594
|
+
}, onKeyDown: function (e) { return handleKeyDown(e, index); }, disabled: isOutOfRange, "data-year": year, "data-calendar-cell": "", tabIndex: year === activeYear ? 0 : -1, className: "bianic-datepicker-calendar-month mx-[6px] flex h-[31px] items-center justify-center rounded-full ".concat(isSelected
|
|
3836
4595
|
? 'border border-bia-blue-dark-10 bg-bia-blue-dark-10'
|
|
3837
|
-
: 'enabled:hover:bg-bia-blue-pastel', " ").concat(isEdgeYear ? 'text-bia-coolgrey' : '') },
|
|
4596
|
+
: 'enabled:hover:bg-bia-blue-pastel', " ").concat(isEdgeYear ? 'text-bia-coolgrey' : '', " ").concat(FOCUS_RING) },
|
|
3838
4597
|
React.createElement(Text, { variant: "small-text", extended: textStyle }, year)));
|
|
3839
4598
|
})));
|
|
3840
4599
|
}
|
|
@@ -3855,26 +4614,36 @@ function PickerHeader(_a) {
|
|
|
3855
4614
|
else if (pickerMode === 'month') {
|
|
3856
4615
|
handleNext = handleNextYear;
|
|
3857
4616
|
}
|
|
4617
|
+
var prevLabels = {
|
|
4618
|
+
date: 'Previous month',
|
|
4619
|
+
month: 'Previous year',
|
|
4620
|
+
year: 'Previous years',
|
|
4621
|
+
};
|
|
4622
|
+
var nextLabels = {
|
|
4623
|
+
date: 'Next month',
|
|
4624
|
+
month: 'Next year',
|
|
4625
|
+
year: 'Next years',
|
|
4626
|
+
};
|
|
3858
4627
|
return (React.createElement("div", { className: "bianic-datepicker-calendar-controller flex w-full items-center justify-between" },
|
|
3859
|
-
React.createElement("button", { type: "button", className: "bianic-datepicker-calendar-prev-button text-bia-coolgrey disabled:text-bia-coolgrey-light-50", disabled: isPrevDisabled ? isPrevDisabled() : false, onClick: handlePrev },
|
|
3860
|
-
React.createElement(TbChevronLeft, { size: 18 })),
|
|
4628
|
+
React.createElement("button", { type: "button", "aria-label": prevLabels[pickerMode], className: "bianic-datepicker-calendar-prev-button rounded text-bia-coolgrey disabled:text-bia-coolgrey-light-50 ".concat(FOCUS_RING), disabled: isPrevDisabled ? isPrevDisabled() : false, onClick: handlePrev },
|
|
4629
|
+
React.createElement(TbChevronLeft, { size: 18, "aria-hidden": "true" })),
|
|
3861
4630
|
React.createElement("div", { className: "bianic-datepicker-calendar-current-month flex items-center justify-center gap-1" },
|
|
3862
|
-
React.createElement("button", { type: "button", className: pickerMode === 'date' ? '' : 'hidden', onClick: function (e) {
|
|
4631
|
+
React.createElement("button", { type: "button", className: "".concat(pickerMode === 'date' ? '' : 'hidden', " rounded ").concat(FOCUS_RING), onClick: function (e) {
|
|
3863
4632
|
e.stopPropagation();
|
|
3864
4633
|
handlePickerMode('month');
|
|
3865
4634
|
} },
|
|
3866
4635
|
React.createElement(Text, { variant: "normal-text-semibold" },
|
|
3867
4636
|
MONTH_MAP[viewMonthValue],
|
|
3868
4637
|
' ')),
|
|
3869
|
-
React.createElement("button", { type: "button", className: pickerMode === 'date' || pickerMode === 'month' ? '' : 'hidden', onClick: function (e) {
|
|
4638
|
+
React.createElement("button", { type: "button", className: "".concat(pickerMode === 'date' || pickerMode === 'month' ? '' : 'hidden', " rounded ").concat(FOCUS_RING), onClick: function (e) {
|
|
3870
4639
|
e.stopPropagation();
|
|
3871
4640
|
handlePickerMode('year');
|
|
3872
4641
|
} },
|
|
3873
4642
|
React.createElement(Text, { variant: "normal-text" }, viewYearValue)),
|
|
3874
|
-
React.createElement("button", { type: "button", className: pickerMode === 'year' ? '' : 'hidden' },
|
|
4643
|
+
React.createElement("button", { type: "button", className: "".concat(pickerMode === 'year' ? '' : 'hidden', " rounded ").concat(FOCUS_RING) },
|
|
3875
4644
|
React.createElement(Text, { variant: "normal-text" }, "".concat(yearDisplayRange[1], " - ").concat(yearDisplayRange[10])))),
|
|
3876
|
-
React.createElement("button", { type: "button", className: "bianic-datepicker-calendar-next-button text-bia-coolgrey disabled:text-bia-coolgrey-light-50", disabled: isNextDisabled ? isNextDisabled() : false, onClick: handleNext },
|
|
3877
|
-
React.createElement(TbChevronRight, { size: 18 }))));
|
|
4645
|
+
React.createElement("button", { type: "button", "aria-label": nextLabels[pickerMode], className: "bianic-datepicker-calendar-next-button rounded text-bia-coolgrey disabled:text-bia-coolgrey-light-50 ".concat(FOCUS_RING), disabled: isNextDisabled ? isNextDisabled() : false, onClick: handleNext },
|
|
4646
|
+
React.createElement(TbChevronRight, { size: 18, "aria-hidden": "true" }))));
|
|
3878
4647
|
}
|
|
3879
4648
|
|
|
3880
4649
|
var useCalendarLogic = function (selectedDate, minDate, maxDate) {
|
|
@@ -4018,12 +4787,12 @@ var useCalendarLogic = function (selectedDate, minDate, maxDate) {
|
|
|
4018
4787
|
};
|
|
4019
4788
|
|
|
4020
4789
|
function PickerContent(_a) {
|
|
4021
|
-
var selectedDate = _a.selectedDate, onDateSelect = _a.onDateSelect, _b = _a.initialViewMonth, initialViewMonth = _b === void 0 ? undefined : _b, _c = _a.initialViewYear, initialViewYear = _c === void 0 ? undefined : _c, minDate = _a.minDate, maxDate = _a.maxDate, _d = _a.onPrevMonth, onPrevMonth = _d === void 0 ? undefined : _d, _e = _a.onNextMonth, onNextMonth = _e === void 0 ? undefined : _e, _f = _a.onMonthSelect, onMonthSelect = _f === void 0 ? undefined : _f, _g = _a.onYearSelect, onYearSelect = _g === void 0 ? undefined : _g;
|
|
4022
|
-
var
|
|
4790
|
+
var selectedDate = _a.selectedDate, onDateSelect = _a.onDateSelect, _b = _a.initialViewMonth, initialViewMonth = _b === void 0 ? undefined : _b, _c = _a.initialViewYear, initialViewYear = _c === void 0 ? undefined : _c, minDate = _a.minDate, maxDate = _a.maxDate, _d = _a.onPrevMonth, onPrevMonth = _d === void 0 ? undefined : _d, _e = _a.onNextMonth, onNextMonth = _e === void 0 ? undefined : _e, _f = _a.onMonthSelect, onMonthSelect = _f === void 0 ? undefined : _f, _g = _a.onYearSelect, onYearSelect = _g === void 0 ? undefined : _g, _h = _a.isOpen, isOpen = _h === void 0 ? true : _h;
|
|
4791
|
+
var _j = useCalendarLogic(
|
|
4023
4792
|
// use first selectedDate if array
|
|
4024
4793
|
Array.isArray(selectedDate)
|
|
4025
4794
|
? selectedDate[0]
|
|
4026
|
-
: selectedDate, minDate, maxDate), pickerMode =
|
|
4795
|
+
: selectedDate, minDate, maxDate), pickerMode = _j.pickerMode, viewMonthValue = _j.viewMonthValue, viewYearValue = _j.viewYearValue, yearDisplayRange = _j.yearDisplayRange, isPrevDisabled = _j.isPrevDisabled, isNextDisabled = _j.isNextDisabled, internalHandlePrevMonth = _j.handlePrevMonth, handlePrevYear = _j.handlePrevYear, handlePrevDecade = _j.handlePrevDecade, internalHandleNextMonth = _j.handleNextMonth, handleNextYear = _j.handleNextYear, handleNextDecade = _j.handleNextDecade, handlePickerMode = _j.handlePickerMode, getDisplayDays = _j.getDisplayDays, setViewMonthValue = _j.setViewMonthValue, setViewYearValue = _j.setViewYearValue, maxDateValue = _j.maxDateValue, minDateValue = _j.minDateValue;
|
|
4027
4796
|
useEffect(function () {
|
|
4028
4797
|
if (typeof initialViewMonth === 'number') {
|
|
4029
4798
|
setViewMonthValue(initialViewMonth);
|
|
@@ -4036,32 +4805,58 @@ function PickerContent(_a) {
|
|
|
4036
4805
|
var handlePrevMonth = onPrevMonth || internalHandlePrevMonth;
|
|
4037
4806
|
var handleNextMonth = onNextMonth || internalHandleNextMonth;
|
|
4038
4807
|
var days = getDisplayDays(viewMonthValue, viewYearValue);
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4808
|
+
var rootRef = useRef(null);
|
|
4809
|
+
// Set when the view changes, so focus follows to the new grid.
|
|
4810
|
+
var focusGridRef = useRef(false);
|
|
4811
|
+
var changePickerMode = function (mode) {
|
|
4812
|
+
focusGridRef.current = true;
|
|
4813
|
+
handlePickerMode(mode);
|
|
4814
|
+
};
|
|
4815
|
+
useEffect(function () {
|
|
4816
|
+
if (!focusGridRef.current)
|
|
4817
|
+
return;
|
|
4818
|
+
focusGridRef.current = false;
|
|
4819
|
+
focusActiveCell(rootRef.current);
|
|
4820
|
+
}, [pickerMode]);
|
|
4821
|
+
var prevDisabled = isPrevDisabled();
|
|
4822
|
+
var nextDisabled = isNextDisabled();
|
|
4823
|
+
useEffect(function () {
|
|
4824
|
+
var _a;
|
|
4825
|
+
var active = document.activeElement;
|
|
4826
|
+
if (active instanceof HTMLButtonElement &&
|
|
4827
|
+
active.disabled &&
|
|
4828
|
+
((_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.contains(active))) {
|
|
4829
|
+
focusActiveCell(rootRef.current);
|
|
4830
|
+
}
|
|
4831
|
+
}, [prevDisabled, nextDisabled]);
|
|
4832
|
+
return (React.createElement("div", { ref: rootRef, className: "picker-body flex w-[250px] flex-col gap-[15px]" },
|
|
4833
|
+
React.createElement(PickerHeader, { pickerMode: pickerMode, viewMonthValue: viewMonthValue, viewYearValue: viewYearValue, yearDisplayRange: yearDisplayRange, isPrevDisabled: isPrevDisabled, isNextDisabled: isNextDisabled, handlePrevMonth: handlePrevMonth, handlePrevYear: handlePrevYear, handlePrevDecade: handlePrevDecade, handleNextMonth: handleNextMonth, handleNextYear: handleNextYear, handleNextDecade: handleNextDecade, handlePickerMode: changePickerMode }),
|
|
4834
|
+
pickerMode === 'date' && (React.createElement(DateDisplay, { displayDays: days, maxDateValue: maxDateValue, minDateValue: minDateValue, onDateSelect: onDateSelect, selectedDate: selectedDate, viewMonthValue: viewMonthValue, viewYearValue: viewYearValue, isOpen: isOpen, onNavigateMonth: function (direction) {
|
|
4835
|
+
return direction === 'prev' ? handlePrevMonth() : handleNextMonth();
|
|
4836
|
+
} })),
|
|
4042
4837
|
pickerMode === 'month' && (React.createElement(MonthDisplay, { maxDateValue: maxDateValue, minDateValue: minDateValue, onMonthSelect: function (m) {
|
|
4043
4838
|
if (onMonthSelect)
|
|
4044
4839
|
onMonthSelect(m);
|
|
4045
4840
|
else
|
|
4046
4841
|
setViewMonthValue(m);
|
|
4047
|
-
|
|
4842
|
+
changePickerMode('date');
|
|
4048
4843
|
}, selectedDate: selectedDate, viewMonthValue: viewMonthValue, viewYearValue: viewYearValue })),
|
|
4049
4844
|
pickerMode === 'year' && (React.createElement(YearDisplay, { maxDateValue: maxDateValue, minDateValue: minDateValue, onYearSelect: function (y) {
|
|
4050
4845
|
if (onYearSelect)
|
|
4051
4846
|
onYearSelect(y);
|
|
4052
4847
|
else
|
|
4053
4848
|
setViewYearValue(y);
|
|
4054
|
-
|
|
4849
|
+
changePickerMode('month');
|
|
4055
4850
|
}, viewYearValue: viewYearValue, yearDisplayRange: yearDisplayRange }))));
|
|
4056
4851
|
}
|
|
4057
4852
|
|
|
4058
4853
|
function SinglePicker(_a) {
|
|
4059
|
-
var selectedDate = _a.selectedDate, onDateChange = _a.onDateChange, minDate = _a.minDate, maxDate = _a.maxDate;
|
|
4854
|
+
var selectedDate = _a.selectedDate, onDateChange = _a.onDateChange, minDate = _a.minDate, maxDate = _a.maxDate, _b = _a.isOpen, isOpen = _b === void 0 ? true : _b;
|
|
4060
4855
|
var handleDateSelect = function (date) {
|
|
4061
4856
|
onDateChange(dateToInputString(date));
|
|
4062
4857
|
};
|
|
4063
4858
|
return (React.createElement("div", { className: "single-picker picker-body" },
|
|
4064
|
-
React.createElement(PickerContent, { selectedDate: selectedDate !== null && selectedDate !== void 0 ? selectedDate : null, onDateSelect: handleDateSelect, minDate: minDate, maxDate: maxDate })));
|
|
4859
|
+
React.createElement(PickerContent, { selectedDate: selectedDate !== null && selectedDate !== void 0 ? selectedDate : null, onDateSelect: handleDateSelect, minDate: minDate, maxDate: maxDate, isOpen: isOpen })));
|
|
4065
4860
|
}
|
|
4066
4861
|
|
|
4067
4862
|
function RangePicker(_a) {
|
|
@@ -4258,8 +5053,8 @@ function RangePicker(_a) {
|
|
|
4258
5053
|
};
|
|
4259
5054
|
return (React.createElement("div", { className: "space-y-[30px]" },
|
|
4260
5055
|
React.createElement("div", { className: "range-picker picker-body flex gap-x-[22px]" },
|
|
4261
|
-
React.createElement(PickerContent, { selectedDate: tempSelectedDate, minDate: minDate, maxDate: maxDate, onDateSelect: handleDateSelect, initialViewMonth: leftMonth, initialViewYear: leftYear, onPrevMonth: handleLeftPrevMonth, onNextMonth: handleLeftNextMonth, onMonthSelect: handleMonthSelect(0, leftYear), onYearSelect: handleYearSelectLeft }),
|
|
4262
|
-
React.createElement(PickerContent, { selectedDate: tempSelectedDate, minDate: minDate, maxDate: maxDate, onDateSelect: handleDateSelect, initialViewMonth: rightMonth, initialViewYear: rightYear, onPrevMonth: handleRightPrevMonth, onNextMonth: handleRightNextMonth, onMonthSelect: handleMonthSelect(1, rightYear), onYearSelect: handleYearSelectRight })),
|
|
5056
|
+
React.createElement(PickerContent, { selectedDate: tempSelectedDate, minDate: minDate, maxDate: maxDate, onDateSelect: handleDateSelect, initialViewMonth: leftMonth, initialViewYear: leftYear, onPrevMonth: handleLeftPrevMonth, onNextMonth: handleLeftNextMonth, onMonthSelect: handleMonthSelect(0, leftYear), onYearSelect: handleYearSelectLeft, isOpen: isPickerOpen }),
|
|
5057
|
+
React.createElement(PickerContent, { selectedDate: tempSelectedDate, minDate: minDate, maxDate: maxDate, onDateSelect: handleDateSelect, initialViewMonth: rightMonth, initialViewYear: rightYear, onPrevMonth: handleRightPrevMonth, onNextMonth: handleRightNextMonth, onMonthSelect: handleMonthSelect(1, rightYear), onYearSelect: handleYearSelectRight, isOpen: isPickerOpen })),
|
|
4263
5058
|
React.createElement("div", { className: "flex justify-between" },
|
|
4264
5059
|
React.createElement(Button, { label: "Reset", size: "sm", variant: "primary-outlined", iconLeft: React.createElement(TbRefresh, { className: "text-bia-blue", size: 14 }), onClick: function () { return setTempSelectedDate([]); } }),
|
|
4265
5060
|
React.createElement("div", { className: "flex gap-x-2.5" },
|
|
@@ -4279,19 +5074,26 @@ function PickerBody(_a) {
|
|
|
4279
5074
|
onCloseRef.current();
|
|
4280
5075
|
}
|
|
4281
5076
|
}, [isPickerOpen]);
|
|
4282
|
-
return (React.createElement("div", { className: "picker-body flex gap-x-5" }, pickerVariant === 'single' ? (React.createElement(SinglePicker, { selectedDate: selectedDate, onDateChange: onDateChange, minDate: minDate, maxDate: maxDate })) : (React.createElement(RangePicker, { selectedDate: selectedDate, onDateChange: onDateChange, minDate: minDate, maxDate: maxDate, onClose: onClose, isPickerOpen: isOpen }))));
|
|
5077
|
+
return (React.createElement("div", { className: "picker-body flex gap-x-5" }, pickerVariant === 'single' ? (React.createElement(SinglePicker, { selectedDate: selectedDate, onDateChange: onDateChange, minDate: minDate, maxDate: maxDate, isOpen: isOpen })) : (React.createElement(RangePicker, { selectedDate: selectedDate, onDateChange: onDateChange, minDate: minDate, maxDate: maxDate, onClose: onClose, isPickerOpen: isOpen }))));
|
|
4283
5078
|
}
|
|
4284
5079
|
var PickerCalendar = function (_a) {
|
|
4285
5080
|
var _b = _a.zIndex, zIndex = _b === void 0 ? 100 : _b, anchorRef = _a.anchorRef, maxDate = _a.maxDate, minDate = _a.minDate, onDateChange = _a.onDateChange; _a.ref; var _c = _a.selectedDate, selectedDate = _c === void 0 ? null : _c, _d = _a.isOpen, isOpen = _d === void 0 ? false : _d, _e = _a.onClose, onClose = _e === void 0 ? function () { } : _e, _f = _a.pickerVariant, pickerVariant = _f === void 0 ? 'range' : _f, props = __rest(_a, ["zIndex", "anchorRef", "maxDate", "minDate", "onDateChange", "ref", "selectedDate", "isOpen", "onClose", "pickerVariant"]);
|
|
4286
5081
|
// Hooks & States
|
|
4287
5082
|
var pickerCalendarRef = useRef(null);
|
|
4288
5083
|
var _g = useDetectOutsideClick(anchorRef, false, pickerCalendarRef), isPickerOpen = _g[0], setIsPickerOpen = _g[1];
|
|
4289
|
-
var style = props.style, className = props.className, restProps = __rest(props, ["style", "className"]);
|
|
5084
|
+
var style = props.style, className = props.className, onKeyDown = props.onKeyDown, restProps = __rest(props, ["style", "className", "onKeyDown"]);
|
|
4290
5085
|
var positionStyle = usePopupPosition(anchorRef, pickerCalendarRef)[0];
|
|
4291
5086
|
useEffect(function () {
|
|
4292
5087
|
setIsPickerOpen(isOpen);
|
|
4293
5088
|
}, [isOpen, setIsPickerOpen]);
|
|
4294
|
-
return createPortal(
|
|
5089
|
+
return createPortal(
|
|
5090
|
+
// Escape and Tab are handled on the dialog root, not on a control.
|
|
5091
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
5092
|
+
React.createElement("div", __assign({ className: "bianic-datepicker-calendar absolute rounded-b-radius-sm bg-bia-white px-1.5 pb-[17px] pt-[15px] text-bia-black shadow-md ".concat(className), ref: pickerCalendarRef, role: "dialog", "aria-label": pickerVariant === 'single' ? 'Choose date' : 'Choose date range', style: __assign(__assign({ zIndex: zIndex, display: isPickerOpen ? 'flex' : 'none' }, positionStyle), style) }, restProps, { onKeyDown: function (event) {
|
|
5093
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
5094
|
+
if (!event.defaultPrevented)
|
|
5095
|
+
handleDialogKeyDown(event, onClose);
|
|
5096
|
+
} }),
|
|
4295
5097
|
React.createElement(PickerBody, { selectedDate: selectedDate, minDate: minDate, maxDate: maxDate, onDateChange: onDateChange, isPickerOpen: isPickerOpen, pickerVariant: pickerVariant, onClose: onClose, isOpen: isOpen })), document.body);
|
|
4296
5098
|
};
|
|
4297
5099
|
|
|
@@ -4318,7 +5120,7 @@ var displayDateFormatter = function (date) {
|
|
|
4318
5120
|
return "".concat(date.getDate(), " ").concat(monthMap[date.getMonth()].slice(0, 3), " '").concat(date.getFullYear().toString().slice(2, 4));
|
|
4319
5121
|
};
|
|
4320
5122
|
var DateInputDisplay = forwardRef(function (_a, ref) {
|
|
4321
|
-
var value = _a.value, _b = _a.setValue, setValue = _b === void 0 ? function () { } : _b, _c = _a.placeholder, placeholder = _c === void 0 ? 'YYYY-MM-DD' : _c, _d = _a.label, label = _d === void 0 ? '' : _d, required = _a.required, readOnly = _a.readOnly, id = _a.id, _e = _a.size, size = _e === void 0 ? 'sm' : _e, className = _a.className, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.buttonAction, buttonAction = _g === void 0 ? function () { } : _g, _h = _a.nullDisplay, nullDisplay = _h === void 0 ? '' : _h;
|
|
5123
|
+
var value = _a.value, _b = _a.setValue, setValue = _b === void 0 ? function () { } : _b, _c = _a.placeholder, placeholder = _c === void 0 ? 'YYYY-MM-DD' : _c, _d = _a.label, label = _d === void 0 ? '' : _d, required = _a.required, readOnly = _a.readOnly, id = _a.id, _e = _a.size, size = _e === void 0 ? 'sm' : _e, className = _a.className, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.buttonAction, buttonAction = _g === void 0 ? function () { } : _g, _h = _a.nullDisplay, nullDisplay = _h === void 0 ? '' : _h, _j = _a.toggleButtonRef, toggleButtonRef = _j === void 0 ? undefined : _j, _k = _a.toggleLabel, toggleLabel = _k === void 0 ? 'Choose date' : _k, _l = _a.isOpen, isOpen = _l === void 0 ? false : _l;
|
|
4322
5124
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
|
|
4323
5125
|
_a.isActive;
|
|
4324
5126
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
|
|
@@ -4342,10 +5144,10 @@ var DateInputDisplay = forwardRef(function (_a, ref) {
|
|
|
4342
5144
|
viewValue = displayDateFormatter(new Date(value));
|
|
4343
5145
|
}
|
|
4344
5146
|
}
|
|
4345
|
-
var
|
|
4346
|
-
var
|
|
5147
|
+
var _m = useState(false), isEditing = _m[0], setIsEditing = _m[1];
|
|
5148
|
+
var _o = useState(inputValue), dateString = _o[0], setDateString = _o[1];
|
|
4347
5149
|
var fieldStyle = styleConfig.text.fieldStyle;
|
|
4348
|
-
var
|
|
5150
|
+
var _p = sizeConfig$d[size], iconSize = _p.iconSize, fieldSize = _p.fieldSize, iconPosition = _p.iconPosition;
|
|
4349
5151
|
var borderStyle = 'border border-bia-grey-dark-10 bg-primary-white';
|
|
4350
5152
|
var extendedInputClassName = "w-full ".concat(fieldStyle, " ").concat(fieldSize, " ").concat(borderStyle, " ").concat(className);
|
|
4351
5153
|
var handleTextChange = function (event) {
|
|
@@ -4365,14 +5167,19 @@ var DateInputDisplay = forwardRef(function (_a, ref) {
|
|
|
4365
5167
|
if (setValue)
|
|
4366
5168
|
setValue('');
|
|
4367
5169
|
};
|
|
4368
|
-
|
|
5170
|
+
// Runs when focus leaves the whole field. Moving from the text to the
|
|
5171
|
+
// icon stays inside the field, so editing continues.
|
|
5172
|
+
var handleBlur = function (event) {
|
|
5173
|
+
if (event.currentTarget.contains(event.relatedTarget)) {
|
|
5174
|
+
return;
|
|
5175
|
+
}
|
|
4369
5176
|
setIsEditing(false);
|
|
4370
5177
|
setDateString(inputValue);
|
|
4371
5178
|
};
|
|
4372
|
-
var input = isEditing || disabled ? (React.createElement(TextInput, { type: "text", value: dateString !== null && dateString !== void 0 ? dateString : '', onChange: handleTextChange,
|
|
4373
|
-
buttonAction === null || buttonAction === void 0 ? void 0 : buttonAction();
|
|
5179
|
+
var input = isEditing || disabled ? (React.createElement(TextInput, { type: "text", value: dateString !== null && dateString !== void 0 ? dateString : '', onChange: handleTextChange, placeholder: placeholder, size: size, inputClassName: extendedInputClassName, autoFocus: true, disabled: disabled, actionElement: React.createElement("button", { type: "button", ref: toggleButtonRef, "aria-label": toggleLabel, "aria-haspopup": "dialog", "aria-expanded": isOpen, className: "bianic-datepicker-toggle-button rounded text-bia-coolgrey disabled:cursor-not-allowed ".concat(FOCUS_RING), disabled: disabled, onClick: function (event) {
|
|
5180
|
+
buttonAction === null || buttonAction === void 0 ? void 0 : buttonAction(event);
|
|
4374
5181
|
} },
|
|
4375
|
-
React.createElement(TbCalendar, { size: iconSize })) })) : (React.createElement(React.Fragment, null,
|
|
5182
|
+
React.createElement(TbCalendar, { size: iconSize, "aria-hidden": "true" })) })) : (React.createElement(React.Fragment, null,
|
|
4376
5183
|
React.createElement("div", { role: "button", tabIndex: 0, onClick: function () { return setIsEditing(true); }, onKeyDown: function (e) {
|
|
4377
5184
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
4378
5185
|
e.preventDefault();
|
|
@@ -4380,8 +5187,8 @@ var DateInputDisplay = forwardRef(function (_a, ref) {
|
|
|
4380
5187
|
}
|
|
4381
5188
|
}, 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),
|
|
4382
5189
|
React.createElement("div", { className: "absolute inset-y-0 flex items-center pl-3 text-bia-coolgrey ".concat(iconPosition) },
|
|
4383
|
-
React.createElement("button", { type: "button", className: "bianic-datepicker-toggle-button", disabled: disabled, onClick: function () { return buttonAction
|
|
4384
|
-
React.createElement(TbCalendar, { size: iconSize })))));
|
|
5190
|
+
React.createElement("button", { type: "button", ref: toggleButtonRef, "aria-label": toggleLabel, "aria-haspopup": "dialog", "aria-expanded": isOpen, className: "bianic-datepicker-toggle-button rounded ".concat(FOCUS_RING), disabled: disabled, onClick: function (event) { return buttonAction === null || buttonAction === void 0 ? void 0 : buttonAction(event); } },
|
|
5191
|
+
React.createElement(TbCalendar, { size: iconSize, "aria-hidden": "true" })))));
|
|
4385
5192
|
useEffect(function () {
|
|
4386
5193
|
// Only update dateString if we are NOT currently editing.
|
|
4387
5194
|
if (!isEditing)
|
|
@@ -4389,7 +5196,7 @@ var DateInputDisplay = forwardRef(function (_a, ref) {
|
|
|
4389
5196
|
}, [inputValue, isEditing]);
|
|
4390
5197
|
return (React.createElement("div", { className: "bianic-date-input-container bianic-fgc-container flex w-full flex-col gap-y-2 text-bia-black" },
|
|
4391
5198
|
label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
|
|
4392
|
-
React.createElement("div", { className: "relative w-full", ref: ref }, input)));
|
|
5199
|
+
React.createElement("div", { className: "relative w-full", ref: ref, onBlur: handleBlur }, input)));
|
|
4393
5200
|
});
|
|
4394
5201
|
DateInputDisplay.defaultProps = {
|
|
4395
5202
|
setValue: undefined,
|
|
@@ -4399,26 +5206,68 @@ DateInputDisplay.defaultProps = {
|
|
|
4399
5206
|
setIsActive: undefined,
|
|
4400
5207
|
buttonAction: undefined,
|
|
4401
5208
|
nullDisplay: undefined,
|
|
5209
|
+
toggleButtonRef: undefined,
|
|
5210
|
+
toggleLabel: undefined,
|
|
5211
|
+
isOpen: undefined,
|
|
4402
5212
|
};
|
|
4403
5213
|
|
|
4404
5214
|
function DatePicker(_a) {
|
|
4405
5215
|
var _b = _a.zIndexCalendar, zIndexCalendar = _b === void 0 ? 100 : _b, _c = _a.value, value = _c === void 0 ? '' : _c, _d = _a.onChange, onChange = _d === void 0 ? function () { } : _d, _e = _a.variant, variant = _e === void 0 ? 'single' : _e, _f = _a.size, size = _f === void 0 ? 'sm' : _f, _g = _a.disabled, disabled = _g === void 0 ? false : _g, _h = _a.placeholder, placeholder = _h === void 0 ? '"YYYY-MM-DD"' : _h, _j = _a.label, label = _j === void 0 ? '' : _j, _k = _a.minDate, minDate = _k === void 0 ? '' : _k, _l = _a.maxDate, maxDate = _l === void 0 ? '' : _l, _m = _a.required, required = _m === void 0 ? false : _m, _o = _a.nullDisplay, nullDisplay = _o === void 0 ? '' : _o, _p = _a.inputClassName, inputClassName = _p === void 0 ? '' : _p, _q = _a.containerClassName, containerClassName = _q === void 0 ? '' : _q;
|
|
4406
5216
|
// State and Ref
|
|
4407
5217
|
var inputRef = useRef(null);
|
|
5218
|
+
var toggleButtonRef = useRef(null);
|
|
5219
|
+
var focusOnOpenRef = useRef(false);
|
|
5220
|
+
var calendarId = useId();
|
|
4408
5221
|
var _r = useState(false), isPickerOpen = _r[0], setIsPickerOpen = _r[1];
|
|
5222
|
+
// Enter or Space on the icon fires a click with detail 0. Only then does
|
|
5223
|
+
// focus move into the popup, so mouse use keeps focus where it is.
|
|
5224
|
+
var handleButtonAction = function (event) {
|
|
5225
|
+
var willOpen = !isPickerOpen;
|
|
5226
|
+
focusOnOpenRef.current = willOpen && (event === null || event === void 0 ? void 0 : event.detail) === 0;
|
|
5227
|
+
setIsPickerOpen(willOpen);
|
|
5228
|
+
};
|
|
5229
|
+
useEffect(function () {
|
|
5230
|
+
if (!isPickerOpen || !focusOnOpenRef.current)
|
|
5231
|
+
return undefined;
|
|
5232
|
+
var frame = 0;
|
|
5233
|
+
var attempts = 0;
|
|
5234
|
+
// The popup may not be visible yet, so retry for a few frames.
|
|
5235
|
+
var tryFocus = function () {
|
|
5236
|
+
var popup = document.getElementById(calendarId);
|
|
5237
|
+
focusActiveCell(popup);
|
|
5238
|
+
attempts += 1;
|
|
5239
|
+
if ((popup === null || popup === void 0 ? void 0 : popup.contains(document.activeElement)) || attempts >= 30) {
|
|
5240
|
+
focusOnOpenRef.current = false;
|
|
5241
|
+
return;
|
|
5242
|
+
}
|
|
5243
|
+
frame = requestAnimationFrame(tryFocus);
|
|
5244
|
+
};
|
|
5245
|
+
frame = requestAnimationFrame(tryFocus);
|
|
5246
|
+
return function () { return cancelAnimationFrame(frame); };
|
|
5247
|
+
}, [isPickerOpen, calendarId]);
|
|
5248
|
+
// Closing while focus is inside the popup puts focus back on the icon.
|
|
5249
|
+
var handleClose = function () {
|
|
5250
|
+
var _a;
|
|
5251
|
+
var popup = document.getElementById(calendarId);
|
|
5252
|
+
var wasInside = !!popup && popup.contains(document.activeElement);
|
|
5253
|
+
setIsPickerOpen(false);
|
|
5254
|
+
if (wasInside)
|
|
5255
|
+
(_a = toggleButtonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
5256
|
+
};
|
|
5257
|
+
var toggleLabel = variant === 'range' ? 'Choose date range' : 'Choose date';
|
|
4409
5258
|
return (React.createElement("div", { className: "bianic-datepicker-container relative ".concat(containerClassName) },
|
|
4410
5259
|
React.createElement("div", { className: "bianic-datepicker-field-container" },
|
|
4411
|
-
React.createElement(DateInputDisplay, { className: inputClassName || '', value: value, setValue: onChange, placeholder: placeholder, nullDisplay: nullDisplay, size: size, label: label, required: required, buttonAction:
|
|
4412
|
-
React.createElement(PickerCalendar, { zIndex: zIndexCalendar, anchorRef: inputRef, selectedDate: value, pickerVariant: variant, onDateChange: onChange, minDate: minDate, maxDate: maxDate, isOpen: isPickerOpen, onClose:
|
|
5260
|
+
React.createElement(DateInputDisplay, { className: inputClassName || '', value: value, setValue: onChange, placeholder: placeholder, nullDisplay: nullDisplay, size: size, label: label, required: required, buttonAction: handleButtonAction, toggleButtonRef: toggleButtonRef, toggleLabel: toggleLabel, isOpen: isPickerOpen, ref: inputRef, disabled: disabled })),
|
|
5261
|
+
React.createElement(PickerCalendar, { id: calendarId, "aria-label": toggleLabel, zIndex: zIndexCalendar, anchorRef: inputRef, selectedDate: value, pickerVariant: variant, onDateChange: onChange, minDate: minDate, maxDate: maxDate, isOpen: isPickerOpen, onClose: handleClose })));
|
|
4413
5262
|
}
|
|
4414
5263
|
|
|
4415
5264
|
var YearPickerDisplay = forwardRef(function (_a, ref) {
|
|
4416
|
-
var value = _a.value, setValue = _a.setValue, _b = _a.placeholder, placeholder = _b === void 0 ? 'YYYY' : _b, label = _a.label, required = _a.required, readOnly = _a.readOnly, id = _a.id, _c = _a.size, size = _c === void 0 ? 'sm' : _c, className = _a.className, _d = _a.disabled, disabled = _d === void 0 ? false : _d, buttonAction = _a.buttonAction, nullDisplay = _a.nullDisplay, minYear = _a.minYear, maxYear = _a.maxYear, customErrorMessage = _a.errorMessage, onErrorChange = _a.onErrorChange, props = __rest(_a, ["value", "setValue", "placeholder", "label", "required", "readOnly", "id", "size", "className", "disabled", "buttonAction", "nullDisplay", "minYear", "maxYear", "errorMessage", "onErrorChange"]);
|
|
5265
|
+
var value = _a.value, setValue = _a.setValue, _b = _a.placeholder, placeholder = _b === void 0 ? 'YYYY' : _b, label = _a.label, required = _a.required, readOnly = _a.readOnly, id = _a.id, _c = _a.size, size = _c === void 0 ? 'sm' : _c, className = _a.className, _d = _a.disabled, disabled = _d === void 0 ? false : _d, buttonAction = _a.buttonAction, nullDisplay = _a.nullDisplay, _e = _a.toggleButtonRef, toggleButtonRef = _e === void 0 ? undefined : _e, _f = _a.toggleLabel, toggleLabel = _f === void 0 ? 'Choose year' : _f, _g = _a.isOpen, isOpen = _g === void 0 ? false : _g, minYear = _a.minYear, maxYear = _a.maxYear, customErrorMessage = _a.errorMessage, onErrorChange = _a.onErrorChange, props = __rest(_a, ["value", "setValue", "placeholder", "label", "required", "readOnly", "id", "size", "className", "disabled", "buttonAction", "nullDisplay", "toggleButtonRef", "toggleLabel", "isOpen", "minYear", "maxYear", "errorMessage", "onErrorChange"]);
|
|
4417
5266
|
var inputRef = useRef(null);
|
|
4418
5267
|
useImperativeHandle(ref, function () { return inputRef.current; });
|
|
4419
|
-
var
|
|
4420
|
-
var
|
|
4421
|
-
var
|
|
5268
|
+
var _h = useState(false), isEditing = _h[0], setIsEditing = _h[1];
|
|
5269
|
+
var _j = useState(value ? value.toString() : ''), inputValue = _j[0], setInputValue = _j[1];
|
|
5270
|
+
var _k = useState(null), internalError = _k[0], setInternalError = _k[1];
|
|
4422
5271
|
var setError = function (msg) {
|
|
4423
5272
|
setInternalError(msg);
|
|
4424
5273
|
onErrorChange === null || onErrorChange === void 0 ? void 0 : onErrorChange(msg);
|
|
@@ -4474,7 +5323,14 @@ var YearPickerDisplay = forwardRef(function (_a, ref) {
|
|
|
4474
5323
|
}
|
|
4475
5324
|
}
|
|
4476
5325
|
};
|
|
4477
|
-
|
|
5326
|
+
// Runs when focus leaves the whole field. Moving from the text to the
|
|
5327
|
+
// icon stays inside the field, so editing continues.
|
|
5328
|
+
var handleBlur = function (event) {
|
|
5329
|
+
if (!isEditing)
|
|
5330
|
+
return;
|
|
5331
|
+
if (event.currentTarget.contains(event.relatedTarget)) {
|
|
5332
|
+
return;
|
|
5333
|
+
}
|
|
4478
5334
|
setIsEditing(false);
|
|
4479
5335
|
// Case A: User left field incomplete (< 4 digits)
|
|
4480
5336
|
if (inputValue.length > 0 && inputValue.length < 4) {
|
|
@@ -4500,17 +5356,17 @@ var YearPickerDisplay = forwardRef(function (_a, ref) {
|
|
|
4500
5356
|
}
|
|
4501
5357
|
}
|
|
4502
5358
|
};
|
|
4503
|
-
var
|
|
5359
|
+
var _l = sizeConfig$d[size], iconSize = _l.iconSize, fieldSize = _l.fieldSize, iconPosition = _l.iconPosition;
|
|
4504
5360
|
var fieldStyle = styleConfig.text.fieldStyle;
|
|
4505
5361
|
var displayError = customErrorMessage || internalError;
|
|
4506
5362
|
var borderStyle = displayError
|
|
4507
5363
|
? 'border border-bia-red bg-primary-white'
|
|
4508
5364
|
: 'border border-bia-grey-dark-10 bg-primary-white';
|
|
4509
5365
|
var extendedInputClassName = "w-full ".concat(fieldStyle, " ").concat(fieldSize, " ").concat(borderStyle, " ").concat(className);
|
|
4510
|
-
var input = isEditing || disabled ? (React.createElement(TextInput, __assign({ type: "text", id: id, value: inputValue, placeholder: placeholder, size: size, inputClassName: extendedInputClassName, onChange: handleChange,
|
|
4511
|
-
buttonAction === null || buttonAction === void 0 ? void 0 : buttonAction();
|
|
5366
|
+
var input = isEditing || disabled ? (React.createElement(TextInput, __assign({ type: "text", id: id, value: inputValue, placeholder: placeholder, size: size, inputClassName: extendedInputClassName, onChange: handleChange, autoFocus: true, required: required, disabled: disabled, actionElement: React.createElement("button", { type: "button", ref: toggleButtonRef, "aria-label": toggleLabel, "aria-haspopup": "dialog", "aria-expanded": isOpen, className: "bianic-datepicker-toggle-button rounded text-bia-coolgrey disabled:cursor-not-allowed ".concat(FOCUS_RING), disabled: disabled, onClick: function (event) {
|
|
5367
|
+
buttonAction === null || buttonAction === void 0 ? void 0 : buttonAction(event);
|
|
4512
5368
|
} },
|
|
4513
|
-
React.createElement(TbCalendar, { size: iconSize })) }, props))) : (React.createElement(React.Fragment, null,
|
|
5369
|
+
React.createElement(TbCalendar, { size: iconSize, "aria-hidden": "true" })) }, props))) : (React.createElement(React.Fragment, null,
|
|
4514
5370
|
React.createElement("div", { role: "button", tabIndex: disabled ? -1 : 0, onClick: function () { return !disabled && setIsEditing(true); }, onKeyDown: function (e) {
|
|
4515
5371
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
4516
5372
|
e.preventDefault();
|
|
@@ -4519,11 +5375,11 @@ var YearPickerDisplay = forwardRef(function (_a, ref) {
|
|
|
4519
5375
|
}
|
|
4520
5376
|
}, 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),
|
|
4521
5377
|
React.createElement("div", { className: "absolute inset-y-0 right-0 flex items-center pl-3 text-bia-coolgrey ".concat(iconPosition) },
|
|
4522
|
-
React.createElement("button", { type: "button", className: "bianic-datepicker-toggle-button", disabled: disabled, onClick: function () { return buttonAction
|
|
4523
|
-
React.createElement(TbCalendar, { size: iconSize })))));
|
|
5378
|
+
React.createElement("button", { type: "button", ref: toggleButtonRef, "aria-label": toggleLabel, "aria-haspopup": "dialog", "aria-expanded": isOpen, className: "bianic-datepicker-toggle-button rounded ".concat(FOCUS_RING), disabled: disabled, onClick: function (event) { return buttonAction === null || buttonAction === void 0 ? void 0 : buttonAction(event); } },
|
|
5379
|
+
React.createElement(TbCalendar, { size: iconSize, "aria-hidden": "true" })))));
|
|
4524
5380
|
return (React.createElement("div", { className: "bianic-year-input-container bianic-fgc-container flex w-full flex-col gap-y-1 text-bia-black" },
|
|
4525
5381
|
label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
|
|
4526
|
-
React.createElement("div", { className: "relative w-full", ref: inputRef }, input),
|
|
5382
|
+
React.createElement("div", { className: "relative w-full", ref: inputRef, onBlur: handleBlur }, input),
|
|
4527
5383
|
displayError && (React.createElement("span", { className: "text-xs text-bia-red" }, displayError))));
|
|
4528
5384
|
});
|
|
4529
5385
|
YearPickerDisplay.defaultProps = {
|
|
@@ -4596,14 +5452,21 @@ var PickerYear = function (_a) {
|
|
|
4596
5452
|
var _d = useYearLogic(selectedYear, minYear, maxYear), viewYearValue = _d.viewYearValue, yearDisplayRange = _d.yearDisplayRange, isNextDisabled = _d.isNextDisabled, isPrevDisabled = _d.isPrevDisabled, handleNextDecade = _d.handleNextDecade, handleNextYear = _d.handleNextYear, handlePrevDecade = _d.handlePrevDecade, handlePrevYear = _d.handlePrevYear;
|
|
4597
5453
|
var pickerCalendarRef = useRef(null);
|
|
4598
5454
|
var _e = useDetectOutsideClick(anchorRef, false, pickerCalendarRef), isPickerOpen = _e[0], setIsPickerOpen = _e[1];
|
|
4599
|
-
var style = props.style, className = props.className, restProps = __rest(props, ["style", "className"]);
|
|
5455
|
+
var style = props.style, className = props.className, onKeyDown = props.onKeyDown, restProps = __rest(props, ["style", "className", "onKeyDown"]);
|
|
4600
5456
|
var positionStyle = usePopupPosition(anchorRef, pickerCalendarRef)[0];
|
|
4601
5457
|
var substituteMaxDate = maxYear ? new Date(maxYear, 0, 1) : null;
|
|
4602
5458
|
var substituteMinDate = minYear ? new Date(minYear, 0, 1) : null;
|
|
4603
5459
|
useEffect(function () {
|
|
4604
5460
|
setIsPickerOpen(isOpen);
|
|
4605
5461
|
}, [isOpen, setIsPickerOpen]);
|
|
4606
|
-
return createPortal(
|
|
5462
|
+
return createPortal(
|
|
5463
|
+
// Escape and Tab are handled on the dialog root, not on a control.
|
|
5464
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
5465
|
+
React.createElement("div", __assign({ className: "bianic-datepicker-calendar absolute rounded-b-radius-sm bg-bia-white px-1.5 pb-[17px] pt-[15px] text-bia-black shadow-md ".concat(className), ref: pickerCalendarRef, role: "dialog", "aria-label": "Choose year", style: __assign(__assign({ zIndex: zIndex, display: isPickerOpen ? 'flex' : 'none' }, positionStyle), style) }, restProps, { onKeyDown: function (event) {
|
|
5466
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
5467
|
+
if (!event.defaultPrevented)
|
|
5468
|
+
handleDialogKeyDown(event, onClose);
|
|
5469
|
+
} }),
|
|
4607
5470
|
React.createElement("div", { className: "picker-body flex w-[250px] flex-col gap-[15px]" },
|
|
4608
5471
|
React.createElement(PickerHeader, { pickerMode: "year", handlePickerMode: function () { }, viewYearValue: viewYearValue, yearDisplayRange: yearDisplayRange, isPrevDisabled: isPrevDisabled, isNextDisabled: isNextDisabled, handlePrevYear: handlePrevYear, handlePrevDecade: handlePrevDecade, handleNextYear: handleNextYear, handleNextDecade: handleNextDecade, viewMonthValue: 0 }),
|
|
4609
5472
|
React.createElement(YearDisplay, { maxDateValue: substituteMaxDate, minDateValue: substituteMinDate, onYearSelect: function (y) {
|
|
@@ -4615,11 +5478,49 @@ var PickerYear = function (_a) {
|
|
|
4615
5478
|
function YearPicker(_a) {
|
|
4616
5479
|
var value = _a.value, onChange = _a.onChange, _b = _a.zIndexCalendar, zIndexCalendar = _b === void 0 ? 100 : _b, _c = _a.minYear, minYear = _c === void 0 ? undefined : _c, _d = _a.maxYear, maxYear = _d === void 0 ? undefined : _d, _e = _a.size, size = _e === void 0 ? 'md' : _e, disabled = _a.disabled, _f = _a.placeholder, placeholder = _f === void 0 ? '"YYYY-MM-DD"' : _f, label = _a.label, required = _a.required, nullDisplay = _a.nullDisplay, inputClassName = _a.inputClassName, containerClassName = _a.containerClassName;
|
|
4617
5480
|
var inputRef = useRef(null);
|
|
5481
|
+
var toggleButtonRef = useRef(null);
|
|
5482
|
+
var focusOnOpenRef = useRef(false);
|
|
5483
|
+
var calendarId = useId();
|
|
4618
5484
|
var _g = useState(false), isPickerOpen = _g[0], setIsPickerOpen = _g[1];
|
|
5485
|
+
// Enter or Space on the icon fires a click with detail 0. Only then does
|
|
5486
|
+
// focus move into the popup, so mouse use keeps focus where it is.
|
|
5487
|
+
var handleButtonAction = function (event) {
|
|
5488
|
+
var willOpen = !isPickerOpen;
|
|
5489
|
+
focusOnOpenRef.current = willOpen && (event === null || event === void 0 ? void 0 : event.detail) === 0;
|
|
5490
|
+
setIsPickerOpen(willOpen);
|
|
5491
|
+
};
|
|
5492
|
+
useEffect(function () {
|
|
5493
|
+
if (!isPickerOpen || !focusOnOpenRef.current)
|
|
5494
|
+
return undefined;
|
|
5495
|
+
var frame = 0;
|
|
5496
|
+
var attempts = 0;
|
|
5497
|
+
// The popup may not be visible yet, so retry for a few frames.
|
|
5498
|
+
var tryFocus = function () {
|
|
5499
|
+
var popup = document.getElementById(calendarId);
|
|
5500
|
+
focusActiveCell(popup);
|
|
5501
|
+
attempts += 1;
|
|
5502
|
+
if ((popup === null || popup === void 0 ? void 0 : popup.contains(document.activeElement)) || attempts >= 30) {
|
|
5503
|
+
focusOnOpenRef.current = false;
|
|
5504
|
+
return;
|
|
5505
|
+
}
|
|
5506
|
+
frame = requestAnimationFrame(tryFocus);
|
|
5507
|
+
};
|
|
5508
|
+
frame = requestAnimationFrame(tryFocus);
|
|
5509
|
+
return function () { return cancelAnimationFrame(frame); };
|
|
5510
|
+
}, [isPickerOpen, calendarId]);
|
|
5511
|
+
// Closing while focus is inside the popup puts focus back on the icon.
|
|
5512
|
+
var handleClose = function () {
|
|
5513
|
+
var _a;
|
|
5514
|
+
var popup = document.getElementById(calendarId);
|
|
5515
|
+
var wasInside = !!popup && popup.contains(document.activeElement);
|
|
5516
|
+
setIsPickerOpen(false);
|
|
5517
|
+
if (wasInside)
|
|
5518
|
+
(_a = toggleButtonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
5519
|
+
};
|
|
4619
5520
|
return (React.createElement("div", { className: "bianic-yearpicker-container relative ".concat(containerClassName) },
|
|
4620
5521
|
React.createElement("div", { className: "bianic-yearpicker-field-container" },
|
|
4621
|
-
React.createElement(YearPickerDisplay, { className: inputClassName || '', value: value, setValue: onChange, placeholder: placeholder, nullDisplay: nullDisplay, size: size, label: label, required: required, buttonAction:
|
|
4622
|
-
React.createElement(PickerYear, { maxYear: maxYear, minYear: minYear, zIndex: zIndexCalendar, anchorRef: inputRef, selectedYear: value, setSelectedYear: onChange, isOpen: isPickerOpen, onClose:
|
|
5522
|
+
React.createElement(YearPickerDisplay, { className: inputClassName || '', value: value, setValue: onChange, placeholder: placeholder, nullDisplay: nullDisplay, size: size, label: label, required: required, buttonAction: handleButtonAction, toggleButtonRef: toggleButtonRef, toggleLabel: "Choose year", isOpen: isPickerOpen, ref: inputRef, disabled: disabled, minYear: minYear, maxYear: maxYear })),
|
|
5523
|
+
React.createElement(PickerYear, { id: calendarId, "aria-label": "Choose year", maxYear: maxYear, minYear: minYear, zIndex: zIndexCalendar, anchorRef: inputRef, selectedYear: value, setSelectedYear: onChange, isOpen: isPickerOpen, onClose: handleClose })));
|
|
4623
5524
|
}
|
|
4624
5525
|
|
|
4625
5526
|
/**
|
|
@@ -5403,7 +6304,7 @@ function ProgressBar(_a) {
|
|
|
5403
6304
|
iconElement = icon; // Use the provided icon
|
|
5404
6305
|
}
|
|
5405
6306
|
}
|
|
5406
|
-
return (React.createElement("div", { className: "bianic-progress-bar-container flex w-
|
|
6307
|
+
return (React.createElement("div", { className: "bianic-progress-bar-container flex w-full flex-col rounded-radius-lg bg-bia-grey-light-80 p-[10px] " },
|
|
5407
6308
|
React.createElement("div", { className: "flex items-center justify-between text-primary-black" },
|
|
5408
6309
|
React.createElement(Text, { variant: "small-text-semibold", extended: "bianic-progress-bar-title" }, title),
|
|
5409
6310
|
React.createElement("div", { className: "flex gap-1" },
|
|
@@ -6078,7 +6979,8 @@ function TableFooterController(_a) {
|
|
|
6078
6979
|
|
|
6079
6980
|
function TableHeaderController(_a) {
|
|
6080
6981
|
var _b = _a.size, size = _b === void 0 ? 'sm' : _b, _c = _a.buttonActions, buttonActions = _c === void 0 ? undefined : _c, _d = _a.totalData, totalData = _d === void 0 ? undefined : _d, _e = _a.firstIndex, firstIndex = _e === void 0 ? undefined : _e, _f = _a.lastIndex, lastIndex = _f === void 0 ? undefined : _f;
|
|
6081
|
-
|
|
6982
|
+
// Boolean(): a bare 0 would be printed by React when there are no results.
|
|
6983
|
+
var isShowHelperText = Boolean(totalData || firstIndex || lastIndex);
|
|
6082
6984
|
var paddingSize = size === 'md' ? 'py-[13px] pt-[14px] ' : 'py-[7px] pt-2';
|
|
6083
6985
|
var textSize = size === 'md' ? 'normal-text' : 'small-text';
|
|
6084
6986
|
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) },
|
|
@@ -6541,6 +7443,59 @@ function DataTable(_a) {
|
|
|
6541
7443
|
React.createElement(TableFooterController, { size: "md", currentPage: table.page, totalPages: table.totalPages, pageSize: table.pageSize, setCurrentPage: setCurrentPage, setPageSize: setPageSize, isLoading: isLoading })));
|
|
6542
7444
|
}
|
|
6543
7445
|
|
|
7446
|
+
var openStateConfig = {
|
|
7447
|
+
open: 'visible grid-rows-[1fr] opacity-100',
|
|
7448
|
+
closed: 'invisible grid-rows-[0fr] opacity-0',
|
|
7449
|
+
};
|
|
7450
|
+
var columnsConfig = {
|
|
7451
|
+
auto: 'grid-cols-[repeat(3,minmax(0,1fr))_auto]',
|
|
7452
|
+
2: 'grid-cols-2',
|
|
7453
|
+
3: 'grid-cols-3',
|
|
7454
|
+
4: 'grid-cols-4',
|
|
7455
|
+
5: 'grid-cols-5',
|
|
7456
|
+
6: 'grid-cols-6',
|
|
7457
|
+
};
|
|
7458
|
+
var panelSizeConfig = {
|
|
7459
|
+
md: 'gap-5 px-5 py-[25px]',
|
|
7460
|
+
sm: 'gap-4 px-5 py-6',
|
|
7461
|
+
};
|
|
7462
|
+
var actionsGapConfig = {
|
|
7463
|
+
md: 'gap-2.5',
|
|
7464
|
+
sm: 'gap-2',
|
|
7465
|
+
};
|
|
7466
|
+
// The buttons sit in the last column. In 'auto' that column is as wide as the
|
|
7467
|
+
// two buttons, so they stay on one line.
|
|
7468
|
+
var actionsColumnConfig = {
|
|
7469
|
+
auto: 'col-start-4 flex-nowrap whitespace-nowrap',
|
|
7470
|
+
2: 'col-start-2 flex-wrap',
|
|
7471
|
+
3: 'col-start-3 flex-wrap',
|
|
7472
|
+
4: 'col-start-4 flex-wrap',
|
|
7473
|
+
5: 'col-start-5 flex-wrap',
|
|
7474
|
+
6: 'col-start-6 flex-wrap',
|
|
7475
|
+
};
|
|
7476
|
+
|
|
7477
|
+
var SIZE_UNION = ['md', 'sm'];
|
|
7478
|
+
var COLUMNS_UNION = ['auto', 2, 3, 4, 5, 6];
|
|
7479
|
+
function TableFilterPanel(_a) {
|
|
7480
|
+
var isOpen = _a.isOpen, onApply = _a.onApply, onReset = _a.onReset, children = _a.children, _b = _a.columns, columns = _b === void 0 ? 'auto' : _b, _c = _a.size, size = _c === void 0 ? 'md' : _c, _d = _a.applyLabel, applyLabel = _d === void 0 ? 'Apply Filter' : _d, _e = _a.resetLabel, resetLabel = _e === void 0 ? 'Reset' : _e, _f = _a.className, className = _f === void 0 ? '' : _f, rest = __rest(_a, ["isOpen", "onApply", "onReset", "children", "columns", "size", "applyLabel", "resetLabel", "className"]);
|
|
7481
|
+
var safeSize = validUnion(size, SIZE_UNION);
|
|
7482
|
+
var safeColumns = validUnion(columns, COLUMNS_UNION);
|
|
7483
|
+
return (React.createElement("div", __assign({}, rest, { "data-state": isOpen ? 'open' : 'closed', className: "bianic-table-filter-panel grid transition-all duration-300 ease-in-out motion-reduce:transition-none ".concat(openStateConfig[isOpen ? 'open' : 'closed'], " ").concat(className) }),
|
|
7484
|
+
React.createElement("div", { className: "min-h-0 overflow-hidden" },
|
|
7485
|
+
React.createElement("div", { className: "grid items-end border-b border-bia-grey bg-bia-grey-light-80 ".concat(columnsConfig[safeColumns], " ").concat(panelSizeConfig[safeSize]) },
|
|
7486
|
+
children,
|
|
7487
|
+
React.createElement("div", { className: "flex items-end justify-start ".concat(actionsColumnConfig[safeColumns], " ").concat(actionsGapConfig[safeSize]) },
|
|
7488
|
+
React.createElement(Button, { variant: "default-outlined", size: safeSize, label: applyLabel, iconLeft: React.createElement(TbCheck, { size: 14, "aria-hidden": "true" }), onClick: onApply }),
|
|
7489
|
+
React.createElement(Button, { variant: "default-outlined", size: safeSize, label: resetLabel, iconLeft: React.createElement(TbRefresh, { size: 14, "aria-hidden": "true" }), onClick: onReset }))))));
|
|
7490
|
+
}
|
|
7491
|
+
|
|
7492
|
+
var TableFilterButton = forwardRef(function (_a, ref) {
|
|
7493
|
+
var isOpen = _a.isOpen, _b = _a.isActive, isActive = _b === void 0 ? false : _b, _c = _a.label, label = _c === void 0 ? 'Filter' : _c, rest = __rest(_a, ["isOpen", "isActive", "label"]);
|
|
7494
|
+
return (React.createElement(Tooltip, { content: label, direction: "bottom-left" },
|
|
7495
|
+
React.createElement(ContextualButton, __assign({ ref: ref }, rest, { icon: React.createElement(TbFilter, { size: 18, "aria-hidden": "true" }), isSelected: isOpen, isNotified: isActive, "aria-expanded": isOpen, "aria-label": isActive ? "".concat(label, " (active)") : label }))));
|
|
7496
|
+
});
|
|
7497
|
+
TableFilterButton.displayName = 'TableFilterButton';
|
|
7498
|
+
|
|
6544
7499
|
var colorConfigs = {
|
|
6545
7500
|
default: 'bg-bia-black',
|
|
6546
7501
|
info: 'bg-bia-teal',
|
|
@@ -10557,4 +11512,4 @@ var useTableDataHandler = function (initialData, options) {
|
|
|
10557
11512
|
};
|
|
10558
11513
|
};
|
|
10559
11514
|
|
|
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 };
|
|
11515
|
+
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, TableFilterButton, TableFilterPanel, 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 };
|