@activecollab/components 2.0.196 → 2.0.198
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/Display/DisplayHours.js +9 -8
- package/dist/cjs/components/Display/DisplayHours.js.map +1 -1
- package/dist/cjs/components/Display/types.js.map +1 -1
- package/dist/cjs/components/Input/InputNumber.js +5 -2
- package/dist/cjs/components/Input/InputNumber.js.map +1 -1
- package/dist/cjs/hooks/useInputNumber.js +8 -7
- package/dist/cjs/hooks/useInputNumber.js.map +1 -1
- package/dist/cjs/utils/currencyUtils.js +20 -1
- package/dist/cjs/utils/currencyUtils.js.map +1 -1
- package/dist/cjs/utils/currencyUtils.test.js +5 -0
- package/dist/cjs/utils/currencyUtils.test.js.map +1 -1
- package/dist/cjs/utils/timeUtils.js +28 -9
- package/dist/cjs/utils/timeUtils.js.map +1 -1
- package/dist/cjs/utils/timeUtils.test.js +3 -2
- package/dist/cjs/utils/timeUtils.test.js.map +1 -1
- package/dist/cjs/utils/types.js.map +1 -1
- package/dist/esm/components/Display/DisplayHours.d.ts.map +1 -1
- package/dist/esm/components/Display/DisplayHours.js +9 -8
- package/dist/esm/components/Display/DisplayHours.js.map +1 -1
- package/dist/esm/components/Display/types.d.ts +3 -2
- package/dist/esm/components/Display/types.d.ts.map +1 -1
- package/dist/esm/components/Display/types.js.map +1 -1
- package/dist/esm/components/Input/InputNumber.d.ts.map +1 -1
- package/dist/esm/components/Input/InputNumber.js +3 -1
- package/dist/esm/components/Input/InputNumber.js.map +1 -1
- package/dist/esm/hooks/useInputNumber.d.ts +2 -1
- package/dist/esm/hooks/useInputNumber.d.ts.map +1 -1
- package/dist/esm/hooks/useInputNumber.js +5 -4
- package/dist/esm/hooks/useInputNumber.js.map +1 -1
- package/dist/esm/utils/currencyUtils.d.ts +1 -0
- package/dist/esm/utils/currencyUtils.d.ts.map +1 -1
- package/dist/esm/utils/currencyUtils.js +10 -0
- package/dist/esm/utils/currencyUtils.js.map +1 -1
- package/dist/esm/utils/currencyUtils.test.js +6 -1
- package/dist/esm/utils/currencyUtils.test.js.map +1 -1
- package/dist/esm/utils/timeUtils.d.ts +11 -7
- package/dist/esm/utils/timeUtils.d.ts.map +1 -1
- package/dist/esm/utils/timeUtils.js +31 -10
- package/dist/esm/utils/timeUtils.js.map +1 -1
- package/dist/esm/utils/timeUtils.test.js +5 -2
- package/dist/esm/utils/timeUtils.test.js.map +1 -1
- package/dist/esm/utils/types.d.ts +2 -1
- package/dist/esm/utils/types.d.ts.map +1 -1
- package/dist/esm/utils/types.js.map +1 -1
- package/dist/index.js +61 -26
- 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
|
@@ -41,11 +41,12 @@ export interface FormatNumberArgs {
|
|
|
41
41
|
decimalSeparator?: "," | ".";
|
|
42
42
|
trimDecimals?: boolean;
|
|
43
43
|
decimalSpaces?: number;
|
|
44
|
-
format?:
|
|
44
|
+
format?: FormatType;
|
|
45
45
|
}
|
|
46
46
|
export interface FormatCurrencyArgs extends FormatNumberArgs {
|
|
47
47
|
currencyCode?: string;
|
|
48
48
|
currencyCodePosition?: "right" | "left";
|
|
49
49
|
}
|
|
50
|
+
export type FormatType = "short" | "long";
|
|
50
51
|
export {};
|
|
51
52
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,MAAM,OAAO,CACjB,CAAC,SAAS,MAAM,GAAG,CAAC,iBAAiB,GAAG,KAAK,CAAC,qBAAqB,CAAC,OAAO,CAAC,IAC1E,GAAG,CAAC,wBAAwB,CAAC,CAAC,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC;AAEvE,KAAK,MAAM,CAAC,CAAC,SAAS,K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;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,IACpD,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AACxC;;;GAGG;AACH,MAAM,MAAM,gCAAgC,CAC1C,CAAC,SAAS,KAAK,CAAC,WAAW,EAC3B,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAC7B,yBAAyB,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,CAAA;CAAE,CAAC;AAEtE,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IACpC,gBAAgB,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CACzC;AAED,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/utils/types.ts"],"sourcesContent":["import React from \"react\";\n\n// Source: https://github.com/emotion-js/emotion/blob/master/packages/styled-base/types/helper.d.ts\n// A more precise version of just React.ComponentPropsWithoutRef on its own\nexport type PropsOf<\n C extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<unknown>\n> = JSX.LibraryManagedAttributes<C, React.ComponentPropsWithoutRef<C>>;\n\ntype AsProp<C extends React.ElementType> = {\n /**\n * An override of the default HTML tag.\n * Can also be another React component.\n */\n as?: C;\n};\n\n/**\n * Allows for extending a set of props (`ExtendedProps`) by an overriding set of props\n * (`OverrideProps`), ensuring that any duplicates are overridden by the overriding\n * set of props.\n */\nexport type ExtendableProps<\n ExtendedProps = Record<string, unknown>,\n OverrideProps = Record<string, unknown>\n> = OverrideProps & Omit<ExtendedProps, keyof OverrideProps>;\n\n/**\n * Allows for inheriting the props from the specified element type so that\n * props like children, className & style work, as well as element-specific\n * attributes like aria roles. The component (`C`) must be passed in.\n */\nexport type InheritableElementProps<\n C extends React.ElementType,\n Props = Record<string, unknown>\n> = ExtendableProps<PropsOf<C>, Props>;\n\n/**\n * A more sophisticated version of `InheritableElementProps` where\n * the passed in `as` prop will determine which props can be included\n */\nexport type PolymorphicComponentProps<\n C extends React.ElementType,\n Props = Record<string, unknown>\n> = InheritableElementProps<C, Props & AsProp<C>>;\n\n/**\n * Utility type to extract the `ref` prop from a polymorphic component\n */\nexport type PolymorphicRef<C extends React.ElementType> =\n React.ComponentPropsWithRef<C>[\"ref\"];\n/**\n * A wrapper of `PolymorphicComponentProps` that also includes the `ref`\n * prop for the polymorphic component\n */\nexport type PolymorphicComponentPropsWithRef<\n C extends React.ElementType,\n Props = Record<string, unknown>\n> = PolymorphicComponentProps<C, Props> & { ref?: PolymorphicRef<C> };\n\nexport interface FormatNumberArgs {\n value: string | number;\n thousandSeparator?: \",\" | \".\" | \" \";\n decimalSeparator?: \",\" | \".\";\n trimDecimals?: boolean;\n decimalSpaces?: number;\n format?:
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/utils/types.ts"],"sourcesContent":["import React from \"react\";\n\n// Source: https://github.com/emotion-js/emotion/blob/master/packages/styled-base/types/helper.d.ts\n// A more precise version of just React.ComponentPropsWithoutRef on its own\nexport type PropsOf<\n C extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<unknown>\n> = JSX.LibraryManagedAttributes<C, React.ComponentPropsWithoutRef<C>>;\n\ntype AsProp<C extends React.ElementType> = {\n /**\n * An override of the default HTML tag.\n * Can also be another React component.\n */\n as?: C;\n};\n\n/**\n * Allows for extending a set of props (`ExtendedProps`) by an overriding set of props\n * (`OverrideProps`), ensuring that any duplicates are overridden by the overriding\n * set of props.\n */\nexport type ExtendableProps<\n ExtendedProps = Record<string, unknown>,\n OverrideProps = Record<string, unknown>\n> = OverrideProps & Omit<ExtendedProps, keyof OverrideProps>;\n\n/**\n * Allows for inheriting the props from the specified element type so that\n * props like children, className & style work, as well as element-specific\n * attributes like aria roles. The component (`C`) must be passed in.\n */\nexport type InheritableElementProps<\n C extends React.ElementType,\n Props = Record<string, unknown>\n> = ExtendableProps<PropsOf<C>, Props>;\n\n/**\n * A more sophisticated version of `InheritableElementProps` where\n * the passed in `as` prop will determine which props can be included\n */\nexport type PolymorphicComponentProps<\n C extends React.ElementType,\n Props = Record<string, unknown>\n> = InheritableElementProps<C, Props & AsProp<C>>;\n\n/**\n * Utility type to extract the `ref` prop from a polymorphic component\n */\nexport type PolymorphicRef<C extends React.ElementType> =\n React.ComponentPropsWithRef<C>[\"ref\"];\n/**\n * A wrapper of `PolymorphicComponentProps` that also includes the `ref`\n * prop for the polymorphic component\n */\nexport type PolymorphicComponentPropsWithRef<\n C extends React.ElementType,\n Props = Record<string, unknown>\n> = PolymorphicComponentProps<C, Props> & { ref?: PolymorphicRef<C> };\n\nexport interface FormatNumberArgs {\n value: string | number;\n thousandSeparator?: \",\" | \".\" | \" \";\n decimalSeparator?: \",\" | \".\";\n trimDecimals?: boolean;\n decimalSpaces?: number;\n format?: FormatType;\n}\n\nexport interface FormatCurrencyArgs extends FormatNumberArgs {\n currencyCode?: string;\n currencyCodePosition?: \"right\" | \"left\";\n}\n\nexport type FormatType = \"short\" | \"long\";\n"],"mappings":""}
|
package/dist/index.js
CHANGED
|
@@ -723,6 +723,19 @@
|
|
|
723
723
|
}
|
|
724
724
|
return currencyCodePosition === "right" ? "".concat(formattedNum, " ").concat(currencyCode) : "".concat(currencyCode, " ").concat(formattedNum);
|
|
725
725
|
};
|
|
726
|
+
var parseValueToNumber = function parseValueToNumber(value, thousandSeparator, decimalSeparator) {
|
|
727
|
+
var stringValue = String(value).trim();
|
|
728
|
+
if (stringValue.includes(":")) {
|
|
729
|
+
var _stringValue$split = stringValue.split(":"),
|
|
730
|
+
_stringValue$split2 = _slicedToArray(_stringValue$split, 2),
|
|
731
|
+
hoursPart = _stringValue$split2[0],
|
|
732
|
+
minutesPart = _stringValue$split2[1];
|
|
733
|
+
var hours = parseFloat(hoursPart) || 0;
|
|
734
|
+
var minutes = parseFloat(minutesPart) || 0;
|
|
735
|
+
return hours + minutes / 60;
|
|
736
|
+
}
|
|
737
|
+
return +stringValue.replaceAll(thousandSeparator, "").replace(decimalSeparator, ".");
|
|
738
|
+
};
|
|
726
739
|
|
|
727
740
|
var validateStopwatchTime = function validateStopwatchTime(value) {
|
|
728
741
|
return /^([0-9]{0,2})?(((:([0-5][0-9])?)|(:[0-5]?))|(\.[0-9]{0,2})|(,[0-9]{0,2}))?$/g.test(value);
|
|
@@ -795,29 +808,36 @@
|
|
|
795
808
|
/**
|
|
796
809
|
* @function formatHours
|
|
797
810
|
* @description
|
|
798
|
-
* Formats a decimal number representing hours into a formatted string (HH:MM).
|
|
799
|
-
* The input can be a number, string, or undefined.
|
|
800
|
-
*
|
|
811
|
+
* Formats a decimal number representing hours into a formatted string (HH:MM) or a short form if needed.
|
|
812
|
+
* The input can be a number, string, or undefined. It handles various formats and can optionally add a
|
|
813
|
+
* leading zero to the hours component. With the new "format" argument, if set to "short" and the value is
|
|
814
|
+
* greater than or equal to 1000, it will return a shortened format (e.g., 1K) similar to formatNumber.
|
|
801
815
|
*
|
|
802
|
-
* @param {number | string | undefined} num - The input representing the hours
|
|
803
|
-
* @param {boolean} [withLeadingZeroHours=false] - Whether to add a leading zero to the hours part
|
|
816
|
+
* @param {number | string | undefined} num - The input representing the hours.
|
|
817
|
+
* @param {boolean} [withLeadingZeroHours=false] - Whether to add a leading zero to the hours part.
|
|
804
818
|
* @param {boolean} [trimZeroMinutes=false] - Whether to remove minutes if they are zero.
|
|
819
|
+
* @param {"long" | "short"} [format="long"] - The format type, either "long" for full numbers or "short" for abbreviated output.
|
|
805
820
|
*
|
|
806
|
-
* @returns {string} - A formatted time string
|
|
821
|
+
* @returns {string} - A formatted time string or a shortened string.
|
|
807
822
|
*
|
|
808
823
|
* @example
|
|
809
824
|
* formatHours(1.5) // "1:30"
|
|
810
825
|
* formatHours("3.5", true) // "03:30"
|
|
826
|
+
* formatHours(1500, false, false, "short") // "1K" (using formatNumber)
|
|
811
827
|
*/
|
|
812
828
|
var formatHours = function formatHours(num) {
|
|
813
829
|
var withLeadingZeroHours = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
814
830
|
var trimZeroMinutes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
831
|
+
var format = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "long";
|
|
832
|
+
// Handle the explicit zero case.
|
|
815
833
|
if (num === 0 || num === "0") {
|
|
816
834
|
return trimZeroMinutes ? "0" : withLeadingZeroHours ? "00:00" : "0:00";
|
|
817
835
|
}
|
|
818
836
|
if (!num) {
|
|
819
837
|
return "";
|
|
820
838
|
}
|
|
839
|
+
|
|
840
|
+
// If the input is in colon format, process it as before.
|
|
821
841
|
if (typeof num === "string" && num.indexOf(":") >= 0) {
|
|
822
842
|
// eslint-disable-next-line prefer-const
|
|
823
843
|
var _num$split = num.split(":"),
|
|
@@ -841,16 +861,27 @@
|
|
|
841
861
|
}
|
|
842
862
|
return withLeadingZeroHours ? "00:".concat(_minutes) : "0:".concat(_minutes);
|
|
843
863
|
}
|
|
864
|
+
|
|
865
|
+
// Replace comma with dot if needed.
|
|
844
866
|
if (typeof num === "string" && num.indexOf(",") >= 0) {
|
|
845
867
|
num = num.replace(",", ".");
|
|
846
868
|
}
|
|
847
869
|
var input = typeof num === "string" ? parseFloat(num) : num;
|
|
870
|
+
|
|
871
|
+
// Use short formatting if specified and the value is >= 1000.
|
|
872
|
+
if (format === "short" && input >= 1000) {
|
|
873
|
+
return formatNumber(input, ",", ".", true, 2, "short");
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
// For whole numbers.
|
|
848
877
|
if (!isDecimal(input)) {
|
|
849
878
|
if (trimZeroMinutes) {
|
|
850
879
|
return withLeadingZeroHours ? withLeadingZero(input) : String(Number(input));
|
|
851
880
|
}
|
|
852
881
|
return withLeadingZeroHours ? "".concat(withLeadingZero(input), ":00") : "".concat(input, ":00");
|
|
853
882
|
}
|
|
883
|
+
|
|
884
|
+
// Process decimal hours.
|
|
854
885
|
var decimal = input.toFixed(2);
|
|
855
886
|
var time = decimal.toString().split(".");
|
|
856
887
|
var hours = time[0];
|
|
@@ -858,11 +889,11 @@
|
|
|
858
889
|
hours = withLeadingZero(hours);
|
|
859
890
|
}
|
|
860
891
|
var minutes = time[1];
|
|
861
|
-
var
|
|
862
|
-
if (trimZeroMinutes &&
|
|
892
|
+
var minutesFormatted = Math.round(parseInt(minutes, 10) / 100 * 60);
|
|
893
|
+
if (trimZeroMinutes && minutesFormatted === 0) {
|
|
863
894
|
return hours;
|
|
864
895
|
}
|
|
865
|
-
return "".concat(hours, ":").concat(withLeadingZero(
|
|
896
|
+
return "".concat(hours, ":").concat(withLeadingZero(minutesFormatted));
|
|
866
897
|
};
|
|
867
898
|
var withLeadingZero = function withLeadingZero(num) {
|
|
868
899
|
var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
|
@@ -14632,7 +14663,8 @@
|
|
|
14632
14663
|
validation = _ref$validation === void 0 ? validateNumberInput : _ref$validation,
|
|
14633
14664
|
min = _ref.min,
|
|
14634
14665
|
max = _ref.max,
|
|
14635
|
-
onBlur = _ref.onBlur
|
|
14666
|
+
onBlur = _ref.onBlur,
|
|
14667
|
+
update = _ref.update;
|
|
14636
14668
|
var isMaxValid = max === undefined || min === undefined || Number(max) >= Number(min);
|
|
14637
14669
|
if (!isMaxValid) {
|
|
14638
14670
|
console.warn("Warning: The maximum value is set to be lower than the minimum value. The maximum value will be ignored.");
|
|
@@ -14661,19 +14693,19 @@
|
|
|
14661
14693
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
14662
14694
|
unformattedPrevValue = _useState8[0],
|
|
14663
14695
|
setUnformattedPrevValue = _useState8[1];
|
|
14696
|
+
var _useState9 = React.useState(false),
|
|
14697
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
14698
|
+
focused = _useState10[0],
|
|
14699
|
+
setFocused = _useState10[1];
|
|
14664
14700
|
React.useEffect(function () {
|
|
14665
|
-
if (value !== prevValue &&
|
|
14701
|
+
if (value !== prevValue && (!focused || update)) {
|
|
14666
14702
|
setCurrentValue(formatNumber(value, thousandSeparator, decimalSeparator, trimDecimals, decimalLength, disableAbbreviation ? "long" : "short"));
|
|
14667
14703
|
setPrevValue(formatNumber(value, thousandSeparator, decimalSeparator, trimDecimals, decimalLength, disableAbbreviation ? "long" : "short"));
|
|
14668
14704
|
setUnformattedValue(formatNumber(value, "", decimalSeparator, false, decimalLength, "long"));
|
|
14669
14705
|
setUnformattedPrevValue(formatNumber(value, "", decimalSeparator, false, decimalLength, "long"));
|
|
14670
14706
|
}
|
|
14671
14707
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
14672
|
-
}, [disableAbbreviation, thousandSeparator, decimalSeparator, decimalLength, trimDecimals, value]);
|
|
14673
|
-
var _useState9 = React.useState(false),
|
|
14674
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
14675
|
-
focused = _useState10[0],
|
|
14676
|
-
setFocused = _useState10[1];
|
|
14708
|
+
}, [disableAbbreviation, thousandSeparator, decimalSeparator, decimalLength, trimDecimals, value, focused]);
|
|
14677
14709
|
var escapeRef = React.useRef(false);
|
|
14678
14710
|
var handleBlur = React.useCallback(function (e) {
|
|
14679
14711
|
if (escapeRef.current) {
|
|
@@ -16170,7 +16202,7 @@
|
|
|
16170
16202
|
});
|
|
16171
16203
|
InputHours.displayName = "InputHours";
|
|
16172
16204
|
|
|
16173
|
-
var _excluded$J = ["decimalLength", "decimalSeparator", "disableAbbreviation", "disabled", "disableMacros", "invalid", "step", "thousandSeparator", "value", "onCancel", "onSave", "onEnterKeyPress", "allowEmptyValue", "onChange", "onClick", "limit", "placeholder", "trimDecimals", "min", "max", "onBlur"];
|
|
16205
|
+
var _excluded$J = ["decimalLength", "decimalSeparator", "disableAbbreviation", "disabled", "disableMacros", "invalid", "step", "thousandSeparator", "value", "onCancel", "onSave", "onEnterKeyPress", "allowEmptyValue", "onChange", "onClick", "limit", "placeholder", "trimDecimals", "min", "max", "onBlur", "update"];
|
|
16174
16206
|
var InputNumber = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
16175
16207
|
var _ref$decimalLength = _ref.decimalLength,
|
|
16176
16208
|
decimalLength = _ref$decimalLength === void 0 ? 2 : _ref$decimalLength,
|
|
@@ -16200,6 +16232,8 @@
|
|
|
16200
16232
|
min = _ref.min,
|
|
16201
16233
|
max = _ref.max,
|
|
16202
16234
|
externalOnBlur = _ref.onBlur,
|
|
16235
|
+
_ref$update = _ref.update,
|
|
16236
|
+
update = _ref$update === void 0 ? false : _ref$update,
|
|
16203
16237
|
rest = _objectWithoutProperties(_ref, _excluded$J);
|
|
16204
16238
|
var inputRef = React.useRef(null);
|
|
16205
16239
|
var handleRef = useForkRef(ref, inputRef);
|
|
@@ -16221,7 +16255,8 @@
|
|
|
16221
16255
|
trimDecimals,
|
|
16222
16256
|
min,
|
|
16223
16257
|
max,
|
|
16224
|
-
onBlur: externalOnBlur
|
|
16258
|
+
onBlur: externalOnBlur,
|
|
16259
|
+
update
|
|
16225
16260
|
}, inputRef),
|
|
16226
16261
|
value = _useInputNumber.value,
|
|
16227
16262
|
onBlur = _useInputNumber.onBlur,
|
|
@@ -17676,27 +17711,27 @@
|
|
|
17676
17711
|
_ref$as = _ref.as,
|
|
17677
17712
|
as = _ref$as === void 0 ? "span" : _ref$as,
|
|
17678
17713
|
rest = _objectWithoutProperties(_ref, _excluded$y);
|
|
17679
|
-
var numberValue =
|
|
17680
|
-
var
|
|
17681
|
-
var
|
|
17682
|
-
var
|
|
17683
|
-
if (
|
|
17714
|
+
var numberValue = parseValueToNumber(value, thousandSeparator, decimalSeparator);
|
|
17715
|
+
var shouldDisplayShort = format === "short" && numberValue >= 1000;
|
|
17716
|
+
var longValue = formatHours(numberValue, withLeadingZero, trimZeroMinutes, "long");
|
|
17717
|
+
var shortValue = formatNumber(numberValue, thousandSeparator, decimalSeparator, trimDecimals, decimalSpaces, "short");
|
|
17718
|
+
if (shouldDisplayShort) {
|
|
17684
17719
|
return /*#__PURE__*/React__default["default"].createElement(Tooltip, {
|
|
17685
|
-
title:
|
|
17720
|
+
title: formatHours(numberValue),
|
|
17686
17721
|
disable: disableTooltip
|
|
17687
17722
|
}, /*#__PURE__*/React__default["default"].createElement(Typography, _extends({
|
|
17688
17723
|
as: as,
|
|
17689
17724
|
variant: variant,
|
|
17690
17725
|
className: className,
|
|
17691
17726
|
ref: ref
|
|
17692
|
-
}, rest),
|
|
17727
|
+
}, rest), shortValue));
|
|
17693
17728
|
}
|
|
17694
17729
|
return /*#__PURE__*/React__default["default"].createElement(Typography, _extends({
|
|
17695
17730
|
as: as,
|
|
17696
17731
|
variant: variant,
|
|
17697
17732
|
className: className,
|
|
17698
17733
|
ref: ref
|
|
17699
|
-
}, rest),
|
|
17734
|
+
}, rest), longValue);
|
|
17700
17735
|
});
|
|
17701
17736
|
DisplayHours.displayName = "DisplayHours";
|
|
17702
17737
|
|