@aotearoan/neon 27.0.0 → 27.0.2

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class i{static formatDate(t){const{day:o,monthShortName:n}=i.stringToNeonDate(t.toISOString());return`${n} ${o}`}static formatISOStringToDateAndTime(t,o=!1){const{day:n,monthShortName:a,year:r,time:e,timeShort:s}=i.stringToNeonDate(t);return o?`${n} ${a} ${r}, ${e}`:`${n} ${a} ${r}, ${s}`}static stringToNeonDate(t,o,n=!1){const a=o||navigator.language,r=new Date,e=new Date(!n&&t.length===10?`${t}T${r.toISOString().split("T")[1]}`:t);let s;t.length>10&&(s=e.toLocaleString("en-GB",t.length<=16?{hour12:!1,hour:"2-digit",minute:"2-digit"}:{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}));const l={year:+e.toLocaleString("en-US",{year:"numeric"}),yearFormatted:e.toLocaleString(a,{year:"numeric"}),month:+e.toLocaleString("en-US",{month:"numeric"}),monthShortName:e.toLocaleString(a,{month:"short"}),monthLongName:e.toLocaleString(a,{month:"long"}),day:+e.toLocaleString("en-US",{day:"numeric"}),dayFormatted:e.toLocaleString(a,{day:"2-digit"})};return s&&(l.time=s,l.timeShort=e.toLocaleString("en-GB",{hour12:!1,hourCycle:"h23",hour:"2-digit",minute:"2-digit"})),l}static dateToIso(t,o=!1){const n=t.toISOString();return o?n:n.split("T")[0]}static dmyToIso(t,o,n){return`${n}-${o<10?"0"+o:o}-${t<10?"0"+t:t}`}static dowNames(t,o="short"){const n=t||navigator.language,a=new Date,r=[];for(;!r[a.getDay()];)r[a.getDay()]=a.toLocaleString(n,{weekday:o}),a.setDate(a.getDate()+1);const e=r.shift();return e&&r.push(e),r}static monthNames(t,o="short"){const n=t||navigator.language;return Array.from(Array(12).keys()).map(a=>new Date(2023,a,15).toLocaleString(n,{month:o}))}static toCalendarConfiguration(t,o,n,a,r){const e=r||navigator.language,s=i.stringToNeonDate(i.dateToIso(new Date),e),l=t?i.stringToNeonDate(t,e,!0):void 0,u=o||s.month,S=o&&n?new Date(n,o-1,15):null,L=(S==null?void 0:S.toLocaleString(e,{month:"long"}))||s.monthLongName,d=n||s.year,$=a||Math.floor(d/10)*10,m=new Date(d,(u+11)%12,1),f=new Date(d,(u+11)%12,1);f.setDate(f.getDate()-1);const h=[];let D=1,w=!1;for(let g=0;g<6;g++){h[g]=[];for(let c=0;c<7;c++)if(g===0&&c<f.getDay())h[g][c]=null;else if(h[g][c]=m.getDate(),D=m.getDate(),m.setDate(m.getDate()+1),m.getDate()===1){for(let y=c+1;y<7;y++)h[g][y]=null;w=!0;break}if(w)break}return{today:s,selected:l,pageMonth:u,pageMonthName:L,pageYear:d,pageDecadeStart:$,dowNames:i.dowNames(e),dowLongNames:i.dowNames(e,"long"),dates:h,lastDayOfMonth:D,months:i.monthNames(e),monthLongNames:i.monthNames(e,"long")}}}exports.NeonDateUtils=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class s{static formatDate(t){const{dayFormatted:o,monthShortName:n}=s.stringToNeonDate(t.toISOString());return`${n} ${o}`}static formatISOStringToDateAndTime(t,o=!1){const{dayFormatted:n,monthShortName:a,year:r,time:e,timeShort:g}=s.stringToNeonDate(t);return o?`${n} ${a} ${r}, ${e}`:`${n} ${a} ${r}, ${g}`}static stringToNeonDate(t,o,n=!1){const a=o||navigator.language,r=new Date,e=Intl.DateTimeFormat().resolvedOptions().timeZone,g=!(t.match(/(.*)Z/)||t.match(/(.*)[+-]\d{2}:\d{2}/)),i=new Date(!n&&t.length===10?`${t}T${r.toISOString().split("T")[1]}`:t+(g?"Z":""));let c;t.length>10&&(c=i.toLocaleString("en-GB",t.length<=16?{hour12:!1,hour:"2-digit",minute:"2-digit",timeZone:e}:{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit",timeZone:e}));const m={year:+i.toLocaleString("en-US",{year:"numeric",timeZone:e}),yearFormatted:i.toLocaleString(a,{year:"numeric",timeZone:e}),month:+i.toLocaleString("en-US",{month:"numeric",timeZone:e}),monthShortName:i.toLocaleString(a,{month:"short",timeZone:e}),monthLongName:i.toLocaleString(a,{month:"long",timeZone:e}),day:+i.toLocaleString("en-US",{day:"numeric",timeZone:e}),dayFormatted:i.toLocaleString(a,{day:"2-digit",timeZone:e})};return c&&(m.time=c,m.timeShort=i.toLocaleString("en-GB",{hour12:!1,hourCycle:"h23",hour:"2-digit",minute:"2-digit",timeZone:e})),m}static dateToIso(t,o=!1){const n=t.toISOString();return o?n:n.split("T")[0]}static dmyToIso(t,o,n){return`${n}-${o<10?"0"+o:o}-${t<10?"0"+t:t}`}static dowNames(t,o="short"){const n=t||navigator.language,a=new Date,r=[];for(;!r[a.getDay()];)r[a.getDay()]=a.toLocaleString(n,{weekday:o}),a.setDate(a.getDate()+1);const e=r.shift();return e&&r.push(e),r}static monthNames(t,o="short"){const n=t||navigator.language;return Array.from(Array(12).keys()).map(a=>new Date(2023,a,15).toLocaleString(n,{month:o}))}static toCalendarConfiguration(t,o,n,a,r){const e=r||navigator.language,g=s.stringToNeonDate(s.dateToIso(new Date),e),i=t?s.stringToNeonDate(t,e,!0):void 0,c=o||g.month,m=o&&n?new Date(n,o-1,15):null,L=(m==null?void 0:m.toLocaleString(e,{month:"long"}))||g.monthLongName,S=n||g.year,T=a||Math.floor(S/10)*10,d=new Date(S,(c+11)%12,1),f=new Date(S,(c+11)%12,1);f.setDate(f.getDate()-1);const u=[];let D=1,w=!1;for(let l=0;l<6;l++){u[l]=[];for(let h=0;h<7;h++)if(l===0&&h<f.getDay())u[l][h]=null;else if(u[l][h]=d.getDate(),D=d.getDate(),d.setDate(d.getDate()+1),d.getDate()===1){for(let y=h+1;y<7;y++)u[l][y]=null;w=!0;break}if(w)break}return{today:g,selected:i,pageMonth:c,pageMonthName:L,pageYear:S,pageDecadeStart:T,dowNames:s.dowNames(e),dowLongNames:s.dowNames(e,"long"),dates:u,lastDayOfMonth:D,months:s.monthNames(e),monthLongNames:s.monthNames(e,"long")}}}exports.NeonDateUtils=s;
2
2
  //# sourceMappingURL=NeonDateUtils.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NeonDateUtils.cjs.js","sources":["../../../../src/utils/common/date/NeonDateUtils.ts"],"sourcesContent":["import type { NeonCalendarConfig } from '@/model/user-input/calendar/NeonCalendarConfig';\nimport type { NeonDate } from '@/model/common/date/NeonDate';\n\n/**\n * Date utilities for general application use as well as internally with the\n * <a href=\"/user-input/date-picker\">NeonDatePicker</a> component.\n */\nexport class NeonDateUtils {\n /**\n * Format a Date object as a locale formatted date with a three letter month and a 2 digit day.\n * @param value The date to format.\n */\n public static formatDate(value: Date) {\n const { day, monthShortName } = NeonDateUtils.stringToNeonDate(value.toISOString());\n return `${monthShortName} ${day}`;\n }\n\n /**\n * Format an ISO 8601 string to a locale formatted date with a three letter month and a 2 digit day and the time.\n * @param value ISO date string\n * @param seconds boolean indicating whether to display seconds\n */\n public static formatISOStringToDateAndTime(value: string, seconds = false) {\n const { day, monthShortName, year, time, timeShort } = NeonDateUtils.stringToNeonDate(value);\n return seconds ? `${day} ${monthShortName} ${year}, ${time}` : `${day} ${monthShortName} ${year}, ${timeShort}`;\n }\n\n /**\n * Convert an ISO 8601 formatted string to a locale formatted date with a three letter month, a 2 digit day and a locale formatted time.\n *\n * @param date The date/time as an <a href=\"https://en.wikipedia.org/wiki/ISO_8601\">ISO 8601</a> string.\n * @param locale The locale for which to convert the date for display purposes, defaults to browser locale.\n * @param strict Do not add time component to localise the date.\n *\n * @returns Object representing the provided date.\n */\n public static stringToNeonDate(date: string, locale?: string, strict = false): NeonDate {\n const loc = locale || navigator.language;\n const now = new Date();\n const dateObj = new Date(!strict && date.length === 10 ? `${date}T${now.toISOString().split('T')[1]}` : date);\n let time;\n if (date.length > 10) {\n time = dateObj.toLocaleString(\n 'en-GB', // use en-GB for 0-23 hr offset\n date.length <= 16\n ? { hour12: false, hour: '2-digit', minute: '2-digit' }\n : { hour12: false, hour: '2-digit', minute: '2-digit', second: '2-digit' },\n );\n }\n\n const result: NeonDate = {\n year: +dateObj.toLocaleString('en-US', { year: 'numeric' }),\n yearFormatted: dateObj.toLocaleString(loc, { year: 'numeric' }),\n month: +dateObj.toLocaleString('en-US', { month: 'numeric' }),\n monthShortName: dateObj.toLocaleString(loc, { month: 'short' }),\n monthLongName: dateObj.toLocaleString(loc, { month: 'long' }),\n day: +dateObj.toLocaleString('en-US', { day: 'numeric' }),\n dayFormatted: dateObj.toLocaleString(loc, { day: '2-digit' }),\n };\n\n if (time) {\n result.time = time;\n // use en-GB for 0-23 hr offset\n result.timeShort = dateObj.toLocaleString('en-GB', {\n hour12: false,\n hourCycle: 'h23',\n hour: '2-digit',\n minute: '2-digit',\n });\n }\n\n return result;\n }\n\n /**\n * Convert a date object to an ISO 8601 formatted string. By default, the time is not considered.\n *\n * @param date Javascript date object.\n * @param time Whether to consider the time as part of the conversion to the ISO string.\n *\n * @returns an ISO 8601 formatted date, optionally with the time as well.\n */\n public static dateToIso(date: Date, time = false): string {\n const dateString = date.toISOString();\n return time ? dateString : dateString.split('T')[0];\n }\n\n /**\n * Convert the params received into an ISO 8601 formatted string with only date in it.\n *\n * @param day The number of the day to be used.\n * @param month The number of the month to be used.\n * @param year The number of the year to be used.\n *\n * @returns an ISO 8601 formatted date for the given parameters.\n */\n public static dmyToIso(day: number, month: number, year: number): string {\n return `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day}`;\n }\n\n /**\n * Returns the days of the week starting at Monday day name translated using the locale received as a first element.\n *\n * @param locale The locale for which to convert the date for display purposes, defaults to browser locale.\n * @param format The format of the returned values\n *\n * @returns an array with the days of the week named according to the locale received.\n */\n public static dowNames(locale?: string, format: 'long' | 'short' | 'narrow' = 'short'): Array<string> {\n const loc = locale || navigator.language;\n const date = new Date();\n\n const weekdays = [];\n while (!weekdays[date.getDay()]) {\n weekdays[date.getDay()] = date.toLocaleString(loc, { weekday: format });\n date.setDate(date.getDate() + 1);\n }\n\n const sunday = weekdays.shift();\n if (sunday) {\n weekdays.push(sunday);\n }\n\n return weekdays;\n }\n\n /**\n * Returns the months of the year starting at January month name translated using the locale received as a first element.\n *\n * @param locale The locale for which to convert the date for display purposes, defaults to browser locale.\n * @param format The format of the month names to return\n *\n * @returns an array with the month names of the year, all named according to the locale received.\n */\n public static monthNames(\n locale?: string,\n format: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow' = 'short',\n ): Array<string> {\n const loc = locale || navigator.language;\n\n return Array.from(Array(12).keys()).map((key) => {\n const date = new Date(2023, key, 15);\n return date.toLocaleString(loc, { month: format });\n });\n }\n\n /**\n * Collate & return the data required to drive the calendar popup in\n * <a href=\"/user-input/date-picker\">NeonDatePicker</a>.\n *\n * @param selectedDate ISO-8601 date-only string for the selected date.\n * @param currentPageMonth month of the current calendar page.\n * @param currentPageYear year of the current calendar page.\n * @param currentPageDecadeStart decade start year of the current calendar page.\n * @param locale user's locale.\n *\n * @returns The calendar configuration.\n */\n public static toCalendarConfiguration(\n selectedDate?: string,\n currentPageMonth?: number,\n currentPageYear?: number,\n currentPageDecadeStart?: number,\n locale?: string,\n ): NeonCalendarConfig {\n const loc = locale || navigator.language;\n const today = NeonDateUtils.stringToNeonDate(NeonDateUtils.dateToIso(new Date()), loc);\n const selected = selectedDate ? NeonDateUtils.stringToNeonDate(selectedDate, loc, true) : undefined;\n // month indexed from 1-12\n const pageMonth = currentPageMonth || today.month;\n\n // month indexed from 0-11\n const pageDate = currentPageMonth && currentPageYear ? new Date(currentPageYear, currentPageMonth - 1, 15) : null;\n const pageMonthName = pageDate?.toLocaleString(loc, { month: 'long' }) || today.monthLongName;\n const pageYear = currentPageYear || today.year;\n const pageDecadeStart = currentPageDecadeStart || Math.floor(pageYear / 10) * 10;\n\n // determine dow of first day of month. Months are indexed from 0 here\n const date = new Date(pageYear, (pageMonth + 11) % 12, 1);\n const offsetDate = new Date(pageYear, (pageMonth + 11) % 12, 1);\n offsetDate.setDate(offsetDate.getDate() - 1);\n\n const dates: Array<Array<number | null>> = [];\n\n let lastDayOfMonth = 1;\n let done = false;\n\n for (let row = 0; row < 6; row++) {\n dates[row] = [];\n\n for (let col = 0; col < 7; col++) {\n if (row === 0 && col < offsetDate.getDay()) {\n dates[row][col] = null;\n } else {\n dates[row][col] = date.getDate();\n lastDayOfMonth = date.getDate();\n date.setDate(date.getDate() + 1);\n\n if (date.getDate() === 1) {\n for (let i = col + 1; i < 7; i++) {\n dates[row][i] = null;\n }\n done = true;\n break;\n }\n }\n }\n\n if (done) {\n break;\n }\n }\n\n return {\n today,\n selected,\n pageMonth,\n pageMonthName,\n pageYear,\n pageDecadeStart,\n dowNames: NeonDateUtils.dowNames(loc),\n dowLongNames: NeonDateUtils.dowNames(loc, 'long'),\n dates,\n lastDayOfMonth,\n months: NeonDateUtils.monthNames(loc),\n monthLongNames: NeonDateUtils.monthNames(loc, 'long'),\n };\n }\n}\n"],"names":["NeonDateUtils","value","day","monthShortName","seconds","year","time","timeShort","date","locale","strict","loc","now","dateObj","result","dateString","month","format","weekdays","sunday","key","selectedDate","currentPageMonth","currentPageYear","currentPageDecadeStart","today","selected","pageMonth","pageDate","pageMonthName","pageYear","pageDecadeStart","offsetDate","dates","lastDayOfMonth","done","row","col","i"],"mappings":"gFAOO,MAAMA,CAAc,CAKzB,OAAc,WAAWC,EAAa,CACpC,KAAM,CAAE,IAAAC,EAAK,eAAAC,CAAA,EAAmBH,EAAc,iBAAiBC,EAAM,aAAa,EAClF,MAAO,GAAGE,CAAc,IAAID,CAAG,EACjC,CAOA,OAAc,6BAA6BD,EAAeG,EAAU,GAAO,CACzE,KAAM,CAAE,IAAAF,EAAK,eAAAC,EAAgB,KAAAE,EAAM,KAAAC,EAAM,UAAAC,GAAcP,EAAc,iBAAiBC,CAAK,EAC3F,OAAOG,EAAU,GAAGF,CAAG,IAAIC,CAAc,IAAIE,CAAI,KAAKC,CAAI,GA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DK,EAAa,IAAI,KAAKF,GAAWH,EAAY,IAAM,GAAI,CAAC,EAC9DK,EAAW,QAAQA,EAAW,QAAA,EAAY,CAAC,EAE3C,MAAMC,EAAqC,CAAA,EAE3C,IAAIC,EAAiB,EACjBC,EAAO,GAEX,QAASC,EAAM,EAAGA,EAAM,EAAGA,IAAO,CAChCH,EAAMG,CAAG,EAAI,CAAA,EAEb,QAASC,EAAM,EAAGA,EAAM,EAAGA,IACzB,GAAID,IAAQ,GAAKC,EAAML,EAAW,SAChCC,EAAMG,CAAG,EAAEC,CAAG,EAAI,aAElBJ,EAAMG,CAAG,EAAEC,CAAG,EAAI7B,EAAK,QAAA,EACvB0B,EAAiB1B,EAAK,QAAA,EACtBA,EAAK,QAAQA,EAAK,QAAA,EAAY,CAAC,EAE3BA,EAAK,QAAA,IAAc,EAAG,CACxB,QAAS8B,EAAID,EAAM,EAAGC,EAAI,EAAGA,IAC3BL,EAAMG,CAAG,EAAEE,CAAC,EAAI,KAElBH,EAAO,GACP,KACF,CAIJ,GAAIA,EACF,KAEJ,CAEA,MAAO,CACL,MAAAV,EACA,SAAAC,EACA,UAAAC,EACA,cAAAE,EACA,SAAAC,EACA,gBAAAC,EACA,SAAU/B,EAAc,SAASW,CAAG,EACpC,aAAcX,EAAc,SAASW,EAAK,MAAM,EAChD,MAAAsB,EACA,eAAAC,EACA,OAAQlC,EAAc,WAAWW,CAAG,EACpC,eAAgBX,EAAc,WAAWW,EAAK,MAAM,CAAA,CAExD,CACF"}
1
+ {"version":3,"file":"NeonDateUtils.cjs.js","sources":["../../../../src/utils/common/date/NeonDateUtils.ts"],"sourcesContent":["import type { NeonCalendarConfig } from '@/model/user-input/calendar/NeonCalendarConfig';\nimport type { NeonDate } from '@/model/common/date/NeonDate';\n\n/**\n * Date utilities for general application use as well as internally with the\n * <a href=\"/user-input/date-picker\">NeonDatePicker</a> component.\n */\nexport class NeonDateUtils {\n /**\n * Format a Date object as a locale formatted date with a three letter month and a 2 digit day.\n * @param value The date to format.\n */\n public static formatDate(value: Date) {\n const { dayFormatted, monthShortName } = NeonDateUtils.stringToNeonDate(value.toISOString());\n return `${monthShortName} ${dayFormatted}`;\n }\n\n /**\n * Format an ISO 8601 string to a locale formatted date with a three letter month and a 2 digit day and the time.\n * @param value ISO date string\n * @param seconds boolean indicating whether to display seconds\n */\n public static formatISOStringToDateAndTime(value: string, seconds = false) {\n const { dayFormatted, monthShortName, year, time, timeShort } = NeonDateUtils.stringToNeonDate(value);\n return seconds\n ? `${dayFormatted} ${monthShortName} ${year}, ${time}`\n : `${dayFormatted} ${monthShortName} ${year}, ${timeShort}`;\n }\n\n /**\n * Convert an ISO 8601 formatted string to a locale formatted date with a three letter month, a 2 digit day and a locale formatted time.\n *\n * @param date The date/time as an <a href=\"https://en.wikipedia.org/wiki/ISO_8601\">ISO 8601</a> string.\n * @param locale The locale for which to convert the date for display purposes, defaults to browser locale.\n * @param strict Do not add time component to localise the date.\n *\n * @returns Object representing the provided date.\n */\n public static stringToNeonDate(date: string, locale?: string, strict = false): NeonDate {\n const loc = locale || navigator.language;\n const now = new Date();\n const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;\n const isUTC = !(date.match(/(.*)Z/) || date.match(/(.*)[+-]\\d{2}:\\d{2}/));\n const dateObj = new Date(\n !strict && date.length === 10 ? `${date}T${now.toISOString().split('T')[1]}` : date + (isUTC ? 'Z' : ''),\n );\n\n let time;\n if (date.length > 10) {\n time = dateObj.toLocaleString(\n 'en-GB', // use en-GB for 0-23 hr offset\n date.length <= 16\n ? { hour12: false, hour: '2-digit', minute: '2-digit', timeZone }\n : { hour12: false, hour: '2-digit', minute: '2-digit', second: '2-digit', timeZone },\n );\n }\n\n const result: NeonDate = {\n year: +dateObj.toLocaleString('en-US', { year: 'numeric', timeZone }),\n yearFormatted: dateObj.toLocaleString(loc, { year: 'numeric', timeZone }),\n month: +dateObj.toLocaleString('en-US', { month: 'numeric', timeZone }),\n monthShortName: dateObj.toLocaleString(loc, { month: 'short', timeZone }),\n monthLongName: dateObj.toLocaleString(loc, { month: 'long', timeZone }),\n day: +dateObj.toLocaleString('en-US', { day: 'numeric', timeZone }),\n dayFormatted: dateObj.toLocaleString(loc, { day: '2-digit', timeZone }),\n };\n\n if (time) {\n result.time = time;\n // use en-GB for 0-23 hr offset\n result.timeShort = dateObj.toLocaleString('en-GB', {\n hour12: false,\n hourCycle: 'h23',\n hour: '2-digit',\n minute: '2-digit',\n timeZone,\n });\n }\n\n return result;\n }\n\n /**\n * Convert a date object to an ISO 8601 formatted string. By default, the time is not considered.\n *\n * @param date Javascript date object.\n * @param time Whether to consider the time as part of the conversion to the ISO string.\n *\n * @returns an ISO 8601 formatted date, optionally with the time as well.\n */\n public static dateToIso(date: Date, time = false): string {\n const dateString = date.toISOString();\n return time ? dateString : dateString.split('T')[0];\n }\n\n /**\n * Convert the params received into an ISO 8601 formatted string with only date in it.\n *\n * @param day The number of the day to be used.\n * @param month The number of the month to be used.\n * @param year The number of the year to be used.\n *\n * @returns an ISO 8601 formatted date for the given parameters.\n */\n public static dmyToIso(day: number, month: number, year: number): string {\n return `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day}`;\n }\n\n /**\n * Returns the days of the week starting at Monday day name translated using the locale received as a first element.\n *\n * @param locale The locale for which to convert the date for display purposes, defaults to browser locale.\n * @param format The format of the returned values\n *\n * @returns an array with the days of the week named according to the locale received.\n */\n public static dowNames(locale?: string, format: 'long' | 'short' | 'narrow' = 'short'): Array<string> {\n const loc = locale || navigator.language;\n const date = new Date();\n\n const weekdays = [];\n while (!weekdays[date.getDay()]) {\n weekdays[date.getDay()] = date.toLocaleString(loc, { weekday: format });\n date.setDate(date.getDate() + 1);\n }\n\n const sunday = weekdays.shift();\n if (sunday) {\n weekdays.push(sunday);\n }\n\n return weekdays;\n }\n\n /**\n * Returns the months of the year starting at January month name translated using the locale received as a first element.\n *\n * @param locale The locale for which to convert the date for display purposes, defaults to browser locale.\n * @param format The format of the month names to return\n *\n * @returns an array with the month names of the year, all named according to the locale received.\n */\n public static monthNames(\n locale?: string,\n format: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow' = 'short',\n ): Array<string> {\n const loc = locale || navigator.language;\n\n return Array.from(Array(12).keys()).map((key) => {\n const date = new Date(2023, key, 15);\n return date.toLocaleString(loc, { month: format });\n });\n }\n\n /**\n * Collate & return the data required to drive the calendar popup in\n * <a href=\"/user-input/date-picker\">NeonDatePicker</a>.\n *\n * @param selectedDate ISO-8601 date-only string for the selected date.\n * @param currentPageMonth month of the current calendar page.\n * @param currentPageYear year of the current calendar page.\n * @param currentPageDecadeStart decade start year of the current calendar page.\n * @param locale user's locale.\n *\n * @returns The calendar configuration.\n */\n public static toCalendarConfiguration(\n selectedDate?: string,\n currentPageMonth?: number,\n currentPageYear?: number,\n currentPageDecadeStart?: number,\n locale?: string,\n ): NeonCalendarConfig {\n const loc = locale || navigator.language;\n const today = NeonDateUtils.stringToNeonDate(NeonDateUtils.dateToIso(new Date()), loc);\n const selected = selectedDate ? NeonDateUtils.stringToNeonDate(selectedDate, loc, true) : undefined;\n // month indexed from 1-12\n const pageMonth = currentPageMonth || today.month;\n\n // month indexed from 0-11\n const pageDate = currentPageMonth && currentPageYear ? new Date(currentPageYear, currentPageMonth - 1, 15) : null;\n const pageMonthName = pageDate?.toLocaleString(loc, { month: 'long' }) || today.monthLongName;\n const pageYear = currentPageYear || today.year;\n const pageDecadeStart = currentPageDecadeStart || Math.floor(pageYear / 10) * 10;\n\n // determine dow of first day of month. Months are indexed from 0 here\n const date = new Date(pageYear, (pageMonth + 11) % 12, 1);\n const offsetDate = new Date(pageYear, (pageMonth + 11) % 12, 1);\n offsetDate.setDate(offsetDate.getDate() - 1);\n\n const dates: Array<Array<number | null>> = [];\n\n let lastDayOfMonth = 1;\n let done = false;\n\n for (let row = 0; row < 6; row++) {\n dates[row] = [];\n\n for (let col = 0; col < 7; col++) {\n if (row === 0 && col < offsetDate.getDay()) {\n dates[row][col] = null;\n } else {\n dates[row][col] = date.getDate();\n lastDayOfMonth = date.getDate();\n date.setDate(date.getDate() + 1);\n\n if (date.getDate() === 1) {\n for (let i = col + 1; i < 7; i++) {\n dates[row][i] = null;\n }\n done = true;\n break;\n }\n }\n }\n\n if (done) {\n break;\n }\n }\n\n return {\n today,\n selected,\n pageMonth,\n pageMonthName,\n pageYear,\n pageDecadeStart,\n dowNames: NeonDateUtils.dowNames(loc),\n dowLongNames: NeonDateUtils.dowNames(loc, 'long'),\n dates,\n lastDayOfMonth,\n months: NeonDateUtils.monthNames(loc),\n monthLongNames: NeonDateUtils.monthNames(loc, 'long'),\n };\n }\n}\n"],"names":["NeonDateUtils","value","dayFormatted","monthShortName","seconds","year","time","timeShort","date","locale","strict","loc","now","timeZone","isUTC","dateObj","result","dateString","day","month","format","weekdays","sunday","key","selectedDate","currentPageMonth","currentPageYear","currentPageDecadeStart","today","selected","pageMonth","pageDate","pageMonthName","pageYear","pageDecadeStart","offsetDate","dates","lastDayOfMonth","done","row","col","i"],"mappings":"gFAOO,MAAMA,CAAc,CAKzB,OAAc,WAAWC,EAAa,CACpC,KAAM,CAAE,aAAAC,EAAc,eAAAC,CAAA,EAAmBH,EAAc,iBAAiBC,EAAM,aAAa,EAC3F,MAAO,GAAGE,CAAc,IAAID,CAAY,EAC1C,CAOA,OAAc,6BAA6BD,EAAeG,EAAU,GAAO,CACzE,KAAM,CAAE,aAAAF,EAAc,eAAAC,EAAgB,KAAAE,EAAM,KAAAC,EAAM,UAAAC,GAAcP,EAAc,iBAAiBC,CAAK,EACpG,OAAOG,EACH,GAAGF,CAAY,IAAIC,CAAc,IAAIE,CAAI,KAAKC,CAAI,GAClD,GAAGJ,CAAY,IAAIC,CAAc,IAAIE,CAAI,KAAKE,CAAS,EAC7D,CAWA,OAAc,iBAAiBC,EAAcC,EAAiBC,EAAS,GAAiB,CACtF,MAAMC,EAAMF,GAAU,UAAU,SAC1BG,MAAU,KACVC,EAAW,KAAK,eAAA,EAAiB,kBAAkB,SACnDC,E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AI,KAAKyB,GAAWH,EAAY,IAAM,GAAI,CAAC,EAClDK,EAAa,IAAI,KAAKF,GAAWH,EAAY,IAAM,GAAI,CAAC,EAC9DK,EAAW,QAAQA,EAAW,QAAA,EAAY,CAAC,EAE3C,MAAMC,EAAqC,CAAA,EAE3C,IAAIC,EAAiB,EACjBC,EAAO,GAEX,QAASC,EAAM,EAAGA,EAAM,EAAGA,IAAO,CAChCH,EAAMG,CAAG,EAAI,CAAA,EAEb,QAASC,EAAM,EAAGA,EAAM,EAAGA,IACzB,GAAID,IAAQ,GAAKC,EAAML,EAAW,SAChCC,EAAMG,CAAG,EAAEC,CAAG,EAAI,aAElBJ,EAAMG,CAAG,EAAEC,CAAG,EAAIhC,EAAK,QAAA,EACvB6B,EAAiB7B,EAAK,QAAA,EACtBA,EAAK,QAAQA,EAAK,QAAA,EAAY,CAAC,EAE3BA,EAAK,QAAA,IAAc,EAAG,CACxB,QAASiC,EAAID,EAAM,EAAGC,EAAI,EAAGA,IAC3BL,EAAMG,CAAG,EAAEE,CAAC,EAAI,KAElBH,EAAO,GACP,KACF,CAIJ,GAAIA,EACF,KAEJ,CAEA,MAAO,CACL,MAAAV,EACA,SAAAC,EACA,UAAAC,EACA,cAAAE,EACA,SAAAC,EACA,gBAAAC,EACA,SAAUlC,EAAc,SAASW,CAAG,EACpC,aAAcX,EAAc,SAASW,EAAK,MAAM,EAChD,MAAAyB,EACA,eAAAC,EACA,OAAQrC,EAAc,WAAWW,CAAG,EACpC,eAAgBX,EAAc,WAAWW,EAAK,MAAM,CAAA,CAExD,CACF"}
@@ -4,17 +4,17 @@ class i {
4
4
  * @param value The date to format.
5
5
  */
6
6
  static formatDate(t) {
7
- const { day: o, monthShortName: n } = i.stringToNeonDate(t.toISOString());
8
- return `${n} ${o}`;
7
+ const { dayFormatted: e, monthShortName: n } = i.stringToNeonDate(t.toISOString());
8
+ return `${n} ${e}`;
9
9
  }
10
10
  /**
11
11
  * Format an ISO 8601 string to a locale formatted date with a three letter month and a 2 digit day and the time.
12
12
  * @param value ISO date string
13
13
  * @param seconds boolean indicating whether to display seconds
14
14
  */
15
- static formatISOStringToDateAndTime(t, o = !1) {
16
- const { day: n, monthShortName: a, year: r, time: e, timeShort: s } = i.stringToNeonDate(t);
17
- return o ? `${n} ${a} ${r}, ${e}` : `${n} ${a} ${r}, ${s}`;
15
+ static formatISOStringToDateAndTime(t, e = !1) {
16
+ const { dayFormatted: n, monthShortName: a, year: r, time: o, timeShort: g } = i.stringToNeonDate(t);
17
+ return e ? `${n} ${a} ${r}, ${o}` : `${n} ${a} ${r}, ${g}`;
18
18
  }
19
19
  /**
20
20
  * Convert an ISO 8601 formatted string to a locale formatted date with a three letter month, a 2 digit day and a locale formatted time.
@@ -25,29 +25,32 @@ class i {
25
25
  *
26
26
  * @returns Object representing the provided date.
27
27
  */
28
- static stringToNeonDate(t, o, n = !1) {
29
- const a = o || navigator.language, r = /* @__PURE__ */ new Date(), e = new Date(!n && t.length === 10 ? `${t}T${r.toISOString().split("T")[1]}` : t);
30
- let s;
31
- t.length > 10 && (s = e.toLocaleString(
28
+ static stringToNeonDate(t, e, n = !1) {
29
+ const a = e || navigator.language, r = /* @__PURE__ */ new Date(), o = Intl.DateTimeFormat().resolvedOptions().timeZone, g = !(t.match(/(.*)Z/) || t.match(/(.*)[+-]\d{2}:\d{2}/)), s = /* @__PURE__ */ new Date(
30
+ !n && t.length === 10 ? `${t}T${r.toISOString().split("T")[1]}` : t + (g ? "Z" : "")
31
+ );
32
+ let m;
33
+ t.length > 10 && (m = s.toLocaleString(
32
34
  "en-GB",
33
35
  // use en-GB for 0-23 hr offset
34
- t.length <= 16 ? { hour12: !1, hour: "2-digit", minute: "2-digit" } : { hour12: !1, hour: "2-digit", minute: "2-digit", second: "2-digit" }
36
+ t.length <= 16 ? { hour12: !1, hour: "2-digit", minute: "2-digit", timeZone: o } : { hour12: !1, hour: "2-digit", minute: "2-digit", second: "2-digit", timeZone: o }
35
37
  ));
36
- const m = {
37
- year: +e.toLocaleString("en-US", { year: "numeric" }),
38
- yearFormatted: e.toLocaleString(a, { year: "numeric" }),
39
- month: +e.toLocaleString("en-US", { month: "numeric" }),
40
- monthShortName: e.toLocaleString(a, { month: "short" }),
41
- monthLongName: e.toLocaleString(a, { month: "long" }),
42
- day: +e.toLocaleString("en-US", { day: "numeric" }),
43
- dayFormatted: e.toLocaleString(a, { day: "2-digit" })
38
+ const c = {
39
+ year: +s.toLocaleString("en-US", { year: "numeric", timeZone: o }),
40
+ yearFormatted: s.toLocaleString(a, { year: "numeric", timeZone: o }),
41
+ month: +s.toLocaleString("en-US", { month: "numeric", timeZone: o }),
42
+ monthShortName: s.toLocaleString(a, { month: "short", timeZone: o }),
43
+ monthLongName: s.toLocaleString(a, { month: "long", timeZone: o }),
44
+ day: +s.toLocaleString("en-US", { day: "numeric", timeZone: o }),
45
+ dayFormatted: s.toLocaleString(a, { day: "2-digit", timeZone: o })
44
46
  };
45
- return s && (m.time = s, m.timeShort = e.toLocaleString("en-GB", {
47
+ return m && (c.time = m, c.timeShort = s.toLocaleString("en-GB", {
46
48
  hour12: !1,
47
49
  hourCycle: "h23",
48
50
  hour: "2-digit",
49
- minute: "2-digit"
50
- })), m;
51
+ minute: "2-digit",
52
+ timeZone: o
53
+ })), c;
51
54
  }
52
55
  /**
53
56
  * Convert a date object to an ISO 8601 formatted string. By default, the time is not considered.
@@ -57,9 +60,9 @@ class i {
57
60
  *
58
61
  * @returns an ISO 8601 formatted date, optionally with the time as well.
59
62
  */
60
- static dateToIso(t, o = !1) {
63
+ static dateToIso(t, e = !1) {
61
64
  const n = t.toISOString();
62
- return o ? n : n.split("T")[0];
65
+ return e ? n : n.split("T")[0];
63
66
  }
64
67
  /**
65
68
  * Convert the params received into an ISO 8601 formatted string with only date in it.
@@ -70,8 +73,8 @@ class i {
70
73
  *
71
74
  * @returns an ISO 8601 formatted date for the given parameters.
72
75
  */
73
- static dmyToIso(t, o, n) {
74
- return `${n}-${o < 10 ? "0" + o : o}-${t < 10 ? "0" + t : t}`;
76
+ static dmyToIso(t, e, n) {
77
+ return `${n}-${e < 10 ? "0" + e : e}-${t < 10 ? "0" + t : t}`;
75
78
  }
76
79
  /**
77
80
  * Returns the days of the week starting at Monday day name translated using the locale received as a first element.
@@ -81,12 +84,12 @@ class i {
81
84
  *
82
85
  * @returns an array with the days of the week named according to the locale received.
83
86
  */
84
- static dowNames(t, o = "short") {
87
+ static dowNames(t, e = "short") {
85
88
  const n = t || navigator.language, a = /* @__PURE__ */ new Date(), r = [];
86
89
  for (; !r[a.getDay()]; )
87
- r[a.getDay()] = a.toLocaleString(n, { weekday: o }), a.setDate(a.getDate() + 1);
88
- const e = r.shift();
89
- return e && r.push(e), r;
90
+ r[a.getDay()] = a.toLocaleString(n, { weekday: e }), a.setDate(a.getDate() + 1);
91
+ const o = r.shift();
92
+ return o && r.push(o), r;
90
93
  }
91
94
  /**
92
95
  * Returns the months of the year starting at January month name translated using the locale received as a first element.
@@ -96,9 +99,9 @@ class i {
96
99
  *
97
100
  * @returns an array with the month names of the year, all named according to the locale received.
98
101
  */
99
- static monthNames(t, o = "short") {
102
+ static monthNames(t, e = "short") {
100
103
  const n = t || navigator.language;
101
- return Array.from(Array(12).keys()).map((a) => new Date(2023, a, 15).toLocaleString(n, { month: o }));
104
+ return Array.from(Array(12).keys()).map((a) => new Date(2023, a, 15).toLocaleString(n, { month: e }));
102
105
  }
103
106
  /**
104
107
  * Collate & return the data required to drive the calendar popup in
@@ -112,19 +115,19 @@ class i {
112
115
  *
113
116
  * @returns The calendar configuration.
114
117
  */
115
- static toCalendarConfiguration(t, o, n, a, r) {
116
- const e = r || navigator.language, s = i.stringToNeonDate(i.dateToIso(/* @__PURE__ */ new Date()), e), m = t ? i.stringToNeonDate(t, e, !0) : void 0, u = o || s.month, S = o && n ? new Date(n, o - 1, 15) : null, L = (S == null ? void 0 : S.toLocaleString(e, { month: "long" })) || s.monthLongName, d = n || s.year, $ = a || Math.floor(d / 10) * 10, l = new Date(d, (u + 11) % 12, 1), f = new Date(d, (u + 11) % 12, 1);
118
+ static toCalendarConfiguration(t, e, n, a, r) {
119
+ const o = r || navigator.language, g = i.stringToNeonDate(i.dateToIso(/* @__PURE__ */ new Date()), o), s = t ? i.stringToNeonDate(t, o, !0) : void 0, m = e || g.month, c = e && n ? new Date(n, e - 1, 15) : null, L = (c == null ? void 0 : c.toLocaleString(o, { month: "long" })) || g.monthLongName, S = n || g.year, T = a || Math.floor(S / 10) * 10, d = new Date(S, (m + 11) % 12, 1), f = new Date(S, (m + 11) % 12, 1);
117
120
  f.setDate(f.getDate() - 1);
118
- const h = [];
121
+ const u = [];
119
122
  let D = 1, w = !1;
120
- for (let g = 0; g < 6; g++) {
121
- h[g] = [];
122
- for (let c = 0; c < 7; c++)
123
- if (g === 0 && c < f.getDay())
124
- h[g][c] = null;
125
- else if (h[g][c] = l.getDate(), D = l.getDate(), l.setDate(l.getDate() + 1), l.getDate() === 1) {
126
- for (let y = c + 1; y < 7; y++)
127
- h[g][y] = null;
123
+ for (let l = 0; l < 6; l++) {
124
+ u[l] = [];
125
+ for (let h = 0; h < 7; h++)
126
+ if (l === 0 && h < f.getDay())
127
+ u[l][h] = null;
128
+ else if (u[l][h] = d.getDate(), D = d.getDate(), d.setDate(d.getDate() + 1), d.getDate() === 1) {
129
+ for (let y = h + 1; y < 7; y++)
130
+ u[l][y] = null;
128
131
  w = !0;
129
132
  break;
130
133
  }
@@ -132,18 +135,18 @@ class i {
132
135
  break;
133
136
  }
134
137
  return {
135
- today: s,
136
- selected: m,
137
- pageMonth: u,
138
+ today: g,
139
+ selected: s,
140
+ pageMonth: m,
138
141
  pageMonthName: L,
139
- pageYear: d,
140
- pageDecadeStart: $,
141
- dowNames: i.dowNames(e),
142
- dowLongNames: i.dowNames(e, "long"),
143
- dates: h,
142
+ pageYear: S,
143
+ pageDecadeStart: T,
144
+ dowNames: i.dowNames(o),
145
+ dowLongNames: i.dowNames(o, "long"),
146
+ dates: u,
144
147
  lastDayOfMonth: D,
145
- months: i.monthNames(e),
146
- monthLongNames: i.monthNames(e, "long")
148
+ months: i.monthNames(o),
149
+ monthLongNames: i.monthNames(o, "long")
147
150
  };
148
151
  }
149
152
  }
@@ -1 +1 @@
1
- {"version":3,"file":"NeonDateUtils.es.js","sources":["../../../../src/utils/common/date/NeonDateUtils.ts"],"sourcesContent":["import type { NeonCalendarConfig } from '@/model/user-input/calendar/NeonCalendarConfig';\nimport type { NeonDate } from '@/model/common/date/NeonDate';\n\n/**\n * Date utilities for general application use as well as internally with the\n * <a href=\"/user-input/date-picker\">NeonDatePicker</a> component.\n */\nexport class NeonDateUtils {\n /**\n * Format a Date object as a locale formatted date with a three letter month and a 2 digit day.\n * @param value The date to format.\n */\n public static formatDate(value: Date) {\n const { day, monthShortName } = NeonDateUtils.stringToNeonDate(value.toISOString());\n return `${monthShortName} ${day}`;\n }\n\n /**\n * Format an ISO 8601 string to a locale formatted date with a three letter month and a 2 digit day and the time.\n * @param value ISO date string\n * @param seconds boolean indicating whether to display seconds\n */\n public static formatISOStringToDateAndTime(value: string, seconds = false) {\n const { day, monthShortName, year, time, timeShort } = NeonDateUtils.stringToNeonDate(value);\n return seconds ? `${day} ${monthShortName} ${year}, ${time}` : `${day} ${monthShortName} ${year}, ${timeShort}`;\n }\n\n /**\n * Convert an ISO 8601 formatted string to a locale formatted date with a three letter month, a 2 digit day and a locale formatted time.\n *\n * @param date The date/time as an <a href=\"https://en.wikipedia.org/wiki/ISO_8601\">ISO 8601</a> string.\n * @param locale The locale for which to convert the date for display purposes, defaults to browser locale.\n * @param strict Do not add time component to localise the date.\n *\n * @returns Object representing the provided date.\n */\n public static stringToNeonDate(date: string, locale?: string, strict = false): NeonDate {\n const loc = locale || navigator.language;\n const now = new Date();\n const dateObj = new Date(!strict && date.length === 10 ? `${date}T${now.toISOString().split('T')[1]}` : date);\n let time;\n if (date.length > 10) {\n time = dateObj.toLocaleString(\n 'en-GB', // use en-GB for 0-23 hr offset\n date.length <= 16\n ? { hour12: false, hour: '2-digit', minute: '2-digit' }\n : { hour12: false, hour: '2-digit', minute: '2-digit', second: '2-digit' },\n );\n }\n\n const result: NeonDate = {\n year: +dateObj.toLocaleString('en-US', { year: 'numeric' }),\n yearFormatted: dateObj.toLocaleString(loc, { year: 'numeric' }),\n month: +dateObj.toLocaleString('en-US', { month: 'numeric' }),\n monthShortName: dateObj.toLocaleString(loc, { month: 'short' }),\n monthLongName: dateObj.toLocaleString(loc, { month: 'long' }),\n day: +dateObj.toLocaleString('en-US', { day: 'numeric' }),\n dayFormatted: dateObj.toLocaleString(loc, { day: '2-digit' }),\n };\n\n if (time) {\n result.time = time;\n // use en-GB for 0-23 hr offset\n result.timeShort = dateObj.toLocaleString('en-GB', {\n hour12: false,\n hourCycle: 'h23',\n hour: '2-digit',\n minute: '2-digit',\n });\n }\n\n return result;\n }\n\n /**\n * Convert a date object to an ISO 8601 formatted string. By default, the time is not considered.\n *\n * @param date Javascript date object.\n * @param time Whether to consider the time as part of the conversion to the ISO string.\n *\n * @returns an ISO 8601 formatted date, optionally with the time as well.\n */\n public static dateToIso(date: Date, time = false): string {\n const dateString = date.toISOString();\n return time ? dateString : dateString.split('T')[0];\n }\n\n /**\n * Convert the params received into an ISO 8601 formatted string with only date in it.\n *\n * @param day The number of the day to be used.\n * @param month The number of the month to be used.\n * @param year The number of the year to be used.\n *\n * @returns an ISO 8601 formatted date for the given parameters.\n */\n public static dmyToIso(day: number, month: number, year: number): string {\n return `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day}`;\n }\n\n /**\n * Returns the days of the week starting at Monday day name translated using the locale received as a first element.\n *\n * @param locale The locale for which to convert the date for display purposes, defaults to browser locale.\n * @param format The format of the returned values\n *\n * @returns an array with the days of the week named according to the locale received.\n */\n public static dowNames(locale?: string, format: 'long' | 'short' | 'narrow' = 'short'): Array<string> {\n const loc = locale || navigator.language;\n const date = new Date();\n\n const weekdays = [];\n while (!weekdays[date.getDay()]) {\n weekdays[date.getDay()] = date.toLocaleString(loc, { weekday: format });\n date.setDate(date.getDate() + 1);\n }\n\n const sunday = weekdays.shift();\n if (sunday) {\n weekdays.push(sunday);\n }\n\n return weekdays;\n }\n\n /**\n * Returns the months of the year starting at January month name translated using the locale received as a first element.\n *\n * @param locale The locale for which to convert the date for display purposes, defaults to browser locale.\n * @param format The format of the month names to return\n *\n * @returns an array with the month names of the year, all named according to the locale received.\n */\n public static monthNames(\n locale?: string,\n format: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow' = 'short',\n ): Array<string> {\n const loc = locale || navigator.language;\n\n return Array.from(Array(12).keys()).map((key) => {\n const date = new Date(2023, key, 15);\n return date.toLocaleString(loc, { month: format });\n });\n }\n\n /**\n * Collate & return the data required to drive the calendar popup in\n * <a href=\"/user-input/date-picker\">NeonDatePicker</a>.\n *\n * @param selectedDate ISO-8601 date-only string for the selected date.\n * @param currentPageMonth month of the current calendar page.\n * @param currentPageYear year of the current calendar page.\n * @param currentPageDecadeStart decade start year of the current calendar page.\n * @param locale user's locale.\n *\n * @returns The calendar configuration.\n */\n public static toCalendarConfiguration(\n selectedDate?: string,\n currentPageMonth?: number,\n currentPageYear?: number,\n currentPageDecadeStart?: number,\n locale?: string,\n ): NeonCalendarConfig {\n const loc = locale || navigator.language;\n const today = NeonDateUtils.stringToNeonDate(NeonDateUtils.dateToIso(new Date()), loc);\n const selected = selectedDate ? NeonDateUtils.stringToNeonDate(selectedDate, loc, true) : undefined;\n // month indexed from 1-12\n const pageMonth = currentPageMonth || today.month;\n\n // month indexed from 0-11\n const pageDate = currentPageMonth && currentPageYear ? new Date(currentPageYear, currentPageMonth - 1, 15) : null;\n const pageMonthName = pageDate?.toLocaleString(loc, { month: 'long' }) || today.monthLongName;\n const pageYear = currentPageYear || today.year;\n const pageDecadeStart = currentPageDecadeStart || Math.floor(pageYear / 10) * 10;\n\n // determine dow of first day of month. Months are indexed from 0 here\n const date = new Date(pageYear, (pageMonth + 11) % 12, 1);\n const offsetDate = new Date(pageYear, (pageMonth + 11) % 12, 1);\n offsetDate.setDate(offsetDate.getDate() - 1);\n\n const dates: Array<Array<number | null>> = [];\n\n let lastDayOfMonth = 1;\n let done = false;\n\n for (let row = 0; row < 6; row++) {\n dates[row] = [];\n\n for (let col = 0; col < 7; col++) {\n if (row === 0 && col < offsetDate.getDay()) {\n dates[row][col] = null;\n } else {\n dates[row][col] = date.getDate();\n lastDayOfMonth = date.getDate();\n date.setDate(date.getDate() + 1);\n\n if (date.getDate() === 1) {\n for (let i = col + 1; i < 7; i++) {\n dates[row][i] = null;\n }\n done = true;\n break;\n }\n }\n }\n\n if (done) {\n break;\n }\n }\n\n return {\n today,\n selected,\n pageMonth,\n pageMonthName,\n pageYear,\n pageDecadeStart,\n dowNames: NeonDateUtils.dowNames(loc),\n dowLongNames: NeonDateUtils.dowNames(loc, 'long'),\n dates,\n lastDayOfMonth,\n months: NeonDateUtils.monthNames(loc),\n monthLongNames: NeonDateUtils.monthNames(loc, 'long'),\n };\n }\n}\n"],"names":["NeonDateUtils","value","day","monthShortName","seconds","year","time","timeShort","date","locale","strict","loc","now","dateObj","result","dateString","month","format","weekdays","sunday","key","selectedDate","currentPageMonth","currentPageYear","currentPageDecadeStart","today","selected","pageMonth","pageDate","pageMonthName","pageYear","pageDecadeStart","offsetDate","dates","lastDayOfMonth","done","row","col","i"],"mappings":"AAOO,MAAMA,EAAc;AAAA;AAAA;AAAA;AAAA;AAAA,EAKzB,OAAc,WAAWC,GAAa;AACpC,UAAM,EAAE,KAAAC,GAAK,gBAAAC,EAAA,IAAmBH,EAAc,iBAAiBC,EAAM,aAAa;AAClF,WAAO,GAAGE,CAAc,IAAID,CAAG;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAc,6BAA6BD,GAAeG,IAAU,IAAO;AACzE,UAAM,EAAE,KAAAF,GAAK,gBAAAC,GAAgB,MAAAE,GAAM,MAAAC,GAAM,WAAAC,MAAcP,EAAc,iBAAiBC,CAAK;AAC3F,WAAOG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AAI;AAElB,UAAAH,IAAO;AACP;AAAA,QACF;AAIJ,UAAIA;AACF;AAAA,IAEJ;AAEA,WAAO;AAAA,MACL,OAAAV;AAAA,MACA,UAAAC;AAAA,MACA,WAAAC;AAAA,MACA,eAAAE;AAAA,MACA,UAAAC;AAAA,MACA,iBAAAC;AAAA,MACA,UAAU/B,EAAc,SAASW,CAAG;AAAA,MACpC,cAAcX,EAAc,SAASW,GAAK,MAAM;AAAA,MAChD,OAAAsB;AAAA,MACA,gBAAAC;AAAA,MACA,QAAQlC,EAAc,WAAWW,CAAG;AAAA,MACpC,gBAAgBX,EAAc,WAAWW,GAAK,MAAM;AAAA,IAAA;AAAA,EAExD;AACF;"}
1
+ {"version":3,"file":"NeonDateUtils.es.js","sources":["../../../../src/utils/common/date/NeonDateUtils.ts"],"sourcesContent":["import type { NeonCalendarConfig } from '@/model/user-input/calendar/NeonCalendarConfig';\nimport type { NeonDate } from '@/model/common/date/NeonDate';\n\n/**\n * Date utilities for general application use as well as internally with the\n * <a href=\"/user-input/date-picker\">NeonDatePicker</a> component.\n */\nexport class NeonDateUtils {\n /**\n * Format a Date object as a locale formatted date with a three letter month and a 2 digit day.\n * @param value The date to format.\n */\n public static formatDate(value: Date) {\n const { dayFormatted, monthShortName } = NeonDateUtils.stringToNeonDate(value.toISOString());\n return `${monthShortName} ${dayFormatted}`;\n }\n\n /**\n * Format an ISO 8601 string to a locale formatted date with a three letter month and a 2 digit day and the time.\n * @param value ISO date string\n * @param seconds boolean indicating whether to display seconds\n */\n public static formatISOStringToDateAndTime(value: string, seconds = false) {\n const { dayFormatted, monthShortName, year, time, timeShort } = NeonDateUtils.stringToNeonDate(value);\n return seconds\n ? `${dayFormatted} ${monthShortName} ${year}, ${time}`\n : `${dayFormatted} ${monthShortName} ${year}, ${timeShort}`;\n }\n\n /**\n * Convert an ISO 8601 formatted string to a locale formatted date with a three letter month, a 2 digit day and a locale formatted time.\n *\n * @param date The date/time as an <a href=\"https://en.wikipedia.org/wiki/ISO_8601\">ISO 8601</a> string.\n * @param locale The locale for which to convert the date for display purposes, defaults to browser locale.\n * @param strict Do not add time component to localise the date.\n *\n * @returns Object representing the provided date.\n */\n public static stringToNeonDate(date: string, locale?: string, strict = false): NeonDate {\n const loc = locale || navigator.language;\n const now = new Date();\n const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;\n const isUTC = !(date.match(/(.*)Z/) || date.match(/(.*)[+-]\\d{2}:\\d{2}/));\n const dateObj = new Date(\n !strict && date.length === 10 ? `${date}T${now.toISOString().split('T')[1]}` : date + (isUTC ? 'Z' : ''),\n );\n\n let time;\n if (date.length > 10) {\n time = dateObj.toLocaleString(\n 'en-GB', // use en-GB for 0-23 hr offset\n date.length <= 16\n ? { hour12: false, hour: '2-digit', minute: '2-digit', timeZone }\n : { hour12: false, hour: '2-digit', minute: '2-digit', second: '2-digit', timeZone },\n );\n }\n\n const result: NeonDate = {\n year: +dateObj.toLocaleString('en-US', { year: 'numeric', timeZone }),\n yearFormatted: dateObj.toLocaleString(loc, { year: 'numeric', timeZone }),\n month: +dateObj.toLocaleString('en-US', { month: 'numeric', timeZone }),\n monthShortName: dateObj.toLocaleString(loc, { month: 'short', timeZone }),\n monthLongName: dateObj.toLocaleString(loc, { month: 'long', timeZone }),\n day: +dateObj.toLocaleString('en-US', { day: 'numeric', timeZone }),\n dayFormatted: dateObj.toLocaleString(loc, { day: '2-digit', timeZone }),\n };\n\n if (time) {\n result.time = time;\n // use en-GB for 0-23 hr offset\n result.timeShort = dateObj.toLocaleString('en-GB', {\n hour12: false,\n hourCycle: 'h23',\n hour: '2-digit',\n minute: '2-digit',\n timeZone,\n });\n }\n\n return result;\n }\n\n /**\n * Convert a date object to an ISO 8601 formatted string. By default, the time is not considered.\n *\n * @param date Javascript date object.\n * @param time Whether to consider the time as part of the conversion to the ISO string.\n *\n * @returns an ISO 8601 formatted date, optionally with the time as well.\n */\n public static dateToIso(date: Date, time = false): string {\n const dateString = date.toISOString();\n return time ? dateString : dateString.split('T')[0];\n }\n\n /**\n * Convert the params received into an ISO 8601 formatted string with only date in it.\n *\n * @param day The number of the day to be used.\n * @param month The number of the month to be used.\n * @param year The number of the year to be used.\n *\n * @returns an ISO 8601 formatted date for the given parameters.\n */\n public static dmyToIso(day: number, month: number, year: number): string {\n return `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day}`;\n }\n\n /**\n * Returns the days of the week starting at Monday day name translated using the locale received as a first element.\n *\n * @param locale The locale for which to convert the date for display purposes, defaults to browser locale.\n * @param format The format of the returned values\n *\n * @returns an array with the days of the week named according to the locale received.\n */\n public static dowNames(locale?: string, format: 'long' | 'short' | 'narrow' = 'short'): Array<string> {\n const loc = locale || navigator.language;\n const date = new Date();\n\n const weekdays = [];\n while (!weekdays[date.getDay()]) {\n weekdays[date.getDay()] = date.toLocaleString(loc, { weekday: format });\n date.setDate(date.getDate() + 1);\n }\n\n const sunday = weekdays.shift();\n if (sunday) {\n weekdays.push(sunday);\n }\n\n return weekdays;\n }\n\n /**\n * Returns the months of the year starting at January month name translated using the locale received as a first element.\n *\n * @param locale The locale for which to convert the date for display purposes, defaults to browser locale.\n * @param format The format of the month names to return\n *\n * @returns an array with the month names of the year, all named according to the locale received.\n */\n public static monthNames(\n locale?: string,\n format: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow' = 'short',\n ): Array<string> {\n const loc = locale || navigator.language;\n\n return Array.from(Array(12).keys()).map((key) => {\n const date = new Date(2023, key, 15);\n return date.toLocaleString(loc, { month: format });\n });\n }\n\n /**\n * Collate & return the data required to drive the calendar popup in\n * <a href=\"/user-input/date-picker\">NeonDatePicker</a>.\n *\n * @param selectedDate ISO-8601 date-only string for the selected date.\n * @param currentPageMonth month of the current calendar page.\n * @param currentPageYear year of the current calendar page.\n * @param currentPageDecadeStart decade start year of the current calendar page.\n * @param locale user's locale.\n *\n * @returns The calendar configuration.\n */\n public static toCalendarConfiguration(\n selectedDate?: string,\n currentPageMonth?: number,\n currentPageYear?: number,\n currentPageDecadeStart?: number,\n locale?: string,\n ): NeonCalendarConfig {\n const loc = locale || navigator.language;\n const today = NeonDateUtils.stringToNeonDate(NeonDateUtils.dateToIso(new Date()), loc);\n const selected = selectedDate ? NeonDateUtils.stringToNeonDate(selectedDate, loc, true) : undefined;\n // month indexed from 1-12\n const pageMonth = currentPageMonth || today.month;\n\n // month indexed from 0-11\n const pageDate = currentPageMonth && currentPageYear ? new Date(currentPageYear, currentPageMonth - 1, 15) : null;\n const pageMonthName = pageDate?.toLocaleString(loc, { month: 'long' }) || today.monthLongName;\n const pageYear = currentPageYear || today.year;\n const pageDecadeStart = currentPageDecadeStart || Math.floor(pageYear / 10) * 10;\n\n // determine dow of first day of month. Months are indexed from 0 here\n const date = new Date(pageYear, (pageMonth + 11) % 12, 1);\n const offsetDate = new Date(pageYear, (pageMonth + 11) % 12, 1);\n offsetDate.setDate(offsetDate.getDate() - 1);\n\n const dates: Array<Array<number | null>> = [];\n\n let lastDayOfMonth = 1;\n let done = false;\n\n for (let row = 0; row < 6; row++) {\n dates[row] = [];\n\n for (let col = 0; col < 7; col++) {\n if (row === 0 && col < offsetDate.getDay()) {\n dates[row][col] = null;\n } else {\n dates[row][col] = date.getDate();\n lastDayOfMonth = date.getDate();\n date.setDate(date.getDate() + 1);\n\n if (date.getDate() === 1) {\n for (let i = col + 1; i < 7; i++) {\n dates[row][i] = null;\n }\n done = true;\n break;\n }\n }\n }\n\n if (done) {\n break;\n }\n }\n\n return {\n today,\n selected,\n pageMonth,\n pageMonthName,\n pageYear,\n pageDecadeStart,\n dowNames: NeonDateUtils.dowNames(loc),\n dowLongNames: NeonDateUtils.dowNames(loc, 'long'),\n dates,\n lastDayOfMonth,\n months: NeonDateUtils.monthNames(loc),\n monthLongNames: NeonDateUtils.monthNames(loc, 'long'),\n };\n }\n}\n"],"names":["NeonDateUtils","value","dayFormatted","monthShortName","seconds","year","time","timeShort","date","locale","strict","loc","now","timeZone","isUTC","dateObj","result","dateString","day","month","format","weekdays","sunday","key","selectedDate","currentPageMonth","currentPageYear","currentPageDecadeStart","today","selected","pageMonth","pageDate","pageMonthName","pageYear","pageDecadeStart","offsetDate","dates","lastDayOfMonth","done","row","col","i"],"mappings":"AAOO,MAAMA,EAAc;AAAA;AAAA;AAAA;AAAA;AAAA,EAKzB,OAAc,WAAWC,GAAa;AACpC,UAAM,EAAE,cAAAC,GAAc,gBAAAC,EAAA,IAAmBH,EAAc,iBAAiBC,EAAM,aAAa;AAC3F,WAAO,GAAGE,CAAc,IAAID,CAAY;AAAA,EAC1C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAc,6BAA6BD,GAAeG,IAAU,IAAO;AACzE,UAAM,EAAE,cAAAF,GAAc,gBAAAC,GAAgB,MAAAE,GAAM,MAAAC,GAAM,WAAAC,MAAcP,EAAc,iBAAiBC,CAAK;AACpG,WAAOG,IACH,GAAGF,CAAY,IAAIC,CAAc,IAAIE,CAAI,KAAKC,CAAI,KAClD,GAAGJ,CAAY,IAAIC,CAAc,IAAIE,CAAI,KAAKE,CAAS;AAAA,EAC7D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,OAAc,iBAAiBC,GAAcC,GAAiBC,IAAS,IAAiB;AACtF,UAAMC,IAAMF,KAAU,UAAU,UAC1BG,wBAAU,KAAA,GACVC,IAAW,KAAK,eAAA,EAAiB,kBAAkB,UACnDC,IAAQ,EAAEN,EAAK,MAAM,OAAO,KAAKA,EAAK,MAAM,qBAAqB,IACjEO,IAAU,oBAAI;AAAA,MAClB,CAACL,KAAUF,EAAK,WAAW,KAAK,GAAGA,CAAI,IAAII,EAAI,cAAc,MAAM,GAAG,EAAE,CAAC,CAAC,KAAKJ,KAAQM,IAAQ,MAAM;AAAA,IAAA;AAGvG,QAAIR;AACJ,IAAIE,EAAK,SAAS,OAChBF,IAAOS,EAAQ;AAAA,MACb;AAAA;AAAA,MACAP,EAAK,UAAU,KACX,EAAE,QAAQ,IAAO,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AACF;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aotearoan/neon",
3
3
  "description": "Neon is a lightweight design library of Vue 3 components with minimal dependencies.",
4
- "version": "27.0.0",
4
+ "version": "27.0.2",
5
5
  "main": "./dist/neon.cjs.js",
6
6
  "module": "./dist/neon.es.js",
7
7
  "types": "./dist/src/neon.d.ts",
@@ -7,7 +7,7 @@
7
7
  padding-bottom: calc(var(--neon-space-20) + var(--neon-height-mobile-menu) + var(--neon-border-width));
8
8
  gap: var(--neon-gutter);
9
9
  width: 100%;
10
- max-width: calc(100% - 2 * var(--neon-gutter));
10
+ max-width: 100%;
11
11
  flex: 1 0 auto;
12
12
 
13
13
  &.neon-page-container--with-sticky-buttons {
@@ -64,6 +64,7 @@
64
64
  .neon-page--left.neon-page--with-side-nav {
65
65
  @include responsive.responsive(larger-than-tablet) {
66
66
  .neon-page-container {
67
+ max-width: calc(100% - 2 * var(--neon-gutter));
67
68
  margin-left: var(--neon-gutter);
68
69
  margin-right: var(--neon-gutter);
69
70
  }