@activecollab/components 2.0.117 → 2.0.119
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/components/EditableHours/EditableHours.js +1 -1
- package/dist/cjs/components/EditableHours/EditableHours.js.map +1 -1
- package/dist/cjs/components/Icons/collection/ArrowRestore.js +46 -0
- package/dist/cjs/components/Icons/collection/ArrowRestore.js.map +1 -0
- package/dist/cjs/components/Icons/collection/index.js +7 -0
- package/dist/cjs/components/Icons/collection/index.js.map +1 -1
- package/dist/cjs/components/SelectTrigger/SelectTrigger.js +11 -1
- package/dist/cjs/components/SelectTrigger/SelectTrigger.js.map +1 -1
- package/dist/cjs/components/SelectTrigger/Styles.js +6 -3
- package/dist/cjs/components/SelectTrigger/Styles.js.map +1 -1
- package/dist/cjs/hooks/useInputHours.js +3 -3
- package/dist/cjs/hooks/useInputHours.js.map +1 -1
- package/dist/cjs/utils/index.js +7 -0
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/timeUtils.js +87 -33
- package/dist/cjs/utils/timeUtils.js.map +1 -1
- package/dist/cjs/utils/timeUtils.test.js +1 -1
- package/dist/cjs/utils/timeUtils.test.js.map +1 -1
- package/dist/esm/components/EditableHours/EditableHours.js +2 -2
- package/dist/esm/components/EditableHours/EditableHours.js.map +1 -1
- package/dist/esm/components/Icons/collection/ArrowRestore.d.ts +23 -0
- package/dist/esm/components/Icons/collection/ArrowRestore.d.ts.map +1 -0
- package/dist/esm/components/Icons/collection/ArrowRestore.js +38 -0
- package/dist/esm/components/Icons/collection/ArrowRestore.js.map +1 -0
- package/dist/esm/components/Icons/collection/index.d.ts +1 -0
- package/dist/esm/components/Icons/collection/index.d.ts.map +1 -1
- package/dist/esm/components/Icons/collection/index.js +1 -0
- package/dist/esm/components/Icons/collection/index.js.map +1 -1
- package/dist/esm/components/SelectTrigger/SelectTrigger.d.ts +2 -3
- package/dist/esm/components/SelectTrigger/SelectTrigger.d.ts.map +1 -1
- package/dist/esm/components/SelectTrigger/SelectTrigger.js +12 -2
- package/dist/esm/components/SelectTrigger/SelectTrigger.js.map +1 -1
- package/dist/esm/components/SelectTrigger/Styles.d.ts +2 -3
- package/dist/esm/components/SelectTrigger/Styles.d.ts.map +1 -1
- package/dist/esm/components/SelectTrigger/Styles.js +8 -3
- package/dist/esm/components/SelectTrigger/Styles.js.map +1 -1
- package/dist/esm/hooks/useInputHours.js +4 -4
- package/dist/esm/hooks/useInputHours.js.map +1 -1
- package/dist/esm/utils/index.d.ts +1 -1
- package/dist/esm/utils/index.d.ts.map +1 -1
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/timeUtils.d.ts +34 -0
- package/dist/esm/utils/timeUtils.d.ts.map +1 -1
- package/dist/esm/utils/timeUtils.js +83 -30
- package/dist/esm/utils/timeUtils.js.map +1 -1
- package/dist/esm/utils/timeUtils.test.js +2 -2
- package/dist/esm/utils/timeUtils.test.js.map +1 -1
- package/dist/index.js +146 -40
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -767,38 +767,23 @@
|
|
|
767
767
|
};
|
|
768
768
|
var useResizeObserver$1 = useResizeObserver;
|
|
769
769
|
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
// minutes_decimal = parseInt(minutes_decimal);
|
|
788
|
-
// } // if
|
|
789
|
-
//
|
|
790
|
-
// const minutes = Math.round((minutes_decimal / 100) * 60);
|
|
791
|
-
//
|
|
792
|
-
// if (hours < 10) {
|
|
793
|
-
// hours = `0${hours}`;
|
|
794
|
-
// }
|
|
795
|
-
// return {
|
|
796
|
-
// hours: hours,
|
|
797
|
-
// minutes: minutes,
|
|
798
|
-
// };
|
|
799
|
-
// };
|
|
800
|
-
|
|
801
|
-
var decimalToHours = function decimalToHours(num) {
|
|
770
|
+
/**
|
|
771
|
+
* @function formatHours
|
|
772
|
+
* @description
|
|
773
|
+
* Formats a decimal number representing hours into a formatted string (HH:MM).
|
|
774
|
+
* The input can be a number, string, or undefined. The function handles various formats
|
|
775
|
+
* and can optionally add a leading zero to the hours component.
|
|
776
|
+
*
|
|
777
|
+
* @param {number | string | undefined} num - The input representing the hours, which can be in decimal format, a time string, or undefined.
|
|
778
|
+
* @param {boolean} [withLeadingZeroHours=false] - Whether to add a leading zero to the hours part of the output.
|
|
779
|
+
*
|
|
780
|
+
* @returns {string} - A formatted time string in HH:MM format.
|
|
781
|
+
*
|
|
782
|
+
* @example
|
|
783
|
+
* formatHours(1.5) // "1:30"
|
|
784
|
+
* formatHours("3.5", true) // "03:30"
|
|
785
|
+
*/
|
|
786
|
+
var formatHours = function formatHours(num) {
|
|
802
787
|
var withLeadingZeroHours = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
803
788
|
if (!num) {
|
|
804
789
|
return "";
|
|
@@ -848,6 +833,75 @@
|
|
|
848
833
|
var minutes_formatted = Math.round(parseInt(minutes, 10) / 100 * 60);
|
|
849
834
|
return "".concat(hours, ":").concat(withLeadingZero(minutes_formatted));
|
|
850
835
|
};
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* @function decimalToHours
|
|
839
|
+
* @deprecated
|
|
840
|
+
* @description
|
|
841
|
+
* Converts a decimal number representing hours into a formatted string (HH:MM).
|
|
842
|
+
* The input can be a number, string, or undefined. The function handles various formats
|
|
843
|
+
* and can optionally add a leading zero to the hours component.
|
|
844
|
+
*
|
|
845
|
+
* @param {number | string | undefined} num - The input representing the hours, which can be in decimal format, a time string, or undefined.
|
|
846
|
+
* @param {boolean} [withLeadingZeroHours=false] - Whether to add a leading zero to the hours part of the output.
|
|
847
|
+
*
|
|
848
|
+
* @returns {string} - A formatted time string in HH:MM format.
|
|
849
|
+
*
|
|
850
|
+
* @example
|
|
851
|
+
* decimalToHours(1.5) // "1:30"
|
|
852
|
+
* decimalToHours("3.5", true) // "03:30"
|
|
853
|
+
*/
|
|
854
|
+
var decimalToHours = function decimalToHours(num) {
|
|
855
|
+
var withLeadingZeroHours = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
856
|
+
console.warn("Deprecated. Please use formatHours from @activecollab/components.");
|
|
857
|
+
if (!num) {
|
|
858
|
+
return "";
|
|
859
|
+
}
|
|
860
|
+
if (typeof num === "string" && !num) {
|
|
861
|
+
return withLeadingZeroHours ? "00:00" : "0:00";
|
|
862
|
+
}
|
|
863
|
+
if (typeof num === "string" && num.indexOf(":") >= 0) {
|
|
864
|
+
//eslint-disable-next-line
|
|
865
|
+
var _num$split3 = num.split(":"),
|
|
866
|
+
_num$split4 = _slicedToArray(_num$split3, 2),
|
|
867
|
+
_hours = _num$split4[0],
|
|
868
|
+
_minutes = _num$split4[1];
|
|
869
|
+
if (_minutes && _minutes.length === 1 && Number(_minutes) < 10) {
|
|
870
|
+
_minutes = "".concat(Number(_minutes), "0");
|
|
871
|
+
}
|
|
872
|
+
if (_hours && _minutes) {
|
|
873
|
+
if (withLeadingZeroHours) {
|
|
874
|
+
return "".concat(withLeadingZero(_hours), ":").concat(_minutes);
|
|
875
|
+
}
|
|
876
|
+
return "".concat(_hours, ":").concat(_minutes);
|
|
877
|
+
} else if (!_hours && _minutes) {
|
|
878
|
+
return withLeadingZeroHours ? "00:".concat(_minutes) : "0:".concat(_minutes);
|
|
879
|
+
} else if (!_minutes && _hours) {
|
|
880
|
+
return withLeadingZeroHours ? "".concat(withLeadingZero(_hours), ":00") : "".concat(_hours, ":00");
|
|
881
|
+
} else {
|
|
882
|
+
return withLeadingZeroHours ? "00:00" : "0:00";
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
if (typeof num === "string" && num.indexOf(",") >= 0) {
|
|
886
|
+
num = num.replace(",", ".");
|
|
887
|
+
}
|
|
888
|
+
var input = typeof num === "string" ? parseFloat(num) : num;
|
|
889
|
+
if (!isDecimal(input)) {
|
|
890
|
+
if (withLeadingZeroHours) {
|
|
891
|
+
return "".concat(withLeadingZero(input), ":00");
|
|
892
|
+
}
|
|
893
|
+
return "".concat(input, ":00");
|
|
894
|
+
}
|
|
895
|
+
var decimal = input.toFixed(2);
|
|
896
|
+
var time = decimal.toString().split(".");
|
|
897
|
+
var hours = time[0];
|
|
898
|
+
if (withLeadingZeroHours) {
|
|
899
|
+
hours = withLeadingZero(hours);
|
|
900
|
+
}
|
|
901
|
+
var minutes = time[1];
|
|
902
|
+
var minutes_formatted = Math.round(parseInt(minutes, 10) / 100 * 60);
|
|
903
|
+
return "".concat(hours, ":").concat(withLeadingZero(minutes_formatted));
|
|
904
|
+
};
|
|
851
905
|
var withLeadingZero = function withLeadingZero(num) {
|
|
852
906
|
var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
|
853
907
|
var s = "".concat(num);
|
|
@@ -1405,6 +1459,43 @@
|
|
|
1405
1459
|
ArrowRefreshIcon.displayName = "ArrowRefreshIcon";
|
|
1406
1460
|
var ArrowRefreshIcon$1 = ArrowRefreshIcon;
|
|
1407
1461
|
|
|
1462
|
+
/**
|
|
1463
|
+
* @component ArrowRestoreIcon
|
|
1464
|
+
* @description
|
|
1465
|
+
*
|
|
1466
|
+
* The React Icon component is a visual element that displays an icon to represent a concept, object, or action.
|
|
1467
|
+
* The Icon component is
|
|
1468
|
+
* customizable, allowing for variations in size, color, and style to fit the needs of the application.
|
|
1469
|
+
*
|
|
1470
|
+
*
|
|
1471
|
+
* @example
|
|
1472
|
+
* return (
|
|
1473
|
+
* <ArrowRestoreIcon className="mr-2" />
|
|
1474
|
+
* )
|
|
1475
|
+
*
|
|
1476
|
+
* @see
|
|
1477
|
+
* https://system.activecollab.com/?path=/story/foundation-icons-icons--icons
|
|
1478
|
+
* @see
|
|
1479
|
+
* https://design.activecollab.com/docs/foundations/icons
|
|
1480
|
+
*/
|
|
1481
|
+
var ArrowRestoreIcon = /*#__PURE__*/React__default["default"].forwardRef(function (props, svgRef) {
|
|
1482
|
+
return /*#__PURE__*/React__default["default"].createElement("svg", _extends({
|
|
1483
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1484
|
+
width: 24,
|
|
1485
|
+
height: 24,
|
|
1486
|
+
"data-testid": "ArrowRestoreIcon",
|
|
1487
|
+
fill: "var(--color-theme-600)",
|
|
1488
|
+
focusable: false,
|
|
1489
|
+
ref: svgRef
|
|
1490
|
+
}, props), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
1491
|
+
fillRule: "evenodd",
|
|
1492
|
+
d: "M17.026 19.796a9 9 0 01-12.294-3.294l-1.732 1 .653-4.87 4.543 1.87-1.732 1a7 7 0 102.562-9.563 6.944 6.944 0 00-3.248 4.254l-1.94-.52a8.896 8.896 0 014.188-5.466 9 9 0 019 15.589z",
|
|
1493
|
+
clipRule: "evenodd"
|
|
1494
|
+
}));
|
|
1495
|
+
});
|
|
1496
|
+
ArrowRestoreIcon.displayName = "ArrowRestoreIcon";
|
|
1497
|
+
var ArrowRestoreIcon$1 = ArrowRestoreIcon;
|
|
1498
|
+
|
|
1408
1499
|
/**
|
|
1409
1500
|
* @component ArrowRightIcon
|
|
1410
1501
|
* @description
|
|
@@ -13561,13 +13652,13 @@
|
|
|
13561
13652
|
onChange = _ref.onChange,
|
|
13562
13653
|
onClick = _ref.onClick;
|
|
13563
13654
|
var _useState = React.useState(function () {
|
|
13564
|
-
return
|
|
13655
|
+
return formatHours(value, withLeadingZero);
|
|
13565
13656
|
}),
|
|
13566
13657
|
_useState2 = _slicedToArray(_useState, 2),
|
|
13567
13658
|
currentValue = _useState2[0],
|
|
13568
13659
|
setCurrentValue = _useState2[1];
|
|
13569
13660
|
var _useState3 = React.useState(function () {
|
|
13570
|
-
return
|
|
13661
|
+
return formatHours(value, withLeadingZero);
|
|
13571
13662
|
}),
|
|
13572
13663
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
13573
13664
|
prevValue = _useState4[0],
|
|
@@ -13578,7 +13669,7 @@
|
|
|
13578
13669
|
setCurrentValue(prevValue);
|
|
13579
13670
|
} else {
|
|
13580
13671
|
if (e.target.value.trim().length > 0 && prevValue !== e.target.value) {
|
|
13581
|
-
var _value =
|
|
13672
|
+
var _value = formatHours(e.target.value, withLeadingZero);
|
|
13582
13673
|
setPrevValue(_value);
|
|
13583
13674
|
setCurrentValue(_value);
|
|
13584
13675
|
typeof onSave === "function" && onSave(e);
|
|
@@ -16549,7 +16640,7 @@
|
|
|
16549
16640
|
var StyledSelectTrigger = styled__default["default"](Trigger).withConfig({
|
|
16550
16641
|
displayName: "Styles__StyledSelectTrigger",
|
|
16551
16642
|
componentId: "sc-9799p2-0"
|
|
16552
|
-
})(["display:flex;align-items:center;justify-content:space-between;padding:0 4px 0 8px;width:300px;transition:border-color 0.3s ease;background-color:transparent;border:none;", " ", " ", " ", " ", " ", " ", ";"], function (_ref) {
|
|
16643
|
+
})(["display:flex;align-items:center;justify-content:space-between;padding:0 4px 0 8px;width:300px;transition:border-color 0.3s ease;background-color:transparent;border:none;", " ", " ", " ", " ", " ", " ", ";", ";"], function (_ref) {
|
|
16553
16644
|
var $mode = _ref.$mode;
|
|
16554
16645
|
return $mode === "outlined" && styled.css(["border:1px solid var(--color-theme-500);background-color:var(--input-background-color);"]);
|
|
16555
16646
|
}, function (_ref2) {
|
|
@@ -16577,13 +16668,16 @@
|
|
|
16577
16668
|
}, function (_ref7) {
|
|
16578
16669
|
var $size = _ref7.$size;
|
|
16579
16670
|
return $size === "big" && styled.css(["height:40px;border-radius:var(--ac-br-8);"]);
|
|
16671
|
+
}, function (_ref8) {
|
|
16672
|
+
var $size = _ref8.$size;
|
|
16673
|
+
return $size === "biggest" && styled.css(["height:48px;border-radius:var(--ac-br-8);"]);
|
|
16580
16674
|
});
|
|
16581
16675
|
StyledSelectTrigger.displayName = "StyledSelectTrigger";
|
|
16582
16676
|
var StyledCaretIcon = styled__default["default"](CollapseExpandSingleIcon$1).withConfig({
|
|
16583
16677
|
displayName: "Styles__StyledCaretIcon",
|
|
16584
16678
|
componentId: "sc-9799p2-1"
|
|
16585
|
-
})(["margin-left:8px;flex-shrink:0;transition:transform 200ms ease;", ""], function (
|
|
16586
|
-
var $open =
|
|
16679
|
+
})(["margin-left:8px;flex-shrink:0;transition:transform 200ms ease;", ""], function (_ref9) {
|
|
16680
|
+
var $open = _ref9.$open;
|
|
16587
16681
|
return !$open && styled.css(["transform:rotate(180deg);"]);
|
|
16588
16682
|
});
|
|
16589
16683
|
StyledCaretIcon.displayName = "StyledCaretIcon";
|
|
@@ -16604,6 +16698,15 @@
|
|
|
16604
16698
|
_ref$mode = _ref.mode,
|
|
16605
16699
|
mode = _ref$mode === void 0 ? "outlined" : _ref$mode,
|
|
16606
16700
|
rest = _objectWithoutProperties(_ref, _excluded$n);
|
|
16701
|
+
var variant = React.useMemo(function () {
|
|
16702
|
+
if (size === "big") {
|
|
16703
|
+
return "Body 1";
|
|
16704
|
+
}
|
|
16705
|
+
if (size === "biggest") {
|
|
16706
|
+
return "Header 2";
|
|
16707
|
+
}
|
|
16708
|
+
return "Body 2";
|
|
16709
|
+
}, [size]);
|
|
16607
16710
|
return /*#__PURE__*/React__default["default"].createElement(StyledSelectTrigger, _extends({
|
|
16608
16711
|
ref: ref,
|
|
16609
16712
|
role: "button",
|
|
@@ -16616,7 +16719,8 @@
|
|
|
16616
16719
|
as: "div",
|
|
16617
16720
|
overflow: "truncate",
|
|
16618
16721
|
whitespace: "no-wrap",
|
|
16619
|
-
variant:
|
|
16722
|
+
variant: variant,
|
|
16723
|
+
weight: size === "biggest" ? "bold" : "regular",
|
|
16620
16724
|
color: mode === "flat" && invalid ? "alert" : undefined
|
|
16621
16725
|
}, typographyProps), children), endAdornment ? endAdornment : /*#__PURE__*/React__default["default"].createElement(StyledCaretIcon, {
|
|
16622
16726
|
$open: open
|
|
@@ -18073,7 +18177,7 @@
|
|
|
18073
18177
|
React.useEffect(function () {
|
|
18074
18178
|
var _value;
|
|
18075
18179
|
if (defaultValue !== undefined) {
|
|
18076
|
-
_value =
|
|
18180
|
+
_value = formatHours(defaultValue, withLeadingZero);
|
|
18077
18181
|
}
|
|
18078
18182
|
setCurrentValue(function (prevState) {
|
|
18079
18183
|
if (prevState !== _value) {
|
|
@@ -19659,6 +19763,7 @@
|
|
|
19659
19763
|
exports.ArrowLeftBoxIcon = ArrowLeftBoxIcon$1;
|
|
19660
19764
|
exports.ArrowLeftIcon = ArrowLeftIcon$1;
|
|
19661
19765
|
exports.ArrowRefreshIcon = ArrowRefreshIcon$1;
|
|
19766
|
+
exports.ArrowRestoreIcon = ArrowRestoreIcon$1;
|
|
19662
19767
|
exports.ArrowRightIcon = ArrowRightIcon$1;
|
|
19663
19768
|
exports.ArrowUpIcon = ArrowUpIcon$1;
|
|
19664
19769
|
exports.ArrowUpLongIcon = ArrowUpLongIcon$1;
|
|
@@ -19963,6 +20068,7 @@
|
|
|
19963
20068
|
exports.colors = colors$1;
|
|
19964
20069
|
exports.decimalToHours = decimalToHours;
|
|
19965
20070
|
exports.formatCurrency = formatCurrency;
|
|
20071
|
+
exports.formatHours = formatHours;
|
|
19966
20072
|
exports.formatNumber = formatNumber;
|
|
19967
20073
|
exports.getNumberFromString = getNumberFromString;
|
|
19968
20074
|
exports.isOptionGroup = isOptionGroup;
|