@aotearoan/neon 10.1.0 → 10.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/utils/NeonDateUtils.cjs.js +1 -1
- package/dist/common/utils/NeonDateUtils.cjs.js.map +1 -1
- package/dist/common/utils/NeonDateUtils.es.js +0 -3
- package/dist/common/utils/NeonDateUtils.es.js.map +1 -1
- package/dist/common/utils/NeonModeUtils.cjs.js +1 -1
- package/dist/common/utils/NeonModeUtils.cjs.js.map +1 -1
- package/dist/common/utils/NeonModeUtils.es.js +5 -2
- package/dist/common/utils/NeonModeUtils.es.js.map +1 -1
- package/dist/components/navigation/dropdown-menu/NeonDropdownMenu.ts_vue_type_script_src_6187a2a6_lang.cjs.js.map +1 -1
- package/dist/components/navigation/dropdown-menu/NeonDropdownMenu.ts_vue_type_script_src_6187a2a6_lang.es.js.map +1 -1
- package/dist/components/navigation/tree-menu/NeonTreeMenu.ts_vue_type_script_src_179b5200_lang.cjs.js +1 -1
- package/dist/components/navigation/tree-menu/NeonTreeMenu.ts_vue_type_script_src_179b5200_lang.cjs.js.map +1 -1
- package/dist/components/navigation/tree-menu/NeonTreeMenu.ts_vue_type_script_src_179b5200_lang.es.js +1 -1
- package/dist/components/navigation/tree-menu/NeonTreeMenu.ts_vue_type_script_src_179b5200_lang.es.js.map +1 -1
- package/dist/components/user-input/search/NeonSearch.cjs.js +1 -1
- package/dist/components/user-input/search/NeonSearch.es.js +3 -2
- package/dist/components/user-input/search/NeonSearch.es.js.map +1 -1
- package/dist/components/user-input/search/NeonSearch.ts_vue_type_script_src_0925a332_lang.cjs.js +2 -0
- package/dist/components/user-input/search/NeonSearch.ts_vue_type_script_src_0925a332_lang.cjs.js.map +1 -0
- package/dist/components/user-input/search/{NeonSearch.ts_vue_type_script_src_2630bb0d_lang.es.js → NeonSearch.ts_vue_type_script_src_0925a332_lang.es.js} +5 -3
- package/dist/components/user-input/search/NeonSearch.ts_vue_type_script_src_0925a332_lang.es.js.map +1 -0
- package/dist/components/user-input/select/NeonSelect.ts_vue_type_script_src_1f492752_lang.cjs.js +1 -1
- package/dist/components/user-input/select/NeonSelect.ts_vue_type_script_src_1f492752_lang.cjs.js.map +1 -1
- package/dist/components/user-input/select/NeonSelect.ts_vue_type_script_src_1f492752_lang.es.js +9 -3
- package/dist/components/user-input/select/NeonSelect.ts_vue_type_script_src_1f492752_lang.es.js.map +1 -1
- package/dist/src/common/utils/NeonModeUtils.d.ts +4 -3
- package/dist/src/components/user-input/search/NeonSearch.d.ts +16 -0
- package/dist/src/components/user-input/select/NeonSelect.d.ts +15 -0
- package/package.json +1 -1
- package/dist/components/user-input/search/NeonSearch.ts_vue_type_script_src_2630bb0d_lang.cjs.js +0 -2
- package/dist/components/user-input/search/NeonSearch.ts_vue_type_script_src_2630bb0d_lang.cjs.js.map +0 -1
- package/dist/components/user-input/search/NeonSearch.ts_vue_type_script_src_2630bb0d_lang.es.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class i{static stringToNeonDate(t,o,e=!1){const a=o||navigator.language,g=new Date,n=new Date(!e&&t.length===10?`${t}T${g.toISOString().split("T")[1]}`:t);let r;t.length>10&&(r=n.toLocaleString(a,t.length<=16?{hour12:!1,hour:"2-digit",minute:"2-digit"}:{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}));const u={year:+n.toLocaleString("en-US",{year:"numeric"}),yearFormatted:n.toLocaleString(a,{year:"numeric"}),month:+n.toLocaleString("en-US",{month:"numeric"}),monthShortName:n.toLocaleString(a,{month:"short"}),monthLongName:n.toLocaleString(a,{month:"long"}),day:+n.toLocaleString("en-US",{day:"numeric"}),dayFormatted:n.toLocaleString(a,{day:"2-digit"})};return r&&(u.time=r),u}static dateToIso(t,o=!1){const e=t.toISOString();return o?e:e.split("T")[0]}static dmyToIso(t,o,e){return`${e}-${o<10?"0"+o:o}-${t<10?"0"+t:t}`}static dowNames(t){const o=t||navigator.language,e=new Date,a=[];for(;!a[e.getDay()];)a[e.getDay()]=e.toLocaleString(o,{weekday:"short"}),e.setDate(e.getDate()+1);const g=a.shift();return g&&a.push(g),a}static monthNames(t){const o=t||navigator.language;return Array.from(Array(12).keys()).map(e=>new Date(2023,e,15).toLocaleString(o,{month:"short"}))}static toCalendarConfiguration(t,o,e,a,g){const n=g||navigator.language,r=i.stringToNeonDate(i.dateToIso(new Date),n),u=t?i.stringToNeonDate(t,n,!0):void 0,h=o||r.month,S=o&&e?new Date(e,o-1,15):null,L=(S==null?void 0:S.toLocaleString(n,{month:"long"}))||r.monthLongName,d=e||r.year,T=a||Math.floor(d/10)*10,c=new Date(d,(h+11)%12,1),f=new Date(d,(h+11)%12,1);f.setDate(f.getDate()-1);const m=[];let y=1,w=!1;for(let s=0;s<6;s++){m[s]=[];for(let l=0;l<7;l++)if(s===0&&l<f.getDay())m[s][l]=null;else if(m[s][l]=c.getDate(),y=c.getDate(),c.setDate(c.getDate()+1),c.getDate()===1){for(let D=l+1;D<7;D++)m[s][D]=null;w=!0;break}if(w)break}return{today:r,selected:u,pageMonth:h,pageMonthName:L,pageYear:d,pageDecadeStart:T,dowNames:i.dowNames(n),dates:m,lastDayOfMonth:y,months:i.monthNames(n)}}}exports.NeonDateUtils=i;
|
|
2
2
|
//# sourceMappingURL=NeonDateUtils.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeonDateUtils.cjs.js","sources":["../../../src/common/utils/NeonDateUtils.ts"],"sourcesContent":["import type { NeonCalendarConfig } from '@/common/models/NeonCalendarConfig';\nimport type { NeonDate } from '@/common/models/NeonDate';\n\nexport class NeonDateUtils {\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 * @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 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 loc,\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 }\n\n return result;\n }\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 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 public static dowNames(locale?: string): 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: 'short' });\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 public static monthNames(locale?: string): 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: 'short' });\n });\n }\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
|
|
1
|
+
{"version":3,"file":"NeonDateUtils.cjs.js","sources":["../../../src/common/utils/NeonDateUtils.ts"],"sourcesContent":["import type { NeonCalendarConfig } from '@/common/models/NeonCalendarConfig';\nimport type { NeonDate } from '@/common/models/NeonDate';\n\nexport class NeonDateUtils {\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 * @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 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 loc,\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 }\n\n return result;\n }\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 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 public static dowNames(locale?: string): 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: 'short' });\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 public static monthNames(locale?: string): 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: 'short' });\n });\n }\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 dates,\n lastDayOfMonth,\n months: NeonDateUtils.monthNames(loc),\n };\n }\n}\n"],"names":["NeonDateUtils","date","locale","strict","loc","now","dateObj","time","result","dateString","day","month","year","weekdays","sunday","key","selectedDate","currentPageMonth","currentPageYear","currentPageDecadeStart","today","selected","pageMonth","pageDate","pageMonthName","pageYear","pageDecadeStart","offsetDate","dates","lastDayOfMonth","done","row","col","i"],"mappings":"4GAGO,MAAMA,CAAc,CAOzB,OAAc,iBAAiBC,EAAcC,EAAiBC,EAAS,GAAiB,CAChF,MAAAC,EAAMF,GAAU,UAAU,SAC1BG,EAAM,IAAI,KACVC,EAAU,IAAI,KAAK,CAACH,GAAUF,EAAK,SAAW,GAAK,GAAGA,KAAQI,EAAI,YAAY,EAAE,MAAM,GAAG,EAAE,KAAOJ,CAAI,EACxG,IAAAM,EACAN,EAAK,OAAS,KAChBM,EAAOD,EAAQ,eACbF,EACAH,EAAK,QAAU,GACX,CAAE,OAAQ,GAAO,KAAM,UAAW,OAAQ,SAC1C,EAAA,CAAE,OAAQ,GAAO,KAAM,UAAW,OAAQ,UAAW,OAAQ,SAAU,CAAA,GAI/E,MAAMO,EAAmB,CACvB,KAAM,CAACF,EAAQ,eAAe,QAAS,CAAE,KAAM,UAAW,EAC1D,cAAeA,EAAQ,eAAeF,EAAK,CAAE,KAAM,UAAW,EAC9D,MAAO,CAACE,EAAQ,eAAe,QAAS,CAAE,MAAO,UAAW,EAC5D,eAAgBA,EAAQ,eAAeF,EAAK,CAAE,MAAO,QAAS,EAC9D,cAAeE,EAAQ,eAAeF,EAAK,CAAE,MAAO,OAAQ,EAC5D,IAAK,CAACE,EAAQ,eAAe,QAAS,CAAE,IAAK,UAAW,EACxD,aAAcA,EAAQ,eAAeF,EAAK,CAAE,IAAK,UAAW,CAAA,EAG9D,OAAIG,IACFC,EAAO,KAAOD,GAGTC,CACT,CAEA,OAAc,UAAUP,EAAYM,EAAO,GAAe,CAClD,MAAAE,EAAaR,EAAK,cACxB,OAAOM,EAAOE,EAAaA,EAAW,MAAM,GAAG,EAAE,EACnD,CAEA,OAAc,SAASC,EAAaC,EAAeC,EAAsB,CAChE,MAAA,GAAGA,KAAQD,EAAQ,GAAK,IAAMA,EAAQA,KAASD,EAAM,GAAK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3C,MAAMC,EAAqC,CAAA,EAE3C,IAAIC,EAAiB,EACjBC,EAAO,GAEX,QAASC,EAAM,EAAGA,EAAM,EAAGA,IAAO,CAChCH,EAAMG,GAAO,GAEb,QAASC,EAAM,EAAGA,EAAM,EAAGA,IACzB,GAAID,IAAQ,GAAKC,EAAML,EAAW,SAChCC,EAAMG,GAAKC,GAAO,aAEZJ,EAAAG,GAAKC,GAAO/B,EAAK,QAAQ,EAC/B4B,EAAiB5B,EAAK,UACtBA,EAAK,QAAQA,EAAK,QAAQ,EAAI,CAAC,EAE3BA,EAAK,QAAQ,IAAM,EAAG,CACxB,QAASgC,EAAID,EAAM,EAAGC,EAAI,EAAGA,IAC3BL,EAAMG,GAAKE,GAAK,KAEXH,EAAA,GACP,KACF,CAIJ,GAAIA,EACF,KAEJ,CAEO,MAAA,CACL,MAAAV,EACA,SAAAC,EACA,UAAAC,EACA,cAAAE,EACA,SAAAC,EACA,gBAAAC,EACA,SAAU1B,EAAc,SAASI,CAAG,EACpC,MAAAwB,EACA,eAAAC,EACA,OAAQ7B,EAAc,WAAWI,CAAG,CAAA,CAExC,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeonDateUtils.es.js","sources":["../../../src/common/utils/NeonDateUtils.ts"],"sourcesContent":["import type { NeonCalendarConfig } from '@/common/models/NeonCalendarConfig';\nimport type { NeonDate } from '@/common/models/NeonDate';\n\nexport class NeonDateUtils {\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 * @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 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 loc,\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 }\n\n return result;\n }\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 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 public static dowNames(locale?: string): 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: 'short' });\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 public static monthNames(locale?: string): 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: 'short' });\n });\n }\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
|
|
1
|
+
{"version":3,"file":"NeonDateUtils.es.js","sources":["../../../src/common/utils/NeonDateUtils.ts"],"sourcesContent":["import type { NeonCalendarConfig } from '@/common/models/NeonCalendarConfig';\nimport type { NeonDate } from '@/common/models/NeonDate';\n\nexport class NeonDateUtils {\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 * @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 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 loc,\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 }\n\n return result;\n }\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 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 public static dowNames(locale?: string): 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: 'short' });\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 public static monthNames(locale?: string): 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: 'short' });\n });\n }\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 dates,\n lastDayOfMonth,\n months: NeonDateUtils.monthNames(loc),\n };\n }\n}\n"],"names":[],"mappings":"AAGO,MAAM,cAAc;AAAA,EAOzB,OAAc,iBAAiB,MAAc,QAAiB,SAAS,OAAiB;AAChF,UAAA,MAAM,UAAU,UAAU;AAC1B,UAAA,MAAM,IAAI;AAChB,UAAM,UAAU,IAAI,KAAK,CAAC,UAAU,KAAK,WAAW,KAAK,GAAG,QAAQ,IAAI,YAAY,EAAE,MAAM,GAAG,EAAE,OAAO,IAAI;AACxG,QAAA;AACA,QAAA,KAAK,SAAS,IAAI;AACpB,aAAO,QAAQ;AAAA,QACb;AAAA,QACA,KAAK,UAAU,KAC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KAAK,OAAO;AAAA,QAAA,OACb;AACC,gBAAA,KAAK,OAAO,KAAK,QAAQ;AAC/B,2BAAiB,KAAK;AACtB,eAAK,QAAQ,KAAK,QAAQ,IAAI,CAAC;AAE3B,cAAA,KAAK,QAAQ,MAAM,GAAG;AACxB,qBAAS,IAAI,MAAM,GAAG,IAAI,GAAG,KAAK;AAChC,oBAAM,KAAK,KAAK;AAAA,YAClB;AACO,mBAAA;AACP;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAEA,UAAI,MAAM;AACR;AAAA,MACF;AAAA,IACF;AAEO,WAAA;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU,cAAc,SAAS,GAAG;AAAA,MACpC;AAAA,MACA;AAAA,MACA,QAAQ,cAAc,WAAW,GAAG;AAAA,IAAA;AAAA,EAExC;AACF;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var d=(o,a,t)=>a in o?i(o,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[a]=t;var r=(o,a,t)=>(d(o,typeof a!="symbol"?a+"":a,t),t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var c=require("../enums/NeonMode.cjs.js");const e=class{static getMode(){return e.mode}static getCallbacks(){return e.callbacks}static init(a){if(a)e.defaultMode=a,e.mode=e.defaultMode;else{const t=window.matchMedia("(prefers-color-scheme: dark)").matches,s=window.matchMedia("(prefers-color-scheme: light)").matches;t?e.mode=c.NeonMode.Dark:s?e.mode=c.NeonMode.Light:e.mode=e.defaultMode}}static addListener(a,t){window.matchMedia&&(Object.keys(e.callbacks).length===0&&(window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",e.onDarkChange),window.matchMedia("(prefers-color-scheme: light)").addEventListener("change",e.onLightChange),window.matchMedia("(prefers-color-scheme: no-preference)").addEventListener("change",e.onNoPreferenceChange)),e.callbacks[a]=t,t(e.mode||e.defaultMode))}static removeListener(a){delete e.callbacks[a],Object.keys(e.callbacks).length===0&&window.matchMedia&&(window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",e.onDarkChange),window.matchMedia("(prefers-color-scheme: light)").removeEventListener("change",e.onLightChange),window.matchMedia("(prefers-color-scheme: no-preference)").removeEventListener("change",e.onNoPreferenceChange))}static onDarkChange(a){e.onChange(a,c.NeonMode.Dark)}static onLightChange(a){e.onChange(a,c.NeonMode.Light)}static onNoPreferenceChange(a){e.onChange(a,e.defaultMode)}static onChange(a,t){a.matches&&e.handleChange(t)}static handleChange(a){Object.values(e.callbacks).forEach(t=>t(a))}};let n=e;r(n,"callbacks",{}),r(n,"defaultMode",c.NeonMode.Dark),r(n,"mode",null);exports.NeonModeUtils=n;
|
|
2
2
|
//# sourceMappingURL=NeonModeUtils.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeonModeUtils.cjs.js","sources":["../../../src/common/utils/NeonModeUtils.ts"],"sourcesContent":["import { NeonMode } from '../enums/NeonMode';\n\nexport class NeonModeUtils {\n private static callbacks: Record<string, (value: NeonMode) => void> = {};\n private static defaultMode: NeonMode = NeonMode.Dark;\n private static mode: NeonMode | null = null;\n\n public static getMode() {\n return NeonModeUtils.mode;\n }\n\n public static init(defaultMode?: NeonMode) {\n if (defaultMode) {\n NeonModeUtils.defaultMode = defaultMode;\n NeonModeUtils.mode = NeonModeUtils.defaultMode;\n } else {\n const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;\n const isLightMode = window.matchMedia('(prefers-color-scheme: light)').matches;\n\n if (isDarkMode) {\n NeonModeUtils.mode = NeonMode.Dark;\n } else if (isLightMode) {\n NeonModeUtils.mode = NeonMode.Light;\n } else {\n NeonModeUtils.mode = NeonModeUtils.defaultMode;\n }\n }\n }\n\n public static addListener(key: string, callback: (value: NeonMode) => void) {\n if (window.matchMedia) {\n if (Object.keys(NeonModeUtils.callbacks).length === 0
|
|
1
|
+
{"version":3,"file":"NeonModeUtils.cjs.js","sources":["../../../src/common/utils/NeonModeUtils.ts"],"sourcesContent":["import { NeonMode } from '../enums/NeonMode';\n\nexport class NeonModeUtils {\n private static callbacks: Record<string, (value: NeonMode) => void> = {};\n private static defaultMode: NeonMode = NeonMode.Dark;\n private static mode: NeonMode | null = null;\n\n public static getMode() {\n return NeonModeUtils.mode;\n }\n\n public static getCallbacks() {\n return NeonModeUtils.callbacks;\n }\n\n public static init(defaultMode?: NeonMode) {\n if (defaultMode) {\n NeonModeUtils.defaultMode = defaultMode;\n NeonModeUtils.mode = NeonModeUtils.defaultMode;\n } else {\n const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;\n const isLightMode = window.matchMedia('(prefers-color-scheme: light)').matches;\n\n if (isDarkMode) {\n NeonModeUtils.mode = NeonMode.Dark;\n } else if (isLightMode) {\n NeonModeUtils.mode = NeonMode.Light;\n } else {\n NeonModeUtils.mode = NeonModeUtils.defaultMode;\n }\n }\n }\n\n public static addListener(key: string, callback: (value: NeonMode) => void) {\n if (window.matchMedia) {\n if (Object.keys(NeonModeUtils.callbacks).length === 0) {\n window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', NeonModeUtils.onDarkChange);\n window.matchMedia('(prefers-color-scheme: light)').addEventListener('change', NeonModeUtils.onLightChange);\n window\n .matchMedia('(prefers-color-scheme: no-preference)')\n .addEventListener('change', NeonModeUtils.onNoPreferenceChange);\n }\n\n NeonModeUtils.callbacks[key] = callback;\n callback(NeonModeUtils.mode || NeonModeUtils.defaultMode);\n }\n }\n\n public static removeListener(key: string) {\n delete NeonModeUtils.callbacks[key];\n if (\n Object.keys(NeonModeUtils.callbacks).length === 0 &&\n window.matchMedia\n ) {\n window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', NeonModeUtils.onDarkChange);\n window.matchMedia('(prefers-color-scheme: light)').removeEventListener('change', NeonModeUtils.onLightChange);\n window\n .matchMedia('(prefers-color-scheme: no-preference)')\n .removeEventListener('change', NeonModeUtils.onNoPreferenceChange);\n }\n }\n\n static onDarkChange(e: MediaQueryListEvent) {\n NeonModeUtils.onChange(e, NeonMode.Dark);\n }\n\n static onLightChange(e: MediaQueryListEvent) {\n NeonModeUtils.onChange(e, NeonMode.Light);\n }\n\n static onNoPreferenceChange(e: MediaQueryListEvent) {\n NeonModeUtils.onChange(e, NeonModeUtils.defaultMode);\n }\n\n private static onChange(e: MediaQueryListEvent, value: NeonMode) {\n if (e.matches) {\n NeonModeUtils.handleChange(value);\n }\n }\n\n private static handleChange(value: NeonMode) {\n Object.values(NeonModeUtils.callbacks).forEach((cb) => cb(value));\n }\n}\n"],"names":["_NeonModeUtils","defaultMode","isDarkMode","isLightMode","NeonMode","key","callback","e","value","cb","NeonModeUtils","__publicField"],"mappings":"8TAEO,MAAMA,EAAN,KAAoB,CAKzB,OAAc,SAAU,CACtB,OAAOA,EAAc,IACvB,CAEA,OAAc,cAAe,CAC3B,OAAOA,EAAc,SACvB,CAEA,OAAc,KAAKC,EAAwB,CACzC,GAAIA,EACFD,EAAc,YAAcC,EAC5BD,EAAc,KAAOA,EAAc,gBAC9B,CACL,MAAME,EAAa,OAAO,WAAW,8BAA8B,EAAE,QAC/DC,EAAc,OAAO,WAAW,+BAA+B,EAAE,QAEnED,EACFF,EAAc,KAAOI,EAAS,SAAA,KACrBD,EACTH,EAAc,KAAOI,EAAS,SAAA,MAE9BJ,EAAc,KAAOA,EAAc,WAEvC,CACF,CAEA,OAAc,YAAYK,EAAaC,EAAqC,CACtE,OAAO,aACL,OAAO,KAAKN,EAAc,SAAS,EAAE,SAAW,IAClD,OAAO,WAAW,8BAA8B,EAAE,iBAAiB,SAAUA,EAAc,YAAY,EACvG,OAAO,WAAW,+BAA+B,EAAE,iBAAiB,SAAUA,EAAc,aAAa,EACzG,OACG,WAAW,uCAAuC,EAClD,iBAAiB,SAAUA,EAAc,oBAAoB,GAGlEA,EAAc,UAAUK,GAAOC,EACtBA,EAAAN,EAAc,MAAQA,EAAc,WAAW,EAE5D,CAEA,OAAc,eAAeK,EAAa,CACxC,OAAOL,EAAc,UAAUK,GAE7B,OAAO,KAAKL,EAAc,SAAS,EAAE,SAAW,GAChD,OAAO,aAEP,OAAO,WAAW,8BAA8B,EAAE,oBAAoB,SAAUA,EAAc,YAAY,EAC1G,OAAO,WAAW,+BAA+B,EAAE,oBAAoB,SAAUA,EAAc,aAAa,EAC5G,OACG,WAAW,uCAAuC,EAClD,oBAAoB,SAAUA,EAAc,oBAAoB,EAEvE,CAEA,OAAO,aAAaO,EAAwB,CAC5BP,EAAA,SAASO,EAAGH,EAAA,SAAS,IAAI,CACzC,CAEA,OAAO,cAAcG,EAAwB,CAC7BP,EAAA,SAASO,EAAGH,EAAA,SAAS,KAAK,CAC1C,CAEA,OAAO,qBAAqBG,EAAwB,CACpCP,EAAA,SAASO,EAAGP,EAAc,WAAW,CACrD,CAEA,OAAe,SAASO,EAAwBC,EAAiB,CAC3DD,EAAE,SACJP,EAAc,aAAaQ,CAAK,CAEpC,CAEA,OAAe,aAAaA,EAAiB,CACpC,OAAA,OAAOR,EAAc,SAAS,EAAE,QAASS,GAAOA,EAAGD,CAAK,CAAC,CAClE,CACF,EAjFO,IAAME,EAANV,EACLW,EADWD,EACI,YAAuD,CAAA,GACtEC,EAFWD,EAEI,cAAwBN,EAAS,SAAA,MAChDO,EAHWD,EAGI,OAAwB"}
|
|
@@ -9,6 +9,9 @@ const _NeonModeUtils = class {
|
|
|
9
9
|
static getMode() {
|
|
10
10
|
return _NeonModeUtils.mode;
|
|
11
11
|
}
|
|
12
|
+
static getCallbacks() {
|
|
13
|
+
return _NeonModeUtils.callbacks;
|
|
14
|
+
}
|
|
12
15
|
static init(defaultMode) {
|
|
13
16
|
if (defaultMode) {
|
|
14
17
|
_NeonModeUtils.defaultMode = defaultMode;
|
|
@@ -27,7 +30,7 @@ const _NeonModeUtils = class {
|
|
|
27
30
|
}
|
|
28
31
|
static addListener(key, callback) {
|
|
29
32
|
if (window.matchMedia) {
|
|
30
|
-
if (Object.keys(_NeonModeUtils.callbacks).length === 0
|
|
33
|
+
if (Object.keys(_NeonModeUtils.callbacks).length === 0) {
|
|
31
34
|
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", _NeonModeUtils.onDarkChange);
|
|
32
35
|
window.matchMedia("(prefers-color-scheme: light)").addEventListener("change", _NeonModeUtils.onLightChange);
|
|
33
36
|
window.matchMedia("(prefers-color-scheme: no-preference)").addEventListener("change", _NeonModeUtils.onNoPreferenceChange);
|
|
@@ -38,7 +41,7 @@ const _NeonModeUtils = class {
|
|
|
38
41
|
}
|
|
39
42
|
static removeListener(key) {
|
|
40
43
|
delete _NeonModeUtils.callbacks[key];
|
|
41
|
-
if (Object.keys(_NeonModeUtils.callbacks).length === 0 && window.matchMedia
|
|
44
|
+
if (Object.keys(_NeonModeUtils.callbacks).length === 0 && window.matchMedia) {
|
|
42
45
|
window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change", _NeonModeUtils.onDarkChange);
|
|
43
46
|
window.matchMedia("(prefers-color-scheme: light)").removeEventListener("change", _NeonModeUtils.onLightChange);
|
|
44
47
|
window.matchMedia("(prefers-color-scheme: no-preference)").removeEventListener("change", _NeonModeUtils.onNoPreferenceChange);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeonModeUtils.es.js","sources":["../../../src/common/utils/NeonModeUtils.ts"],"sourcesContent":["import { NeonMode } from '../enums/NeonMode';\n\nexport class NeonModeUtils {\n private static callbacks: Record<string, (value: NeonMode) => void> = {};\n private static defaultMode: NeonMode = NeonMode.Dark;\n private static mode: NeonMode | null = null;\n\n public static getMode() {\n return NeonModeUtils.mode;\n }\n\n public static init(defaultMode?: NeonMode) {\n if (defaultMode) {\n NeonModeUtils.defaultMode = defaultMode;\n NeonModeUtils.mode = NeonModeUtils.defaultMode;\n } else {\n const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;\n const isLightMode = window.matchMedia('(prefers-color-scheme: light)').matches;\n\n if (isDarkMode) {\n NeonModeUtils.mode = NeonMode.Dark;\n } else if (isLightMode) {\n NeonModeUtils.mode = NeonMode.Light;\n } else {\n NeonModeUtils.mode = NeonModeUtils.defaultMode;\n }\n }\n }\n\n public static addListener(key: string, callback: (value: NeonMode) => void) {\n if (window.matchMedia) {\n if (Object.keys(NeonModeUtils.callbacks).length === 0
|
|
1
|
+
{"version":3,"file":"NeonModeUtils.es.js","sources":["../../../src/common/utils/NeonModeUtils.ts"],"sourcesContent":["import { NeonMode } from '../enums/NeonMode';\n\nexport class NeonModeUtils {\n private static callbacks: Record<string, (value: NeonMode) => void> = {};\n private static defaultMode: NeonMode = NeonMode.Dark;\n private static mode: NeonMode | null = null;\n\n public static getMode() {\n return NeonModeUtils.mode;\n }\n\n public static getCallbacks() {\n return NeonModeUtils.callbacks;\n }\n\n public static init(defaultMode?: NeonMode) {\n if (defaultMode) {\n NeonModeUtils.defaultMode = defaultMode;\n NeonModeUtils.mode = NeonModeUtils.defaultMode;\n } else {\n const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;\n const isLightMode = window.matchMedia('(prefers-color-scheme: light)').matches;\n\n if (isDarkMode) {\n NeonModeUtils.mode = NeonMode.Dark;\n } else if (isLightMode) {\n NeonModeUtils.mode = NeonMode.Light;\n } else {\n NeonModeUtils.mode = NeonModeUtils.defaultMode;\n }\n }\n }\n\n public static addListener(key: string, callback: (value: NeonMode) => void) {\n if (window.matchMedia) {\n if (Object.keys(NeonModeUtils.callbacks).length === 0) {\n window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', NeonModeUtils.onDarkChange);\n window.matchMedia('(prefers-color-scheme: light)').addEventListener('change', NeonModeUtils.onLightChange);\n window\n .matchMedia('(prefers-color-scheme: no-preference)')\n .addEventListener('change', NeonModeUtils.onNoPreferenceChange);\n }\n\n NeonModeUtils.callbacks[key] = callback;\n callback(NeonModeUtils.mode || NeonModeUtils.defaultMode);\n }\n }\n\n public static removeListener(key: string) {\n delete NeonModeUtils.callbacks[key];\n if (\n Object.keys(NeonModeUtils.callbacks).length === 0 &&\n window.matchMedia\n ) {\n window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', NeonModeUtils.onDarkChange);\n window.matchMedia('(prefers-color-scheme: light)').removeEventListener('change', NeonModeUtils.onLightChange);\n window\n .matchMedia('(prefers-color-scheme: no-preference)')\n .removeEventListener('change', NeonModeUtils.onNoPreferenceChange);\n }\n }\n\n static onDarkChange(e: MediaQueryListEvent) {\n NeonModeUtils.onChange(e, NeonMode.Dark);\n }\n\n static onLightChange(e: MediaQueryListEvent) {\n NeonModeUtils.onChange(e, NeonMode.Light);\n }\n\n static onNoPreferenceChange(e: MediaQueryListEvent) {\n NeonModeUtils.onChange(e, NeonModeUtils.defaultMode);\n }\n\n private static onChange(e: MediaQueryListEvent, value: NeonMode) {\n if (e.matches) {\n NeonModeUtils.handleChange(value);\n }\n }\n\n private static handleChange(value: NeonMode) {\n Object.values(NeonModeUtils.callbacks).forEach((cb) => cb(value));\n }\n}\n"],"names":[],"mappings":";;;;;;;AAEO,MAAM,iBAAN,MAAoB;AAAA,EAKzB,OAAc,UAAU;AACtB,WAAO,eAAc;AAAA,EACvB;AAAA,EAEA,OAAc,eAAe;AAC3B,WAAO,eAAc;AAAA,EACvB;AAAA,EAEA,OAAc,KAAK,aAAwB;AACzC,QAAI,aAAa;AACf,qBAAc,cAAc;AAC5B,qBAAc,OAAO,eAAc;AAAA,IAAA,OAC9B;AACL,YAAM,aAAa,OAAO,WAAW,8BAA8B,EAAE;AACrE,YAAM,cAAc,OAAO,WAAW,+BAA+B,EAAE;AAEvE,UAAI,YAAY;AACd,uBAAc,OAAO,SAAS;AAAA,iBACrB,aAAa;AACtB,uBAAc,OAAO,SAAS;AAAA,MAAA,OACzB;AACL,uBAAc,OAAO,eAAc;AAAA,MACrC;AAAA,IACF;AAAA,EACF;AAAA,EAEA,OAAc,YAAY,KAAa,UAAqC;AAC1E,QAAI,OA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W,eAGI,QAAwB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeonDropdownMenu.ts_vue_type_script_src_6187a2a6_lang.cjs.js","sources":["../../../../src/components/navigation/dropdown-menu/NeonDropdownMenu.ts?vue&type=script&src=6187a2a6&lang.ts"],"sourcesContent":["import { defineComponent, onMounted, onUnmounted, ref, useAttrs, watch } from 'vue';\nimport type { NeonDropdownMenuItem } from '@/common/models/NeonDropdownMenuItem';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport NeonDropdown from '@/components/presentation/dropdown/NeonDropdown.vue';\nimport { NeonDropdownPlacement } from '@/common/enums/NeonDropdownPlacement';\nimport { NeonScrollUtils } from '@/common/utils/NeonScrollUtils';\nimport NeonIcon from '@/components/presentation/icon/NeonIcon.vue';\nimport NeonLink from '@/components/navigation/link/NeonLink.vue';\n\n/**\n * <p>A dropdown menu consisting of a button to open the menu and a list of menu items. Clicking on a menu item will\n * result in navigating to the provided URL or notifying the parent component via the @click event.</p>\n * <p><strong>Note:</strong> As well as the options described below, pass through attributes supported by\n * <a href=\"/presentation/dropdown\">NeonDropdown</a> to change the style of the dropdown button.</p>\n */\nexport default defineComponent({\n name: 'NeonDropdownMenu',\n components: {\n NeonDropdown,\n NeonIcon,\n NeonLink,\n },\n props: {\n /**\n * A list of menu items to render in the dropdown menu.\n */\n model: { type: Array as () => Array<NeonDropdownMenuItem>, required: true },\n /**\n * The size of the dropdown - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The dropdown color.\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n /**\n * Whether the dropdown button is disabled or not.\n */\n disabled: { type: Boolean, default: false },\n /**\n * Instead of opening on click (default), open on hover.\n */\n openOnHover: { type: Boolean, default: false },\n },\n emits: [\n /**\n * emitted when the user clicks on a menu item.\n * @type {NeonDropdownMenuItem} the menu item the user clicked on.\n */\n 'click',\n /**\n * emitted on initialisation\n * @type {HTMLElement} the reference to the HTMLElement for the dropdown menu button.\n */\n 'button-ref',\n ],\n setup(props, { emit }) {\n const attrs = useAttrs();\n const dropdown = ref<HTMLElement | null>(null);\n const dropdownPlacement = ref<NeonDropdownPlacement | null>(null);\n const items = ref<Array<HTMLLIElement>>([]);\n const open = ref(false);\n const highlightedKey = ref<string | null>(null);\n const highlightedIndex = ref(-1);\n\n const changeHighlighted = (key: string) => {\n highlightedKey.value = key;\n highlightedIndex.value = props.model.findIndex((item) => item.key === key);\n };\n\n const onPlacement = (placement: NeonDropdownPlacement) => {\n dropdownPlacement.value = placement;\n };\n\n const isReverse = () => {\n switch (dropdownPlacement.value) {\n case NeonDropdownPlacement.TopLeft:\n case NeonDropdownPlacement.TopRight:\n case NeonDropdownPlacement.LeftBottom:\n case NeonDropdownPlacement.RightBottom:\n return true;\n }\n\n return false;\n };\n\n const scrollOnNavigate = () => {\n const element = dropdown.value?.querySelector('.neon-dropdown-menu__item--highlighted') as HTMLElement;\n NeonScrollUtils.scrollIntoView(element);\n };\n\n const navigateBy = (offset: number, $event: KeyboardEvent) => {\n const newIndex = highlightedIndex.value + offset;\n if (newIndex >= 0 && newIndex <= props.model.length - 1) {\n highlightedIndex.value = newIndex;\n highlightedKey.value = props.model[highlightedIndex.value].key;\n $event.preventDefault();\n setTimeout(scrollOnNavigate);\n }\n };\n\n const keyboardHandler = ($event: KeyboardEvent) => {\n if (!props.disabled) {\n if (open.value) {\n switch ($event.code) {\n case 'ArrowUp':\n case 'ArrowDown'
|
|
1
|
+
{"version":3,"file":"NeonDropdownMenu.ts_vue_type_script_src_6187a2a6_lang.cjs.js","sources":["../../../../src/components/navigation/dropdown-menu/NeonDropdownMenu.ts?vue&type=script&src=6187a2a6&lang.ts"],"sourcesContent":["import { defineComponent, onMounted, onUnmounted, ref, useAttrs, watch } from 'vue';\nimport type { NeonDropdownMenuItem } from '@/common/models/NeonDropdownMenuItem';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport NeonDropdown from '@/components/presentation/dropdown/NeonDropdown.vue';\nimport { NeonDropdownPlacement } from '@/common/enums/NeonDropdownPlacement';\nimport { NeonScrollUtils } from '@/common/utils/NeonScrollUtils';\nimport NeonIcon from '@/components/presentation/icon/NeonIcon.vue';\nimport NeonLink from '@/components/navigation/link/NeonLink.vue';\n\n/**\n * <p>A dropdown menu consisting of a button to open the menu and a list of menu items. Clicking on a menu item will\n * result in navigating to the provided URL or notifying the parent component via the @click event.</p>\n * <p><strong>Note:</strong> As well as the options described below, pass through attributes supported by\n * <a href=\"/presentation/dropdown\">NeonDropdown</a> to change the style of the dropdown button.</p>\n */\nexport default defineComponent({\n name: 'NeonDropdownMenu',\n components: {\n NeonDropdown,\n NeonIcon,\n NeonLink,\n },\n props: {\n /**\n * A list of menu items to render in the dropdown menu.\n */\n model: { type: Array as () => Array<NeonDropdownMenuItem>, required: true },\n /**\n * The size of the dropdown - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The dropdown color.\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n /**\n * Whether the dropdown button is disabled or not.\n */\n disabled: { type: Boolean, default: false },\n /**\n * Instead of opening on click (default), open on hover.\n */\n openOnHover: { type: Boolean, default: false },\n },\n emits: [\n /**\n * emitted when the user clicks on a menu item.\n * @type {NeonDropdownMenuItem} the menu item the user clicked on.\n */\n 'click',\n /**\n * emitted on initialisation\n * @type {HTMLElement} the reference to the HTMLElement for the dropdown menu button.\n */\n 'button-ref',\n ],\n setup(props, { emit }) {\n const attrs = useAttrs();\n const dropdown = ref<HTMLElement | null>(null);\n const dropdownPlacement = ref<NeonDropdownPlacement | null>(null);\n const items = ref<Array<HTMLLIElement>>([]);\n const open = ref(false);\n const highlightedKey = ref<string | null>(null);\n const highlightedIndex = ref(-1);\n\n const changeHighlighted = (key: string) => {\n highlightedKey.value = key;\n highlightedIndex.value = props.model.findIndex((item) => item.key === key);\n };\n\n const onPlacement = (placement: NeonDropdownPlacement) => {\n dropdownPlacement.value = placement;\n };\n\n const isReverse = () => {\n switch (dropdownPlacement.value) {\n case NeonDropdownPlacement.TopLeft:\n case NeonDropdownPlacement.TopRight:\n case NeonDropdownPlacement.LeftBottom:\n case NeonDropdownPlacement.RightBottom:\n return true;\n }\n\n return false;\n };\n\n const scrollOnNavigate = () => {\n const element = dropdown.value?.querySelector('.neon-dropdown-menu__item--highlighted') as HTMLElement;\n NeonScrollUtils.scrollIntoView(element);\n };\n\n const navigateBy = (offset: number, $event: KeyboardEvent) => {\n const newIndex = highlightedIndex.value + offset;\n if (newIndex >= 0 && newIndex <= props.model.length - 1) {\n highlightedIndex.value = newIndex;\n highlightedKey.value = props.model[highlightedIndex.value].key;\n $event.preventDefault();\n setTimeout(scrollOnNavigate);\n }\n };\n\n const keyboardHandler = ($event: KeyboardEvent) => {\n if (!props.disabled) {\n if (open.value) {\n switch ($event.code) {\n case 'ArrowUp':\n case 'ArrowDown': {\n const reverseOffset = isReverse() ? -1 : 1;\n if ($event.code === 'ArrowUp') {\n navigateBy(-1 * reverseOffset, $event);\n } else {\n navigateBy(1 * reverseOffset, $event);\n }\n }\n break;\n case 'Enter':\n case 'Space':\n if (props.model[highlightedIndex.value] && !props.model[highlightedIndex.value].disabled) {\n clickItem(props.model[highlightedIndex.value]);\n $event.preventDefault();\n }\n break;\n case 'Tab':\n if (!$event.ctrlKey && !$event.metaKey && !$event.altKey) {\n open.value = false;\n }\n break;\n case 'Escape':\n open.value = false;\n break;\n }\n }\n }\n };\n\n const clickItem = (item: NeonDropdownMenuItem) => {\n if (!item.disabled) {\n if (item.href) {\n const anchor = items.value[highlightedIndex.value]?.firstElementChild as HTMLAnchorElement;\n anchor && anchor.click();\n } else {\n emit('click', item);\n }\n open.value = false;\n }\n };\n\n const onFocus = () => {\n if (props.openOnHover) {\n open.value = true;\n }\n };\n\n const onBlur = () => {\n if (props.openOnHover) {\n open.value = false;\n }\n };\n\n onMounted(() => {\n document.addEventListener('keydown', keyboardHandler);\n });\n\n onUnmounted(() => {\n document.removeEventListener('keydown', keyboardHandler);\n });\n\n watch(\n () => open.value,\n (open: boolean) => {\n if (open) {\n highlightedKey.value = props.model[0].key;\n highlightedIndex.value = 0;\n }\n },\n );\n\n return {\n dropdown,\n items,\n open,\n highlightedKey,\n highlightedIndex,\n attrs,\n emit,\n changeHighlighted,\n keyboardHandler,\n onBlur,\n onFocus,\n clickItem,\n navigateBy,\n onPlacement,\n };\n },\n});\n"],"names":["_sfc_main","defineComponent","NeonDropdown","NeonIcon","NeonLink","NeonSize","NeonFunctionalColor","props","emit","attrs","useAttrs","dropdown","ref","dropdownPlacement","items","open","highlightedKey","highlightedIndex","changeHighlighted","key","item","onPlacement","placement","isReverse","NeonDropdownPlacement","scrollOnNavigate","element","_a","NeonScrollUtils","navigateBy","offset","$event","newIndex","keyboardHandler","reverseOffset","clickItem","anchor","onFocus","onBlur","onMounted","onUnmounted","watch"],"mappings":"oaAgBAA,EAAeC,kBAAgB,CAC7B,KAAM,mBACN,WAAY,CACV,aAAAC,EACA,SAAAC,EACA,SAAAC,CACF,EACA,MAAO,CAIL,MAAO,CAAE,KAAM,MAA4C,SAAU,EAAK,EAI1E,KAAM,CAAE,KAAM,OAA0B,QAASC,EAAAA,SAAS,MAAO,EAIjE,MAAO,CAAE,KAAM,OAAqC,QAASC,EAAAA,oBAAoB,WAAY,EAI7F,SAAU,CAAE,KAAM,QAAS,QAAS,EAAM,EAI1C,YAAa,CAAE,KAAM,QAAS,QAAS,EAAM,CAC/C,EACA,MAAO,CAKL,QAKA,YACF,EACA,MAAMC,EAAO,CAAE,KAAAC,GAAQ,CACrB,MAAMC,EAAQC,EAAAA,WACRC,EAAWC,MAAwB,IAAI,EACvCC,EAAoBD,MAAkC,IAAI,EAC1DE,EAAQF,MAA0B,CAAA,CAAE,EACpCG,EAAOH,MAA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,SACHA,EAAK,MAAQ,GACb,MAGR,EAGIoB,EAAaf,GAA+B,OAC5C,GAAA,CAACA,EAAK,SAAU,CAClB,GAAIA,EAAK,KAAM,CACb,MAAMgB,GAAST,EAAAb,EAAM,MAAMG,EAAiB,SAA7B,YAAAU,EAAqC,kBACpDS,GAAUA,EAAO,OAAM,MAEvB5B,EAAK,QAASY,CAAI,EAEpBL,EAAK,MAAQ,EACf,CAAA,EAGIsB,EAAU,IAAM,CAChB9B,EAAM,cACRQ,EAAK,MAAQ,GACf,EAGIuB,EAAS,IAAM,CACf/B,EAAM,cACRQ,EAAK,MAAQ,GACf,EAGFwB,OAAAA,EAAAA,UAAU,IAAM,CACL,SAAA,iBAAiB,UAAWN,CAAe,CAAA,CACrD,EAEDO,EAAAA,YAAY,IAAM,CACP,SAAA,oBAAoB,UAAWP,CAAe,CAAA,CACxD,EAEDQ,EAAA,MACE,IAAM1B,EAAK,MACVA,GAAkB,CACbA,IACaC,EAAA,MAAQT,EAAM,MAAM,GAAG,IACtCU,EAAiB,MAAQ,EAE7B,CAAA,EAGK,CACL,SAAAN,EACA,MAAAG,EACA,KAAAC,EACA,eAAAC,EACA,iBAAAC,EACA,MAAAR,EACA,KAAAD,EACA,kBAAAU,EACA,gBAAAe,EACA,OAAAK,EACA,QAAAD,EACA,UAAAF,EACA,WAAAN,EACA,YAAAR,CAAA,CAEJ,CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeonDropdownMenu.ts_vue_type_script_src_6187a2a6_lang.es.js","sources":["../../../../src/components/navigation/dropdown-menu/NeonDropdownMenu.ts?vue&type=script&src=6187a2a6&lang.ts"],"sourcesContent":["import { defineComponent, onMounted, onUnmounted, ref, useAttrs, watch } from 'vue';\nimport type { NeonDropdownMenuItem } from '@/common/models/NeonDropdownMenuItem';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport NeonDropdown from '@/components/presentation/dropdown/NeonDropdown.vue';\nimport { NeonDropdownPlacement } from '@/common/enums/NeonDropdownPlacement';\nimport { NeonScrollUtils } from '@/common/utils/NeonScrollUtils';\nimport NeonIcon from '@/components/presentation/icon/NeonIcon.vue';\nimport NeonLink from '@/components/navigation/link/NeonLink.vue';\n\n/**\n * <p>A dropdown menu consisting of a button to open the menu and a list of menu items. Clicking on a menu item will\n * result in navigating to the provided URL or notifying the parent component via the @click event.</p>\n * <p><strong>Note:</strong> As well as the options described below, pass through attributes supported by\n * <a href=\"/presentation/dropdown\">NeonDropdown</a> to change the style of the dropdown button.</p>\n */\nexport default defineComponent({\n name: 'NeonDropdownMenu',\n components: {\n NeonDropdown,\n NeonIcon,\n NeonLink,\n },\n props: {\n /**\n * A list of menu items to render in the dropdown menu.\n */\n model: { type: Array as () => Array<NeonDropdownMenuItem>, required: true },\n /**\n * The size of the dropdown - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The dropdown color.\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n /**\n * Whether the dropdown button is disabled or not.\n */\n disabled: { type: Boolean, default: false },\n /**\n * Instead of opening on click (default), open on hover.\n */\n openOnHover: { type: Boolean, default: false },\n },\n emits: [\n /**\n * emitted when the user clicks on a menu item.\n * @type {NeonDropdownMenuItem} the menu item the user clicked on.\n */\n 'click',\n /**\n * emitted on initialisation\n * @type {HTMLElement} the reference to the HTMLElement for the dropdown menu button.\n */\n 'button-ref',\n ],\n setup(props, { emit }) {\n const attrs = useAttrs();\n const dropdown = ref<HTMLElement | null>(null);\n const dropdownPlacement = ref<NeonDropdownPlacement | null>(null);\n const items = ref<Array<HTMLLIElement>>([]);\n const open = ref(false);\n const highlightedKey = ref<string | null>(null);\n const highlightedIndex = ref(-1);\n\n const changeHighlighted = (key: string) => {\n highlightedKey.value = key;\n highlightedIndex.value = props.model.findIndex((item) => item.key === key);\n };\n\n const onPlacement = (placement: NeonDropdownPlacement) => {\n dropdownPlacement.value = placement;\n };\n\n const isReverse = () => {\n switch (dropdownPlacement.value) {\n case NeonDropdownPlacement.TopLeft:\n case NeonDropdownPlacement.TopRight:\n case NeonDropdownPlacement.LeftBottom:\n case NeonDropdownPlacement.RightBottom:\n return true;\n }\n\n return false;\n };\n\n const scrollOnNavigate = () => {\n const element = dropdown.value?.querySelector('.neon-dropdown-menu__item--highlighted') as HTMLElement;\n NeonScrollUtils.scrollIntoView(element);\n };\n\n const navigateBy = (offset: number, $event: KeyboardEvent) => {\n const newIndex = highlightedIndex.value + offset;\n if (newIndex >= 0 && newIndex <= props.model.length - 1) {\n highlightedIndex.value = newIndex;\n highlightedKey.value = props.model[highlightedIndex.value].key;\n $event.preventDefault();\n setTimeout(scrollOnNavigate);\n }\n };\n\n const keyboardHandler = ($event: KeyboardEvent) => {\n if (!props.disabled) {\n if (open.value) {\n switch ($event.code) {\n case 'ArrowUp':\n case 'ArrowDown'
|
|
1
|
+
{"version":3,"file":"NeonDropdownMenu.ts_vue_type_script_src_6187a2a6_lang.es.js","sources":["../../../../src/components/navigation/dropdown-menu/NeonDropdownMenu.ts?vue&type=script&src=6187a2a6&lang.ts"],"sourcesContent":["import { defineComponent, onMounted, onUnmounted, ref, useAttrs, watch } from 'vue';\nimport type { NeonDropdownMenuItem } from '@/common/models/NeonDropdownMenuItem';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport NeonDropdown from '@/components/presentation/dropdown/NeonDropdown.vue';\nimport { NeonDropdownPlacement } from '@/common/enums/NeonDropdownPlacement';\nimport { NeonScrollUtils } from '@/common/utils/NeonScrollUtils';\nimport NeonIcon from '@/components/presentation/icon/NeonIcon.vue';\nimport NeonLink from '@/components/navigation/link/NeonLink.vue';\n\n/**\n * <p>A dropdown menu consisting of a button to open the menu and a list of menu items. Clicking on a menu item will\n * result in navigating to the provided URL or notifying the parent component via the @click event.</p>\n * <p><strong>Note:</strong> As well as the options described below, pass through attributes supported by\n * <a href=\"/presentation/dropdown\">NeonDropdown</a> to change the style of the dropdown button.</p>\n */\nexport default defineComponent({\n name: 'NeonDropdownMenu',\n components: {\n NeonDropdown,\n NeonIcon,\n NeonLink,\n },\n props: {\n /**\n * A list of menu items to render in the dropdown menu.\n */\n model: { type: Array as () => Array<NeonDropdownMenuItem>, required: true },\n /**\n * The size of the dropdown - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The dropdown color.\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n /**\n * Whether the dropdown button is disabled or not.\n */\n disabled: { type: Boolean, default: false },\n /**\n * Instead of opening on click (default), open on hover.\n */\n openOnHover: { type: Boolean, default: false },\n },\n emits: [\n /**\n * emitted when the user clicks on a menu item.\n * @type {NeonDropdownMenuItem} the menu item the user clicked on.\n */\n 'click',\n /**\n * emitted on initialisation\n * @type {HTMLElement} the reference to the HTMLElement for the dropdown menu button.\n */\n 'button-ref',\n ],\n setup(props, { emit }) {\n const attrs = useAttrs();\n const dropdown = ref<HTMLElement | null>(null);\n const dropdownPlacement = ref<NeonDropdownPlacement | null>(null);\n const items = ref<Array<HTMLLIElement>>([]);\n const open = ref(false);\n const highlightedKey = ref<string | null>(null);\n const highlightedIndex = ref(-1);\n\n const changeHighlighted = (key: string) => {\n highlightedKey.value = key;\n highlightedIndex.value = props.model.findIndex((item) => item.key === key);\n };\n\n const onPlacement = (placement: NeonDropdownPlacement) => {\n dropdownPlacement.value = placement;\n };\n\n const isReverse = () => {\n switch (dropdownPlacement.value) {\n case NeonDropdownPlacement.TopLeft:\n case NeonDropdownPlacement.TopRight:\n case NeonDropdownPlacement.LeftBottom:\n case NeonDropdownPlacement.RightBottom:\n return true;\n }\n\n return false;\n };\n\n const scrollOnNavigate = () => {\n const element = dropdown.value?.querySelector('.neon-dropdown-menu__item--highlighted') as HTMLElement;\n NeonScrollUtils.scrollIntoView(element);\n };\n\n const navigateBy = (offset: number, $event: KeyboardEvent) => {\n const newIndex = highlightedIndex.value + offset;\n if (newIndex >= 0 && newIndex <= props.model.length - 1) {\n highlightedIndex.value = newIndex;\n highlightedKey.value = props.model[highlightedIndex.value].key;\n $event.preventDefault();\n setTimeout(scrollOnNavigate);\n }\n };\n\n const keyboardHandler = ($event: KeyboardEvent) => {\n if (!props.disabled) {\n if (open.value) {\n switch ($event.code) {\n case 'ArrowUp':\n case 'ArrowDown': {\n const reverseOffset = isReverse() ? -1 : 1;\n if ($event.code === 'ArrowUp') {\n navigateBy(-1 * reverseOffset, $event);\n } else {\n navigateBy(1 * reverseOffset, $event);\n }\n }\n break;\n case 'Enter':\n case 'Space':\n if (props.model[highlightedIndex.value] && !props.model[highlightedIndex.value].disabled) {\n clickItem(props.model[highlightedIndex.value]);\n $event.preventDefault();\n }\n break;\n case 'Tab':\n if (!$event.ctrlKey && !$event.metaKey && !$event.altKey) {\n open.value = false;\n }\n break;\n case 'Escape':\n open.value = false;\n break;\n }\n }\n }\n };\n\n const clickItem = (item: NeonDropdownMenuItem) => {\n if (!item.disabled) {\n if (item.href) {\n const anchor = items.value[highlightedIndex.value]?.firstElementChild as HTMLAnchorElement;\n anchor && anchor.click();\n } else {\n emit('click', item);\n }\n open.value = false;\n }\n };\n\n const onFocus = () => {\n if (props.openOnHover) {\n open.value = true;\n }\n };\n\n const onBlur = () => {\n if (props.openOnHover) {\n open.value = false;\n }\n };\n\n onMounted(() => {\n document.addEventListener('keydown', keyboardHandler);\n });\n\n onUnmounted(() => {\n document.removeEventListener('keydown', keyboardHandler);\n });\n\n watch(\n () => open.value,\n (open: boolean) => {\n if (open) {\n highlightedKey.value = props.model[0].key;\n highlightedIndex.value = 0;\n }\n },\n );\n\n return {\n dropdown,\n items,\n open,\n highlightedKey,\n highlightedIndex,\n attrs,\n emit,\n changeHighlighted,\n keyboardHandler,\n onBlur,\n onFocus,\n clickItem,\n navigateBy,\n onPlacement,\n };\n },\n});\n"],"names":["open"],"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B,aAAK,QAAQ;AAAA,MACf;AAAA,IAAA;AAGF,UAAM,SAAS,MAAM;AACnB,UAAI,MAAM,aAAa;AACrB,aAAK,QAAQ;AAAA,MACf;AAAA,IAAA;AAGF,cAAU,MAAM;AACL,eAAA,iBAAiB,WAAW,eAAe;AAAA,IAAA,CACrD;AAED,gBAAY,MAAM;AACP,eAAA,oBAAoB,WAAW,eAAe;AAAA,IAAA,CACxD;AAED;AAAA,MACE,MAAM,KAAK;AAAA,MACX,CAACA,UAAkB;AACjB,YAAIA,OAAM;AACO,yBAAA,QAAQ,MAAM,MAAM,GAAG;AACtC,2BAAiB,QAAQ;AAAA,QAC3B;AAAA,MACF;AAAA,IAAA;AAGK,WAAA;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AACF,CAAC;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var r=require("vue"),i=require("../link/NeonLink.cjs.js"),l=require("vue-router"),p=r.defineComponent({name:"NeonTreeMenu",components:{NeonLink:i},props:{model:{type:Array,required:!0},expandAll:{type:Boolean,default:!1}},emits:["click"],setup(m,{emit:o}){const u=l.useRoute(),t=r.ref(null),a=e=>{const n=e.target;n.parentElement&&n.parentElement.click()},c=e=>{o("click",e)},s=e=>e.toLowerCase().replace(/\s/g,"-");return r.watch(()=>u.path,e=>t.value=e,{immediate:!0}),{url:t,click:a,onClick:c,fragment:s}}});module.exports=p;
|
|
2
2
|
//# sourceMappingURL=NeonTreeMenu.ts_vue_type_script_src_179b5200_lang.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeonTreeMenu.ts_vue_type_script_src_179b5200_lang.cjs.js","sources":["../../../../src/components/navigation/tree-menu/NeonTreeMenu.ts?vue&type=script&src=179b5200&lang.ts"],"sourcesContent":["import { defineComponent, ref, watch } from 'vue';\nimport type { NeonTreeMenuSectionModel } from '@/common/models/NeonTreeMenuSectionModel';\nimport NeonLink from '../link/NeonLink.vue';\nimport { useRoute } from 'vue-router';\n\n/**\n * Three level tree menu. This is useful for displaying a hierarchical navigation in NeonSideNav.The top level of the\n * menu is expandable on click but will not navigate to a page. The second level is links to pages and the third level\n * is the fragments on that page.\n */\nexport default defineComponent({\n name: 'NeonTreeMenu',\n components: {\n NeonLink,\n },\n props: {\n /**\n * The tree model defining the menu.\n */\n model: { type: Array as () => Array<NeonTreeMenuSectionModel>, required: true },\n /**\n * Expand all nodes in the tree, this is useful for providing filtering (e.g. the Neon showcase side navigation menu).\n */\n expandAll: { type: Boolean, default: false },\n },\n emits: [\n /**\n * Emitted when the user clicks on a menu item\n * @type {string} the key of the clicked on menu item.\n */\n 'click',\n ],\n setup(props, { emit }) {\n const route = useRoute();\n const url = ref<string | null>(null);\n\n const click = ($event: KeyboardEvent) => {\n const target = $event.target as HTMLSpanElement;\n if (target
|
|
1
|
+
{"version":3,"file":"NeonTreeMenu.ts_vue_type_script_src_179b5200_lang.cjs.js","sources":["../../../../src/components/navigation/tree-menu/NeonTreeMenu.ts?vue&type=script&src=179b5200&lang.ts"],"sourcesContent":["import { defineComponent, ref, watch } from 'vue';\nimport type { NeonTreeMenuSectionModel } from '@/common/models/NeonTreeMenuSectionModel';\nimport NeonLink from '../link/NeonLink.vue';\nimport { useRoute } from 'vue-router';\n\n/**\n * Three level tree menu. This is useful for displaying a hierarchical navigation in NeonSideNav.The top level of the\n * menu is expandable on click but will not navigate to a page. The second level is links to pages and the third level\n * is the fragments on that page.\n */\nexport default defineComponent({\n name: 'NeonTreeMenu',\n components: {\n NeonLink,\n },\n props: {\n /**\n * The tree model defining the menu.\n */\n model: { type: Array as () => Array<NeonTreeMenuSectionModel>, required: true },\n /**\n * Expand all nodes in the tree, this is useful for providing filtering (e.g. the Neon showcase side navigation menu).\n */\n expandAll: { type: Boolean, default: false },\n },\n emits: [\n /**\n * Emitted when the user clicks on a menu item\n * @type {string} the key of the clicked on menu item.\n */\n 'click',\n ],\n setup(props, { emit }) {\n const route = useRoute();\n const url = ref<string | null>(null);\n\n const click = ($event: KeyboardEvent) => {\n const target = $event.target as HTMLSpanElement;\n if (target.parentElement) {\n target.parentElement.click();\n }\n };\n\n const onClick = (key: string) => {\n emit('click', key);\n };\n\n const fragment = (anchor: string) => {\n return anchor.toLowerCase().replace(/\\s/g, '-');\n };\n\n watch(\n () => route.path,\n (value) => (url.value = value),\n { immediate: true },\n );\n\n return {\n url,\n click,\n onClick,\n fragment,\n };\n },\n});\n"],"names":["_sfc_main","defineComponent","NeonLink","props","emit","route","useRoute","url","ref","click","$event","target","onClick","key","fragment","anchor","watch","value"],"mappings":"+FAUAA,EAAeC,kBAAgB,CAC7B,KAAM,eACN,WAAY,CACV,SAAAC,CACF,EACA,MAAO,CAIL,MAAO,CAAE,KAAM,MAAgD,SAAU,EAAK,EAI9E,UAAW,CAAE,KAAM,QAAS,QAAS,EAAM,CAC7C,EACA,MAAO,CAKL,OACF,EACA,MAAMC,EAAO,CAAE,KAAAC,GAAQ,CACrB,MAAMC,EAAQC,EAAAA,WACRC,EAAMC,MAAmB,IAAI,EAE7BC,EAASC,GAA0B,CACvC,MAAMC,EAASD,EAAO,OAClBC,EAAO,eACTA,EAAO,cAAc,OACvB,EAGIC,EAAWC,GAAgB,CAC/BT,EAAK,QAASS,CAAG,CAAA,EAGbC,EAAYC,GACTA,EAAO,YAAc,EAAA,QAAQ,MAAO,GAAG,EAGhDC,OAAAA,EAAA,MACE,IAAMX,EAAM,KACXY,GAAWV,EAAI,MAAQU,EACxB,CAAE,UAAW,EAAK,CAAA,EAGb,CACL,IAAAV,EACA,MAAAE,EACA,QAAAG,EACA,SAAAE,CAAA,CAEJ,CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeonTreeMenu.ts_vue_type_script_src_179b5200_lang.es.js","sources":["../../../../src/components/navigation/tree-menu/NeonTreeMenu.ts?vue&type=script&src=179b5200&lang.ts"],"sourcesContent":["import { defineComponent, ref, watch } from 'vue';\nimport type { NeonTreeMenuSectionModel } from '@/common/models/NeonTreeMenuSectionModel';\nimport NeonLink from '../link/NeonLink.vue';\nimport { useRoute } from 'vue-router';\n\n/**\n * Three level tree menu. This is useful for displaying a hierarchical navigation in NeonSideNav.The top level of the\n * menu is expandable on click but will not navigate to a page. The second level is links to pages and the third level\n * is the fragments on that page.\n */\nexport default defineComponent({\n name: 'NeonTreeMenu',\n components: {\n NeonLink,\n },\n props: {\n /**\n * The tree model defining the menu.\n */\n model: { type: Array as () => Array<NeonTreeMenuSectionModel>, required: true },\n /**\n * Expand all nodes in the tree, this is useful for providing filtering (e.g. the Neon showcase side navigation menu).\n */\n expandAll: { type: Boolean, default: false },\n },\n emits: [\n /**\n * Emitted when the user clicks on a menu item\n * @type {string} the key of the clicked on menu item.\n */\n 'click',\n ],\n setup(props, { emit }) {\n const route = useRoute();\n const url = ref<string | null>(null);\n\n const click = ($event: KeyboardEvent) => {\n const target = $event.target as HTMLSpanElement;\n if (target
|
|
1
|
+
{"version":3,"file":"NeonTreeMenu.ts_vue_type_script_src_179b5200_lang.es.js","sources":["../../../../src/components/navigation/tree-menu/NeonTreeMenu.ts?vue&type=script&src=179b5200&lang.ts"],"sourcesContent":["import { defineComponent, ref, watch } from 'vue';\nimport type { NeonTreeMenuSectionModel } from '@/common/models/NeonTreeMenuSectionModel';\nimport NeonLink from '../link/NeonLink.vue';\nimport { useRoute } from 'vue-router';\n\n/**\n * Three level tree menu. This is useful for displaying a hierarchical navigation in NeonSideNav.The top level of the\n * menu is expandable on click but will not navigate to a page. The second level is links to pages and the third level\n * is the fragments on that page.\n */\nexport default defineComponent({\n name: 'NeonTreeMenu',\n components: {\n NeonLink,\n },\n props: {\n /**\n * The tree model defining the menu.\n */\n model: { type: Array as () => Array<NeonTreeMenuSectionModel>, required: true },\n /**\n * Expand all nodes in the tree, this is useful for providing filtering (e.g. the Neon showcase side navigation menu).\n */\n expandAll: { type: Boolean, default: false },\n },\n emits: [\n /**\n * Emitted when the user clicks on a menu item\n * @type {string} the key of the clicked on menu item.\n */\n 'click',\n ],\n setup(props, { emit }) {\n const route = useRoute();\n const url = ref<string | null>(null);\n\n const click = ($event: KeyboardEvent) => {\n const target = $event.target as HTMLSpanElement;\n if (target.parentElement) {\n target.parentElement.click();\n }\n };\n\n const onClick = (key: string) => {\n emit('click', key);\n };\n\n const fragment = (anchor: string) => {\n return anchor.toLowerCase().replace(/\\s/g, '-');\n };\n\n watch(\n () => route.path,\n (value) => (url.value = value),\n { immediate: true },\n );\n\n return {\n url,\n click,\n onClick,\n fragment,\n };\n },\n});\n"],"names":[],"mappings":";;;AAUA,IAAA,YAAe,gBAAgB;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY;AAAA,IACV;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IAIL,OAAO,EAAE,MAAM,OAAgD,UAAU,KAAK;AAAA,IAI9E,WAAW,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,EAC7C;AAAA,EACA,OAAO;AAAA,IAKL;AAAA,EACF;AAAA,EACA,MAAM,OAAO,EAAE,QAAQ;AACrB,UAAM,QAAQ;AACR,UAAA,MAAM,IAAmB,IAAI;AAE7B,UAAA,QAAQ,CAAC,WAA0B;AACvC,YAAM,SAAS,OAAO;AACtB,UAAI,OAAO,eAAe;AACxB,eAAO,cAAc;MACvB;AAAA,IAAA;AAGI,UAAA,UAAU,CAAC,QAAgB;AAC/B,WAAK,SAAS,GAAG;AAAA,IAAA;AAGb,UAAA,WAAW,CAAC,WAAmB;AACnC,aAAO,OAAO,YAAc,EAAA,QAAQ,OAAO,GAAG;AAAA,IAAA;AAGhD;AAAA,MACE,MAAM,MAAM;AAAA,MACZ,CAAC,UAAW,IAAI,QAAQ;AAAA,MACxB,EAAE,WAAW,KAAK;AAAA,IAAA;AAGb,WAAA;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AACF,CAAC;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var d=require("./NeonSearch.
|
|
1
|
+
"use strict";var d=require("./NeonSearch.ts_vue_type_script_src_0925a332_lang.cjs.js"),o=require("vue"),c=require("../../../_virtual/plugin-vue_export-helper.cjs.js");const p={class:"neon-search__wrapper"},u={class:"no-style neon-search__options"},m=["id","onClick","onMouseover"],h={class:"neon-search__option-container"},b={class:"neon-search__option-label"};function v(e,l,_,V,g,C){const r=o.resolveComponent("neon-icon"),s=o.resolveComponent("neon-chip"),i=o.resolveComponent("neon-input"),t=o.resolveComponent("neon-dropdown");return o.openBlock(),o.createElementBlock("div",p,[o.createVNode(t,o.mergeProps({ref:"dropdown",modelValue:e.open,"onUpdate:modelValue":l[2]||(l[2]=n=>e.open=n),"aria-activedescendant":e.multiple?e.modelValue[0]&&e.modelValue[0].key:e.modelValue,"aria-multiselectable":e.multiple,class:[[`neon-search--${e.color}`,{"neon-search--multiple":e.multiple,"neon-search--disabled":e.disabled,"neon-search--empty":e.computedOptions.length===0}],"neon-search"],color:e.color,disabled:e.disabled,placement:e.dropdownPlacement,size:e.size,role:"listbox"},e.sanitizedAttributes,{onDropdownPlacement:e.onPlacement}),{"dropdown-button":o.withCtx(()=>[o.createElementVNode("div",{ref:"dropdownButton",class:o.normalizeClass([[`neon-search__container--${e.size}`,`neon-search__container--${e.color}`,{"neon-search__container--disabled":e.disabled}],"neon-search__container"])},[o.createVNode(r,{disabled:e.disabled,class:"neon-search__search-icon",color:"low-contrast",name:"search"},null,8,["disabled"]),e.multiple?(o.openBlock(!0),o.createElementBlock(o.Fragment,{key:0},o.renderList(e.modelValue,(n,a)=>(o.openBlock(),o.createBlock(s,{id:n.key,key:n.key,class:o.normalizeClass({"neon-chip--last-chip":a===e.modelValue.length-1}),color:n.chipColor,disabled:e.disabled,label:n.label,size:e.size,action:"remove","aria-selected":"true",role:"option",onClose:y=>e.removeSelected(n)},null,8,["id","class","color","disabled","label","size","onClose"]))),128)):o.createCommentVNode("",!0),o.createVNode(i,o.mergeProps({disabled:e.disabled,modelValue:e.filter,placeholder:e.placeholder,size:e.size,class:"neon-search__input"},e.sanitizedAttributes,{onFocus:l[0]||(l[0]=n=>e.showOptions()),"onUpdate:modelValue":e.onFilterChange,onIconClick:l[1]||(l[1]=n=>e.onFilterChange(""))}),null,16,["disabled","modelValue","placeholder","size","onUpdate:modelValue"])],2)]),default:o.withCtx(()=>[o.createElementVNode("ul",u,[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(e.computedOptions,n=>(o.openBlock(),o.createElementBlock("li",{id:n.key,key:n.key,class:o.normalizeClass([[{"neon-search__option--separator-before":n.separatorBefore,"neon-search__option--highlighted":n.key===e.highlightedKey},`neon-search__option--${e.size}`],"neon-search__option"]),"aria-selected":"false",role:"option",onClick:a=>e.clickOption(n),onMouseover:a=>e.changeHighlighted(n.key)},[o.createElementVNode("div",h,[o.renderSlot(e.$slots,"option",{option:n},()=>[n.icon?(o.openBlock(),o.createBlock(r,{key:0,name:n.icon,class:"neon-search__option-icon"},null,8,["name"])):o.createCommentVNode("",!0),o.createElementVNode("span",b,o.toDisplayString(n.label),1)])])],42,m))),128))])]),_:3},16,["modelValue","aria-activedescendant","aria-multiselectable","class","color","disabled","placement","size","onDropdownPlacement"])])}var k=c(d,[["render",v]]);module.exports=k;
|
|
2
2
|
//# sourceMappingURL=NeonSearch.cjs.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _sfc_main from "./NeonSearch.
|
|
1
|
+
import _sfc_main from "./NeonSearch.ts_vue_type_script_src_0925a332_lang.es.js";
|
|
2
2
|
import { resolveComponent, openBlock, createElementBlock, createVNode, mergeProps, withCtx, createElementVNode, normalizeClass, Fragment, renderList, createBlock, createCommentVNode, renderSlot, toDisplayString } from "vue";
|
|
3
3
|
import _export_sfc from "../../../_virtual/plugin-vue_export-helper.es.js";
|
|
4
4
|
const _hoisted_1 = { class: "neon-search__wrapper" };
|
|
@@ -28,6 +28,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
28
28
|
], "neon-search"],
|
|
29
29
|
color: _ctx.color,
|
|
30
30
|
disabled: _ctx.disabled,
|
|
31
|
+
placement: _ctx.dropdownPlacement,
|
|
31
32
|
size: _ctx.size,
|
|
32
33
|
role: "listbox"
|
|
33
34
|
}, _ctx.sanitizedAttributes, { onDropdownPlacement: _ctx.onPlacement }), {
|
|
@@ -107,7 +108,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
107
108
|
])
|
|
108
109
|
]),
|
|
109
110
|
_: 3
|
|
110
|
-
}, 16, ["modelValue", "aria-activedescendant", "aria-multiselectable", "class", "color", "disabled", "size", "onDropdownPlacement"])
|
|
111
|
+
}, 16, ["modelValue", "aria-activedescendant", "aria-multiselectable", "class", "color", "disabled", "placement", "size", "onDropdownPlacement"])
|
|
111
112
|
]);
|
|
112
113
|
}
|
|
113
114
|
var NeonSearch = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeonSearch.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NeonSearch.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/components/user-input/search/NeonSearch.ts_vue_type_script_src_0925a332_lang.cjs.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var o=require("vue"),C=require("../../../common/enums/NeonSize.cjs.js"),P=require("../../../common/enums/NeonFunctionalColor.cjs.js"),A=require("../../presentation/dropdown/NeonDropdown.cjs.js"),L=require("../../presentation/icon/NeonIcon.cjs.js"),x=require("../input/NeonInput.cjs.js"),z=require("../chip/NeonChip.cjs.js"),i=require("../../../common/enums/NeonDropdownPlacement.cjs.js"),B=require("../../../common/utils/NeonScrollUtils.cjs.js"),U=o.defineComponent({name:"NeonSearch",components:{NeonChip:z,NeonDropdown:A,NeonIcon:L,NeonInput:x},props:{modelValue:{type:[String,Array],required:!0},placeholder:{type:String,required:!0},options:{type:Array,required:!0},multiple:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},size:{type:String,default:C.NeonSize.Medium},color:{type:String,default:P.NeonFunctionalColor.LowContrast},placement:{type:String,default:i.NeonDropdownPlacement.BottomLeft}},emits:["update:modelValue","filter-changed"],setup(t,{emit:p}){const N=o.useAttrs(),f=o.ref(null),u=o.ref(t.placement),a=o.ref(!1),s=o.ref(null),l=o.ref(-1),d=o.ref("");o.watch(()=>a.value,e=>{e&&t.options.length>0&&(s.value=t.options[0].key,l.value=0)});const w=()=>{switch(u.value){case i.NeonDropdownPlacement.TopLeft:case i.NeonDropdownPlacement.TopRight:case i.NeonDropdownPlacement.LeftBottom:case i.NeonDropdownPlacement.RightBottom:return!0}return!1},j=()=>{var n;const e=(n=f.value)==null?void 0:n.querySelector(".neon-search__option--highlighted");B.NeonScrollUtils.scrollIntoView(e)},v=(e,n)=>{const r=l.value+e;r>=0&&r<=t.options.length-1&&(l.value=r,s.value=t.options[l.value].key,n.preventDefault(),setTimeout(j))},c=e=>{p("update:modelValue",e)},h=e=>{t.multiple||c(""),d.value=e,p("filter-changed",e)},g=e=>{if(t.multiple){const n=t.modelValue.map(m=>m),r=n.findIndex(m=>m.key===e.key);r>=0?n.splice(r,1):n.push(e),c(n)}else c(e.key);h(t.multiple?"":e.label.toString())},y=e=>{if(a.value)switch(e.code){case"ArrowUp":case"ArrowDown":{const n=w()?-1:1;e.code==="ArrowUp"?v(-1*n,e):v(1*n,e)}break;case"Enter":case"Space":e.target.classList.contains("neon-search__input")||(g(t.options[l.value]),e.preventDefault());break;case"Tab":!e.ctrlKey&&!e.metaKey&&!e.altKey&&(a.value=!1);break}},S=e=>{u.value=e};o.onMounted(()=>{document.addEventListener("keydown",y)}),o.onUnmounted(()=>{document.removeEventListener("keydown",y)});const k=o.computed(()=>{const{onFilterChanged:e,...n}=N;return n}),q=e=>{s.value=e,l.value=t.options.findIndex(n=>n.key===e)},D=()=>a.value=!0,I=e=>c(t.modelValue.filter(n=>n.key!==e.key)),b=o.computed(()=>t.multiple?t.options:t.options.filter(e=>e.label!==d.value));return{dropdown:f,open:a,highlightedKey:s,filter:d,sanitizedAttributes:k,computedOptions:b,dropdownPlacement:u,onPlacement:S,onFilterChange:h,clickOption:g,changeHighlighted:q,showOptions:D,removeSelected:I}}});module.exports=U;
|
|
2
|
+
//# sourceMappingURL=NeonSearch.ts_vue_type_script_src_0925a332_lang.cjs.js.map
|
package/dist/components/user-input/search/NeonSearch.ts_vue_type_script_src_0925a332_lang.cjs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NeonSearch.ts_vue_type_script_src_0925a332_lang.cjs.js","sources":["../../../../src/components/user-input/search/NeonSearch.ts?vue&type=script&src=0925a332&lang.ts"],"sourcesContent":["import { computed, defineComponent, onMounted, onUnmounted, ref, useAttrs, watch } from 'vue';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport NeonDropdown from '@/components/presentation/dropdown/NeonDropdown.vue';\nimport NeonIcon from '@/components/presentation/icon/NeonIcon.vue';\nimport type { NeonSearchOption } from '@/common/models/NeonSearchOption';\nimport NeonInput from '@/components/user-input/input/NeonInput.vue';\nimport NeonChip from '@/components/user-input/chip/NeonChip.vue';\nimport { NeonDropdownPlacement } from '@/common/enums/NeonDropdownPlacement';\nimport { NeonScrollUtils } from '@/common/utils/NeonScrollUtils';\n\n/**\n * <p>\n * The <strong>NeonSearch</strong> component is equivalent to an HTML <input type=\"search\"> element. It is\n * useful as an alternative to <em>NeonSelect</em> to provide filtered results when the universe of results is very\n * large and/or the results need to be requested from a server side API.\n * </p>\n * <p><strong>NeonSearch</strong> provides input chips in the case the search allows multiple selection.</p>\n */\nexport default defineComponent({\n name: 'NeonSearch',\n components: {\n NeonChip,\n NeonDropdown,\n NeonIcon,\n NeonInput,\n },\n props: {\n /**\n * Either a string indicating the key of the selected option ('' if there is no selection) or an array of selected\n * NeonSearchOption in the case when multiple = true (necessary to display them as chips).\n */\n modelValue: { type: [String, Array as () => Array<NeonSearchOption>], required: true },\n /**\n * Placeholder to display in search input when there is no search string entered.\n */\n placeholder: { type: String, required: true },\n /**\n * The list of search results.\n */\n options: { type: Array as () => Array<NeonSearchOption>, required: true },\n /**\n * Allow multi-select.\n */\n multiple: { type: Boolean, default: false },\n /**\n * Disable the search\n */\n disabled: { type: Boolean, default: false },\n /**\n * The size of the dropdown - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The color of the search.\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n /**\n * Placement of the dropdown contents.\n */\n placement: { type: String as () => NeonDropdownPlacement, default: NeonDropdownPlacement.BottomLeft },\n },\n emits: [\n /**\n * emitted when the user changes the selection.\n * @type {string | NeonSearchOption[]} either the selected option's key (single select) or an array of the\n * selected options (multi-select).\n */\n 'update:modelValue',\n /**\n * emitted when the user types in filter box.\n * @type {string} the current filter criteria. This can be used by the application to filter the displayed options.\n */\n 'filter-changed',\n ],\n setup(props, { emit }) {\n const attrs = useAttrs();\n\n const dropdown = ref<HTMLElement | null>(null);\n const dropdownPlacement = ref<NeonDropdownPlacement>(props.placement);\n\n const open = ref(false);\n const highlightedKey = ref<string | null>(null);\n const highlightedIndex = ref(-1);\n const filter = ref('');\n\n watch(\n () => open.value,\n (open: boolean) => {\n if (open && props.options.length > 0) {\n highlightedKey.value = props.options[0].key;\n highlightedIndex.value = 0;\n }\n },\n );\n\n const isReverse = () => {\n switch (dropdownPlacement.value) {\n case NeonDropdownPlacement.TopLeft:\n case NeonDropdownPlacement.TopRight:\n case NeonDropdownPlacement.LeftBottom:\n case NeonDropdownPlacement.RightBottom:\n return true;\n }\n\n return false;\n };\n\n const scrollOnNavigate = () => {\n const element = dropdown.value?.querySelector('.neon-search__option--highlighted') as HTMLElement;\n NeonScrollUtils.scrollIntoView(element);\n };\n\n const navigateBy = (offset: number, $event: KeyboardEvent) => {\n const newIndex = highlightedIndex.value + offset;\n if (newIndex >= 0 && newIndex <= props.options.length - 1) {\n highlightedIndex.value = newIndex;\n highlightedKey.value = props.options[highlightedIndex.value].key;\n $event.preventDefault();\n setTimeout(scrollOnNavigate);\n }\n };\n\n const emitInputEvent = (value: string | NeonSearchOption[]) => {\n emit('update:modelValue', value);\n };\n\n const onFilterChange = (_filter: string) => {\n if (!props.multiple) {\n emitInputEvent('');\n }\n\n filter.value = _filter;\n emit('filter-changed', _filter);\n };\n\n const clickOption = (option: NeonSearchOption) => {\n if (props.multiple) {\n const values = (props.modelValue as NeonSearchOption[]).map((v) => v);\n const index = values.findIndex((v) => v.key === option.key);\n if (index >= 0) {\n values.splice(index, 1);\n } else {\n values.push(option);\n }\n emitInputEvent(values);\n } else {\n emitInputEvent(option.key);\n }\n\n onFilterChange(props.multiple ? '' : option.label.toString());\n };\n\n const keyboardHandler = ($event: KeyboardEvent) => {\n if (open.value) {\n switch ($event.code) {\n case 'ArrowUp':\n case 'ArrowDown': {\n const reverseOffset = isReverse() ? -1 : 1;\n if ($event.code === 'ArrowUp') {\n navigateBy(-1 * reverseOffset, $event);\n } else {\n navigateBy(1 * reverseOffset, $event);\n }\n }\n break;\n case 'Enter':\n case 'Space':\n if (!($event.target as HTMLElement).classList.contains('neon-search__input')) {\n clickOption(props.options[highlightedIndex.value]);\n $event.preventDefault();\n }\n break;\n case 'Tab':\n if (!$event.ctrlKey && !$event.metaKey && !$event.altKey) {\n open.value = false;\n }\n break;\n }\n }\n };\n\n const onPlacement = (placement: NeonDropdownPlacement) => {\n dropdownPlacement.value = placement;\n };\n\n onMounted(() => {\n document.addEventListener('keydown', keyboardHandler);\n });\n\n onUnmounted(() => {\n document.removeEventListener('keydown', keyboardHandler);\n });\n\n const sanitizedAttributes = computed(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { onFilterChanged, ...sanitized } = attrs;\n return sanitized;\n });\n\n const changeHighlighted = (key: string) => {\n highlightedKey.value = key;\n highlightedIndex.value = props.options.findIndex((opt) => opt.key === key);\n };\n\n const showOptions = () => (open.value = true);\n\n const removeSelected = (removed: NeonSearchOption) =>\n emitInputEvent((props.modelValue as NeonSearchOption[]).filter((v) => v.key !== removed.key));\n\n const computedOptions = computed(() => {\n return props.multiple ? props.options : props.options.filter((opt) => opt.label !== filter.value);\n });\n\n return {\n dropdown,\n open,\n highlightedKey,\n filter,\n sanitizedAttributes,\n computedOptions,\n dropdownPlacement,\n onPlacement,\n onFilterChange,\n clickOption,\n changeHighlighted,\n showOptions,\n removeSelected,\n };\n },\n});\n"],"names":["_sfc_main","defineComponent","NeonChip","NeonDropdown","NeonIcon","NeonInput","NeonSize","NeonFunctionalColor","NeonDropdownPlacement","props","emit","attrs","useAttrs","dropdown","ref","dropdownPlacement","open","highlightedKey","highlightedIndex","filter","watch","isReverse","scrollOnNavigate","element","_a","NeonScrollUtils","navigateBy","offset","$event","newIndex","emitInputEvent","value","onFilterChange","_filter","clickOption","option","values","v","index","keyboardHandler","reverseOffset","onPlacement","placement","onMounted","onUnmounted","sanitizedAttributes","computed","onFilterChanged","sanitized","changeHighlighted","key","opt","showOptions","removeSelected","removed","computedOptions"],"mappings":"2cAmBAA,EAAeC,kBAAgB,CAC7B,KAAM,aACN,WAAY,CACV,SAAAC,EACA,aAAAC,EACA,SAAAC,EACA,UAAAC,CACF,EACA,MAAO,CAKL,WAAY,CAAE,KAAM,CAAC,OAAQ,KAAsC,EAAG,SAAU,EAAK,EAIrF,YAA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ACxD,EAEK,MAAAM,EAAsBC,EAAAA,SAAS,IAAM,CAEnC,KAAA,CAAE,gBAAAC,KAAoBC,CAAA,EAAcrC,EACnC,OAAAqC,CAAA,CACR,EAEKC,EAAqBC,GAAgB,CACzCjC,EAAe,MAAQiC,EACNhC,EAAA,MAAQT,EAAM,QAAQ,UAAW0C,GAAQA,EAAI,MAAQD,CAAG,CAAA,EAGrEE,EAAc,IAAOpC,EAAK,MAAQ,GAElCqC,EAAkBC,GACtBxB,EAAgBrB,EAAM,WAAkC,OAAQ4B,GAAMA,EAAE,MAAQiB,EAAQ,GAAG,CAAC,EAExFC,EAAkBT,EAAAA,SAAS,IACxBrC,EAAM,SAAWA,EAAM,QAAUA,EAAM,QAAQ,OAAQ0C,GAAQA,EAAI,QAAUhC,EAAO,KAAK,CACjG,EAEM,MAAA,CACL,SAAAN,EACA,KAAAG,EACA,eAAAC,EACA,OAAAE,EACA,oBAAA0B,EACA,gBAAAU,EACA,kBAAAxC,EACA,YAAA0B,EACA,eAAAT,EACA,YAAAE,EACA,kBAAAe,EACA,YAAAG,EACA,eAAAC,CAAA,CAEJ,CACF,CAAC"}
|
|
@@ -22,7 +22,8 @@ var _sfc_main = defineComponent({
|
|
|
22
22
|
multiple: { type: Boolean, default: false },
|
|
23
23
|
disabled: { type: Boolean, default: false },
|
|
24
24
|
size: { type: String, default: NeonSize.Medium },
|
|
25
|
-
color: { type: String, default: NeonFunctionalColor.LowContrast }
|
|
25
|
+
color: { type: String, default: NeonFunctionalColor.LowContrast },
|
|
26
|
+
placement: { type: String, default: NeonDropdownPlacement.BottomLeft }
|
|
26
27
|
},
|
|
27
28
|
emits: [
|
|
28
29
|
"update:modelValue",
|
|
@@ -31,7 +32,7 @@ var _sfc_main = defineComponent({
|
|
|
31
32
|
setup(props, { emit }) {
|
|
32
33
|
const attrs = useAttrs();
|
|
33
34
|
const dropdown = ref(null);
|
|
34
|
-
const dropdownPlacement = ref(
|
|
35
|
+
const dropdownPlacement = ref(props.placement);
|
|
35
36
|
const open = ref(false);
|
|
36
37
|
const highlightedKey = ref(null);
|
|
37
38
|
const highlightedIndex = ref(-1);
|
|
@@ -152,6 +153,7 @@ var _sfc_main = defineComponent({
|
|
|
152
153
|
filter,
|
|
153
154
|
sanitizedAttributes,
|
|
154
155
|
computedOptions,
|
|
156
|
+
dropdownPlacement,
|
|
155
157
|
onPlacement,
|
|
156
158
|
onFilterChange,
|
|
157
159
|
clickOption,
|
|
@@ -162,4 +164,4 @@ var _sfc_main = defineComponent({
|
|
|
162
164
|
}
|
|
163
165
|
});
|
|
164
166
|
export { _sfc_main as default };
|
|
165
|
-
//# sourceMappingURL=NeonSearch.
|
|
167
|
+
//# sourceMappingURL=NeonSearch.ts_vue_type_script_src_0925a332_lang.es.js.map
|
package/dist/components/user-input/search/NeonSearch.ts_vue_type_script_src_0925a332_lang.es.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NeonSearch.ts_vue_type_script_src_0925a332_lang.es.js","sources":["../../../../src/components/user-input/search/NeonSearch.ts?vue&type=script&src=0925a332&lang.ts"],"sourcesContent":["import { computed, defineComponent, onMounted, onUnmounted, ref, useAttrs, watch } from 'vue';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport NeonDropdown from '@/components/presentation/dropdown/NeonDropdown.vue';\nimport NeonIcon from '@/components/presentation/icon/NeonIcon.vue';\nimport type { NeonSearchOption } from '@/common/models/NeonSearchOption';\nimport NeonInput from '@/components/user-input/input/NeonInput.vue';\nimport NeonChip from '@/components/user-input/chip/NeonChip.vue';\nimport { NeonDropdownPlacement } from '@/common/enums/NeonDropdownPlacement';\nimport { NeonScrollUtils } from '@/common/utils/NeonScrollUtils';\n\n/**\n * <p>\n * The <strong>NeonSearch</strong> component is equivalent to an HTML <input type=\"search\"> element. It is\n * useful as an alternative to <em>NeonSelect</em> to provide filtered results when the universe of results is very\n * large and/or the results need to be requested from a server side API.\n * </p>\n * <p><strong>NeonSearch</strong> provides input chips in the case the search allows multiple selection.</p>\n */\nexport default defineComponent({\n name: 'NeonSearch',\n components: {\n NeonChip,\n NeonDropdown,\n NeonIcon,\n NeonInput,\n },\n props: {\n /**\n * Either a string indicating the key of the selected option ('' if there is no selection) or an array of selected\n * NeonSearchOption in the case when multiple = true (necessary to display them as chips).\n */\n modelValue: { type: [String, Array as () => Array<NeonSearchOption>], required: true },\n /**\n * Placeholder to display in search input when there is no search string entered.\n */\n placeholder: { type: String, required: true },\n /**\n * The list of search results.\n */\n options: { type: Array as () => Array<NeonSearchOption>, required: true },\n /**\n * Allow multi-select.\n */\n multiple: { type: Boolean, default: false },\n /**\n * Disable the search\n */\n disabled: { type: Boolean, default: false },\n /**\n * The size of the dropdown - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The color of the search.\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n /**\n * Placement of the dropdown contents.\n */\n placement: { type: String as () => NeonDropdownPlacement, default: NeonDropdownPlacement.BottomLeft },\n },\n emits: [\n /**\n * emitted when the user changes the selection.\n * @type {string | NeonSearchOption[]} either the selected option's key (single select) or an array of the\n * selected options (multi-select).\n */\n 'update:modelValue',\n /**\n * emitted when the user types in filter box.\n * @type {string} the current filter criteria. This can be used by the application to filter the displayed options.\n */\n 'filter-changed',\n ],\n setup(props, { emit }) {\n const attrs = useAttrs();\n\n const dropdown = ref<HTMLElement | null>(null);\n const dropdownPlacement = ref<NeonDropdownPlacement>(props.placement);\n\n const open = ref(false);\n const highlightedKey = ref<string | null>(null);\n const highlightedIndex = ref(-1);\n const filter = ref('');\n\n watch(\n () => open.value,\n (open: boolean) => {\n if (open && props.options.length > 0) {\n highlightedKey.value = props.options[0].key;\n highlightedIndex.value = 0;\n }\n },\n );\n\n const isReverse = () => {\n switch (dropdownPlacement.value) {\n case NeonDropdownPlacement.TopLeft:\n case NeonDropdownPlacement.TopRight:\n case NeonDropdownPlacement.LeftBottom:\n case NeonDropdownPlacement.RightBottom:\n return true;\n }\n\n return false;\n };\n\n const scrollOnNavigate = () => {\n const element = dropdown.value?.querySelector('.neon-search__option--highlighted') as HTMLElement;\n NeonScrollUtils.scrollIntoView(element);\n };\n\n const navigateBy = (offset: number, $event: KeyboardEvent) => {\n const newIndex = highlightedIndex.value + offset;\n if (newIndex >= 0 && newIndex <= props.options.length - 1) {\n highlightedIndex.value = newIndex;\n highlightedKey.value = props.options[highlightedIndex.value].key;\n $event.preventDefault();\n setTimeout(scrollOnNavigate);\n }\n };\n\n const emitInputEvent = (value: string | NeonSearchOption[]) => {\n emit('update:modelValue', value);\n };\n\n const onFilterChange = (_filter: string) => {\n if (!props.multiple) {\n emitInputEvent('');\n }\n\n filter.value = _filter;\n emit('filter-changed', _filter);\n };\n\n const clickOption = (option: NeonSearchOption) => {\n if (props.multiple) {\n const values = (props.modelValue as NeonSearchOption[]).map((v) => v);\n const index = values.findIndex((v) => v.key === option.key);\n if (index >= 0) {\n values.splice(index, 1);\n } else {\n values.push(option);\n }\n emitInputEvent(values);\n } else {\n emitInputEvent(option.key);\n }\n\n onFilterChange(props.multiple ? '' : option.label.toString());\n };\n\n const keyboardHandler = ($event: KeyboardEvent) => {\n if (open.value) {\n switch ($event.code) {\n case 'ArrowUp':\n case 'ArrowDown': {\n const reverseOffset = isReverse() ? -1 : 1;\n if ($event.code === 'ArrowUp') {\n navigateBy(-1 * reverseOffset, $event);\n } else {\n navigateBy(1 * reverseOffset, $event);\n }\n }\n break;\n case 'Enter':\n case 'Space':\n if (!($event.target as HTMLElement).classList.contains('neon-search__input')) {\n clickOption(props.options[highlightedIndex.value]);\n $event.preventDefault();\n }\n break;\n case 'Tab':\n if (!$event.ctrlKey && !$event.metaKey && !$event.altKey) {\n open.value = false;\n }\n break;\n }\n }\n };\n\n const onPlacement = (placement: NeonDropdownPlacement) => {\n dropdownPlacement.value = placement;\n };\n\n onMounted(() => {\n document.addEventListener('keydown', keyboardHandler);\n });\n\n onUnmounted(() => {\n document.removeEventListener('keydown', keyboardHandler);\n });\n\n const sanitizedAttributes = computed(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { onFilterChanged, ...sanitized } = attrs;\n return sanitized;\n });\n\n const changeHighlighted = (key: string) => {\n highlightedKey.value = key;\n highlightedIndex.value = props.options.findIndex((opt) => opt.key === key);\n };\n\n const showOptions = () => (open.value = true);\n\n const removeSelected = (removed: NeonSearchOption) =>\n emitInputEvent((props.modelValue as NeonSearchOption[]).filter((v) => v.key !== removed.key));\n\n const computedOptions = computed(() => {\n return props.multiple ? props.options : props.options.filter((opt) => opt.label !== filter.value);\n });\n\n return {\n dropdown,\n open,\n highlightedKey,\n filter,\n sanitizedAttributes,\n computedOptions,\n dropdownPlacement,\n onPlacement,\n onFilterChange,\n clickOption,\n changeHighlighted,\n showOptions,\n removeSelected,\n };\n },\n});\n"],"names":["open"],"mappings":";;;;;;;;;AAmBA,IAAA,YAAe,gBAAgB;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IAKL,YAAY,EAAE,MAAM,CAAC,QAAQ,KAAsC,GAAG,UAAU,KAAK;AAAA,IAIrF,aAAa,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IAI5C,SAAS,EAAE,MAAM,OAAwC,UAAU,KAAK;AAAA,IAIxE,UAAU,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,IAI1C,UAAU,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,IAI1C,MAAM,EAAE,MAAM,QAA0B,SAAS,SAAS,OAAO;AAAA,IAIjE,OAAO,EAAE,MAAM,QAAqC,SAAS,oBAAoB,YAAY;AAAA,IAI7F,WAAW,EAAE,MAAM,QAAuC,SAAS,sBAAsB,WAAW;AAAA,EACtG;AAAA,EACA,OAAO;AAAA,IAML;AAAA,IAKA;AAA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SAAS,MAAM;AAEnC,YAAA,EAAE,oBAAoB,UAAA,IAAc;AACnC,aAAA;AAAA,IAAA,CACR;AAEK,UAAA,oBAAoB,CAAC,QAAgB;AACzC,qBAAe,QAAQ;AACN,uBAAA,QAAQ,MAAM,QAAQ,UAAU,CAAC,QAAQ,IAAI,QAAQ,GAAG;AAAA,IAAA;AAGrE,UAAA,cAAc,MAAO,KAAK,QAAQ;AAExC,UAAM,iBAAiB,CAAC,YACtB,eAAgB,MAAM,WAAkC,OAAO,CAAC,MAAM,EAAE,QAAQ,QAAQ,GAAG,CAAC;AAExF,UAAA,kBAAkB,SAAS,MAAM;AACrC,aAAO,MAAM,WAAW,MAAM,UAAU,MAAM,QAAQ,OAAO,CAAC,QAAQ,IAAI,UAAU,OAAO,KAAK;AAAA,IAAA,CACjG;AAEM,WAAA;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AACF,CAAC;;"}
|
package/dist/components/user-input/select/NeonSelect.ts_vue_type_script_src_1f492752_lang.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var o=require("vue"),b=require("../../../common/enums/NeonSize.cjs.js"),I=require("../../../common/enums/NeonFunctionalColor.cjs.js"),A=require("../../presentation/dropdown/NeonDropdown.cjs.js"),x=require("../../presentation/icon/NeonIcon.cjs.js"),B=require("../switch/NeonSwitch.cjs.js"),c=require("../../../common/enums/NeonDropdownPlacement.cjs.js"),L=require("../../../common/utils/NeonScrollUtils.cjs.js"),z=o.defineComponent({name:"NeonSelect",components:{NeonDropdown:A,NeonIcon:x,NeonSwitch:B},props:{id:{type:String},placeholder:{type:String,required:!0},placeholderAsOption:{type:Boolean,default:!1},placeholderIcon:{type:String,required:!1},options:{type:Array,required:!1},groupedOptions:{type:Array,required:!1},modelValue:{type:[String,Array],required:!0},multiple:{type:Boolean,default:!1},multiselectPlaceholder:{type:String,required:!1},disabled:{type:Boolean,default:!1},size:{type:String,default:b.NeonSize.Medium},color:{type:String,default:I.NeonFunctionalColor.LowContrast},placement:{type:String,default:c.NeonDropdownPlacement.BottomLeft}},emits:["update:modelValue"],setup(t,{emit:g}){const w=o.useAttrs(),f=o.ref(null),i=o.ref(!1),v=o.ref(t.placement),s=o.ref(null),r=o.ref(-1),l=o.computed(()=>{var e;return t.options?t.options:t.groupedOptions?(e=t.groupedOptions)==null?void 0:e.flatMap(n=>n.options):[]}),N=()=>{if(!t.groupedOptions)switch(v.value){case c.NeonDropdownPlacement.TopLeft:case c.NeonDropdownPlacement.TopRight:case c.NeonDropdownPlacement.LeftBottom:case c.NeonDropdownPlacement.RightBottom:return!0}return!1},S=()=>{var n;const e=(n=f.value)==null?void 0:n.querySelector(".neon-select__option--highlighted");e&&L.NeonScrollUtils.scrollIntoView(e)},p=(e,n)=>{const a=r.value+e;a>=0&&a<=l.value.length-1&&(r.value=a,s.value=l.value[r.value].key,n.preventDefault(),setTimeout(S))},d=e=>{g("update:modelValue",e)},y=e=>{if(t.multiple){const n=[...t.modelValue],a=n.findIndex(m=>m===e.key);a>=0?n.splice(a,1):n.push(e.key),d(n)}else t.modelValue!==e.key&&(i.value=!1,d(e.key))},h=e=>{if(i.value)switch(e.code){case"ArrowUp":case"ArrowDown":{const n=N()?-1:1;e.code==="ArrowUp"?p(-1*n,e):p(1*n,e)}break;case"Enter":case"Space":l.value[r.value].disabled||(y(l.value[r.value]),e.preventDefault());break;case"Tab":!e.ctrlKey&&!e.metaKey&&!e.altKey&&(i.value=!1);break}},k=o.computed(()=>t.groupedOptions||[{group:"",options:t.options||[]}]),q=o.computed(()=>{const{...e}=w;return e}),j=o.computed(()=>{if(t.multiple&&t.modelValue.length>0){if(t.multiselectPlaceholder)return t.multiselectPlaceholder;if(t.modelValue.length>1)return`${t.modelValue.length} items selected`;{const e=l.value.find(n=>n.key===t.modelValue[0]);return(e==null?void 0:e.label)||""}}else if(t.modelValue){const e=l.value.find(n=>n.key===t.modelValue);if(e)return e.label}return t.placeholder}),V=o.computed(()=>{if(t.modelValue){const e=l.value.find(n=>n.key===t.modelValue);if(e)return e.icon}return t.placeholderIcon}),O=e=>{const n=Array.from(e.target.options).filter(u=>u.selected).map(u=>u.value),a=l.value.filter(u=>n.indexOf(u.key)>=0),m=t.multiple?a.map(u=>u.key):a[0].key;d(m)},D=e=>{s.value=e,r.value=l.value.findIndex(n=>n.key===e)},P=e=>{v.value=e};return o.onMounted(()=>{document.addEventListener("keydown",h)}),o.onUnmounted(()=>{document.removeEventListener("keydown",h)}),o.watch(()=>i.value,e=>{e&&(s.value=l.value[0].key,r.value=0)}),{dropdown:f,open:i,highlightedKey:s,highlightedIndex:r,flattenedOptions:l,computedLabel:j,sanitizedAttributes:q,computedOptions:k,computedIcon:V,clickOption:y,nativeSelectChange:O,changeHighlighted:D,onPlacement:P}}});module.exports=z;
|
|
2
2
|
//# sourceMappingURL=NeonSelect.ts_vue_type_script_src_1f492752_lang.cjs.js.map
|
package/dist/components/user-input/select/NeonSelect.ts_vue_type_script_src_1f492752_lang.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeonSelect.ts_vue_type_script_src_1f492752_lang.cjs.js","sources":["../../../../src/components/user-input/select/NeonSelect.ts?vue&type=script&src=1f492752&lang.ts"],"sourcesContent":["import { computed, defineComponent, onMounted, onUnmounted, ref, useAttrs, watch } from 'vue';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport type { NeonSelectGroup } from '@/common/models/NeonSelectGroup';\nimport type { NeonSelectOption } from '@/common/models/NeonSelectOption';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport NeonDropdown from '@/components/presentation/dropdown/NeonDropdown.vue';\nimport NeonIcon from '@/components/presentation/icon/NeonIcon.vue';\nimport NeonSwitch from '@/components/user-input/switch/NeonSwitch.vue';\nimport { NeonDropdownPlacement } from '@/common/enums/NeonDropdownPlacement';\nimport { NeonScrollUtils } from '@/common/utils/NeonScrollUtils';\n\n/**\n * <p>The <strong>NeonSelect</strong> is the equivalent of an HTML <select> form control. On touch devices\n * NeonSelect will use the native select for input. <strong>NeonSelect</strong> supports grouping and multiselect.</p>\n * <p><strong>Note:</strong> As well as the options described below, pass through attributes supported by\n * <a href=\"/presentation/dropdown\">NeonDropdown</a> to change the style of the dropdown button.</p>\n */\nexport default defineComponent({\n name: 'NeonSelect',\n components: {\n NeonDropdown,\n NeonIcon,\n NeonSwitch,\n },\n props: {\n /**\n * Id for the dropdown button\n */\n id: { type: String },\n /**\n * Placeholder to display as button label when there is no option selected.\n */\n placeholder: { type: String, required: true },\n /**\n * Display the placeholder as the first option in the select, this is useful as an alternative to a label.\n */\n placeholderAsOption: { type: Boolean, default: false },\n /**\n * Optional placeholder icon.\n */\n placeholderIcon: { type: String, required: false },\n /**\n * A list of options to render in the select.\n */\n options: { type: Array as () => Array<NeonSelectOption>, required: false },\n /**\n * A list of grouped options to render in the select.\n */\n groupedOptions: { type: Array as () => Array<NeonSelectGroup>, required: false },\n /**\n * Either a single string, indicating the key of the selected option or an array of selected keys in the case\n * multiple = true.\n */\n modelValue: { type: [String, Array as () => Array<string>], required: true },\n /**\n * Allow multi-select.\n */\n multiple: { type: Boolean, default: false },\n /**\n * Placeholder when multiple values are selected.\n */\n multiselectPlaceholder: { type: String, required: false },\n /**\n * Disable the select\n */\n disabled: { type: Boolean, default: false },\n /**\n * The size of the dropdown - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The color of the select.\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n },\n emits: [\n /**\n * emitted when the user changes the selection.\n * @type {string | string[]} either the selected option's key (single select) or an array of the selected keys\n * (multi-select).\n */\n 'update:modelValue',\n ],\n setup(props, { emit }) {\n const attrs = useAttrs();\n\n const dropdown = ref<HTMLElement | null>(null);\n\n const open = ref(false);\n const dropdownPlacement = ref<NeonDropdownPlacement | null>(null);\n const highlightedKey = ref<string | null>(null);\n const highlightedIndex = ref(-1);\n\n const flattenedOptions = computed((): NeonSelectOption[] => {\n return props.options || props.groupedOptions?.flatMap((group) => group.options) || [];\n });\n\n const isReverse = () => {\n if (!props.groupedOptions) {\n switch (dropdownPlacement.value) {\n case NeonDropdownPlacement.TopLeft:\n case NeonDropdownPlacement.TopRight:\n case NeonDropdownPlacement.LeftBottom:\n case NeonDropdownPlacement.RightBottom:\n return true;\n }\n }\n\n return false;\n };\n\n const scrollOnNavigate = () => {\n const element = dropdown.value?.querySelector('.neon-select__option--highlighted') as HTMLElement;\n\n if (element) {\n NeonScrollUtils.scrollIntoView(element);\n }\n };\n\n const navigateBy = (offset: number, $event: KeyboardEvent) => {\n const newIndex = highlightedIndex.value + offset;\n if (newIndex >= 0 && newIndex <= flattenedOptions.value.length - 1) {\n highlightedIndex.value = newIndex;\n highlightedKey.value = flattenedOptions.value[highlightedIndex.value].key;\n $event.preventDefault();\n setTimeout(scrollOnNavigate);\n }\n };\n\n const emitInputEvent = (value: string | string[]) => {\n emit('update:modelValue', value);\n };\n\n const clickOption = (option: NeonSelectOption) => {\n if (props.multiple) {\n const values = [...props.modelValue];\n const index = values.findIndex((v) => v === option.key);\n if (index >= 0) {\n values.splice(index, 1);\n } else {\n values.push(option.key);\n }\n emitInputEvent(values);\n } else if (props.modelValue !== option.key) {\n open.value = false;\n emitInputEvent(option.key);\n }\n };\n\n const keyboardHandler = ($event: KeyboardEvent) => {\n if (open.value) {\n switch ($event.code) {\n case 'ArrowUp':\n case 'ArrowDown':\n {\n const reverseOffset = isReverse() ? -1 : 1;\n if ($event.code === 'ArrowUp') {\n navigateBy(-1 * reverseOffset, $event);\n } else {\n navigateBy(1 * reverseOffset, $event);\n }\n }\n break;\n case 'Enter':\n case 'Space':\n if (!flattenedOptions.value[highlightedIndex.value].disabled) {\n clickOption(flattenedOptions.value[highlightedIndex.value]);\n $event.preventDefault();\n }\n break;\n case 'Tab':\n if (!$event.ctrlKey && !$event.metaKey && !$event.altKey) {\n open.value = false;\n }\n break;\n }\n }\n };\n\n const computedOptions = computed((): Array<NeonSelectGroup> => {\n return (\n props.groupedOptions || [\n {\n group: '',\n options: props.options || [],\n },\n ]\n );\n });\n\n const sanitizedAttributes = computed(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { ...sanitized } = attrs;\n return sanitized;\n });\n\n const computedLabel = computed(() => {\n if (props.multiple && props.modelValue.length > 0) {\n if (props.multiselectPlaceholder) {\n return props.multiselectPlaceholder;\n } else if (props.modelValue.length > 1) {\n return `${props.modelValue.length} items selected`;\n } else {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue[0]);\n return selected?.label || '';\n }\n } else if (props.modelValue) {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue);\n\n if (selected) {\n return selected.label;\n }\n }\n\n return props.placeholder;\n });\n\n const computedIcon = computed(() => {\n if (props.modelValue) {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue);\n\n if (selected) {\n return selected.icon;\n }\n }\n\n return props.placeholderIcon;\n });\n\n const nativeSelectChange = (event: Event) => {\n const selectedKeys = Array.from((event.target as HTMLSelectElement).options)\n .filter((opt) => opt.selected)\n .map((opt) => opt.value);\n const selectedOptions = flattenedOptions.value.filter((v) => selectedKeys.indexOf(v.key) >= 0);\n const value = props.multiple ? selectedOptions.map((value) => value.key) : selectedOptions[0].key;\n emitInputEvent(value);\n };\n\n const changeHighlighted = (key: string) => {\n highlightedKey.value = key;\n highlightedIndex.value = flattenedOptions.value.findIndex((opt) => opt.key === key);\n };\n\n const onPlacement = (placement: NeonDropdownPlacement) => {\n dropdownPlacement.value = placement;\n };\n\n onMounted(() => {\n document.addEventListener('keydown', keyboardHandler);\n });\n\n onUnmounted(() => {\n document.removeEventListener('keydown', keyboardHandler);\n });\n\n watch(\n () => open.value,\n (open: boolean) => {\n if (open) {\n highlightedKey.value = flattenedOptions.value[0].key;\n highlightedIndex.value = 0;\n }\n },\n );\n\n return {\n dropdown,\n open,\n highlightedKey,\n highlightedIndex,\n flattenedOptions,\n computedLabel,\n sanitizedAttributes,\n computedOptions,\n computedIcon,\n clickOption,\n nativeSelectChange,\n changeHighlighted,\n onPlacement,\n };\n },\n});\n"],"names":["_sfc_main","defineComponent","NeonDropdown","NeonIcon","NeonSwitch","NeonSize","NeonFunctionalColor","props","emit","attrs","useAttrs","dropdown","ref","open","dropdownPlacement","highlightedKey","highlightedIndex","flattenedOptions","computed","_a","group","isReverse","NeonDropdownPlacement","scrollOnNavigate","element","NeonScrollUtils","navigateBy","offset","$event","newIndex","emitInputEvent","value","clickOption","option","values","index","v","keyboardHandler","reverseOffset","computedOptions","sanitizedAttributes","sanitized","computedLabel","selected","computedIcon","nativeSelectChange","event","selectedKeys","opt","selectedOptions","changeHighlighted","key","onPlacement","placement","onMounted","onUnmounted","watch"],"mappings":"waAiBAA,EAAeC,kBAAgB,CAC7B,KAAM,aACN,WAAY,CACV,aAAAC,EACA,SAAAC,EACA,WAAAC,CACF,EACA,MAAO,CAIL,GAAI,CAAE,KAAM,MAAO,EAInB,YAAa,CAAE,KAAM,OAAQ,SAAU,EAAK,EAI5C,oBAAqB,CAAE,KAAM,QAAS,QAAS,EAAM,EAIrD,gBAAiB,CAAE,KAAM,OAAQ,SAAU,EAAM,EAIjD,QAAS,CAAE,KAAM,MAAwC,SAAU,EAAM,EAIzE,eAAgB,CAAE,KAAM,MAAuC,SAAU,EAAM,EAK/E,WAAY,CAAE,KAAM,CAAC,OAAQ,KAA4B,EAAG,SAAU,EAAK,EAI3E,SAAU,CAAE,KAAM,QAAS,QAAS,EAAM,EAI1C,uBAAwB,CAAE,KAAM,OAAQ,SAAU,EAAM,EAIxD,SAAU,CAAE,KAAM,QAAS,QAAS,EAAM,EAI1C,KAAM,CAAE,KAAM,OAA0B,QAASC,EAAAA,SAAS,MAAO,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,EACA,YAAAE,CAAA,CAEJ,CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"NeonSelect.ts_vue_type_script_src_1f492752_lang.cjs.js","sources":["../../../../src/components/user-input/select/NeonSelect.ts?vue&type=script&src=1f492752&lang.ts"],"sourcesContent":["import { computed, defineComponent, onMounted, onUnmounted, ref, useAttrs, watch } from 'vue';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport type { NeonSelectGroup } from '@/common/models/NeonSelectGroup';\nimport type { NeonSelectOption } from '@/common/models/NeonSelectOption';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport NeonDropdown from '@/components/presentation/dropdown/NeonDropdown.vue';\nimport NeonIcon from '@/components/presentation/icon/NeonIcon.vue';\nimport NeonSwitch from '@/components/user-input/switch/NeonSwitch.vue';\nimport { NeonDropdownPlacement } from '@/common/enums/NeonDropdownPlacement';\nimport { NeonScrollUtils } from '@/common/utils/NeonScrollUtils';\n\n/**\n * <p>The <strong>NeonSelect</strong> is the equivalent of an HTML <select> form control. On touch devices\n * NeonSelect will use the native select for input. <strong>NeonSelect</strong> supports grouping and multiselect.</p>\n * <p><strong>Note:</strong> As well as the options described below, pass through attributes supported by\n * <a href=\"/presentation/dropdown\">NeonDropdown</a> to change the style of the dropdown button.</p>\n */\nexport default defineComponent({\n name: 'NeonSelect',\n components: {\n NeonDropdown,\n NeonIcon,\n NeonSwitch,\n },\n props: {\n /**\n * Id for the dropdown button\n */\n id: { type: String },\n /**\n * Placeholder to display as button label when there is no option selected.\n */\n placeholder: { type: String, required: true },\n /**\n * Display the placeholder as the first option in the select, this is useful as an alternative to a label.\n */\n placeholderAsOption: { type: Boolean, default: false },\n /**\n * Optional placeholder icon.\n */\n placeholderIcon: { type: String, required: false },\n /**\n * A list of options to render in the select.\n */\n options: { type: Array as () => Array<NeonSelectOption>, required: false },\n /**\n * A list of grouped options to render in the select.\n */\n groupedOptions: { type: Array as () => Array<NeonSelectGroup>, required: false },\n /**\n * Either a single string, indicating the key of the selected option or an array of selected keys in the case\n * multiple = true.\n */\n modelValue: { type: [String, Array as () => Array<string>], required: true },\n /**\n * Allow multi-select.\n */\n multiple: { type: Boolean, default: false },\n /**\n * Placeholder when multiple values are selected.\n */\n multiselectPlaceholder: { type: String, required: false },\n /**\n * Disable the select\n */\n disabled: { type: Boolean, default: false },\n /**\n * The size of the dropdown - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The color of the select.\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n /**\n * Placement of the dropdown contents.\n */\n placement: { type: String as () => NeonDropdownPlacement, default: NeonDropdownPlacement.BottomLeft },\n },\n emits: [\n /**\n * emitted when the user changes the selection.\n * @type {string | string[]} either the selected option's key (single select) or an array of the selected keys\n * (multi-select).\n */\n 'update:modelValue',\n ],\n setup(props, { emit }) {\n const attrs = useAttrs();\n\n const dropdown = ref<HTMLElement | null>(null);\n\n const open = ref(false);\n const dropdownPlacement = ref<NeonDropdownPlacement>(props.placement);\n const highlightedKey = ref<string | null>(null);\n const highlightedIndex = ref(-1);\n\n const flattenedOptions = computed((): NeonSelectOption[] => {\n if (props.options) {\n return props.options;\n } else if (props.groupedOptions) {\n return props.groupedOptions?.flatMap((group) => group.options);\n }\n return [];\n });\n\n const isReverse = () => {\n if (!props.groupedOptions) {\n switch (dropdownPlacement.value) {\n case NeonDropdownPlacement.TopLeft:\n case NeonDropdownPlacement.TopRight:\n case NeonDropdownPlacement.LeftBottom:\n case NeonDropdownPlacement.RightBottom:\n return true;\n }\n }\n\n return false;\n };\n\n const scrollOnNavigate = () => {\n const element = dropdown.value?.querySelector('.neon-select__option--highlighted') as HTMLElement;\n\n if (element) {\n NeonScrollUtils.scrollIntoView(element);\n }\n };\n\n const navigateBy = (offset: number, $event: KeyboardEvent) => {\n const newIndex = highlightedIndex.value + offset;\n if (newIndex >= 0 && newIndex <= flattenedOptions.value.length - 1) {\n highlightedIndex.value = newIndex;\n highlightedKey.value = flattenedOptions.value[highlightedIndex.value].key;\n $event.preventDefault();\n setTimeout(scrollOnNavigate);\n }\n };\n\n const emitInputEvent = (value: string | string[]) => {\n emit('update:modelValue', value);\n };\n\n const clickOption = (option: NeonSelectOption) => {\n if (props.multiple) {\n const values = [...props.modelValue];\n const index = values.findIndex((v) => v === option.key);\n if (index >= 0) {\n values.splice(index, 1);\n } else {\n values.push(option.key);\n }\n emitInputEvent(values);\n } else if (props.modelValue !== option.key) {\n open.value = false;\n emitInputEvent(option.key);\n }\n };\n\n const keyboardHandler = ($event: KeyboardEvent) => {\n if (open.value) {\n switch ($event.code) {\n case 'ArrowUp':\n case 'ArrowDown': {\n const reverseOffset = isReverse() ? -1 : 1;\n if ($event.code === 'ArrowUp') {\n navigateBy(-1 * reverseOffset, $event);\n } else {\n navigateBy(1 * reverseOffset, $event);\n }\n }\n break;\n case 'Enter':\n case 'Space':\n if (!flattenedOptions.value[highlightedIndex.value].disabled) {\n clickOption(flattenedOptions.value[highlightedIndex.value]);\n $event.preventDefault();\n }\n break;\n case 'Tab':\n if (!$event.ctrlKey && !$event.metaKey && !$event.altKey) {\n open.value = false;\n }\n break;\n }\n }\n };\n\n const computedOptions = computed((): Array<NeonSelectGroup> => {\n return (\n props.groupedOptions || [\n {\n group: '',\n options: props.options || [],\n },\n ]\n );\n });\n\n const sanitizedAttributes = computed(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { ...sanitized } = attrs;\n return sanitized;\n });\n\n const computedLabel = computed(() => {\n if (props.multiple && props.modelValue.length > 0) {\n if (props.multiselectPlaceholder) {\n return props.multiselectPlaceholder;\n } else if (props.modelValue.length > 1) {\n return `${props.modelValue.length} items selected`;\n } else {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue[0]);\n return selected?.label || '';\n }\n } else if (props.modelValue) {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue);\n\n if (selected) {\n return selected.label;\n }\n }\n\n return props.placeholder;\n });\n\n const computedIcon = computed(() => {\n if (props.modelValue) {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue);\n\n if (selected) {\n return selected.icon;\n }\n }\n\n return props.placeholderIcon;\n });\n\n const nativeSelectChange = (event: Event) => {\n const selectedKeys = Array.from((event.target as HTMLSelectElement).options)\n .filter((opt) => opt.selected)\n .map((opt) => opt.value);\n const selectedOptions = flattenedOptions.value.filter((v) => selectedKeys.indexOf(v.key) >= 0);\n const value = props.multiple ? selectedOptions.map((value) => value.key) : selectedOptions[0].key;\n emitInputEvent(value);\n };\n\n const changeHighlighted = (key: string) => {\n highlightedKey.value = key;\n highlightedIndex.value = flattenedOptions.value.findIndex((opt) => opt.key === key);\n };\n\n const onPlacement = (placement: NeonDropdownPlacement) => {\n dropdownPlacement.value = placement;\n };\n\n onMounted(() => {\n document.addEventListener('keydown', keyboardHandler);\n });\n\n onUnmounted(() => {\n document.removeEventListener('keydown', keyboardHandler);\n });\n\n watch(\n () => open.value,\n (open: boolean) => {\n if (open) {\n highlightedKey.value = flattenedOptions.value[0].key;\n highlightedIndex.value = 0;\n }\n },\n );\n\n return {\n dropdown,\n open,\n highlightedKey,\n highlightedIndex,\n flattenedOptions,\n computedLabel,\n sanitizedAttributes,\n computedOptions,\n computedIcon,\n clickOption,\n nativeSelectChange,\n changeHighlighted,\n onPlacement,\n };\n },\n});\n"],"names":["_sfc_main","defineComponent","NeonDropdown","NeonIcon","NeonSwitch","NeonSize","NeonFunctionalColor","NeonDropdownPlacement","props","emit","attrs","useAttrs","dropdown","ref","open","dropdownPlacement","highlightedKey","highlightedIndex","flattenedOptions","computed","_a","group","isReverse","scrollOnNavigate","element","NeonScrollUtils","navigateBy","offset","$event","newIndex","emitInputEvent","value","clickOption","option","values","index","v","keyboardHandler","reverseOffset","computedOptions","sanitizedAttributes","sanitized","computedLabel","selected","computedIcon","nativeSelectChange","event","selectedKeys","opt","selectedOptions","changeHighlighted","key","onPlacement","placement","onMounted","onUnmounted","watch"],"mappings":"waAiBAA,EA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lB,GAAUA,EAAM,GAAG,EAAIkB,EAAgB,GAAG,IAC9FnB,EAAeC,CAAK,CAAA,EAGhBmB,EAAqBC,GAAgB,CACzCnC,EAAe,MAAQmC,EACNlC,EAAA,MAAQC,EAAiB,MAAM,UAAW8B,GAAQA,EAAI,MAAQG,CAAG,CAAA,EAG9EC,EAAeC,GAAqC,CACxDtC,EAAkB,MAAQsC,CAAA,EAG5BC,OAAAA,EAAAA,UAAU,IAAM,CACL,SAAA,iBAAiB,UAAWjB,CAAe,CAAA,CACrD,EAEDkB,EAAAA,YAAY,IAAM,CACP,SAAA,oBAAoB,UAAWlB,CAAe,CAAA,CACxD,EAEDmB,EAAA,MACE,IAAM1C,EAAK,MACVA,GAAkB,CACbA,IACaE,EAAA,MAAQE,EAAiB,MAAM,GAAG,IACjDD,EAAiB,MAAQ,EAE7B,CAAA,EAGK,CACL,SAAAL,EACA,KAAAE,EACA,eAAAE,EACA,iBAAAC,EACA,iBAAAC,EACA,cAAAwB,EACA,oBAAAF,EACA,gBAAAD,EACA,aAAAK,EACA,YAAAZ,EACA,mBAAAa,EACA,kBAAAK,EACA,YAAAE,CAAA,CAEJ,CACF,CAAC"}
|
package/dist/components/user-input/select/NeonSelect.ts_vue_type_script_src_1f492752_lang.es.js
CHANGED
|
@@ -25,7 +25,8 @@ var _sfc_main = defineComponent({
|
|
|
25
25
|
multiselectPlaceholder: { type: String, required: false },
|
|
26
26
|
disabled: { type: Boolean, default: false },
|
|
27
27
|
size: { type: String, default: NeonSize.Medium },
|
|
28
|
-
color: { type: String, default: NeonFunctionalColor.LowContrast }
|
|
28
|
+
color: { type: String, default: NeonFunctionalColor.LowContrast },
|
|
29
|
+
placement: { type: String, default: NeonDropdownPlacement.BottomLeft }
|
|
29
30
|
},
|
|
30
31
|
emits: [
|
|
31
32
|
"update:modelValue"
|
|
@@ -34,12 +35,17 @@ var _sfc_main = defineComponent({
|
|
|
34
35
|
const attrs = useAttrs();
|
|
35
36
|
const dropdown = ref(null);
|
|
36
37
|
const open = ref(false);
|
|
37
|
-
const dropdownPlacement = ref(
|
|
38
|
+
const dropdownPlacement = ref(props.placement);
|
|
38
39
|
const highlightedKey = ref(null);
|
|
39
40
|
const highlightedIndex = ref(-1);
|
|
40
41
|
const flattenedOptions = computed(() => {
|
|
41
42
|
var _a;
|
|
42
|
-
|
|
43
|
+
if (props.options) {
|
|
44
|
+
return props.options;
|
|
45
|
+
} else if (props.groupedOptions) {
|
|
46
|
+
return (_a = props.groupedOptions) == null ? void 0 : _a.flatMap((group) => group.options);
|
|
47
|
+
}
|
|
48
|
+
return [];
|
|
43
49
|
});
|
|
44
50
|
const isReverse = () => {
|
|
45
51
|
if (!props.groupedOptions) {
|
package/dist/components/user-input/select/NeonSelect.ts_vue_type_script_src_1f492752_lang.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeonSelect.ts_vue_type_script_src_1f492752_lang.es.js","sources":["../../../../src/components/user-input/select/NeonSelect.ts?vue&type=script&src=1f492752&lang.ts"],"sourcesContent":["import { computed, defineComponent, onMounted, onUnmounted, ref, useAttrs, watch } from 'vue';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport type { NeonSelectGroup } from '@/common/models/NeonSelectGroup';\nimport type { NeonSelectOption } from '@/common/models/NeonSelectOption';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport NeonDropdown from '@/components/presentation/dropdown/NeonDropdown.vue';\nimport NeonIcon from '@/components/presentation/icon/NeonIcon.vue';\nimport NeonSwitch from '@/components/user-input/switch/NeonSwitch.vue';\nimport { NeonDropdownPlacement } from '@/common/enums/NeonDropdownPlacement';\nimport { NeonScrollUtils } from '@/common/utils/NeonScrollUtils';\n\n/**\n * <p>The <strong>NeonSelect</strong> is the equivalent of an HTML <select> form control. On touch devices\n * NeonSelect will use the native select for input. <strong>NeonSelect</strong> supports grouping and multiselect.</p>\n * <p><strong>Note:</strong> As well as the options described below, pass through attributes supported by\n * <a href=\"/presentation/dropdown\">NeonDropdown</a> to change the style of the dropdown button.</p>\n */\nexport default defineComponent({\n name: 'NeonSelect',\n components: {\n NeonDropdown,\n NeonIcon,\n NeonSwitch,\n },\n props: {\n /**\n * Id for the dropdown button\n */\n id: { type: String },\n /**\n * Placeholder to display as button label when there is no option selected.\n */\n placeholder: { type: String, required: true },\n /**\n * Display the placeholder as the first option in the select, this is useful as an alternative to a label.\n */\n placeholderAsOption: { type: Boolean, default: false },\n /**\n * Optional placeholder icon.\n */\n placeholderIcon: { type: String, required: false },\n /**\n * A list of options to render in the select.\n */\n options: { type: Array as () => Array<NeonSelectOption>, required: false },\n /**\n * A list of grouped options to render in the select.\n */\n groupedOptions: { type: Array as () => Array<NeonSelectGroup>, required: false },\n /**\n * Either a single string, indicating the key of the selected option or an array of selected keys in the case\n * multiple = true.\n */\n modelValue: { type: [String, Array as () => Array<string>], required: true },\n /**\n * Allow multi-select.\n */\n multiple: { type: Boolean, default: false },\n /**\n * Placeholder when multiple values are selected.\n */\n multiselectPlaceholder: { type: String, required: false },\n /**\n * Disable the select\n */\n disabled: { type: Boolean, default: false },\n /**\n * The size of the dropdown - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The color of the select.\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n },\n emits: [\n /**\n * emitted when the user changes the selection.\n * @type {string | string[]} either the selected option's key (single select) or an array of the selected keys\n * (multi-select).\n */\n 'update:modelValue',\n ],\n setup(props, { emit }) {\n const attrs = useAttrs();\n\n const dropdown = ref<HTMLElement | null>(null);\n\n const open = ref(false);\n const dropdownPlacement = ref<NeonDropdownPlacement | null>(null);\n const highlightedKey = ref<string | null>(null);\n const highlightedIndex = ref(-1);\n\n const flattenedOptions = computed((): NeonSelectOption[] => {\n return props.options || props.groupedOptions?.flatMap((group) => group.options) || [];\n });\n\n const isReverse = () => {\n if (!props.groupedOptions) {\n switch (dropdownPlacement.value) {\n case NeonDropdownPlacement.TopLeft:\n case NeonDropdownPlacement.TopRight:\n case NeonDropdownPlacement.LeftBottom:\n case NeonDropdownPlacement.RightBottom:\n return true;\n }\n }\n\n return false;\n };\n\n const scrollOnNavigate = () => {\n const element = dropdown.value?.querySelector('.neon-select__option--highlighted') as HTMLElement;\n\n if (element) {\n NeonScrollUtils.scrollIntoView(element);\n }\n };\n\n const navigateBy = (offset: number, $event: KeyboardEvent) => {\n const newIndex = highlightedIndex.value + offset;\n if (newIndex >= 0 && newIndex <= flattenedOptions.value.length - 1) {\n highlightedIndex.value = newIndex;\n highlightedKey.value = flattenedOptions.value[highlightedIndex.value].key;\n $event.preventDefault();\n setTimeout(scrollOnNavigate);\n }\n };\n\n const emitInputEvent = (value: string | string[]) => {\n emit('update:modelValue', value);\n };\n\n const clickOption = (option: NeonSelectOption) => {\n if (props.multiple) {\n const values = [...props.modelValue];\n const index = values.findIndex((v) => v === option.key);\n if (index >= 0) {\n values.splice(index, 1);\n } else {\n values.push(option.key);\n }\n emitInputEvent(values);\n } else if (props.modelValue !== option.key) {\n open.value = false;\n emitInputEvent(option.key);\n }\n };\n\n const keyboardHandler = ($event: KeyboardEvent) => {\n if (open.value) {\n switch ($event.code) {\n case 'ArrowUp':\n case 'ArrowDown':\n {\n const reverseOffset = isReverse() ? -1 : 1;\n if ($event.code === 'ArrowUp') {\n navigateBy(-1 * reverseOffset, $event);\n } else {\n navigateBy(1 * reverseOffset, $event);\n }\n }\n break;\n case 'Enter':\n case 'Space':\n if (!flattenedOptions.value[highlightedIndex.value].disabled) {\n clickOption(flattenedOptions.value[highlightedIndex.value]);\n $event.preventDefault();\n }\n break;\n case 'Tab':\n if (!$event.ctrlKey && !$event.metaKey && !$event.altKey) {\n open.value = false;\n }\n break;\n }\n }\n };\n\n const computedOptions = computed((): Array<NeonSelectGroup> => {\n return (\n props.groupedOptions || [\n {\n group: '',\n options: props.options || [],\n },\n ]\n );\n });\n\n const sanitizedAttributes = computed(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { ...sanitized } = attrs;\n return sanitized;\n });\n\n const computedLabel = computed(() => {\n if (props.multiple && props.modelValue.length > 0) {\n if (props.multiselectPlaceholder) {\n return props.multiselectPlaceholder;\n } else if (props.modelValue.length > 1) {\n return `${props.modelValue.length} items selected`;\n } else {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue[0]);\n return selected?.label || '';\n }\n } else if (props.modelValue) {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue);\n\n if (selected) {\n return selected.label;\n }\n }\n\n return props.placeholder;\n });\n\n const computedIcon = computed(() => {\n if (props.modelValue) {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue);\n\n if (selected) {\n return selected.icon;\n }\n }\n\n return props.placeholderIcon;\n });\n\n const nativeSelectChange = (event: Event) => {\n const selectedKeys = Array.from((event.target as HTMLSelectElement).options)\n .filter((opt) => opt.selected)\n .map((opt) => opt.value);\n const selectedOptions = flattenedOptions.value.filter((v) => selectedKeys.indexOf(v.key) >= 0);\n const value = props.multiple ? selectedOptions.map((value) => value.key) : selectedOptions[0].key;\n emitInputEvent(value);\n };\n\n const changeHighlighted = (key: string) => {\n highlightedKey.value = key;\n highlightedIndex.value = flattenedOptions.value.findIndex((opt) => opt.key === key);\n };\n\n const onPlacement = (placement: NeonDropdownPlacement) => {\n dropdownPlacement.value = placement;\n };\n\n onMounted(() => {\n document.addEventListener('keydown', keyboardHandler);\n });\n\n onUnmounted(() => {\n document.removeEventListener('keydown', keyboardHandler);\n });\n\n watch(\n () => open.value,\n (open: boolean) => {\n if (open) {\n highlightedKey.value = flattenedOptions.value[0].key;\n highlightedIndex.value = 0;\n }\n },\n );\n\n return {\n dropdown,\n open,\n highlightedKey,\n highlightedIndex,\n flattenedOptions,\n computedLabel,\n sanitizedAttributes,\n computedOptions,\n computedIcon,\n clickOption,\n nativeSelectChange,\n changeHighlighted,\n onPlacement,\n };\n },\n});\n"],"names":["value","open"],"mappings":";;;;;;;;AAiBA,IAAA,Y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
{"version":3,"file":"NeonSelect.ts_vue_type_script_src_1f492752_lang.es.js","sources":["../../../../src/components/user-input/select/NeonSelect.ts?vue&type=script&src=1f492752&lang.ts"],"sourcesContent":["import { computed, defineComponent, onMounted, onUnmounted, ref, useAttrs, watch } from 'vue';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport type { NeonSelectGroup } from '@/common/models/NeonSelectGroup';\nimport type { NeonSelectOption } from '@/common/models/NeonSelectOption';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport NeonDropdown from '@/components/presentation/dropdown/NeonDropdown.vue';\nimport NeonIcon from '@/components/presentation/icon/NeonIcon.vue';\nimport NeonSwitch from '@/components/user-input/switch/NeonSwitch.vue';\nimport { NeonDropdownPlacement } from '@/common/enums/NeonDropdownPlacement';\nimport { NeonScrollUtils } from '@/common/utils/NeonScrollUtils';\n\n/**\n * <p>The <strong>NeonSelect</strong> is the equivalent of an HTML <select> form control. On touch devices\n * NeonSelect will use the native select for input. <strong>NeonSelect</strong> supports grouping and multiselect.</p>\n * <p><strong>Note:</strong> As well as the options described below, pass through attributes supported by\n * <a href=\"/presentation/dropdown\">NeonDropdown</a> to change the style of the dropdown button.</p>\n */\nexport default defineComponent({\n name: 'NeonSelect',\n components: {\n NeonDropdown,\n NeonIcon,\n NeonSwitch,\n },\n props: {\n /**\n * Id for the dropdown button\n */\n id: { type: String },\n /**\n * Placeholder to display as button label when there is no option selected.\n */\n placeholder: { type: String, required: true },\n /**\n * Display the placeholder as the first option in the select, this is useful as an alternative to a label.\n */\n placeholderAsOption: { type: Boolean, default: false },\n /**\n * Optional placeholder icon.\n */\n placeholderIcon: { type: String, required: false },\n /**\n * A list of options to render in the select.\n */\n options: { type: Array as () => Array<NeonSelectOption>, required: false },\n /**\n * A list of grouped options to render in the select.\n */\n groupedOptions: { type: Array as () => Array<NeonSelectGroup>, required: false },\n /**\n * Either a single string, indicating the key of the selected option or an array of selected keys in the case\n * multiple = true.\n */\n modelValue: { type: [String, Array as () => Array<string>], required: true },\n /**\n * Allow multi-select.\n */\n multiple: { type: Boolean, default: false },\n /**\n * Placeholder when multiple values are selected.\n */\n multiselectPlaceholder: { type: String, required: false },\n /**\n * Disable the select\n */\n disabled: { type: Boolean, default: false },\n /**\n * The size of the dropdown - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The color of the select.\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n /**\n * Placement of the dropdown contents.\n */\n placement: { type: String as () => NeonDropdownPlacement, default: NeonDropdownPlacement.BottomLeft },\n },\n emits: [\n /**\n * emitted when the user changes the selection.\n * @type {string | string[]} either the selected option's key (single select) or an array of the selected keys\n * (multi-select).\n */\n 'update:modelValue',\n ],\n setup(props, { emit }) {\n const attrs = useAttrs();\n\n const dropdown = ref<HTMLElement | null>(null);\n\n const open = ref(false);\n const dropdownPlacement = ref<NeonDropdownPlacement>(props.placement);\n const highlightedKey = ref<string | null>(null);\n const highlightedIndex = ref(-1);\n\n const flattenedOptions = computed((): NeonSelectOption[] => {\n if (props.options) {\n return props.options;\n } else if (props.groupedOptions) {\n return props.groupedOptions?.flatMap((group) => group.options);\n }\n return [];\n });\n\n const isReverse = () => {\n if (!props.groupedOptions) {\n switch (dropdownPlacement.value) {\n case NeonDropdownPlacement.TopLeft:\n case NeonDropdownPlacement.TopRight:\n case NeonDropdownPlacement.LeftBottom:\n case NeonDropdownPlacement.RightBottom:\n return true;\n }\n }\n\n return false;\n };\n\n const scrollOnNavigate = () => {\n const element = dropdown.value?.querySelector('.neon-select__option--highlighted') as HTMLElement;\n\n if (element) {\n NeonScrollUtils.scrollIntoView(element);\n }\n };\n\n const navigateBy = (offset: number, $event: KeyboardEvent) => {\n const newIndex = highlightedIndex.value + offset;\n if (newIndex >= 0 && newIndex <= flattenedOptions.value.length - 1) {\n highlightedIndex.value = newIndex;\n highlightedKey.value = flattenedOptions.value[highlightedIndex.value].key;\n $event.preventDefault();\n setTimeout(scrollOnNavigate);\n }\n };\n\n const emitInputEvent = (value: string | string[]) => {\n emit('update:modelValue', value);\n };\n\n const clickOption = (option: NeonSelectOption) => {\n if (props.multiple) {\n const values = [...props.modelValue];\n const index = values.findIndex((v) => v === option.key);\n if (index >= 0) {\n values.splice(index, 1);\n } else {\n values.push(option.key);\n }\n emitInputEvent(values);\n } else if (props.modelValue !== option.key) {\n open.value = false;\n emitInputEvent(option.key);\n }\n };\n\n const keyboardHandler = ($event: KeyboardEvent) => {\n if (open.value) {\n switch ($event.code) {\n case 'ArrowUp':\n case 'ArrowDown': {\n const reverseOffset = isReverse() ? -1 : 1;\n if ($event.code === 'ArrowUp') {\n navigateBy(-1 * reverseOffset, $event);\n } else {\n navigateBy(1 * reverseOffset, $event);\n }\n }\n break;\n case 'Enter':\n case 'Space':\n if (!flattenedOptions.value[highlightedIndex.value].disabled) {\n clickOption(flattenedOptions.value[highlightedIndex.value]);\n $event.preventDefault();\n }\n break;\n case 'Tab':\n if (!$event.ctrlKey && !$event.metaKey && !$event.altKey) {\n open.value = false;\n }\n break;\n }\n }\n };\n\n const computedOptions = computed((): Array<NeonSelectGroup> => {\n return (\n props.groupedOptions || [\n {\n group: '',\n options: props.options || [],\n },\n ]\n );\n });\n\n const sanitizedAttributes = computed(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { ...sanitized } = attrs;\n return sanitized;\n });\n\n const computedLabel = computed(() => {\n if (props.multiple && props.modelValue.length > 0) {\n if (props.multiselectPlaceholder) {\n return props.multiselectPlaceholder;\n } else if (props.modelValue.length > 1) {\n return `${props.modelValue.length} items selected`;\n } else {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue[0]);\n return selected?.label || '';\n }\n } else if (props.modelValue) {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue);\n\n if (selected) {\n return selected.label;\n }\n }\n\n return props.placeholder;\n });\n\n const computedIcon = computed(() => {\n if (props.modelValue) {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue);\n\n if (selected) {\n return selected.icon;\n }\n }\n\n return props.placeholderIcon;\n });\n\n const nativeSelectChange = (event: Event) => {\n const selectedKeys = Array.from((event.target as HTMLSelectElement).options)\n .filter((opt) => opt.selected)\n .map((opt) => opt.value);\n const selectedOptions = flattenedOptions.value.filter((v) => selectedKeys.indexOf(v.key) >= 0);\n const value = props.multiple ? selectedOptions.map((value) => value.key) : selectedOptions[0].key;\n emitInputEvent(value);\n };\n\n const changeHighlighted = (key: string) => {\n highlightedKey.value = key;\n highlightedIndex.value = flattenedOptions.value.findIndex((opt) => opt.key === key);\n };\n\n const onPlacement = (placement: NeonDropdownPlacement) => {\n dropdownPlacement.value = placement;\n };\n\n onMounted(() => {\n document.addEventListener('keydown', keyboardHandler);\n });\n\n onUnmounted(() => {\n document.removeEventListener('keydown', keyboardHandler);\n });\n\n watch(\n () => open.value,\n (open: boolean) => {\n if (open) {\n highlightedKey.value = flattenedOptions.value[0].key;\n highlightedIndex.value = 0;\n }\n },\n );\n\n return {\n dropdown,\n open,\n highlightedKey,\n highlightedIndex,\n flattenedOptions,\n computedLabel,\n sanitizedAttributes,\n computedOptions,\n computedIcon,\n clickOption,\n nativeSelectChange,\n changeHighlighted,\n onPlacement,\n };\n },\n});\n"],"names":["value","open"],"mappings":";;;;;;;;AAiBA,IAAA,YAAe,gBAAgB;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IAIL,IAAI,EAAE,MAAM,OAAO;AAAA,IAInB,aAAa,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IAI5C,qBAAqB,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,IAIrD,iBAAiB,EAAE,MAAM,QAAQ,UAAU,MAAM;AAAA,IAIjD,SAAS,EAAE,MAAM,OAAwC,UAAU,MAAM;AAAA,IAIzE,gBAAgB,EAAE,MAAM,OAAuC,UAAU,MAAM;AAAA,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,EAC5B,IAAI,CAAC,QAAQ,IAAI,KAAK;AACnB,YAAA,kBAAkB,iBAAiB,MAAM,OAAO,CAAC,MAAM,aAAa,QAAQ,EAAE,GAAG,KAAK,CAAC;AACvF,YAAA,QAAQ,MAAM,WAAW,gBAAgB,IAAI,CAACA,WAAUA,OAAM,GAAG,IAAI,gBAAgB,GAAG;AAC9F,qBAAe,KAAK;AAAA,IAAA;AAGhB,UAAA,oBAAoB,CAAC,QAAgB;AACzC,qBAAe,QAAQ;AACN,uBAAA,QAAQ,iBAAiB,MAAM,UAAU,CAAC,QAAQ,IAAI,QAAQ,GAAG;AAAA,IAAA;AAG9E,UAAA,cAAc,CAAC,cAAqC;AACxD,wBAAkB,QAAQ;AAAA,IAAA;AAG5B,cAAU,MAAM;AACL,eAAA,iBAAiB,WAAW,eAAe;AAAA,IAAA,CACrD;AAED,gBAAY,MAAM;AACP,eAAA,oBAAoB,WAAW,eAAe;AAAA,IAAA,CACxD;AAED;AAAA,MACE,MAAM,KAAK;AAAA,MACX,CAACC,UAAkB;AACjB,YAAIA,OAAM;AACO,yBAAA,QAAQ,iBAAiB,MAAM,GAAG;AACjD,2BAAiB,QAAQ;AAAA,QAC3B;AAAA,MACF;AAAA,IAAA;AAGK,WAAA;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AACF,CAAC;;"}
|
|
@@ -4,12 +4,13 @@ export declare class NeonModeUtils {
|
|
|
4
4
|
private static defaultMode;
|
|
5
5
|
private static mode;
|
|
6
6
|
static getMode(): NeonMode | null;
|
|
7
|
+
static getCallbacks(): Record<string, (value: NeonMode) => void>;
|
|
7
8
|
static init(defaultMode?: NeonMode): void;
|
|
8
9
|
static addListener(key: string, callback: (value: NeonMode) => void): void;
|
|
9
10
|
static removeListener(key: string): void;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
static onDarkChange(e: MediaQueryListEvent): void;
|
|
12
|
+
static onLightChange(e: MediaQueryListEvent): void;
|
|
13
|
+
static onNoPreferenceChange(e: MediaQueryListEvent): void;
|
|
13
14
|
private static onChange;
|
|
14
15
|
private static handleChange;
|
|
15
16
|
}
|
|
@@ -61,6 +61,13 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
61
61
|
type: () => NeonFunctionalColor;
|
|
62
62
|
default: NeonFunctionalColor;
|
|
63
63
|
};
|
|
64
|
+
/**
|
|
65
|
+
* Placement of the dropdown contents.
|
|
66
|
+
*/
|
|
67
|
+
placement: {
|
|
68
|
+
type: () => NeonDropdownPlacement;
|
|
69
|
+
default: NeonDropdownPlacement;
|
|
70
|
+
};
|
|
64
71
|
}, {
|
|
65
72
|
dropdown: import("vue").Ref<HTMLElement | null>;
|
|
66
73
|
open: import("vue").Ref<boolean>;
|
|
@@ -70,6 +77,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
70
77
|
[x: string]: unknown;
|
|
71
78
|
}>;
|
|
72
79
|
computedOptions: import("vue").ComputedRef<NeonSearchOption[]>;
|
|
80
|
+
dropdownPlacement: import("vue").Ref<NeonDropdownPlacement>;
|
|
73
81
|
onPlacement: (placement: NeonDropdownPlacement) => void;
|
|
74
82
|
onFilterChange: (_filter: string) => void;
|
|
75
83
|
clickOption: (option: NeonSearchOption) => void;
|
|
@@ -127,12 +135,20 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
127
135
|
type: () => NeonFunctionalColor;
|
|
128
136
|
default: NeonFunctionalColor;
|
|
129
137
|
};
|
|
138
|
+
/**
|
|
139
|
+
* Placement of the dropdown contents.
|
|
140
|
+
*/
|
|
141
|
+
placement: {
|
|
142
|
+
type: () => NeonDropdownPlacement;
|
|
143
|
+
default: NeonDropdownPlacement;
|
|
144
|
+
};
|
|
130
145
|
}>> & {
|
|
131
146
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
132
147
|
"onFilter-changed"?: ((...args: any[]) => any) | undefined;
|
|
133
148
|
}, {
|
|
134
149
|
color: NeonFunctionalColor;
|
|
135
150
|
disabled: boolean;
|
|
151
|
+
placement: NeonDropdownPlacement;
|
|
136
152
|
size: NeonSize;
|
|
137
153
|
multiple: boolean;
|
|
138
154
|
}>;
|
|
@@ -94,6 +94,13 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
94
94
|
type: () => NeonFunctionalColor;
|
|
95
95
|
default: NeonFunctionalColor;
|
|
96
96
|
};
|
|
97
|
+
/**
|
|
98
|
+
* Placement of the dropdown contents.
|
|
99
|
+
*/
|
|
100
|
+
placement: {
|
|
101
|
+
type: () => NeonDropdownPlacement;
|
|
102
|
+
default: NeonDropdownPlacement;
|
|
103
|
+
};
|
|
97
104
|
}, {
|
|
98
105
|
dropdown: import("vue").Ref<HTMLElement | null>;
|
|
99
106
|
open: import("vue").Ref<boolean>;
|
|
@@ -195,11 +202,19 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
195
202
|
type: () => NeonFunctionalColor;
|
|
196
203
|
default: NeonFunctionalColor;
|
|
197
204
|
};
|
|
205
|
+
/**
|
|
206
|
+
* Placement of the dropdown contents.
|
|
207
|
+
*/
|
|
208
|
+
placement: {
|
|
209
|
+
type: () => NeonDropdownPlacement;
|
|
210
|
+
default: NeonDropdownPlacement;
|
|
211
|
+
};
|
|
198
212
|
}>> & {
|
|
199
213
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
200
214
|
}, {
|
|
201
215
|
color: NeonFunctionalColor;
|
|
202
216
|
disabled: boolean;
|
|
217
|
+
placement: NeonDropdownPlacement;
|
|
203
218
|
size: NeonSize;
|
|
204
219
|
multiple: boolean;
|
|
205
220
|
placeholderAsOption: boolean;
|
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": "10.1.
|
|
4
|
+
"version": "10.1.1",
|
|
5
5
|
"main": "./dist/neon.cjs.js",
|
|
6
6
|
"module": "./dist/neon.es.js",
|
|
7
7
|
"types": "./dist/src/neon.d.ts",
|
package/dist/components/user-input/search/NeonSearch.ts_vue_type_script_src_2630bb0d_lang.cjs.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var t=require("vue"),C=require("../../../common/enums/NeonSize.cjs.js"),P=require("../../../common/enums/NeonFunctionalColor.cjs.js"),A=require("../../presentation/dropdown/NeonDropdown.cjs.js"),x=require("../../presentation/icon/NeonIcon.cjs.js"),z=require("../input/NeonInput.cjs.js"),L=require("../chip/NeonChip.cjs.js"),c=require("../../../common/enums/NeonDropdownPlacement.cjs.js"),U=require("../../../common/utils/NeonScrollUtils.cjs.js"),V=t.defineComponent({name:"NeonSearch",components:{NeonChip:L,NeonDropdown:A,NeonIcon:x,NeonInput:z},props:{modelValue:{type:[String,Array],required:!0},placeholder:{type:String,required:!0},options:{type:Array,required:!0},multiple:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},size:{type:String,default:C.NeonSize.Medium},color:{type:String,default:P.NeonFunctionalColor.LowContrast}},emits:["update:modelValue","filter-changed"],setup(o,{emit:m}){const N=t.useAttrs(),p=t.ref(null),f=t.ref(null),a=t.ref(!1),s=t.ref(null),l=t.ref(-1),u=t.ref("");t.watch(()=>a.value,e=>{e&&o.options.length>0&&(s.value=o.options[0].key,l.value=0)});const w=()=>{switch(f.value){case c.NeonDropdownPlacement.TopLeft:case c.NeonDropdownPlacement.TopRight:case c.NeonDropdownPlacement.LeftBottom:case c.NeonDropdownPlacement.RightBottom:return!0}return!1},j=()=>{var n;const e=(n=p.value)==null?void 0:n.querySelector(".neon-search__option--highlighted");U.NeonScrollUtils.scrollIntoView(e)},v=(e,n)=>{const r=l.value+e;r>=0&&r<=o.options.length-1&&(l.value=r,s.value=o.options[l.value].key,n.preventDefault(),setTimeout(j))},i=e=>{m("update:modelValue",e)},h=e=>{o.multiple||i(""),u.value=e,m("filter-changed",e)},g=e=>{if(o.multiple){const n=o.modelValue.map(d=>d),r=n.findIndex(d=>d.key===e.key);r>=0?n.splice(r,1):n.push(e),i(n)}else i(e.key);h(o.multiple?"":e.label.toString())},y=e=>{if(a.value)switch(e.code){case"ArrowUp":case"ArrowDown":{const n=w()?-1:1;e.code==="ArrowUp"?v(-1*n,e):v(1*n,e)}break;case"Enter":case"Space":e.target.classList.contains("neon-search__input")||(g(o.options[l.value]),e.preventDefault());break;case"Tab":!e.ctrlKey&&!e.metaKey&&!e.altKey&&(a.value=!1);break}},S=e=>{f.value=e};t.onMounted(()=>{document.addEventListener("keydown",y)}),t.onUnmounted(()=>{document.removeEventListener("keydown",y)});const k=t.computed(()=>{const{onFilterChanged:e,...n}=N;return n}),q=e=>{s.value=e,l.value=o.options.findIndex(n=>n.key===e)},D=()=>a.value=!0,I=e=>i(o.modelValue.filter(n=>n.key!==e.key)),b=t.computed(()=>o.multiple?o.options:o.options.filter(e=>e.label!==u.value));return{dropdown:p,open:a,highlightedKey:s,filter:u,sanitizedAttributes:k,computedOptions:b,onPlacement:S,onFilterChange:h,clickOption:g,changeHighlighted:q,showOptions:D,removeSelected:I}}});module.exports=V;
|
|
2
|
-
//# sourceMappingURL=NeonSearch.ts_vue_type_script_src_2630bb0d_lang.cjs.js.map
|
package/dist/components/user-input/search/NeonSearch.ts_vue_type_script_src_2630bb0d_lang.cjs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NeonSearch.ts_vue_type_script_src_2630bb0d_lang.cjs.js","sources":["../../../../src/components/user-input/search/NeonSearch.ts?vue&type=script&src=2630bb0d&lang.ts"],"sourcesContent":["import { computed, defineComponent, onMounted, onUnmounted, ref, useAttrs, watch } from 'vue';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport NeonDropdown from '@/components/presentation/dropdown/NeonDropdown.vue';\nimport NeonIcon from '@/components/presentation/icon/NeonIcon.vue';\nimport type { NeonSearchOption } from '@/common/models/NeonSearchOption';\nimport NeonInput from '@/components/user-input/input/NeonInput.vue';\nimport NeonChip from '@/components/user-input/chip/NeonChip.vue';\nimport { NeonDropdownPlacement } from '@/common/enums/NeonDropdownPlacement';\nimport { NeonScrollUtils } from '@/common/utils/NeonScrollUtils';\n\n/**\n * <p>\n * The <strong>NeonSearch</strong> component is equivalent to an HTML <input type=\"search\"> element. It is\n * useful as an alternative to <em>NeonSelect</em> to provide filtered results when the universe of results is very\n * large and/or the results need to be requested from a server side API.\n * </p>\n * <p><strong>NeonSearch</strong> provides input chips in the case the search allows multiple selection.</p>\n */\nexport default defineComponent({\n name: 'NeonSearch',\n components: {\n NeonChip,\n NeonDropdown,\n NeonIcon,\n NeonInput,\n },\n props: {\n /**\n * Either a string indicating the key of the selected option ('' if there is no selection) or an array of selected\n * NeonSearchOption in the case when multiple = true (necessary to display them as chips).\n */\n modelValue: { type: [String, Array as () => Array<NeonSearchOption>], required: true },\n /**\n * Placeholder to display in search input when there is no search string entered.\n */\n placeholder: { type: String, required: true },\n /**\n * The list of search results.\n */\n options: { type: Array as () => Array<NeonSearchOption>, required: true },\n /**\n * Allow multi-select.\n */\n multiple: { type: Boolean, default: false },\n /**\n * Disable the search\n */\n disabled: { type: Boolean, default: false },\n /**\n * The size of the dropdown - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The color of the search.\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n },\n emits: [\n /**\n * emitted when the user changes the selection.\n * @type {string | NeonSearchOption[]} either the selected option's key (single select) or an array of the\n * selected options (multi-select).\n */\n 'update:modelValue',\n /**\n * emitted when the user types in filter box.\n * @type {string} the current filter criteria. This can be used by the application to filter the displayed options.\n */\n 'filter-changed',\n ],\n setup(props, { emit }) {\n const attrs = useAttrs();\n\n const dropdown = ref<HTMLElement | null>(null);\n const dropdownPlacement = ref<NeonDropdownPlacement | null>(null);\n\n const open = ref(false);\n const highlightedKey = ref<string | null>(null);\n const highlightedIndex = ref(-1);\n const filter = ref('');\n\n watch(\n () => open.value,\n (open: boolean) => {\n if (open && props.options.length > 0) {\n highlightedKey.value = props.options[0].key;\n highlightedIndex.value = 0;\n }\n },\n );\n\n const isReverse = () => {\n switch (dropdownPlacement.value) {\n case NeonDropdownPlacement.TopLeft:\n case NeonDropdownPlacement.TopRight:\n case NeonDropdownPlacement.LeftBottom:\n case NeonDropdownPlacement.RightBottom:\n return true;\n }\n\n return false;\n };\n\n const scrollOnNavigate = () => {\n const element = dropdown.value?.querySelector('.neon-search__option--highlighted') as HTMLElement;\n NeonScrollUtils.scrollIntoView(element);\n };\n\n const navigateBy = (offset: number, $event: KeyboardEvent) => {\n const newIndex = highlightedIndex.value + offset;\n if (newIndex >= 0 && newIndex <= props.options.length - 1) {\n highlightedIndex.value = newIndex;\n highlightedKey.value = props.options[highlightedIndex.value].key;\n $event.preventDefault();\n setTimeout(scrollOnNavigate);\n }\n };\n\n const emitInputEvent = (value: string | NeonSearchOption[]) => {\n emit('update:modelValue', value);\n };\n\n const onFilterChange = (_filter: string) => {\n if (!props.multiple) {\n emitInputEvent('');\n }\n\n filter.value = _filter;\n emit('filter-changed', _filter);\n };\n\n const clickOption = (option: NeonSearchOption) => {\n if (props.multiple) {\n const values = (props.modelValue as NeonSearchOption[]).map((v) => v);\n const index = values.findIndex((v) => v.key === option.key);\n if (index >= 0) {\n values.splice(index, 1);\n } else {\n values.push(option);\n }\n emitInputEvent(values);\n } else {\n emitInputEvent(option.key);\n }\n\n onFilterChange(props.multiple ? '' : option.label.toString());\n };\n\n const keyboardHandler = ($event: KeyboardEvent) => {\n if (open.value) {\n switch ($event.code) {\n case 'ArrowUp':\n case 'ArrowDown':\n {\n const reverseOffset = isReverse() ? -1 : 1;\n if ($event.code === 'ArrowUp') {\n navigateBy(-1 * reverseOffset, $event);\n } else {\n navigateBy(1 * reverseOffset, $event);\n }\n }\n break;\n case 'Enter':\n case 'Space':\n if (!($event.target as HTMLElement).classList.contains('neon-search__input')) {\n clickOption(props.options[highlightedIndex.value]);\n $event.preventDefault();\n }\n break;\n case 'Tab':\n if (!$event.ctrlKey && !$event.metaKey && !$event.altKey) {\n open.value = false;\n }\n break;\n }\n }\n };\n\n const onPlacement = (placement: NeonDropdownPlacement) => {\n dropdownPlacement.value = placement;\n };\n\n onMounted(() => {\n document.addEventListener('keydown', keyboardHandler);\n });\n\n onUnmounted(() => {\n document.removeEventListener('keydown', keyboardHandler);\n });\n\n const sanitizedAttributes = computed(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { onFilterChanged, ...sanitized } = attrs;\n return sanitized;\n });\n\n const changeHighlighted = (key: string) => {\n highlightedKey.value = key;\n highlightedIndex.value = props.options.findIndex((opt) => opt.key === key);\n };\n\n const showOptions = () => (open.value = true);\n\n const removeSelected = (removed: NeonSearchOption) =>\n emitInputEvent((props.modelValue as NeonSearchOption[]).filter((v) => v.key !== removed.key));\n\n const computedOptions = computed(() => {\n return props.multiple ? props.options : props.options.filter((opt) => opt.label !== filter.value);\n });\n\n return {\n dropdown,\n open,\n highlightedKey,\n filter,\n sanitizedAttributes,\n computedOptions,\n onPlacement,\n onFilterChange,\n clickOption,\n changeHighlighted,\n showOptions,\n removeSelected,\n };\n },\n});\n"],"names":["_sfc_main","defineComponent","NeonChip","NeonDropdown","NeonIcon","NeonInput","NeonSize","NeonFunctionalColor","props","emit","attrs","useAttrs","dropdown","ref","dropdownPlacement","open","highlightedKey","highlightedIndex","filter","watch","isReverse","NeonDropdownPlacement","scrollOnNavigate","element","_a","NeonScrollUtils","navigateBy","offset","$event","newIndex","emitInputEvent","value","onFilterChange","_filter","clickOption","option","values","v","index","keyboardHandler","reverseOffset","onPlacement","placement","onMounted","onUnmounted","sanitizedAttributes","computed","onFilterChanged","sanitized","changeHighlighted","key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Q4B,CAAA,EAG5BC,EAAAA,UAAU,IAAM,CACL,SAAA,iBAAiB,UAAWJ,CAAe,CAAA,CACrD,EAEDK,EAAAA,YAAY,IAAM,CACP,SAAA,oBAAoB,UAAWL,CAAe,CAAA,CACxD,EAEK,MAAAM,EAAsBC,EAAAA,SAAS,IAAM,CAEnC,KAAA,CAAE,gBAAAC,KAAoBC,CAAA,EAActC,EACnC,OAAAsC,CAAA,CACR,EAEKC,EAAqBC,GAAgB,CACzClC,EAAe,MAAQkC,EACNjC,EAAA,MAAQT,EAAM,QAAQ,UAAW2C,GAAQA,EAAI,MAAQD,CAAG,CAAA,EAGrEE,EAAc,IAAOrC,EAAK,MAAQ,GAElCsC,EAAkBC,GACtBxB,EAAgBtB,EAAM,WAAkC,OAAQ6B,GAAMA,EAAE,MAAQiB,EAAQ,GAAG,CAAC,EAExFC,EAAkBT,EAAAA,SAAS,IACxBtC,EAAM,SAAWA,EAAM,QAAUA,EAAM,QAAQ,OAAQ2C,GAAQA,EAAI,QAAUjC,EAAO,KAAK,CACjG,EAEM,MAAA,CACL,SAAAN,EACA,KAAAG,EACA,eAAAC,EACA,OAAAE,EACA,oBAAA2B,EACA,gBAAAU,EACA,YAAAd,EACA,eAAAT,EACA,YAAAE,EACA,kBAAAe,EACA,YAAAG,EACA,eAAAC,CAAA,CAEJ,CACF,CAAC"}
|
package/dist/components/user-input/search/NeonSearch.ts_vue_type_script_src_2630bb0d_lang.es.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NeonSearch.ts_vue_type_script_src_2630bb0d_lang.es.js","sources":["../../../../src/components/user-input/search/NeonSearch.ts?vue&type=script&src=2630bb0d&lang.ts"],"sourcesContent":["import { computed, defineComponent, onMounted, onUnmounted, ref, useAttrs, watch } from 'vue';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport NeonDropdown from '@/components/presentation/dropdown/NeonDropdown.vue';\nimport NeonIcon from '@/components/presentation/icon/NeonIcon.vue';\nimport type { NeonSearchOption } from '@/common/models/NeonSearchOption';\nimport NeonInput from '@/components/user-input/input/NeonInput.vue';\nimport NeonChip from '@/components/user-input/chip/NeonChip.vue';\nimport { NeonDropdownPlacement } from '@/common/enums/NeonDropdownPlacement';\nimport { NeonScrollUtils } from '@/common/utils/NeonScrollUtils';\n\n/**\n * <p>\n * The <strong>NeonSearch</strong> component is equivalent to an HTML <input type=\"search\"> element. It is\n * useful as an alternative to <em>NeonSelect</em> to provide filtered results when the universe of results is very\n * large and/or the results need to be requested from a server side API.\n * </p>\n * <p><strong>NeonSearch</strong> provides input chips in the case the search allows multiple selection.</p>\n */\nexport default defineComponent({\n name: 'NeonSearch',\n components: {\n NeonChip,\n NeonDropdown,\n NeonIcon,\n NeonInput,\n },\n props: {\n /**\n * Either a string indicating the key of the selected option ('' if there is no selection) or an array of selected\n * NeonSearchOption in the case when multiple = true (necessary to display them as chips).\n */\n modelValue: { type: [String, Array as () => Array<NeonSearchOption>], required: true },\n /**\n * Placeholder to display in search input when there is no search string entered.\n */\n placeholder: { type: String, required: true },\n /**\n * The list of search results.\n */\n options: { type: Array as () => Array<NeonSearchOption>, required: true },\n /**\n * Allow multi-select.\n */\n multiple: { type: Boolean, default: false },\n /**\n * Disable the search\n */\n disabled: { type: Boolean, default: false },\n /**\n * The size of the dropdown - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The color of the search.\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n },\n emits: [\n /**\n * emitted when the user changes the selection.\n * @type {string | NeonSearchOption[]} either the selected option's key (single select) or an array of the\n * selected options (multi-select).\n */\n 'update:modelValue',\n /**\n * emitted when the user types in filter box.\n * @type {string} the current filter criteria. This can be used by the application to filter the displayed options.\n */\n 'filter-changed',\n ],\n setup(props, { emit }) {\n const attrs = useAttrs();\n\n const dropdown = ref<HTMLElement | null>(null);\n const dropdownPlacement = ref<NeonDropdownPlacement | null>(null);\n\n const open = ref(false);\n const highlightedKey = ref<string | null>(null);\n const highlightedIndex = ref(-1);\n const filter = ref('');\n\n watch(\n () => open.value,\n (open: boolean) => {\n if (open && props.options.length > 0) {\n highlightedKey.value = props.options[0].key;\n highlightedIndex.value = 0;\n }\n },\n );\n\n const isReverse = () => {\n switch (dropdownPlacement.value) {\n case NeonDropdownPlacement.TopLeft:\n case NeonDropdownPlacement.TopRight:\n case NeonDropdownPlacement.LeftBottom:\n case NeonDropdownPlacement.RightBottom:\n return true;\n }\n\n return false;\n };\n\n const scrollOnNavigate = () => {\n const element = dropdown.value?.querySelector('.neon-search__option--highlighted') as HTMLElement;\n NeonScrollUtils.scrollIntoView(element);\n };\n\n const navigateBy = (offset: number, $event: KeyboardEvent) => {\n const newIndex = highlightedIndex.value + offset;\n if (newIndex >= 0 && newIndex <= props.options.length - 1) {\n highlightedIndex.value = newIndex;\n highlightedKey.value = props.options[highlightedIndex.value].key;\n $event.preventDefault();\n setTimeout(scrollOnNavigate);\n }\n };\n\n const emitInputEvent = (value: string | NeonSearchOption[]) => {\n emit('update:modelValue', value);\n };\n\n const onFilterChange = (_filter: string) => {\n if (!props.multiple) {\n emitInputEvent('');\n }\n\n filter.value = _filter;\n emit('filter-changed', _filter);\n };\n\n const clickOption = (option: NeonSearchOption) => {\n if (props.multiple) {\n const values = (props.modelValue as NeonSearchOption[]).map((v) => v);\n const index = values.findIndex((v) => v.key === option.key);\n if (index >= 0) {\n values.splice(index, 1);\n } else {\n values.push(option);\n }\n emitInputEvent(values);\n } else {\n emitInputEvent(option.key);\n }\n\n onFilterChange(props.multiple ? '' : option.label.toString());\n };\n\n const keyboardHandler = ($event: KeyboardEvent) => {\n if (open.value) {\n switch ($event.code) {\n case 'ArrowUp':\n case 'ArrowDown':\n {\n const reverseOffset = isReverse() ? -1 : 1;\n if ($event.code === 'ArrowUp') {\n navigateBy(-1 * reverseOffset, $event);\n } else {\n navigateBy(1 * reverseOffset, $event);\n }\n }\n break;\n case 'Enter':\n case 'Space':\n if (!($event.target as HTMLElement).classList.contains('neon-search__input')) {\n clickOption(props.options[highlightedIndex.value]);\n $event.preventDefault();\n }\n break;\n case 'Tab':\n if (!$event.ctrlKey && !$event.metaKey && !$event.altKey) {\n open.value = false;\n }\n break;\n }\n }\n };\n\n const onPlacement = (placement: NeonDropdownPlacement) => {\n dropdownPlacement.value = placement;\n };\n\n onMounted(() => {\n document.addEventListener('keydown', keyboardHandler);\n });\n\n onUnmounted(() => {\n document.removeEventListener('keydown', keyboardHandler);\n });\n\n const sanitizedAttributes = computed(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { onFilterChanged, ...sanitized } = attrs;\n return sanitized;\n });\n\n const changeHighlighted = (key: string) => {\n highlightedKey.value = key;\n highlightedIndex.value = props.options.findIndex((opt) => opt.key === key);\n };\n\n const showOptions = () => (open.value = true);\n\n const removeSelected = (removed: NeonSearchOption) =>\n emitInputEvent((props.modelValue as NeonSearchOption[]).filter((v) => v.key !== removed.key));\n\n const computedOptions = computed(() => {\n return props.multiple ? props.options : props.options.filter((opt) => opt.label !== filter.value);\n });\n\n return {\n dropdown,\n open,\n highlightedKey,\n filter,\n sanitizedAttributes,\n computedOptions,\n onPlacement,\n onFilterChange,\n clickOption,\n changeHighlighted,\n showOptions,\n removeSelected,\n };\n },\n});\n"],"names":["open"],"mappings":";;;;;;;;;AAmBA,IAAA,YAAe,gBAAgB;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IAKL,YAAY,EAAE,MAAM,CAAC,QAAQ,KAAsC,GAAG,UAAU,KAAK;AAAA,IAIrF,aAAa,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IAI5C,SAAS,EAAE,MAAM,OAAwC,UAAU,KAAK;AAAA,IAIxE,UAAU,EAAE,MAAM,SAAS,SAAS,MAAM;A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