@fluentui/react-timepicker-compat 0.0.0-nightly-20250828-0408.1 → 0.0.0-nightly-20250829-0406.1

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/CHANGELOG.md CHANGED
@@ -1,28 +1,28 @@
1
1
  # Change Log - @fluentui/react-timepicker-compat
2
2
 
3
- This log was last generated on Thu, 28 Aug 2025 04:22:48 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 29 Aug 2025 04:21:39 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## [0.0.0-nightly-20250828-0408.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-timepicker-compat_v0.0.0-nightly-20250828-0408.1)
7
+ ## [0.0.0-nightly-20250829-0406.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-timepicker-compat_v0.0.0-nightly-20250829-0406.1)
8
8
 
9
- Thu, 28 Aug 2025 04:22:48 GMT
10
- [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-timepicker-compat_v0.4.14..@fluentui/react-timepicker-compat_v0.0.0-nightly-20250828-0408.1)
9
+ Fri, 29 Aug 2025 04:21:39 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-timepicker-compat_v0.4.14..@fluentui/react-timepicker-compat_v0.0.0-nightly-20250829-0406.1)
11
11
 
12
12
  ### Changes
13
13
 
14
14
  - Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
15
- - Bump @fluentui/keyboard-keys to v0.0.0-nightly-20250828-0408.1 ([commit](https://github.com/microsoft/fluentui/commit/1f74bd3c8ea7e7476d2092995db628337708a5d1) by beachball)
16
- - Bump @fluentui/react-combobox to v0.0.0-nightly-20250828-0408.1 ([commit](https://github.com/microsoft/fluentui/commit/1f74bd3c8ea7e7476d2092995db628337708a5d1) by beachball)
17
- - Bump @fluentui/react-field to v0.0.0-nightly-20250828-0408.1 ([commit](https://github.com/microsoft/fluentui/commit/1f74bd3c8ea7e7476d2092995db628337708a5d1) by beachball)
18
- - Bump @fluentui/react-jsx-runtime to v0.0.0-nightly-20250828-0408.1 ([commit](https://github.com/microsoft/fluentui/commit/1f74bd3c8ea7e7476d2092995db628337708a5d1) by beachball)
19
- - Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20250828-0408.1 ([commit](https://github.com/microsoft/fluentui/commit/1f74bd3c8ea7e7476d2092995db628337708a5d1) by beachball)
20
- - Bump @fluentui/react-theme to v0.0.0-nightly-20250828-0408.1 ([commit](https://github.com/microsoft/fluentui/commit/1f74bd3c8ea7e7476d2092995db628337708a5d1) by beachball)
21
- - Bump @fluentui/react-utilities to v0.0.0-nightly-20250828-0408.1 ([commit](https://github.com/microsoft/fluentui/commit/1f74bd3c8ea7e7476d2092995db628337708a5d1) by beachball)
22
- - Bump @fluentui/react-provider to v0.0.0-nightly-20250828-0408.1 ([commit](https://github.com/microsoft/fluentui/commit/1f74bd3c8ea7e7476d2092995db628337708a5d1) by beachball)
23
- - Bump @fluentui/react-components to v0.0.0-nightly-20250828-0408.1 ([commit](https://github.com/microsoft/fluentui/commit/1f74bd3c8ea7e7476d2092995db628337708a5d1) by beachball)
24
- - Bump @fluentui/react-conformance to v0.0.0-nightly-20250828-0408.1 ([commit](https://github.com/microsoft/fluentui/commit/1f74bd3c8ea7e7476d2092995db628337708a5d1) by beachball)
25
- - Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20250828-0408.1 ([commit](https://github.com/microsoft/fluentui/commit/1f74bd3c8ea7e7476d2092995db628337708a5d1) by beachball)
15
+ - Bump @fluentui/keyboard-keys to v0.0.0-nightly-20250829-0406.1 ([commit](https://github.com/microsoft/fluentui/commit/005adf2b3b451f7cc49bd2bfa88f08a155215b53) by beachball)
16
+ - Bump @fluentui/react-combobox to v0.0.0-nightly-20250829-0406.1 ([commit](https://github.com/microsoft/fluentui/commit/005adf2b3b451f7cc49bd2bfa88f08a155215b53) by beachball)
17
+ - Bump @fluentui/react-field to v0.0.0-nightly-20250829-0406.1 ([commit](https://github.com/microsoft/fluentui/commit/005adf2b3b451f7cc49bd2bfa88f08a155215b53) by beachball)
18
+ - Bump @fluentui/react-jsx-runtime to v0.0.0-nightly-20250829-0406.1 ([commit](https://github.com/microsoft/fluentui/commit/005adf2b3b451f7cc49bd2bfa88f08a155215b53) by beachball)
19
+ - Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20250829-0406.1 ([commit](https://github.com/microsoft/fluentui/commit/005adf2b3b451f7cc49bd2bfa88f08a155215b53) by beachball)
20
+ - Bump @fluentui/react-theme to v0.0.0-nightly-20250829-0406.1 ([commit](https://github.com/microsoft/fluentui/commit/005adf2b3b451f7cc49bd2bfa88f08a155215b53) by beachball)
21
+ - Bump @fluentui/react-utilities to v0.0.0-nightly-20250829-0406.1 ([commit](https://github.com/microsoft/fluentui/commit/005adf2b3b451f7cc49bd2bfa88f08a155215b53) by beachball)
22
+ - Bump @fluentui/react-provider to v0.0.0-nightly-20250829-0406.1 ([commit](https://github.com/microsoft/fluentui/commit/005adf2b3b451f7cc49bd2bfa88f08a155215b53) by beachball)
23
+ - Bump @fluentui/react-components to v0.0.0-nightly-20250829-0406.1 ([commit](https://github.com/microsoft/fluentui/commit/005adf2b3b451f7cc49bd2bfa88f08a155215b53) by beachball)
24
+ - Bump @fluentui/react-conformance to v0.0.0-nightly-20250829-0406.1 ([commit](https://github.com/microsoft/fluentui/commit/005adf2b3b451f7cc49bd2bfa88f08a155215b53) by beachball)
25
+ - Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20250829-0406.1 ([commit](https://github.com/microsoft/fluentui/commit/005adf2b3b451f7cc49bd2bfa88f08a155215b53) by beachball)
26
26
 
27
27
  ## [0.4.14](https://github.com/microsoft/fluentui/tree/@fluentui/react-timepicker-compat_v0.4.14)
28
28
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/TimePicker/timeMath.ts"],"sourcesContent":["import type { TimeFormatOptions, TimeStringValidationResult } from './TimePicker.types';\n\nfunction isValidDate(date: Date): boolean {\n return !isNaN(date.getTime());\n}\n\n/**\n * Converts a Date object to a string key.\n */\nexport function dateToKey(date: Date | null): string {\n if (!date) {\n return '';\n }\n if (!isValidDate(date)) {\n return 'invalid';\n }\n return date.toISOString();\n}\n\n/**\n * Converts a string key back to a Date object.\n * Returns undefined for keys that don't represent valid dates.\n */\nexport function keyToDate(key: string): Date | null {\n if (key === '' || key === 'invalid') {\n return null;\n }\n const date = new Date(key);\n return isValidDate(date) ? date : null;\n}\n\n/**\n * Formats a Date object into a time string based on provided options.\n *\n * @param date - The Date object to be formatted.\n * @param options - Formatting options. It has two properties:\n * 1. hourCycle (default: undefined): Determines if the time format should be 12-hour or 24-hour.\n * 2. showSeconds (default: false): Determines if the seconds should be included in the formatted string.\n * @returns Formatted time string based on the given options.\n *\n * @example\n * const date = new Date(2023, 9, 6, 23, 45, 12);\n * formatDateToTimeString(date); // Returns \"23:45\" in CET\n * formatDateToTimeString(date, \\{ showSeconds: true \\}); // Returns \"23:45:12\" in CET\n * formatDateToTimeString(date, \\{ hourCycle: 'h12', showSeconds: true \\}); // Returns \"11:45:12 PM\" in CET\n */\nexport function formatDateToTimeString(date: Date, { hourCycle, showSeconds }: TimeFormatOptions = {}): string {\n return date.toLocaleTimeString(undefined, {\n hour: 'numeric',\n hourCycle,\n minute: '2-digit',\n second: showSeconds ? '2-digit' : undefined,\n });\n}\n\n/**\n * Get the start date anchor based on the provided parameters.\n * @example\n * const date = new Date(2023, 9, 6); // October 6, 2023\n * getStartAnchorDate(date, 5); // Returns a date for October 6, 2023, 05:00:00\n */\nexport function getDateStartAnchor(dateAnchor: Date, startHour: number): Date {\n const startDate = new Date(dateAnchor);\n startDate.setHours(startHour, 0, 0, 0);\n return startDate;\n}\n\n/**\n * Get the end date anchor based on the provided parameters.\n * @example\n * const date = new Date(2023, 9, 6); // October 6, 2023\n * getEndAnchorDate(date, 5, 10); // Returns a date for October 6, 2023, 10:00:00\n * getEndAnchorDate(date, 10, 5); // Returns a date for October 7, 2023, 05:00:00 (next day due to hour conditions)\n */\nexport function getDateEndAnchor(dateAnchor: Date, startHour: number, endHour: number): Date {\n const endDate = new Date(dateAnchor);\n if (startHour > endHour || endHour === 24) {\n endDate.setDate(endDate.getDate() + 1);\n }\n endDate.setHours(endHour === 24 ? 0 : endHour, 0, 0, 0);\n return endDate;\n}\n\n/**\n * Generates an array of Date objects between two given Date anchors.\n *\n * @param dateStartAnchor - The starting Date anchor.\n * @param dateEndAnchor - The ending Date anchor.\n * @param increment - The minute increment between each Date in the resulting array.\n * @returns - An array of Date objects.\n *\n * @example\n * const start = new Date(2023, 0, 1, 10, 0); // Jan 1, 2023 10:00:00 AM\n * const end = new Date(2023, 0, 1, 11, 0); // Jan 1, 2023 11:00:00 AM\n * getTimesBetween(start, end, 15); // Returns array with Dates [10:00, 10:15, 10:30, 10:45]\n */\nexport function getTimesBetween(dateStartAnchor: Date, dateEndAnchor: Date, increment: number) {\n if (increment <= 0) {\n // eslint-disable-next-line no-console\n console.error('Increment value should be a positive number.');\n return [];\n }\n\n const result: Date[] = [];\n\n const startDate = new Date(dateStartAnchor);\n while (startDate < dateEndAnchor) {\n result.push(new Date(startDate));\n startDate.setMinutes(startDate.getMinutes() + increment);\n }\n\n return result;\n}\n\nconst REGEX_SHOW_SECONDS_HOUR_12 = /^((1[0-2]|0?[0-9]):([0-5][0-9]):([0-5][0-9])\\s([AaPp][Mm]))$/;\nconst REGEX_HIDE_SECONDS_HOUR_12 = /^((1[0-2]|0?[0-9]):[0-5][0-9]\\s([AaPp][Mm]))$/;\nconst REGEX_SHOW_SECONDS_HOUR_24 = /^([0-1]?[0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9]$/;\nconst REGEX_HIDE_SECONDS_HOUR_24 = /^([0-1]?[0-9]|2[0-4]):[0-5][0-9]$/;\n\n/**\n * Calculates a new date from the user-selected time string based on anchor dates.\n * Returns an object containing a date if the provided time string is valid, and an optional string indicating the type of error.\n *\n * @param time - The time string to be parsed (e.g., \"2:30 PM\", \"15:45:20\").\n * @param dateStartAnchor - The start anchor date.\n * @param dateEndAnchor - The end anchor date.\n * @param timeFormatOptions - format options for the provided time string.\n * @returns An object with either a 'date' or an 'errorType'.\n *\n * @example\n * Input: time=\"2:30 PM\", dateStartAnchor=2023-10-06T12:00:00Z, dateEndAnchor=2023-10-07T12:00:00Z, options={hourCycle: 'h12', showSeconds: false}\n * Output: { date: 2023-10-06T14:30:00Z }\n *\n * Input: time=\"25:30\"\n * Output: { errorType: 'invalid-input' }\n *\n * Input: time=\"1:30 AM\", dateStartAnchor=2023-10-06T03:00:00Z, dateEndAnchor=2023-10-07T03:00:00Z, options={hourCycle: 'h12', showSeconds: false}\n * Output: { date: 2023-10-07T01:30:00Z, errorType: 'out-of-bounds' }\n */\nexport function getDateFromTimeString(\n time: string | undefined,\n dateStartAnchor: Date,\n dateEndAnchor: Date,\n timeFormatOptions: TimeFormatOptions,\n): TimeStringValidationResult {\n if (!time) {\n return { date: null, errorType: 'required-input' };\n }\n\n const { hourCycle, showSeconds } = timeFormatOptions;\n const hour12 = hourCycle === 'h11' || hourCycle === 'h12';\n\n // Determine the regex based on format\n const regex = hour12\n ? showSeconds\n ? REGEX_SHOW_SECONDS_HOUR_12\n : REGEX_HIDE_SECONDS_HOUR_12\n : showSeconds\n ? REGEX_SHOW_SECONDS_HOUR_24\n : REGEX_HIDE_SECONDS_HOUR_24;\n\n if (!regex.test(time)) {\n return { date: null, errorType: 'invalid-input' };\n }\n\n const timeParts = /^(\\d\\d?):(\\d\\d):?(\\d\\d)? ?([ap]m)?/i.exec(time);\n if (!timeParts) {\n return { date: null, errorType: 'invalid-input' };\n }\n\n const [, selectedHours, minutes, seconds, amPm] = timeParts;\n let hours = selectedHours;\n\n // Adjust for 12-hour time format if needed\n if (hour12 && amPm) {\n if (amPm.toLowerCase() === 'pm' && +hours !== 12) {\n hours = (+hours + 12).toString();\n } else if (amPm.toLowerCase() === 'am' && +hours === 12) {\n hours = '0';\n }\n }\n\n const adjustedDate = new Date(dateStartAnchor);\n adjustedDate.setHours(+hours, +minutes, seconds ? +seconds : 0);\n\n // Adjust to the next day if the selected time is before the anchor time\n if (adjustedDate < dateStartAnchor) {\n adjustedDate.setDate(adjustedDate.getDate() + 1);\n }\n\n if (adjustedDate >= dateEndAnchor) {\n return { date: adjustedDate, errorType: 'out-of-bounds' };\n }\n\n return { date: adjustedDate };\n}\n"],"names":["isValidDate","date","isNaN","getTime","dateToKey","toISOString","keyToDate","key","Date","formatDateToTimeString","hourCycle","showSeconds","toLocaleTimeString","undefined","hour","minute","second","getDateStartAnchor","dateAnchor","startHour","startDate","setHours","getDateEndAnchor","endHour","endDate","setDate","getDate","getTimesBetween","dateStartAnchor","dateEndAnchor","increment","console","error","result","push","setMinutes","getMinutes","REGEX_SHOW_SECONDS_HOUR_12","REGEX_HIDE_SECONDS_HOUR_12","REGEX_SHOW_SECONDS_HOUR_24","REGEX_HIDE_SECONDS_HOUR_24","getDateFromTimeString","time","timeFormatOptions","errorType","hour12","regex","test","timeParts","exec","selectedHours","minutes","seconds","amPm","hours","toLowerCase","toString","adjustedDate"],"mappings":"AAEA,SAASA,YAAYC,IAAU;IAC7B,OAAO,CAACC,MAAMD,KAAKE,OAAO;AAC5B;AAEA;;CAEC,GACD,OAAO,SAASC,UAAUH,IAAiB;IACzC,IAAI,CAACA,MAAM;QACT,OAAO;IACT;IACA,IAAI,CAACD,YAAYC,OAAO;QACtB,OAAO;IACT;IACA,OAAOA,KAAKI,WAAW;AACzB;AAEA;;;CAGC,GACD,OAAO,SAASC,UAAUC,GAAW;IACnC,IAAIA,QAAQ,MAAMA,QAAQ,WAAW;QACnC,OAAO;IACT;IACA,MAAMN,OAAO,IAAIO,KAAKD;IACtB,OAAOP,YAAYC,QAAQA,OAAO;AACpC;AAEA;;;;;;;;;;;;;;CAcC,GACD,OAAO,SAASQ,uBAAuBR,IAAU,EAAE,EAAES,SAAS,EAAEC,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M2C,WAAW;QAAiB;IACnD;IAEA,MAAM,EAAElC,SAAS,EAAEC,WAAW,EAAE,GAAGgC;IACnC,MAAME,SAASnC,cAAc,SAASA,cAAc;IAEpD,sCAAsC;IACtC,MAAMoC,QAAQD,SACVlC,cACE0B,6BACAC,6BACF3B,cACA4B,6BACAC;IAEJ,IAAI,CAACM,MAAMC,IAAI,CAACL,OAAO;QACrB,OAAO;YAAEzC,MAAM;YAAM2C,WAAW;QAAgB;IAClD;IAEA,MAAMI,YAAY,sCAAsCC,IAAI,CAACP;IAC7D,IAAI,CAACM,WAAW;QACd,OAAO;YAAE/C,MAAM;YAAM2C,WAAW;QAAgB;IAClD;IAEA,MAAM,GAAGM,eAAeC,SAASC,SAASC,KAAK,GAAGL;IAClD,IAAIM,QAAQJ;IAEZ,2CAA2C;IAC3C,IAAIL,UAAUQ,MAAM;QAClB,IAAIA,KAAKE,WAAW,OAAO,QAAQ,CAACD,UAAU,IAAI;YAChDA,QAAQ,AAAC,CAAA,CAACA,QAAQ,EAAC,EAAGE,QAAQ;QAChC,OAAO,IAAIH,KAAKE,WAAW,OAAO,QAAQ,CAACD,UAAU,IAAI;YACvDA,QAAQ;QACV;IACF;IAEA,MAAMG,eAAe,IAAIjD,KAAKoB;IAC9B6B,aAAapC,QAAQ,CAAC,CAACiC,OAAO,CAACH,SAASC,UAAU,CAACA,UAAU;IAE7D,wEAAwE;IACxE,IAAIK,eAAe7B,iBAAiB;QAClC6B,aAAahC,OAAO,CAACgC,aAAa/B,OAAO,KAAK;IAChD;IAEA,IAAI+B,gBAAgB5B,eAAe;QACjC,OAAO;YAAE5B,MAAMwD;YAAcb,WAAW;QAAgB;IAC1D;IAEA,OAAO;QAAE3C,MAAMwD;IAAa;AAC9B"}
1
+ {"version":3,"sources":["../src/components/TimePicker/timeMath.ts"],"sourcesContent":["import type { TimeFormatOptions, TimeStringValidationResult } from './TimePicker.types';\n\nfunction isValidDate(date: Date): boolean {\n return !isNaN(date.getTime());\n}\n\n/**\n * Converts a Date object to a string key.\n */\nexport function dateToKey(date: Date | null): string {\n if (!date) {\n return '';\n }\n if (!isValidDate(date)) {\n return 'invalid';\n }\n return date.toISOString();\n}\n\n/**\n * Converts a string key back to a Date object.\n * Returns undefined for keys that don't represent valid dates.\n */\nexport function keyToDate(key: string): Date | null {\n if (key === '' || key === 'invalid') {\n return null;\n }\n const date = new Date(key);\n return isValidDate(date) ? date : null;\n}\n\n/**\n * Formats a Date object into a time string based on provided options.\n *\n * @param date - The Date object to be formatted.\n * @param options - Formatting options. It has two properties:\n * 1. hourCycle (default: undefined): Determines if the time format should be 12-hour or 24-hour.\n * 2. showSeconds (default: false): Determines if the seconds should be included in the formatted string.\n * @returns Formatted time string based on the given options.\n *\n * @example\n * const date = new Date(2023, 9, 6, 23, 45, 12);\n * formatDateToTimeString(date); // Returns \"23:45\" in CET\n * formatDateToTimeString(date, \\{ showSeconds: true \\}); // Returns \"23:45:12\" in CET\n * formatDateToTimeString(date, \\{ hourCycle: 'h12', showSeconds: true \\}); // Returns \"11:45:12 PM\" in CET\n */\nexport function formatDateToTimeString(date: Date, { hourCycle, showSeconds }: TimeFormatOptions = {}): string {\n return date.toLocaleTimeString(undefined, {\n hour: 'numeric',\n hourCycle,\n minute: '2-digit',\n second: showSeconds ? '2-digit' : undefined,\n });\n}\n\n/**\n * Get the start date anchor based on the provided parameters.\n * @example\n * const date = new Date(2023, 9, 6); // October 6, 2023\n * getStartAnchorDate(date, 5); // Returns a date for October 6, 2023, 05:00:00\n */\nexport function getDateStartAnchor(dateAnchor: Date, startHour: number): Date {\n const startDate = new Date(dateAnchor);\n startDate.setHours(startHour, 0, 0, 0);\n return startDate;\n}\n\n/**\n * Get the end date anchor based on the provided parameters.\n * @example\n * const date = new Date(2023, 9, 6); // October 6, 2023\n * getEndAnchorDate(date, 5, 10); // Returns a date for October 6, 2023, 10:00:00\n * getEndAnchorDate(date, 10, 5); // Returns a date for October 7, 2023, 05:00:00 (next day due to hour conditions)\n */\nexport function getDateEndAnchor(dateAnchor: Date, startHour: number, endHour: number): Date {\n const endDate = new Date(dateAnchor);\n if (startHour > endHour || endHour === 24) {\n endDate.setDate(endDate.getDate() + 1);\n }\n endDate.setHours(endHour === 24 ? 0 : endHour, 0, 0, 0);\n return endDate;\n}\n\n/**\n * Generates an array of Date objects between two given Date anchors.\n *\n * @param dateStartAnchor - The starting Date anchor.\n * @param dateEndAnchor - The ending Date anchor.\n * @param increment - The minute increment between each Date in the resulting array.\n * @returns - An array of Date objects.\n *\n * @example\n * const start = new Date(2023, 0, 1, 10, 0); // Jan 1, 2023 10:00:00 AM\n * const end = new Date(2023, 0, 1, 11, 0); // Jan 1, 2023 11:00:00 AM\n * getTimesBetween(start, end, 15); // Returns array with Dates [10:00, 10:15, 10:30, 10:45]\n */\nexport function getTimesBetween(dateStartAnchor: Date, dateEndAnchor: Date, increment: number): Date[] {\n if (increment <= 0) {\n // eslint-disable-next-line no-console\n console.error('Increment value should be a positive number.');\n return [];\n }\n\n const result: Date[] = [];\n\n const startDate = new Date(dateStartAnchor);\n while (startDate < dateEndAnchor) {\n result.push(new Date(startDate));\n startDate.setMinutes(startDate.getMinutes() + increment);\n }\n\n return result;\n}\n\nconst REGEX_SHOW_SECONDS_HOUR_12 = /^((1[0-2]|0?[0-9]):([0-5][0-9]):([0-5][0-9])\\s([AaPp][Mm]))$/;\nconst REGEX_HIDE_SECONDS_HOUR_12 = /^((1[0-2]|0?[0-9]):[0-5][0-9]\\s([AaPp][Mm]))$/;\nconst REGEX_SHOW_SECONDS_HOUR_24 = /^([0-1]?[0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9]$/;\nconst REGEX_HIDE_SECONDS_HOUR_24 = /^([0-1]?[0-9]|2[0-4]):[0-5][0-9]$/;\n\n/**\n * Calculates a new date from the user-selected time string based on anchor dates.\n * Returns an object containing a date if the provided time string is valid, and an optional string indicating the type of error.\n *\n * @param time - The time string to be parsed (e.g., \"2:30 PM\", \"15:45:20\").\n * @param dateStartAnchor - The start anchor date.\n * @param dateEndAnchor - The end anchor date.\n * @param timeFormatOptions - format options for the provided time string.\n * @returns An object with either a 'date' or an 'errorType'.\n *\n * @example\n * Input: time=\"2:30 PM\", dateStartAnchor=2023-10-06T12:00:00Z, dateEndAnchor=2023-10-07T12:00:00Z, options={hourCycle: 'h12', showSeconds: false}\n * Output: { date: 2023-10-06T14:30:00Z }\n *\n * Input: time=\"25:30\"\n * Output: { errorType: 'invalid-input' }\n *\n * Input: time=\"1:30 AM\", dateStartAnchor=2023-10-06T03:00:00Z, dateEndAnchor=2023-10-07T03:00:00Z, options={hourCycle: 'h12', showSeconds: false}\n * Output: { date: 2023-10-07T01:30:00Z, errorType: 'out-of-bounds' }\n */\nexport function getDateFromTimeString(\n time: string | undefined,\n dateStartAnchor: Date,\n dateEndAnchor: Date,\n timeFormatOptions: TimeFormatOptions,\n): TimeStringValidationResult {\n if (!time) {\n return { date: null, errorType: 'required-input' };\n }\n\n const { hourCycle, showSeconds } = timeFormatOptions;\n const hour12 = hourCycle === 'h11' || hourCycle === 'h12';\n\n // Determine the regex based on format\n const regex = hour12\n ? showSeconds\n ? REGEX_SHOW_SECONDS_HOUR_12\n : REGEX_HIDE_SECONDS_HOUR_12\n : showSeconds\n ? REGEX_SHOW_SECONDS_HOUR_24\n : REGEX_HIDE_SECONDS_HOUR_24;\n\n if (!regex.test(time)) {\n return { date: null, errorType: 'invalid-input' };\n }\n\n const timeParts = /^(\\d\\d?):(\\d\\d):?(\\d\\d)? ?([ap]m)?/i.exec(time);\n if (!timeParts) {\n return { date: null, errorType: 'invalid-input' };\n }\n\n const [, selectedHours, minutes, seconds, amPm] = timeParts;\n let hours = selectedHours;\n\n // Adjust for 12-hour time format if needed\n if (hour12 && amPm) {\n if (amPm.toLowerCase() === 'pm' && +hours !== 12) {\n hours = (+hours + 12).toString();\n } else if (amPm.toLowerCase() === 'am' && +hours === 12) {\n hours = '0';\n }\n }\n\n const adjustedDate = new Date(dateStartAnchor);\n adjustedDate.setHours(+hours, +minutes, seconds ? +seconds : 0);\n\n // Adjust to the next day if the selected time is before the anchor time\n if (adjustedDate < dateStartAnchor) {\n adjustedDate.setDate(adjustedDate.getDate() + 1);\n }\n\n if (adjustedDate >= dateEndAnchor) {\n return { date: adjustedDate, errorType: 'out-of-bounds' };\n }\n\n return { date: adjustedDate };\n}\n"],"names":["isValidDate","date","isNaN","getTime","dateToKey","toISOString","keyToDate","key","Date","formatDateToTimeString","hourCycle","showSeconds","toLocaleTimeString","undefined","hour","minute","second","getDateStartAnchor","dateAnchor","startHour","startDate","setHours","getDateEndAnchor","endHour","endDate","setDate","getDate","getTimesBetween","dateStartAnchor","dateEndAnchor","increment","console","error","result","push","setMinutes","getMinutes","REGEX_SHOW_SECONDS_HOUR_12","REGEX_HIDE_SECONDS_HOUR_12","REGEX_SHOW_SECONDS_HOUR_24","REGEX_HIDE_SECONDS_HOUR_24","getDateFromTimeString","time","timeFormatOptions","errorType","hour12","regex","test","timeParts","exec","selectedHours","minutes","seconds","amPm","hours","toLowerCase","toString","adjustedDate"],"mappings":"AAEA,SAASA,YAAYC,IAAU;IAC7B,OAAO,CAACC,MAAMD,KAAKE,OAAO;AAC5B;AAEA;;CAEC,GACD,OAAO,SAASC,UAAUH,IAAiB;IACzC,IAAI,CAACA,MAAM;QACT,OAAO;IACT;IACA,IAAI,CAACD,YAAYC,OAAO;QACtB,OAAO;IACT;IACA,OAAOA,KAAKI,WAAW;AACzB;AAEA;;;CAGC,GACD,OAAO,SAASC,UAAUC,GAAW;IACnC,IAAIA,QAAQ,MAAMA,QAAQ,WAAW;QACnC,OAAO;IACT;IACA,MAAMN,OAAO,IAAIO,KAAKD;IACtB,OAAOP,YAAYC,QAAQA,OAAO;AACpC;AAEA;;;;;;;;;;;;;;CAcC,GACD,OAAO,SAASQ,uBAAuBR,IAAU,EAAE,EAAES,SAAS,EAAEC,WAAW,EAAqB,GAAG,CAAC,CAAC;IACnG,OAAOV,KAAKW,kBAAkB,CAACC,WAAW;QACxCC,MAA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MAAME,SAASnC,cAAc,SAASA,cAAc;IAEpD,sCAAsC;IACtC,MAAMoC,QAAQD,SACVlC,cACE0B,6BACAC,6BACF3B,cACA4B,6BACAC;IAEJ,IAAI,CAACM,MAAMC,IAAI,CAACL,OAAO;QACrB,OAAO;YAAEzC,MAAM;YAAM2C,WAAW;QAAgB;IAClD;IAEA,MAAMI,YAAY,sCAAsCC,IAAI,CAACP;IAC7D,IAAI,CAACM,WAAW;QACd,OAAO;YAAE/C,MAAM;YAAM2C,WAAW;QAAgB;IAClD;IAEA,MAAM,GAAGM,eAAeC,SAASC,SAASC,KAAK,GAAGL;IAClD,IAAIM,QAAQJ;IAEZ,2CAA2C;IAC3C,IAAIL,UAAUQ,MAAM;QAClB,IAAIA,KAAKE,WAAW,OAAO,QAAQ,CAACD,UAAU,IAAI;YAChDA,QAAQ,AAAC,CAAA,CAACA,QAAQ,EAAC,EAAGE,QAAQ;QAChC,OAAO,IAAIH,KAAKE,WAAW,OAAO,QAAQ,CAACD,UAAU,IAAI;YACvDA,QAAQ;QACV;IACF;IAEA,MAAMG,eAAe,IAAIjD,KAAKoB;IAC9B6B,aAAapC,QAAQ,CAAC,CAACiC,OAAO,CAACH,SAASC,UAAU,CAACA,UAAU;IAE7D,wEAAwE;IACxE,IAAIK,eAAe7B,iBAAiB;QAClC6B,aAAahC,OAAO,CAACgC,aAAa/B,OAAO,KAAK;IAChD;IAEA,IAAI+B,gBAAgB5B,eAAe;QACjC,OAAO;YAAE5B,MAAMwD;YAAcb,WAAW;QAAgB;IAC1D;IAEA,OAAO;QAAE3C,MAAMwD;IAAa;AAC9B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/TimePicker/timeMath.ts"],"sourcesContent":["import type { TimeFormatOptions, TimeStringValidationResult } from './TimePicker.types';\n\nfunction isValidDate(date: Date): boolean {\n return !isNaN(date.getTime());\n}\n\n/**\n * Converts a Date object to a string key.\n */\nexport function dateToKey(date: Date | null): string {\n if (!date) {\n return '';\n }\n if (!isValidDate(date)) {\n return 'invalid';\n }\n return date.toISOString();\n}\n\n/**\n * Converts a string key back to a Date object.\n * Returns undefined for keys that don't represent valid dates.\n */\nexport function keyToDate(key: string): Date | null {\n if (key === '' || key === 'invalid') {\n return null;\n }\n const date = new Date(key);\n return isValidDate(date) ? date : null;\n}\n\n/**\n * Formats a Date object into a time string based on provided options.\n *\n * @param date - The Date object to be formatted.\n * @param options - Formatting options. It has two properties:\n * 1. hourCycle (default: undefined): Determines if the time format should be 12-hour or 24-hour.\n * 2. showSeconds (default: false): Determines if the seconds should be included in the formatted string.\n * @returns Formatted time string based on the given options.\n *\n * @example\n * const date = new Date(2023, 9, 6, 23, 45, 12);\n * formatDateToTimeString(date); // Returns \"23:45\" in CET\n * formatDateToTimeString(date, \\{ showSeconds: true \\}); // Returns \"23:45:12\" in CET\n * formatDateToTimeString(date, \\{ hourCycle: 'h12', showSeconds: true \\}); // Returns \"11:45:12 PM\" in CET\n */\nexport function formatDateToTimeString(date: Date, { hourCycle, showSeconds }: TimeFormatOptions = {}): string {\n return date.toLocaleTimeString(undefined, {\n hour: 'numeric',\n hourCycle,\n minute: '2-digit',\n second: showSeconds ? '2-digit' : undefined,\n });\n}\n\n/**\n * Get the start date anchor based on the provided parameters.\n * @example\n * const date = new Date(2023, 9, 6); // October 6, 2023\n * getStartAnchorDate(date, 5); // Returns a date for October 6, 2023, 05:00:00\n */\nexport function getDateStartAnchor(dateAnchor: Date, startHour: number): Date {\n const startDate = new Date(dateAnchor);\n startDate.setHours(startHour, 0, 0, 0);\n return startDate;\n}\n\n/**\n * Get the end date anchor based on the provided parameters.\n * @example\n * const date = new Date(2023, 9, 6); // October 6, 2023\n * getEndAnchorDate(date, 5, 10); // Returns a date for October 6, 2023, 10:00:00\n * getEndAnchorDate(date, 10, 5); // Returns a date for October 7, 2023, 05:00:00 (next day due to hour conditions)\n */\nexport function getDateEndAnchor(dateAnchor: Date, startHour: number, endHour: number): Date {\n const endDate = new Date(dateAnchor);\n if (startHour > endHour || endHour === 24) {\n endDate.setDate(endDate.getDate() + 1);\n }\n endDate.setHours(endHour === 24 ? 0 : endHour, 0, 0, 0);\n return endDate;\n}\n\n/**\n * Generates an array of Date objects between two given Date anchors.\n *\n * @param dateStartAnchor - The starting Date anchor.\n * @param dateEndAnchor - The ending Date anchor.\n * @param increment - The minute increment between each Date in the resulting array.\n * @returns - An array of Date objects.\n *\n * @example\n * const start = new Date(2023, 0, 1, 10, 0); // Jan 1, 2023 10:00:00 AM\n * const end = new Date(2023, 0, 1, 11, 0); // Jan 1, 2023 11:00:00 AM\n * getTimesBetween(start, end, 15); // Returns array with Dates [10:00, 10:15, 10:30, 10:45]\n */\nexport function getTimesBetween(dateStartAnchor: Date, dateEndAnchor: Date, increment: number) {\n if (increment <= 0) {\n // eslint-disable-next-line no-console\n console.error('Increment value should be a positive number.');\n return [];\n }\n\n const result: Date[] = [];\n\n const startDate = new Date(dateStartAnchor);\n while (startDate < dateEndAnchor) {\n result.push(new Date(startDate));\n startDate.setMinutes(startDate.getMinutes() + increment);\n }\n\n return result;\n}\n\nconst REGEX_SHOW_SECONDS_HOUR_12 = /^((1[0-2]|0?[0-9]):([0-5][0-9]):([0-5][0-9])\\s([AaPp][Mm]))$/;\nconst REGEX_HIDE_SECONDS_HOUR_12 = /^((1[0-2]|0?[0-9]):[0-5][0-9]\\s([AaPp][Mm]))$/;\nconst REGEX_SHOW_SECONDS_HOUR_24 = /^([0-1]?[0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9]$/;\nconst REGEX_HIDE_SECONDS_HOUR_24 = /^([0-1]?[0-9]|2[0-4]):[0-5][0-9]$/;\n\n/**\n * Calculates a new date from the user-selected time string based on anchor dates.\n * Returns an object containing a date if the provided time string is valid, and an optional string indicating the type of error.\n *\n * @param time - The time string to be parsed (e.g., \"2:30 PM\", \"15:45:20\").\n * @param dateStartAnchor - The start anchor date.\n * @param dateEndAnchor - The end anchor date.\n * @param timeFormatOptions - format options for the provided time string.\n * @returns An object with either a 'date' or an 'errorType'.\n *\n * @example\n * Input: time=\"2:30 PM\", dateStartAnchor=2023-10-06T12:00:00Z, dateEndAnchor=2023-10-07T12:00:00Z, options={hourCycle: 'h12', showSeconds: false}\n * Output: { date: 2023-10-06T14:30:00Z }\n *\n * Input: time=\"25:30\"\n * Output: { errorType: 'invalid-input' }\n *\n * Input: time=\"1:30 AM\", dateStartAnchor=2023-10-06T03:00:00Z, dateEndAnchor=2023-10-07T03:00:00Z, options={hourCycle: 'h12', showSeconds: false}\n * Output: { date: 2023-10-07T01:30:00Z, errorType: 'out-of-bounds' }\n */\nexport function getDateFromTimeString(\n time: string | undefined,\n dateStartAnchor: Date,\n dateEndAnchor: Date,\n timeFormatOptions: TimeFormatOptions,\n): TimeStringValidationResult {\n if (!time) {\n return { date: null, errorType: 'required-input' };\n }\n\n const { hourCycle, showSeconds } = timeFormatOptions;\n const hour12 = hourCycle === 'h11' || hourCycle === 'h12';\n\n // Determine the regex based on format\n const regex = hour12\n ? showSeconds\n ? REGEX_SHOW_SECONDS_HOUR_12\n : REGEX_HIDE_SECONDS_HOUR_12\n : showSeconds\n ? REGEX_SHOW_SECONDS_HOUR_24\n : REGEX_HIDE_SECONDS_HOUR_24;\n\n if (!regex.test(time)) {\n return { date: null, errorType: 'invalid-input' };\n }\n\n const timeParts = /^(\\d\\d?):(\\d\\d):?(\\d\\d)? ?([ap]m)?/i.exec(time);\n if (!timeParts) {\n return { date: null, errorType: 'invalid-input' };\n }\n\n const [, selectedHours, minutes, seconds, amPm] = timeParts;\n let hours = selectedHours;\n\n // Adjust for 12-hour time format if needed\n if (hour12 && amPm) {\n if (amPm.toLowerCase() === 'pm' && +hours !== 12) {\n hours = (+hours + 12).toString();\n } else if (amPm.toLowerCase() === 'am' && +hours === 12) {\n hours = '0';\n }\n }\n\n const adjustedDate = new Date(dateStartAnchor);\n adjustedDate.setHours(+hours, +minutes, seconds ? +seconds : 0);\n\n // Adjust to the next day if the selected time is before the anchor time\n if (adjustedDate < dateStartAnchor) {\n adjustedDate.setDate(adjustedDate.getDate() + 1);\n }\n\n if (adjustedDate >= dateEndAnchor) {\n return { date: adjustedDate, errorType: 'out-of-bounds' };\n }\n\n return { date: adjustedDate };\n}\n"],"names":["isValidDate","date","isNaN","getTime","dateToKey","toISOString","keyToDate","key","Date","formatDateToTimeString","hourCycle","showSeconds","toLocaleTimeString","undefined","hour","minute","second","getDateStartAnchor","dateAnchor","startHour","startDate","setHours","getDateEndAnchor","endHour","endDate","setDate","getDate","getTimesBetween","dateStartAnchor","dateEndAnchor","increment","console","error","result","push","setMinutes","getMinutes","REGEX_SHOW_SECONDS_HOUR_12","REGEX_HIDE_SECONDS_HOUR_12","REGEX_SHOW_SECONDS_HOUR_24","REGEX_HIDE_SECONDS_HOUR_24","getDateFromTimeString","time","timeFormatOptions","errorType","hour12","regex","test","timeParts","exec","selectedHours","minutes","seconds","amPm","hours","toLowerCase","toString","adjustedDate"],"mappings":";;;;;;;;;;;aASgBI;eAAAA;;IAqCAK,sBAAAA;;;IA4BAa,gBAAAA;;;yBAiEAmB;eAAAA;;sBA9EAxB;eAAAA;;IAmCAU,eAAAA;;;aAzEArB;eAAAA;;;AArBhB,SAASN,YAAYC,IAAU;IAC7B,OAAO,CAACC,MAAMD,KAAKE,OAAO;AAC5B;AAKO,mBAAmBF,IAAiB;IACzC,IAAI,CAACA,MAAM;QACT,OAAO;IACT;IACA,IAAI,CAACD,YAAYC,OAAO;QACtB,OAAO;IACT;IACA,OAAOA,KAAKI,WAAW;AACzB;AAMO,mBAAmBE,GAAW;IACnC,IAAIA,QAAQ,MAAMA,QAAQ,WAAW;QACnC,OAAO;IACT;IACA,MAAMN,OAAO,IAAIO,KAAKD;IACtB,OAAOP,YAAYC,QAAQA,OAAO;AACpC;AAiBO,gCAAgCA,IAAU,EAAE,EAAES,SAAS,EAAEC,WAAW,EAAqB,GAAG,CAAC,CAAC;IACnG,OAAOV,KAAKW,kBAAkB,CAACC,WAAW;QACxCC,MAAM;QACNJ;QACAK,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O;QACrB,OAAO;YAAEzC,MAAM;YAAM2C,WAAW;QAAgB;IAClD;IAEA,MAAMI,YAAY,sCAAsCC,IAAI,CAACP;IAC7D,IAAI,CAACM,WAAW;QACd,OAAO;YAAE/C,MAAM;YAAM2C,WAAW;QAAgB;IAClD;IAEA,MAAM,GAAGM,eAAeC,SAASC,SAASC,KAAK,GAAGL;IAClD,IAAIM,QAAQJ;IAEZ,2CAA2C;IAC3C,IAAIL,UAAUQ,MAAM;QAClB,IAAIA,KAAKE,WAAW,OAAO,QAAQ,CAACD,UAAU,IAAI;YAChDA,QAAS,CAAA,CAACA,QAAQ,EAAA,CAAC,CAAGE,QAAQ;QAChC,OAAO,IAAIH,KAAKE,WAAW,OAAO,QAAQ,CAACD,UAAU,IAAI;YACvDA,QAAQ;QACV;IACF;IAEA,MAAMG,eAAe,IAAIjD,KAAKoB;IAC9B6B,aAAapC,QAAQ,CAAC,CAACiC,OAAO,CAACH,SAASC,UAAU,CAACA,UAAU;IAE7D,wEAAwE;IACxE,IAAIK,eAAe7B,iBAAiB;QAClC6B,aAAahC,OAAO,CAACgC,aAAa/B,OAAO,KAAK;IAChD;IAEA,IAAI+B,gBAAgB5B,eAAe;QACjC,OAAO;YAAE5B,MAAMwD;YAAcb,WAAW;QAAgB;IAC1D;IAEA,OAAO;QAAE3C,MAAMwD;IAAa;AAC9B"}
1
+ {"version":3,"sources":["../src/components/TimePicker/timeMath.ts"],"sourcesContent":["import type { TimeFormatOptions, TimeStringValidationResult } from './TimePicker.types';\n\nfunction isValidDate(date: Date): boolean {\n return !isNaN(date.getTime());\n}\n\n/**\n * Converts a Date object to a string key.\n */\nexport function dateToKey(date: Date | null): string {\n if (!date) {\n return '';\n }\n if (!isValidDate(date)) {\n return 'invalid';\n }\n return date.toISOString();\n}\n\n/**\n * Converts a string key back to a Date object.\n * Returns undefined for keys that don't represent valid dates.\n */\nexport function keyToDate(key: string): Date | null {\n if (key === '' || key === 'invalid') {\n return null;\n }\n const date = new Date(key);\n return isValidDate(date) ? date : null;\n}\n\n/**\n * Formats a Date object into a time string based on provided options.\n *\n * @param date - The Date object to be formatted.\n * @param options - Formatting options. It has two properties:\n * 1. hourCycle (default: undefined): Determines if the time format should be 12-hour or 24-hour.\n * 2. showSeconds (default: false): Determines if the seconds should be included in the formatted string.\n * @returns Formatted time string based on the given options.\n *\n * @example\n * const date = new Date(2023, 9, 6, 23, 45, 12);\n * formatDateToTimeString(date); // Returns \"23:45\" in CET\n * formatDateToTimeString(date, \\{ showSeconds: true \\}); // Returns \"23:45:12\" in CET\n * formatDateToTimeString(date, \\{ hourCycle: 'h12', showSeconds: true \\}); // Returns \"11:45:12 PM\" in CET\n */\nexport function formatDateToTimeString(date: Date, { hourCycle, showSeconds }: TimeFormatOptions = {}): string {\n return date.toLocaleTimeString(undefined, {\n hour: 'numeric',\n hourCycle,\n minute: '2-digit',\n second: showSeconds ? '2-digit' : undefined,\n });\n}\n\n/**\n * Get the start date anchor based on the provided parameters.\n * @example\n * const date = new Date(2023, 9, 6); // October 6, 2023\n * getStartAnchorDate(date, 5); // Returns a date for October 6, 2023, 05:00:00\n */\nexport function getDateStartAnchor(dateAnchor: Date, startHour: number): Date {\n const startDate = new Date(dateAnchor);\n startDate.setHours(startHour, 0, 0, 0);\n return startDate;\n}\n\n/**\n * Get the end date anchor based on the provided parameters.\n * @example\n * const date = new Date(2023, 9, 6); // October 6, 2023\n * getEndAnchorDate(date, 5, 10); // Returns a date for October 6, 2023, 10:00:00\n * getEndAnchorDate(date, 10, 5); // Returns a date for October 7, 2023, 05:00:00 (next day due to hour conditions)\n */\nexport function getDateEndAnchor(dateAnchor: Date, startHour: number, endHour: number): Date {\n const endDate = new Date(dateAnchor);\n if (startHour > endHour || endHour === 24) {\n endDate.setDate(endDate.getDate() + 1);\n }\n endDate.setHours(endHour === 24 ? 0 : endHour, 0, 0, 0);\n return endDate;\n}\n\n/**\n * Generates an array of Date objects between two given Date anchors.\n *\n * @param dateStartAnchor - The starting Date anchor.\n * @param dateEndAnchor - The ending Date anchor.\n * @param increment - The minute increment between each Date in the resulting array.\n * @returns - An array of Date objects.\n *\n * @example\n * const start = new Date(2023, 0, 1, 10, 0); // Jan 1, 2023 10:00:00 AM\n * const end = new Date(2023, 0, 1, 11, 0); // Jan 1, 2023 11:00:00 AM\n * getTimesBetween(start, end, 15); // Returns array with Dates [10:00, 10:15, 10:30, 10:45]\n */\nexport function getTimesBetween(dateStartAnchor: Date, dateEndAnchor: Date, increment: number): Date[] {\n if (increment <= 0) {\n // eslint-disable-next-line no-console\n console.error('Increment value should be a positive number.');\n return [];\n }\n\n const result: Date[] = [];\n\n const startDate = new Date(dateStartAnchor);\n while (startDate < dateEndAnchor) {\n result.push(new Date(startDate));\n startDate.setMinutes(startDate.getMinutes() + increment);\n }\n\n return result;\n}\n\nconst REGEX_SHOW_SECONDS_HOUR_12 = /^((1[0-2]|0?[0-9]):([0-5][0-9]):([0-5][0-9])\\s([AaPp][Mm]))$/;\nconst REGEX_HIDE_SECONDS_HOUR_12 = /^((1[0-2]|0?[0-9]):[0-5][0-9]\\s([AaPp][Mm]))$/;\nconst REGEX_SHOW_SECONDS_HOUR_24 = /^([0-1]?[0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9]$/;\nconst REGEX_HIDE_SECONDS_HOUR_24 = /^([0-1]?[0-9]|2[0-4]):[0-5][0-9]$/;\n\n/**\n * Calculates a new date from the user-selected time string based on anchor dates.\n * Returns an object containing a date if the provided time string is valid, and an optional string indicating the type of error.\n *\n * @param time - The time string to be parsed (e.g., \"2:30 PM\", \"15:45:20\").\n * @param dateStartAnchor - The start anchor date.\n * @param dateEndAnchor - The end anchor date.\n * @param timeFormatOptions - format options for the provided time string.\n * @returns An object with either a 'date' or an 'errorType'.\n *\n * @example\n * Input: time=\"2:30 PM\", dateStartAnchor=2023-10-06T12:00:00Z, dateEndAnchor=2023-10-07T12:00:00Z, options={hourCycle: 'h12', showSeconds: false}\n * Output: { date: 2023-10-06T14:30:00Z }\n *\n * Input: time=\"25:30\"\n * Output: { errorType: 'invalid-input' }\n *\n * Input: time=\"1:30 AM\", dateStartAnchor=2023-10-06T03:00:00Z, dateEndAnchor=2023-10-07T03:00:00Z, options={hourCycle: 'h12', showSeconds: false}\n * Output: { date: 2023-10-07T01:30:00Z, errorType: 'out-of-bounds' }\n */\nexport function getDateFromTimeString(\n time: string | undefined,\n dateStartAnchor: Date,\n dateEndAnchor: Date,\n timeFormatOptions: TimeFormatOptions,\n): TimeStringValidationResult {\n if (!time) {\n return { date: null, errorType: 'required-input' };\n }\n\n const { hourCycle, showSeconds } = timeFormatOptions;\n const hour12 = hourCycle === 'h11' || hourCycle === 'h12';\n\n // Determine the regex based on format\n const regex = hour12\n ? showSeconds\n ? REGEX_SHOW_SECONDS_HOUR_12\n : REGEX_HIDE_SECONDS_HOUR_12\n : showSeconds\n ? REGEX_SHOW_SECONDS_HOUR_24\n : REGEX_HIDE_SECONDS_HOUR_24;\n\n if (!regex.test(time)) {\n return { date: null, errorType: 'invalid-input' };\n }\n\n const timeParts = /^(\\d\\d?):(\\d\\d):?(\\d\\d)? ?([ap]m)?/i.exec(time);\n if (!timeParts) {\n return { date: null, errorType: 'invalid-input' };\n }\n\n const [, selectedHours, minutes, seconds, amPm] = timeParts;\n let hours = selectedHours;\n\n // Adjust for 12-hour time format if needed\n if (hour12 && amPm) {\n if (amPm.toLowerCase() === 'pm' && +hours !== 12) {\n hours = (+hours + 12).toString();\n } else if (amPm.toLowerCase() === 'am' && +hours === 12) {\n hours = '0';\n }\n }\n\n const adjustedDate = new Date(dateStartAnchor);\n adjustedDate.setHours(+hours, +minutes, seconds ? +seconds : 0);\n\n // Adjust to the next day if the selected time is before the anchor time\n if (adjustedDate < dateStartAnchor) {\n adjustedDate.setDate(adjustedDate.getDate() + 1);\n }\n\n if (adjustedDate >= dateEndAnchor) {\n return { date: adjustedDate, errorType: 'out-of-bounds' };\n }\n\n return { date: adjustedDate };\n}\n"],"names":["isValidDate","date","isNaN","getTime","dateToKey","toISOString","keyToDate","key","Date","formatDateToTimeString","hourCycle","showSeconds","toLocaleTimeString","undefined","hour","minute","second","getDateStartAnchor","dateAnchor","startHour","startDate","setHours","getDateEndAnchor","endHour","endDate","setDate","getDate","getTimesBetween","dateStartAnchor","dateEndAnchor","increment","console","error","result","push","setMinutes","getMinutes","REGEX_SHOW_SECONDS_HOUR_12","REGEX_HIDE_SECONDS_HOUR_12","REGEX_SHOW_SECONDS_HOUR_24","REGEX_HIDE_SECONDS_HOUR_24","getDateFromTimeString","time","timeFormatOptions","errorType","hour12","regex","test","timeParts","exec","selectedHours","minutes","seconds","amPm","hours","toLowerCase","toString","adjustedDate"],"mappings":";;;;;;;;;;;aASgBI;eAAAA;;IAqCAK,sBAAAA;;;IA4BAa,gBAAAA;;;yBAiEAmB;eAAAA;;sBA9EAxB;eAAAA;;IAmCAU,eAAAA;;;aAzEArB;eAAAA;;;AArBhB,SAASN,YAAYC,IAAU;IAC7B,OAAO,CAACC,MAAMD,KAAKE,OAAO;AAC5B;AAKO,mBAAmBF,IAAiB;IACzC,IAAI,CAACA,MAAM;QACT,OAAO;IACT;IACA,IAAI,CAACD,YAAYC,OAAO;QACtB,OAAO;IACT;IACA,OAAOA,KAAKI,WAAW;AACzB;AAMO,mBAAmBE,GAAW;IACnC,IAAIA,QAAQ,MAAMA,QAAQ,WAAW;QACnC,OAAO;IACT;IACA,MAAMN,OAAO,IAAIO,KAAKD;IACtB,OAAOP,YAAYC,QAAQA,OAAO;AACpC;AAiBO,gCAAgCA,IAAU,EAAE,EAAES,SAAS,EAAEC,WAAW,EAAqB,GAAG,CAAC,CAAC;IACnG,OAAOV,KAAKW,kBAAkB,CAACC,WAAW;QACxCC,MAAM;QACNJ;QACAK,QAAQ;QACRC,QAAQL,cAAc,YAAYE;IACpC;AACF;AAQO,4BAA4BK,UAAgB,EAAEC,SAAiB;IACpE,MAAMC,YAAY,IAAIZ,KAAKU;IAC3BE,UAAUC,QAAQ,CAACF,WAAW,GAAG,GAAG;I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AgB;IAClD;IAEA,MAAM,GAAGM,eAAeC,SAASC,SAASC,KAAK,GAAGL;IAClD,IAAIM,QAAQJ;IAEZ,2CAA2C;IAC3C,IAAIL,UAAUQ,MAAM;QAClB,IAAIA,KAAKE,WAAW,OAAO,QAAQ,CAACD,UAAU,IAAI;YAChDA,QAAS,CAAA,CAACA,QAAQ,EAAA,CAAC,CAAGE,QAAQ;QAChC,OAAO,IAAIH,KAAKE,WAAW,OAAO,QAAQ,CAACD,UAAU,IAAI;YACvDA,QAAQ;QACV;IACF;IAEA,MAAMG,eAAe,IAAIjD,KAAKoB;IAC9B6B,aAAapC,QAAQ,CAAC,CAACiC,OAAO,CAACH,SAASC,UAAU,CAACA,UAAU;IAE7D,wEAAwE;IACxE,IAAIK,eAAe7B,iBAAiB;QAClC6B,aAAahC,OAAO,CAACgC,aAAa/B,OAAO,KAAK;IAChD;IAEA,IAAI+B,gBAAgB5B,eAAe;QACjC,OAAO;YAAE5B,MAAMwD;YAAcb,WAAW;QAAgB;IAC1D;IAEA,OAAO;QAAE3C,MAAMwD;IAAa;AAC9B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-timepicker-compat",
3
- "version": "0.0.0-nightly-20250828-0408.1",
3
+ "version": "0.0.0-nightly-20250829-0406.1",
4
4
  "description": "Fluent UI TimePicker Compat Component",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -18,22 +18,22 @@
18
18
  },
19
19
  "license": "MIT",
20
20
  "devDependencies": {
21
- "@fluentui/react-provider": "0.0.0-nightly-20250828-0408.1",
22
- "@fluentui/react-components": "0.0.0-nightly-20250828-0408.1",
21
+ "@fluentui/react-provider": "0.0.0-nightly-20250829-0406.1",
22
+ "@fluentui/react-components": "0.0.0-nightly-20250829-0406.1",
23
23
  "@fluentui/eslint-plugin": "*",
24
- "@fluentui/react-conformance": "0.0.0-nightly-20250828-0408.1",
25
- "@fluentui/react-conformance-griffel": "0.0.0-nightly-20250828-0408.1",
24
+ "@fluentui/react-conformance": "0.0.0-nightly-20250829-0406.1",
25
+ "@fluentui/react-conformance-griffel": "0.0.0-nightly-20250829-0406.1",
26
26
  "@fluentui/scripts-api-extractor": "*",
27
27
  "@fluentui/scripts-cypress": "*"
28
28
  },
29
29
  "dependencies": {
30
- "@fluentui/keyboard-keys": "0.0.0-nightly-20250828-0408.1",
31
- "@fluentui/react-combobox": "0.0.0-nightly-20250828-0408.1",
32
- "@fluentui/react-field": "0.0.0-nightly-20250828-0408.1",
33
- "@fluentui/react-jsx-runtime": "0.0.0-nightly-20250828-0408.1",
34
- "@fluentui/react-shared-contexts": "0.0.0-nightly-20250828-0408.1",
35
- "@fluentui/react-theme": "0.0.0-nightly-20250828-0408.1",
36
- "@fluentui/react-utilities": "0.0.0-nightly-20250828-0408.1",
30
+ "@fluentui/keyboard-keys": "0.0.0-nightly-20250829-0406.1",
31
+ "@fluentui/react-combobox": "0.0.0-nightly-20250829-0406.1",
32
+ "@fluentui/react-field": "0.0.0-nightly-20250829-0406.1",
33
+ "@fluentui/react-jsx-runtime": "0.0.0-nightly-20250829-0406.1",
34
+ "@fluentui/react-shared-contexts": "0.0.0-nightly-20250829-0406.1",
35
+ "@fluentui/react-theme": "0.0.0-nightly-20250829-0406.1",
36
+ "@fluentui/react-utilities": "0.0.0-nightly-20250829-0406.1",
37
37
  "@griffel/react": "^1.5.22",
38
38
  "@swc/helpers": "^0.5.1"
39
39
  },