bianic-ui 1.9.3 → 1.10.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 +597 -129
- package/dist/cjs/lib.css +1 -1
- package/dist/cjs/types/components/Forms/DatePicker/DatePicker.d.ts +6 -0
- package/dist/cjs/types/components/Forms/DatePicker/DatePickerSimulation.d.ts +3 -0
- package/dist/cjs/types/components/Forms/DatePicker/PickerCalendar.d.ts +7 -0
- package/dist/cjs/types/components/Forms/DatePicker/index.d.ts +1 -0
- package/dist/cjs/types/components/Forms/Dropdown/DropdownItem.d.ts +5 -2
- package/dist/cjs/types/components/Forms/Dropdown/config.d.ts +6 -2
- package/dist/cjs/types/components/Forms/SegmentButton/SegmentButtonItem.d.ts +1 -1
- package/dist/cjs/types/components/Forms/SegmentButton/config.d.ts +7 -1
- package/dist/cjs/types/components/Forms/SelectInput/Example/CustomDropdown.d.ts +3 -0
- package/dist/cjs/types/components/Forms/SelectInput/PropsInterface.d.ts +4 -1
- package/dist/cjs/types/components/Forms/SelectInput/index.d.ts +1 -1
- package/dist/cjs/types/components/Forms/TextInput/PropsInterface.d.ts +2 -2
- package/dist/cjs/types/components/Forms/TextInput/index.d.ts +1 -1
- package/dist/cjs/types/components/Forms/index.d.ts +1 -0
- package/dist/cjs/types/components/index.d.ts +1 -1
- package/dist/cjs/types/stories/Form/DatePicker/Datepicker.stories.d.ts +14 -0
- package/dist/cjs/types/stories/Form/DatePicker/DatepickerSimulation.stories.d.ts +13 -0
- package/dist/cjs/types/stories/Form/SegmentButton.stories.d.ts +1 -0
- package/dist/cjs/types/stories/Form/SelectInput/SelectInput.stories.d.ts +0 -1
- package/dist/cjs/types/stories/Form/SelectInput/SelectInputCustom.stories.d.ts +13 -0
- package/dist/cjs/types/utility/helper.d.ts +1 -1
- package/dist/esm/index.js +597 -130
- package/dist/esm/lib.css +1 -1
- package/dist/esm/types/components/Forms/DatePicker/DatePicker.d.ts +6 -0
- package/dist/esm/types/components/Forms/DatePicker/DatePickerSimulation.d.ts +3 -0
- package/dist/esm/types/components/Forms/DatePicker/PickerCalendar.d.ts +7 -0
- package/dist/esm/types/components/Forms/DatePicker/index.d.ts +1 -0
- package/dist/esm/types/components/Forms/Dropdown/DropdownItem.d.ts +5 -2
- package/dist/esm/types/components/Forms/Dropdown/config.d.ts +6 -2
- package/dist/esm/types/components/Forms/SegmentButton/SegmentButtonItem.d.ts +1 -1
- package/dist/esm/types/components/Forms/SegmentButton/config.d.ts +7 -1
- package/dist/esm/types/components/Forms/SelectInput/Example/CustomDropdown.d.ts +3 -0
- package/dist/esm/types/components/Forms/SelectInput/PropsInterface.d.ts +4 -1
- package/dist/esm/types/components/Forms/SelectInput/index.d.ts +1 -1
- package/dist/esm/types/components/Forms/TextInput/PropsInterface.d.ts +2 -2
- package/dist/esm/types/components/Forms/TextInput/index.d.ts +1 -1
- package/dist/esm/types/components/Forms/index.d.ts +1 -0
- package/dist/esm/types/components/index.d.ts +1 -1
- package/dist/esm/types/stories/Form/DatePicker/Datepicker.stories.d.ts +14 -0
- package/dist/esm/types/stories/Form/DatePicker/DatepickerSimulation.stories.d.ts +13 -0
- package/dist/esm/types/stories/Form/SegmentButton.stories.d.ts +1 -0
- package/dist/esm/types/stories/Form/SelectInput/SelectInput.stories.d.ts +0 -1
- package/dist/esm/types/stories/Form/SelectInput/SelectInputCustom.stories.d.ts +13 -0
- package/dist/esm/types/utility/helper.d.ts +1 -1
- package/dist/index.d.ts +31 -21
- package/package.json +1 -1
- package/src/style/color.css +29 -29
- package/src/style/scrollbar.css +24 -5
- package/tailwind.config.js +26 -26
- package/dist/cjs/types/components/Dump.d.ts +0 -3
- package/dist/cjs/types/context/DropdownContext.d.ts +0 -12
- package/dist/esm/types/components/Dump.d.ts +0 -3
- package/dist/esm/types/context/DropdownContext.d.ts +0 -12
package/dist/cjs/index.js
CHANGED
|
@@ -265,13 +265,20 @@ var childrenElement = function (element) {
|
|
|
265
265
|
var validUnion = function (value, union) {
|
|
266
266
|
return union.includes(value) ? value : union[0];
|
|
267
267
|
};
|
|
268
|
-
var useDetectOutsideClick = function (ref, initialState, event) {
|
|
268
|
+
var useDetectOutsideClick = function (ref, initialState, ignoreRef, event) {
|
|
269
269
|
if (event === void 0) { event = 'click'; }
|
|
270
270
|
var _a = React.useState(initialState), isActive = _a[0], setIsActive = _a[1];
|
|
271
271
|
React.useEffect(function () {
|
|
272
272
|
var pageClickEvent = function (event) {
|
|
273
273
|
// If the active element exists and is clicked outside of
|
|
274
|
-
if (
|
|
274
|
+
if (ignoreRef &&
|
|
275
|
+
ignoreRef.current &&
|
|
276
|
+
ignoreRef.current.contains(event.target)) {
|
|
277
|
+
console.log('enter');
|
|
278
|
+
}
|
|
279
|
+
else if (ref.current !== null &&
|
|
280
|
+
!ref.current.contains(event.target)) {
|
|
281
|
+
console.log('close');
|
|
275
282
|
setIsActive(!isActive);
|
|
276
283
|
}
|
|
277
284
|
};
|
|
@@ -414,7 +421,7 @@ var radiusConfig$1 = {
|
|
|
414
421
|
tn: 'rounded-radius-full focus-visible:rounded-radius-full',
|
|
415
422
|
},
|
|
416
423
|
};
|
|
417
|
-
var sizeConfig$
|
|
424
|
+
var sizeConfig$c = {
|
|
418
425
|
lg: 'py-[10.5px] h-[48px] flex items-center justify-center gap-[10px] text-size-md ',
|
|
419
426
|
md: 'py-[9px] h-[40px] flex items-center justify-center gap-[5px] text-size-base ',
|
|
420
427
|
sm: 'py-[6px] h-[30px] flex items-center justify-center gap-[5px] text-size-sm ',
|
|
@@ -492,10 +499,10 @@ function Button(_a) {
|
|
|
492
499
|
}
|
|
493
500
|
var sizingRules;
|
|
494
501
|
if (variant.includes('link')) {
|
|
495
|
-
sizingRules = "".concat(sizeConfig$
|
|
502
|
+
sizingRules = "".concat(sizeConfig$c[validatedSize]);
|
|
496
503
|
}
|
|
497
504
|
else {
|
|
498
|
-
sizingRules = "".concat(sizeConfig$
|
|
505
|
+
sizingRules = "".concat(sizeConfig$c[validatedSize], " ").concat(sidePaddingConfig[validatedSize]);
|
|
499
506
|
}
|
|
500
507
|
var sizeClass = label || variant === 'form-group'
|
|
501
508
|
? " ".concat(minWidthRules, " ").concat(sizingRules)
|
|
@@ -1483,8 +1490,8 @@ var colorConfig$1 = {
|
|
|
1483
1490
|
active: 'bg-bia-verdantgreen-dark-40 text-primary-white',
|
|
1484
1491
|
},
|
|
1485
1492
|
blue: {
|
|
1486
|
-
default: 'bg-bia-
|
|
1487
|
-
active: 'bg-bia-
|
|
1493
|
+
default: 'bg-bia-crayola hover:bg-bia-crayola-light-10 active:bg-bia-crayola-dark-10 text-primary-white disabled:bg-bia-crayola-dark-20 disabled:text-primary-white/50 disabled:cursor-default',
|
|
1494
|
+
active: 'bg-bia-crayola-dark-10 text-primary-white',
|
|
1488
1495
|
},
|
|
1489
1496
|
};
|
|
1490
1497
|
|
|
@@ -1551,12 +1558,12 @@ function Color() {
|
|
|
1551
1558
|
tailwind: 'blue',
|
|
1552
1559
|
},
|
|
1553
1560
|
{
|
|
1554
|
-
css: '
|
|
1555
|
-
tailwind: '
|
|
1561
|
+
css: 'crayola',
|
|
1562
|
+
tailwind: 'crayola',
|
|
1556
1563
|
},
|
|
1557
1564
|
{
|
|
1558
1565
|
css: 'sky',
|
|
1559
|
-
tailwind: '
|
|
1566
|
+
tailwind: 'sky',
|
|
1560
1567
|
},
|
|
1561
1568
|
{
|
|
1562
1569
|
css: 'coolgrey',
|
|
@@ -1785,7 +1792,7 @@ MenuItem.defaultProps = {
|
|
|
1785
1792
|
onClick: function () { },
|
|
1786
1793
|
};
|
|
1787
1794
|
|
|
1788
|
-
var sizeConfig$
|
|
1795
|
+
var sizeConfig$b = {
|
|
1789
1796
|
md: {
|
|
1790
1797
|
fieldSize: 'text-size-base p-2.5 font-[350] h-10',
|
|
1791
1798
|
iconPosition: 'right-[10px]',
|
|
@@ -1841,13 +1848,13 @@ function PasswordIcon(_a) {
|
|
|
1841
1848
|
}
|
|
1842
1849
|
|
|
1843
1850
|
function TextInput(_a) {
|
|
1844
|
-
var descText = _a.descText, _b = _a.disabled, disabled = _b === void 0 ? false : _b, icon = _a.icon, _c = _a.id, id = _c === void 0 ? '' : _c, _d = _a.size, size = _d === void 0 ? 'md' : _d, _e = _a.isValid, isValid = _e === void 0 ? null : _e, label = _a.label, _f = _a.placeholder, placeholder = _f === void 0 ? '' : _f, _g = _a.readOnly, readOnly = _g === void 0 ? false : _g, _h = _a.required, required = _h === void 0 ? false : _h, _j = _a.variant, variant = _j === void 0 ? 'text' : _j, _k = _a.value, value = _k === void 0 ? undefined : _k, _l = _a.onChange, onChange = _l === void 0 ? function () { } : _l, _m = _a.maxLength, maxLength = _m === void 0 ? undefined : _m, _o = _a.inputClassName, inputClassName = _o === void 0 ? '' : _o; _a.isFlatRight; var actionElement = _a.actionElement, _q = _a.autoComplete, autoComplete = _q === void 0 ? 'off' : _q, props = __rest(_a, ["descText", "disabled", "icon", "id", "size", "isValid", "label", "placeholder", "readOnly", "required", "variant", "value", "onChange", "maxLength", "inputClassName", "isFlatRight", "actionElement", "autoComplete"]);
|
|
1851
|
+
var descText = _a.descText, _b = _a.disabled, disabled = _b === void 0 ? false : _b, icon = _a.icon, _c = _a.id, id = _c === void 0 ? '' : _c, _d = _a.size, size = _d === void 0 ? 'md' : _d, _e = _a.isValid, isValid = _e === void 0 ? null : _e, label = _a.label, _f = _a.placeholder, placeholder = _f === void 0 ? '' : _f, _g = _a.readOnly, readOnly = _g === void 0 ? false : _g, _h = _a.required, required = _h === void 0 ? false : _h, _j = _a.variant, variant = _j === void 0 ? 'text' : _j, _k = _a.value, value = _k === void 0 ? undefined : _k, _l = _a.onChange, onChange = _l === void 0 ? function () { } : _l, _m = _a.maxLength, maxLength = _m === void 0 ? undefined : _m, _o = _a.inputClassName, inputClassName = _o === void 0 ? '' : _o; _a.isFlatRight; var actionElement = _a.actionElement, _q = _a.autoComplete, autoComplete = _q === void 0 ? 'off' : _q, ref = _a.ref, props = __rest(_a, ["descText", "disabled", "icon", "id", "size", "isValid", "label", "placeholder", "readOnly", "required", "variant", "value", "onChange", "maxLength", "inputClassName", "isFlatRight", "actionElement", "autoComplete", "ref"]);
|
|
1845
1852
|
var isTransparent = variant.includes('transparent');
|
|
1846
1853
|
var _r = React.useState(false), isShow = _r[0], setIsShow = _r[1];
|
|
1847
1854
|
var _s = styleConfig[variant], fieldStyle = _s.fieldStyle, iconStyle = _s.iconStyle;
|
|
1848
1855
|
var _t = isTransparent
|
|
1849
|
-
? __assign(__assign({}, sizeConfig$
|
|
1850
|
-
" pe-[".concat(9 + sizeConfig$
|
|
1856
|
+
? __assign(__assign({}, sizeConfig$b[size]), { iconPosition: "right-0 ", fieldSize: sizeConfig$b[size].fieldSize +
|
|
1857
|
+
" pe-[".concat(9 + sizeConfig$b[size].iconSize, "px]") }) : sizeConfig$b[size], iconSize = _t.iconSize, fieldSize = _t.fieldSize, iconPosition = _t.iconPosition;
|
|
1851
1858
|
var borderStyle = isTransparent
|
|
1852
1859
|
? 'border-transparent bg-transparent' // customize border rule for transparent variant
|
|
1853
1860
|
: 'border border-bia-grey-dark-10 bg-primary-white';
|
|
@@ -1886,7 +1893,7 @@ function TextInput(_a) {
|
|
|
1886
1893
|
label,
|
|
1887
1894
|
required && React.createElement("span", { className: "p-1 text-bia-red" }, "*"))),
|
|
1888
1895
|
React.createElement("div", { className: "relative w-full" },
|
|
1889
|
-
React.createElement("input", __assign({ className: "bianic-text-input bianic-fgc-target w-full rounded read-only:pointer-events-none read-only:border-bia-grey-light-50 hover:rounded-b-none focus:rounded-b-none focus-visible:outline-none disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-grey-active ".concat(extendedInputClassName), disabled: disabled, id: id, placeholder: placeholder || label, readOnly: readOnly, required: required, type: typeVariant, value: value, onChange: function (e) { return onChange(e); }, maxLength: maxLength, autoComplete: autoComplete }, props)),
|
|
1896
|
+
React.createElement("input", __assign({ className: "bianic-text-input bianic-fgc-target w-full rounded read-only:pointer-events-none read-only:border-bia-grey-light-50 hover:rounded-b-none focus:rounded-b-none focus-visible:outline-none disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-grey-active ".concat(extendedInputClassName), disabled: disabled, id: id, placeholder: placeholder || label, readOnly: readOnly, required: required, type: typeVariant, value: value, onChange: function (e) { return onChange(e); }, maxLength: maxLength, autoComplete: autoComplete, ref: ref }, props)),
|
|
1890
1897
|
React.createElement("div", { className: "absolute inset-y-0 flex items-center pl-3 ".concat(actionElement ? '' : iconStyle, " ").concat(iconPosition, " ").concat(iconSizing) }, iconElement)),
|
|
1891
1898
|
(descText || maxLength) && (React.createElement("div", { className: "bianic-text-input-desc flex justify-between gap-1 text-xs ".concat(descColor) },
|
|
1892
1899
|
React.createElement("span", null, descText),
|
|
@@ -1913,7 +1920,7 @@ TextInput.defaultProps = {
|
|
|
1913
1920
|
};
|
|
1914
1921
|
|
|
1915
1922
|
// Desc: Radio button size configuration
|
|
1916
|
-
var sizeConfig$
|
|
1923
|
+
var sizeConfig$a = {
|
|
1917
1924
|
md: {
|
|
1918
1925
|
checkSize: 'w-[22px] h-[22px]',
|
|
1919
1926
|
labelSize: 'text-size-base',
|
|
@@ -1928,7 +1935,7 @@ var sizeUnion$4 = ['md', 'sm'];
|
|
|
1928
1935
|
function Radio(_a) {
|
|
1929
1936
|
var label = _a.label, _b = _a.size, size = _b === void 0 ? 'md' : _b, id = _a.id, _c = _a.onClick, onClick = _c === void 0 ? function () { } : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.checked, checked = _e === void 0 ? false : _e;
|
|
1930
1937
|
var validatedSize = validUnion(size, sizeUnion$4);
|
|
1931
|
-
var _f = sizeConfig$
|
|
1938
|
+
var _f = sizeConfig$a[validatedSize], checkSize = _f.checkSize, labelSize = _f.labelSize;
|
|
1932
1939
|
return (React.createElement("div", { className: "flex items-center" },
|
|
1933
1940
|
React.createElement("div", { className: "bg-white rounded-full flex flex-shrink-0 justify-center items-center relative ".concat(checkSize) },
|
|
1934
1941
|
React.createElement("input", { id: id, "aria-labelledby": "label1", type: "radio", className: "peer checkbox box-content appearance-none focus:opacity-100 focus:ring-1 focus:ring-offset-2 checked:disabled:border-bia-blue-disabled focus:ring-bia-blue focus:outline-none rounded-full border-bia-coolgrey-light-50 checked:border-bia-blue hover:border-bia-blue-hover disabled:border-bia-grey-dark-10 border-2 absolute cursor-pointer w-full h-full", onClick: function (e) { return onClick(e); }, checked: checked, disabled: disabled }),
|
|
@@ -1944,7 +1951,7 @@ Radio.defaultProps = {
|
|
|
1944
1951
|
checked: false,
|
|
1945
1952
|
};
|
|
1946
1953
|
|
|
1947
|
-
var sizeConfig$
|
|
1954
|
+
var sizeConfig$9 = {
|
|
1948
1955
|
md: {
|
|
1949
1956
|
inputClass: 'text-size-base font-[350] min-h-10',
|
|
1950
1957
|
},
|
|
@@ -1967,7 +1974,7 @@ var ResizeIcon = function (_a) {
|
|
|
1967
1974
|
function TextArea(_a) {
|
|
1968
1975
|
var descText = _a.descText, _b = _a.disabled, disabled = _b === void 0 ? false : _b, id = _a.id, _c = _a.size, size = _c === void 0 ? 'md' : _c, label = _a.label, _d = _a.placeholder, placeholder = _d === void 0 ? '' : _d, required = _a.required, rows = _a.rows, _e = _a.maxLength, maxLength = _e === void 0 ? undefined : _e, value = _a.value, _f = _a.readOnly, readOnly = _f === void 0 ? false : _f, _g = _a.autoComplete, autoComplete = _g === void 0 ? 'off' : _g, props = __rest(_a, ["descText", "disabled", "id", "size", "label", "placeholder", "required", "rows", "maxLength", "value", "readOnly", "autoComplete"]);
|
|
1969
1976
|
var inputRow = rows !== null && rows !== void 0 ? rows : 4;
|
|
1970
|
-
var inputClass = sizeConfig$
|
|
1977
|
+
var inputClass = sizeConfig$9[size].inputClass;
|
|
1971
1978
|
var remainWords = maxLength ? maxLength - (value ? value.length : 0) : 0;
|
|
1972
1979
|
return (React.createElement("div", { className: "field-group flex w-full flex-col" },
|
|
1973
1980
|
React.createElement("label", { htmlFor: id, className: "label pb-2 text-xs font-semibold read-only:pointer-events-none" },
|
|
@@ -1997,7 +2004,7 @@ TextArea.defaultProps = {
|
|
|
1997
2004
|
value: '',
|
|
1998
2005
|
};
|
|
1999
2006
|
|
|
2000
|
-
var sizeConfig$
|
|
2007
|
+
var sizeConfig$8 = {
|
|
2001
2008
|
md: {
|
|
2002
2009
|
checkClass: 'w-[22px] h-[22px]',
|
|
2003
2010
|
labelClass: 'text-size-base font-[350]',
|
|
@@ -2011,7 +2018,7 @@ var sizeConfig$9 = {
|
|
|
2011
2018
|
var sizeUnion$3 = ['md', 'sm'];
|
|
2012
2019
|
function Checkbox(_a) {
|
|
2013
2020
|
var _b = _a.disabled, disabled = _b === void 0 ? false : _b, id = _a.id, _c = _a.size, size = _c === void 0 ? 'md' : _c, label = _a.label, _d = _a.onChange, onChange = _d === void 0 ? function () { } : _d, props = __rest(_a, ["disabled", "id", "size", "label", "onChange"]);
|
|
2014
|
-
var _e = sizeConfig$
|
|
2021
|
+
var _e = sizeConfig$8[validUnion(size, sizeUnion$3)], checkClass = _e.checkClass, labelClass = _e.labelClass;
|
|
2015
2022
|
return (React.createElement("div", { className: "flex items-center" },
|
|
2016
2023
|
React.createElement("div", { className: "relative flex flex-shrink-0 items-center justify-center rounded-full bg-white ".concat(checkClass) },
|
|
2017
2024
|
React.createElement("input", __assign({ id: id, type: "checkbox", className: "checkbox peer absolute box-content h-full w-full cursor-pointer appearance-none rounded-full border-2 border-bia-coolgrey-light-50 checked:border-bia-blue hover:border-bia-blue-hover focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-bia-blue focus-visible:ring-offset-2 disabled:border-bia-coolgrey-light-50 disabled:checked:border-bia-blue-light-50", onChange: function (e) { return onChange(e); }, disabled: disabled }, props)),
|
|
@@ -2029,7 +2036,7 @@ Checkbox.defaultProps = {
|
|
|
2029
2036
|
onChange: function () { },
|
|
2030
2037
|
};
|
|
2031
2038
|
|
|
2032
|
-
var sizeConfig$
|
|
2039
|
+
var sizeConfig$7 = {
|
|
2033
2040
|
md: {
|
|
2034
2041
|
searchSize: 'text-size-base p-2.5 font-[350] h-10',
|
|
2035
2042
|
iconSize: 'right-[10px] text-[18px]',
|
|
@@ -2040,7 +2047,7 @@ var sizeConfig$8 = {
|
|
|
2040
2047
|
},
|
|
2041
2048
|
};
|
|
2042
2049
|
|
|
2043
|
-
var sizeConfig$
|
|
2050
|
+
var sizeConfig$6 = {
|
|
2044
2051
|
md: {
|
|
2045
2052
|
container: 'text-size-base font-[350] py-[3px] first:pt-[8px] last:pb-[8px]',
|
|
2046
2053
|
item: 'min-h-[34px] p-2.5',
|
|
@@ -2058,7 +2065,7 @@ function CustomDropdownItem(_a) {
|
|
|
2058
2065
|
var _f = React.useState(false), isHoveredSubMenu = _f[0], setIsHoveredSubMenu = _f[1];
|
|
2059
2066
|
var isOpenDropdown = isHovered || isHoveredSubMenu;
|
|
2060
2067
|
var selectedClass = isSelected ? 'font-semibold' : 'font-normal';
|
|
2061
|
-
var _g = sizeConfig$
|
|
2068
|
+
var _g = sizeConfig$6[size], containerClass = _g.container, item = _g.item;
|
|
2062
2069
|
var itemClass = "".concat(item, " ").concat(selectedClass, " ").concat(className);
|
|
2063
2070
|
var isExistSubDropdown = options.length !== 0;
|
|
2064
2071
|
return (React.createElement("div", { className: "relative w-full focus-visible:outline-bia-blue-light-50 ".concat(containerClass), tabIndex: 0, role: "button", onClick: function (e) { return onClick(e); }, onMouseEnter: function () { return setisHovered(true); }, onMouseLeave: function () { return setisHovered(false); }, onKeyDown: function () { } },
|
|
@@ -2085,7 +2092,7 @@ function DefaultDropdownItem(_a) {
|
|
|
2085
2092
|
var _g = React.useState(false), isHoveredSubMenu = _g[0], setIsHoveredSubMenu = _g[1];
|
|
2086
2093
|
var isOpenDropdown = isHovered || isHoveredSubMenu;
|
|
2087
2094
|
var selectedClass = isSelected ? 'font-semibold' : 'font-normal';
|
|
2088
|
-
var _h = sizeConfig$
|
|
2095
|
+
var _h = sizeConfig$6[size], containerClass = _h.container, item = _h.item;
|
|
2089
2096
|
var itemClass = "".concat(item, " ").concat(selectedClass, " ").concat(className);
|
|
2090
2097
|
var isExistSubDropdown = options.length !== 0;
|
|
2091
2098
|
return (React.createElement("div", { className: "relative w-full focus-visible:outline-bia-blue-light-50 ".concat(containerClass), tabIndex: 0, role: "button", onClick: function (e) { return onClick(e); }, onMouseEnter: function () { return setisHovered(true); }, onMouseLeave: function () { return setisHovered(false); }, onKeyDown: function () { } },
|
|
@@ -2107,12 +2114,95 @@ DefaultDropdownItem.defaultProps = {
|
|
|
2107
2114
|
caption: '',
|
|
2108
2115
|
};
|
|
2109
2116
|
|
|
2117
|
+
var containerSizeConfig = {
|
|
2118
|
+
sm: 'min-w-[72px]',
|
|
2119
|
+
md: 'min-w-[96px]',
|
|
2120
|
+
};
|
|
2121
|
+
var itemSizeConfig = {
|
|
2122
|
+
sm: 'min-h-[30px] border-y-[2px] border-bia-white',
|
|
2123
|
+
md: 'min-h-[40px] border-y-[3px] border-bia-white',
|
|
2124
|
+
};
|
|
2125
|
+
var fontConfig = {
|
|
2126
|
+
sm: 'text-[12px] font-[400]',
|
|
2127
|
+
md: 'text-[14px] font-[350]',
|
|
2128
|
+
};
|
|
2129
|
+
|
|
2130
|
+
var DropdownContainer = React.forwardRef(function DropdownContainer(propsComp, ref) {
|
|
2131
|
+
var _a = propsComp.isTopFlat, isTopFlat = _a === void 0 ? false : _a, children = propsComp.children, _b = propsComp.open, open = _b === void 0 ? true : _b, _c = propsComp.onClose, onClose = _c === void 0 ? function () { } : _c, _d = propsComp.className, className = _d === void 0 ? '' : _d, _e = propsComp.isWithOverlay, isWithOverlay = _e === void 0 ? true : _e, _f = propsComp.size, size = _f === void 0 ? 'md' : _f, _g = propsComp.onClickItem, onClickItem = _g === void 0 ? function () { } : _g, _h = propsComp.zIndex, zIndex = _h === void 0 ? 0 : _h, restProps = __rest(propsComp, ["isTopFlat", "children", "open", "onClose", "className", "isWithOverlay", "size", "onClickItem", "zIndex"]);
|
|
2132
|
+
var radiusClass = "rounded-b-radius-sm ".concat(!isTopFlat && 'rounded-t-radius-sm');
|
|
2133
|
+
var sizeClass = containerSizeConfig[size] || containerSizeConfig['md'];
|
|
2134
|
+
var containerClass = "".concat(sizeClass, " ").concat(radiusClass, " ").concat(className);
|
|
2135
|
+
var handleClickDrpdownItem = function (e, val) {
|
|
2136
|
+
onClickItem(e, val);
|
|
2137
|
+
onClose();
|
|
2138
|
+
};
|
|
2139
|
+
return (open && (React.createElement(React.Fragment, null,
|
|
2140
|
+
isWithOverlay && (React.createElement("div", { className: "bianic-dropdown-overlay fixed left-0 top-0 h-screen w-screen", style: { zIndex: zIndex }, onClick: function () { return onClose(); } })),
|
|
2141
|
+
React.createElement("div", __assign({ style: {
|
|
2142
|
+
zIndex: zIndex + 10, // Ensure dropdown is above overlay
|
|
2143
|
+
}, ref: ref, className: "bianic-dropdown-container bg-bia-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] ".concat(containerClass) }, restProps), React.Children.map(children, function (child) {
|
|
2144
|
+
return React.isValidElement(child)
|
|
2145
|
+
? // Kirimkan handleItemClick sebagai props onClick ke setiap DropdownItem
|
|
2146
|
+
React.cloneElement(child, {
|
|
2147
|
+
onClose: function () { return onClose(); },
|
|
2148
|
+
size: size,
|
|
2149
|
+
onClickItem: function (e, val) { return handleClickDrpdownItem(e, val); },
|
|
2150
|
+
zIndex: zIndex + 10,
|
|
2151
|
+
})
|
|
2152
|
+
: child;
|
|
2153
|
+
})))));
|
|
2154
|
+
});
|
|
2155
|
+
DropdownContainer.defaultProps = {
|
|
2156
|
+
isTopFlat: false,
|
|
2157
|
+
};
|
|
2158
|
+
|
|
2159
|
+
function DropdownItem(_a) {
|
|
2160
|
+
var children = _a.children, _b = _a.className, className = _b === void 0 ? '' : _b, _c = _a.onClickItem, onClickItem = _c === void 0 ? function () { } : _c, _d = _a.onClose, onClose = _d === void 0 ? function () { } : _d, _e = _a.size, size = _e === void 0 ? 'md' : _e, _f = _a.value, value = _f === void 0 ? '' : _f, content = _a.content, _g = _a.disabled, disabled = _g === void 0 ? false : _g, _h = _a.zIndex, zIndex = _h === void 0 ? 0 : _h, props = __rest(_a, ["children", "className", "onClickItem", "onClose", "size", "value", "content", "disabled", "zIndex"]);
|
|
2161
|
+
var _j = React.useState(false), isHovered = _j[0], setIsHovered = _j[1];
|
|
2162
|
+
var _k = React.useState(false), isLeft = _k[0], setIsLeft = _k[1];
|
|
2163
|
+
var fontClass = fontConfig[size] || fontConfig['md'];
|
|
2164
|
+
var itemSizeClass = itemSizeConfig[size] || itemSizeConfig['md'];
|
|
2165
|
+
var itemClass = "".concat(itemSizeClass, " ").concat(fontClass, " ").concat(className);
|
|
2166
|
+
var chevronSize = size === 'sm' ? 14 : 18;
|
|
2167
|
+
var DropdownContRef = React.useRef(null);
|
|
2168
|
+
React.useEffect(function () {
|
|
2169
|
+
var _a;
|
|
2170
|
+
if (DropdownContRef.current) {
|
|
2171
|
+
// Adjust dropdown position to prevent overflow on the right.
|
|
2172
|
+
var MenuContRect = (_a = DropdownContRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
2173
|
+
var RectRight = MenuContRect === null || MenuContRect === void 0 ? void 0 : MenuContRect.right;
|
|
2174
|
+
var innerWindow = window.innerWidth;
|
|
2175
|
+
if (RectRight > innerWindow)
|
|
2176
|
+
setIsLeft(true);
|
|
2177
|
+
else
|
|
2178
|
+
setIsLeft(false);
|
|
2179
|
+
}
|
|
2180
|
+
}, [isHovered]);
|
|
2181
|
+
var translateClass = isLeft
|
|
2182
|
+
? 'left-0 -translate-x-full'
|
|
2183
|
+
: 'right-0 translate-x-full';
|
|
2184
|
+
var currentZIndex = zIndex + 10;
|
|
2185
|
+
return (React.createElement("div", { className: "bianic-dropdown-item group/main relative cursor-pointer first:rounded-t-radius-sm first:pt-[5px] last:rounded-b-radius-sm last:pb-[5px]", onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); } },
|
|
2186
|
+
React.createElement("button", __assign({ className: "relative flex w-full !min-w-fit items-center justify-start whitespace-nowrap px-[15px] py-[5px] text-left text-bia-black disabled:cursor-not-allowed disabled:text-bia-coolgrey-light-50 hover:[&:not(:disabled)]:bg-bia-blue-pastel ".concat(itemClass), style: {
|
|
2187
|
+
zIndex: isHovered ? currentZIndex : currentZIndex + 15,
|
|
2188
|
+
}, onClick: function (e) {
|
|
2189
|
+
onClickItem(e, value);
|
|
2190
|
+
}, onKeyDown: function () { }, disabled: disabled, type: "button" }, props),
|
|
2191
|
+
content,
|
|
2192
|
+
React.createElement("div", { className: "ml-auto flex items-center" }, children && (React.createElement(TbChevronRight, { className: "ml-[10px] text-bia-coolgrey", size: chevronSize })))),
|
|
2193
|
+
children && (React.createElement(DropdownContainer, { className: "absolute top-0 bg-primary-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] group-first/main:top-[6px] ".concat(translateClass), onClose: onClose, open: isHovered, onClickItem: function (e, value) { return onClickItem(e, value); }, size: size, ref: DropdownContRef, zIndex: currentZIndex + 10 }, children))));
|
|
2194
|
+
}
|
|
2195
|
+
DropdownItem.defaultProps = {
|
|
2196
|
+
className: '',
|
|
2197
|
+
onClickItem: function () { },
|
|
2198
|
+
};
|
|
2199
|
+
|
|
2110
2200
|
var sizeUnion$2 = ['md', 'sm'];
|
|
2111
2201
|
function SelectInput(_a) {
|
|
2112
|
-
var descText = _a.descText, _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.size, size = _c === void 0 ? 'md' : _c, id = _a.id, label = _a.label,
|
|
2113
|
-
var
|
|
2202
|
+
var descText = _a.descText, _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.size, size = _c === void 0 ? 'md' : _c, id = _a.id, label = _a.label, _d = _a.options, options = _d === void 0 ? [] : _d, _e = _a.required, required = _e === void 0 ? false : _e, selected = _a.selected, setSelected = _a.setSelected, _f = _a.onClickDropdown, onClickDropdown = _f === void 0 ? function () { } : _f, children = _a.children, _g = _a.dropContProps, _h = _g === void 0 ? {} : _g, _j = _h.className, dropContClassName = _j === void 0 ? '' : _j, restDropContProps = __rest(_h, ["className"]), props = __rest(_a, ["descText", "disabled", "size", "id", "label", "options", "required", "selected", "setSelected", "onClickDropdown", "children", "dropContProps"]);
|
|
2203
|
+
var _k = React.useState(false), isOpen = _k[0], setIsOpen = _k[1];
|
|
2114
2204
|
var validatedSize = validUnion(size, sizeUnion$2);
|
|
2115
|
-
var
|
|
2205
|
+
var _l = sizeConfig$7[validatedSize], searchSize = _l.searchSize, iconSize = _l.iconSize;
|
|
2116
2206
|
var inputRef = React.useRef(null);
|
|
2117
2207
|
var handleOutsideClick = function (e) {
|
|
2118
2208
|
if (inputRef.current && !inputRef.current.contains(e.target)) {
|
|
@@ -2151,7 +2241,7 @@ function SelectInput(_a) {
|
|
|
2151
2241
|
React.createElement("div", { className: "group relative w-full" },
|
|
2152
2242
|
React.createElement("input", __assign({ className: "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:bg-bia-grey-light-80 disabled:text-bia-coolgrey ".concat(searchSize), onClick: function () { return setIsOpen(!isOpen); }, value: selectedLabel, readOnly: true, id: id, disabled: disabled }, props)),
|
|
2153
2243
|
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)),
|
|
2154
|
-
isOpen && (React.createElement("div", { className: "absolute z-10 w-full overflow-y-auto rounded-b-md border border-bia-grey-dark-10 bg-primary-white shadow-lg", ref: optionsRef, onClick: onClickDropdown }, options.map(function (option) {
|
|
2244
|
+
children === undefined && isOpen && (React.createElement("div", { className: "absolute z-10 w-full overflow-y-auto rounded-b-md border border-bia-grey-dark-10 bg-primary-white shadow-lg", ref: optionsRef, onClick: onClickDropdown }, options.map(function (option) {
|
|
2155
2245
|
var isSelected = JSON.stringify(option) === JSON.stringify(selected);
|
|
2156
2246
|
var optionLabel = isObjectOptionItem ? option.label : option;
|
|
2157
2247
|
var optionCaption = isObjectOptionItem ? option.caption : '';
|
|
@@ -2162,6 +2252,18 @@ function SelectInput(_a) {
|
|
|
2162
2252
|
setSelected(option);
|
|
2163
2253
|
setIsOpen(false);
|
|
2164
2254
|
} }));
|
|
2255
|
+
}))),
|
|
2256
|
+
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) }, restDropContProps), React.Children.map(children, function (child) {
|
|
2257
|
+
if (React.isValidElement(child)) {
|
|
2258
|
+
return React.cloneElement(child, {
|
|
2259
|
+
isSelected: selected && selected.id === child.props.value.id,
|
|
2260
|
+
onClick: function () {
|
|
2261
|
+
setSelected(child.props.value);
|
|
2262
|
+
setIsOpen(false);
|
|
2263
|
+
},
|
|
2264
|
+
});
|
|
2265
|
+
}
|
|
2266
|
+
return child;
|
|
2165
2267
|
})))),
|
|
2166
2268
|
descText && (React.createElement("span", { className: "desc mt-2 text-xs text-primary-cool" }, descText))));
|
|
2167
2269
|
}
|
|
@@ -2176,7 +2278,7 @@ SelectInput.defaultProps = {
|
|
|
2176
2278
|
setSelected: function () { },
|
|
2177
2279
|
};
|
|
2178
2280
|
|
|
2179
|
-
var sizeConfig$
|
|
2281
|
+
var sizeConfig$5 = {
|
|
2180
2282
|
md: {
|
|
2181
2283
|
iconClass: 'right-[10px]',
|
|
2182
2284
|
iconSize: '18',
|
|
@@ -2191,90 +2293,13 @@ var sizeConfig$6 = {
|
|
|
2191
2293
|
},
|
|
2192
2294
|
};
|
|
2193
2295
|
|
|
2194
|
-
var sizeConfig$5 = {
|
|
2195
|
-
sm: 'min-w-[72px]',
|
|
2196
|
-
md: 'min-w-[96px]',
|
|
2197
|
-
};
|
|
2198
|
-
var fontConfig = {
|
|
2199
|
-
sm: 'text-[12px] font-[400]',
|
|
2200
|
-
md: 'text-[14px] font-[350]',
|
|
2201
|
-
};
|
|
2202
|
-
|
|
2203
|
-
var DropdownContainer = React.forwardRef(function DropdownContainer(propsComp, ref) {
|
|
2204
|
-
var _a = propsComp.isTopFlat, isTopFlat = _a === void 0 ? false : _a, children = propsComp.children, _b = propsComp.open, open = _b === void 0 ? true : _b, _c = propsComp.onClose, onClose = _c === void 0 ? function () { } : _c, _d = propsComp.className, className = _d === void 0 ? '' : _d, _e = propsComp.isWithOverlay, isWithOverlay = _e === void 0 ? true : _e, _f = propsComp.size, size = _f === void 0 ? 'md' : _f, _g = propsComp.onClickItem, onClickItem = _g === void 0 ? function () { } : _g, _h = propsComp.zIndex, zIndex = _h === void 0 ? 0 : _h, restProps = __rest(propsComp, ["isTopFlat", "children", "open", "onClose", "className", "isWithOverlay", "size", "onClickItem", "zIndex"]);
|
|
2205
|
-
var radiusClass = "rounded-b-radius-sm ".concat(!isTopFlat && 'rounded-t-radius-sm');
|
|
2206
|
-
var sizeClass = sizeConfig$5[size] || sizeConfig$5['md'];
|
|
2207
|
-
var containerClass = "".concat(sizeClass, " ").concat(radiusClass, " ").concat(className);
|
|
2208
|
-
var handleClickDrpdownItem = function (e, val) {
|
|
2209
|
-
onClickItem(e, val);
|
|
2210
|
-
onClose();
|
|
2211
|
-
};
|
|
2212
|
-
return (open && (React.createElement(React.Fragment, null,
|
|
2213
|
-
isWithOverlay && (React.createElement("div", { className: "bianic-dropdown-overlay fixed left-0 top-0 h-screen w-screen", style: { zIndex: zIndex }, onClick: function () { return onClose(); } })),
|
|
2214
|
-
React.createElement("div", __assign({ style: {
|
|
2215
|
-
zIndex: zIndex + 10, // Ensure dropdown is above overlay
|
|
2216
|
-
}, ref: ref, className: "bianic-dropdown-container bg-bia-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] ".concat(containerClass) }, restProps), React.Children.map(children, function (child) {
|
|
2217
|
-
return React.isValidElement(child)
|
|
2218
|
-
? // Kirimkan handleItemClick sebagai props onClick ke setiap DropdownItem
|
|
2219
|
-
React.cloneElement(child, {
|
|
2220
|
-
onClose: function () { return onClose(); },
|
|
2221
|
-
size: size,
|
|
2222
|
-
onClickItem: function (e, val) { return handleClickDrpdownItem(e, val); },
|
|
2223
|
-
zIndex: zIndex + 10,
|
|
2224
|
-
})
|
|
2225
|
-
: child;
|
|
2226
|
-
})))));
|
|
2227
|
-
});
|
|
2228
|
-
DropdownContainer.defaultProps = {
|
|
2229
|
-
isTopFlat: false,
|
|
2230
|
-
};
|
|
2231
|
-
|
|
2232
|
-
function DropdownItem(_a) {
|
|
2233
|
-
var children = _a.children, _b = _a.className, className = _b === void 0 ? '' : _b, _c = _a.onClickItem, onClickItem = _c === void 0 ? function () { } : _c, _d = _a.onClose, onClose = _d === void 0 ? function () { } : _d, _e = _a.size, size = _e === void 0 ? 'md' : _e, _f = _a.value, value = _f === void 0 ? '' : _f, content = _a.content, _g = _a.disabled, disabled = _g === void 0 ? false : _g, _h = _a.zIndex, zIndex = _h === void 0 ? 0 : _h, props = __rest(_a, ["children", "className", "onClickItem", "onClose", "size", "value", "content", "disabled", "zIndex"]);
|
|
2234
|
-
var _j = React.useState(false), isHovered = _j[0], setIsHovered = _j[1];
|
|
2235
|
-
var _k = React.useState(false), isLeft = _k[0], setIsLeft = _k[1];
|
|
2236
|
-
var fontClass = fontConfig[size] || fontConfig['md'];
|
|
2237
|
-
var itemClass = "".concat(fontClass, " ").concat(className);
|
|
2238
|
-
var chevronSize = size === 'sm' ? 14 : 18;
|
|
2239
|
-
var DropdownContRef = React.useRef(null);
|
|
2240
|
-
React.useEffect(function () {
|
|
2241
|
-
var _a;
|
|
2242
|
-
if (DropdownContRef.current) {
|
|
2243
|
-
// Adjust dropdown position to prevent overflow on the right.
|
|
2244
|
-
var MenuContRect = (_a = DropdownContRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
2245
|
-
var RectRight = MenuContRect === null || MenuContRect === void 0 ? void 0 : MenuContRect.right;
|
|
2246
|
-
var innerWindow = window.innerWidth;
|
|
2247
|
-
if (RectRight > innerWindow)
|
|
2248
|
-
setIsLeft(true);
|
|
2249
|
-
else
|
|
2250
|
-
setIsLeft(false);
|
|
2251
|
-
}
|
|
2252
|
-
}, [isHovered]);
|
|
2253
|
-
var translateClass = isLeft
|
|
2254
|
-
? 'left-0 -translate-x-full'
|
|
2255
|
-
: 'right-0 translate-x-full';
|
|
2256
|
-
var currentZIndex = zIndex + 10;
|
|
2257
|
-
return (React.createElement("div", { className: "bianic-dropdown-item group/main relative cursor-pointer first:rounded-t-radius-sm first:pt-[6px] last:rounded-b-radius-sm last:pb-[6px]", onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); } },
|
|
2258
|
-
React.createElement("button", __assign({ className: "relative flex h-full w-full !min-w-fit items-center justify-start whitespace-nowrap px-[15px] py-[5px] text-left text-bia-black disabled:cursor-not-allowed disabled:text-bia-coolgrey-light-50 hover:[&:not(:disabled)]:bg-bia-blue-pastel ".concat(itemClass), style: {
|
|
2259
|
-
zIndex: isHovered ? currentZIndex : currentZIndex + 15,
|
|
2260
|
-
}, onClick: function (e) {
|
|
2261
|
-
onClickItem(e, value);
|
|
2262
|
-
}, onKeyDown: function () { }, disabled: disabled, type: "button" }, props),
|
|
2263
|
-
content,
|
|
2264
|
-
React.createElement("div", { className: "ml-auto flex items-center" }, children && (React.createElement(TbChevronRight, { className: "ml-[10px] text-bia-coolgrey", size: chevronSize })))),
|
|
2265
|
-
children && (React.createElement(DropdownContainer, { className: "absolute top-0 bg-primary-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] group-first/main:top-[6px] ".concat(translateClass), onClose: onClose, open: isHovered, onClickItem: function (e, value) { return onClickItem(e, value); }, size: size, ref: DropdownContRef, zIndex: currentZIndex + 10 }, children))));
|
|
2266
|
-
}
|
|
2267
|
-
DropdownItem.defaultProps = {
|
|
2268
|
-
className: '',
|
|
2269
|
-
onClickItem: function () { },
|
|
2270
|
-
};
|
|
2271
|
-
|
|
2272
2296
|
function LiveSearch(_a) {
|
|
2273
2297
|
var descText = _a.descText, _b = _a.disabled, disabled = _b === void 0 ? false : _b, id = _a.id, _c = _a.size, size = _c === void 0 ? 'md' : _c, label = _a.label, placeholder = _a.placeholder, _d = _a.required, required = _d === void 0 ? false : _d, options = _a.options, setValue = _a.setValue, value = _a.value, _e = _a.readOnly, readOnly = _e === void 0 ? false : _e, _f = _a.onChangeText, onChangeText = _f === void 0 ? function () { } : _f, _g = _a.onClickDropdown, onClickDropdown = _g === void 0 ? function () { } : _g, _h = _a.autoComplete, autoComplete = _h === void 0 ? 'off' : _h, _j = _a.children, children = _j === void 0 ? undefined : _j, _k = _a.dropContProps, dropContProps = _k === void 0 ? { className: undefined } : _k;
|
|
2274
2298
|
var _l = React.useState(false), isOpen = _l[0], setIsOpen = _l[1];
|
|
2275
2299
|
var _m = React.useState(value.label || ''), searchTerm = _m[0], setSearchTerm = _m[1];
|
|
2276
|
-
var _o = sizeConfig$
|
|
2300
|
+
var _o = sizeConfig$5[size], iconClass = _o.iconClass, iconSize = _o.iconSize, inputClass = _o.inputClass;
|
|
2277
2301
|
var dropContClassName = dropContProps.className, restDropContProps = __rest(dropContProps, ["className"]);
|
|
2302
|
+
var isValueExist = value && value.label !== undefined && value.label !== '';
|
|
2278
2303
|
var inputRef = React.useRef(null);
|
|
2279
2304
|
var handleOutsideClick = function (e) {
|
|
2280
2305
|
if (inputRef.current && !inputRef.current.contains(e.target)) {
|
|
@@ -2370,11 +2395,10 @@ function LiveSearch(_a) {
|
|
|
2370
2395
|
setValue({ id: null, label: e.target.value });
|
|
2371
2396
|
handleInputChange(e);
|
|
2372
2397
|
}, type: "text", readOnly: readOnly, autoComplete: autoComplete }),
|
|
2373
|
-
React.createElement("div", { className: "absolute inset-y-0 flex items-center pl-3
|
|
2374
|
-
React.createElement(TbZoom, { className: "text-primary-black", style: { fontSize: iconSize } })),
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
React.createElement(TbX, { className: "text-primary-black", style: { fontSize: iconSize } }))),
|
|
2398
|
+
React.createElement("div", { className: "absolute inset-y-0 flex items-center pl-3 ".concat(iconClass) },
|
|
2399
|
+
!isValueExist && (React.createElement(TbZoom, { className: "text-primary-black", style: { fontSize: iconSize } })),
|
|
2400
|
+
isValueExist && (React.createElement("button", { onClick: function () { return setValue({ id: null, label: '' }); }, className: "flex h-full w-full items-center" },
|
|
2401
|
+
React.createElement(TbX, { className: "text-primary-black", style: { fontSize: iconSize } })))),
|
|
2378
2402
|
children === undefined && isOpen && (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) {
|
|
2379
2403
|
var isSelected = value && value.id && option.id === value.id;
|
|
2380
2404
|
return option.custom ? (React.createElement(CustomDropdownItem, { size: size, isSelected: isSelected, className: dropContClassName, onClick: function () {
|
|
@@ -2385,7 +2409,7 @@ function LiveSearch(_a) {
|
|
|
2385
2409
|
setIsOpen(false);
|
|
2386
2410
|
} }));
|
|
2387
2411
|
}))),
|
|
2388
|
-
children && isOpen && (React.createElement(DropdownContainer, __assign({ open: isOpen, onClose: function () { return setIsOpen(false); }, size: size, isTopFlat: true, className: "bianic-livesearch-dropdown absolute
|
|
2412
|
+
children && isOpen && (React.createElement(DropdownContainer, __assign({ open: isOpen, onClose: function () { return setIsOpen(false); }, size: size, isTopFlat: true, zIndex: 10, className: "bianic-livesearch-dropdown absolute w-full overflow-hidden bg-white shadow-lg" }, restDropContProps), hasFilteredResults
|
|
2389
2413
|
? renderedChildren
|
|
2390
2414
|
: // If no results and searchTerm is present
|
|
2391
2415
|
searchTerm.length > 0 && (React.createElement(DropdownItem, { content: React.createElement("div", { className: "px-4 py-2 text-gray-500" }, "Tidak ada hasil ditemukan.") }))))),
|
|
@@ -2447,9 +2471,9 @@ var roundedConfig = {
|
|
|
2447
2471
|
tn: 'first:rounded-l-radius-tn last:rounded-r-radius-tn',
|
|
2448
2472
|
};
|
|
2449
2473
|
var sizeConfig$3 = {
|
|
2450
|
-
lg: 'text-size-md leading-[23.94px] px-[13px] py-[
|
|
2451
|
-
md: 'text-size-base leading-[21px] px-[11px] py-[
|
|
2452
|
-
sm: 'text-size-sm leading-[15.96px] px-[7px] py-[
|
|
2474
|
+
lg: 'text-size-md leading-[23.94px] px-[13px] py-[11px] ',
|
|
2475
|
+
md: 'text-size-base leading-[21px] px-[11px] py-[8.5px] ',
|
|
2476
|
+
sm: 'text-size-sm leading-[15.96px] px-[7px] py-[6px] ',
|
|
2453
2477
|
tn: 'text-size-sm leading-[15.96px] px-[4px] py-[2px] ',
|
|
2454
2478
|
};
|
|
2455
2479
|
var minWidthConfig = {
|
|
@@ -2458,16 +2482,22 @@ var minWidthConfig = {
|
|
|
2458
2482
|
sm: 'min-w-[72px]',
|
|
2459
2483
|
tn: 'min-w-[64px]',
|
|
2460
2484
|
};
|
|
2485
|
+
var minHeightConfig = {
|
|
2486
|
+
lg: 'min-h-[48px]',
|
|
2487
|
+
md: 'min-h-[40px]',
|
|
2488
|
+
sm: 'min-h-[30px]',
|
|
2489
|
+
tn: 'min-h-[22px]',
|
|
2490
|
+
};
|
|
2461
2491
|
|
|
2462
2492
|
function SegmentButtonItem(_a) {
|
|
2463
|
-
var _b = _a.selected, selected = _b === void 0 ? false : _b, size = _a.size, children = _a.children, disabled = _a.disabled, _c = _a.isfitContent, isfitContent = _c === void 0 ? false : _c, onClick = _a.onClick;
|
|
2493
|
+
var className = _a.className, _b = _a.selected, selected = _b === void 0 ? false : _b, size = _a.size, children = _a.children, disabled = _a.disabled, _c = _a.isfitContent, isfitContent = _c === void 0 ? false : _c, onClick = _a.onClick;
|
|
2464
2494
|
var isSelected = selected ? 'selected' : 'notSelected';
|
|
2465
2495
|
var sizingStyle = isfitContent
|
|
2466
|
-
? "".concat(sizeConfig$3[size])
|
|
2467
|
-
: "".concat(sizeConfig$3[size], " ").concat(minWidthConfig[size]);
|
|
2496
|
+
? "".concat(sizeConfig$3[size], " ").concat(minHeightConfig[size])
|
|
2497
|
+
: "".concat(sizeConfig$3[size], " ").concat(minWidthConfig[size], " ").concat(minHeightConfig[size]);
|
|
2468
2498
|
var radiusStyle = "".concat(roundedConfig[size]);
|
|
2469
2499
|
var selectedStyle = "".concat(isSelectedConfig[isSelected]);
|
|
2470
|
-
return (React.createElement("button", { type: "button", onClick: onClick, disabled: disabled, className: "group:last:border-l-0 border-[1px] border-l-0 border-bia-grey-dark-10 first:border-l-[1px] focus-visible:z-50 focus-visible:outline focus-visible:outline-[3px] focus-visible:-outline-offset-1 focus-visible:outline-bia-blue-light-50 disabled:cursor-not-allowed disabled:bg-bia-grey-light-80 disabled:text-bia-grey-dark-10 ".concat(selectedStyle, " ").concat(radiusStyle, " ").concat(sizingStyle) }, children));
|
|
2500
|
+
return (React.createElement("button", { type: "button", onClick: onClick, disabled: disabled, className: "group:last:border-l-0 flex items-center justify-center border-[1px] border-l-0 border-bia-grey-dark-10 first:border-l-[1px] focus-visible:z-50 focus-visible:outline focus-visible:outline-[3px] focus-visible:-outline-offset-1 focus-visible:outline-bia-blue-light-50 disabled:cursor-not-allowed disabled:bg-bia-grey-light-80 disabled:text-bia-grey-dark-10 ".concat(selectedStyle, " ").concat(radiusStyle, " ").concat(sizingStyle, " ").concat(className) }, children));
|
|
2471
2501
|
}
|
|
2472
2502
|
|
|
2473
2503
|
function SegmentButtonGroup(_a) {
|
|
@@ -2507,6 +2537,443 @@ var FormGroupLabel = function (_a) {
|
|
|
2507
2537
|
childrenElement(iconRight)));
|
|
2508
2538
|
};
|
|
2509
2539
|
|
|
2540
|
+
var oneDayValue = 24 * 60 * 60 * 1000; // milliseconds in one day
|
|
2541
|
+
var todayValue = Date.now() -
|
|
2542
|
+
(Date.now() % oneDayValue) +
|
|
2543
|
+
new Date().getTimezoneOffset() * 1000 * 60; // today in milliseconds
|
|
2544
|
+
var PickerCalendar = function (_a) {
|
|
2545
|
+
var selectedDate = _a.selectedDate, onDateChange = _a.onDateChange, ref = _a.ref;
|
|
2546
|
+
// Constants
|
|
2547
|
+
var daysMap = [
|
|
2548
|
+
'Monday',
|
|
2549
|
+
'Tuesday',
|
|
2550
|
+
'Wednesday',
|
|
2551
|
+
'Thursday',
|
|
2552
|
+
'Friday',
|
|
2553
|
+
'Saturday',
|
|
2554
|
+
'Sunday',
|
|
2555
|
+
];
|
|
2556
|
+
var monthMap = [
|
|
2557
|
+
'January',
|
|
2558
|
+
'February',
|
|
2559
|
+
'March',
|
|
2560
|
+
'April',
|
|
2561
|
+
'May',
|
|
2562
|
+
'June',
|
|
2563
|
+
'July',
|
|
2564
|
+
'August',
|
|
2565
|
+
'September',
|
|
2566
|
+
'October',
|
|
2567
|
+
'November',
|
|
2568
|
+
'December',
|
|
2569
|
+
];
|
|
2570
|
+
var modeMap = ['date', 'year', 'month'];
|
|
2571
|
+
// Mode Controller
|
|
2572
|
+
var _b = React.useState(modeMap[0]), pickerMode = _b[0], setPickerMode = _b[1];
|
|
2573
|
+
var _c = React.useState(''), prevMode = _c[0], setPrevMode = _c[1];
|
|
2574
|
+
// styling constants and functions
|
|
2575
|
+
var chevronButtonStyle = 'text-bia-coolgrey';
|
|
2576
|
+
var selectedDateStyle = function (date, dateSelected) {
|
|
2577
|
+
var isSelected = checkDateEquals(date, dateSelected);
|
|
2578
|
+
var isToday = checkDateEquals(date, new Date(todayValue));
|
|
2579
|
+
if (isSelected) {
|
|
2580
|
+
return 'bg-bia-blue-dark-10 text-bia-white rounded-full border border-bia-blue-dark-10';
|
|
2581
|
+
}
|
|
2582
|
+
else if (!isSelected && isToday) {
|
|
2583
|
+
return 'bg-bia-blue-pastel text-bia-black rounded-full border border-bia-blue-light-50';
|
|
2584
|
+
}
|
|
2585
|
+
else {
|
|
2586
|
+
return 'hover:bg-bia-blue-pastel rounded-full';
|
|
2587
|
+
}
|
|
2588
|
+
};
|
|
2589
|
+
var datesColorStyle = function (date, viewMonth) {
|
|
2590
|
+
if (date.getMonth() === viewMonth) {
|
|
2591
|
+
return 'text-bia-black';
|
|
2592
|
+
}
|
|
2593
|
+
else {
|
|
2594
|
+
return 'text-bia-coolgrey';
|
|
2595
|
+
}
|
|
2596
|
+
};
|
|
2597
|
+
var selectedMonthStyle = function (month, monthSelected) {
|
|
2598
|
+
if (month === monthSelected) {
|
|
2599
|
+
return 'bg-bia-blue-dark-10 text-bia-white rounded-full border border-bia-blue-dark-10';
|
|
2600
|
+
}
|
|
2601
|
+
else {
|
|
2602
|
+
return 'hover:bg-bia-blue-pastel rounded-full';
|
|
2603
|
+
}
|
|
2604
|
+
};
|
|
2605
|
+
// Supporting functions
|
|
2606
|
+
var checkDateEquals = function (date1, date2) {
|
|
2607
|
+
if (!date2 || !date1)
|
|
2608
|
+
return false;
|
|
2609
|
+
return (date1.getFullYear() === date2.getFullYear() &&
|
|
2610
|
+
date1.getMonth() === date2.getMonth() &&
|
|
2611
|
+
date1.getDate() === date2.getDate());
|
|
2612
|
+
};
|
|
2613
|
+
// handler
|
|
2614
|
+
var handleViewNextMonth = function () {
|
|
2615
|
+
if (viewMonthValue === 11) {
|
|
2616
|
+
setViewMonthValue(0);
|
|
2617
|
+
setViewYearValue(viewYearValue + 1);
|
|
2618
|
+
setViewDecadeValue(viewYearValue + 1);
|
|
2619
|
+
}
|
|
2620
|
+
else {
|
|
2621
|
+
setViewMonthValue(viewMonthValue + 1);
|
|
2622
|
+
}
|
|
2623
|
+
};
|
|
2624
|
+
var handleViewNextYear = function () {
|
|
2625
|
+
setViewYearValue(function (oldYear) { return oldYear + 1; });
|
|
2626
|
+
setViewDecadeValue(function (oldYear) { return oldYear + 1; });
|
|
2627
|
+
};
|
|
2628
|
+
var handleViewPrevYear = function () {
|
|
2629
|
+
setViewYearValue(function (oldYear) { return oldYear - 1; });
|
|
2630
|
+
setViewDecadeValue(function (oldYear) { return oldYear - 1; });
|
|
2631
|
+
};
|
|
2632
|
+
var handleViewPrevMonth = function () {
|
|
2633
|
+
if (viewMonthValue === 0) {
|
|
2634
|
+
setViewMonthValue(11);
|
|
2635
|
+
setViewYearValue(viewYearValue - 1);
|
|
2636
|
+
setViewDecadeValue(viewYearValue - 1);
|
|
2637
|
+
}
|
|
2638
|
+
else {
|
|
2639
|
+
setViewMonthValue(viewMonthValue - 1);
|
|
2640
|
+
}
|
|
2641
|
+
};
|
|
2642
|
+
var handleNextAction = function () {
|
|
2643
|
+
if (pickerMode === 'date') {
|
|
2644
|
+
handleViewNextMonth();
|
|
2645
|
+
}
|
|
2646
|
+
else if (pickerMode === 'month') {
|
|
2647
|
+
handleViewNextYear();
|
|
2648
|
+
}
|
|
2649
|
+
else {
|
|
2650
|
+
setViewDecadeValue(function (oldvalue) { return oldvalue + 10; });
|
|
2651
|
+
}
|
|
2652
|
+
};
|
|
2653
|
+
var handlePrevAction = function () {
|
|
2654
|
+
if (pickerMode === 'date') {
|
|
2655
|
+
handleViewPrevMonth();
|
|
2656
|
+
}
|
|
2657
|
+
else if (pickerMode === 'month') {
|
|
2658
|
+
handleViewPrevYear();
|
|
2659
|
+
}
|
|
2660
|
+
else {
|
|
2661
|
+
setViewDecadeValue(function (oldvalue) { return oldvalue - 10; });
|
|
2662
|
+
}
|
|
2663
|
+
};
|
|
2664
|
+
var handleSetMonth = function (monthNumber) {
|
|
2665
|
+
setViewMonthValue(monthNumber);
|
|
2666
|
+
setPickerMode('date');
|
|
2667
|
+
};
|
|
2668
|
+
var handleSetYear = function (year, index) {
|
|
2669
|
+
setViewYearValue(year);
|
|
2670
|
+
setPickerMode(prevMode);
|
|
2671
|
+
};
|
|
2672
|
+
var handleSetSelectedDate = function (date) {
|
|
2673
|
+
if (date.getMonth() !== viewMonthValue) {
|
|
2674
|
+
// if the date is not in the current view month, update the view month and year
|
|
2675
|
+
setViewMonthValue(date.getMonth());
|
|
2676
|
+
setViewYearValue(date.getFullYear());
|
|
2677
|
+
}
|
|
2678
|
+
if (onDateChange) {
|
|
2679
|
+
onDateChange(date);
|
|
2680
|
+
}
|
|
2681
|
+
};
|
|
2682
|
+
var handlePickerMode = function (mode) {
|
|
2683
|
+
setPickerMode(function (oldvalue) {
|
|
2684
|
+
setPrevMode(oldvalue);
|
|
2685
|
+
return mode;
|
|
2686
|
+
});
|
|
2687
|
+
};
|
|
2688
|
+
// View Date Logic
|
|
2689
|
+
var _d = React.useState(new Date(selectedDate || todayValue).getMonth()), viewMonthValue = _d[0], setViewMonthValue = _d[1]; // get the month of the selected date
|
|
2690
|
+
var _e = React.useState(new Date(selectedDate || todayValue).getFullYear()), viewYearValue = _e[0], setViewYearValue = _e[1]; // get the year of the selected date
|
|
2691
|
+
var _f = React.useState(new Date(selectedDate || todayValue).getFullYear()), viewDecadeValue = _f[0], setViewDecadeValue = _f[1]; // get the year for decaderange
|
|
2692
|
+
// Month view logic
|
|
2693
|
+
var monthStartDay = new Date("".concat(viewYearValue, "-").concat(viewMonthValue + 1, "-01")).getDay() === 0
|
|
2694
|
+
? 6
|
|
2695
|
+
: new Date("".concat(viewYearValue, "-").concat(viewMonthValue + 1, "-01")).getDay() - 1;
|
|
2696
|
+
var monthTotalDate = new Date(viewYearValue, viewMonthValue + 1, 0).getDate(); // get total days in the month
|
|
2697
|
+
var monthCalenderView = monthTotalDate + monthStartDay > 35 ? 42 : 35; // for 5 or 6 weeks view for the calendar
|
|
2698
|
+
var viewFirstDate = new Date("".concat(viewYearValue, "-").concat(viewMonthValue + 1, "-01"));
|
|
2699
|
+
viewFirstDate.setDate(viewFirstDate.getDate() - monthStartDay); // get the first date of the view
|
|
2700
|
+
var viewLastDate = new Date(viewFirstDate);
|
|
2701
|
+
viewLastDate.setDate(viewLastDate.getDate() + monthCalenderView - 1); // get the last date of the view
|
|
2702
|
+
// Generate the view days array
|
|
2703
|
+
var _g = React.useState([]), displayDays = _g[0], setDisplayDays = _g[1];
|
|
2704
|
+
function getDecadeRange(year) {
|
|
2705
|
+
// Calculate the start of the decade
|
|
2706
|
+
var startOfDecade = Math.floor(year / 10) * 10;
|
|
2707
|
+
// Calculate the end of the decade
|
|
2708
|
+
var endOfDecade = startOfDecade + 9;
|
|
2709
|
+
// Create an array to hold the years in the decade
|
|
2710
|
+
var decadeRange = [];
|
|
2711
|
+
for (var i = startOfDecade; i <= endOfDecade + 2; i++) {
|
|
2712
|
+
decadeRange.push(i);
|
|
2713
|
+
}
|
|
2714
|
+
return decadeRange;
|
|
2715
|
+
}
|
|
2716
|
+
var yearDisplayRange = getDecadeRange(viewDecadeValue);
|
|
2717
|
+
// Variable display
|
|
2718
|
+
var dateDisplay = (React.createElement("div", { className: "".concat(pickerMode === 'date' ? '' : 'hidden') },
|
|
2719
|
+
React.createElement("div", { className: "bianic-datepicker-calendar-days-grid-header grid grid-cols-7 gap-[3px] pb-1.5" }, daysMap.map(function (day) { return (React.createElement("div", { key: day, className: "bianic-datepicker-calendar-day flex h-[18px] w-[31px] items-center justify-center text-bia-coolgrey" },
|
|
2720
|
+
React.createElement(Text, { variant: "small-text" }, day.slice(0, 3)))); })),
|
|
2721
|
+
React.createElement("div", { className: "bianic-datepicker-calendar-days-grid-body grid grid-cols-7 gap-y-1.5" }, displayDays.map(function (date) { return (React.createElement("button", { key: date.toString(), className: "bianic-datepicker-calendar-day flex h-[31px] w-[31px] items-center justify-center ".concat(datesColorStyle(date, viewMonthValue), " ").concat(selectedDateStyle(date, selectedDate)), onClick: function () {
|
|
2722
|
+
// Handle date selection logic here
|
|
2723
|
+
handleSetSelectedDate(date);
|
|
2724
|
+
} },
|
|
2725
|
+
React.createElement(Text, { variant: "small-text" }, date.getDate()))); }))));
|
|
2726
|
+
var monthDisplay = (React.createElement("div", { className: "bianic-datepicker-calendar-month-grid grid grid-cols-3 gap-y-1.5 ".concat(pickerMode === 'month' ? '' : 'hidden') }, monthMap.map(function (month, index) { return (React.createElement("button", { className: "bianic-datepicker-calendar-month mx-[15px] flex h-[31px] items-center justify-center ".concat(selectedMonthStyle(index, viewMonthValue)), key: index, onClick: function () { return handleSetMonth(index); } },
|
|
2727
|
+
React.createElement(Text, { variant: "small-text" }, month.slice(0, 3)))); })));
|
|
2728
|
+
var yearDisplay = (React.createElement("div", { className: "bianic-datepicker-calendar-year-grid grid grid-cols-4 gap-y-1.5 ".concat(pickerMode === 'year' ? '' : 'hidden') }, yearDisplayRange.map(function (year, index) { return (React.createElement("button", { className: "bianic-datepicker-calendar-month mx-[6px] flex h-[31px] items-center justify-center ".concat(selectedMonthStyle(year, viewYearValue), " ").concat(index === 0 || index === 11 ? 'text-bia-coolgrey' : 'text-bia-black'), key: index, onClick: function () { return handleSetYear(year); } },
|
|
2729
|
+
React.createElement(Text, { variant: "small-text" }, year))); })));
|
|
2730
|
+
// useEffect to update displayDays when viewMonthValue or viewYearValue changes
|
|
2731
|
+
React.useEffect(function () {
|
|
2732
|
+
var tempDisplayDays = [];
|
|
2733
|
+
for (var d = viewFirstDate; d <= viewLastDate; d.setDate(d.getDate() + 1)) {
|
|
2734
|
+
tempDisplayDays.push(new Date(d));
|
|
2735
|
+
}
|
|
2736
|
+
setDisplayDays(tempDisplayDays);
|
|
2737
|
+
}, [viewMonthValue, viewYearValue, selectedDate]);
|
|
2738
|
+
return (React.createElement("div", { className: "bianic-datepicker-calendar flex flex-col gap-[15px] text-bia-black", ref: ref },
|
|
2739
|
+
React.createElement("div", { className: "bianic-datepicker-calendar-controller flex w-full items-center justify-between" },
|
|
2740
|
+
React.createElement("button", { className: "bianic-datepicker-calendar-prev-button ".concat(chevronButtonStyle), onClick: function () { return handlePrevAction(); } },
|
|
2741
|
+
React.createElement(TbChevronLeft, { size: 18 })),
|
|
2742
|
+
React.createElement("div", { className: "bianic-datepicker-calendar-current-month gap flex items-center justify-center gap-1" },
|
|
2743
|
+
React.createElement("button", { className: "".concat(pickerMode === 'date' ? '' : 'hidden'), onClick: function () { return handlePickerMode('month'); } },
|
|
2744
|
+
React.createElement(Text, { variant: "normal-text-semibold" },
|
|
2745
|
+
monthMap[viewMonthValue],
|
|
2746
|
+
' ')),
|
|
2747
|
+
React.createElement("button", { className: "".concat(pickerMode === 'date' || pickerMode === 'month' ? '' : 'hidden'), onClick: function () { return handlePickerMode('year'); } },
|
|
2748
|
+
React.createElement(Text, { variant: "normal-text" }, viewYearValue)),
|
|
2749
|
+
React.createElement("button", { className: "".concat(pickerMode === 'year' ? '' : 'hidden') },
|
|
2750
|
+
React.createElement(Text, { variant: "normal-text" }, "".concat(yearDisplayRange[1], " - ").concat(yearDisplayRange[10])))),
|
|
2751
|
+
React.createElement("button", { className: "bianic-datepicker-calendar-next-button ".concat(chevronButtonStyle), onClick: function () { return handleNextAction(); } },
|
|
2752
|
+
React.createElement(TbChevronRight, { size: 18 }))),
|
|
2753
|
+
React.createElement("div", { className: "bianic-datepicker-calendar-days-grid flex flex-col " },
|
|
2754
|
+
dateDisplay,
|
|
2755
|
+
monthDisplay,
|
|
2756
|
+
yearDisplay)));
|
|
2757
|
+
};
|
|
2758
|
+
|
|
2759
|
+
var monthMap = [
|
|
2760
|
+
'January',
|
|
2761
|
+
'February',
|
|
2762
|
+
'March',
|
|
2763
|
+
'April',
|
|
2764
|
+
'May',
|
|
2765
|
+
'June',
|
|
2766
|
+
'July',
|
|
2767
|
+
'August',
|
|
2768
|
+
'September',
|
|
2769
|
+
'October',
|
|
2770
|
+
'November',
|
|
2771
|
+
'December',
|
|
2772
|
+
];
|
|
2773
|
+
function DatePicker(_a) {
|
|
2774
|
+
var value = _a.value, onChange = _a.onChange;
|
|
2775
|
+
// State and Ref
|
|
2776
|
+
var inputRef = React.useRef(null);
|
|
2777
|
+
var wrapperRef = React.useRef(null);
|
|
2778
|
+
var pickerRef = React.useRef(null);
|
|
2779
|
+
var _b = useDetectOutsideClick(wrapperRef, false, pickerRef), isPickerOpen = _b[0], setIsPickerOpen = _b[1];
|
|
2780
|
+
return (React.createElement("div", { className: "bianic-datepicker-container relative", ref: wrapperRef },
|
|
2781
|
+
React.createElement("div", { className: "bianic-datepicker-field-container" },
|
|
2782
|
+
React.createElement(DateInput, { ref: inputRef, placeholder: "YYYY-MM-DD", value: value, onChange: onChange, buttonAction: function () { return setIsPickerOpen(true); }, setIsActive: setIsPickerOpen })),
|
|
2783
|
+
isPickerOpen && (React.createElement("div", { className: "bianic-datepicker-calendar-container absolute left-0 w-[250px] rounded-b-radius-sm bg-bia-white px-1.5 pb-[17px] pt-[15px] shadow-md" },
|
|
2784
|
+
React.createElement(PickerCalendar, { selectedDate: new Date(value), onDateChange: onChange, ref: pickerRef })))));
|
|
2785
|
+
}
|
|
2786
|
+
var DateInput = function (_a) {
|
|
2787
|
+
var className = _a.className, value = _a.value; _a.isActive; var setIsActive = _a.setIsActive, label = _a.label, id = _a.id, _b = _a.size, size = _b === void 0 ? 'md' : _b, onChange = _a.onChange, _c = _a.required, required = _c === void 0 ? false : _c, buttonAction = _a.buttonAction, props = __rest(_a, ["className", "value", "isActive", "setIsActive", "label", "id", "size", "onChange", "required", "buttonAction"]);
|
|
2788
|
+
var editDateFormatter = function (date) {
|
|
2789
|
+
var localString = date.toLocaleDateString().split('/');
|
|
2790
|
+
return localString.reverse().join('-');
|
|
2791
|
+
};
|
|
2792
|
+
var displayDateFormatter = function (date) {
|
|
2793
|
+
return "".concat(date.getDate(), " ").concat(monthMap[date.getMonth()].slice(0, 3), " '").concat(date.getFullYear().toString().slice(2, 4));
|
|
2794
|
+
};
|
|
2795
|
+
// Convert Date to string for display
|
|
2796
|
+
var formattedValue = value instanceof Date ? displayDateFormatter(value) : value;
|
|
2797
|
+
var _d = React.useState(formattedValue), viewValue = _d[0], setViewValue = _d[1];
|
|
2798
|
+
React.useRef(null);
|
|
2799
|
+
var _e = React.useState(0); _e[0]; _e[1];
|
|
2800
|
+
var _f = styleConfig['text'], fieldStyle = _f.fieldStyle;
|
|
2801
|
+
var _g = sizeConfig$b[size]; _g.iconSize; var fieldSize = _g.fieldSize, iconPosition = _g.iconPosition;
|
|
2802
|
+
var borderStyle = 'border border-bia-grey-dark-10 bg-primary-white';
|
|
2803
|
+
var extendedInputClassName = "".concat(fieldStyle, " ").concat(fieldSize, " ").concat(borderStyle, " ").concat(className);
|
|
2804
|
+
var labelStatus = props.readOnly ? 'read-only:pointer-events-none' : '';
|
|
2805
|
+
// Don't remove this, it will be used later
|
|
2806
|
+
// Helper function to format the cleaned input with specific group sizes
|
|
2807
|
+
// const formatInput = (cleanedValue: string, separator: string = '-') => {
|
|
2808
|
+
// let formattedValue = ''
|
|
2809
|
+
// // Define the group lengths: 4, 2, 2
|
|
2810
|
+
// const groupLengths = [4, 2, 2]
|
|
2811
|
+
// let currentIndex = 0
|
|
2812
|
+
// for (let i = 0; i < groupLengths.length; i++) {
|
|
2813
|
+
// const groupLength = groupLengths[i]
|
|
2814
|
+
// const nextSegment = cleanedValue.substring(
|
|
2815
|
+
// currentIndex,
|
|
2816
|
+
// currentIndex + groupLength
|
|
2817
|
+
// )
|
|
2818
|
+
// if (nextSegment.length > 0) {
|
|
2819
|
+
// formattedValue += nextSegment
|
|
2820
|
+
// currentIndex += groupLength
|
|
2821
|
+
// // Add separator if there are more groups to follow and we have enough characters
|
|
2822
|
+
// if (i < groupLengths.length - 1 && currentIndex < cleanedValue.length) {
|
|
2823
|
+
// formattedValue += separator
|
|
2824
|
+
// }
|
|
2825
|
+
// } else {
|
|
2826
|
+
// // Stop if there are no more characters for the current group
|
|
2827
|
+
// break
|
|
2828
|
+
// }
|
|
2829
|
+
// }
|
|
2830
|
+
// return formattedValue
|
|
2831
|
+
// }
|
|
2832
|
+
var validateAndFormatDate = function (value) {
|
|
2833
|
+
// 1. validate separator
|
|
2834
|
+
var splittedDate = value.split('-');
|
|
2835
|
+
if (splittedDate.length !== 3) {
|
|
2836
|
+
return [1, value]; // Invalid format
|
|
2837
|
+
}
|
|
2838
|
+
var year = splittedDate[0];
|
|
2839
|
+
var month = splittedDate[1];
|
|
2840
|
+
var day = splittedDate[2];
|
|
2841
|
+
// 2. validate year
|
|
2842
|
+
if (!/^\d{4}$/.test(year)) {
|
|
2843
|
+
return [2, value];
|
|
2844
|
+
}
|
|
2845
|
+
var parsedYear = parseInt(year, 10);
|
|
2846
|
+
// 3. validate month digit
|
|
2847
|
+
if (!/^\d{1,2}$/.test(month)) {
|
|
2848
|
+
return [3, value];
|
|
2849
|
+
}
|
|
2850
|
+
// 4. validate month range
|
|
2851
|
+
var parsedMonth = parseInt(month, 10);
|
|
2852
|
+
if (parsedMonth < 1 || parsedMonth > 12) {
|
|
2853
|
+
return [4, value];
|
|
2854
|
+
}
|
|
2855
|
+
var formattedMonth = String(parsedMonth).padStart(2, '0');
|
|
2856
|
+
// 5. validate date digit
|
|
2857
|
+
if (!/^\d{1,2}$/.test(day)) {
|
|
2858
|
+
return [5, value];
|
|
2859
|
+
}
|
|
2860
|
+
// 6. validate date range
|
|
2861
|
+
var parsedDate = parseInt(day, 10);
|
|
2862
|
+
if (parsedDate < 1 || parsedDate > 31) {
|
|
2863
|
+
return [6, value];
|
|
2864
|
+
}
|
|
2865
|
+
var formattedDay = String(parsedDate).padStart(2, '0');
|
|
2866
|
+
// 7. validate date rightness
|
|
2867
|
+
var dateObject = new Date(parsedYear, parsedMonth - 1, parsedDate);
|
|
2868
|
+
if (dateObject.getFullYear() !== parsedYear ||
|
|
2869
|
+
dateObject.getMonth() !== parsedMonth - 1 ||
|
|
2870
|
+
dateObject.getDate() !== parsedDate) {
|
|
2871
|
+
return [7, value];
|
|
2872
|
+
}
|
|
2873
|
+
// If all checks pass, the date is valid and formatted
|
|
2874
|
+
var formattedDate = "".concat(year, "-").concat(formattedMonth, "-").concat(formattedDay);
|
|
2875
|
+
return [0, formattedDate];
|
|
2876
|
+
};
|
|
2877
|
+
// Update actual value on release
|
|
2878
|
+
var updateValue = function (newValue) {
|
|
2879
|
+
var date = new Date(newValue); // Create a Date object from the input
|
|
2880
|
+
if (onChange && !Number.isNaN(date.valueOf())) {
|
|
2881
|
+
onChange(date); // Update the value if it's a valid date
|
|
2882
|
+
}
|
|
2883
|
+
};
|
|
2884
|
+
// Handle input change will develop later don't remove
|
|
2885
|
+
// const handleChange = (event) => {
|
|
2886
|
+
// const inputElement = event.target
|
|
2887
|
+
// const rawValue = inputElement.value
|
|
2888
|
+
// const currentCursorPos = inputElement.selectionStart
|
|
2889
|
+
// const cleaned = cleanInput(rawValue)
|
|
2890
|
+
// // Max total digits for XXXX-XX-XX is 4 + 2 + 2 = 8
|
|
2891
|
+
// const maxDigits = 8
|
|
2892
|
+
// const truncatedCleaned = cleaned.substring(0, maxDigits)
|
|
2893
|
+
// const formatted = formatInput(truncatedCleaned)
|
|
2894
|
+
// // --- Cursor Position Adjustment Logic ---
|
|
2895
|
+
// let newCursorPos = currentCursorPos
|
|
2896
|
+
// const prevFormattedLength = viewValue.length // Length of the string *before* update
|
|
2897
|
+
// const currentFormattedLength = formatted.length // Length of the string *after* update
|
|
2898
|
+
// // If text was added and formatted length increased
|
|
2899
|
+
// if (currentFormattedLength > prevFormattedLength) {
|
|
2900
|
+
// // Count how many separators are now *before* the cursor in the new string
|
|
2901
|
+
// // We'll compare the raw cursor position with the formatted string to adjust
|
|
2902
|
+
// let separatorCountBeforeCursor = 0
|
|
2903
|
+
// let originalCleanedValue = cleanInput(viewValue) // Clean value before this change
|
|
2904
|
+
// // If a character was inserted, estimate new cursor position
|
|
2905
|
+
// if (cleaned.length > originalCleanedValue.length) {
|
|
2906
|
+
// // Count separators in the *new* formatted string up to the currentCursorPos
|
|
2907
|
+
// for (let i = 0; i < currentCursorPos; i++) {
|
|
2908
|
+
// if (formatted.charAt(i) === '-') {
|
|
2909
|
+
// separatorCountBeforeCursor++
|
|
2910
|
+
// }
|
|
2911
|
+
// }
|
|
2912
|
+
// newCursorPos = currentCursorPos + separatorCountBeforeCursor
|
|
2913
|
+
// } else {
|
|
2914
|
+
// // If characters were deleted (backspace/delete)
|
|
2915
|
+
// newCursorPos = currentCursorPos
|
|
2916
|
+
// // More sophisticated logic for backspace/delete on separators can go here.
|
|
2917
|
+
// // For example, if you backspace a digit and it causes a separator to disappear,
|
|
2918
|
+
// // the cursor might need to jump back an extra position.
|
|
2919
|
+
// // This basic setup often works acceptably for most cases.
|
|
2920
|
+
// }
|
|
2921
|
+
// } else {
|
|
2922
|
+
// // If text was deleted or no change in length
|
|
2923
|
+
// newCursorPos = currentCursorPos
|
|
2924
|
+
// }
|
|
2925
|
+
// const handleKeyDown = (event) => {
|
|
2926
|
+
// if (event.key === 'Enter') {
|
|
2927
|
+
// // Prevent default form submission if the input is inside a <form>
|
|
2928
|
+
// // event.preventDefault();
|
|
2929
|
+
// }
|
|
2930
|
+
// }
|
|
2931
|
+
// setViewValue(formatted)
|
|
2932
|
+
// setLastCursorPos(newCursorPos)
|
|
2933
|
+
// }
|
|
2934
|
+
var handleChange = function (event) {
|
|
2935
|
+
var value = event.target.value;
|
|
2936
|
+
// Regular expression to allow only numbers (0-9) and hyphens (-)
|
|
2937
|
+
// The caret (^) matches the beginning of the string, and the dollar sign ($) matches the end.
|
|
2938
|
+
// This ensures the *entire* string matches the pattern.
|
|
2939
|
+
var regex = /^[0-9-]*$/;
|
|
2940
|
+
if (regex.test(value)) {
|
|
2941
|
+
setViewValue(value);
|
|
2942
|
+
}
|
|
2943
|
+
};
|
|
2944
|
+
// Will Develop later
|
|
2945
|
+
// useEffect to set cursor position after render
|
|
2946
|
+
// useEffect(() => {
|
|
2947
|
+
// if (inputRef.current) {
|
|
2948
|
+
// inputRef.current.setSelectionRange(lastCursorPos, lastCursorPos)
|
|
2949
|
+
// }
|
|
2950
|
+
// }, [viewValue, lastCursorPos]) // Re-run when viewValue or lastCursorPos changes
|
|
2951
|
+
React.useEffect(function () {
|
|
2952
|
+
setViewValue(formattedValue);
|
|
2953
|
+
}, [value]);
|
|
2954
|
+
return (React.createElement("div", { className: "bianic-date-input-container bianic-fgc-container flex w-full flex-col gap-y-2 text-bia-black" },
|
|
2955
|
+
label && (React.createElement("label", { htmlFor: id, className: "bianic-text-input-label text-xs font-semibold ".concat(labelStatus) },
|
|
2956
|
+
label,
|
|
2957
|
+
required && React.createElement("span", { className: "p-1 text-bia-red" }, "*"))),
|
|
2958
|
+
React.createElement("div", { className: "relative w-full" },
|
|
2959
|
+
React.createElement("input", __assign({}, props, { type: "text", className: "bianic-text-input bianic-fgc-target w-full rounded read-only:pointer-events-none read-only:border-bia-grey-light-50 hover:rounded-b-none focus:rounded-b-none focus-visible:outline-none disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-grey-active ".concat(extendedInputClassName), id: id, value: viewValue, onFocus: function () {
|
|
2960
|
+
setIsActive && setIsActive(true);
|
|
2961
|
+
setViewValue(editDateFormatter(value));
|
|
2962
|
+
}, onChange: handleChange, onBlur: function () {
|
|
2963
|
+
var _a = validateAndFormatDate(viewValue), status = _a[0], validatedValue = _a[1];
|
|
2964
|
+
setViewValue(displayDateFormatter(value));
|
|
2965
|
+
if (status !== 0) ;
|
|
2966
|
+
else {
|
|
2967
|
+
updateValue(validatedValue);
|
|
2968
|
+
}
|
|
2969
|
+
}, maxLength: 10 })),
|
|
2970
|
+
React.createElement("div", { className: "absolute inset-y-0 flex items-center pl-3 text-[18px] ".concat(iconPosition) },
|
|
2971
|
+
React.createElement("button", { className: "bianic-datepicker-toggle-button", onClick: function () {
|
|
2972
|
+
buttonAction && buttonAction();
|
|
2973
|
+
} },
|
|
2974
|
+
React.createElement(TbCalendar, null))))));
|
|
2975
|
+
};
|
|
2976
|
+
|
|
2510
2977
|
var Node = function (_a) {
|
|
2511
2978
|
var className = _a.className, _b = _a.fill, fill = _b === void 0 ? '#2f2f2f' : _b, _c = _a.size, size = _c === void 0 ? 20 : _c;
|
|
2512
2979
|
return (React.createElement("svg", { className: className, width: size, height: size, viewBox: "0 0 24 24", fill: fill, stroke: fill, xmlns: "http://www.w3.org/2000/svg" },
|
|
@@ -2969,8 +3436,8 @@ function ResizeableDiv(_a) {
|
|
|
2969
3436
|
var container = React.useRef(null);
|
|
2970
3437
|
var resizer = React.useRef(null);
|
|
2971
3438
|
var handleResize = function (e) {
|
|
2972
|
-
var mouseY = e.
|
|
2973
|
-
var mouseX = e.
|
|
3439
|
+
var mouseY = e.clientY;
|
|
3440
|
+
var mouseX = e.clientX;
|
|
2974
3441
|
var divBottom = container.current.getBoundingClientRect().bottom;
|
|
2975
3442
|
var divLeft = container.current.getBoundingClientRect().left;
|
|
2976
3443
|
var divTop = container.current.getBoundingClientRect().top;
|
|
@@ -2984,12 +3451,12 @@ function ResizeableDiv(_a) {
|
|
|
2984
3451
|
container.current.style.height = "".concat(height, "px");
|
|
2985
3452
|
break;
|
|
2986
3453
|
case 'right':
|
|
2987
|
-
width = mouseX
|
|
3454
|
+
width = mouseX - divLeft;
|
|
2988
3455
|
if (width > 9)
|
|
2989
3456
|
container.current.style.width = "".concat(width, "px");
|
|
2990
3457
|
break;
|
|
2991
3458
|
case 'bottom':
|
|
2992
|
-
height = mouseY
|
|
3459
|
+
height = mouseY - divTop;
|
|
2993
3460
|
if (height > 9)
|
|
2994
3461
|
container.current.style.height = "".concat(height, "px");
|
|
2995
3462
|
break;
|
|
@@ -3023,13 +3490,13 @@ function ResizeableDiv(_a) {
|
|
|
3023
3490
|
minWidth: minimumWidth,
|
|
3024
3491
|
minHeight: minimumHeight,
|
|
3025
3492
|
} },
|
|
3026
|
-
React.createElement("div", { className: "
|
|
3027
|
-
React.createElement("div", { className: "group absolute z-10 flex items-center justify-center ".concat(resizerContainerClass[position]), ref: resizer, onMouseDown: function () {
|
|
3493
|
+
React.createElement("div", { className: "group peer absolute z-10 flex items-center justify-center ".concat(resizerContainerClass[position]), ref: resizer, onMouseDown: function () {
|
|
3028
3494
|
window.addEventListener('mousemove', handleResize);
|
|
3029
3495
|
window.addEventListener('mouseup', stopResize);
|
|
3030
3496
|
}, role: "button" },
|
|
3031
3497
|
React.createElement("div", { className: "flex h-[9px] w-[25px] items-center justify-center rounded-radius-full border border-bia-grey-light-10 bg-primary-white opacity-20 group-hover:opacity-100 group-active:bg-bia-coolgrey-light-90 group-active:opacity-100 ".concat(thumbClass) },
|
|
3032
|
-
React.createElement(TbDots, { className: "text-bia-grey-light-30" })))
|
|
3498
|
+
React.createElement(TbDots, { className: "text-bia-grey-light-30" }))),
|
|
3499
|
+
React.createElement("div", { className: "h-full w-full peer-active:select-none ".concat(className) }, children)));
|
|
3033
3500
|
}
|
|
3034
3501
|
ResizeableDiv.defaultProps = {
|
|
3035
3502
|
position: 'left',
|
|
@@ -3523,6 +3990,7 @@ exports.ButtonApp = ButtonApp;
|
|
|
3523
3990
|
exports.Checkbox = Checkbox;
|
|
3524
3991
|
exports.Color = Color;
|
|
3525
3992
|
exports.ContextualButton = ContextualButton;
|
|
3993
|
+
exports.DatePicker = DatePicker;
|
|
3526
3994
|
exports.Display = Display;
|
|
3527
3995
|
exports.Divider = Divider;
|
|
3528
3996
|
exports.DropdownContainer = DropdownContainer;
|