@govtechsg/sgds-web-component 3.24.0-rc.1 → 3.24.0

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.
Files changed (71) hide show
  1. package/components/Checkbox/index.umd.min.js +1 -1
  2. package/components/Checkbox/index.umd.min.js.map +1 -1
  3. package/components/ComboBox/index.umd.min.js +1 -1
  4. package/components/ComboBox/index.umd.min.js.map +1 -1
  5. package/components/Datepicker/datepicker-calendar.js +4 -4
  6. package/components/Datepicker/datepicker-calendar.js.map +1 -1
  7. package/components/Datepicker/datepicker-header.js +2 -2
  8. package/components/Datepicker/datepicker-header.js.map +1 -1
  9. package/components/Datepicker/datepicker-input.js +48 -13
  10. package/components/Datepicker/datepicker-input.js.map +1 -1
  11. package/components/Datepicker/index.umd.min.js +335 -335
  12. package/components/Datepicker/index.umd.min.js.map +1 -1
  13. package/components/Datepicker/sgds-datepicker.js +6 -6
  14. package/components/Datepicker/sgds-datepicker.js.map +1 -1
  15. package/components/Radio/index.umd.min.js +1 -1
  16. package/components/Radio/index.umd.min.js.map +1 -1
  17. package/components/Switch/index.umd.min.js +1 -1
  18. package/components/Switch/index.umd.min.js.map +1 -1
  19. package/components/Switch/switch.js +1 -1
  20. package/components/index.umd.min.js +423 -423
  21. package/components/index.umd.min.js.map +1 -1
  22. package/css/fouc.css +1 -1
  23. package/custom-elements.json +645 -645
  24. package/index.umd.min.js +467 -467
  25. package/index.umd.min.js.map +1 -1
  26. package/package.json +3 -1
  27. package/react/components/Datepicker/datepicker-calendar.cjs.js +4 -4
  28. package/react/components/Datepicker/datepicker-calendar.cjs.js.map +1 -1
  29. package/react/components/Datepicker/datepicker-calendar.js +4 -4
  30. package/react/components/Datepicker/datepicker-calendar.js.map +1 -1
  31. package/react/components/Datepicker/datepicker-header.cjs.js +2 -2
  32. package/react/components/Datepicker/datepicker-header.cjs.js.map +1 -1
  33. package/react/components/Datepicker/datepicker-header.js +2 -2
  34. package/react/components/Datepicker/datepicker-header.js.map +1 -1
  35. package/react/components/Datepicker/datepicker-input.cjs.js +52 -13
  36. package/react/components/Datepicker/datepicker-input.cjs.js.map +1 -1
  37. package/react/components/Datepicker/datepicker-input.js +48 -13
  38. package/react/components/Datepicker/datepicker-input.js.map +1 -1
  39. package/react/components/Datepicker/sgds-datepicker.cjs.js +6 -6
  40. package/react/components/Datepicker/sgds-datepicker.cjs.js.map +1 -1
  41. package/react/components/Datepicker/sgds-datepicker.js +6 -6
  42. package/react/components/Datepicker/sgds-datepicker.js.map +1 -1
  43. package/react/components/Switch/switch.cjs.js +1 -1
  44. package/react/components/Switch/switch.js +1 -1
  45. package/react/index.cjs.js +6 -6
  46. package/react/index.d.ts +1 -1
  47. package/react/index.js +1 -1
  48. package/react/styles/form-check.cjs.js +1 -1
  49. package/react/styles/form-check.js +1 -1
  50. package/react/utils/time.cjs.js +7 -7
  51. package/react/utils/time.cjs.js.map +1 -1
  52. package/react/utils/time.js +1 -1
  53. package/react/utils/time.js.map +1 -1
  54. package/styles/form-check.js +1 -1
  55. package/types/react.d.ts +16 -16
  56. package/utils/time.js +1 -1
  57. package/utils/time.js.map +1 -1
  58. package/react/utils/date-helpers.cjs.js +0 -120
  59. package/react/utils/date-helpers.cjs.js.map +0 -1
  60. package/react/utils/date-helpers.js +0 -108
  61. package/react/utils/date-helpers.js.map +0 -1
  62. package/react/utils/date-mask.cjs.js +0 -203
  63. package/react/utils/date-mask.cjs.js.map +0 -1
  64. package/react/utils/date-mask.js +0 -199
  65. package/react/utils/date-mask.js.map +0 -1
  66. package/utils/date-helpers.d.ts +0 -22
  67. package/utils/date-helpers.js +0 -107
  68. package/utils/date-helpers.js.map +0 -1
  69. package/utils/date-mask.d.ts +0 -44
  70. package/utils/date-mask.js +0 -198
  71. package/utils/date-mask.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"time.cjs.js","sources":["../../../src/utils/time.ts"],"sourcesContent":["import { getDaysInMonth, isLastDayOfMonth, lastDayOfMonth } from \"./date-helpers\";\n\nexport const DATE_PATTERNS = {\n \"DD/MM/YYYY\": {\n imPattern: \"`dd{/}`mm{/}`yyyy\",\n imRangePattern: \"`dd{/}`mm{/}`yyyy - `DD{/}`MM{/}`YYYY\",\n fnsPattern: \"dd/MM/yyyy\"\n },\n \"MM/DD/YYYY\": {\n imPattern: \"`mm{/}`dd{/}`yyyy\",\n imRangePattern: \"`mm{/}`dd{/}`yyyy - `MM{/}`DD{/}`YYYY\",\n fnsPattern: \"MM/dd/yyyy\"\n },\n \"YYYY/MM/DD\": {\n imPattern: \"`yyyy{/}`mm{/}`dd\",\n imRangePattern: \"`yyyy{/}`mm{/}`dd - `YYYY{/}`MM{/}`DD\",\n fnsPattern: \"yyyy/MM/dd\"\n }\n};\n\n/**\n * @description - creates calendar's year view years array with context of\n * datepicker's displayDate and current year\n * Fixes current year to the start of array\n */\nexport const createYearViewArray = (displayDate: Date, currentYear: number) => {\n // keeping the year range position to be always fixed by setting current year to the first element of the calendar\n const displayYear = displayDate.getFullYear();\n const remainder = (displayYear - currentYear) % 12;\n const yearsPosition = remainder < 0 ? 12 + remainder : remainder;\n\n const yearArray = [];\n const startLimit = displayYear - yearsPosition;\n const endLimit = displayYear - yearsPosition + 12 - 1; // -1 to match the index of the years (index starts from 0)\n\n for (let i = startLimit; i < endLimit + 1; i++) {\n yearArray.push(i);\n }\n\n return yearArray;\n};\nexport const sanitizedNextMonth = (d: Date) => {\n const month = d.getMonth();\n const year = d.getFullYear();\n const date = d.getDate();\n const nextMonthDate = new Date(year, month + 1);\n const numberOfDaysNextMonth = getDaysInMonth(nextMonthDate);\n\n if (isLastDayOfMonth(d) && numberOfDaysNextMonth < date) {\n return lastDayOfMonth(nextMonthDate);\n } else {\n return new Date(year, month + 1, date);\n }\n};\nexport const sanitizedPreviousMonth = (d: Date) => {\n const month = d.getMonth();\n const year = d.getFullYear();\n const date = d.getDate();\n const prevMonthDate = new Date(year, month - 1);\n const numberOfDaysPrevMonth = getDaysInMonth(prevMonthDate);\n if (isLastDayOfMonth(d) && numberOfDaysPrevMonth < date) {\n return lastDayOfMonth(prevMonthDate);\n } else {\n return new Date(year, month - 1, date);\n }\n};\nexport const setTimeToNoon = (date: Date): Date => {\n const newDate = new Date(date);\n newDate.setHours(12);\n newDate.setMinutes(0);\n newDate.setSeconds(0);\n newDate.setMilliseconds(0);\n return newDate;\n};\n\nexport const sortAscDates = (dates: Date[]) => {\n return dates.sort((a, b) => a.getTime() - b.getTime());\n};\n"],"names":["getDaysInMonth","isLastDayOfMonth","lastDayOfMonth"],"mappings":";;;;;;;AAEa,MAAA,aAAa,GAAG;AAC3B,IAAA,YAAY,EAAE;AACZ,QAAA,SAAS,EAAE,mBAAmB;AAC9B,QAAA,cAAc,EAAE,uCAAuC;AACvD,QAAA,UAAU,EAAE,YAAY;AACzB,KAAA;AACD,IAAA,YAAY,EAAE;AACZ,QAAA,SAAS,EAAE,mBAAmB;AAC9B,QAAA,cAAc,EAAE,uCAAuC;AACvD,QAAA,UAAU,EAAE,YAAY;AACzB,KAAA;AACD,IAAA,YAAY,EAAE;AACZ,QAAA,SAAS,EAAE,mBAAmB;AAC9B,QAAA,cAAc,EAAE,uCAAuC;AACvD,QAAA,UAAU,EAAE,YAAY;AACzB,KAAA;EACD;AAEF;;;;AAIG;MACU,mBAAmB,GAAG,CAAC,WAAiB,EAAE,WAAmB,KAAI;;AAE5E,IAAA,MAAM,WAAW,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;IAC9C,MAAM,SAAS,GAAG,CAAC,WAAW,GAAG,WAAW,IAAI,EAAE,CAAC;AACnD,IAAA,MAAM,aAAa,GAAG,SAAS,GAAG,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,SAAS,CAAC;IAEjE,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,IAAA,MAAM,UAAU,GAAG,WAAW,GAAG,aAAa,CAAC;IAC/C,MAAM,QAAQ,GAAG,WAAW,GAAG,aAAa,GAAG,EAAE,GAAG,CAAC,CAAC;A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AAC,IAAI,qBAAqB,GAAG,IAAI,EAAE;AACvD,QAAA,OAAOC,0BAAc,CAAC,aAAa,CAAC,CAAC;KACtC;SAAM;QACL,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;KACxC;AACH,EAAE;AACW,MAAA,aAAa,GAAG,CAAC,IAAU,KAAU;AAChD,IAAA,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/B,IAAA,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AACrB,IAAA,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACtB,IAAA,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACtB,IAAA,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;AAC3B,IAAA,OAAO,OAAO,CAAC;AACjB;;;;;;;;"}
1
+ {"version":3,"file":"time.cjs.js","sources":["../../../src/utils/time.ts"],"sourcesContent":["import { getDaysInMonth, isLastDayOfMonth, lastDayOfMonth } from \"date-fns\";\n\nexport const DATE_PATTERNS = {\n \"DD/MM/YYYY\": {\n imPattern: \"`dd{/}`mm{/}`yyyy\",\n imRangePattern: \"`dd{/}`mm{/}`yyyy - `DD{/}`MM{/}`YYYY\",\n fnsPattern: \"dd/MM/yyyy\"\n },\n \"MM/DD/YYYY\": {\n imPattern: \"`mm{/}`dd{/}`yyyy\",\n imRangePattern: \"`mm{/}`dd{/}`yyyy - `MM{/}`DD{/}`YYYY\",\n fnsPattern: \"MM/dd/yyyy\"\n },\n \"YYYY/MM/DD\": {\n imPattern: \"`yyyy{/}`mm{/}`dd\",\n imRangePattern: \"`yyyy{/}`mm{/}`dd - `YYYY{/}`MM{/}`DD\",\n fnsPattern: \"yyyy/MM/dd\"\n }\n};\n\n/**\n * @description - creates calendar's year view years array with context of\n * datepicker's displayDate and current year\n * Fixes current year to the start of array\n */\nexport const createYearViewArray = (displayDate: Date, currentYear: number) => {\n // keeping the year range position to be always fixed by setting current year to the first element of the calendar\n const displayYear = displayDate.getFullYear();\n const remainder = (displayYear - currentYear) % 12;\n const yearsPosition = remainder < 0 ? 12 + remainder : remainder;\n\n const yearArray = [];\n const startLimit = displayYear - yearsPosition;\n const endLimit = displayYear - yearsPosition + 12 - 1; // -1 to match the index of the years (index starts from 0)\n\n for (let i = startLimit; i < endLimit + 1; i++) {\n yearArray.push(i);\n }\n\n return yearArray;\n};\nexport const sanitizedNextMonth = (d: Date) => {\n const month = d.getMonth();\n const year = d.getFullYear();\n const date = d.getDate();\n const nextMonthDate = new Date(year, month + 1);\n const numberOfDaysNextMonth = getDaysInMonth(nextMonthDate);\n\n if (isLastDayOfMonth(d) && numberOfDaysNextMonth < date) {\n return lastDayOfMonth(nextMonthDate);\n } else {\n return new Date(year, month + 1, date);\n }\n};\nexport const sanitizedPreviousMonth = (d: Date) => {\n const month = d.getMonth();\n const year = d.getFullYear();\n const date = d.getDate();\n const prevMonthDate = new Date(year, month - 1);\n const numberOfDaysPrevMonth = getDaysInMonth(prevMonthDate);\n if (isLastDayOfMonth(d) && numberOfDaysPrevMonth < date) {\n return lastDayOfMonth(prevMonthDate);\n } else {\n return new Date(year, month - 1, date);\n }\n};\nexport const setTimeToNoon = (date: Date): Date => {\n const newDate = new Date(date);\n newDate.setHours(12);\n newDate.setMinutes(0);\n newDate.setSeconds(0);\n newDate.setMilliseconds(0);\n return newDate;\n};\n\nexport const sortAscDates = (dates: Date[]) => {\n return dates.sort((a, b) => a.getTime() - b.getTime());\n};\n"],"names":["getDaysInMonth","isLastDayOfMonth","lastDayOfMonth"],"mappings":";;;;;;;AAEa,MAAA,aAAa,GAAG;AAC3B,IAAA,YAAY,EAAE;AACZ,QAAA,SAAS,EAAE,mBAAmB;AAC9B,QAAA,cAAc,EAAE,uCAAuC;AACvD,QAAA,UAAU,EAAE,YAAY;AACzB,KAAA;AACD,IAAA,YAAY,EAAE;AACZ,QAAA,SAAS,EAAE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;AACjB;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { getDaysInMonth, isLastDayOfMonth, lastDayOfMonth } from './date-helpers.js';
2
+ import { getDaysInMonth, isLastDayOfMonth, lastDayOfMonth } from 'date-fns';
3
3
 
4
4
  const DATE_PATTERNS = {
5
5
  "DD/MM/YYYY": {
@@ -1 +1 @@
1
- {"version":3,"file":"time.js","sources":["../../../src/utils/time.ts"],"sourcesContent":["import { getDaysInMonth, isLastDayOfMonth, lastDayOfMonth } from \"./date-helpers\";\n\nexport const DATE_PATTERNS = {\n \"DD/MM/YYYY\": {\n imPattern: \"`dd{/}`mm{/}`yyyy\",\n imRangePattern: \"`dd{/}`mm{/}`yyyy - `DD{/}`MM{/}`YYYY\",\n fnsPattern: \"dd/MM/yyyy\"\n },\n \"MM/DD/YYYY\": {\n imPattern: \"`mm{/}`dd{/}`yyyy\",\n imRangePattern: \"`mm{/}`dd{/}`yyyy - `MM{/}`DD{/}`YYYY\",\n fnsPattern: \"MM/dd/yyyy\"\n },\n \"YYYY/MM/DD\": {\n imPattern: \"`yyyy{/}`mm{/}`dd\",\n imRangePattern: \"`yyyy{/}`mm{/}`dd - `YYYY{/}`MM{/}`DD\",\n fnsPattern: \"yyyy/MM/dd\"\n }\n};\n\n/**\n * @description - creates calendar's year view years array with context of\n * datepicker's displayDate and current year\n * Fixes current year to the start of array\n */\nexport const createYearViewArray = (displayDate: Date, currentYear: number) => {\n // keeping the year range position to be always fixed by setting current year to the first element of the calendar\n const displayYear = displayDate.getFullYear();\n const remainder = (displayYear - currentYear) % 12;\n const yearsPosition = remainder < 0 ? 12 + remainder : remainder;\n\n const yearArray = [];\n const startLimit = displayYear - yearsPosition;\n const endLimit = displayYear - yearsPosition + 12 - 1; // -1 to match the index of the years (index starts from 0)\n\n for (let i = startLimit; i < endLimit + 1; i++) {\n yearArray.push(i);\n }\n\n return yearArray;\n};\nexport const sanitizedNextMonth = (d: Date) => {\n const month = d.getMonth();\n const year = d.getFullYear();\n const date = d.getDate();\n const nextMonthDate = new Date(year, month + 1);\n const numberOfDaysNextMonth = getDaysInMonth(nextMonthDate);\n\n if (isLastDayOfMonth(d) && numberOfDaysNextMonth < date) {\n return lastDayOfMonth(nextMonthDate);\n } else {\n return new Date(year, month + 1, date);\n }\n};\nexport const sanitizedPreviousMonth = (d: Date) => {\n const month = d.getMonth();\n const year = d.getFullYear();\n const date = d.getDate();\n const prevMonthDate = new Date(year, month - 1);\n const numberOfDaysPrevMonth = getDaysInMonth(prevMonthDate);\n if (isLastDayOfMonth(d) && numberOfDaysPrevMonth < date) {\n return lastDayOfMonth(prevMonthDate);\n } else {\n return new Date(year, month - 1, date);\n }\n};\nexport const setTimeToNoon = (date: Date): Date => {\n const newDate = new Date(date);\n newDate.setHours(12);\n newDate.setMinutes(0);\n newDate.setSeconds(0);\n newDate.setMilliseconds(0);\n return newDate;\n};\n\nexport const sortAscDates = (dates: Date[]) => {\n return dates.sort((a, b) => a.getTime() - b.getTime());\n};\n"],"names":[],"mappings":";;;AAEa,MAAA,aAAa,GAAG;AAC3B,IAAA,YAAY,EAAE;AACZ,QAAA,SAAS,EAAE,mBAAmB;AAC9B,QAAA,cAAc,EAAE,uCAAuC;AACvD,QAAA,UAAU,EAAE,YAAY;AACzB,KAAA;AACD,IAAA,YAAY,EAAE;AACZ,QAAA,SAAS,EAAE,mBAAmB;AAC9B,QAAA,cAAc,EAAE,uCAAuC;AACvD,QAAA,UAAU,EAAE,YAAY;AACzB,KAAA;AACD,IAAA,YAAY,EAAE;AACZ,QAAA,SAAS,EAAE,mBAAmB;AAC9B,QAAA,cAAc,EAAE,uCAAuC;AACvD,QAAA,UAAU,EAAE,YAAY;AACzB,KAAA;EACD;AAEF;;;;AAIG;MACU,mBAAmB,GAAG,CAAC,WAAiB,EAAE,WAAmB,KAAI;;AAE5E,IAAA,MAAM,WAAW,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;IAC9C,MAAM,SAAS,GAAG,CAAC,WAAW,GAA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,CAAC,CAAC,WAAW,EAAE,CAAC;AAC7B,IAAA,MAAM,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;IACzB,MAAM,aAAa,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;AAChD,IAAA,MAAM,qBAAqB,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;IAC5D,IAAI,gBAAgB,CAAC,CAAC,CAAC,IAAI,qBAAqB,GAAG,IAAI,EAAE;AACvD,QAAA,OAAO,cAAc,CAAC,aAAa,CAAC,CAAC;KACtC;SAAM;QACL,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;KACxC;AACH,EAAE;AACW,MAAA,aAAa,GAAG,CAAC,IAAU,KAAU;AAChD,IAAA,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/B,IAAA,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AACrB,IAAA,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACtB,IAAA,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACtB,IAAA,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;AAC3B,IAAA,OAAO,OAAO,CAAC;AACjB;;;;"}
1
+ {"version":3,"file":"time.js","sources":["../../../src/utils/time.ts"],"sourcesContent":["import { getDaysInMonth, isLastDayOfMonth, lastDayOfMonth } from \"date-fns\";\n\nexport const DATE_PATTERNS = {\n \"DD/MM/YYYY\": {\n imPattern: \"`dd{/}`mm{/}`yyyy\",\n imRangePattern: \"`dd{/}`mm{/}`yyyy - `DD{/}`MM{/}`YYYY\",\n fnsPattern: \"dd/MM/yyyy\"\n },\n \"MM/DD/YYYY\": {\n imPattern: \"`mm{/}`dd{/}`yyyy\",\n imRangePattern: \"`mm{/}`dd{/}`yyyy - `MM{/}`DD{/}`YYYY\",\n fnsPattern: \"MM/dd/yyyy\"\n },\n \"YYYY/MM/DD\": {\n imPattern: \"`yyyy{/}`mm{/}`dd\",\n imRangePattern: \"`yyyy{/}`mm{/}`dd - `YYYY{/}`MM{/}`DD\",\n fnsPattern: \"yyyy/MM/dd\"\n }\n};\n\n/**\n * @description - creates calendar's year view years array with context of\n * datepicker's displayDate and current year\n * Fixes current year to the start of array\n */\nexport const createYearViewArray = (displayDate: Date, currentYear: number) => {\n // keeping the year range position to be always fixed by setting current year to the first element of the calendar\n const displayYear = displayDate.getFullYear();\n const remainder = (displayYear - currentYear) % 12;\n const yearsPosition = remainder < 0 ? 12 + remainder : remainder;\n\n const yearArray = [];\n const startLimit = displayYear - yearsPosition;\n const endLimit = displayYear - yearsPosition + 12 - 1; // -1 to match the index of the years (index starts from 0)\n\n for (let i = startLimit; i < endLimit + 1; i++) {\n yearArray.push(i);\n }\n\n return yearArray;\n};\nexport const sanitizedNextMonth = (d: Date) => {\n const month = d.getMonth();\n const year = d.getFullYear();\n const date = d.getDate();\n const nextMonthDate = new Date(year, month + 1);\n const numberOfDaysNextMonth = getDaysInMonth(nextMonthDate);\n\n if (isLastDayOfMonth(d) && numberOfDaysNextMonth < date) {\n return lastDayOfMonth(nextMonthDate);\n } else {\n return new Date(year, month + 1, date);\n }\n};\nexport const sanitizedPreviousMonth = (d: Date) => {\n const month = d.getMonth();\n const year = d.getFullYear();\n const date = d.getDate();\n const prevMonthDate = new Date(year, month - 1);\n const numberOfDaysPrevMonth = getDaysInMonth(prevMonthDate);\n if (isLastDayOfMonth(d) && numberOfDaysPrevMonth < date) {\n return lastDayOfMonth(prevMonthDate);\n } else {\n return new Date(year, month - 1, date);\n }\n};\nexport const setTimeToNoon = (date: Date): Date => {\n const newDate = new Date(date);\n newDate.setHours(12);\n newDate.setMinutes(0);\n newDate.setSeconds(0);\n newDate.setMilliseconds(0);\n return newDate;\n};\n\nexport const sortAscDates = (dates: Date[]) => {\n return dates.sort((a, b) => a.getTime() - b.getTime());\n};\n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AAE,CAAC,CAAC;AACrB,IAAA,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACtB,IAAA,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACtB,IAAA,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;AAC3B,IAAA,OAAO,OAAO,CAAC;AACjB;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { css } from 'lit';
2
2
 
3
- var css_248z = css`input{margin:0}.form-check{display:flex;gap:var(--sgds-form-gap-md);padding:var(--sgds-form-padding-inline-sm) 0}.form-check-input{appearance:none;background-color:var(--sgds-form-surface-default);background-image:var(--sgds-radio-bg-image);background-position:50%;background-repeat:no-repeat;background-size:auto;border:var(--sgds-form-border-width-default) solid var(--sgds-border-color-default);height:var(--sgds-form-height-sm);width:var(--sgds-form-width-xs)}.form-check-input[checked]{background-color:var(--sgds-form-primary-surface-default);border:var(--sgds-form-border-width-default) solid var(--sgds-border-color-transparent)}.form-check-input:focus-visible{outline:var(--sgds-form-outline-focus);outline-offset:var(--sgds-form-outline-offset-focus)}.form-check-input:not([disabled]):not(.is-invalid):not([aria-checked=true]):not(:focus-visible):hover{outline:var(--sgds-form-border-width-thick) solid var(--sgds-border-color-emphasis);outline-offset:var(--sgds-form-outline-offset-focus)}.form-check-input:not([disabled]):not(.is-invalid)[checked]:focus-visible,.form-check-input:not([disabled]):not(.is-invalid)[checked]:hover{background-color:var(--sgds-form-primary-surface-emphasis)}:host([disabled]) .form-check{cursor:not-allowed;opacity:var(--sgds-opacity-40)}.form-check-input:not([disabled]).is-invalid{border:var(--sgds-form-border-width-default) solid var(--sgds-form-danger-border-color-default)}.form-check-input:not([disabled]).is-invalid:focus-visible{outline:var(--sgds-border-width-2) solid var(--sgds-form-danger-color-default);outline-offset:var(--sgds-form-outline-offset-focus)}`;
3
+ var css_248z = css`input{margin:0}.form-check{display:flex;gap:var(--sgds-form-gap-md);padding:var(--sgds-form-padding-inline-sm) 0}.form-check-input{appearance:none;background-color:var(--sgds-form-surface-default);background-image:var(--sgds-radio-bg-image);background-position:50%;background-repeat:no-repeat;background-size:auto;border:var(--sgds-form-border-width-default) solid var(--sgds-border-color-default);flex-shrink:0;height:var(--sgds-form-height-sm);width:var(--sgds-form-width-xs)}.form-check-input[checked]{background-color:var(--sgds-form-primary-surface-default);border:var(--sgds-form-border-width-default) solid var(--sgds-border-color-transparent)}.form-check-input:focus-visible{outline:var(--sgds-form-outline-focus);outline-offset:var(--sgds-form-outline-offset-focus)}.form-check-input:not([disabled]):not(.is-invalid):not([aria-checked=true]):not(:focus-visible):hover{outline:var(--sgds-form-border-width-thick) solid var(--sgds-border-color-emphasis);outline-offset:var(--sgds-form-outline-offset-focus)}.form-check-input:not([disabled]):not(.is-invalid)[checked]:focus-visible,.form-check-input:not([disabled]):not(.is-invalid)[checked]:hover{background-color:var(--sgds-form-primary-surface-emphasis)}:host([disabled]) .form-check{cursor:not-allowed;opacity:var(--sgds-opacity-40)}.form-check-input:not([disabled]).is-invalid{border:var(--sgds-form-border-width-default) solid var(--sgds-form-danger-border-color-default)}.form-check-input:not([disabled]).is-invalid:focus-visible{outline:var(--sgds-border-width-2) solid var(--sgds-form-danger-color-default);outline-offset:var(--sgds-form-outline-offset-focus)}`;
4
4
 
5
5
  export { css_248z as default };
6
6
  //# sourceMappingURL=form-check.js.map
package/types/react.d.ts CHANGED
@@ -187,6 +187,20 @@ Variants include: `primary`, `accent`, `success`, `danger`, `warning`, `cyan`, `
187
187
  onSgdsAfterHide?: SgdsEventHandler;
188
188
  }
189
189
 
190
+ // ── BreadcrumbItem ─────────────────────────────────────────────────────────────
191
+
192
+ export interface SgdsBreadcrumbItemProps extends SgdsBaseProps {
193
+ /** Indicates the link matches the current location of the page. Programmatically handled by SgdsBreadcrumb to set this prop to true for the last breadcrumb item */
194
+ active?: boolean;
195
+ }
196
+
197
+ // ── Breadcrumb ─────────────────────────────────────────────────────────────
198
+
199
+ export interface SgdsBreadcrumbProps extends SgdsBaseProps {
200
+ /** The aria-label of nav element within breadcrumb component. */
201
+ ariaLabel?: string;
202
+ }
203
+
190
204
  // ── Button ─────────────────────────────────────────────────────────────
191
205
 
192
206
  export interface SgdsButtonProps extends SgdsBaseProps {
@@ -243,20 +257,6 @@ value of this attribute must be an id of a form in the same document or shadow r
243
257
  onSgdsFocus?: SgdsEventHandler;
244
258
  }
245
259
 
246
- // ── BreadcrumbItem ─────────────────────────────────────────────────────────────
247
-
248
- export interface SgdsBreadcrumbItemProps extends SgdsBaseProps {
249
- /** Indicates the link matches the current location of the page. Programmatically handled by SgdsBreadcrumb to set this prop to true for the last breadcrumb item */
250
- active?: boolean;
251
- }
252
-
253
- // ── Breadcrumb ─────────────────────────────────────────────────────────────
254
-
255
- export interface SgdsBreadcrumbProps extends SgdsBaseProps {
256
- /** The aria-label of nav element within breadcrumb component. */
257
- ariaLabel?: string;
258
- }
259
-
260
260
  // ── Card ─────────────────────────────────────────────────────────────
261
261
 
262
262
  export interface SgdsCardProps extends SgdsBaseProps {
@@ -1722,9 +1722,9 @@ declare module "react" {
1722
1722
  "sgds-alert-link": React.DetailedHTMLProps<SgdsAlertLinkProps, HTMLElement>;
1723
1723
  "sgds-alert": React.DetailedHTMLProps<SgdsAlertProps, HTMLElement>;
1724
1724
  "sgds-badge": React.DetailedHTMLProps<SgdsBadgeProps, HTMLElement>;
1725
- "sgds-button": React.DetailedHTMLProps<SgdsButtonProps, HTMLElement>;
1726
1725
  "sgds-breadcrumb-item": React.DetailedHTMLProps<SgdsBreadcrumbItemProps, HTMLElement>;
1727
1726
  "sgds-breadcrumb": React.DetailedHTMLProps<SgdsBreadcrumbProps, HTMLElement>;
1727
+ "sgds-button": React.DetailedHTMLProps<SgdsButtonProps, HTMLElement>;
1728
1728
  "sgds-card": React.DetailedHTMLProps<SgdsCardProps, HTMLElement>;
1729
1729
  "sgds-checkbox-group": React.DetailedHTMLProps<SgdsCheckboxGroupProps, HTMLElement>;
1730
1730
  "sgds-checkbox": React.DetailedHTMLProps<SgdsCheckboxProps, HTMLElement>;
@@ -1805,9 +1805,9 @@ declare global {
1805
1805
  "sgds-alert-link": HTMLElement;
1806
1806
  "sgds-alert": HTMLElement;
1807
1807
  "sgds-badge": HTMLElement;
1808
- "sgds-button": HTMLElement;
1809
1808
  "sgds-breadcrumb-item": HTMLElement;
1810
1809
  "sgds-breadcrumb": HTMLElement;
1810
+ "sgds-button": HTMLElement;
1811
1811
  "sgds-card": HTMLElement;
1812
1812
  "sgds-checkbox-group": HTMLElement;
1813
1813
  "sgds-checkbox": HTMLElement;
package/utils/time.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getDaysInMonth, isLastDayOfMonth, lastDayOfMonth } from './date-helpers.js';
1
+ import { getDaysInMonth, isLastDayOfMonth, lastDayOfMonth } from 'date-fns';
2
2
 
3
3
  const DATE_PATTERNS = {
4
4
  "DD/MM/YYYY": {
package/utils/time.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"time.js","sources":["../../src/utils/time.ts"],"sourcesContent":["import { getDaysInMonth, isLastDayOfMonth, lastDayOfMonth } from \"./date-helpers\";\n\nexport const DATE_PATTERNS = {\n \"DD/MM/YYYY\": {\n imPattern: \"`dd{/}`mm{/}`yyyy\",\n imRangePattern: \"`dd{/}`mm{/}`yyyy - `DD{/}`MM{/}`YYYY\",\n fnsPattern: \"dd/MM/yyyy\"\n },\n \"MM/DD/YYYY\": {\n imPattern: \"`mm{/}`dd{/}`yyyy\",\n imRangePattern: \"`mm{/}`dd{/}`yyyy - `MM{/}`DD{/}`YYYY\",\n fnsPattern: \"MM/dd/yyyy\"\n },\n \"YYYY/MM/DD\": {\n imPattern: \"`yyyy{/}`mm{/}`dd\",\n imRangePattern: \"`yyyy{/}`mm{/}`dd - `YYYY{/}`MM{/}`DD\",\n fnsPattern: \"yyyy/MM/dd\"\n }\n};\n\n/**\n * @description - creates calendar's year view years array with context of\n * datepicker's displayDate and current year\n * Fixes current year to the start of array\n */\nexport const createYearViewArray = (displayDate: Date, currentYear: number) => {\n // keeping the year range position to be always fixed by setting current year to the first element of the calendar\n const displayYear = displayDate.getFullYear();\n const remainder = (displayYear - currentYear) % 12;\n const yearsPosition = remainder < 0 ? 12 + remainder : remainder;\n\n const yearArray = [];\n const startLimit = displayYear - yearsPosition;\n const endLimit = displayYear - yearsPosition + 12 - 1; // -1 to match the index of the years (index starts from 0)\n\n for (let i = startLimit; i < endLimit + 1; i++) {\n yearArray.push(i);\n }\n\n return yearArray;\n};\nexport const sanitizedNextMonth = (d: Date) => {\n const month = d.getMonth();\n const year = d.getFullYear();\n const date = d.getDate();\n const nextMonthDate = new Date(year, month + 1);\n const numberOfDaysNextMonth = getDaysInMonth(nextMonthDate);\n\n if (isLastDayOfMonth(d) && numberOfDaysNextMonth < date) {\n return lastDayOfMonth(nextMonthDate);\n } else {\n return new Date(year, month + 1, date);\n }\n};\nexport const sanitizedPreviousMonth = (d: Date) => {\n const month = d.getMonth();\n const year = d.getFullYear();\n const date = d.getDate();\n const prevMonthDate = new Date(year, month - 1);\n const numberOfDaysPrevMonth = getDaysInMonth(prevMonthDate);\n if (isLastDayOfMonth(d) && numberOfDaysPrevMonth < date) {\n return lastDayOfMonth(prevMonthDate);\n } else {\n return new Date(year, month - 1, date);\n }\n};\nexport const setTimeToNoon = (date: Date): Date => {\n const newDate = new Date(date);\n newDate.setHours(12);\n newDate.setMinutes(0);\n newDate.setSeconds(0);\n newDate.setMilliseconds(0);\n return newDate;\n};\n\nexport const sortAscDates = (dates: Date[]) => {\n return dates.sort((a, b) => a.getTime() - b.getTime());\n};\n"],"names":[],"mappings":";;AAEa,MAAA,aAAa,GAAG;AAC3B,IAAA,YAAY,EAAE;AACZ,QAAA,SAAS,EAAE,mBAAmB;AAC9B,QAAA,cAAc,EAAE,uCAAuC;AACvD,QAAA,UAAU,EAAE,YAAY;AACzB,KAAA;AACD,IAAA,YAAY,EAAE;AACZ,QAAA,SAAS,EAAE,mBAAmB;AAC9B,QAAA,cAAc,EAAE,uCAAuC;AACv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ourcesContent":["import { getDaysInMonth, isLastDayOfMonth, lastDayOfMonth } from \"date-fns\";\n\nexport const DATE_PATTERNS = {\n \"DD/MM/YYYY\": {\n imPattern: \"`dd{/}`mm{/}`yyyy\",\n imRangePattern: \"`dd{/}`mm{/}`yyyy - `DD{/}`MM{/}`YYYY\",\n fnsPattern: \"dd/MM/yyyy\"\n },\n \"MM/DD/YYYY\": {\n imPattern: \"`mm{/}`dd{/}`yyyy\",\n imRangePattern: \"`mm{/}`dd{/}`yyyy - `MM{/}`DD{/}`YYYY\",\n fnsPattern: \"MM/dd/yyyy\"\n },\n \"YYYY/MM/DD\": {\n imPattern: \"`yyyy{/}`mm{/}`dd\",\n imRangePattern: \"`yyyy{/}`mm{/}`dd - `YYYY{/}`MM{/}`DD\",\n fnsPattern: \"yyyy/MM/dd\"\n }\n};\n\n/**\n * @description - creates calendar's year view years array with context of\n * datepicker's displayDate and current year\n * Fixes current year to the start of array\n */\nexport const createYearViewArray = (displayDate: Date, currentYear: number) => {\n // keeping the year range position to be always fixed by setting current year to the first element of the calendar\n const displayYear = displayDate.getFullYear();\n const remainder = (displayYear - currentYear) % 12;\n const yearsPosition = remainder < 0 ? 12 + remainder : remainder;\n\n const yearArray = [];\n const startLimit = displayYear - yearsPosition;\n const endLimit = displayYear - yearsPosition + 12 - 1; // -1 to match the index of the years (index starts from 0)\n\n for (let i = startLimit; i < endLimit + 1; i++) {\n yearArray.push(i);\n }\n\n return yearArray;\n};\nexport const sanitizedNextMonth = (d: Date) => {\n const month = d.getMonth();\n const year = d.getFullYear();\n const date = d.getDate();\n const nextMonthDate = new Date(year, month + 1);\n const numberOfDaysNextMonth = getDaysInMonth(nextMonthDate);\n\n if (isLastDayOfMonth(d) && numberOfDaysNextMonth < date) {\n return lastDayOfMonth(nextMonthDate);\n } else {\n return new Date(year, month + 1, date);\n }\n};\nexport const sanitizedPreviousMonth = (d: Date) => {\n const month = d.getMonth();\n const year = d.getFullYear();\n const date = d.getDate();\n const prevMonthDate = new Date(year, month - 1);\n const numberOfDaysPrevMonth = getDaysInMonth(prevMonthDate);\n if (isLastDayOfMonth(d) && numberOfDaysPrevMonth < date) {\n return lastDayOfMonth(prevMonthDate);\n } else {\n return new Date(year, month - 1, date);\n }\n};\nexport const setTimeToNoon = (date: Date): Date => {\n const newDate = new Date(date);\n newDate.setHours(12);\n newDate.setMinutes(0);\n newDate.setSeconds(0);\n newDate.setMilliseconds(0);\n return newDate;\n};\n\nexport const sortAscDates = (dates: Date[]) => {\n return dates.sort((a, b) => a.getTime() - b.getTime());\n};\n"],"names":[],"mappings":";;AAEa,MAAA,aAAa,GAAG;AAC3B,IAAA,YAAY,EAAE;AACZ,QAAA,SAAS,EAAE,mBAAmB;AAC9B,QAAA,cAAc,EAAE,uCAAuC;AACvD,QAAA,UAAU,EAAE,YAAY;AACzB,KAAA;AACD,IAAA,YAAY,EAAE;AACZ,QAAA,SAAS,EAAE,mBAAmB;AAC9B,QAAA,cAAc,EAAE,uCAAuC;AACvD,QAAA,UAAU,EAAE,YAAY;AACzB,KAAA;AACD,IAAA,YAAY,EAAE;AACZ,QAAA,SAAS,EAAE,mBAAmB;AAC9B,QAAA,cAAc,EAAE,uCAAuC;AACvD,QAAA,UAAU,EAAE,YAAY;AACzB,KAAA;EACD;AAEF;;;;AAIG;MACU,mBAAmB,GAAG,CAAC,WAAiB,EAAE,WAAmB,KAAI;;AAE5E,IAAA,MAAM,WAAW,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;IAC9C,MAAM,SAAS,GAAG,CAAC,WAAW,GAAG,WAAW,IAAI,EAAE,CAAC;AACnD,IAAA,MAAM,aAAa,GAAG,SAAS,GAAG,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,SAAS,CAAC;IAEjE,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,IAAA,MAAM,UAAU,GAAG,WAAW,GAAG,aAAa,CAAC;IAC/C,MAAM,QAAQ,GAAG,WAAW,GAAG,aAAa,GAAG,EAAE,GAAG,CAAC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AC,IAAI,qBAAqB,GAAG,IAAI,EAAE;AACvD,QAAA,OAAO,cAAc,CAAC,aAAa,CAAC,CAAC;KACtC;SAAM;QACL,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;KACxC;AACH,EAAE;AACW,MAAA,aAAa,GAAG,CAAC,IAAU,KAAU;AAChD,IAAA,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/B,IAAA,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AACrB,IAAA,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACtB,IAAA,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACtB,IAAA,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;AAC3B,IAAA,OAAO,OAAO,CAAC;AACjB;;;;"}
@@ -1,120 +0,0 @@
1
- 'use client';
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- /**
7
- * Lightweight date utility functions replacing date-fns.
8
- * Only supports the 3 date patterns used by the Datepicker component.
9
- */
10
- function getOrdinalSuffix(day) {
11
- if (day >= 11 && day <= 13)
12
- return day + "th";
13
- switch (day % 10) {
14
- case 1:
15
- return day + "st";
16
- case 2:
17
- return day + "nd";
18
- case 3:
19
- return day + "rd";
20
- default:
21
- return day + "th";
22
- }
23
- }
24
- /**
25
- * Format a date using one of the 3 known patterns or "PPPP" (full locale date).
26
- */
27
- function formatDate(date, pattern) {
28
- const day = date.getDate();
29
- const month = date.getMonth() + 1;
30
- const year = date.getFullYear();
31
- const dd = day < 10 ? "0" + day : String(day);
32
- const mm = month < 10 ? "0" + month : String(month);
33
- const yyyy = String(year);
34
- switch (pattern) {
35
- case "dd/MM/yyyy":
36
- return `${dd}/${mm}/${yyyy}`;
37
- case "MM/dd/yyyy":
38
- return `${mm}/${dd}/${yyyy}`;
39
- case "yyyy/MM/dd":
40
- return `${yyyy}/${mm}/${dd}`;
41
- case "PPPP": {
42
- const weekday = new Intl.DateTimeFormat("en-US", { weekday: "long" }).format(date);
43
- const month = new Intl.DateTimeFormat("en-US", { month: "long" }).format(date);
44
- const ordinal = getOrdinalSuffix(date.getDate());
45
- return `${weekday}, ${month} ${ordinal}, ${date.getFullYear()}`;
46
- }
47
- default:
48
- return `${dd}/${mm}/${yyyy}`;
49
- }
50
- }
51
- function getDaysInMonth(date) {
52
- return new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
53
- }
54
- function isAfterDate(a, b) {
55
- return a.getTime() > b.getTime();
56
- }
57
- function isBeforeDate(a, b) {
58
- return a.getTime() < b.getTime();
59
- }
60
- function isEqualDate(a, b) {
61
- return a.getTime() === b.getTime();
62
- }
63
- function isLastDayOfMonth(date) {
64
- return date.getDate() === getDaysInMonth(date);
65
- }
66
- function isValidDate(date) {
67
- return date instanceof Date && !isNaN(date.getTime());
68
- }
69
- function lastDayOfMonth(date) {
70
- return new Date(date.getFullYear(), date.getMonth() + 1, 0);
71
- }
72
- /**
73
- * Parse a date string using one of the 3 known patterns:
74
- * - "dd/MM/yyyy"
75
- * - "MM/dd/yyyy"
76
- * - "yyyy/MM/dd"
77
- */
78
- function parseDate(dateStr, pattern) {
79
- const parts = dateStr.split("/");
80
- let day, month, year;
81
- switch (pattern) {
82
- case "dd/MM/yyyy":
83
- day = parseInt(parts[0], 10);
84
- month = parseInt(parts[1], 10) - 1;
85
- year = parseInt(parts[2], 10);
86
- break;
87
- case "MM/dd/yyyy":
88
- month = parseInt(parts[0], 10) - 1;
89
- day = parseInt(parts[1], 10);
90
- year = parseInt(parts[2], 10);
91
- break;
92
- case "yyyy/MM/dd":
93
- year = parseInt(parts[0], 10);
94
- month = parseInt(parts[1], 10) - 1;
95
- day = parseInt(parts[2], 10);
96
- break;
97
- default:
98
- return new Date(NaN);
99
- }
100
- if (isNaN(day) || isNaN(month) || isNaN(year)) {
101
- return new Date(NaN);
102
- }
103
- const date = new Date(year, month, day, 12, 0, 0, 0);
104
- // Validate that the parsed date matches the input (catches invalid dates like 31/02/2024)
105
- if (date.getFullYear() !== year || date.getMonth() !== month || date.getDate() !== day) {
106
- return new Date(NaN);
107
- }
108
- return date;
109
- }
110
-
111
- exports.formatDate = formatDate;
112
- exports.getDaysInMonth = getDaysInMonth;
113
- exports.isAfterDate = isAfterDate;
114
- exports.isBeforeDate = isBeforeDate;
115
- exports.isEqualDate = isEqualDate;
116
- exports.isLastDayOfMonth = isLastDayOfMonth;
117
- exports.isValidDate = isValidDate;
118
- exports.lastDayOfMonth = lastDayOfMonth;
119
- exports.parseDate = parseDate;
120
- //# sourceMappingURL=date-helpers.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"date-helpers.cjs.js","sources":["../../../src/utils/date-helpers.ts"],"sourcesContent":["/**\n * Lightweight date utility functions replacing date-fns.\n * Only supports the 3 date patterns used by the Datepicker component.\n */\n\nfunction getOrdinalSuffix(day: number): string {\n if (day >= 11 && day <= 13) return day + \"th\";\n switch (day % 10) {\n case 1:\n return day + \"st\";\n case 2:\n return day + \"nd\";\n case 3:\n return day + \"rd\";\n default:\n return day + \"th\";\n }\n}\n\n/**\n * Format a date using one of the 3 known patterns or \"PPPP\" (full locale date).\n */\nexport function formatDate(date: Date, pattern: string): string {\n const day = date.getDate();\n const month = date.getMonth() + 1;\n const year = date.getFullYear();\n const dd = day < 10 ? \"0\" + day : String(day);\n const mm = month < 10 ? \"0\" + month : String(month);\n const yyyy = String(year);\n\n switch (pattern) {\n case \"dd/MM/yyyy\":\n return `${dd}/${mm}/${yyyy}`;\n case \"MM/dd/yyyy\":\n return `${mm}/${dd}/${yyyy}`;\n case \"yyyy/MM/dd\":\n return `${yyyy}/${mm}/${dd}`;\n case \"PPPP\": {\n const weekday = new Intl.DateTimeFormat(\"en-US\", { weekday: \"long\" }).format(date);\n const month = new Intl.DateTimeFormat(\"en-US\", { month: \"long\" }).format(date);\n const ordinal = getOrdinalSuffix(date.getDate());\n return `${weekday}, ${month} ${ordinal}, ${date.getFullYear()}`;\n }\n default:\n return `${dd}/${mm}/${yyyy}`;\n }\n}\n\nexport function getDaysInMonth(date: Date): number {\n return new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();\n}\n\nexport function isAfterDate(a: Date, b: Date): boolean {\n return a.getTime() > b.getTime();\n}\n\nexport function isBeforeDate(a: Date, b: Date): boolean {\n return a.getTime() < b.getTime();\n}\n\nexport function isEqualDate(a: Date, b: Date): boolean {\n return a.getTime() === b.getTime();\n}\n\nexport function isLastDayOfMonth(date: Date): boolean {\n return date.getDate() === getDaysInMonth(date);\n}\n\nexport function isValidDate(date: Date): boolean {\n return date instanceof Date && !isNaN(date.getTime());\n}\n\nexport function lastDayOfMonth(date: Date): Date {\n return new Date(date.getFullYear(), date.getMonth() + 1, 0);\n}\n\n/**\n * Parse a date string using one of the 3 known patterns:\n * - \"dd/MM/yyyy\"\n * - \"MM/dd/yyyy\"\n * - \"yyyy/MM/dd\"\n */\nexport function parseDate(dateStr: string, pattern: string): Date {\n const parts = dateStr.split(\"/\");\n let day: number, month: number, year: number;\n\n switch (pattern) {\n case \"dd/MM/yyyy\":\n day = parseInt(parts[0], 10);\n month = parseInt(parts[1], 10) - 1;\n year = parseInt(parts[2], 10);\n break;\n case \"MM/dd/yyyy\":\n month = parseInt(parts[0], 10) - 1;\n day = parseInt(parts[1], 10);\n year = parseInt(parts[2], 10);\n break;\n case \"yyyy/MM/dd\":\n year = parseInt(parts[0], 10);\n month = parseInt(parts[1], 10) - 1;\n day = parseInt(parts[2], 10);\n break;\n default:\n return new Date(NaN);\n }\n\n if (isNaN(day) || isNaN(month) || isNaN(year)) {\n return new Date(NaN);\n }\n\n const date = new Date(year, month, day, 12, 0, 0, 0);\n // Validate that the parsed date matches the input (catches invalid dates like 31/02/2024)\n if (date.getFullYear() !== year || date.getMonth() !== month || date.getDate() !== day) {\n return new Date(NaN);\n }\n return date;\n}\n"],"names":[],"mappings":";;;;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IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC9B,MAAM;AACR,QAAA,KAAK,YAAY;YACf,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC9B,YAAA,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;YACnC,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC7B,MAAM;AACR,QAAA;AACE,YAAA,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;KACxB;AAED,IAAA,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE;AAC7C,QAAA,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;KACtB;AAED,IAAA,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;;IAErD,IAAI,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,EAAE;AACtF,QAAA,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;KACtB;AACD,IAAA,OAAO,IAAI,CAAC;AACd;;;;;;;;;;;;"}
@@ -1,108 +0,0 @@
1
- 'use client';
2
- /**
3
- * Lightweight date utility functions replacing date-fns.
4
- * Only supports the 3 date patterns used by the Datepicker component.
5
- */
6
- function getOrdinalSuffix(day) {
7
- if (day >= 11 && day <= 13)
8
- return day + "th";
9
- switch (day % 10) {
10
- case 1:
11
- return day + "st";
12
- case 2:
13
- return day + "nd";
14
- case 3:
15
- return day + "rd";
16
- default:
17
- return day + "th";
18
- }
19
- }
20
- /**
21
- * Format a date using one of the 3 known patterns or "PPPP" (full locale date).
22
- */
23
- function formatDate(date, pattern) {
24
- const day = date.getDate();
25
- const month = date.getMonth() + 1;
26
- const year = date.getFullYear();
27
- const dd = day < 10 ? "0" + day : String(day);
28
- const mm = month < 10 ? "0" + month : String(month);
29
- const yyyy = String(year);
30
- switch (pattern) {
31
- case "dd/MM/yyyy":
32
- return `${dd}/${mm}/${yyyy}`;
33
- case "MM/dd/yyyy":
34
- return `${mm}/${dd}/${yyyy}`;
35
- case "yyyy/MM/dd":
36
- return `${yyyy}/${mm}/${dd}`;
37
- case "PPPP": {
38
- const weekday = new Intl.DateTimeFormat("en-US", { weekday: "long" }).format(date);
39
- const month = new Intl.DateTimeFormat("en-US", { month: "long" }).format(date);
40
- const ordinal = getOrdinalSuffix(date.getDate());
41
- return `${weekday}, ${month} ${ordinal}, ${date.getFullYear()}`;
42
- }
43
- default:
44
- return `${dd}/${mm}/${yyyy}`;
45
- }
46
- }
47
- function getDaysInMonth(date) {
48
- return new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
49
- }
50
- function isAfterDate(a, b) {
51
- return a.getTime() > b.getTime();
52
- }
53
- function isBeforeDate(a, b) {
54
- return a.getTime() < b.getTime();
55
- }
56
- function isEqualDate(a, b) {
57
- return a.getTime() === b.getTime();
58
- }
59
- function isLastDayOfMonth(date) {
60
- return date.getDate() === getDaysInMonth(date);
61
- }
62
- function isValidDate(date) {
63
- return date instanceof Date && !isNaN(date.getTime());
64
- }
65
- function lastDayOfMonth(date) {
66
- return new Date(date.getFullYear(), date.getMonth() + 1, 0);
67
- }
68
- /**
69
- * Parse a date string using one of the 3 known patterns:
70
- * - "dd/MM/yyyy"
71
- * - "MM/dd/yyyy"
72
- * - "yyyy/MM/dd"
73
- */
74
- function parseDate(dateStr, pattern) {
75
- const parts = dateStr.split("/");
76
- let day, month, year;
77
- switch (pattern) {
78
- case "dd/MM/yyyy":
79
- day = parseInt(parts[0], 10);
80
- month = parseInt(parts[1], 10) - 1;
81
- year = parseInt(parts[2], 10);
82
- break;
83
- case "MM/dd/yyyy":
84
- month = parseInt(parts[0], 10) - 1;
85
- day = parseInt(parts[1], 10);
86
- year = parseInt(parts[2], 10);
87
- break;
88
- case "yyyy/MM/dd":
89
- year = parseInt(parts[0], 10);
90
- month = parseInt(parts[1], 10) - 1;
91
- day = parseInt(parts[2], 10);
92
- break;
93
- default:
94
- return new Date(NaN);
95
- }
96
- if (isNaN(day) || isNaN(month) || isNaN(year)) {
97
- return new Date(NaN);
98
- }
99
- const date = new Date(year, month, day, 12, 0, 0, 0);
100
- // Validate that the parsed date matches the input (catches invalid dates like 31/02/2024)
101
- if (date.getFullYear() !== year || date.getMonth() !== month || date.getDate() !== day) {
102
- return new Date(NaN);
103
- }
104
- return date;
105
- }
106
-
107
- export { formatDate, getDaysInMonth, isAfterDate, isBeforeDate, isEqualDate, isLastDayOfMonth, isValidDate, lastDayOfMonth, parseDate };
108
- //# sourceMappingURL=date-helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"date-helpers.js","sources":["../../../src/utils/date-helpers.ts"],"sourcesContent":["/**\n * Lightweight date utility functions replacing date-fns.\n * Only supports the 3 date patterns used by the Datepicker component.\n */\n\nfunction getOrdinalSuffix(day: number): string {\n if (day >= 11 && day <= 13) return day + \"th\";\n switch (day % 10) {\n case 1:\n return day + \"st\";\n case 2:\n return day + \"nd\";\n case 3:\n return day + \"rd\";\n default:\n return day + \"th\";\n }\n}\n\n/**\n * Format a date using one of the 3 known patterns or \"PPPP\" (full locale date).\n */\nexport function formatDate(date: Date, pattern: string): string {\n const day = date.getDate();\n const month = date.getMonth() + 1;\n const year = date.getFullYear();\n const dd = day < 10 ? \"0\" + day : String(day);\n const mm = month < 10 ? \"0\" + month : String(month);\n const yyyy = String(year);\n\n switch (pattern) {\n case \"dd/MM/yyyy\":\n return `${dd}/${mm}/${yyyy}`;\n case \"MM/dd/yyyy\":\n return `${mm}/${dd}/${yyyy}`;\n case \"yyyy/MM/dd\":\n return `${yyyy}/${mm}/${dd}`;\n case \"PPPP\": {\n const weekday = new Intl.DateTimeFormat(\"en-US\", { weekday: \"long\" }).format(date);\n const month = new Intl.DateTimeFormat(\"en-US\", { month: \"long\" }).format(date);\n const ordinal = getOrdinalSuffix(date.getDate());\n return `${weekday}, ${month} ${ordinal}, ${date.getFullYear()}`;\n }\n default:\n return `${dd}/${mm}/${yyyy}`;\n }\n}\n\nexport function getDaysInMonth(date: Date): number {\n return new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();\n}\n\nexport function isAfterDate(a: Date, b: Date): boolean {\n return a.getTime() > b.getTime();\n}\n\nexport function isBeforeDate(a: Date, b: Date): boolean {\n return a.getTime() < b.getTime();\n}\n\nexport function isEqualDate(a: Date, b: Date): boolean {\n return a.getTime() === b.getTime();\n}\n\nexport function isLastDayOfMonth(date: Date): boolean {\n return date.getDate() === getDaysInMonth(date);\n}\n\nexport function isValidDate(date: Date): boolean {\n return date instanceof Date && !isNaN(date.getTime());\n}\n\nexport function lastDayOfMonth(date: Date): Date {\n return new Date(date.getFullYear(), date.getMonth() + 1, 0);\n}\n\n/**\n * Parse a date string using one of the 3 known patterns:\n * - \"dd/MM/yyyy\"\n * - \"MM/dd/yyyy\"\n * - \"yyyy/MM/dd\"\n */\nexport function parseDate(dateStr: string, pattern: string): Date {\n const parts = dateStr.split(\"/\");\n let day: number, month: number, year: number;\n\n switch (pattern) {\n case \"dd/MM/yyyy\":\n day = parseInt(parts[0], 10);\n month = parseInt(parts[1], 10) - 1;\n year = parseInt(parts[2], 10);\n break;\n case \"MM/dd/yyyy\":\n month = parseInt(parts[0], 10) - 1;\n day = parseInt(parts[1], 10);\n year = parseInt(parts[2], 10);\n break;\n case \"yyyy/MM/dd\":\n year = parseInt(parts[0], 10);\n month = parseInt(parts[1], 10) - 1;\n day = parseInt(parts[2], 10);\n break;\n default:\n return new Date(NaN);\n }\n\n if (isNaN(day) || isNaN(month) || isNaN(year)) {\n return new Date(NaN);\n }\n\n const date = new Date(year, month, day, 12, 0, 0, 0);\n // Validate that the parsed date matches the input (catches invalid dates like 31/02/2024)\n if (date.getFullYear() !== year || date.getMonth() !== month || date.getDate() !== day) {\n return new Date(NaN);\n }\n return date;\n}\n"],"names":[],"mappings":";AAAA;;;AAGG;AAEH,SAAS,gBAAgB,CAAC,GAAW,EAAA;AACnC,IAAA,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE;QAAE,OAAO,GAAG,GAAG,IAAI,CAAC;AAC9C,IAAA,QAAQ,GAAG,GAAG,EAAE;AACd,QAAA,KAAK,CAAC;YACJ,OAAO,GAAG,GAAG,IAAI,CAAC;AACpB,QAAA,KAAK,CAAC;YACJ,OAAO,GAAG,GAAG,IAAI,CAAC;AACpB,QAAA,KAAK,CAAC;YACJ,OAAO,GAAG,GAAG,IAAI,CAAC;AACpB,QAAA;YACE,OAAO,GAAG,GAAG,IAAI,CAAC;KACrB;AACH,CAAC;AAED;;AAEG;AACa,SAAA,UAAU,CAAC,IAAU,EAAE,OAAe,EAAA;AACpD,IAAA,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;AAClC,IAAA,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;AAChC,IAAA,MAAM,EAAE,GAAG,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;AAC9C,IAAA,MAAM,EAAE,GAAG,KAAK,GAAG,EAAE,GAAG,GAAG,GAAG,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AACpD,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAE1B,QAAQ,OAAO;AACb,QAAA,KAAK,YAAY;AACf,YAAA,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@@
1
- 'use client';
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- /**
7
- * Lightweight date input mask replacing imask.
8
- * Handles digit-only input with placeholder display for date formats.
9
- */
10
- class DateMask {
11
- constructor(input, options) {
12
- this.listeners = new Map();
13
- this.input = input;
14
- this.placeholderStr = this._buildPlaceholder(options.pattern);
15
- this._state = this.placeholderStr;
16
- this.listeners.set("accept", []);
17
- this.listeners.set("complete", []);
18
- const masked = { value: "", isComplete: false };
19
- Object.defineProperties(masked, {
20
- value: { get: () => this._state, enumerable: true },
21
- isComplete: { get: () => this._state.length > 0 && !/[DMY]/.test(this._state), enumerable: true }
22
- });
23
- this.masked = masked;
24
- // If input already has a value that looks like a filled date, use it
25
- if (this.input.value && this.input.value.length === this._state.length && !/[DMY]/.test(this.input.value)) {
26
- this._state = this.input.value;
27
- }
28
- else {
29
- this.input.value = this._state;
30
- }
31
- this._boundHandleBeforeInput = this._handleBeforeInput.bind(this);
32
- this._boundHandleInput = this._handleInput.bind(this);
33
- this._boundHandleKeydown = this._handleKeydown.bind(this);
34
- this._boundHandleFocus = this._handleFocus.bind(this);
35
- this._boundHandleBlur = this._handleBlur.bind(this);
36
- this._valueAtFocus = this._state;
37
- this.input.addEventListener("beforeinput", this._boundHandleBeforeInput);
38
- this.input.addEventListener("input", this._boundHandleInput);
39
- this.input.addEventListener("keydown", this._boundHandleKeydown);
40
- this.input.addEventListener("focus", this._boundHandleFocus);
41
- this.input.addEventListener("blur", this._boundHandleBlur);
42
- }
43
- get value() {
44
- return this._state;
45
- }
46
- set value(val) {
47
- if (!val || val === "") {
48
- this._state = this.placeholderStr;
49
- }
50
- else {
51
- this._state = val;
52
- }
53
- this.input.value = this._state;
54
- this._emit("accept");
55
- }
56
- on(event, handler) {
57
- var _a;
58
- (_a = this.listeners.get(event)) === null || _a === void 0 ? void 0 : _a.push(handler);
59
- }
60
- updateValue() {
61
- // Sync state from input (used when value set externally on input)
62
- this._state = this.input.value;
63
- }
64
- destroy() {
65
- this.input.removeEventListener("beforeinput", this._boundHandleBeforeInput);
66
- this.input.removeEventListener("input", this._boundHandleInput);
67
- this.input.removeEventListener("keydown", this._boundHandleKeydown);
68
- this.input.removeEventListener("focus", this._boundHandleFocus);
69
- this.input.removeEventListener("blur", this._boundHandleBlur);
70
- this.listeners.clear();
71
- }
72
- _handleFocus() {
73
- this._valueAtFocus = this._state;
74
- }
75
- _handleBlur() {
76
- // Dispatch native change event if value changed during this focus session
77
- if (this._state !== this._valueAtFocus) {
78
- this.input.dispatchEvent(new Event("change", { bubbles: true }));
79
- }
80
- }
81
- _buildPlaceholder(pattern) {
82
- return pattern
83
- .replace(/`/g, "")
84
- .replace(/\{(\/)\}/g, "$1")
85
- .replace(/d/g, "D")
86
- .replace(/m/g, "M")
87
- .replace(/y/g, "Y");
88
- }
89
- _getDigitPositions() {
90
- const positions = [];
91
- for (let i = 0; i < this.placeholderStr.length; i++) {
92
- const ch = this.placeholderStr[i];
93
- if (ch === "D" || ch === "M" || ch === "Y") {
94
- positions.push(i);
95
- }
96
- }
97
- return positions;
98
- }
99
- _handleBeforeInput(e) {
100
- // Prevent browser's default text handling — we handle everything in keydown
101
- e.preventDefault();
102
- }
103
- _handleInput() {
104
- // If browser still modified the value (some edge cases), restore our state
105
- if (this.input.value !== this._state) {
106
- this.input.value = this._state;
107
- }
108
- }
109
- _handleKeydown(e) {
110
- if (e.key === "Backspace") {
111
- e.preventDefault();
112
- this._backspace();
113
- }
114
- else if (e.key === "Delete") {
115
- e.preventDefault();
116
- this._deleteForward();
117
- }
118
- else if (e.key.length === 1 && /\d/.test(e.key)) {
119
- e.preventDefault();
120
- this._insertDigit(e.key);
121
- }
122
- // Arrow keys: let browser handle cursor movement naturally
123
- }
124
- _insertDigit(digit) {
125
- const digitPositions = this._getDigitPositions();
126
- const currentVal = this._state.split("");
127
- // Find the first unfilled placeholder position
128
- let insertPos = -1;
129
- for (const pos of digitPositions) {
130
- if (/[DMY]/.test(currentVal[pos])) {
131
- insertPos = pos;
132
- break;
133
- }
134
- }
135
- if (insertPos === -1) {
136
- // All filled — no room
137
- return;
138
- }
139
- currentVal[insertPos] = digit;
140
- this._state = currentVal.join("");
141
- this.input.value = this._state;
142
- // Move cursor after the inserted digit
143
- const nextPos = this._findNextInputPos(insertPos);
144
- this.input.setSelectionRange(nextPos, nextPos);
145
- this._emit("accept");
146
- if (this.masked.isComplete) {
147
- this._emit("complete");
148
- }
149
- }
150
- _backspace() {
151
- var _a;
152
- const pos = (_a = this.input.selectionStart) !== null && _a !== void 0 ? _a : this._state.length;
153
- const val = this._state.split("");
154
- // Find previous digit position from cursor
155
- let targetPos = pos - 1;
156
- while (targetPos >= 0 && !/\d/.test(val[targetPos])) {
157
- targetPos--;
158
- }
159
- if (targetPos >= 0) {
160
- val[targetPos] = this.placeholderStr[targetPos];
161
- this._state = val.join("");
162
- this.input.value = this._state;
163
- this.input.setSelectionRange(targetPos, targetPos);
164
- this._emit("accept");
165
- }
166
- }
167
- _deleteForward() {
168
- var _a;
169
- const pos = (_a = this.input.selectionStart) !== null && _a !== void 0 ? _a : 0;
170
- const val = this._state.split("");
171
- let targetPos = pos;
172
- while (targetPos < val.length && !/\d/.test(val[targetPos])) {
173
- targetPos++;
174
- }
175
- if (targetPos < val.length) {
176
- val[targetPos] = this.placeholderStr[targetPos];
177
- this._state = val.join("");
178
- this.input.value = this._state;
179
- this.input.setSelectionRange(pos, pos);
180
- this._emit("accept");
181
- }
182
- }
183
- _findNextInputPos(pos) {
184
- for (let i = pos + 1; i < this._state.length; i++) {
185
- if (/[DMY]/.test(this._state[i])) {
186
- return i;
187
- }
188
- }
189
- // If no more placeholders, place cursor at end
190
- return this._state.length;
191
- }
192
- _emit(event) {
193
- const handlers = this.listeners.get(event);
194
- if (handlers) {
195
- for (const handler of handlers) {
196
- handler();
197
- }
198
- }
199
- }
200
- }
201
-
202
- exports.DateMask = DateMask;
203
- //# sourceMappingURL=date-mask.cjs.js.map