bianic-ui 2.3.1 → 2.4.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 CHANGED
@@ -1989,9 +1989,9 @@ var usePopupPosition = function (anchorRef, popupRef, position) {
1989
1989
  };
1990
1990
 
1991
1991
  var MenuElement = React.forwardRef(function (_a, ref) {
1992
- var isTopFlat = _a.isTopFlat, children = _a.children, className = _a.className, zIndex = _a.zIndex, menuRef = _a.menuRef, onClose = _a.onClose, onClickItem = _a.onClickItem, style = _a.style, restProps = __rest(_a, ["isTopFlat", "children", "className", "zIndex", "menuRef", "onClose", "onClickItem", "style"]);
1992
+ var isTopFlat = _a.isTopFlat, children = _a.children, className = _a.className, zIndex = _a.zIndex, menuRef = _a.menuRef, onClose = _a.onClose, onClickItem = _a.onClickItem, style = _a.style, onContextMenu = _a.onContextMenu, restProps = __rest(_a, ["isTopFlat", "children", "className", "zIndex", "menuRef", "onClose", "onClickItem", "style", "onContextMenu"]);
1993
1993
  var radiusClass = "rounded-b-radius-sm ".concat(!isTopFlat && 'rounded-t-radius-sm');
1994
- return (React.createElement("div", __assign({ ref: menuRef, className: "w-fit bg-bia-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] ".concat(radiusClass, " ").concat(className), style: style }, restProps), React.Children.map(children, function (child) {
1994
+ return (React.createElement("div", __assign({ ref: menuRef, className: "w-fit bg-bia-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] ".concat(radiusClass, " ").concat(className), style: style, onContextMenu: onContextMenu }, restProps), React.Children.map(children, function (child) {
1995
1995
  return React.isValidElement(child)
1996
1996
  ? React.cloneElement(child, {
1997
1997
  onClose: function () { return onClose(); },
@@ -2002,7 +2002,7 @@ var MenuElement = React.forwardRef(function (_a, ref) {
2002
2002
  })));
2003
2003
  });
2004
2004
  var MenuContainer = function (props) {
2005
- var _a = props.isTopFlat, isTopFlat = _a === void 0 ? false : _a, children = props.children, _b = props.open, open = _b === void 0 ? true : _b, _c = props.onClose, onClose = _c === void 0 ? function () { } : _c, _d = props.className, className = _d === void 0 ? '' : _d, _e = props.isWithOverlay, isWithOverlay = _e === void 0 ? true : _e, _f = props.zIndex, zIndex = _f === void 0 ? 100 : _f, _g = props.onClickItem, onClickItem = _g === void 0 ? function () { } : _g, anchorRef = props.anchorRef, matchAnchorWidth = props.matchAnchorWidth, restProps = __rest(props, ["isTopFlat", "children", "open", "onClose", "className", "isWithOverlay", "zIndex", "onClickItem", "anchorRef", "matchAnchorWidth"]);
2005
+ var _a = props.isTopFlat, isTopFlat = _a === void 0 ? false : _a, children = props.children, _b = props.open, open = _b === void 0 ? true : _b, _c = props.onClose, onClose = _c === void 0 ? function () { } : _c, _d = props.className, className = _d === void 0 ? '' : _d, _e = props.isWithOverlay, isWithOverlay = _e === void 0 ? true : _e, _f = props.zIndex, zIndex = _f === void 0 ? 100 : _f, _g = props.onClickItem, onClickItem = _g === void 0 ? function () { } : _g, anchorRef = props.anchorRef, matchAnchorWidth = props.matchAnchorWidth, onContextMenu = props.onContextMenu, restProps = __rest(props, ["isTopFlat", "children", "open", "onClose", "className", "isWithOverlay", "zIndex", "onClickItem", "anchorRef", "matchAnchorWidth", "onContextMenu"]);
2006
2006
  if (!open)
2007
2007
  return null;
2008
2008
  var MenuContainerRef = React.useRef(null);
@@ -2030,9 +2030,13 @@ var MenuContainer = function (props) {
2030
2030
  }
2031
2031
  return __assign(__assign({ zIndex: zIndex + 10 }, widthStyle), positionStyle);
2032
2032
  }, [positionStyle]);
2033
- var menuElement = (React.createElement(MenuElement, __assign({ isTopFlat: isTopFlat, children: children, className: className, zIndex: zIndex, menuRef: MenuContainerRef, onClose: onClose, onClickItem: onClickItem, style: newStyle }, restProps)));
2033
+ var menuElement = (React.createElement(MenuElement, __assign({ isTopFlat: isTopFlat, children: children, className: className, zIndex: zIndex, menuRef: MenuContainerRef, onClose: onClose, onClickItem: onClickItem, style: newStyle, onContextMenu: function (e) {
2034
+ return onContextMenu ? onContextMenu(e) : e.preventDefault();
2035
+ } }, restProps)));
2034
2036
  return (React.createElement(React.Fragment, null,
2035
- isWithOverlay && (React.createElement("div", { className: "bianic-menu-overlay fixed left-0 top-0 z-0 h-screen w-screen", onClick: function () { return onClose(); }, style: { zIndex: zIndex } })),
2037
+ isWithOverlay && (React.createElement("div", { className: "bianic-menu-overlay fixed left-0 top-0 z-0 h-screen w-screen", onClick: function () { return onClose(); }, style: { zIndex: zIndex }, onContextMenu: function (e) {
2038
+ return onContextMenu ? onContextMenu(e) : e.preventDefault();
2039
+ } })),
2036
2040
  (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)
2037
2041
  ? reactDom.createPortal(menuElement, document.body)
2038
2042
  : menuElement));
@@ -2297,7 +2301,7 @@ var TextInput = React.forwardRef(function (_a, ref) {
2297
2301
  return (React.createElement("div", { className: "bianic-text-input-container bianic-fgc-container group/form flex w-full flex-col gap-y-2 text-bia-black" },
2298
2302
  label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
2299
2303
  React.createElement("div", { className: "relative w-full ".concat(disabledClass) },
2300
- React.createElement("input", __assign({ className: "bianic-text-input bianic-fgc-target w-full rounded read-only:pointer-events-none read-only:border-bia-grey-light-50 hover:rounded-b-none focus:rounded-b-none focus-visible:outline-none disabled:cursor-not-allowed disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-grey-active ".concat(extendedInputClassName), disabled: disabled, id: id, placeholder: placeholder || label, readOnly: readOnly, required: required, type: typeVariant, value: value, onChange: function (e) { return onChange(e); }, maxLength: maxLength, autoComplete: autoComplete, ref: ref }, props)),
2304
+ React.createElement("input", __assign({ className: "bianic-text-input bianic-fgc-target w-full rounded read-only:pointer-events-none read-only:border-bia-grey-light-50 hover:rounded-b-none focus:rounded-b-none focus-visible:outline-none disabled:cursor-not-allowed disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-grey-active ".concat(extendedInputClassName), disabled: disabled, id: id, placeholder: placeholder || label, readOnly: readOnly, required: required, type: typeVariant, value: value, onChange: function (e) { return onChange(e); }, maxLength: maxLength, autoComplete: autoComplete, ref: ref, style: { paddingRight: "".concat(10 + Number(iconSize), "px") } }, props)),
2301
2305
  React.createElement("div", { className: "absolute inset-y-0 flex items-center pl-3 ".concat(actionElement ? '' : iconStyle, " ").concat(iconPosition, " ").concat(iconSizing) }, iconElement)),
2302
2306
  (descText || maxLength) && (React.createElement("div", { className: "bianic-text-input-desc flex justify-between gap-1 whitespace-nowrap text-xs ".concat(descColor) },
2303
2307
  React.createElement("span", null, descText),
@@ -2569,7 +2573,7 @@ function SelectInput(_a) {
2569
2573
  }
2570
2574
  return child;
2571
2575
  })))),
2572
- descText && (React.createElement("span", { className: "bianic-livesearch-desc bianic-text-input-desc whitespace-nowrap text-xs ".concat(descColor) }, descText))));
2576
+ descText && (React.createElement("span", { className: "bianic-livesearch-desc bianic-text-input-desc text-xs ".concat(descColor) }, descText))));
2573
2577
  }
2574
2578
  SelectInput.defaultProps = {
2575
2579
  descText: '',
@@ -2727,11 +2731,7 @@ function DropdownItem(_a) {
2727
2731
  : 'right-0 translate-x-full';
2728
2732
  var currentZIndex = zIndex + 10;
2729
2733
  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); } },
2730
- 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: {
2731
- zIndex: isHovered ? currentZIndex : currentZIndex + 15,
2732
- }, onClick: function (e) {
2733
- onClickItem(e, value);
2734
- }, onKeyDown: function () { }, disabled: disabled, type: "button" }, props),
2734
+ 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: { zIndex: currentZIndex + 15 }, onClick: function (e) { return onClickItem(e, value); }, onKeyDown: function () { }, disabled: disabled, type: "button" }, props),
2735
2735
  content,
2736
2736
  React.createElement("div", { className: "ml-auto flex items-center" }, children && (React.createElement(TbChevronRight, { className: "ml-[10px] text-bia-coolgrey", size: chevronSize })))),
2737
2737
  children && (React.createElement(DropdownContNoAnchor, { className: "absolute top-0 bg-primary-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] group-first/main:top-[6px] ".concat(translateClass), onClose: onClose, open: isHovered, onClickItem: function (e, value) { return onClickItem(e, value); }, size: size, ref: DropdownContRef, zIndex: currentZIndex + 10 }, children))));
@@ -2761,11 +2761,12 @@ var filterOptions = function (options, searchTerm) {
2761
2761
  });
2762
2762
  };
2763
2763
 
2764
+ var isObjectWithLabel = function (value) {
2765
+ return typeof value === 'object' && value !== null && 'label' in value;
2766
+ };
2764
2767
  var getItemLabel = function (value) {
2765
2768
  var _a;
2766
- return typeof value === 'object' && value !== null && 'label' in value
2767
- ? (_a = value.label) !== null && _a !== void 0 ? _a : ''
2768
- : String(value !== null && value !== void 0 ? value : '');
2769
+ return isObjectWithLabel(value) ? (_a = value.label) !== null && _a !== void 0 ? _a : '' : String(value !== null && value !== void 0 ? value : '');
2769
2770
  };
2770
2771
  var processDropdownChildren = function (nodes, currentSearchTerm, includeAllIfNoSearch, searchVariant, handleDropdownItemClick) {
2771
2772
  if (searchVariant === void 0) { searchVariant = 'include'; }
@@ -2869,7 +2870,7 @@ function LiveSearch(_a) {
2869
2870
  }), isOpen = _m.isOpen, setIsOpen = _m.setIsOpen, searchTerm = _m.searchTerm, handleInputChange = _m.handleInputChange, handleDropdownItemClick = _m.handleDropdownItemClick;
2870
2871
  var _o = sizeConfig$6[size], iconClass = _o.iconClass, iconSize = _o.iconSize, inputClass = _o.inputClass;
2871
2872
  var _p = dropContProps || {}, dropContClassName = _p.className; _p.onClickItem; _p.anchorRef; var restDropContProps = __rest(_p, ["className", "onClickItem", "anchorRef"]);
2872
- var isValueExist = value && value.label !== undefined && value.label !== '';
2873
+ var isSearchTermExist = searchTerm && searchTerm !== '';
2873
2874
  var descColor = 'text-primary-cool';
2874
2875
  var isExistValidation = isValid !== null && isValid !== undefined;
2875
2876
  if (!disabled && isExistValidation && isValid)
@@ -2882,13 +2883,13 @@ function LiveSearch(_a) {
2882
2883
  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" },
2883
2884
  label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
2884
2885
  React.createElement("div", { className: "group relative w-full ".concat(disabledClass) },
2885
- 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), onClick: function () { return setIsOpen(!isOpen); }, value: searchTerm, required: required, disabled: disabled, id: id, placeholder: placeholder, ref: inputRef, onChange: function (e) {
2886
+ React.createElement("input", { className: "bianic-livesearch-input bianic-fgc-target field peer w-full rounded border border-bia-grey-dark-10 bg-primary-white text-bia-black read-only:pointer-events-none read-only:border-bia-grey-light-50 focus-visible:outline-none enabled:hover:rounded-b-none enabled:hover:border-b-bia-blue enabled:focus:rounded-b-none enabled:focus:border-b-bia-blue disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-coolgrey ".concat(inputClass), style: { paddingRight: "".concat(10 + Number(iconSize), "px") }, onClick: function () { return setIsOpen(!isOpen); }, value: searchTerm, required: required, disabled: disabled, id: id, placeholder: placeholder, ref: inputRef, onChange: function (e) {
2886
2887
  onChangeText(e);
2887
2888
  handleInputChange(e);
2888
2889
  }, type: "text", readOnly: readOnly, autoComplete: autoComplete }),
2889
2890
  React.createElement("div", { className: "absolute inset-y-0 flex items-center pl-3 ".concat(iconClass) },
2890
- !isValueExist && (React.createElement(TbZoom, { className: "text-primary-black", style: { fontSize: iconSize } })),
2891
- isValueExist && (React.createElement("button", { onClick: function () { return setValue({ id: null, label: '' }); }, className: "flex h-full w-full items-center" },
2891
+ !isSearchTermExist && (React.createElement(TbZoom, { className: "text-primary-black", style: { fontSize: iconSize } })),
2892
+ isSearchTermExist && (React.createElement("button", { onClick: function () { return setValue({ id: null, label: '' }); }, className: "flex h-full w-full items-center disabled:cursor-not-allowed", disabled: disabled },
2892
2893
  React.createElement(TbX, { className: "text-primary-black", style: { fontSize: iconSize } })))),
2893
2894
  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) {
2894
2895
  var isSelected = value && value.id && option.id === value.id;
@@ -2904,7 +2905,7 @@ function LiveSearch(_a) {
2904
2905
  ? renderedChildren
2905
2906
  : // If no results and searchTerm is present
2906
2907
  searchTerm.length > 0 && (React.createElement(DropdownItem, { content: React.createElement("div", { className: "px-4 py-2 text-gray-500" }, "Tidak ada hasil ditemukan.") }))))),
2907
- descText && (React.createElement("span", { className: "bianic-livesearch-desc bianic-text-input-desc whitespace-nowrap text-xs ".concat(descColor) }, descText))));
2908
+ descText && (React.createElement("span", { className: "bianic-livesearch-desc bianic-text-input-desc text-xs ".concat(descColor) }, descText))));
2908
2909
  }
2909
2910
  LiveSearch.defaultProps = {
2910
2911
  descText: '',
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { SearchVariant } from '../types';
3
+ export declare const isObjectWithLabel: (value: any) => boolean;
3
4
  export declare const getItemLabel: (value: any) => string;
4
5
  export declare const processDropdownChildren: (nodes: React.ReactNode, currentSearchTerm: string, includeAllIfNoSearch: boolean, searchVariant: SearchVariant | undefined, handleDropdownItemClick: (e: React.MouseEvent<HTMLDivElement>, value: any) => void) => React.ReactNode;
5
6
  export declare const processRenderedChildren: (children: React.ReactNode | undefined, searchTerm: string, searchVariant: SearchVariant, handleDropdownItemClick: (e: React.MouseEvent<HTMLDivElement>, value: any) => void) => {
@@ -1,3 +1,4 @@
1
+ import React, { ComponentPropsWithRef } from 'react';
1
2
  interface MenuContainerProps extends ComponentPropsWithRef<'div'> {
2
3
  isTopFlat?: boolean;
3
4
  children: React.ReactNode | undefined;
@@ -9,8 +10,8 @@ interface MenuContainerProps extends ComponentPropsWithRef<'div'> {
9
10
  onClickItem?: () => void;
10
11
  anchorRef?: React.RefObject<HTMLElement>;
11
12
  matchAnchorWidth?: undefined | 'min' | 'exact';
13
+ onContextMenu?: (event: React.MouseEvent<HTMLElement>) => void;
12
14
  }
13
- import React, { ComponentPropsWithRef } from 'react';
14
15
  declare const MenuContainer: {
15
16
  (props: MenuContainerProps): React.JSX.Element | null;
16
17
  defaultProps: {
package/dist/esm/index.js CHANGED
@@ -1987,9 +1987,9 @@ var usePopupPosition = function (anchorRef, popupRef, position) {
1987
1987
  };
1988
1988
 
1989
1989
  var MenuElement = forwardRef(function (_a, ref) {
1990
- var isTopFlat = _a.isTopFlat, children = _a.children, className = _a.className, zIndex = _a.zIndex, menuRef = _a.menuRef, onClose = _a.onClose, onClickItem = _a.onClickItem, style = _a.style, restProps = __rest(_a, ["isTopFlat", "children", "className", "zIndex", "menuRef", "onClose", "onClickItem", "style"]);
1990
+ var isTopFlat = _a.isTopFlat, children = _a.children, className = _a.className, zIndex = _a.zIndex, menuRef = _a.menuRef, onClose = _a.onClose, onClickItem = _a.onClickItem, style = _a.style, onContextMenu = _a.onContextMenu, restProps = __rest(_a, ["isTopFlat", "children", "className", "zIndex", "menuRef", "onClose", "onClickItem", "style", "onContextMenu"]);
1991
1991
  var radiusClass = "rounded-b-radius-sm ".concat(!isTopFlat && 'rounded-t-radius-sm');
1992
- return (React.createElement("div", __assign({ ref: menuRef, className: "w-fit bg-bia-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] ".concat(radiusClass, " ").concat(className), style: style }, restProps), Children.map(children, function (child) {
1992
+ return (React.createElement("div", __assign({ ref: menuRef, className: "w-fit bg-bia-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] ".concat(radiusClass, " ").concat(className), style: style, onContextMenu: onContextMenu }, restProps), Children.map(children, function (child) {
1993
1993
  return React.isValidElement(child)
1994
1994
  ? cloneElement(child, {
1995
1995
  onClose: function () { return onClose(); },
@@ -2000,7 +2000,7 @@ var MenuElement = forwardRef(function (_a, ref) {
2000
2000
  })));
2001
2001
  });
2002
2002
  var MenuContainer = function (props) {
2003
- var _a = props.isTopFlat, isTopFlat = _a === void 0 ? false : _a, children = props.children, _b = props.open, open = _b === void 0 ? true : _b, _c = props.onClose, onClose = _c === void 0 ? function () { } : _c, _d = props.className, className = _d === void 0 ? '' : _d, _e = props.isWithOverlay, isWithOverlay = _e === void 0 ? true : _e, _f = props.zIndex, zIndex = _f === void 0 ? 100 : _f, _g = props.onClickItem, onClickItem = _g === void 0 ? function () { } : _g, anchorRef = props.anchorRef, matchAnchorWidth = props.matchAnchorWidth, restProps = __rest(props, ["isTopFlat", "children", "open", "onClose", "className", "isWithOverlay", "zIndex", "onClickItem", "anchorRef", "matchAnchorWidth"]);
2003
+ var _a = props.isTopFlat, isTopFlat = _a === void 0 ? false : _a, children = props.children, _b = props.open, open = _b === void 0 ? true : _b, _c = props.onClose, onClose = _c === void 0 ? function () { } : _c, _d = props.className, className = _d === void 0 ? '' : _d, _e = props.isWithOverlay, isWithOverlay = _e === void 0 ? true : _e, _f = props.zIndex, zIndex = _f === void 0 ? 100 : _f, _g = props.onClickItem, onClickItem = _g === void 0 ? function () { } : _g, anchorRef = props.anchorRef, matchAnchorWidth = props.matchAnchorWidth, onContextMenu = props.onContextMenu, restProps = __rest(props, ["isTopFlat", "children", "open", "onClose", "className", "isWithOverlay", "zIndex", "onClickItem", "anchorRef", "matchAnchorWidth", "onContextMenu"]);
2004
2004
  if (!open)
2005
2005
  return null;
2006
2006
  var MenuContainerRef = useRef(null);
@@ -2028,9 +2028,13 @@ var MenuContainer = function (props) {
2028
2028
  }
2029
2029
  return __assign(__assign({ zIndex: zIndex + 10 }, widthStyle), positionStyle);
2030
2030
  }, [positionStyle]);
2031
- var menuElement = (React.createElement(MenuElement, __assign({ isTopFlat: isTopFlat, children: children, className: className, zIndex: zIndex, menuRef: MenuContainerRef, onClose: onClose, onClickItem: onClickItem, style: newStyle }, restProps)));
2031
+ var menuElement = (React.createElement(MenuElement, __assign({ isTopFlat: isTopFlat, children: children, className: className, zIndex: zIndex, menuRef: MenuContainerRef, onClose: onClose, onClickItem: onClickItem, style: newStyle, onContextMenu: function (e) {
2032
+ return onContextMenu ? onContextMenu(e) : e.preventDefault();
2033
+ } }, restProps)));
2032
2034
  return (React.createElement(React.Fragment, null,
2033
- isWithOverlay && (React.createElement("div", { className: "bianic-menu-overlay fixed left-0 top-0 z-0 h-screen w-screen", onClick: function () { return onClose(); }, style: { zIndex: zIndex } })),
2035
+ isWithOverlay && (React.createElement("div", { className: "bianic-menu-overlay fixed left-0 top-0 z-0 h-screen w-screen", onClick: function () { return onClose(); }, style: { zIndex: zIndex }, onContextMenu: function (e) {
2036
+ return onContextMenu ? onContextMenu(e) : e.preventDefault();
2037
+ } })),
2034
2038
  (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)
2035
2039
  ? createPortal(menuElement, document.body)
2036
2040
  : menuElement));
@@ -2295,7 +2299,7 @@ var TextInput = forwardRef(function (_a, ref) {
2295
2299
  return (React.createElement("div", { className: "bianic-text-input-container bianic-fgc-container group/form flex w-full flex-col gap-y-2 text-bia-black" },
2296
2300
  label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
2297
2301
  React.createElement("div", { className: "relative w-full ".concat(disabledClass) },
2298
- React.createElement("input", __assign({ className: "bianic-text-input bianic-fgc-target w-full rounded read-only:pointer-events-none read-only:border-bia-grey-light-50 hover:rounded-b-none focus:rounded-b-none focus-visible:outline-none disabled:cursor-not-allowed disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-grey-active ".concat(extendedInputClassName), disabled: disabled, id: id, placeholder: placeholder || label, readOnly: readOnly, required: required, type: typeVariant, value: value, onChange: function (e) { return onChange(e); }, maxLength: maxLength, autoComplete: autoComplete, ref: ref }, props)),
2302
+ React.createElement("input", __assign({ className: "bianic-text-input bianic-fgc-target w-full rounded read-only:pointer-events-none read-only:border-bia-grey-light-50 hover:rounded-b-none focus:rounded-b-none focus-visible:outline-none disabled:cursor-not-allowed disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-grey-active ".concat(extendedInputClassName), disabled: disabled, id: id, placeholder: placeholder || label, readOnly: readOnly, required: required, type: typeVariant, value: value, onChange: function (e) { return onChange(e); }, maxLength: maxLength, autoComplete: autoComplete, ref: ref, style: { paddingRight: "".concat(10 + Number(iconSize), "px") } }, props)),
2299
2303
  React.createElement("div", { className: "absolute inset-y-0 flex items-center pl-3 ".concat(actionElement ? '' : iconStyle, " ").concat(iconPosition, " ").concat(iconSizing) }, iconElement)),
2300
2304
  (descText || maxLength) && (React.createElement("div", { className: "bianic-text-input-desc flex justify-between gap-1 whitespace-nowrap text-xs ".concat(descColor) },
2301
2305
  React.createElement("span", null, descText),
@@ -2567,7 +2571,7 @@ function SelectInput(_a) {
2567
2571
  }
2568
2572
  return child;
2569
2573
  })))),
2570
- descText && (React.createElement("span", { className: "bianic-livesearch-desc bianic-text-input-desc whitespace-nowrap text-xs ".concat(descColor) }, descText))));
2574
+ descText && (React.createElement("span", { className: "bianic-livesearch-desc bianic-text-input-desc text-xs ".concat(descColor) }, descText))));
2571
2575
  }
2572
2576
  SelectInput.defaultProps = {
2573
2577
  descText: '',
@@ -2725,11 +2729,7 @@ function DropdownItem(_a) {
2725
2729
  : 'right-0 translate-x-full';
2726
2730
  var currentZIndex = zIndex + 10;
2727
2731
  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); } },
2728
- 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: {
2729
- zIndex: isHovered ? currentZIndex : currentZIndex + 15,
2730
- }, onClick: function (e) {
2731
- onClickItem(e, value);
2732
- }, onKeyDown: function () { }, disabled: disabled, type: "button" }, props),
2732
+ 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: { zIndex: currentZIndex + 15 }, onClick: function (e) { return onClickItem(e, value); }, onKeyDown: function () { }, disabled: disabled, type: "button" }, props),
2733
2733
  content,
2734
2734
  React.createElement("div", { className: "ml-auto flex items-center" }, children && (React.createElement(TbChevronRight, { className: "ml-[10px] text-bia-coolgrey", size: chevronSize })))),
2735
2735
  children && (React.createElement(DropdownContNoAnchor, { className: "absolute top-0 bg-primary-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] group-first/main:top-[6px] ".concat(translateClass), onClose: onClose, open: isHovered, onClickItem: function (e, value) { return onClickItem(e, value); }, size: size, ref: DropdownContRef, zIndex: currentZIndex + 10 }, children))));
@@ -2759,11 +2759,12 @@ var filterOptions = function (options, searchTerm) {
2759
2759
  });
2760
2760
  };
2761
2761
 
2762
+ var isObjectWithLabel = function (value) {
2763
+ return typeof value === 'object' && value !== null && 'label' in value;
2764
+ };
2762
2765
  var getItemLabel = function (value) {
2763
2766
  var _a;
2764
- return typeof value === 'object' && value !== null && 'label' in value
2765
- ? (_a = value.label) !== null && _a !== void 0 ? _a : ''
2766
- : String(value !== null && value !== void 0 ? value : '');
2767
+ return isObjectWithLabel(value) ? (_a = value.label) !== null && _a !== void 0 ? _a : '' : String(value !== null && value !== void 0 ? value : '');
2767
2768
  };
2768
2769
  var processDropdownChildren = function (nodes, currentSearchTerm, includeAllIfNoSearch, searchVariant, handleDropdownItemClick) {
2769
2770
  if (searchVariant === void 0) { searchVariant = 'include'; }
@@ -2867,7 +2868,7 @@ function LiveSearch(_a) {
2867
2868
  }), isOpen = _m.isOpen, setIsOpen = _m.setIsOpen, searchTerm = _m.searchTerm, handleInputChange = _m.handleInputChange, handleDropdownItemClick = _m.handleDropdownItemClick;
2868
2869
  var _o = sizeConfig$6[size], iconClass = _o.iconClass, iconSize = _o.iconSize, inputClass = _o.inputClass;
2869
2870
  var _p = dropContProps || {}, dropContClassName = _p.className; _p.onClickItem; _p.anchorRef; var restDropContProps = __rest(_p, ["className", "onClickItem", "anchorRef"]);
2870
- var isValueExist = value && value.label !== undefined && value.label !== '';
2871
+ var isSearchTermExist = searchTerm && searchTerm !== '';
2871
2872
  var descColor = 'text-primary-cool';
2872
2873
  var isExistValidation = isValid !== null && isValid !== undefined;
2873
2874
  if (!disabled && isExistValidation && isValid)
@@ -2880,13 +2881,13 @@ function LiveSearch(_a) {
2880
2881
  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" },
2881
2882
  label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
2882
2883
  React.createElement("div", { className: "group relative w-full ".concat(disabledClass) },
2883
- 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), onClick: function () { return setIsOpen(!isOpen); }, value: searchTerm, required: required, disabled: disabled, id: id, placeholder: placeholder, ref: inputRef, onChange: function (e) {
2884
+ React.createElement("input", { className: "bianic-livesearch-input bianic-fgc-target field peer w-full rounded border border-bia-grey-dark-10 bg-primary-white text-bia-black read-only:pointer-events-none read-only:border-bia-grey-light-50 focus-visible:outline-none enabled:hover:rounded-b-none enabled:hover:border-b-bia-blue enabled:focus:rounded-b-none enabled:focus:border-b-bia-blue disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-80 disabled:text-bia-coolgrey ".concat(inputClass), style: { paddingRight: "".concat(10 + Number(iconSize), "px") }, onClick: function () { return setIsOpen(!isOpen); }, value: searchTerm, required: required, disabled: disabled, id: id, placeholder: placeholder, ref: inputRef, onChange: function (e) {
2884
2885
  onChangeText(e);
2885
2886
  handleInputChange(e);
2886
2887
  }, type: "text", readOnly: readOnly, autoComplete: autoComplete }),
2887
2888
  React.createElement("div", { className: "absolute inset-y-0 flex items-center pl-3 ".concat(iconClass) },
2888
- !isValueExist && (React.createElement(TbZoom, { className: "text-primary-black", style: { fontSize: iconSize } })),
2889
- isValueExist && (React.createElement("button", { onClick: function () { return setValue({ id: null, label: '' }); }, className: "flex h-full w-full items-center" },
2889
+ !isSearchTermExist && (React.createElement(TbZoom, { className: "text-primary-black", style: { fontSize: iconSize } })),
2890
+ isSearchTermExist && (React.createElement("button", { onClick: function () { return setValue({ id: null, label: '' }); }, className: "flex h-full w-full items-center disabled:cursor-not-allowed", disabled: disabled },
2890
2891
  React.createElement(TbX, { className: "text-primary-black", style: { fontSize: iconSize } })))),
2891
2892
  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) {
2892
2893
  var isSelected = value && value.id && option.id === value.id;
@@ -2902,7 +2903,7 @@ function LiveSearch(_a) {
2902
2903
  ? renderedChildren
2903
2904
  : // If no results and searchTerm is present
2904
2905
  searchTerm.length > 0 && (React.createElement(DropdownItem, { content: React.createElement("div", { className: "px-4 py-2 text-gray-500" }, "Tidak ada hasil ditemukan.") }))))),
2905
- descText && (React.createElement("span", { className: "bianic-livesearch-desc bianic-text-input-desc whitespace-nowrap text-xs ".concat(descColor) }, descText))));
2906
+ descText && (React.createElement("span", { className: "bianic-livesearch-desc bianic-text-input-desc text-xs ".concat(descColor) }, descText))));
2906
2907
  }
2907
2908
  LiveSearch.defaultProps = {
2908
2909
  descText: '',
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { SearchVariant } from '../types';
3
+ export declare const isObjectWithLabel: (value: any) => boolean;
3
4
  export declare const getItemLabel: (value: any) => string;
4
5
  export declare const processDropdownChildren: (nodes: React.ReactNode, currentSearchTerm: string, includeAllIfNoSearch: boolean, searchVariant: SearchVariant | undefined, handleDropdownItemClick: (e: React.MouseEvent<HTMLDivElement>, value: any) => void) => React.ReactNode;
5
6
  export declare const processRenderedChildren: (children: React.ReactNode | undefined, searchTerm: string, searchVariant: SearchVariant, handleDropdownItemClick: (e: React.MouseEvent<HTMLDivElement>, value: any) => void) => {
@@ -1,3 +1,4 @@
1
+ import React, { ComponentPropsWithRef } from 'react';
1
2
  interface MenuContainerProps extends ComponentPropsWithRef<'div'> {
2
3
  isTopFlat?: boolean;
3
4
  children: React.ReactNode | undefined;
@@ -9,8 +10,8 @@ interface MenuContainerProps extends ComponentPropsWithRef<'div'> {
9
10
  onClickItem?: () => void;
10
11
  anchorRef?: React.RefObject<HTMLElement>;
11
12
  matchAnchorWidth?: undefined | 'min' | 'exact';
13
+ onContextMenu?: (event: React.MouseEvent<HTMLElement>) => void;
12
14
  }
13
- import React, { ComponentPropsWithRef } from 'react';
14
15
  declare const MenuContainer: {
15
16
  (props: MenuContainerProps): React.JSX.Element | null;
16
17
  defaultProps: {
package/dist/index.d.ts CHANGED
@@ -197,8 +197,8 @@ interface MenuContainerProps extends ComponentPropsWithRef<'div'> {
197
197
  onClickItem?: () => void;
198
198
  anchorRef?: React$1.RefObject<HTMLElement>;
199
199
  matchAnchorWidth?: undefined | 'min' | 'exact';
200
+ onContextMenu?: (event: React$1.MouseEvent<HTMLElement>) => void;
200
201
  }
201
-
202
202
  declare const MenuContainer: {
203
203
  (props: MenuContainerProps): React$1.JSX.Element | null;
204
204
  defaultProps: {
package/package.json CHANGED
@@ -3,12 +3,8 @@
3
3
  "publishConfig": {
4
4
  "@biaenergi:registry": "https://gitlab.com/api/v4/projects/50905269/packages/npm/"
5
5
  },
6
- "version": "2.3.1",
6
+ "version": "2.4.0",
7
7
  "description": "Design Language System develop by BIAENERGI",
8
- "repository": {
9
- "type": "git",
10
- "url": "git@github.com:bia-energi/bianic-2.0.git"
11
- },
12
8
  "scripts": {
13
9
  "rollup": "rollup -c",
14
10
  "storybook": "storybook dev -p 6006",
@@ -18,8 +14,8 @@
18
14
  "lint:fix": "npx eslint src/components --fix",
19
15
  "prepare": "husky install",
20
16
  "release": "standard-version",
21
- "full-release": "npm run release && git push --follow-tags origin development && npm publish",
22
- "release:beta": "npm run release -- --prerelease beta && git push --follow-tags origin development && npm publish --tag beta"
17
+ "full-release": "npm run release && git push --follow-tags origin development-temporary && npm run rollup && npm publish",
18
+ "release:beta": "npm run release -- --prerelease beta && git push --follow-tags origin development-temporary && npm publish --tag beta"
23
19
  },
24
20
  "standard-version": {
25
21
  "types": [