bianic-ui 2.13.0 → 2.14.0-alpha.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
@@ -1665,7 +1665,7 @@ var ContextualButton = React.forwardRef(function (_a, ref) {
1665
1665
  : 'text-primary-white'
1666
1666
  : textColorConfig[variant];
1667
1667
  var stateColor = stateColorConfig[isSelected ? 'selected' : 'default'];
1668
- return (React.createElement("button", __assign({ ref: ref, className: "bianic-contextual-button box-border flex min-h-[22px] flex-row items-center rounded-radius-sm border border-transparent p-[1px] outline-none ".concat(stateColor, " ").concat(textColor) }, props, { disabled: disabled }),
1668
+ return (React.createElement("button", __assign({ ref: ref, className: "bianic-contextual-button box-border flex min-h-[23px] flex-row items-center rounded-radius-sm border border-transparent p-[1px] outline-none ".concat(stateColor, " ").concat(textColor) }, props, { disabled: disabled }),
1669
1669
  icon,
1670
1670
  label && (React.createElement("div", { className: "label flex max-h-[46px] items-center gap-x-0.5 px-[5px] text-[12px] leading-none" },
1671
1671
  React.createElement("span", null, label),
@@ -3349,11 +3349,11 @@ TagLabel.defaultProps = {
3349
3349
  };
3350
3350
 
3351
3351
  var TagLabelInputInner = function (_a, ref) {
3352
- var children = _a.children, className = _a.className, description = _a.description, _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.dropContProps, dropContProps = _c === void 0 ? {} : _c, customId = _a.id, _d = _a.isValid, isValid = _d === void 0 ? null : _d, _e = _a.label, label = _e === void 0 ? '' : _e, onBlur = _a.onBlur, onChange = _a.onChange, onChangeText = _a.onChangeText, onFocus = _a.onFocus, placeholder = _a.placeholder, _f = _a.readOnly, readOnly = _f === void 0 ? false : _f, _g = _a.required, required = _g === void 0 ? false : _g, _h = _a.size, size = _h === void 0 ? 'md' : _h, _j = _a.value, value = _j === void 0 ? [] : _j, _k = _a.zIndex, zIndex = _k === void 0 ? 10 : _k, restInputProps = __rest(_a, ["children", "className", "description", "disabled", "dropContProps", "id", "isValid", "label", "onBlur", "onChange", "onChangeText", "onFocus", "placeholder", "readOnly", "required", "size", "value", "zIndex"]);
3352
+ var children = _a.children, className = _a.className, description = _a.description, _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.dropContProps, dropContProps = _c === void 0 ? {} : _c, customId = _a.id, _d = _a.isValid, isValid = _d === void 0 ? null : _d, _e = _a.label, label = _e === void 0 ? '' : _e, onBlur = _a.onBlur, onChange = _a.onChange, onChangeText = _a.onChangeText, onFocus = _a.onFocus, placeholder = _a.placeholder, _f = _a.readOnly, readOnly = _f === void 0 ? false : _f, _g = _a.required, required = _g === void 0 ? false : _g, _h = _a.size, size = _h === void 0 ? 'md' : _h, _j = _a.value, value = _j === void 0 ? [] : _j, restInputProps = __rest(_a, ["children", "className", "description", "disabled", "dropContProps", "id", "isValid", "label", "onBlur", "onChange", "onChangeText", "onFocus", "placeholder", "readOnly", "required", "size", "value"]);
3353
3353
  var generatedId = React.useId();
3354
3354
  var inputId = customId || generatedId;
3355
- var _l = React.useState(false), isFocused = _l[0], setIsFocused = _l[1];
3356
- var _m = React.useState(false), isHovered = _m[0], setIsHovered = _m[1];
3355
+ var _k = React.useState(false), isFocused = _k[0], setIsFocused = _k[1];
3356
+ var _l = React.useState(false), isHovered = _l[0], setIsHovered = _l[1];
3357
3357
  var internalInputRef = React.useRef(null);
3358
3358
  var containerRef = React.useRef(null);
3359
3359
  React.useImperativeHandle(ref, function () { return internalInputRef.current; });
@@ -3377,12 +3377,12 @@ var TagLabelInputInner = function (_a, ref) {
3377
3377
  var updatedValues = value.filter(function (_, idx) { return idx !== indexToRemove; });
3378
3378
  onChange(updatedValues);
3379
3379
  };
3380
- var _o = useLiveSearch({
3380
+ var _m = useLiveSearch({
3381
3381
  value: value,
3382
3382
  setValue: onChange,
3383
3383
  onChangeText: onChangeText,
3384
3384
  dropContOnClickItem: dropContProps === null || dropContProps === void 0 ? void 0 : dropContProps.onClickItem,
3385
- }), isOpen = _o.isOpen, setIsOpen = _o.setIsOpen, searchTerm = _o.searchTerm, handleInputChange = _o.handleInputChange, handleDropdownItemClick = _o.handleDropdownItemClick;
3385
+ }), isOpen = _m.isOpen, setIsOpen = _m.setIsOpen, searchTerm = _m.searchTerm, handleInputChange = _m.handleInputChange, handleDropdownItemClick = _m.handleDropdownItemClick;
3386
3386
  var handleKeyDown = function (e) {
3387
3387
  var _a;
3388
3388
  if (e.key === 'Backspace' && searchTerm === '' && value.length > 0) {
@@ -3416,9 +3416,9 @@ var TagLabelInputInner = function (_a, ref) {
3416
3416
  ? 'text-bia-green'
3417
3417
  : 'text-bia-red'
3418
3418
  : 'text-primary-cool';
3419
- var _p = sizeConfig$6[size], inputClass = _p.inputClass, paddingClass = _p.paddingClass, resizePosition = _p.resizePosition;
3420
- var _q = dropContProps || {}, dropContClassName = _q.dropContClassName, restDropContProps = __rest(_q, ["dropContClassName"]);
3421
- var _r = processRenderedChildren(children, searchTerm, 'include', handleDropdownItemClick, value), renderedChildren = _r.renderedChildren, hasFilteredResults = _r.hasFilteredResults;
3419
+ var _o = sizeConfig$6[size], inputClass = _o.inputClass, paddingClass = _o.paddingClass, resizePosition = _o.resizePosition;
3420
+ var _p = dropContProps || {}, dropContClassName = _p.dropContClassName, restDropContProps = __rest(_p, ["dropContClassName"]);
3421
+ var _q = processRenderedChildren(children, searchTerm, 'include', handleDropdownItemClick, value), renderedChildren = _q.renderedChildren, hasFilteredResults = _q.hasFilteredResults;
3422
3422
  var showPlaceholder = !disabled && !readOnly && value.length === 0;
3423
3423
  console.log('showPlaceholder', showPlaceholder);
3424
3424
  return (React.createElement("div", { className: cn$1('relative w-full', className) },
@@ -3445,7 +3445,7 @@ var TagLabelInputInner = function (_a, ref) {
3445
3445
  }, onKeyDown: handleKeyDown, placeholder: showPlaceholder ? placeholder || 'Select options...' : '', readOnly: readOnly, ref: internalInputRef, role: "combobox", type: "text", value: disabled || readOnly ? '' : searchTerm, className: cn$1(inputClass, 'min-w-[80px] flex-1 border-none bg-transparent p-0 outline-none focus:ring-0', disabled && 'cursor-not-allowed', readOnly && 'pointer-events-none') })),
3446
3446
  React.createElement(ResizeIcon, { className: cn$1('absolute', resizePosition) })),
3447
3447
  description && (React.createElement("p", { className: cn$1('mt-1.5 text-xs transition-colors', descColor) }, description)),
3448
- children && (React.createElement(DropdownContainer, __assign({ anchorRef: containerRef, className: cn$1('bianic-livesearch-dropdown w-full overflow-hidden bg-white shadow-lg', dropContClassName), isTopFlat: true, matchAnchorWidth: "min", onClose: function () { return setIsOpen(false); }, open: isOpen && !disabled && !readOnly, size: size, zIndex: zIndex }, restDropContProps), hasFilteredResults
3448
+ children && (React.createElement(DropdownContainer, __assign({ anchorRef: containerRef, className: cn$1('bianic-livesearch-dropdown w-full overflow-hidden bg-white shadow-lg', dropContClassName), isTopFlat: true, matchAnchorWidth: "min", onClose: function () { return setIsOpen(false); }, open: isOpen && !disabled && !readOnly, size: size, zIndex: 10 }, restDropContProps), hasFilteredResults
3449
3449
  ? renderedChildren
3450
3450
  : searchTerm.length > 0 && (React.createElement(DropdownItem, { content: React.createElement("div", { className: "px-4 py-2 text-gray-500" }, "Tidak ada hasil ditemukan.") }))))));
3451
3451
  };
@@ -4640,7 +4640,7 @@ var useFileHandler = function (_a) {
4640
4640
  };
4641
4641
 
4642
4642
  var SimpleFileUploader = function (_a) {
4643
- var _b = _a.size, size = _b === void 0 ? 'md' : _b, accept = _a.accept, _c = _a.multiple, multiple = _c === void 0 ? false : _c, maxSize = _a.maxSize, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.label, label = _e === void 0 ? 'Choose File' : _e, _f = _a.variant, variant = _f === void 0 ? 'form-group' : _f, errorMessage = _a.errorMessage, _g = _a.value, value = _g === void 0 ? [] : _g, onChange = _a.onChange, onError = _a.onError, className = _a.className;
4643
+ var _b = _a.size, size = _b === void 0 ? 'md' : _b, accept = _a.accept, _c = _a.multiple, multiple = _c === void 0 ? false : _c, maxSize = _a.maxSize, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.label, label = _e === void 0 ? 'Choose File' : _e, _f = _a.variant, variant = _f === void 0 ? 'form-group' : _f, errorMessage = _a.errorMessage, _g = _a.value, value = _g === void 0 ? [] : _g, onChange = _a.onChange, onError = _a.onError, className = _a.className, iconLeft = _a.iconLeft, buttonProps = __rest(_a, ["size", "accept", "multiple", "maxSize", "disabled", "label", "variant", "errorMessage", "value", "onChange", "onError", "className", "iconLeft"]);
4644
4644
  var _h = useFileHandler({
4645
4645
  accept: accept,
4646
4646
  multiple: multiple,
@@ -4659,7 +4659,9 @@ var SimpleFileUploader = function (_a) {
4659
4659
  }[size];
4660
4660
  return (React.createElement("div", { className: cn$1('inline-flex flex-col items-start gap-1.5', className) },
4661
4661
  React.createElement("input", { ref: inputRef, type: "file", accept: accept, multiple: multiple, disabled: disabled, onChange: handleInputChange, className: "hidden", "aria-label": "File input" }),
4662
- React.createElement(Button, { label: label, onClick: triggerClick, disabled: disabled, size: size, variant: variant, iconLeft: React.createElement(TbFolderOpen, { size: iconSizes, className: "shrink-0 text-bia-black" }) }),
4662
+ React.createElement(Button
4663
+ // eslint-disable-next-line react/jsx-props-no-spreading
4664
+ , __assign({}, buttonProps, { label: label, onClick: triggerClick, disabled: disabled, size: size, variant: variant, iconLeft: iconLeft !== null && iconLeft !== void 0 ? iconLeft : (React.createElement(TbFolderOpen, { size: iconSizes, className: "shrink-0 text-bia-black" })) })),
4663
4665
  activeError && (React.createElement("div", { className: "flex items-center gap-1 text-xs font-medium text-bia-red" },
4664
4666
  React.createElement(TbAlertCircle, { size: 14, className: "shrink-0" }),
4665
4667
  React.createElement("span", null, activeError)))));
@@ -5658,7 +5660,7 @@ var SidebarProfile = React.forwardRef(function (_a, ref) {
5658
5660
  }, className: cn$1('cubic-bezier(0.68, -0.1, 0.32, 1.2) flex w-full items-center gap-x-2.5 delay-500 duration-300', buttonClass, className) }),
5659
5661
  avatarImage,
5660
5662
  React.createElement("div", { className: "flex flex-col" },
5661
- React.createElement(Text, { variant: "normal-text", className: cn$1('truncate text-bia-white delay-[400ms]', isMinimized
5663
+ React.createElement(Text, { variant: "normal-text", className: cn$1('truncate text-left text-bia-white delay-[400ms]', isMinimized
5662
5664
  ? 'opacity-0 duration-300 ease-in-out'
5663
5665
  : 'opacity-100 delay-1000 duration-700 ease-in-out') }, username),
5664
5666
  React.createElement(Text, { variant: "small-text", className: cn$1('truncate text-left text-bia-white delay-[400ms]', isMinimized
@@ -9409,6 +9411,71 @@ function getRelativeTime(date) {
9409
9411
  return "".concat(Math.floor(diffMs / month), " months ago");
9410
9412
  return "".concat(Math.floor(diffMs / year), " years ago");
9411
9413
  }
9414
+ /**
9415
+ * formatDateTime
9416
+ * Accepts a date value and formats it into one of several human-readable
9417
+ * or machine-sortable string formats.
9418
+ * Formats:
9419
+ * - 'short': "'24 Feb 4"
9420
+ * - 'long' (default): "4 February 2024"
9421
+ * - 'long-with-time': "4 February 2024, 16:30"
9422
+ * - 'table': "2024-02-04"
9423
+ * - 'table-with-time': "2024-02-04, 16:30"
9424
+ * - 'time24': "16:30"
9425
+ */
9426
+ var formatDateTime = function (dateString, type) {
9427
+ if (type === void 0) { type = null; }
9428
+ var date = new Date(dateString);
9429
+ var year;
9430
+ var month = '';
9431
+ var day = '';
9432
+ var timeResult = date.toLocaleTimeString('en-GB', {
9433
+ hour: '2-digit',
9434
+ minute: '2-digit',
9435
+ hour12: false,
9436
+ });
9437
+ switch (type) {
9438
+ case 'short':
9439
+ // example: '24 Feb 4
9440
+ year = date.getFullYear().toString().substring(2, 4);
9441
+ month = date.toLocaleString('en-US', { month: 'short' });
9442
+ day = String(date.getDate());
9443
+ return "'".concat(year, " ").concat(month, " ").concat(day);
9444
+ case 'long':
9445
+ // example: 4 February 2024
9446
+ year = date.getFullYear().toString();
9447
+ month = date.toLocaleString('en-US', { month: 'long' });
9448
+ day = String(date.getDate());
9449
+ return "".concat(day, " ").concat(month, " ").concat(year);
9450
+ case 'long-with-time':
9451
+ // example: 4 February 2024, 16:30
9452
+ year = date.getFullYear().toString();
9453
+ month = date.toLocaleString('en-US', { month: 'long' });
9454
+ day = String(date.getDate());
9455
+ return "".concat(day, " ").concat(month, " ").concat(year, ", ").concat(timeResult);
9456
+ case 'table':
9457
+ // example: 2024-02-04
9458
+ year = date.getFullYear();
9459
+ month = String(date.getMonth() + 1).padStart(2, '0');
9460
+ day = String(date.getDate()).padStart(2, '0');
9461
+ return "".concat(year, "-").concat(month, "-").concat(day);
9462
+ case 'table-with-time':
9463
+ // example: 2024-02-04, 16:30
9464
+ year = date.getFullYear();
9465
+ month = String(date.getMonth() + 1).padStart(2, '0');
9466
+ day = String(date.getDate()).padStart(2, '0');
9467
+ return "".concat(year, "-").concat(month, "-").concat(day, ", ").concat(timeResult);
9468
+ case 'time24':
9469
+ // example: 16:30
9470
+ return "".concat(timeResult);
9471
+ default:
9472
+ // default to long format (4 February 2024)
9473
+ year = date.getFullYear().toString();
9474
+ month = date.toLocaleString('en-US', { month: 'long' });
9475
+ day = String(date.getDate());
9476
+ return "".concat(day, " ").concat(month, " ").concat(year);
9477
+ }
9478
+ };
9412
9479
 
9413
9480
  /**
9414
9481
  * A custom hook to handle data processing for tables, managing internal states
@@ -9631,6 +9698,7 @@ exports.TreeItem = TreeItem;
9631
9698
  exports.VerticalStepper = StepperItem;
9632
9699
  exports.Window = Window;
9633
9700
  exports.YearPicker = YearPicker;
9701
+ exports.formatDateTime = formatDateTime;
9634
9702
  exports.getRelativeTime = getRelativeTime;
9635
9703
  exports.useFileTree = useFileTree;
9636
9704
  exports.useTableDataHandler = useTableDataHandler;