@activecollab/components 2.0.135 → 2.0.136
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/SelectTime/SelectTime.js +4 -2
- package/dist/cjs/components/SelectTime/SelectTime.js.map +1 -1
- package/dist/cjs/utils/timeUtils.js +3 -3
- package/dist/cjs/utils/timeUtils.js.map +1 -1
- package/dist/esm/components/SelectTime/SelectTime.d.ts +1 -0
- package/dist/esm/components/SelectTime/SelectTime.d.ts.map +1 -1
- package/dist/esm/components/SelectTime/SelectTime.js +2 -1
- package/dist/esm/components/SelectTime/SelectTime.js.map +1 -1
- package/dist/esm/utils/timeUtils.js +3 -3
- package/dist/esm/utils/timeUtils.js.map +1 -1
- package/dist/index.js +7 -5
- 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
|
@@ -9,7 +9,7 @@ var _moment = _interopRequireDefault(require("moment"));
|
|
|
9
9
|
var _timeUtils = require("../../utils/timeUtils");
|
|
10
10
|
var _Select = require("../Select/Select");
|
|
11
11
|
var _SelectTrigger = require("../SelectTrigger");
|
|
12
|
-
var _excluded = ["mode", "selected", "min", "max", "onChange", "target", "triggerMode"];
|
|
12
|
+
var _excluded = ["mode", "selected", "min", "max", "onChange", "target", "triggerMode", "step"];
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
14
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
15
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
@@ -24,6 +24,8 @@ var SelectTime = exports.SelectTime = function SelectTime(_ref) {
|
|
|
24
24
|
onChange = _ref.onChange,
|
|
25
25
|
target = _ref.target,
|
|
26
26
|
triggerMode = _ref.triggerMode,
|
|
27
|
+
_ref$step = _ref.step,
|
|
28
|
+
step = _ref$step === void 0 ? 15 : _ref$step,
|
|
27
29
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
28
30
|
var generateTimeOptions = function generateTimeOptions() {
|
|
29
31
|
var minTime = (0, _moment.default)((0, _timeUtils.isValidTime)(min) ? min : "00:00", "HH:mm");
|
|
@@ -35,7 +37,7 @@ var SelectTime = exports.SelectTime = function SelectTime(_ref) {
|
|
|
35
37
|
id: currentTime.format("HH:mm"),
|
|
36
38
|
name: currentTime.format(mode === "12" ? "hh:mm A" : "HH:mm")
|
|
37
39
|
});
|
|
38
|
-
currentTime.add(
|
|
40
|
+
currentTime.add(step, "minutes");
|
|
39
41
|
}
|
|
40
42
|
return options;
|
|
41
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectTime.js","names":["_react","_interopRequireDefault","require","_moment","_timeUtils","_Select","_SelectTrigger","_excluded","obj","__esModule","default","_extends","Object","assign","bind","target","i","arguments","length","source","key","prototype","hasOwnProperty","call","apply","_objectWithoutProperties","excluded","_objectWithoutPropertiesLoose","getOwnPropertySymbols","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","keys","SelectTime","exports","_ref","_ref$mode","mode","_ref$selected","selected","min","max","onChange","triggerMode","rest","generateTimeOptions","minTime","moment","isValidTime","maxTime","options","currentTime","clone","isSameOrBefore","push","id","format","name","add","timeOptions","displaySelectedTime","createElement","Select","disabledInternalSort","disableSearch","keepSameOptionsOrder","SelectTrigger","renderOption","_ref2","forceCloseMenu"],"sources":["../../../../src/components/SelectTime/SelectTime.tsx"],"sourcesContent":["import React from \"react\";\n\nimport moment from \"moment\";\n\nimport { isValidTime } from \"../../utils/timeUtils\";\nimport { InputMode } from \"../Input/types\";\nimport { IOptionItemProps } from \"../Select/Option\";\nimport { ElementWithRef, Select } from \"../Select/Select\";\nimport { SelectTrigger, SelectTriggerProps } from \"../SelectTrigger\";\n\nexport type Time24HourFormat = `${string}:${string}` | undefined;\n\nexport interface SelectTimeProps extends Omit<SelectTriggerProps, \"mode\"> {\n mode?: \"12\" | \"24\";\n selected?: Time24HourFormat;\n min?: Time24HourFormat;\n max?: Time24HourFormat;\n onChange?: () => void;\n target?: ElementWithRef<Element>;\n className?: string;\n triggerMode?: InputMode;\n locale?: string;\n trigger?: string;\n}\n\nexport const SelectTime: React.FC<SelectTimeProps> = ({\n mode = \"24\",\n selected = \"12:00\",\n min,\n max,\n onChange,\n target,\n triggerMode,\n ...rest\n}) => {\n const generateTimeOptions = (): IOptionItemProps[] => {\n const minTime = moment(isValidTime(min) ? min : \"00:00\", \"HH:mm\");\n const maxTime = moment(isValidTime(max) ? max : \"23:45\", \"HH:mm\");\n const options: IOptionItemProps[] = [];\n\n const currentTime = minTime.clone();\n while (currentTime.isSameOrBefore(maxTime)) {\n options.push({\n id: currentTime.format(\"HH:mm\"),\n name: currentTime.format(mode === \"12\" ? \"hh:mm A\" : \"HH:mm\"),\n });\n currentTime.add(
|
|
1
|
+
{"version":3,"file":"SelectTime.js","names":["_react","_interopRequireDefault","require","_moment","_timeUtils","_Select","_SelectTrigger","_excluded","obj","__esModule","default","_extends","Object","assign","bind","target","i","arguments","length","source","key","prototype","hasOwnProperty","call","apply","_objectWithoutProperties","excluded","_objectWithoutPropertiesLoose","getOwnPropertySymbols","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","keys","SelectTime","exports","_ref","_ref$mode","mode","_ref$selected","selected","min","max","onChange","triggerMode","_ref$step","step","rest","generateTimeOptions","minTime","moment","isValidTime","maxTime","options","currentTime","clone","isSameOrBefore","push","id","format","name","add","timeOptions","displaySelectedTime","createElement","Select","disabledInternalSort","disableSearch","keepSameOptionsOrder","SelectTrigger","renderOption","_ref2","forceCloseMenu"],"sources":["../../../../src/components/SelectTime/SelectTime.tsx"],"sourcesContent":["import React from \"react\";\n\nimport moment from \"moment\";\n\nimport { isValidTime } from \"../../utils/timeUtils\";\nimport { InputMode } from \"../Input/types\";\nimport { IOptionItemProps } from \"../Select/Option\";\nimport { ElementWithRef, Select } from \"../Select/Select\";\nimport { SelectTrigger, SelectTriggerProps } from \"../SelectTrigger\";\n\nexport type Time24HourFormat = `${string}:${string}` | undefined;\n\nexport interface SelectTimeProps extends Omit<SelectTriggerProps, \"mode\"> {\n mode?: \"12\" | \"24\";\n selected?: Time24HourFormat;\n min?: Time24HourFormat;\n max?: Time24HourFormat;\n onChange?: () => void;\n target?: ElementWithRef<Element>;\n className?: string;\n triggerMode?: InputMode;\n locale?: string;\n trigger?: string;\n step?: number;\n}\n\nexport const SelectTime: React.FC<SelectTimeProps> = ({\n mode = \"24\",\n selected = \"12:00\",\n min,\n max,\n onChange,\n target,\n triggerMode,\n step = 15,\n ...rest\n}) => {\n const generateTimeOptions = (): IOptionItemProps[] => {\n const minTime = moment(isValidTime(min) ? min : \"00:00\", \"HH:mm\");\n const maxTime = moment(isValidTime(max) ? max : \"23:45\", \"HH:mm\");\n const options: IOptionItemProps[] = [];\n\n const currentTime = minTime.clone();\n while (currentTime.isSameOrBefore(maxTime)) {\n options.push({\n id: currentTime.format(\"HH:mm\"),\n name: currentTime.format(mode === \"12\" ? \"hh:mm A\" : \"HH:mm\"),\n });\n currentTime.add(step, \"minutes\");\n }\n\n return options;\n };\n\n const timeOptions = generateTimeOptions();\n\n const displaySelectedTime = moment(selected, \"HH:mm\").format(\n mode === \"12\" ? \"hh:mm A\" : \"HH:mm\"\n );\n\n return (\n <Select\n options={timeOptions}\n disabledInternalSort\n selected={selected}\n disableSearch\n keepSameOptionsOrder\n target={\n target ? (\n target\n ) : (\n <SelectTrigger mode={triggerMode} {...rest}>\n {displaySelectedTime}\n </SelectTrigger>\n )\n }\n mode=\"tiny\"\n renderOption={({ name }) => <div>{name}</div>}\n onChange={onChange}\n forceCloseMenu\n />\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,UAAA,GAAAF,OAAA;AAGA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AAAqE,IAAAK,SAAA;AAAA,SAAAN,uBAAAO,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,SAAA,IAAAA,QAAA,GAAAC,MAAA,CAAAC,MAAA,GAAAD,MAAA,CAAAC,MAAA,CAAAC,IAAA,eAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,GAAAF,SAAA,CAAAD,CAAA,YAAAI,GAAA,IAAAD,MAAA,QAAAP,MAAA,CAAAS,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAJ,MAAA,EAAAC,GAAA,KAAAL,MAAA,CAAAK,GAAA,IAAAD,MAAA,CAAAC,GAAA,gBAAAL,MAAA,YAAAJ,QAAA,CAAAa,KAAA,OAAAP,SAAA;AAAA,SAAAQ,yBAAAN,MAAA,EAAAO,QAAA,QAAAP,MAAA,yBAAAJ,MAAA,GAAAY,6BAAA,CAAAR,MAAA,EAAAO,QAAA,OAAAN,GAAA,EAAAJ,CAAA,MAAAJ,MAAA,CAAAgB,qBAAA,QAAAC,gBAAA,GAAAjB,MAAA,CAAAgB,qBAAA,CAAAT,MAAA,QAAAH,CAAA,MAAAA,CAAA,GAAAa,gBAAA,CAAAX,MAAA,EAAAF,CAAA,MAAAI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M;IAAY,GAAKG,IAAI,GACvCgB,mBACY,CAElB;IACDzB,IAAI,EAAC,MAAM;IACXgC,YAAY,EAAE,SAAAA,aAAAC,KAAA;MAAA,IAAGX,IAAI,GAAAW,KAAA,CAAJX,IAAI;MAAA,oBAAO5D,MAAA,CAAAU,OAAA,CAAAsD,aAAA,cAAMJ,IAAU,CAAC;IAAA,CAAC;IAC9CjB,QAAQ,EAAEA,QAAS;IACnB6B,cAAc;EAAA,CACf,CAAC;AAEN,CAAC"}
|
|
@@ -28,12 +28,12 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
28
28
|
*/
|
|
29
29
|
var formatHours = exports.formatHours = function formatHours(num) {
|
|
30
30
|
var withLeadingZeroHours = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
31
|
+
if (num === 0 || num === "0") {
|
|
32
|
+
return withLeadingZeroHours ? "00:00" : "0:00";
|
|
33
|
+
}
|
|
31
34
|
if (!num) {
|
|
32
35
|
return "";
|
|
33
36
|
}
|
|
34
|
-
if (typeof num === "string" && !num) {
|
|
35
|
-
return withLeadingZeroHours ? "00:00" : "0:00";
|
|
36
|
-
}
|
|
37
37
|
if (typeof num === "string" && num.indexOf(":") >= 0) {
|
|
38
38
|
//eslint-disable-next-line
|
|
39
39
|
var _num$split = num.split(":"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeUtils.js","names":["formatHours","exports","num","withLeadingZeroHours","arguments","length","undefined","indexOf","_num$split","split","_num$split2","_slicedToArray","_hours","_minutes","Number","concat","withLeadingZero","replace","input","parseFloat","isDecimal","decimal","toFixed","time","toString","hours","minutes","minutes_formatted","Math","round","parseInt","size","s","isInteger","isValidTime","test"],"sources":["../../../src/utils/timeUtils.ts"],"sourcesContent":["/**\n * @function formatHours\n * @description\n * Formats a decimal number representing hours into a formatted string (HH:MM).\n * The input can be a number, string, or undefined. The function handles various formats\n * and can optionally add a leading zero to the hours component.\n *\n * @param {number | string | undefined} num - The input representing the hours, which can be in decimal format, a time string, or undefined.\n * @param {boolean} [withLeadingZeroHours=false] - Whether to add a leading zero to the hours part of the output.\n *\n * @returns {string} - A formatted time string in HH:MM format.\n *\n * @example\n * formatHours(1.5) // \"1:30\"\n * formatHours(\"3.5\", true) // \"03:30\"\n */\nexport const formatHours = (\n num: number | string | undefined,\n withLeadingZeroHours = false\n): string => {\n if (
|
|
1
|
+
{"version":3,"file":"timeUtils.js","names":["formatHours","exports","num","withLeadingZeroHours","arguments","length","undefined","indexOf","_num$split","split","_num$split2","_slicedToArray","_hours","_minutes","Number","concat","withLeadingZero","replace","input","parseFloat","isDecimal","decimal","toFixed","time","toString","hours","minutes","minutes_formatted","Math","round","parseInt","size","s","isInteger","isValidTime","test"],"sources":["../../../src/utils/timeUtils.ts"],"sourcesContent":["/**\n * @function formatHours\n * @description\n * Formats a decimal number representing hours into a formatted string (HH:MM).\n * The input can be a number, string, or undefined. The function handles various formats\n * and can optionally add a leading zero to the hours component.\n *\n * @param {number | string | undefined} num - The input representing the hours, which can be in decimal format, a time string, or undefined.\n * @param {boolean} [withLeadingZeroHours=false] - Whether to add a leading zero to the hours part of the output.\n *\n * @returns {string} - A formatted time string in HH:MM format.\n *\n * @example\n * formatHours(1.5) // \"1:30\"\n * formatHours(\"3.5\", true) // \"03:30\"\n */\nexport const formatHours = (\n num: number | string | undefined,\n withLeadingZeroHours = false\n): string => {\n if (num === 0 || num === \"0\") {\n return withLeadingZeroHours ? \"00:00\" : \"0:00\";\n }\n if (!num) {\n return \"\";\n }\n if (typeof num === \"string\" && num.indexOf(\":\") >= 0) {\n //eslint-disable-next-line\n let [_hours, _minutes] = num.split(\":\");\n if (_minutes && _minutes.length === 1 && Number(_minutes) < 10) {\n _minutes = `${Number(_minutes)}0`;\n }\n if (_hours && _minutes) {\n if (withLeadingZeroHours) {\n return `${withLeadingZero(_hours)}:${_minutes}`;\n }\n return `${_hours}:${_minutes}`;\n } else if (!_hours && _minutes) {\n return withLeadingZeroHours ? `00:${_minutes}` : `0:${_minutes}`;\n } else if (!_minutes && _hours) {\n return withLeadingZeroHours\n ? `${withLeadingZero(_hours)}:00`\n : `${_hours}:00`;\n } else {\n return withLeadingZeroHours ? `00:00` : \"0:00\";\n }\n }\n if (typeof num === \"string\" && num.indexOf(\",\") >= 0) {\n num = num.replace(\",\", \".\");\n }\n const input = typeof num === \"string\" ? parseFloat(num) : num;\n\n if (!isDecimal(input)) {\n if (withLeadingZeroHours) {\n return `${withLeadingZero(input)}:00`;\n }\n return `${input}:00`;\n }\n\n const decimal = input.toFixed(2);\n const time = decimal.toString().split(\".\");\n let hours: string = time[0];\n if (withLeadingZeroHours) {\n hours = withLeadingZero(hours);\n }\n const minutes: string = time[1];\n const minutes_formatted = Math.round((parseInt(minutes, 10) / 100) * 60);\n\n return `${hours}:${withLeadingZero(minutes_formatted)}`;\n};\n\nexport const withLeadingZero = (num: string | number, size = 2) => {\n let s = `${num}`;\n while (s.length < size) s = `0` + s;\n return s;\n};\n\nexport const isDecimal = (num: number): boolean => {\n return !Number.isInteger(num);\n};\n\nexport const isValidTime = (time: string | undefined): boolean => {\n return time === undefined || /^([01]\\d|2[0-3]):([0-5]\\d)$/.test(time);\n};\n"],"mappings":";;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,SAAdA,WAAWA,CACtBE,GAAgC,EAErB;EAAA,IADXC,oBAAoB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAE5B,IAAIF,GAAG,KAAK,CAAC,IAAIA,GAAG,KAAK,GAAG,EAAE;IAC5B,OAAOC,oBAAoB,GAAG,OAAO,GAAG,MAAM;EAChD;EACA,IAAI,CAACD,GAAG,EAAE;IACR,OAAO,EAAE;EACX;EACA,IAAI,OAAOA,GAAG,KA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AAC/B,GAAG,CAAC;AAC/B,CAAC;AAEM,IAAMgC,WAAW,GAAAjC,OAAA,CAAAiC,WAAA,GAAG,SAAdA,WAAWA,CAAIX,IAAwB,EAAc;EAChE,OAAOA,IAAI,KAAKjB,SAAS,IAAI,6BAA6B,CAAC6B,IAAI,CAACZ,IAAI,CAAC;AACvE,CAAC"}
|
|
@@ -14,6 +14,7 @@ export interface SelectTimeProps extends Omit<SelectTriggerProps, "mode"> {
|
|
|
14
14
|
triggerMode?: InputMode;
|
|
15
15
|
locale?: string;
|
|
16
16
|
trigger?: string;
|
|
17
|
+
step?: number;
|
|
17
18
|
}
|
|
18
19
|
export declare const SelectTime: React.FC<SelectTimeProps>;
|
|
19
20
|
//# sourceMappingURL=SelectTime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectTime.d.ts","sourceRoot":"","sources":["../../../../src/components/SelectTime/SelectTime.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,cAAc,EAAU,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAiB,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAErE,MAAM,MAAM,gBAAgB,GAAG,GAAG,MAAM,IAAI,MAAM,EAAE,GAAG,SAAS,CAAC;AAEjE,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACvE,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,GAAG,CAAC,EAAE,gBAAgB,CAAC;IACvB,GAAG,CAAC,EAAE,gBAAgB,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"SelectTime.d.ts","sourceRoot":"","sources":["../../../../src/components/SelectTime/SelectTime.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,cAAc,EAAU,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAiB,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAErE,MAAM,MAAM,gBAAgB,GAAG,GAAG,MAAM,IAAI,MAAM,EAAE,GAAG,SAAS,CAAC;AAEjE,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACvE,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,GAAG,CAAC,EAAE,gBAAgB,CAAC;IACvB,GAAG,CAAC,EAAE,gBAAgB,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAwDhD,CAAC"}
|
|
@@ -13,6 +13,7 @@ export const SelectTime = _ref => {
|
|
|
13
13
|
onChange,
|
|
14
14
|
target,
|
|
15
15
|
triggerMode,
|
|
16
|
+
step = 15,
|
|
16
17
|
...rest
|
|
17
18
|
} = _ref;
|
|
18
19
|
const generateTimeOptions = () => {
|
|
@@ -25,7 +26,7 @@ export const SelectTime = _ref => {
|
|
|
25
26
|
id: currentTime.format("HH:mm"),
|
|
26
27
|
name: currentTime.format(mode === "12" ? "hh:mm A" : "HH:mm")
|
|
27
28
|
});
|
|
28
|
-
currentTime.add(
|
|
29
|
+
currentTime.add(step, "minutes");
|
|
29
30
|
}
|
|
30
31
|
return options;
|
|
31
32
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectTime.js","names":["React","moment","isValidTime","Select","SelectTrigger","SelectTime","_ref","mode","selected","min","max","onChange","target","triggerMode","rest","generateTimeOptions","minTime","maxTime","options","currentTime","clone","isSameOrBefore","push","id","format","name","add","timeOptions","displaySelectedTime","createElement","disabledInternalSort","disableSearch","keepSameOptionsOrder","_extends","renderOption","_ref2","forceCloseMenu"],"sources":["../../../../src/components/SelectTime/SelectTime.tsx"],"sourcesContent":["import React from \"react\";\n\nimport moment from \"moment\";\n\nimport { isValidTime } from \"../../utils/timeUtils\";\nimport { InputMode } from \"../Input/types\";\nimport { IOptionItemProps } from \"../Select/Option\";\nimport { ElementWithRef, Select } from \"../Select/Select\";\nimport { SelectTrigger, SelectTriggerProps } from \"../SelectTrigger\";\n\nexport type Time24HourFormat = `${string}:${string}` | undefined;\n\nexport interface SelectTimeProps extends Omit<SelectTriggerProps, \"mode\"> {\n mode?: \"12\" | \"24\";\n selected?: Time24HourFormat;\n min?: Time24HourFormat;\n max?: Time24HourFormat;\n onChange?: () => void;\n target?: ElementWithRef<Element>;\n className?: string;\n triggerMode?: InputMode;\n locale?: string;\n trigger?: string;\n}\n\nexport const SelectTime: React.FC<SelectTimeProps> = ({\n mode = \"24\",\n selected = \"12:00\",\n min,\n max,\n onChange,\n target,\n triggerMode,\n ...rest\n}) => {\n const generateTimeOptions = (): IOptionItemProps[] => {\n const minTime = moment(isValidTime(min) ? min : \"00:00\", \"HH:mm\");\n const maxTime = moment(isValidTime(max) ? max : \"23:45\", \"HH:mm\");\n const options: IOptionItemProps[] = [];\n\n const currentTime = minTime.clone();\n while (currentTime.isSameOrBefore(maxTime)) {\n options.push({\n id: currentTime.format(\"HH:mm\"),\n name: currentTime.format(mode === \"12\" ? \"hh:mm A\" : \"HH:mm\"),\n });\n currentTime.add(
|
|
1
|
+
{"version":3,"file":"SelectTime.js","names":["React","moment","isValidTime","Select","SelectTrigger","SelectTime","_ref","mode","selected","min","max","onChange","target","triggerMode","step","rest","generateTimeOptions","minTime","maxTime","options","currentTime","clone","isSameOrBefore","push","id","format","name","add","timeOptions","displaySelectedTime","createElement","disabledInternalSort","disableSearch","keepSameOptionsOrder","_extends","renderOption","_ref2","forceCloseMenu"],"sources":["../../../../src/components/SelectTime/SelectTime.tsx"],"sourcesContent":["import React from \"react\";\n\nimport moment from \"moment\";\n\nimport { isValidTime } from \"../../utils/timeUtils\";\nimport { InputMode } from \"../Input/types\";\nimport { IOptionItemProps } from \"../Select/Option\";\nimport { ElementWithRef, Select } from \"../Select/Select\";\nimport { SelectTrigger, SelectTriggerProps } from \"../SelectTrigger\";\n\nexport type Time24HourFormat = `${string}:${string}` | undefined;\n\nexport interface SelectTimeProps extends Omit<SelectTriggerProps, \"mode\"> {\n mode?: \"12\" | \"24\";\n selected?: Time24HourFormat;\n min?: Time24HourFormat;\n max?: Time24HourFormat;\n onChange?: () => void;\n target?: ElementWithRef<Element>;\n className?: string;\n triggerMode?: InputMode;\n locale?: string;\n trigger?: string;\n step?: number;\n}\n\nexport const SelectTime: React.FC<SelectTimeProps> = ({\n mode = \"24\",\n selected = \"12:00\",\n min,\n max,\n onChange,\n target,\n triggerMode,\n step = 15,\n ...rest\n}) => {\n const generateTimeOptions = (): IOptionItemProps[] => {\n const minTime = moment(isValidTime(min) ? min : \"00:00\", \"HH:mm\");\n const maxTime = moment(isValidTime(max) ? max : \"23:45\", \"HH:mm\");\n const options: IOptionItemProps[] = [];\n\n const currentTime = minTime.clone();\n while (currentTime.isSameOrBefore(maxTime)) {\n options.push({\n id: currentTime.format(\"HH:mm\"),\n name: currentTime.format(mode === \"12\" ? \"hh:mm A\" : \"HH:mm\"),\n });\n currentTime.add(step, \"minutes\");\n }\n\n return options;\n };\n\n const timeOptions = generateTimeOptions();\n\n const displaySelectedTime = moment(selected, \"HH:mm\").format(\n mode === \"12\" ? \"hh:mm A\" : \"HH:mm\"\n );\n\n return (\n <Select\n options={timeOptions}\n disabledInternalSort\n selected={selected}\n disableSearch\n keepSameOptionsOrder\n target={\n target ? (\n target\n ) : (\n <SelectTrigger mode={triggerMode} {...rest}>\n {displaySelectedTime}\n </SelectTrigger>\n )\n }\n mode=\"tiny\"\n renderOption={({ name }) => <div>{name}</div>}\n onChange={onChange}\n forceCloseMenu\n />\n );\n};\n"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,OAAOC,MAAM,MAAM,QAAQ;AAE3B,SAASC,WAAW,QAAQ,uBAAuB;AAGnD,SAAyBC,MAAM,QAAQ,kBAAkB;AACzD,SAASC,aAAa,QAA4B,kBAAkB;AAkBpE,OAAO,MAAMC,UAAqC,GAAGC,IAAA,IAU/C;EAAA,IAVgD;IACpDC,IAAI,GAAG,IAAI;IACXC,QAAQ,GAAG,OAAO;IAClBC,GAAG;IACHC,GAAG;IACHC,QAAQ;IACRC,MAAM;IACNC,WAAW;IACXC,IAAI,GAAG,EAAE;IACT,GAAGC;EACL,CAAC,GAAAT,IAAA;EACC,MAAMU,mBAAmB,GAAGA,CAAA,KAA0B;IACpD,MAAMC,OAAO,GAAGhB,MAAM,CAACC,WAAW,CAACO,GAAG,CAAC,GAAGA,GAAG,GAAG,OAAO,EAAE,OAAO,CAAC;IACjE,MAAMS,OAAO,GAAGjB,MAAM,CAACC,WAAW,CAACQ,GAAG,CAAC,GAAGA,GAAG,GAAG,OAAO,EAAE,OAAO,CAAC;IACjE,MAAMS,OAA2B,GAAG,EAAE;IAEtC,MAAMC,WAAW,GAAGH,OAAO,CAACI,KAAK,CAAC,CAAC;IACnC,OAAOD,WAAW,CAACE,cAAc,CAACJ,OAAO,CAAC,EAAE;MAC1CC,OAAO,CAACI,IAAI,CAAC;QACXC,EAAE,EAAEJ,WAAW,CAACK,MAAM,CAAC,OAAO,CAAC;QAC/BC,IAAI,EAAEN,WAAW,CAACK,MAAM,CAAClB,IAAI,KAAK,IAAI,GAAG,SAAS,GAAG,OAAO;MAC9D,CAAC,CAAC;MACFa,WAAW,CAACO,GAAG,CAACb,IAAI,EAAE,SAAS,CAAC;IAClC;IAEA,OAAOK,OAAO;EAChB,CAAC;EAED,MAAMS,WAAW,GAAGZ,mBAAmB,CAAC,CAAC;EAEzC,MAAMa,mBAAmB,GAAG5B,MAAM,CAACO,QAAQ,EAAE,OAAO,CAAC,CAACiB,MAAM,CAC1DlB,IAAI,KAAK,IAAI,GAAG,SAAS,GAAG,OAC9B,CAAC;EAED,oBACEP,KAAA,CAAA8B,aAAA,CAAC3B,MAAM;IACLgB,OAAO,EAAES,WAAY;IACrBG,oBAAoB;IACpBvB,QAAQ,EAAEA,QAAS;IACnBwB,aAAa;IACbC,oBAAoB;IACpBrB,MAAM,EACJA,MAAM,GACJA,MAAM,gBAENZ,KAAA,CAAA8B,aAAA,CAAC1B,aAAa,EAAA8B,QAAA;MAAC3B,IAAI,EAAEM;IAAY,GAAKE,IAAI,GACvCc,mBACY,CAElB;IACDtB,IAAI,EAAC,MAAM;IACX4B,YAAY,EAAEC,KAAA;MAAA,IAAC;QAAEV;MAAK,CAAC,GAAAU,KAAA;MAAA,oBAAKpC,KAAA,CAAA8B,aAAA,cAAMJ,IAAU,CAAC;IAAA,CAAC;IAC9Cf,QAAQ,EAAEA,QAAS;IACnB0B,cAAc;EAAA,CACf,CAAC;AAEN,CAAC"}
|
|
@@ -18,12 +18,12 @@ export const formatHours = function (num, withLeadingZeroHours) {
|
|
|
18
18
|
if (withLeadingZeroHours === void 0) {
|
|
19
19
|
withLeadingZeroHours = false;
|
|
20
20
|
}
|
|
21
|
+
if (num === 0 || num === "0") {
|
|
22
|
+
return withLeadingZeroHours ? "00:00" : "0:00";
|
|
23
|
+
}
|
|
21
24
|
if (!num) {
|
|
22
25
|
return "";
|
|
23
26
|
}
|
|
24
|
-
if (typeof num === "string" && !num) {
|
|
25
|
-
return withLeadingZeroHours ? "00:00" : "0:00";
|
|
26
|
-
}
|
|
27
27
|
if (typeof num === "string" && num.indexOf(":") >= 0) {
|
|
28
28
|
//eslint-disable-next-line
|
|
29
29
|
let [_hours, _minutes] = num.split(":");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeUtils.js","names":["formatHours","num","withLeadingZeroHours","indexOf","_hours","_minutes","split","length","Number","withLeadingZero","replace","input","parseFloat","isDecimal","decimal","toFixed","time","toString","hours","minutes","minutes_formatted","Math","round","parseInt","size","s","isInteger","isValidTime","undefined","test"],"sources":["../../../src/utils/timeUtils.ts"],"sourcesContent":["/**\n * @function formatHours\n * @description\n * Formats a decimal number representing hours into a formatted string (HH:MM).\n * The input can be a number, string, or undefined. The function handles various formats\n * and can optionally add a leading zero to the hours component.\n *\n * @param {number | string | undefined} num - The input representing the hours, which can be in decimal format, a time string, or undefined.\n * @param {boolean} [withLeadingZeroHours=false] - Whether to add a leading zero to the hours part of the output.\n *\n * @returns {string} - A formatted time string in HH:MM format.\n *\n * @example\n * formatHours(1.5) // \"1:30\"\n * formatHours(\"3.5\", true) // \"03:30\"\n */\nexport const formatHours = (\n num: number | string | undefined,\n withLeadingZeroHours = false\n): string => {\n if (
|
|
1
|
+
{"version":3,"file":"timeUtils.js","names":["formatHours","num","withLeadingZeroHours","indexOf","_hours","_minutes","split","length","Number","withLeadingZero","replace","input","parseFloat","isDecimal","decimal","toFixed","time","toString","hours","minutes","minutes_formatted","Math","round","parseInt","size","s","isInteger","isValidTime","undefined","test"],"sources":["../../../src/utils/timeUtils.ts"],"sourcesContent":["/**\n * @function formatHours\n * @description\n * Formats a decimal number representing hours into a formatted string (HH:MM).\n * The input can be a number, string, or undefined. The function handles various formats\n * and can optionally add a leading zero to the hours component.\n *\n * @param {number | string | undefined} num - The input representing the hours, which can be in decimal format, a time string, or undefined.\n * @param {boolean} [withLeadingZeroHours=false] - Whether to add a leading zero to the hours part of the output.\n *\n * @returns {string} - A formatted time string in HH:MM format.\n *\n * @example\n * formatHours(1.5) // \"1:30\"\n * formatHours(\"3.5\", true) // \"03:30\"\n */\nexport const formatHours = (\n num: number | string | undefined,\n withLeadingZeroHours = false\n): string => {\n if (num === 0 || num === \"0\") {\n return withLeadingZeroHours ? \"00:00\" : \"0:00\";\n }\n if (!num) {\n return \"\";\n }\n if (typeof num === \"string\" && num.indexOf(\":\") >= 0) {\n //eslint-disable-next-line\n let [_hours, _minutes] = num.split(\":\");\n if (_minutes && _minutes.length === 1 && Number(_minutes) < 10) {\n _minutes = `${Number(_minutes)}0`;\n }\n if (_hours && _minutes) {\n if (withLeadingZeroHours) {\n return `${withLeadingZero(_hours)}:${_minutes}`;\n }\n return `${_hours}:${_minutes}`;\n } else if (!_hours && _minutes) {\n return withLeadingZeroHours ? `00:${_minutes}` : `0:${_minutes}`;\n } else if (!_minutes && _hours) {\n return withLeadingZeroHours\n ? `${withLeadingZero(_hours)}:00`\n : `${_hours}:00`;\n } else {\n return withLeadingZeroHours ? `00:00` : \"0:00\";\n }\n }\n if (typeof num === \"string\" && num.indexOf(\",\") >= 0) {\n num = num.replace(\",\", \".\");\n }\n const input = typeof num === \"string\" ? parseFloat(num) : num;\n\n if (!isDecimal(input)) {\n if (withLeadingZeroHours) {\n return `${withLeadingZero(input)}:00`;\n }\n return `${input}:00`;\n }\n\n const decimal = input.toFixed(2);\n const time = decimal.toString().split(\".\");\n let hours: string = time[0];\n if (withLeadingZeroHours) {\n hours = withLeadingZero(hours);\n }\n const minutes: string = time[1];\n const minutes_formatted = Math.round((parseInt(minutes, 10) / 100) * 60);\n\n return `${hours}:${withLeadingZero(minutes_formatted)}`;\n};\n\nexport const withLeadingZero = (num: string | number, size = 2) => {\n let s = `${num}`;\n while (s.length < size) s = `0` + s;\n return s;\n};\n\nexport const isDecimal = (num: number): boolean => {\n return !Number.isInteger(num);\n};\n\nexport const isValidTime = (time: string | undefined): boolean => {\n return time === undefined || /^([01]\\d|2[0-3]):([0-5]\\d)$/.test(time);\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,WAAW,GAAG,SAAAA,CACzBC,GAAgC,EAChCC,oBAAoB,EACT;EAAA,IADXA,oBAAoB;IAApBA,oBAAoB,GAAG,KAAK;EAAA;EAE5B,IAAID,GAAG,KAAK,CAAC,IAAIA,GAAG,KAAK,GAAG,EAAE;IAC5B,OAAOC,oBAAoB,GAAG,OAAO,GAAG,MAAM;EAChD;EACA,IAAI,CAACD,GAAG,EAAE;IACR,OAAO,EAAE;EACX;EACA,IAAI,OAAOA,GAAG,KAAK,QAAQ,IAAIA,GAAG,CAACE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;IACpD;IACA,IAAI,CAACC,MAAM,EAAEC,QAAQ,CAAC,GAAGJ,GAAG,CAACK,KAAK,CAAC,GAAG,CAAC;IACvC,IAAID,QAAQ,IAAIA,QAAQ,CAACE,MAAM,KAAK,CAAC,IAAIC,MAAM,CAACH,QAAQ,CAAC,GAAG,EAAE,EAAE;MAC9DA,QAAQ,GAAMG,MAAM,CAACH,QAAQ,CAAC,MAAG;IACnC;IACA,IAAID,MAAM,IAAIC,QAAQ,EAAE;MACtB,IAAIH,oBAAoB,EAAE;QACxB,OAAUO,eAAe,CAACL,MAAM,CAAC,SAAIC,QAAQ;MAC/C;MACA,OAAUD,MAAM,SAAIC,QAAQ;IAC9B,CAAC,MAAM,IAAI,CAACD,MAAM,IAAIC,QAAQ,EAAE;MAC9B,OAAOH,oBAAoB,WAASG,QAAQ,UAAUA,QAAU;IAClE,CAAC,MAAM,IAAI,CAACA,QAAQ,IAAID,MAAM,EAAE;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AAOwB,CAAC,CAAClB,MAAM,GAAGiB,IAAI,EAAEC,CAAC,GAAG,MAAMA,CAAC;EACnC,OAAOA,CAAC;AACV,CAAC;AAED,OAAO,MAAMZ,SAAS,GAAIZ,GAAW,IAAc;EACjD,OAAO,CAACO,MAAM,CAACkB,SAAS,CAACzB,GAAG,CAAC;AAC/B,CAAC;AAED,OAAO,MAAM0B,WAAW,GAAIX,IAAwB,IAAc;EAChE,OAAOA,IAAI,KAAKY,SAAS,IAAI,6BAA6B,CAACC,IAAI,CAACb,IAAI,CAAC;AACvE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -785,12 +785,12 @@
|
|
|
785
785
|
*/
|
|
786
786
|
var formatHours = function formatHours(num) {
|
|
787
787
|
var withLeadingZeroHours = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
788
|
+
if (num === 0 || num === "0") {
|
|
789
|
+
return withLeadingZeroHours ? "00:00" : "0:00";
|
|
790
|
+
}
|
|
788
791
|
if (!num) {
|
|
789
792
|
return "";
|
|
790
793
|
}
|
|
791
|
-
if (typeof num === "string" && !num) {
|
|
792
|
-
return withLeadingZeroHours ? "00:00" : "0:00";
|
|
793
|
-
}
|
|
794
794
|
if (typeof num === "string" && num.indexOf(":") >= 0) {
|
|
795
795
|
//eslint-disable-next-line
|
|
796
796
|
var _num$split = num.split(":"),
|
|
@@ -16918,7 +16918,7 @@
|
|
|
16918
16918
|
});
|
|
16919
16919
|
SelectTrigger.displayName = "SelectTrigger";
|
|
16920
16920
|
|
|
16921
|
-
var _excluded$n = ["mode", "selected", "min", "max", "onChange", "target", "triggerMode"];
|
|
16921
|
+
var _excluded$n = ["mode", "selected", "min", "max", "onChange", "target", "triggerMode", "step"];
|
|
16922
16922
|
var SelectTime = function SelectTime(_ref) {
|
|
16923
16923
|
var _ref$mode = _ref.mode,
|
|
16924
16924
|
mode = _ref$mode === void 0 ? "24" : _ref$mode,
|
|
@@ -16929,6 +16929,8 @@
|
|
|
16929
16929
|
onChange = _ref.onChange,
|
|
16930
16930
|
target = _ref.target,
|
|
16931
16931
|
triggerMode = _ref.triggerMode,
|
|
16932
|
+
_ref$step = _ref.step,
|
|
16933
|
+
step = _ref$step === void 0 ? 15 : _ref$step,
|
|
16932
16934
|
rest = _objectWithoutProperties(_ref, _excluded$n);
|
|
16933
16935
|
var generateTimeOptions = function generateTimeOptions() {
|
|
16934
16936
|
var minTime = moment__default["default"](isValidTime(min) ? min : "00:00", "HH:mm");
|
|
@@ -16940,7 +16942,7 @@
|
|
|
16940
16942
|
id: currentTime.format("HH:mm"),
|
|
16941
16943
|
name: currentTime.format(mode === "12" ? "hh:mm A" : "HH:mm")
|
|
16942
16944
|
});
|
|
16943
|
-
currentTime.add(
|
|
16945
|
+
currentTime.add(step, "minutes");
|
|
16944
16946
|
}
|
|
16945
16947
|
return options;
|
|
16946
16948
|
};
|