@activecollab/components 2.0.126 → 2.0.128
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/Input/InputSelect.js +6 -1
- package/dist/cjs/components/Input/InputSelect.js.map +1 -1
- package/dist/cjs/components/SelectTime/SelectTime.js +62 -0
- package/dist/cjs/components/SelectTime/SelectTime.js.map +1 -0
- package/dist/cjs/components/SelectTime/index.js +17 -0
- package/dist/cjs/components/SelectTime/index.js.map +1 -0
- package/dist/cjs/components/index.js +11 -0
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/cjs/utils/timeUtils.js +4 -1
- package/dist/cjs/utils/timeUtils.js.map +1 -1
- package/dist/esm/components/Input/InputSelect.js +6 -1
- package/dist/esm/components/Input/InputSelect.js.map +1 -1
- package/dist/esm/components/SelectTime/SelectTime.d.ts +19 -0
- package/dist/esm/components/SelectTime/SelectTime.d.ts.map +1 -0
- package/dist/esm/components/SelectTime/SelectTime.js +54 -0
- package/dist/esm/components/SelectTime/SelectTime.js.map +1 -0
- package/dist/esm/components/SelectTime/index.d.ts +2 -0
- package/dist/esm/components/SelectTime/index.d.ts.map +1 -0
- package/dist/esm/components/SelectTime/index.js +2 -0
- package/dist/esm/components/SelectTime/index.js.map +1 -0
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/utils/timeUtils.d.ts +1 -0
- package/dist/esm/utils/timeUtils.d.ts.map +1 -1
- package/dist/esm/utils/timeUtils.js +3 -0
- package/dist/esm/utils/timeUtils.js.map +1 -1
- package/dist/index.js +204 -149
- 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
|
@@ -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"],"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) {\n return \"\";\n }\n if (typeof num === \"string\" && !num) {\n return withLeadingZeroHours ? `00:00` : \"0:00\";\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"],"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,IAAI,CAACD,GAAG,EAAE;IACR,OAAO,EAAE;EACX;EACA,IAAI,OAAOA,GAAG,KAAK,QAAQ,IAAI,CAACA,GAAG,EAAE;IACnC,OAAOC,oBAAoB,aAAa,MAAM;EAChD;EACA,IAAI,OAAOD,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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AAEuB,IAAI,EAAS;EAAA,IAAbA,IAAI;IAAJA,IAAI,GAAG,CAAC;EAAA;EAC5D,IAAIC,CAAC,QAAMxB,GAAK;EAChB,OAAOwB,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"}
|
|
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) {\n return \"\";\n }\n if (typeof num === \"string\" && !num) {\n return withLeadingZeroHours ? `00:00` : \"0:00\";\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,IAAI,CAACD,GAAG,EAAE;IACR,OAAO,EAAE;EACX;EACA,IAAI,OAAOA,GAAG,KAAK,QAAQ,IAAI,CAACA,GAAG,EAAE;IACnC,OAAOC,oBAAoB,aAAa,MAAM;EAChD;EACA,IAAI,OAAOD,GAAG,KAAK,QAAQ,IAAIA,GAAG,CAACE,OAAO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