bianic-ui 1.7.3-alpha.2 → 1.7.4-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/cjs/index.js +121 -31
  2. package/dist/cjs/lib.css +1 -1
  3. package/dist/cjs/types/components/FileTree/index.d.ts +6 -2
  4. package/dist/cjs/types/components/Menu/MenuContainer.d.ts +2 -1
  5. package/dist/cjs/types/components/Table/TableCell/configs.d.ts +1 -6
  6. package/dist/cjs/types/components/Table/TableCell/index.d.ts +1 -3
  7. package/dist/cjs/types/components/Toaster/Toaster.d.ts +11 -0
  8. package/dist/cjs/types/components/Toaster/configs.d.ts +7 -0
  9. package/dist/cjs/types/components/Toaster/index.d.ts +1 -0
  10. package/dist/cjs/types/components/index.d.ts +2 -0
  11. package/dist/cjs/types/stories/FileTree/{FileTree.stories.d.ts → FIleTree.stories.d.ts} +1 -1
  12. package/dist/cjs/types/stories/FileTree/FileTreeContextMenu.stories.d.ts +14 -0
  13. package/dist/cjs/types/stories/Toaster/Toaster.stories.d.ts +16 -0
  14. package/dist/cjs/types/stories/Window/Window.stories.d.ts +2 -1
  15. package/dist/cjs/types/utility/helper.d.ts +1 -1
  16. package/dist/esm/index.js +121 -33
  17. package/dist/esm/lib.css +1 -1
  18. package/dist/esm/types/components/FileTree/index.d.ts +6 -2
  19. package/dist/esm/types/components/Menu/MenuContainer.d.ts +2 -1
  20. package/dist/esm/types/components/Table/TableCell/configs.d.ts +1 -6
  21. package/dist/esm/types/components/Table/TableCell/index.d.ts +1 -3
  22. package/dist/esm/types/components/Toaster/Toaster.d.ts +11 -0
  23. package/dist/esm/types/components/Toaster/configs.d.ts +7 -0
  24. package/dist/esm/types/components/Toaster/index.d.ts +1 -0
  25. package/dist/esm/types/components/index.d.ts +2 -0
  26. package/dist/esm/types/stories/FileTree/{FileTree.stories.d.ts → FIleTree.stories.d.ts} +1 -1
  27. package/dist/esm/types/stories/FileTree/FileTreeContextMenu.stories.d.ts +14 -0
  28. package/dist/esm/types/stories/Toaster/Toaster.stories.d.ts +16 -0
  29. package/dist/esm/types/stories/Window/Window.stories.d.ts +2 -1
  30. package/dist/esm/types/utility/helper.d.ts +1 -1
  31. package/dist/index.d.ts +29 -7
  32. package/package.json +1 -1
package/dist/cjs/index.js CHANGED
@@ -263,7 +263,8 @@ var childrenElement = function (element) {
263
263
  var validUnion = function (value, union) {
264
264
  return union.includes(value) ? value : union[0];
265
265
  };
266
- var useDetectOutsideClick = function (ref, initialState) {
266
+ var useDetectOutsideClick = function (ref, initialState, event) {
267
+ if (event === void 0) { event = 'click'; }
267
268
  var _a = React.useState(initialState), isActive = _a[0], setIsActive = _a[1];
268
269
  React.useEffect(function () {
269
270
  var pageClickEvent = function (event) {
@@ -274,8 +275,8 @@ var useDetectOutsideClick = function (ref, initialState) {
274
275
  };
275
276
  // If the item is active (ie open) then listen for clicks
276
277
  if (isActive)
277
- window.addEventListener('click', pageClickEvent);
278
- return function () { return window.removeEventListener('click', pageClickEvent); };
278
+ window.addEventListener(event, pageClickEvent);
279
+ return function () { return window.removeEventListener(event, pageClickEvent); };
279
280
  }, [isActive, ref]);
280
281
  return [isActive, setIsActive];
281
282
  };
@@ -1647,23 +1648,45 @@ Divider.defaultProps = {
1647
1648
  };
1648
1649
 
1649
1650
  var FileTree = function (_a) {
1650
- var data = _a.data, color = _a.color;
1651
- return (React.createElement("div", { className: "file-tree" }, data.map(function (_a, index) {
1652
- var label = _a.label, nodes = _a.nodes, props = __rest(_a, ["label", "nodes"]);
1653
- return (React.createElement(TreeItem, __assign({ label: label, nodes: nodes, key: index, color: color }, props)));
1654
- })));
1651
+ var data = _a.data, color = _a.color, contextMenu = _a.contextMenu, onMouseDown = _a.onMouseDown;
1652
+ var popupRef = React.useRef(null); // Ref untuk div utama
1653
+ var _b = useDetectOutsideClick(popupRef, false), isOpenContMenu = _b[0], setIsOpenContMenu = _b[1];
1654
+ var _c = React.useState({ x: 0, y: 0 }), contMenuPosition = _c[0], setContMenuPosition = _c[1];
1655
+ var menuStyle = {
1656
+ position: 'absolute',
1657
+ top: "".concat(contMenuPosition.y, "px"),
1658
+ left: "".concat(contMenuPosition.x, "px"),
1659
+ // Pastikan z-index cukup tinggi agar muncul di atas elemen lain
1660
+ zIndex: 1000,
1661
+ };
1662
+ var handleRightClick = function (event) {
1663
+ setIsOpenContMenu(true);
1664
+ setContMenuPosition({ x: event.clientX, y: event.clientY });
1665
+ };
1666
+ return (React.createElement("div", { className: "file-tree" },
1667
+ data.map(function (_a, index) {
1668
+ var label = _a.label, nodes = _a.nodes, props = __rest(_a, ["label", "nodes"]);
1669
+ return (React.createElement(TreeItem, __assign({ label: label, nodes: nodes, key: index, color: color, handleRightClick: handleRightClick, onMouseDownTreeItem: onMouseDown }, props)));
1670
+ }),
1671
+ isOpenContMenu && (React.createElement("div", { style: menuStyle, ref: popupRef, className: "bianic-filetree-contextmenu absolute z-10" }, React.isValidElement(contextMenu)
1672
+ ? // Kirimkan handleItemClick sebagai props onClick ke setiap MenuItem
1673
+ React.cloneElement(contextMenu, { isWithOverlay: false })
1674
+ : contextMenu))));
1655
1675
  };
1656
1676
  var TreeItem = function (_a) {
1657
- var label = _a.label, nodes = _a.nodes, color = _a.color, props = __rest(_a, ["label", "nodes", "color"]);
1677
+ var label = _a.label, nodes = _a.nodes, color = _a.color, handleRightClick = _a.handleRightClick, onMouseDownTreeItem = _a.onMouseDownTreeItem, props = __rest(_a, ["label", "nodes", "color", "handleRightClick", "onMouseDownTreeItem"]);
1678
+ var treeRef = React.useRef(null);
1658
1679
  var _b = React.useState(false), isExpand = _b[0], setIsExpand = _b[1];
1659
1680
  var _c = React.useState(false), isFocused = _c[0], setIsFocused = _c[1];
1681
+ var _d = useDetectOutsideClick(treeRef, false, 'mousedown'), isClickRight = _d[0], setIsClickRight = _d[1];
1660
1682
  var focusedIconColor = color
1661
1683
  ? "text-bia-".concat(color)
1662
1684
  : 'text-bia-coolgrey-light-50';
1663
- var foucusedBgColor = color ? "bg-bia-".concat(color) : 'bg-bia-coolgrey-light-50';
1664
- var textClass = "flex items-center rounded-radius-sm px-[2px] cursor-pointer hover:bg-bia-coolgrey-light-90 focus:pointer-events-none ".concat(isFocused && foucusedBgColor);
1685
+ var focusedBgColor = color ? "bg-bia-".concat(color) : 'bg-bia-coolgrey-light-50';
1686
+ var clickRightClass = 'outline outline-[3px] outline-bia-blue-light-50';
1687
+ var textClass = "flex items-center rounded-radius-sm px-[2px] cursor-pointer hover:bg-bia-coolgrey-light-90 focus:pointer-events-none ".concat(isFocused && focusedBgColor, " ").concat(isClickRight && clickRightClass);
1665
1688
  return (React.createElement("div", { className: "bianic-tree-item" },
1666
- React.createElement("div", { className: "justify-left group flex items-center" },
1689
+ React.createElement("div", { className: "justify-left group flex items-center", ref: treeRef },
1667
1690
  nodes && nodes.length > 0 ? (React.createElement("button", { className: "cursor-pointer", onClick: function (e) {
1668
1691
  setIsExpand(function (prev) { return !prev; });
1669
1692
  } },
@@ -1675,24 +1698,32 @@ var TreeItem = function (_a) {
1675
1698
  }, onBlur: function (e) {
1676
1699
  var _a;
1677
1700
  setIsFocused(false);
1701
+ setIsClickRight(false); // Reset isClickRight saat blur
1678
1702
  (_a = props === null || props === void 0 ? void 0 : props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e);
1679
- }, className: textClass }, props),
1680
- React.createElement(Text, { variant: "small-text" },
1681
- " ",
1682
- label,
1683
- " "))),
1703
+ }, className: textClass, onMouseDown: function (e) {
1704
+ if (e.button === 2) {
1705
+ // 2 = tombol kanan mouse
1706
+ e.preventDefault(); // Blokir default lebih awal
1707
+ }
1708
+ onMouseDownTreeItem === null || onMouseDownTreeItem === void 0 ? void 0 : onMouseDownTreeItem(e, __assign({ label: label, nodes: nodes }, props));
1709
+ }, onContextMenu: function (e) {
1710
+ e.preventDefault();
1711
+ setIsClickRight(true);
1712
+ handleRightClick === null || handleRightClick === void 0 ? void 0 : handleRightClick(e);
1713
+ } }, props),
1714
+ React.createElement(Text, { variant: "small-text" }, label))),
1684
1715
  isExpand && nodes && nodes.length > 0 && (React.createElement("div", { className: "ml-4" }, nodes.map(function (_a, index) {
1685
- var label = _a.label, nodes = _a.nodes;
1686
- return (React.createElement(TreeItem, { label: label, nodes: nodes, key: index, color: color }));
1716
+ var label = _a.label, nodes = _a.nodes, props = __rest(_a, ["label", "nodes"]);
1717
+ return (React.createElement(TreeItem, __assign({ label: label, nodes: nodes, key: index, color: color, handleRightClick: handleRightClick, onMouseDownTreeItem: onMouseDownTreeItem }, props)));
1687
1718
  })))));
1688
1719
  };
1689
1720
 
1690
1721
  function MenuContainer(_a) {
1691
- var _b = _a.isTopFlat, isTopFlat = _b === void 0 ? false : _b, children = _a.children, open = _a.open, _c = _a.onClose, onClose = _c === void 0 ? function () { } : _c, _d = _a.className, className = _d === void 0 ? '' : _d;
1722
+ var _b = _a.isTopFlat, isTopFlat = _b === void 0 ? false : _b, children = _a.children, _c = _a.open, open = _c === void 0 ? true : _c, _d = _a.onClose, onClose = _d === void 0 ? function () { } : _d, _e = _a.className, className = _e === void 0 ? '' : _e, _f = _a.isWithOverlay, isWithOverlay = _f === void 0 ? true : _f;
1692
1723
  var radiusClass = "rounded-b-radius-sm ".concat(!isTopFlat && 'rounded-t-radius-sm');
1693
1724
  return (open && (React.createElement(React.Fragment, null,
1694
- React.createElement("div", { className: "fixed left-0 top-0 z-0 h-screen w-screen", onClick: function () { return onClose(); } }),
1695
- React.createElement("div", { className: "w-fit shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] bg-bia-white ".concat(radiusClass, " ").concat(className) }, React.Children.map(children, function (child) {
1725
+ isWithOverlay && (React.createElement("div", { className: "bianic-menu-overlay fixed left-0 top-0 z-0 h-screen w-screen", onClick: function () { return onClose(); } })),
1726
+ React.createElement("div", { className: "w-fit bg-bia-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] ".concat(radiusClass, " ").concat(className) }, React.Children.map(children, function (child) {
1696
1727
  return React.isValidElement(child)
1697
1728
  ? // Kirimkan handleItemClick sebagai props onClick ke setiap MenuItem
1698
1729
  React.cloneElement(child, { onClose: function () { return onClose(); } })
@@ -1711,7 +1742,7 @@ function MenuItem(_a) {
1711
1742
  onClick(e);
1712
1743
  }, onKeyDown: function () { } }, props),
1713
1744
  isChecked !== undefined && (React.createElement("div", { className: "mr-[5px] aspect-square w-[14px]" }, isChecked && React.createElement(TbCheck, { className: "text-primary-black", size: 14 }))),
1714
- React.createElement("span", { className: "whitespace-nowrap font-arial text-[11px]" }, label),
1745
+ React.createElement("span", { className: "whitespace-nowrap font-arial text-[11px] text-bia-black" }, label),
1715
1746
  React.createElement("div", { className: "ml-auto flex items-center" },
1716
1747
  children && (React.createElement(TbChevronRight, { className: "ml-[10px] text-bia-coolgrey" })),
1717
1748
  children === undefined && caption && (React.createElement("span", { className: "ml-[30px] whitespace-nowrap text-[11px] text-bia-coolgrey" }, caption)))),
@@ -2914,11 +2945,6 @@ var TabMenu = function (_a) {
2914
2945
  React.createElement(TbX, { className: "rounded-radius-sm ".concat(usedActionButtonConfig), size: 14 })))));
2915
2946
  };
2916
2947
 
2917
- var alignConfig = {
2918
- center: 'justify-center',
2919
- right: 'justify-end',
2920
- left: 'justify-start',
2921
- };
2922
2948
  var sizeConfig$1 = {
2923
2949
  md: 'px-2.5 py-[9px]',
2924
2950
  sm: 'px-2.5 py-[7px]',
@@ -2936,19 +2962,18 @@ var headTextConfig = {
2936
2962
  };
2937
2963
 
2938
2964
  function TableCell(_a) {
2939
- var _b = _a.variant, variant = _b === void 0 ? 'body' : _b, _c = _a.alignment, alignment = _c === void 0 ? 'left' : _c, className = _a.className, children = _a.children, _d = _a.size, size = _d === void 0 ? 'md' : _d, _e = _a.lined, lined = _e === void 0 ? false : _e, _f = _a.bgColor, bgColor = _f === void 0 ? '' : _f, props = __rest(_a, ["variant", "alignment", "className", "children", "size", "lined", "bgColor"]);
2965
+ var _b = _a.variant, variant = _b === void 0 ? 'body' : _b, className = _a.className, children = _a.children, _c = _a.size, size = _c === void 0 ? 'md' : _c, _d = _a.lined, lined = _d === void 0 ? false : _d, _e = _a.bgColor, bgColor = _e === void 0 ? '' : _e, props = __rest(_a, ["variant", "className", "children", "size", "lined", "bgColor"]);
2940
2966
  var bottomLined = lined ? 'border-b border-bia-grey' : '';
2941
2967
  var bgColorClass = "bg-bia-".concat(bgColor);
2942
2968
  var isHead = variant === 'head';
2943
2969
  var textConfig = isHead ? headTextConfig[size] : bodyTextConfig[size];
2944
- var columnClass = "p-0 ".concat(sizeConfig$1[size], " ").concat(bottomLined, " ").concat(bgColorClass, " ").concat(alignConfig[alignment], " ").concat(textConfig, " ").concat(className);
2970
+ var columnClass = "p-0 ".concat(sizeConfig$1[size], " ").concat(bottomLined, " ").concat(bgColorClass, " ").concat(textConfig, " ").concat(className);
2945
2971
  if (variant === 'head') {
2946
2972
  return (React.createElement("th", __assign({ className: "bianic-table-cell table-head bg-bia-grey-light-80 ".concat(columnClass) }, props), children));
2947
2973
  }
2948
2974
  return (React.createElement("td", __assign({ className: "bianic-table-cell table-col ".concat(columnClass) }, props), children));
2949
2975
  }
2950
2976
  TableCell.defaultProps = {
2951
- alignment: 'left',
2952
2977
  lined: false,
2953
2978
  size: 'md',
2954
2979
  variant: 'body',
@@ -3190,6 +3215,69 @@ Tooltip.defaultProps = {
3190
3215
  };
3191
3216
  Tooltip.defaultProps = {};
3192
3217
 
3218
+ var colorConfigs = {
3219
+ default: 'bg-bia-black',
3220
+ info: 'bg-bia-teal',
3221
+ success: 'bg-bia-green',
3222
+ danger: 'bg-bia-red',
3223
+ warning: 'bg-bia-orange',
3224
+ };
3225
+
3226
+ function Toaster(_a) {
3227
+ var children = _a.children, title = _a.title, icon = _a.icon, onClose = _a.onClose, _b = _a.variant, variant = _b === void 0 ? 'default' : _b; _a.position;
3228
+ // Default styles for the toaster based on variant
3229
+ var colorStyles = "".concat(colorConfigs[variant], " text-bia-white");
3230
+ // Logic for content alignment based on `isHeaderShow`
3231
+ var content = title ? (React.createElement("div", { className: "bianic-content-area flex flex-col gap-[5px]" },
3232
+ React.createElement("div", { className: "bianic-toaster-header-area flex flex-row items-center gap-[5px]" },
3233
+ icon && React.createElement("div", { className: "bianic-toaster-icon-area" }, icon),
3234
+ React.createElement("div", { className: "bianic-toaster-title-area text-[14px] font-semibold leading-[21px]" }, title)),
3235
+ React.createElement("div", { className: "bianic-toaster-description-area text-[12px] font-normal leading-[134%]" }, children))) : (React.createElement("div", { className: "bianic-toaster-content-area flex flex-row gap-[5px]" },
3236
+ icon && React.createElement("div", { className: "bianic-toaster-icon-area" }, icon),
3237
+ React.createElement("div", { className: "bianic-toaster-description-area text-[12px] font-normal leading-[134%]" }, children)));
3238
+ return (React.createElement("div", { className: "bianic-toaster flex max-w-[300px] flex-row gap-[5px] rounded-[5px] py-[10px] shadow-[0px_3px_20px_0px_rgba(0,0,0,0.10)] ".concat(colorStyles) },
3239
+ React.createElement("span", { className: "mr-[10px] flex min-w-[3px] rounded-r-[10px] bg-bia-white/50" }),
3240
+ content,
3241
+ React.createElement("div", { className: "flex items-start pr-[11px] pt-[1px]" },
3242
+ React.createElement("button", { onClick: onClose, className: "rounded-[3px] hover:bg-bia-white/20 focus-visible:outline focus-visible:outline-[3px] focus-visible:outline-bia-white/50 active:bg-black/10" },
3243
+ React.createElement(TbX, { size: 14 })))));
3244
+ }
3245
+
3246
+ function Window(_a) {
3247
+ var _b = _a.size, size = _b === void 0 ? 'sm' : _b, title = _a.title, open = _a.open; _a.zIndex; var onClose = _a.onClose, rest = __rest(_a, ["size", "title", "open", "zIndex", "onClose"]);
3248
+ var windowSize;
3249
+ // sizing logic
3250
+ switch (size) {
3251
+ case 'sm':
3252
+ windowSize = 'w-[300px]';
3253
+ break;
3254
+ case 'md':
3255
+ windowSize = 'w-[540px]';
3256
+ break;
3257
+ case 'lg':
3258
+ windowSize = 'w-[800px]';
3259
+ break;
3260
+ case 'xl':
3261
+ windowSize = 'w-[1140px]';
3262
+ break;
3263
+ default:
3264
+ windowSize = 'w-[540px]';
3265
+ }
3266
+ if (open) {
3267
+ return (
3268
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
3269
+ // <Draggable handle=".drag-handle" enableUserSelectHack={false}>
3270
+ React.createElement("div", { className: "bianic-window drag-handle flex flex-col gap-[20px] rounded-[5px] bg-white ".concat(windowSize) },
3271
+ React.createElement("div", { className: "bianic-window-header flex cursor-move justify-between px-[20px] pt-[20px]" },
3272
+ React.createElement("div", { className: " text-wrap text-left font-humnst777 text-[18px] font-bold leading-[21.85px] text-primary-black" }, title),
3273
+ React.createElement(Button, { variant: "subtle", radius: "full-rounded", iconLeft: React.createElement(TbX, null), size: "tn", onClick: function () { return onClose(); } })),
3274
+ React.createElement("div", { className: "bianic-window-content flex w-full flex-col items-start gap-[20px] px-[20px] pb-[20px] text-primary-black" }, rest.children))
3275
+ // </Draggable>
3276
+ );
3277
+ }
3278
+ return null;
3279
+ }
3280
+
3193
3281
  exports.Accordions = Accordions;
3194
3282
  exports.Alert = Alert;
3195
3283
  exports.Avatar = Avatar;
@@ -3255,5 +3343,7 @@ exports.TagLabel = TagLabel;
3255
3343
  exports.Text = Text;
3256
3344
  exports.TextArea = TextArea;
3257
3345
  exports.TextInput = TextInput;
3346
+ exports.Toaster = Toaster;
3258
3347
  exports.Toggle = Toggle;
3259
3348
  exports.Tooltip = Tooltip;
3349
+ exports.Window = Window;