vuetify 3.9.0-beta.0 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_component-variables-labs.sass +1 -0
- package/dist/json/attributes.json +3590 -3502
- package/dist/json/importMap-labs.json +16 -12
- package/dist/json/importMap.json +186 -186
- package/dist/json/tags.json +31 -4
- package/dist/json/web-types.json +6626 -6392
- package/dist/vuetify-labs.cjs +1082 -195
- package/dist/vuetify-labs.css +4654 -4339
- package/dist/vuetify-labs.d.ts +2027 -493
- package/dist/vuetify-labs.esm.js +1082 -196
- package/dist/vuetify-labs.esm.js.map +1 -1
- package/dist/vuetify-labs.js +1082 -195
- package/dist/vuetify-labs.min.css +2 -2
- package/dist/vuetify.cjs +663 -170
- package/dist/vuetify.cjs.map +1 -1
- package/dist/vuetify.css +4744 -4671
- package/dist/vuetify.d.ts +1575 -267
- package/dist/vuetify.esm.js +663 -171
- package/dist/vuetify.esm.js.map +1 -1
- package/dist/vuetify.js +663 -170
- package/dist/vuetify.js.map +1 -1
- package/dist/vuetify.min.css +2 -2
- package/dist/vuetify.min.js +1182 -1126
- package/dist/vuetify.min.js.map +1 -1
- package/lib/components/VAutocomplete/VAutocomplete.d.ts +39 -14
- package/lib/components/VAutocomplete/VAutocomplete.js +2 -2
- package/lib/components/VAutocomplete/VAutocomplete.js.map +1 -1
- package/lib/components/VBtn/VBtn.sass +3 -1
- package/lib/components/VCarousel/VCarousel.css +0 -1
- package/lib/components/VCarousel/VCarousel.js +1 -0
- package/lib/components/VCarousel/VCarousel.js.map +1 -1
- package/lib/components/VCarousel/VCarousel.sass +0 -1
- package/lib/components/VCombobox/VCombobox.d.ts +39 -14
- package/lib/components/VCombobox/VCombobox.js +2 -2
- package/lib/components/VCombobox/VCombobox.js.map +1 -1
- package/lib/components/VDataIterator/composables/items.d.ts +2 -1
- package/lib/components/VDataIterator/composables/items.js.map +1 -1
- package/lib/components/VDataTable/VDataTable.css +12 -1
- package/lib/components/VDataTable/VDataTable.d.ts +20 -38
- package/lib/components/VDataTable/VDataTable.sass +12 -2
- package/lib/components/VDataTable/VDataTableColumn.d.ts +9 -3
- package/lib/components/VDataTable/VDataTableColumn.js +12 -4
- package/lib/components/VDataTable/VDataTableColumn.js.map +1 -1
- package/lib/components/VDataTable/VDataTableHeaders.d.ts +0 -13
- package/lib/components/VDataTable/VDataTableHeaders.js +10 -9
- package/lib/components/VDataTable/VDataTableHeaders.js.map +1 -1
- package/lib/components/VDataTable/VDataTableRow.js +2 -0
- package/lib/components/VDataTable/VDataTableRow.js.map +1 -1
- package/lib/components/VDataTable/VDataTableServer.d.ts +10 -23
- package/lib/components/VDataTable/VDataTableVirtual.d.ts +10 -23
- package/lib/components/VDataTable/composables/headers.d.ts +22 -14
- package/lib/components/VDataTable/composables/headers.js +51 -22
- package/lib/components/VDataTable/composables/headers.js.map +1 -1
- package/lib/components/VDataTable/composables/sort.js +2 -1
- package/lib/components/VDataTable/composables/sort.js.map +1 -1
- package/lib/components/VDataTable/types.d.ts +4 -2
- package/lib/components/VDataTable/types.js.map +1 -1
- package/lib/components/VDatePicker/VDatePicker.js +2 -1
- package/lib/components/VDatePicker/VDatePicker.js.map +1 -1
- package/lib/components/VDatePicker/VDatePickerControls.css +1 -0
- package/lib/components/VDatePicker/VDatePickerControls.sass +1 -0
- package/lib/components/VDatePicker/VDatePickerMonth.css +3 -8
- package/lib/components/VDatePicker/VDatePickerMonth.js +7 -3
- package/lib/components/VDatePicker/VDatePickerMonth.js.map +1 -1
- package/lib/components/VDatePicker/VDatePickerMonth.sass +3 -8
- package/lib/components/VField/VField.js +2 -10
- package/lib/components/VField/VField.js.map +1 -1
- package/lib/components/VKbd/VKbd.css +14 -5
- package/lib/components/VKbd/VKbd.js.map +1 -1
- package/lib/components/VKbd/VKbd.scss +26 -0
- package/lib/components/VKbd/_variables.scss +12 -6
- package/lib/components/VKbd/index.js.map +1 -1
- package/lib/components/VList/VList.d.ts +24 -27
- package/lib/components/VList/VList.js +1 -5
- package/lib/components/VList/VList.js.map +1 -1
- package/lib/components/VList/VListGroup.d.ts +13 -0
- package/lib/components/VList/VListGroup.js +2 -1
- package/lib/components/VList/VListGroup.js.map +1 -1
- package/lib/components/VList/VListItem.d.ts +6 -3
- package/lib/components/VList/VListItem.js +1 -1
- package/lib/components/VList/VListItem.js.map +1 -1
- package/lib/components/VNumberInput/VNumberInput.js +4 -10
- package/lib/components/VNumberInput/VNumberInput.js.map +1 -1
- package/lib/components/VNumberInput/hold.js +4 -0
- package/lib/components/VNumberInput/hold.js.map +1 -1
- package/lib/components/VOtpInput/VOtpInput.js +17 -14
- package/lib/components/VOtpInput/VOtpInput.js.map +1 -1
- package/lib/components/VOverlay/locationStrategies.js +1 -1
- package/lib/components/VOverlay/locationStrategies.js.map +1 -1
- package/lib/components/VSelect/VSelect.d.ts +58 -22
- package/lib/components/VSelect/VSelect.js +2 -2
- package/lib/components/VSelect/VSelect.js.map +1 -1
- package/lib/components/VTextField/VTextField.js +1 -1
- package/lib/components/VTextField/VTextField.js.map +1 -1
- package/lib/components/VTimePicker/VTimePicker.css +1 -6
- package/lib/components/VTimePicker/VTimePicker.sass +1 -6
- package/lib/components/VTimePicker/VTimePickerClock.css +5 -4
- package/lib/components/VTimePicker/VTimePickerClock.sass +5 -4
- package/lib/components/VTimePicker/VTimePickerControls.css +2 -1
- package/lib/components/VTimePicker/VTimePickerControls.sass +2 -3
- package/lib/components/VTreeview/VTreeview.d.ts +235 -188
- package/lib/components/VTreeview/VTreeview.js +13 -12
- package/lib/components/VTreeview/VTreeview.js.map +1 -1
- package/lib/components/VTreeview/VTreeviewChildren.d.ts +94 -10
- package/lib/components/VTreeview/VTreeviewChildren.js +61 -17
- package/lib/components/VTreeview/VTreeviewChildren.js.map +1 -1
- package/lib/components/VTreeview/VTreeviewGroup.d.ts +13 -0
- package/lib/components/VTreeview/VTreeviewItem.css +57 -0
- package/lib/components/VTreeview/VTreeviewItem.d.ts +1334 -97
- package/lib/components/VTreeview/VTreeviewItem.js +25 -16
- package/lib/components/VTreeview/VTreeviewItem.js.map +1 -1
- package/lib/components/VTreeview/VTreeviewItem.sass +60 -0
- package/lib/components/VTreeview/_variables.scss +15 -0
- package/lib/composables/calendar.d.ts +2 -1
- package/lib/composables/calendar.js +8 -8
- package/lib/composables/calendar.js.map +1 -1
- package/lib/composables/date/adapters/vuetify.js +1 -1
- package/lib/composables/date/adapters/vuetify.js.map +1 -1
- package/lib/composables/filter.d.ts +1 -0
- package/lib/composables/filter.js +1 -1
- package/lib/composables/filter.js.map +1 -1
- package/lib/composables/hotkey/hotkey-parsing.d.ts +15 -0
- package/lib/composables/hotkey/hotkey-parsing.js +154 -0
- package/lib/composables/hotkey/hotkey-parsing.js.map +1 -0
- package/lib/composables/hotkey/hotkey.d.ts +9 -0
- package/lib/composables/{hotkey.js → hotkey/hotkey.js} +31 -39
- package/lib/composables/hotkey/hotkey.js.map +1 -0
- package/lib/composables/hotkey/index.d.ts +1 -0
- package/lib/composables/hotkey/index.js +2 -0
- package/lib/composables/hotkey/index.js.map +1 -0
- package/lib/composables/hotkey/key-aliases.d.ts +14 -0
- package/lib/composables/hotkey/key-aliases.js +38 -0
- package/lib/composables/hotkey/key-aliases.js.map +1 -0
- package/lib/composables/icons.d.ts +11 -0
- package/lib/composables/icons.js.map +1 -1
- package/lib/composables/index.d.ts +1 -0
- package/lib/composables/index.js +1 -0
- package/lib/composables/index.js.map +1 -1
- package/lib/composables/list-items.d.ts +14 -1
- package/lib/composables/list-items.js +9 -3
- package/lib/composables/list-items.js.map +1 -1
- package/lib/composables/nested/nested.d.ts +7 -4
- package/lib/composables/nested/nested.js +24 -14
- package/lib/composables/nested/nested.js.map +1 -1
- package/lib/composables/nested/selectStrategies.d.ts +2 -1
- package/lib/composables/nested/selectStrategies.js +22 -11
- package/lib/composables/nested/selectStrategies.js.map +1 -1
- package/lib/composables/virtual.js +1 -1
- package/lib/composables/virtual.js.map +1 -1
- package/lib/entry-bundler.js +1 -1
- package/lib/entry-bundler.js.map +1 -1
- package/lib/framework.d.ts +91 -66
- package/lib/framework.js +1 -1
- package/lib/framework.js.map +1 -1
- package/lib/iconsets/fa.js +12 -1
- package/lib/iconsets/fa.js.map +1 -1
- package/lib/iconsets/fa4.js +12 -1
- package/lib/iconsets/fa4.js.map +1 -1
- package/lib/iconsets/md.js +12 -1
- package/lib/iconsets/md.js.map +1 -1
- package/lib/iconsets/mdi-svg.js +12 -1
- package/lib/iconsets/mdi-svg.js.map +1 -1
- package/lib/iconsets/mdi.js +12 -1
- package/lib/iconsets/mdi.js.map +1 -1
- package/lib/labs/VCalendar/VCalendar.d.ts +33 -33
- package/lib/labs/VCalendar/VCalendar.js +10 -10
- package/lib/labs/VCalendar/VCalendar.js.map +1 -1
- package/lib/labs/VCalendar/VCalendarDay.d.ts +33 -33
- package/lib/labs/VCalendar/VCalendarDay.js +1 -1
- package/lib/labs/VCalendar/VCalendarDay.js.map +1 -1
- package/lib/labs/VCalendar/VCalendarInterval.d.ts +36 -36
- package/lib/labs/VCalendar/VCalendarInterval.js +9 -9
- package/lib/labs/VCalendar/VCalendarInterval.js.map +1 -1
- package/lib/labs/VCalendar/VCalendarIntervalEvent.d.ts +12 -12
- package/lib/labs/VCalendar/VCalendarIntervalEvent.js +1 -1
- package/lib/labs/VCalendar/VCalendarIntervalEvent.js.map +1 -1
- package/lib/labs/VCalendar/VCalendarMonthDay.d.ts +36 -36
- package/lib/labs/VCalendar/VCalendarMonthDay.js +4 -4
- package/lib/labs/VCalendar/VCalendarMonthDay.js.map +1 -1
- package/lib/labs/VHotkey/VHotkey.css +242 -0
- package/lib/labs/VHotkey/VHotkey.d.ts +387 -0
- package/lib/labs/VHotkey/VHotkey.js +432 -0
- package/lib/labs/VHotkey/VHotkey.js.map +1 -0
- package/lib/labs/VHotkey/VHotkey.scss +253 -0
- package/lib/labs/VHotkey/_variables.scss +43 -0
- package/lib/labs/VHotkey/index.d.ts +1 -0
- package/lib/labs/VHotkey/index.js +2 -0
- package/lib/labs/VHotkey/index.js.map +1 -0
- package/lib/labs/VIconBtn/VIconBtn.js +1 -0
- package/lib/labs/VIconBtn/VIconBtn.js.map +1 -1
- package/lib/labs/VPicker/VPicker.css +4 -0
- package/lib/labs/VPicker/VPicker.sass +4 -0
- package/lib/labs/components.d.ts +1 -0
- package/lib/labs/components.js +1 -0
- package/lib/labs/components.js.map +1 -1
- package/lib/locale/af.d.ts +18 -0
- package/lib/locale/af.js +18 -0
- package/lib/locale/af.js.map +1 -1
- package/lib/locale/ar.d.ts +18 -0
- package/lib/locale/ar.js +18 -0
- package/lib/locale/ar.js.map +1 -1
- package/lib/locale/az.d.ts +18 -0
- package/lib/locale/az.js +18 -0
- package/lib/locale/az.js.map +1 -1
- package/lib/locale/bg.d.ts +18 -0
- package/lib/locale/bg.js +18 -0
- package/lib/locale/bg.js.map +1 -1
- package/lib/locale/ca.d.ts +18 -0
- package/lib/locale/ca.js +18 -0
- package/lib/locale/ca.js.map +1 -1
- package/lib/locale/ckb.d.ts +18 -0
- package/lib/locale/ckb.js +18 -0
- package/lib/locale/ckb.js.map +1 -1
- package/lib/locale/cs.d.ts +18 -0
- package/lib/locale/cs.js +18 -0
- package/lib/locale/cs.js.map +1 -1
- package/lib/locale/da.d.ts +18 -0
- package/lib/locale/da.js +18 -0
- package/lib/locale/da.js.map +1 -1
- package/lib/locale/de.d.ts +18 -0
- package/lib/locale/de.js +18 -0
- package/lib/locale/de.js.map +1 -1
- package/lib/locale/el.d.ts +18 -0
- package/lib/locale/el.js +18 -0
- package/lib/locale/el.js.map +1 -1
- package/lib/locale/en.d.ts +18 -0
- package/lib/locale/en.js +18 -0
- package/lib/locale/en.js.map +1 -1
- package/lib/locale/es.d.ts +18 -0
- package/lib/locale/es.js +18 -0
- package/lib/locale/es.js.map +1 -1
- package/lib/locale/et.d.ts +18 -0
- package/lib/locale/et.js +18 -0
- package/lib/locale/et.js.map +1 -1
- package/lib/locale/fa.d.ts +18 -0
- package/lib/locale/fa.js +18 -0
- package/lib/locale/fa.js.map +1 -1
- package/lib/locale/fi.d.ts +18 -0
- package/lib/locale/fi.js +18 -0
- package/lib/locale/fi.js.map +1 -1
- package/lib/locale/fr.d.ts +18 -0
- package/lib/locale/fr.js +18 -0
- package/lib/locale/fr.js.map +1 -1
- package/lib/locale/he.d.ts +18 -0
- package/lib/locale/he.js +18 -0
- package/lib/locale/he.js.map +1 -1
- package/lib/locale/hr.d.ts +18 -0
- package/lib/locale/hr.js +18 -0
- package/lib/locale/hr.js.map +1 -1
- package/lib/locale/hu.d.ts +18 -0
- package/lib/locale/hu.js +18 -0
- package/lib/locale/hu.js.map +1 -1
- package/lib/locale/id.d.ts +18 -0
- package/lib/locale/id.js +18 -0
- package/lib/locale/id.js.map +1 -1
- package/lib/locale/it.d.ts +18 -0
- package/lib/locale/it.js +18 -0
- package/lib/locale/it.js.map +1 -1
- package/lib/locale/ja.d.ts +18 -0
- package/lib/locale/ja.js +18 -0
- package/lib/locale/ja.js.map +1 -1
- package/lib/locale/km.d.ts +18 -0
- package/lib/locale/km.js +18 -0
- package/lib/locale/km.js.map +1 -1
- package/lib/locale/ko.d.ts +18 -0
- package/lib/locale/ko.js +18 -0
- package/lib/locale/ko.js.map +1 -1
- package/lib/locale/lt.d.ts +18 -0
- package/lib/locale/lt.js +18 -0
- package/lib/locale/lt.js.map +1 -1
- package/lib/locale/lv.d.ts +18 -0
- package/lib/locale/lv.js +18 -0
- package/lib/locale/lv.js.map +1 -1
- package/lib/locale/nl.d.ts +18 -0
- package/lib/locale/nl.js +18 -0
- package/lib/locale/nl.js.map +1 -1
- package/lib/locale/no.d.ts +18 -0
- package/lib/locale/no.js +18 -0
- package/lib/locale/no.js.map +1 -1
- package/lib/locale/pl.d.ts +18 -0
- package/lib/locale/pl.js +18 -0
- package/lib/locale/pl.js.map +1 -1
- package/lib/locale/pt.d.ts +18 -0
- package/lib/locale/pt.js +18 -0
- package/lib/locale/pt.js.map +1 -1
- package/lib/locale/ro.d.ts +18 -0
- package/lib/locale/ro.js +18 -0
- package/lib/locale/ro.js.map +1 -1
- package/lib/locale/ru.d.ts +18 -0
- package/lib/locale/ru.js +18 -0
- package/lib/locale/ru.js.map +1 -1
- package/lib/locale/sk.d.ts +18 -0
- package/lib/locale/sk.js +18 -0
- package/lib/locale/sk.js.map +1 -1
- package/lib/locale/sl.d.ts +18 -0
- package/lib/locale/sl.js +18 -0
- package/lib/locale/sl.js.map +1 -1
- package/lib/locale/sr-Cyrl.d.ts +18 -0
- package/lib/locale/sr-Cyrl.js +18 -0
- package/lib/locale/sr-Cyrl.js.map +1 -1
- package/lib/locale/sr-Latn.d.ts +18 -0
- package/lib/locale/sr-Latn.js +18 -0
- package/lib/locale/sr-Latn.js.map +1 -1
- package/lib/locale/sv.d.ts +18 -0
- package/lib/locale/sv.js +18 -0
- package/lib/locale/sv.js.map +1 -1
- package/lib/locale/th.d.ts +18 -0
- package/lib/locale/th.js +18 -0
- package/lib/locale/th.js.map +1 -1
- package/lib/locale/tr.d.ts +18 -0
- package/lib/locale/tr.js +18 -0
- package/lib/locale/tr.js.map +1 -1
- package/lib/locale/uk.d.ts +18 -0
- package/lib/locale/uk.js +18 -0
- package/lib/locale/uk.js.map +1 -1
- package/lib/locale/vi.d.ts +18 -0
- package/lib/locale/vi.js +18 -0
- package/lib/locale/vi.js.map +1 -1
- package/lib/locale/zh-Hans.d.ts +18 -0
- package/lib/locale/zh-Hans.js +18 -0
- package/lib/locale/zh-Hans.js.map +1 -1
- package/lib/locale/zh-Hant.d.ts +18 -0
- package/lib/locale/zh-Hant.js +18 -0
- package/lib/locale/zh-Hant.js.map +1 -1
- package/lib/util/helpers.d.ts +3 -0
- package/lib/util/helpers.js +4 -0
- package/lib/util/helpers.js.map +1 -1
- package/lib/util/indentLines.d.ts +17 -0
- package/lib/util/indentLines.js +34 -0
- package/lib/util/indentLines.js.map +1 -0
- package/lib/util/index.d.ts +1 -0
- package/lib/util/index.js +1 -0
- package/lib/util/index.js.map +1 -1
- package/package.json +2 -2
- package/lib/components/VKbd/VKbd.sass +0 -15
- package/lib/composables/hotkey.d.ts +0 -9
- package/lib/composables/hotkey.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.js","names":["computed","shallowRef","unref","watchEffect","normalizeClass","_normalizeClass","createElementVNode","_createElementVNode","Fragment","_Fragment","getPropertyFromItem","propsFactory","wrapInArray","defaultFilter","value","query","item","length","toString","toLocaleLowerCase","result","idx","indexOf","push","normaliseMatch","match","Array","isArray","makeFilterProps","customFilter","Function","customKeyFilter","Object","filterKeys","String","filterMode","type","default","noFilter","Boolean","filterItems","items","options","array","filter","keys","customFiltersLength","loop","i","transformed","customMatches","defaultMatches","includes","raw","key","keyFilter","title","defaultMatchesLength","customMatchesLength","index","matches","useFilter","props","filteredItems","filteredMatches","Map","transformedItems","transform","map","_query","strQuery","results","originalItems","_filteredItems","_filteredMatches","forEach","_ref","set","getMatches","get","highlightResult","name","text","start","slice"],"sources":["../../src/composables/filter.tsx"],"sourcesContent":["/* eslint-disable max-statements */\n/* eslint-disable no-labels */\n\n// Utilities\nimport { computed, shallowRef, unref, watchEffect } from 'vue'\nimport { getPropertyFromItem, propsFactory, wrapInArray } from '@/util'\n\n// Types\nimport type { PropType, Ref } from 'vue'\nimport type { MaybeRef } from '@/util'\n\n/**\n * - boolean: match without highlight\n * - number: single match (index), length already known\n * - []: single match (start, end)\n * - [][]: multiple matches (start, end), shouldn't overlap\n */\nexport type FilterMatchArraySingle = readonly [number, number]\nexport type FilterMatchArrayMultiple = readonly FilterMatchArraySingle[]\nexport type FilterMatchArray = FilterMatchArraySingle | FilterMatchArrayMultiple\nexport type FilterMatch = boolean | number | FilterMatchArray\nexport type FilterFunction = (value: string, query: string, item?: InternalItem) => FilterMatch\nexport type FilterKeyFunctions = Record<string, FilterFunction>\nexport type FilterKeys = string | string[]\nexport type FilterMode = 'some' | 'every' | 'union' | 'intersection'\n\nexport interface FilterProps {\n customFilter?: FilterFunction\n customKeyFilter?: FilterKeyFunctions\n filterKeys?: FilterKeys\n filterMode?: FilterMode\n noFilter?: boolean\n}\n\nexport interface InternalItem<T = any> {\n value: any\n raw: T\n}\n\n// Composables\nexport const defaultFilter: FilterFunction = (value, query, item) => {\n if (value == null || query == null) return -1\n if (!query.length) return 0\n\n value = value.toString().toLocaleLowerCase()\n query = query.toString().toLocaleLowerCase()\n\n const result = []\n let idx = value.indexOf(query)\n while (~idx) {\n result.push([idx, idx + query.length] as const)\n\n idx = value.indexOf(query, idx + query.length)\n }\n\n return result.length ? result : -1\n}\n\nfunction normaliseMatch (match: FilterMatch, query: string): FilterMatchArrayMultiple | undefined {\n if (match == null || typeof match === 'boolean' || match === -1) return\n if (typeof match === 'number') return [[match, match + query.length]]\n if (Array.isArray(match[0])) return match as FilterMatchArrayMultiple\n return [match] as FilterMatchArrayMultiple\n}\n\nexport const makeFilterProps = propsFactory({\n customFilter: Function as PropType<FilterFunction>,\n customKeyFilter: Object as PropType<FilterKeyFunctions>,\n filterKeys: [Array, String] as PropType<FilterKeys>,\n filterMode: {\n type: String as PropType<FilterMode>,\n default: 'intersection',\n },\n noFilter: Boolean,\n}, 'filter')\n\nexport function filterItems (\n items: readonly (readonly [item: InternalItem, transformed: {}])[] | readonly InternalItem[],\n query: string,\n options?: {\n customKeyFilter?: FilterKeyFunctions\n default?: FilterFunction\n filterKeys?: FilterKeys\n filterMode?: FilterMode\n noFilter?: boolean\n },\n) {\n const array: { index: number, matches: Record<string, FilterMatchArrayMultiple | undefined> }[] = []\n // always ensure we fall back to a functioning filter\n const filter = options?.default ?? defaultFilter\n const keys = options?.filterKeys ? wrapInArray(options.filterKeys) : false\n const customFiltersLength = Object.keys(options?.customKeyFilter ?? {}).length\n\n if (!items?.length) return array\n\n loop:\n for (let i = 0; i < items.length; i++) {\n const [item, transformed = item] = wrapInArray(items[i]) as readonly [InternalItem, {}]\n const customMatches: Record<string, FilterMatchArrayMultiple | undefined> = {}\n const defaultMatches: Record<string, FilterMatchArrayMultiple | undefined> = {}\n let match: FilterMatch = -1\n\n if ((query || customFiltersLength > 0) && !options?.noFilter) {\n if (typeof item === 'object') {\n if (['divider', 'subheader'].includes(item.raw?.type)) {\n continue\n }\n\n const filterKeys = keys || Object.keys(transformed)\n\n for (const key of filterKeys) {\n const value = getPropertyFromItem(transformed, key)\n const keyFilter = options?.customKeyFilter?.[key]\n\n match = keyFilter\n ? keyFilter(value, query, item)\n : filter(value, query, item)\n\n if (match !== -1 && match !== false) {\n if (keyFilter) customMatches[key] = normaliseMatch(match, query)\n else defaultMatches[key] = normaliseMatch(match, query)\n } else if (options?.filterMode === 'every') {\n continue loop\n }\n }\n } else {\n match = filter(item, query, item)\n if (match !== -1 && match !== false) {\n defaultMatches.title = normaliseMatch(match, query)\n }\n }\n\n const defaultMatchesLength = Object.keys(defaultMatches).length\n const customMatchesLength = Object.keys(customMatches).length\n\n if (!defaultMatchesLength && !customMatchesLength) continue\n\n if (\n options?.filterMode === 'union' &&\n customMatchesLength !== customFiltersLength &&\n !defaultMatchesLength\n ) continue\n\n if (\n options?.filterMode === 'intersection' &&\n (\n customMatchesLength !== customFiltersLength ||\n !defaultMatchesLength\n )\n ) continue\n }\n\n array.push({ index: i, matches: { ...defaultMatches, ...customMatches } })\n }\n\n return array\n}\n\nexport function useFilter <T extends InternalItem> (\n props: FilterProps,\n items: MaybeRef<T[]>,\n query: Ref<string | undefined> | (() => string | undefined),\n options?: {\n transform?: (item: T) => {}\n customKeyFilter?: MaybeRef<FilterKeyFunctions | undefined>\n }\n) {\n const filteredItems = shallowRef<T[]>([])\n const filteredMatches = shallowRef(new Map<unknown, Record<string, FilterMatchArrayMultiple | undefined>>())\n const transformedItems = computed(() => (\n options?.transform\n ? unref(items).map(item => ([item, options.transform!(item)] as const))\n : unref(items)\n ))\n\n watchEffect(() => {\n const _query = typeof query === 'function' ? query() : unref(query)\n const strQuery = (\n typeof _query !== 'string' &&\n typeof _query !== 'number'\n ) ? '' : String(_query)\n\n const results = filterItems(\n transformedItems.value,\n strQuery,\n {\n customKeyFilter: {\n ...props.customKeyFilter,\n ...unref(options?.customKeyFilter),\n },\n default: props.customFilter,\n filterKeys: props.filterKeys,\n filterMode: props.filterMode,\n noFilter: props.noFilter,\n },\n )\n\n const originalItems = unref(items)\n\n const _filteredItems: typeof filteredItems['value'] = []\n const _filteredMatches: typeof filteredMatches['value'] = new Map()\n results.forEach(({ index, matches }) => {\n const item = originalItems[index]\n _filteredItems.push(item)\n _filteredMatches.set(item.value, matches)\n })\n filteredItems.value = _filteredItems\n filteredMatches.value = _filteredMatches\n })\n\n function getMatches (item: T) {\n return filteredMatches.value.get(item.value)\n }\n\n return { filteredItems, filteredMatches, getMatches }\n}\n\nexport function highlightResult (name: string, text: string, matches: FilterMatchArrayMultiple | undefined) {\n if (matches == null || !matches.length) return text\n\n return matches.map((match, i) => {\n const start = i === 0 ? 0 : matches[i - 1][1]\n const result = [\n <span class={ `${name}__unmask` }>{ text.slice(start, match[0]) }</span>,\n <span class={ `${name}__mask` }>{ text.slice(match[0], match[1]) }</span>,\n ]\n if (i === matches.length - 1) {\n result.push(<span class={ `${name}__unmask` }>{ text.slice(match[1]) }</span>)\n }\n return <>{ result }</>\n })\n}\n"],"mappings":"AAAA;AACA;;AAEA;AACA,SAASA,QAAQ,EAAEC,UAAU,EAAEC,KAAK,EAAEC,WAAW,EAAAC,cAAA,IAAAC,eAAA,EAAAC,kBAAA,IAAAC,mBAAA,EAAAC,QAAA,IAAAC,SAAA,QAAQ,KAAK;AAAA,SACrDC,mBAAmB,EAAEC,YAAY,EAAEC,WAAW,4BAEvD;AAIA;AACA;AACA;AACA;AACA;AACA;AAuBA;AACA,OAAO,MAAMC,aAA6B,GAAGA,CAACC,KAAK,EAAEC,KAAK,EAAEC,IAAI,KAAK;EACnE,IAAIF,KAAK,IAAI,IAAI,IAAIC,KAAK,IAAI,IAAI,EAAE,OAAO,CAAC,CAAC;EAC7C,IAAI,CAACA,KAAK,CAACE,MAAM,EAAE,OAAO,CAA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eAAA,CACC,GAAG4E,IAAI,UAAU;IAAA,IAAKC,IAAI,CAACE,KAAK,CAACD,KAAK,EAAE1D,KAAK,CAAC,CAAC,CAAC,CAAC,IAAAlB,mBAAA;MAAA,SAAAF,eAAA,CACjD,GAAG4E,IAAI,QAAQ;IAAA,IAAKC,IAAI,CAACE,KAAK,CAAC3D,KAAK,CAAC,CAAC,CAAC,EAAEA,KAAK,CAAC,CAAC,CAAC,CAAC,GACjE;IACD,IAAIuB,CAAC,KAAKY,OAAO,CAAC3C,MAAM,GAAG,CAAC,EAAE;MAC5BG,MAAM,CAACG,IAAI,CAAAhB,mBAAA;QAAA,SAAAF,eAAA,CAAe,GAAG4E,IAAI,UAAU;MAAA,IAAKC,IAAI,CAACE,KAAK,CAAC3D,KAAK,CAAC,CAAC,CAAC,CAAC,EAAS,CAAC;IAChF;IACA,OAAAlB,mBAAA,CAAAE,SAAA,SAAWW,MAAM;EACnB,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"filter.js","names":["computed","shallowRef","unref","watchEffect","normalizeClass","_normalizeClass","createElementVNode","_createElementVNode","Fragment","_Fragment","getPropertyFromItem","propsFactory","wrapInArray","defaultFilter","value","query","item","length","toString","toLocaleLowerCase","result","idx","indexOf","push","normaliseMatch","match","Array","isArray","makeFilterProps","customFilter","Function","customKeyFilter","Object","filterKeys","String","filterMode","type","default","noFilter","Boolean","filterItems","items","options","array","filter","keys","customFiltersLength","loop","i","transformed","customMatches","defaultMatches","key","keyFilter","title","defaultMatchesLength","customMatchesLength","index","matches","useFilter","props","filteredItems","filteredMatches","Map","transformedItems","transform","map","_query","strQuery","results","originalItems","_filteredItems","_filteredMatches","forEach","_ref","set","getMatches","get","highlightResult","name","text","start","slice"],"sources":["../../src/composables/filter.tsx"],"sourcesContent":["/* eslint-disable max-statements */\n/* eslint-disable no-labels */\n\n// Utilities\nimport { computed, shallowRef, unref, watchEffect } from 'vue'\nimport { getPropertyFromItem, propsFactory, wrapInArray } from '@/util'\n\n// Types\nimport type { PropType, Ref } from 'vue'\nimport type { MaybeRef } from '@/util'\n\n/**\n * - boolean: match without highlight\n * - number: single match (index), length already known\n * - []: single match (start, end)\n * - [][]: multiple matches (start, end), shouldn't overlap\n */\nexport type FilterMatchArraySingle = readonly [number, number]\nexport type FilterMatchArrayMultiple = readonly FilterMatchArraySingle[]\nexport type FilterMatchArray = FilterMatchArraySingle | FilterMatchArrayMultiple\nexport type FilterMatch = boolean | number | FilterMatchArray\nexport type FilterFunction = (value: string, query: string, item?: InternalItem) => FilterMatch\nexport type FilterKeyFunctions = Record<string, FilterFunction>\nexport type FilterKeys = string | string[]\nexport type FilterMode = 'some' | 'every' | 'union' | 'intersection'\n\nexport interface FilterProps {\n customFilter?: FilterFunction\n customKeyFilter?: FilterKeyFunctions\n filterKeys?: FilterKeys\n filterMode?: FilterMode\n noFilter?: boolean\n}\n\nexport interface InternalItem<T = any> {\n value: any\n raw: T\n type?: string\n}\n\n// Composables\nexport const defaultFilter: FilterFunction = (value, query, item) => {\n if (value == null || query == null) return -1\n if (!query.length) return 0\n\n value = value.toString().toLocaleLowerCase()\n query = query.toString().toLocaleLowerCase()\n\n const result = []\n let idx = value.indexOf(query)\n while (~idx) {\n result.push([idx, idx + query.length] as const)\n\n idx = value.indexOf(query, idx + query.length)\n }\n\n return result.length ? result : -1\n}\n\nfunction normaliseMatch (match: FilterMatch, query: string): FilterMatchArrayMultiple | undefined {\n if (match == null || typeof match === 'boolean' || match === -1) return\n if (typeof match === 'number') return [[match, match + query.length]]\n if (Array.isArray(match[0])) return match as FilterMatchArrayMultiple\n return [match] as FilterMatchArrayMultiple\n}\n\nexport const makeFilterProps = propsFactory({\n customFilter: Function as PropType<FilterFunction>,\n customKeyFilter: Object as PropType<FilterKeyFunctions>,\n filterKeys: [Array, String] as PropType<FilterKeys>,\n filterMode: {\n type: String as PropType<FilterMode>,\n default: 'intersection',\n },\n noFilter: Boolean,\n}, 'filter')\n\nexport function filterItems (\n items: readonly (readonly [item: InternalItem, transformed: {}])[] | readonly InternalItem[],\n query: string,\n options?: {\n customKeyFilter?: FilterKeyFunctions\n default?: FilterFunction\n filterKeys?: FilterKeys\n filterMode?: FilterMode\n noFilter?: boolean\n },\n) {\n const array: { index: number, matches: Record<string, FilterMatchArrayMultiple | undefined> }[] = []\n // always ensure we fall back to a functioning filter\n const filter = options?.default ?? defaultFilter\n const keys = options?.filterKeys ? wrapInArray(options.filterKeys) : false\n const customFiltersLength = Object.keys(options?.customKeyFilter ?? {}).length\n\n if (!items?.length) return array\n\n loop:\n for (let i = 0; i < items.length; i++) {\n const [item, transformed = item] = wrapInArray(items[i]) as readonly [InternalItem, {}]\n const customMatches: Record<string, FilterMatchArrayMultiple | undefined> = {}\n const defaultMatches: Record<string, FilterMatchArrayMultiple | undefined> = {}\n let match: FilterMatch = -1\n\n if ((query || customFiltersLength > 0) && !options?.noFilter) {\n if (typeof item === 'object') {\n if (item.type === 'divider' || item.type === 'subheader') {\n continue\n }\n\n const filterKeys = keys || Object.keys(transformed)\n\n for (const key of filterKeys) {\n const value = getPropertyFromItem(transformed, key)\n const keyFilter = options?.customKeyFilter?.[key]\n\n match = keyFilter\n ? keyFilter(value, query, item)\n : filter(value, query, item)\n\n if (match !== -1 && match !== false) {\n if (keyFilter) customMatches[key] = normaliseMatch(match, query)\n else defaultMatches[key] = normaliseMatch(match, query)\n } else if (options?.filterMode === 'every') {\n continue loop\n }\n }\n } else {\n match = filter(item, query, item)\n if (match !== -1 && match !== false) {\n defaultMatches.title = normaliseMatch(match, query)\n }\n }\n\n const defaultMatchesLength = Object.keys(defaultMatches).length\n const customMatchesLength = Object.keys(customMatches).length\n\n if (!defaultMatchesLength && !customMatchesLength) continue\n\n if (\n options?.filterMode === 'union' &&\n customMatchesLength !== customFiltersLength &&\n !defaultMatchesLength\n ) continue\n\n if (\n options?.filterMode === 'intersection' &&\n (\n customMatchesLength !== customFiltersLength ||\n !defaultMatchesLength\n )\n ) continue\n }\n\n array.push({ index: i, matches: { ...defaultMatches, ...customMatches } })\n }\n\n return array\n}\n\nexport function useFilter <T extends InternalItem> (\n props: FilterProps,\n items: MaybeRef<T[]>,\n query: Ref<string | undefined> | (() => string | undefined),\n options?: {\n transform?: (item: T) => {}\n customKeyFilter?: MaybeRef<FilterKeyFunctions | undefined>\n }\n) {\n const filteredItems = shallowRef<T[]>([])\n const filteredMatches = shallowRef(new Map<unknown, Record<string, FilterMatchArrayMultiple | undefined>>())\n const transformedItems = computed(() => (\n options?.transform\n ? unref(items).map(item => ([item, options.transform!(item)] as const))\n : unref(items)\n ))\n\n watchEffect(() => {\n const _query = typeof query === 'function' ? query() : unref(query)\n const strQuery = (\n typeof _query !== 'string' &&\n typeof _query !== 'number'\n ) ? '' : String(_query)\n\n const results = filterItems(\n transformedItems.value,\n strQuery,\n {\n customKeyFilter: {\n ...props.customKeyFilter,\n ...unref(options?.customKeyFilter),\n },\n default: props.customFilter,\n filterKeys: props.filterKeys,\n filterMode: props.filterMode,\n noFilter: props.noFilter,\n },\n )\n\n const originalItems = unref(items)\n\n const _filteredItems: typeof filteredItems['value'] = []\n const _filteredMatches: typeof filteredMatches['value'] = new Map()\n results.forEach(({ index, matches }) => {\n const item = originalItems[index]\n _filteredItems.push(item)\n _filteredMatches.set(item.value, matches)\n })\n filteredItems.value = _filteredItems\n filteredMatches.value = _filteredMatches\n })\n\n function getMatches (item: T) {\n return filteredMatches.value.get(item.value)\n }\n\n return { filteredItems, filteredMatches, getMatches }\n}\n\nexport function highlightResult (name: string, text: string, matches: FilterMatchArrayMultiple | undefined) {\n if (matches == null || !matches.length) return text\n\n return matches.map((match, i) => {\n const start = i === 0 ? 0 : matches[i - 1][1]\n const result = [\n <span class={ `${name}__unmask` }>{ text.slice(start, match[0]) }</span>,\n <span class={ `${name}__mask` }>{ text.slice(match[0], match[1]) }</span>,\n ]\n if (i === matches.length - 1) {\n result.push(<span class={ `${name}__unmask` }>{ text.slice(match[1]) }</span>)\n }\n return <>{ result }</>\n })\n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AAE+C,aAAa;IAAEC,eAAe;IAAEc;EAAW,CAAC;AACvD;AAEA,OAAO,SAASE,eAAeA,CAAEC,IAAY,EAAEC,IAAY,EAAEtB,OAA6C,EAAE;EAC1G,IAAIA,OAAO,IAAI,IAAI,IAAI,CAACA,OAAO,CAACzC,MAAM,EAAE,OAAO+D,IAAI;EAEnD,OAAOtB,OAAO,CAACQ,GAAG,CAAC,CAACzC,KAAK,EAAEuB,CAAC,KAAK;IAC/B,MAAMiC,KAAK,GAAGjC,CAAC,KAAK,CAAC,GAAG,CAAC,GAAGU,OAAO,CAACV,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7C,MAAM5B,MAAM,GAAG,CAAAb,mBAAA;MAAA,SAAAF,eAAA,CACC,GAAG0E,IAAI,UAAU;IAAA,IAAKC,IAAI,CAACE,KAAK,CAACD,KAAK,EAAExD,KAAK,CAAC,CAAC,CAAC,CAAC,IAAAlB,mBAAA;MAAA,SAAAF,eAAA,CACjD,GAAG0E,IAAI,QAAQ;IAAA,IAAKC,IAAI,CAACE,KAAK,CAACzD,KAAK,CAAC,CAAC,CAAC,EAAEA,KAAK,CAAC,CAAC,CAAC,CAAC,GACjE;IACD,IAAIuB,CAAC,KAAKU,OAAO,CAACzC,MAAM,GAAG,CAAC,EAAE;MAC5BG,MAAM,CAACG,IAAI,CAAAhB,mBAAA;QAAA,SAAAF,eAAA,CAAe,GAAG0E,IAAI,UAAU;MAAA,IAAKC,IAAI,CAACE,KAAK,CAACzD,KAAK,CAAC,CAAC,CAAC,CAAC,EAAS,CAAC;IAChF;IACA,OAAAlB,mBAAA,CAAAE,SAAA,SAAWW,MAAM;EACnB,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const MODIFIERS: string[];
|
|
2
|
+
/**
|
|
3
|
+
* Splits a single combination string into individual key parts.
|
|
4
|
+
*
|
|
5
|
+
* A combination is a set of keys that must be pressed simultaneously.
|
|
6
|
+
* e.g. `ctrl+k`, `shift--`
|
|
7
|
+
*/
|
|
8
|
+
export declare function splitKeyCombination(combination: string, isInternal?: boolean): string[];
|
|
9
|
+
/**
|
|
10
|
+
* Splits a hotkey string into its constituent combination groups.
|
|
11
|
+
*
|
|
12
|
+
* A sequence is a series of combinations that must be pressed in order.
|
|
13
|
+
* e.g. `a-b`, `ctrl+k-p`
|
|
14
|
+
*/
|
|
15
|
+
export declare function splitKeySequence(str: string): string[];
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// Utilities
|
|
2
|
+
import { normalizeKey } from "./key-aliases.js";
|
|
3
|
+
import { consoleWarn } from "../../util/console.js"; // Types
|
|
4
|
+
export const MODIFIERS = ['ctrl', 'shift', 'alt', 'meta', 'cmd'];
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Splits a single combination string into individual key parts.
|
|
8
|
+
*
|
|
9
|
+
* A combination is a set of keys that must be pressed simultaneously.
|
|
10
|
+
* e.g. `ctrl+k`, `shift--`
|
|
11
|
+
*/
|
|
12
|
+
export function splitKeyCombination(combination) {
|
|
13
|
+
let isInternal = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
14
|
+
if (!combination) {
|
|
15
|
+
if (!isInternal) consoleWarn('Invalid hotkey combination: empty string provided');
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// --- VALIDATION ---
|
|
20
|
+
const startsWithPlusOrUnderscore = combination.startsWith('+') || combination.startsWith('_');
|
|
21
|
+
const hasInvalidLeadingSeparator =
|
|
22
|
+
// Starts with a single '+' or '_' followed by a non-separator character (e.g. '+a', '_a')
|
|
23
|
+
startsWithPlusOrUnderscore && !(combination.startsWith('++') || combination.startsWith('__'));
|
|
24
|
+
const hasInvalidStructure =
|
|
25
|
+
// Invalid leading separator patterns
|
|
26
|
+
combination.length > 1 && hasInvalidLeadingSeparator ||
|
|
27
|
+
// Disallow literal + or _ keys (they require shift)
|
|
28
|
+
combination.includes('++') || combination.includes('__') || combination === '+' || combination === '_' ||
|
|
29
|
+
// Ends with a separator that is not part of a doubled literal
|
|
30
|
+
combination.length > 1 && (combination.endsWith('+') || combination.endsWith('_')) && combination.at(-2) !== combination.at(-1) ||
|
|
31
|
+
// Stand-alone doubled separators (dangling)
|
|
32
|
+
combination === '++' || combination === '--' || combination === '__';
|
|
33
|
+
if (hasInvalidStructure) {
|
|
34
|
+
if (!isInternal) consoleWarn(`Invalid hotkey combination: "${combination}" has invalid structure`);
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
const keys = [];
|
|
38
|
+
let buffer = '';
|
|
39
|
+
const flushBuffer = () => {
|
|
40
|
+
if (buffer) {
|
|
41
|
+
keys.push(normalizeKey(buffer));
|
|
42
|
+
buffer = '';
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
for (let i = 0; i < combination.length; i++) {
|
|
46
|
+
const char = combination[i];
|
|
47
|
+
const nextChar = combination[i + 1];
|
|
48
|
+
if (char === '+' || char === '_' || char === '-') {
|
|
49
|
+
if (char === nextChar) {
|
|
50
|
+
flushBuffer();
|
|
51
|
+
keys.push(char);
|
|
52
|
+
i++;
|
|
53
|
+
} else if (char === '+' || char === '_') {
|
|
54
|
+
flushBuffer();
|
|
55
|
+
} else {
|
|
56
|
+
buffer += char;
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
buffer += char;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
flushBuffer();
|
|
63
|
+
|
|
64
|
+
// Within a combination, `-` is only valid as a literal key (e.g., `ctrl+-`).
|
|
65
|
+
// `-` cannot be part of a longer key name within a combination.
|
|
66
|
+
const hasInvalidMinus = keys.some(key => key.length > 1 && key.includes('-') && key !== '--');
|
|
67
|
+
if (hasInvalidMinus) {
|
|
68
|
+
if (!isInternal) consoleWarn(`Invalid hotkey combination: "${combination}" has invalid structure`);
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
if (keys.length === 0 && combination) {
|
|
72
|
+
return [normalizeKey(combination)];
|
|
73
|
+
}
|
|
74
|
+
return keys;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Splits a hotkey string into its constituent combination groups.
|
|
79
|
+
*
|
|
80
|
+
* A sequence is a series of combinations that must be pressed in order.
|
|
81
|
+
* e.g. `a-b`, `ctrl+k-p`
|
|
82
|
+
*/
|
|
83
|
+
export function splitKeySequence(str) {
|
|
84
|
+
if (!str) {
|
|
85
|
+
consoleWarn('Invalid hotkey sequence: empty string provided');
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// A sequence is invalid if it starts or ends with a separator,
|
|
90
|
+
// unless it is part of a combination (e.g., `shift+-`).
|
|
91
|
+
const hasInvalidStart = str.startsWith('-') && !['---', '--+'].includes(str);
|
|
92
|
+
const hasInvalidEnd = str.endsWith('-') && !str.endsWith('+-') && !str.endsWith('_-') && str !== '-' && str !== '---';
|
|
93
|
+
if (hasInvalidStart || hasInvalidEnd) {
|
|
94
|
+
consoleWarn(`Invalid hotkey sequence: "${str}" contains invalid combinations`);
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
const result = [];
|
|
98
|
+
let buffer = '';
|
|
99
|
+
let i = 0;
|
|
100
|
+
while (i < str.length) {
|
|
101
|
+
const char = str[i];
|
|
102
|
+
if (char === '-') {
|
|
103
|
+
// Determine if this hyphen is part of the current combination
|
|
104
|
+
const prevChar = str[i - 1];
|
|
105
|
+
const prevPrevChar = i > 1 ? str[i - 2] : undefined;
|
|
106
|
+
const precededBySinglePlusOrUnderscore = (prevChar === '+' || prevChar === '_') && prevPrevChar !== '+';
|
|
107
|
+
if (precededBySinglePlusOrUnderscore) {
|
|
108
|
+
// Treat as part of the combination (e.g., 'ctrl+-')
|
|
109
|
+
buffer += char;
|
|
110
|
+
i++;
|
|
111
|
+
} else {
|
|
112
|
+
// Treat as sequence separator
|
|
113
|
+
if (buffer) {
|
|
114
|
+
result.push(buffer);
|
|
115
|
+
buffer = '';
|
|
116
|
+
} else {
|
|
117
|
+
// Empty buffer means we have a literal '-' key
|
|
118
|
+
result.push('-');
|
|
119
|
+
}
|
|
120
|
+
i++;
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
buffer += char;
|
|
124
|
+
i++;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Add final buffer if it exists
|
|
129
|
+
if (buffer) {
|
|
130
|
+
result.push(buffer);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Collapse runs of '-' so that every second '-' is removed
|
|
134
|
+
const collapsed = [];
|
|
135
|
+
let minusCount = 0;
|
|
136
|
+
for (const part of result) {
|
|
137
|
+
if (part === '-') {
|
|
138
|
+
if (minusCount % 2 === 0) collapsed.push('-');
|
|
139
|
+
minusCount++;
|
|
140
|
+
} else {
|
|
141
|
+
minusCount = 0;
|
|
142
|
+
collapsed.push(part);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Validate that each part of the sequence is a valid combination
|
|
147
|
+
const areAllValid = collapsed.every(s => splitKeyCombination(s, true).length > 0);
|
|
148
|
+
if (!areAllValid) {
|
|
149
|
+
consoleWarn(`Invalid hotkey sequence: "${str}" contains invalid combinations`);
|
|
150
|
+
return [];
|
|
151
|
+
}
|
|
152
|
+
return collapsed;
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=hotkey-parsing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotkey-parsing.js","names":["normalizeKey","consoleWarn","MODIFIERS","splitKeyCombination","combination","isInternal","arguments","length","undefined","startsWithPlusOrUnderscore","startsWith","hasInvalidLeadingSeparator","hasInvalidStructure","includes","endsWith","at","keys","buffer","flushBuffer","push","i","char","nextChar","hasInvalidMinus","some","key","splitKeySequence","str","hasInvalidStart","hasInvalidEnd","result","prevChar","prevPrevChar","precededBySinglePlusOrUnderscore","collapsed","minusCount","part","areAllValid","every","s"],"sources":["../../../src/composables/hotkey/hotkey-parsing.ts"],"sourcesContent":["// Utilities\nimport { normalizeKey } from './key-aliases'\nimport { consoleWarn } from '../../util/console'\n\n// Types\nexport const MODIFIERS = ['ctrl', 'shift', 'alt', 'meta', 'cmd']\n\n/**\n * Splits a single combination string into individual key parts.\n *\n * A combination is a set of keys that must be pressed simultaneously.\n * e.g. `ctrl+k`, `shift--`\n */\nexport function splitKeyCombination (combination: string, isInternal = false): string[] {\n if (!combination) {\n if (!isInternal) consoleWarn('Invalid hotkey combination: empty string provided')\n return []\n }\n\n // --- VALIDATION ---\n const startsWithPlusOrUnderscore = combination.startsWith('+') || combination.startsWith('_')\n\n const hasInvalidLeadingSeparator = (\n // Starts with a single '+' or '_' followed by a non-separator character (e.g. '+a', '_a')\n startsWithPlusOrUnderscore &&\n !(combination.startsWith('++') || combination.startsWith('__'))\n )\n\n const hasInvalidStructure = (\n // Invalid leading separator patterns\n (combination.length > 1 && hasInvalidLeadingSeparator) ||\n // Disallow literal + or _ keys (they require shift)\n combination.includes('++') || combination.includes('__') ||\n combination === '+' || combination === '_' ||\n // Ends with a separator that is not part of a doubled literal\n (combination.length > 1 && (combination.endsWith('+') || combination.endsWith('_')) && combination.at(-2) !== combination.at(-1)) ||\n // Stand-alone doubled separators (dangling)\n combination === '++' || combination === '--' || combination === '__'\n )\n\n if (hasInvalidStructure) {\n if (!isInternal) consoleWarn(`Invalid hotkey combination: \"${combination}\" has invalid structure`)\n return []\n }\n\n const keys: string[] = []\n let buffer = ''\n\n const flushBuffer = () => {\n if (buffer) {\n keys.push(normalizeKey(buffer))\n buffer = ''\n }\n }\n\n for (let i = 0; i < combination.length; i++) {\n const char = combination[i]\n const nextChar = combination[i + 1]\n\n if (char === '+' || char === '_' || char === '-') {\n if (char === nextChar) {\n flushBuffer()\n keys.push(char)\n i++\n } else if (char === '+' || char === '_') {\n flushBuffer()\n } else {\n buffer += char\n }\n } else {\n buffer += char\n }\n }\n flushBuffer()\n\n // Within a combination, `-` is only valid as a literal key (e.g., `ctrl+-`).\n // `-` cannot be part of a longer key name within a combination.\n const hasInvalidMinus = keys.some(key => key.length > 1 && key.includes('-') && key !== '--')\n if (hasInvalidMinus) {\n if (!isInternal) consoleWarn(`Invalid hotkey combination: \"${combination}\" has invalid structure`)\n return []\n }\n\n if (keys.length === 0 && combination) {\n return [normalizeKey(combination)]\n }\n\n return keys\n}\n\n/**\n * Splits a hotkey string into its constituent combination groups.\n *\n * A sequence is a series of combinations that must be pressed in order.\n * e.g. `a-b`, `ctrl+k-p`\n */\nexport function splitKeySequence (str: string): string[] {\n if (!str) {\n consoleWarn('Invalid hotkey sequence: empty string provided')\n return []\n }\n\n // A sequence is invalid if it starts or ends with a separator,\n // unless it is part of a combination (e.g., `shift+-`).\n const hasInvalidStart = str.startsWith('-') && !['---', '--+'].includes(str)\n const hasInvalidEnd = str.endsWith('-') && !str.endsWith('+-') && !str.endsWith('_-') && str !== '-' && str !== '---'\n\n if (hasInvalidStart || hasInvalidEnd) {\n consoleWarn(`Invalid hotkey sequence: \"${str}\" contains invalid combinations`)\n return []\n }\n\n const result: string[] = []\n let buffer = ''\n let i = 0\n\n while (i < str.length) {\n const char = str[i]\n\n if (char === '-') {\n // Determine if this hyphen is part of the current combination\n const prevChar = str[i - 1]\n const prevPrevChar = i > 1 ? str[i - 2] : undefined\n\n const precededBySinglePlusOrUnderscore = (\n (prevChar === '+' || prevChar === '_') && prevPrevChar !== '+'\n )\n\n if (precededBySinglePlusOrUnderscore) {\n // Treat as part of the combination (e.g., 'ctrl+-')\n buffer += char\n i++\n } else {\n // Treat as sequence separator\n if (buffer) {\n result.push(buffer)\n buffer = ''\n } else {\n // Empty buffer means we have a literal '-' key\n result.push('-')\n }\n i++\n }\n } else {\n buffer += char\n i++\n }\n }\n\n // Add final buffer if it exists\n if (buffer) {\n result.push(buffer)\n }\n\n // Collapse runs of '-' so that every second '-' is removed\n const collapsed: string[] = []\n let minusCount = 0\n for (const part of result) {\n if (part === '-') {\n if (minusCount % 2 === 0) collapsed.push('-')\n minusCount++\n } else {\n minusCount = 0\n collapsed.push(part)\n }\n }\n\n // Validate that each part of the sequence is a valid combination\n const areAllValid = collapsed.every(s => splitKeyCombination(s, true).length > 0)\n\n if (!areAllValid) {\n consoleWarn(`Invalid hotkey sequence: \"${str}\" contains invalid combinations`)\n return []\n }\n\n return collapsed\n}\n"],"mappings":"AAAA;AAAA,SACSA,YAAY;AAAA,SACZC,WAAW,iCAEpB;AACA,OAAO,MAAMC,SAAS,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC;;AAEhE;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAEC,WAAmB,EAAgC;EAAA,IAA9BC,UAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAC1E,IAAI,CAACF,WAAW,EAAE;IAChB,IAAI,CAACC,UAAU,EAAEJ,WAAW,CAAC,mDAAmD,CAAC;IACjF,OAAO,EAAE;EACX;;EAEA;EACA,MAAMQ,0BAA0B,GAAGL,WAAW,CAACM,UAAU,CAAC,GAAG,CAAC,IAAIN,WAAW,CAACM,UAAU,CAAC,GAAG,CAAC;EAE7F,MAAMC,0BAA0B;EAC9B;EACAF,0BAA0B,IAC1B,EAAEL,WAAW,CAACM,UAAU,CAAC,IAAI,CAAC,IAAIN,WAAW,CAACM,UAAU,CAAC,IAAI,CAAC,CAC/D;EAED,MAAME,mBAAmB;EACvB;EACCR,WAAW,CAACG,MAAM,GAAG,CAAC,IAAII,0BAA0B;EACrD;EACAP,WAAW,CAACS,QAAQ,CAAC,IAAI,CAAC,IAAIT,WAAW,CAACS,QAAQ,CAAC,IAAI,CAAC,IACxDT,WAAW,KAAK,GAAG,IAAIA,WAAW,KAAK,GAAG;EAC1C;EACCA,WAAW,CAACG,MAAM,GAAG,CAAC,KAAKH,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WAAW,GAAGH,SAAS,CAACI,KAAK,CAACC,CAAC,IAAIpC,mBAAmB,CAACoC,CAAC,EAAE,IAAI,CAAC,CAAChC,MAAM,GAAG,CAAC,CAAC;EAEjF,IAAI,CAAC8B,WAAW,EAAE;IAChBpC,WAAW,CAAC,6BAA6B0B,GAAG,iCAAiC,CAAC;IAC9E,OAAO,EAAE;EACX;EAEA,OAAOO,SAAS;AAClB","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MaybeRef } from "../../util/index.js";
|
|
2
|
+
interface HotkeyOptions {
|
|
3
|
+
event?: MaybeRef<'keydown' | 'keyup'>;
|
|
4
|
+
inputs?: MaybeRef<boolean>;
|
|
5
|
+
preventDefault?: MaybeRef<boolean>;
|
|
6
|
+
sequenceTimeout?: MaybeRef<number>;
|
|
7
|
+
}
|
|
8
|
+
export declare function useHotkey(keys: MaybeRef<string | undefined>, callback: (e: KeyboardEvent) => void, options?: HotkeyOptions): () => void;
|
|
9
|
+
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Composables
|
|
2
|
+
import { splitKeyCombination, splitKeySequence } from "./hotkey-parsing.js"; // Utilities
|
|
2
3
|
import { onBeforeUnmount, toValue, watch } from 'vue';
|
|
3
|
-
import { IN_BROWSER } from "
|
|
4
|
-
import { getCurrentInstance } from "
|
|
4
|
+
import { IN_BROWSER } from "../../util/index.js";
|
|
5
|
+
import { getCurrentInstance } from "../../util/getCurrentInstance.js"; // Types
|
|
5
6
|
export function useHotkey(keys, callback) {
|
|
6
7
|
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
7
8
|
if (!IN_BROWSER) return function () {};
|
|
@@ -11,7 +12,7 @@ export function useHotkey(keys, callback) {
|
|
|
11
12
|
preventDefault = true,
|
|
12
13
|
sequenceTimeout = 1000
|
|
13
14
|
} = options;
|
|
14
|
-
const isMac = navigator?.userAgent?.includes('Macintosh');
|
|
15
|
+
const isMac = navigator?.userAgent?.includes('Macintosh') ?? false;
|
|
15
16
|
let timeout = 0;
|
|
16
17
|
let keyGroups;
|
|
17
18
|
let isSequence = false;
|
|
@@ -22,7 +23,7 @@ export function useHotkey(keys, callback) {
|
|
|
22
23
|
timeout = 0;
|
|
23
24
|
}
|
|
24
25
|
function isInputFocused() {
|
|
25
|
-
if (inputs) return false;
|
|
26
|
+
if (toValue(inputs)) return false;
|
|
26
27
|
const activeElement = document.activeElement;
|
|
27
28
|
return activeElement && (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA' || activeElement.isContentEditable || activeElement.contentEditable === 'true');
|
|
28
29
|
}
|
|
@@ -37,7 +38,7 @@ export function useHotkey(keys, callback) {
|
|
|
37
38
|
if (isSequence) resetSequence();
|
|
38
39
|
return;
|
|
39
40
|
}
|
|
40
|
-
if (preventDefault) e.preventDefault();
|
|
41
|
+
if (toValue(preventDefault)) e.preventDefault();
|
|
41
42
|
if (!isSequence) {
|
|
42
43
|
callback(e);
|
|
43
44
|
return;
|
|
@@ -49,32 +50,12 @@ export function useHotkey(keys, callback) {
|
|
|
49
50
|
resetSequence();
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
52
|
-
timeout = window.setTimeout(resetSequence, sequenceTimeout);
|
|
53
|
+
timeout = window.setTimeout(resetSequence, toValue(sequenceTimeout));
|
|
53
54
|
}
|
|
54
55
|
function cleanup() {
|
|
55
|
-
window.removeEventListener(event, handler);
|
|
56
|
+
window.removeEventListener(toValue(event), handler);
|
|
56
57
|
clearTimer();
|
|
57
58
|
}
|
|
58
|
-
function splitKeySequence(str) {
|
|
59
|
-
const groups = [];
|
|
60
|
-
let current = '';
|
|
61
|
-
for (let i = 0; i < str.length; i++) {
|
|
62
|
-
const char = str[i];
|
|
63
|
-
if (char === '-') {
|
|
64
|
-
const next = str[i + 1];
|
|
65
|
-
// Treat '-' as a sequence delimiter only if the next character exists
|
|
66
|
-
// and is NOT one of '-', '+', or '_' (these indicate the '-' belongs to the key itself)
|
|
67
|
-
if (next && !['-', '+', '_'].includes(next)) {
|
|
68
|
-
groups.push(current);
|
|
69
|
-
current = '';
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
current += char;
|
|
74
|
-
}
|
|
75
|
-
groups.push(current);
|
|
76
|
-
return groups;
|
|
77
|
-
}
|
|
78
59
|
watch(() => toValue(keys), function (unrefKeys) {
|
|
79
60
|
cleanup();
|
|
80
61
|
if (unrefKeys) {
|
|
@@ -82,11 +63,19 @@ export function useHotkey(keys, callback) {
|
|
|
82
63
|
isSequence = groups.length > 1;
|
|
83
64
|
keyGroups = groups;
|
|
84
65
|
resetSequence();
|
|
85
|
-
window.addEventListener(event, handler);
|
|
66
|
+
window.addEventListener(toValue(event), handler);
|
|
86
67
|
}
|
|
87
68
|
}, {
|
|
88
69
|
immediate: true
|
|
89
70
|
});
|
|
71
|
+
|
|
72
|
+
// Watch for changes in the event type to re-register the listener
|
|
73
|
+
watch(() => toValue(event), function (newEvent, oldEvent) {
|
|
74
|
+
if (oldEvent && keyGroups && keyGroups.length > 0) {
|
|
75
|
+
window.removeEventListener(oldEvent, handler);
|
|
76
|
+
window.addEventListener(newEvent, handler);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
90
79
|
try {
|
|
91
80
|
getCurrentInstance('useHotkey');
|
|
92
81
|
onBeforeUnmount(cleanup);
|
|
@@ -96,24 +85,25 @@ export function useHotkey(keys, callback) {
|
|
|
96
85
|
function parseKeyGroup(group) {
|
|
97
86
|
const MODIFIERS = ['ctrl', 'shift', 'alt', 'meta', 'cmd'];
|
|
98
87
|
|
|
99
|
-
//
|
|
100
|
-
const parts = group.toLowerCase()
|
|
88
|
+
// Use the shared combination splitting logic
|
|
89
|
+
const parts = splitKeyCombination(group.toLowerCase());
|
|
90
|
+
|
|
91
|
+
// If the combination is invalid, return empty result
|
|
92
|
+
if (parts.length === 0) {
|
|
93
|
+
return {
|
|
94
|
+
modifiers: Object.fromEntries(MODIFIERS.map(m => [m, false])),
|
|
95
|
+
actualKey: undefined
|
|
96
|
+
};
|
|
97
|
+
}
|
|
101
98
|
const modifiers = Object.fromEntries(MODIFIERS.map(m => [m, false]));
|
|
102
99
|
let actualKey;
|
|
103
100
|
for (const part of parts) {
|
|
104
|
-
if (!part) continue; // Skip empty tokens
|
|
105
101
|
if (MODIFIERS.includes(part)) {
|
|
106
102
|
modifiers[part] = true;
|
|
107
103
|
} else {
|
|
108
104
|
actualKey = part;
|
|
109
105
|
}
|
|
110
106
|
}
|
|
111
|
-
|
|
112
|
-
// Fallback for cases where actualKey is a literal '+' or '-' (e.g. alt--, alt++ , alt+-, alt-+)
|
|
113
|
-
if (!actualKey) {
|
|
114
|
-
const lastChar = group.slice(-1);
|
|
115
|
-
if (['+', '-', '_'].includes(lastChar)) actualKey = lastChar;
|
|
116
|
-
}
|
|
117
107
|
return {
|
|
118
108
|
modifiers,
|
|
119
109
|
actualKey
|
|
@@ -124,7 +114,9 @@ export function useHotkey(keys, callback) {
|
|
|
124
114
|
modifiers,
|
|
125
115
|
actualKey
|
|
126
116
|
} = parseKeyGroup(group);
|
|
127
|
-
|
|
117
|
+
const expectCtrl = modifiers.ctrl || !isMac && (modifiers.cmd || modifiers.meta);
|
|
118
|
+
const expectMeta = isMac && (modifiers.cmd || modifiers.meta);
|
|
119
|
+
return e.ctrlKey === expectCtrl && e.metaKey === expectMeta && e.shiftKey === modifiers.shift && e.altKey === modifiers.alt && e.key.toLowerCase() === actualKey?.toLowerCase();
|
|
128
120
|
}
|
|
129
121
|
return cleanup;
|
|
130
122
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotkey.js","names":["splitKeyCombination","splitKeySequence","onBeforeUnmount","toValue","watch","IN_BROWSER","getCurrentInstance","useHotkey","keys","callback","options","arguments","length","undefined","event","inputs","preventDefault","sequenceTimeout","isMac","navigator","userAgent","includes","timeout","keyGroups","isSequence","groupIndex","clearTimer","clearTimeout","isInputFocused","activeElement","document","tagName","isContentEditable","contentEditable","resetSequence","handler","e","group","matchesKeyGroup","window","setTimeout","cleanup","removeEventListener","unrefKeys","groups","toLowerCase","addEventListener","immediate","newEvent","oldEvent","parseKeyGroup","MODIFIERS","parts","modifiers","Object","fromEntries","map","m","actualKey","part","expectCtrl","ctrl","cmd","meta","expectMeta","ctrlKey","metaKey","shiftKey","shift","altKey","alt","key"],"sources":["../../../src/composables/hotkey/hotkey.ts"],"sourcesContent":["// Composables\nimport { splitKeyCombination, splitKeySequence } from '@/composables/hotkey/hotkey-parsing'\n\n// Utilities\nimport { onBeforeUnmount, toValue, watch } from 'vue'\nimport { IN_BROWSER } from '@/util'\nimport { getCurrentInstance } from '@/util/getCurrentInstance'\n\n// Types\nimport type { MaybeRef } from '@/util'\n\ninterface HotkeyOptions {\n event?: MaybeRef<'keydown' | 'keyup'>\n inputs?: MaybeRef<boolean>\n preventDefault?: MaybeRef<boolean>\n sequenceTimeout?: MaybeRef<number>\n}\n\nexport function useHotkey (\n keys: MaybeRef<string | undefined>,\n callback: (e: KeyboardEvent) => void,\n options: HotkeyOptions = {}\n) {\n if (!IN_BROWSER) return function () {}\n\n const {\n event = 'keydown',\n inputs = false,\n preventDefault = true,\n sequenceTimeout = 1000,\n } = options\n\n const isMac = navigator?.userAgent?.includes('Macintosh') ?? false\n let timeout = 0\n let keyGroups: string[]\n let isSequence = false\n let groupIndex = 0\n\n function clearTimer () {\n if (!timeout) return\n\n clearTimeout(timeout)\n timeout = 0\n }\n\n function isInputFocused () {\n if (toValue(inputs)) return false\n\n const activeElement = document.activeElement as HTMLElement\n\n return activeElement && (\n activeElement.tagName === 'INPUT' ||\n activeElement.tagName === 'TEXTAREA' ||\n activeElement.isContentEditable ||\n activeElement.contentEditable === 'true'\n )\n }\n\n function resetSequence () {\n groupIndex = 0\n clearTimer()\n }\n\n function handler (e: KeyboardEvent) {\n const group = keyGroups[groupIndex]\n\n if (!group || isInputFocused()) return\n\n if (!matchesKeyGroup(e, group)) {\n if (isSequence) resetSequence()\n return\n }\n\n if (toValue(preventDefault)) e.preventDefault()\n\n if (!isSequence) {\n callback(e)\n return\n }\n\n clearTimer()\n groupIndex++\n\n if (groupIndex === keyGroups.length) {\n callback(e)\n resetSequence()\n return\n }\n\n timeout = window.setTimeout(resetSequence, toValue(sequenceTimeout))\n }\n\n function cleanup () {\n window.removeEventListener(toValue(event), handler)\n clearTimer()\n }\n\n watch(() => toValue(keys), function (unrefKeys) {\n cleanup()\n\n if (unrefKeys) {\n const groups = splitKeySequence(unrefKeys.toLowerCase())\n isSequence = groups.length > 1\n keyGroups = groups\n resetSequence()\n window.addEventListener(toValue(event), handler)\n }\n }, { immediate: true })\n\n // Watch for changes in the event type to re-register the listener\n watch(() => toValue(event), function (newEvent, oldEvent) {\n if (oldEvent && keyGroups && keyGroups.length > 0) {\n window.removeEventListener(oldEvent, handler)\n window.addEventListener(newEvent, handler)\n }\n })\n\n try {\n getCurrentInstance('useHotkey')\n onBeforeUnmount(cleanup)\n } catch {\n // Not in Vue setup context\n }\n\n function parseKeyGroup (group: string) {\n const MODIFIERS = ['ctrl', 'shift', 'alt', 'meta', 'cmd']\n\n // Use the shared combination splitting logic\n const parts = splitKeyCombination(group.toLowerCase())\n\n // If the combination is invalid, return empty result\n if (parts.length === 0) {\n return { modifiers: Object.fromEntries(MODIFIERS.map(m => [m, false])), actualKey: undefined }\n }\n\n const modifiers = Object.fromEntries(MODIFIERS.map(m => [m, false])) as Record<string, boolean>\n let actualKey: string | undefined\n\n for (const part of parts) {\n if (MODIFIERS.includes(part)) {\n modifiers[part] = true\n } else {\n actualKey = part\n }\n }\n\n return { modifiers, actualKey }\n }\n\n function matchesKeyGroup (e: KeyboardEvent, group: string) {\n const { modifiers, actualKey } = parseKeyGroup(group)\n\n const expectCtrl = modifiers.ctrl || (!isMac && (modifiers.cmd || modifiers.meta))\n const expectMeta = isMac && (modifiers.cmd || modifiers.meta)\n\n return (\n e.ctrlKey === expectCtrl &&\n e.metaKey === expectMeta &&\n e.shiftKey === modifiers.shift &&\n e.altKey === modifiers.alt &&\n e.key.toLowerCase() === actualKey?.toLowerCase()\n )\n }\n\n return cleanup\n}\n"],"mappings":"AAAA;AAAA,SACSA,mBAAmB,EAAEC,gBAAgB,+BAE9C;AACA,SAASC,eAAe,EAAEC,OAAO,EAAEC,KAAK,QAAQ,KAAK;AAAA,SAC5CC,UAAU;AAAA,SACVC,kBAAkB,4CAE3B;AAUA,OAAO,SAASC,SAASA,CACvBC,IAAkC,EAClCC,QAAoC,EAEpC;EAAA,IADAC,OAAsB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAE3B,IAAI,CAACN,UAAU,EAAE,OAAO,YAAY,CAAC,CAAC;EAEtC,MAAM;IACJS,KAAK,GAAG,SAAS;IACjBC,MAAM,GAAG,KAAK;IACdC,cAAc,GAAG,IAAI;IACrBC,eAAe,GAAG;EACpB,CAAC,GAAGP,OAAO;EAEX,MAAMQ,KAAK,GAAGC,SAAS,EAAEC,SAAS,EAAEC,QAAQ,CAAC,WAAW,CAAC,IAAI,KAAK;EAClE,IAAIC,OAAO,GAAG,CAAC;EACf,IAAIC,SAAmB;EACvB,IAAIC,UAAU,GAAG,KAAK;EACtB,IAAIC,UAAU,GAAG,CAAC;EAElB,SAASC,UAAUA,CAAA,EAAI;IACrB,IAAI,CAACJ,OAAO,EAAE;IAEdK,YAAY,CAACL,OAAO,CAAC;IACrBA,OAAO,GAAG,CAAC;EACb;EAEA,SAASM,cAAcA,CAAA,EAAI;IACzB,IAAIzB,OAAO,CAACY,MAAM,CAAC,EAAE,OAAO,KAAK;IAEjC,MAAMc,aAAa,GAAGC,QAAQ,CAACD,aAA4B;IAE3D,OAAOA,aAAa,KAClBA,aAAa,CAACE,OAAO,KAAK,OAAO,IACjCF,aAAa,CAACE,OAAO,KAAK,UAAU,IACpCF,aAAa,CAACG,iBAAiB,IAC/BH,aAAa,CAACI,eAAe,KAAK,MAA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K,EAAE;MACxB,IAAID,SAAS,CAAC9B,QAAQ,CAACsC,IAAI,CAAC,EAAE;QAC5BN,SAAS,CAACM,IAAI,CAAC,GAAG,IAAI;MACxB,CAAC,MAAM;QACLD,SAAS,GAAGC,IAAI;MAClB;IACF;IAEA,OAAO;MAAEN,SAAS;MAAEK;IAAU,CAAC;EACjC;EAEA,SAASpB,eAAeA,CAAEF,CAAgB,EAAEC,KAAa,EAAE;IACzD,MAAM;MAAEgB,SAAS;MAAEK;IAAU,CAAC,GAAGR,aAAa,CAACb,KAAK,CAAC;IAErD,MAAMuB,UAAU,GAAGP,SAAS,CAACQ,IAAI,IAAK,CAAC3C,KAAK,KAAKmC,SAAS,CAACS,GAAG,IAAIT,SAAS,CAACU,IAAI,CAAE;IAClF,MAAMC,UAAU,GAAG9C,KAAK,KAAKmC,SAAS,CAACS,GAAG,IAAIT,SAAS,CAACU,IAAI,CAAC;IAE7D,OACE3B,CAAC,CAAC6B,OAAO,KAAKL,UAAU,IACxBxB,CAAC,CAAC8B,OAAO,KAAKF,UAAU,IACxB5B,CAAC,CAAC+B,QAAQ,KAAKd,SAAS,CAACe,KAAK,IAC9BhC,CAAC,CAACiC,MAAM,KAAKhB,SAAS,CAACiB,GAAG,IAC1BlC,CAAC,CAACmC,GAAG,CAAC1B,WAAW,CAAC,CAAC,KAAKa,SAAS,EAAEb,WAAW,CAAC,CAAC;EAEpD;EAEA,OAAOJ,OAAO;AAChB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useHotkey } from './hotkey.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["useHotkey"],"sources":["../../../src/composables/hotkey/index.ts"],"sourcesContent":["export { useHotkey } from './hotkey'\n"],"mappings":"SAASA,SAAS","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized key alias mapping for consistent key normalization across the hotkey system.
|
|
3
|
+
*
|
|
4
|
+
* This maps various user-friendly aliases to canonical key names that match
|
|
5
|
+
* KeyboardEvent.key values (in lowercase) where possible.
|
|
6
|
+
*/
|
|
7
|
+
export declare const keyAliasMap: Record<string, string>;
|
|
8
|
+
/**
|
|
9
|
+
* Normalizes a key string to its canonical form using the alias map.
|
|
10
|
+
*
|
|
11
|
+
* @param key - The key string to normalize
|
|
12
|
+
* @returns The canonical key name in lowercase
|
|
13
|
+
*/
|
|
14
|
+
export declare function normalizeKey(key: string): string;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized key alias mapping for consistent key normalization across the hotkey system.
|
|
3
|
+
*
|
|
4
|
+
* This maps various user-friendly aliases to canonical key names that match
|
|
5
|
+
* KeyboardEvent.key values (in lowercase) where possible.
|
|
6
|
+
*/
|
|
7
|
+
export const keyAliasMap = {
|
|
8
|
+
// Modifier aliases (from vue-use, other libraries, and current implementation)
|
|
9
|
+
control: 'ctrl',
|
|
10
|
+
command: 'cmd',
|
|
11
|
+
option: 'alt',
|
|
12
|
+
// Arrow key aliases (common abbreviations)
|
|
13
|
+
up: 'arrowup',
|
|
14
|
+
down: 'arrowdown',
|
|
15
|
+
left: 'arrowleft',
|
|
16
|
+
right: 'arrowright',
|
|
17
|
+
// Other common key aliases
|
|
18
|
+
esc: 'escape',
|
|
19
|
+
spacebar: ' ',
|
|
20
|
+
space: ' ',
|
|
21
|
+
return: 'enter',
|
|
22
|
+
del: 'delete',
|
|
23
|
+
// Symbol aliases (existing from hotkey-parsing.ts)
|
|
24
|
+
minus: '-',
|
|
25
|
+
hyphen: '-'
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Normalizes a key string to its canonical form using the alias map.
|
|
30
|
+
*
|
|
31
|
+
* @param key - The key string to normalize
|
|
32
|
+
* @returns The canonical key name in lowercase
|
|
33
|
+
*/
|
|
34
|
+
export function normalizeKey(key) {
|
|
35
|
+
const lowerKey = key.toLowerCase();
|
|
36
|
+
return keyAliasMap[lowerKey] || lowerKey;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=key-aliases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-aliases.js","names":["keyAliasMap","control","command","option","up","down","left","right","esc","spacebar","space","return","del","minus","hyphen","normalizeKey","key","lowerKey","toLowerCase"],"sources":["../../../src/composables/hotkey/key-aliases.ts"],"sourcesContent":["/**\n * Centralized key alias mapping for consistent key normalization across the hotkey system.\n *\n * This maps various user-friendly aliases to canonical key names that match\n * KeyboardEvent.key values (in lowercase) where possible.\n */\nexport const keyAliasMap: Record<string, string> = {\n // Modifier aliases (from vue-use, other libraries, and current implementation)\n control: 'ctrl',\n command: 'cmd',\n option: 'alt',\n\n // Arrow key aliases (common abbreviations)\n up: 'arrowup',\n down: 'arrowdown',\n left: 'arrowleft',\n right: 'arrowright',\n\n // Other common key aliases\n esc: 'escape',\n spacebar: ' ',\n space: ' ',\n return: 'enter',\n del: 'delete',\n\n // Symbol aliases (existing from hotkey-parsing.ts)\n minus: '-',\n hyphen: '-',\n}\n\n/**\n * Normalizes a key string to its canonical form using the alias map.\n *\n * @param key - The key string to normalize\n * @returns The canonical key name in lowercase\n */\nexport function normalizeKey (key: string): string {\n const lowerKey = key.toLowerCase()\n return keyAliasMap[lowerKey] || lowerKey\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,WAAmC,GAAG;EACjD;EACAC,OAAO,EAAE,MAAM;EACfC,OAAO,EAAE,KAAK;EACdC,MAAM,EAAE,KAAK;EAEb;EACAC,EAAE,EAAE,SAAS;EACbC,IAAI,EAAE,WAAW;EACjBC,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE,YAAY;EAEnB;EACAC,GAAG,EAAE,QAAQ;EACbC,QAAQ,EAAE,GAAG;EACbC,KAAK,EAAE,GAAG;EACVC,MAAM,EAAE,OAAO;EACfC,GAAG,EAAE,QAAQ;EAEb;EACAC,KAAK,EAAE,GAAG;EACVC,MAAM,EAAE;AACV,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAAEC,GAAW,EAAU;EACjD,MAAMC,QAAQ,GAAGD,GAAG,CAACE,WAAW,CAAC,CAAC;EAClC,OAAOlB,WAAW,CAACiB,QAAQ,CAAC,IAAIA,QAAQ;AAC1C","ignoreList":[]}
|
|
@@ -45,6 +45,17 @@ export interface IconAliases {
|
|
|
45
45
|
eyeDropper: IconValue;
|
|
46
46
|
upload: IconValue;
|
|
47
47
|
color: IconValue;
|
|
48
|
+
command: IconValue;
|
|
49
|
+
ctrl: IconValue;
|
|
50
|
+
space: IconValue;
|
|
51
|
+
shift: IconValue;
|
|
52
|
+
alt: IconValue;
|
|
53
|
+
enter: IconValue;
|
|
54
|
+
arrowup: IconValue;
|
|
55
|
+
arrowdown: IconValue;
|
|
56
|
+
arrowleft: IconValue;
|
|
57
|
+
arrowright: IconValue;
|
|
58
|
+
backspace: IconValue;
|
|
48
59
|
}
|
|
49
60
|
export interface IconProps {
|
|
50
61
|
tag: string | JSXComponent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.js","names":["aliases","mdi","computed","inject","toValue","consoleWarn","defineComponent","genericComponent","mergeDeep","propsFactory","IconValue","String","Function","Object","Array","IconSymbol","Symbol","for","makeIconProps","icon","type","tag","required","VComponentIcon","name","props","setup","_ref","slots","Icon","_createVNode","default","VSvgIcon","inheritAttrs","_ref2","attrs","_mergeProps","_createElementVNode","isArray","map","path","VLigatureIcon","VClassIcon","_normalizeClass","genDefaults","svg","component","class","createIcons","options","sets","defaultSet","vuetify","useIcon","icons","Error","iconData","iconAlias","trim","startsWith","slice","iconSetName","keys","find","setName","iconName","length","iconSet"],"sources":["../../src/composables/icons.tsx"],"sourcesContent":["// Icons\nimport { aliases, mdi } from '@/iconsets/mdi'\n\n// Utilities\nimport { computed, inject, toValue } from 'vue'\nimport { consoleWarn, defineComponent, genericComponent, mergeDeep, propsFactory } from '@/util'\n\n// Types\nimport type { InjectionKey, MaybeRefOrGetter, PropType } from 'vue'\nimport type { JSXComponent } from '@/util'\n\nexport type IconValue =\n | string\n | (string | [path: string, opacity: number])[]\n | JSXComponent\nexport const IconValue = [String, Function, Object, Array] as PropType<IconValue>\n\nexport interface IconAliases {\n [name: string]: IconValue\n collapse: IconValue\n complete: IconValue\n cancel: IconValue\n close: IconValue\n delete: IconValue\n clear: IconValue\n success: IconValue\n info: IconValue\n warning: IconValue\n error: IconValue\n prev: IconValue\n next: IconValue\n checkboxOn: IconValue\n checkboxOff: IconValue\n checkboxIndeterminate: IconValue\n delimiter: IconValue\n sortAsc: IconValue\n sortDesc: IconValue\n expand: IconValue\n menu: IconValue\n subgroup: IconValue\n dropdown: IconValue\n radioOn: IconValue\n radioOff: IconValue\n edit: IconValue\n ratingEmpty: IconValue\n ratingFull: IconValue\n ratingHalf: IconValue\n loading: IconValue\n first: IconValue\n last: IconValue\n unfold: IconValue\n file: IconValue\n plus: IconValue\n minus: IconValue\n calendar: IconValue\n treeviewCollapse: IconValue\n treeviewExpand: IconValue\n eyeDropper: IconValue\n upload: IconValue\n color: IconValue\n}\n\nexport interface IconProps {\n tag: string | JSXComponent\n icon?: IconValue\n disabled?: boolean\n}\n\ntype IconComponent = JSXComponent<IconProps>\n\nexport interface IconSet {\n component: IconComponent\n}\n\nexport type InternalIconOptions = {\n defaultSet: string\n aliases: Partial<IconAliases>\n sets: Record<string, IconSet>\n}\n\nexport type IconOptions = Partial<InternalIconOptions>\n\ntype IconInstance = {\n component: IconComponent\n icon?: IconValue\n}\n\nexport const IconSymbol: InjectionKey<InternalIconOptions> = Symbol.for('vuetify:icons')\n\nexport const makeIconProps = propsFactory({\n icon: {\n type: IconValue,\n },\n // Could not remove this and use makeTagProps, types complained because it is not required\n tag: {\n type: [String, Object, Function] as PropType<string | JSXComponent>,\n required: true,\n },\n}, 'icon')\n\nexport const VComponentIcon = genericComponent()({\n name: 'VComponentIcon',\n\n props: makeIconProps(),\n\n setup (props, { slots }) {\n return () => {\n const Icon = props.icon as JSXComponent\n return (\n <props.tag>\n { props.icon ? <Icon /> : slots.default?.() }\n </props.tag>\n )\n }\n },\n})\nexport type VComponentIcon = InstanceType<typeof VComponentIcon>\n\nexport const VSvgIcon = defineComponent({\n name: 'VSvgIcon',\n\n inheritAttrs: false,\n\n props: makeIconProps(),\n\n setup (props, { attrs }) {\n return () => {\n return (\n <props.tag { ...attrs } style={ null }>\n <svg\n class=\"v-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n role=\"img\"\n aria-hidden=\"true\"\n >\n { Array.isArray(props.icon)\n ? props.icon.map(path => (\n Array.isArray(path)\n ? <path d={ path[0] as string } fill-opacity={ path[1] }></path>\n : <path d={ path as string }></path>\n ))\n : <path d={ props.icon as string }></path>\n }\n </svg>\n </props.tag>\n )\n }\n },\n})\nexport type VSvgIcon = InstanceType<typeof VSvgIcon>\n\nexport const VLigatureIcon = defineComponent({\n name: 'VLigatureIcon',\n\n props: makeIconProps(),\n\n setup (props) {\n return () => {\n return <props.tag>{ props.icon }</props.tag>\n }\n },\n})\nexport type VLigatureIcon = InstanceType<typeof VLigatureIcon>\n\nexport const VClassIcon = defineComponent({\n name: 'VClassIcon',\n\n props: makeIconProps(),\n\n setup (props) {\n return () => {\n return <props.tag class={ props.icon }></props.tag>\n }\n },\n})\nexport type VClassIcon = InstanceType<typeof VClassIcon>\n\nfunction genDefaults (): Record<string, IconSet> {\n return {\n svg: {\n component: VSvgIcon,\n },\n class: {\n component: VClassIcon,\n },\n }\n}\n\n// Composables\nexport function createIcons (options?: IconOptions) {\n const sets = genDefaults()\n const defaultSet = options?.defaultSet ?? 'mdi'\n\n if (defaultSet === 'mdi' && !sets.mdi) {\n sets.mdi = mdi\n }\n\n return mergeDeep({\n defaultSet,\n sets,\n aliases: {\n ...aliases,\n /* eslint-disable max-len */\n vuetify: [\n 'M8.2241 14.2009L12 21L22 3H14.4459L8.2241 14.2009Z',\n ['M7.26303 12.4733L7.00113 12L2 3H12.5261C12.5261 3 12.5261 3 12.5261 3L7.26303 12.4733Z', 0.6],\n ],\n 'vuetify-outline': 'svg:M7.26 12.47 12.53 3H2L7.26 12.47ZM14.45 3 8.22 14.2 12 21 22 3H14.45ZM18.6 5 12 16.88 10.51 14.2 15.62 5ZM7.26 8.35 5.4 5H9.13L7.26 8.35Z',\n 'vuetify-play': [\n 'm6.376 13.184-4.11-7.192C1.505 4.66 2.467 3 4.003 3h8.532l-.953 1.576-.006.01-.396.677c-.429.732-.214 1.507.194 2.015.404.503 1.092.878 1.869.806a3.72 3.72 0 0 1 1.005.022c.276.053.434.143.523.237.138.146.38.635-.25 2.09-.893 1.63-1.553 1.722-1.847 1.677-.213-.033-.468-.158-.756-.406a4.95 4.95 0 0 1-.8-.927c-.39-.564-1.04-.84-1.66-.846-.625-.006-1.316.27-1.693.921l-.478.826-.911 1.506Z',\n ['M9.093 11.552c.046-.079.144-.15.32-.148a.53.53 0 0 1 .43.207c.285.414.636.847 1.046 1.2.405.35.914.662 1.516.754 1.334.205 2.502-.698 3.48-2.495l.014-.028.013-.03c.687-1.574.774-2.852-.005-3.675-.37-.391-.861-.586-1.333-.676a5.243 5.243 0 0 0-1.447-.044c-.173.016-.393-.073-.54-.257-.145-.18-.127-.316-.082-.392l.393-.672L14.287 3h5.71c1.536 0 2.499 1.659 1.737 2.992l-7.997 13.996c-.768 1.344-2.706 1.344-3.473 0l-3.037-5.314 1.377-2.278.004-.006.004-.007.481-.831Z', 0.6],\n ],\n /* eslint-enable max-len */\n },\n }, options) as InternalIconOptions\n}\n\nexport const useIcon = (props: MaybeRefOrGetter<IconValue | undefined>) => {\n const icons = inject(IconSymbol)\n\n if (!icons) throw new Error('Missing Vuetify Icons provide!')\n\n const iconData = computed<IconInstance>(() => {\n const iconAlias = toValue(props)\n\n if (!iconAlias) return { component: VComponentIcon }\n\n let icon: IconValue | undefined = iconAlias\n\n if (typeof icon === 'string') {\n icon = icon.trim()\n\n if (icon.startsWith('$')) {\n icon = icons.aliases?.[icon.slice(1)]\n }\n }\n\n if (!icon) consoleWarn(`Could not find aliased icon \"${iconAlias}\"`)\n\n if (Array.isArray(icon)) {\n return {\n component: VSvgIcon,\n icon,\n }\n } else if (typeof icon !== 'string') {\n return {\n component: VComponentIcon,\n icon,\n }\n }\n\n const iconSetName = Object.keys(icons.sets).find(\n setName => typeof icon === 'string' && icon.startsWith(`${setName}:`)\n )\n\n const iconName = iconSetName ? icon.slice(iconSetName.length + 1) : icon\n const iconSet = icons.sets[iconSetName ?? icons.defaultSet]\n\n return {\n component: iconSet.component,\n icon: iconName,\n }\n })\n\n return { iconData }\n}\n"],"mappings":";AAAA;AAAA,SACSA,OAAO,EAAEC,GAAG,8BAErB;AACA,SAASC,QAAQ,EAAEC,MAAM,EAAEC,OAAO,QAAQ,KAAK;AAAA,SACtCC,WAAW,EAAEC,eAAe,EAAEC,gBAAgB,EAAEC,SAAS,EAAEC,YAAY,4BAEhF;AAQA,OAAO,MAAMC,SAAS,GAAG,CAACC,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,KAAK,CAAwB;AAwEjF,OAAO,MAAMC,UAA6C,GAAGC,MAAM,CAACC,GAAG,CAAC,eAAe,CAAC;AAExF,OAAO,MAAMC,aAAa,GAAGT,YAAY,CAAC;EACxCU,IAAI,EAAE;IACJC,IAAI,EAAEV;EACR,CAAC;EACD;EACAW,GAAG,EAAE;IACHD,IAAI,EAAE,CAACT,MAAM,EAAEE,MAAM,EAAED,QAAQ,CAAoC;IACnEU,QAAQ,EAAE;EACZ;AACF,CAAC,EAAE,MAAM,CAAC;AAEV,OAAO,MAAMC,cAAc,GAAGhB,gBAAgB,CAAC,CAAC,CAAC;EAC/CiB,IAAI,EAAE,gBAAgB;EAEtBC,KAAK,EAAEP,aAAa,CAAC,CAAC;EAEtBQ,KAAKA,CAAED,KAAK,EAAAE,IAAA,EAAa;IAAA,IAAX;MA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G,CAAC,CAAC,GAAG/C,IAAI;IACxE,MAAMgD,OAAO,GAAGb,KAAK,CAACJ,IAAI,CAACW,WAAW,IAAIP,KAAK,CAACH,UAAU,CAAC;IAE3D,OAAO;MACLL,SAAS,EAAEqB,OAAO,CAACrB,SAAS;MAC5B3B,IAAI,EAAE8C;IACR,CAAC;EACH,CAAC,CAAC;EAEF,OAAO;IAAET;EAAS,CAAC;AACrB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"icons.js","names":["aliases","mdi","computed","inject","toValue","consoleWarn","defineComponent","genericComponent","mergeDeep","propsFactory","IconValue","String","Function","Object","Array","IconSymbol","Symbol","for","makeIconProps","icon","type","tag","required","VComponentIcon","name","props","setup","_ref","slots","Icon","_createVNode","default","VSvgIcon","inheritAttrs","_ref2","attrs","_mergeProps","_createElementVNode","isArray","map","path","VLigatureIcon","VClassIcon","_normalizeClass","genDefaults","svg","component","class","createIcons","options","sets","defaultSet","vuetify","useIcon","icons","Error","iconData","iconAlias","trim","startsWith","slice","iconSetName","keys","find","setName","iconName","length","iconSet"],"sources":["../../src/composables/icons.tsx"],"sourcesContent":["// Icons\nimport { aliases, mdi } from '@/iconsets/mdi'\n\n// Utilities\nimport { computed, inject, toValue } from 'vue'\nimport { consoleWarn, defineComponent, genericComponent, mergeDeep, propsFactory } from '@/util'\n\n// Types\nimport type { InjectionKey, MaybeRefOrGetter, PropType } from 'vue'\nimport type { JSXComponent } from '@/util'\n\nexport type IconValue =\n | string\n | (string | [path: string, opacity: number])[]\n | JSXComponent\nexport const IconValue = [String, Function, Object, Array] as PropType<IconValue>\n\nexport interface IconAliases {\n [name: string]: IconValue\n collapse: IconValue\n complete: IconValue\n cancel: IconValue\n close: IconValue\n delete: IconValue\n clear: IconValue\n success: IconValue\n info: IconValue\n warning: IconValue\n error: IconValue\n prev: IconValue\n next: IconValue\n checkboxOn: IconValue\n checkboxOff: IconValue\n checkboxIndeterminate: IconValue\n delimiter: IconValue\n sortAsc: IconValue\n sortDesc: IconValue\n expand: IconValue\n menu: IconValue\n subgroup: IconValue\n dropdown: IconValue\n radioOn: IconValue\n radioOff: IconValue\n edit: IconValue\n ratingEmpty: IconValue\n ratingFull: IconValue\n ratingHalf: IconValue\n loading: IconValue\n first: IconValue\n last: IconValue\n unfold: IconValue\n file: IconValue\n plus: IconValue\n minus: IconValue\n calendar: IconValue\n treeviewCollapse: IconValue\n treeviewExpand: IconValue\n eyeDropper: IconValue\n upload: IconValue\n color: IconValue\n // Font Awesome does not have most of these icons!\n command: IconValue\n ctrl: IconValue\n space: IconValue\n shift: IconValue\n alt: IconValue\n enter: IconValue\n arrowup: IconValue\n arrowdown: IconValue\n arrowleft: IconValue\n arrowright: IconValue\n backspace: IconValue\n}\n\nexport interface IconProps {\n tag: string | JSXComponent\n icon?: IconValue\n disabled?: boolean\n}\n\ntype IconComponent = JSXComponent<IconProps>\n\nexport interface IconSet {\n component: IconComponent\n}\n\nexport type InternalIconOptions = {\n defaultSet: string\n aliases: Partial<IconAliases>\n sets: Record<string, IconSet>\n}\n\nexport type IconOptions = Partial<InternalIconOptions>\n\ntype IconInstance = {\n component: IconComponent\n icon?: IconValue\n}\n\nexport const IconSymbol: InjectionKey<InternalIconOptions> = Symbol.for('vuetify:icons')\n\nexport const makeIconProps = propsFactory({\n icon: {\n type: IconValue,\n },\n // Could not remove this and use makeTagProps, types complained because it is not required\n tag: {\n type: [String, Object, Function] as PropType<string | JSXComponent>,\n required: true,\n },\n}, 'icon')\n\nexport const VComponentIcon = genericComponent()({\n name: 'VComponentIcon',\n\n props: makeIconProps(),\n\n setup (props, { slots }) {\n return () => {\n const Icon = props.icon as JSXComponent\n return (\n <props.tag>\n { props.icon ? <Icon /> : slots.default?.() }\n </props.tag>\n )\n }\n },\n})\nexport type VComponentIcon = InstanceType<typeof VComponentIcon>\n\nexport const VSvgIcon = defineComponent({\n name: 'VSvgIcon',\n\n inheritAttrs: false,\n\n props: makeIconProps(),\n\n setup (props, { attrs }) {\n return () => {\n return (\n <props.tag { ...attrs } style={ null }>\n <svg\n class=\"v-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n role=\"img\"\n aria-hidden=\"true\"\n >\n { Array.isArray(props.icon)\n ? props.icon.map(path => (\n Array.isArray(path)\n ? <path d={ path[0] as string } fill-opacity={ path[1] }></path>\n : <path d={ path as string }></path>\n ))\n : <path d={ props.icon as string }></path>\n }\n </svg>\n </props.tag>\n )\n }\n },\n})\nexport type VSvgIcon = InstanceType<typeof VSvgIcon>\n\nexport const VLigatureIcon = defineComponent({\n name: 'VLigatureIcon',\n\n props: makeIconProps(),\n\n setup (props) {\n return () => {\n return <props.tag>{ props.icon }</props.tag>\n }\n },\n})\nexport type VLigatureIcon = InstanceType<typeof VLigatureIcon>\n\nexport const VClassIcon = defineComponent({\n name: 'VClassIcon',\n\n props: makeIconProps(),\n\n setup (props) {\n return () => {\n return <props.tag class={ props.icon }></props.tag>\n }\n },\n})\nexport type VClassIcon = InstanceType<typeof VClassIcon>\n\nfunction genDefaults (): Record<string, IconSet> {\n return {\n svg: {\n component: VSvgIcon,\n },\n class: {\n component: VClassIcon,\n },\n }\n}\n\n// Composables\nexport function createIcons (options?: IconOptions) {\n const sets = genDefaults()\n const defaultSet = options?.defaultSet ?? 'mdi'\n\n if (defaultSet === 'mdi' && !sets.mdi) {\n sets.mdi = mdi\n }\n\n return mergeDeep({\n defaultSet,\n sets,\n aliases: {\n ...aliases,\n /* eslint-disable max-len */\n vuetify: [\n 'M8.2241 14.2009L12 21L22 3H14.4459L8.2241 14.2009Z',\n ['M7.26303 12.4733L7.00113 12L2 3H12.5261C12.5261 3 12.5261 3 12.5261 3L7.26303 12.4733Z', 0.6],\n ],\n 'vuetify-outline': 'svg:M7.26 12.47 12.53 3H2L7.26 12.47ZM14.45 3 8.22 14.2 12 21 22 3H14.45ZM18.6 5 12 16.88 10.51 14.2 15.62 5ZM7.26 8.35 5.4 5H9.13L7.26 8.35Z',\n 'vuetify-play': [\n 'm6.376 13.184-4.11-7.192C1.505 4.66 2.467 3 4.003 3h8.532l-.953 1.576-.006.01-.396.677c-.429.732-.214 1.507.194 2.015.404.503 1.092.878 1.869.806a3.72 3.72 0 0 1 1.005.022c.276.053.434.143.523.237.138.146.38.635-.25 2.09-.893 1.63-1.553 1.722-1.847 1.677-.213-.033-.468-.158-.756-.406a4.95 4.95 0 0 1-.8-.927c-.39-.564-1.04-.84-1.66-.846-.625-.006-1.316.27-1.693.921l-.478.826-.911 1.506Z',\n ['M9.093 11.552c.046-.079.144-.15.32-.148a.53.53 0 0 1 .43.207c.285.414.636.847 1.046 1.2.405.35.914.662 1.516.754 1.334.205 2.502-.698 3.48-2.495l.014-.028.013-.03c.687-1.574.774-2.852-.005-3.675-.37-.391-.861-.586-1.333-.676a5.243 5.243 0 0 0-1.447-.044c-.173.016-.393-.073-.54-.257-.145-.18-.127-.316-.082-.392l.393-.672L14.287 3h5.71c1.536 0 2.499 1.659 1.737 2.992l-7.997 13.996c-.768 1.344-2.706 1.344-3.473 0l-3.037-5.314 1.377-2.278.004-.006.004-.007.481-.831Z', 0.6],\n ],\n /* eslint-enable max-len */\n },\n }, options) as InternalIconOptions\n}\n\nexport const useIcon = (props: MaybeRefOrGetter<IconValue | undefined>) => {\n const icons = inject(IconSymbol)\n\n if (!icons) throw new Error('Missing Vuetify Icons provide!')\n\n const iconData = computed<IconInstance>(() => {\n const iconAlias = toValue(props)\n\n if (!iconAlias) return { component: VComponentIcon }\n\n let icon: IconValue | undefined = iconAlias\n\n if (typeof icon === 'string') {\n icon = icon.trim()\n if (icon.startsWith('$')) {\n icon = icons.aliases?.[icon.slice(1)]\n }\n }\n\n if (!icon) consoleWarn(`Could not find aliased icon \"${iconAlias}\"`)\n\n if (Array.isArray(icon)) {\n return {\n component: VSvgIcon,\n icon,\n }\n } else if (typeof icon !== 'string') {\n return {\n component: VComponentIcon,\n icon,\n }\n }\n\n const iconSetName = Object.keys(icons.sets).find(\n setName => typeof icon === 'string' && icon.startsWith(`${setName}:`)\n )\n\n const iconName = iconSetName ? icon.slice(iconSetName.length + 1) : icon\n const iconSet = icons.sets[iconSetName ?? icons.defaultSet]\n\n return {\n component: iconSet.component,\n icon: iconName,\n }\n })\n\n return { iconData }\n}\n"],"mappings":";AAAA;AAAA,SACSA,OAAO,EAAEC,GAAG,8BAErB;AACA,SAASC,QAAQ,EAAEC,MAAM,EAAEC,OAAO,QAAQ,KAAK;AAAA,SACtCC,WAAW,EAAEC,eAAe,EAAEC,gBAAgB,EAAEC,SAAS,EAAEC,YAAY,4BAEhF;AAQA,OAAO,MAAMC,SAAS,GAAG,CAACC,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,KAAK,CAAwB;AAoFjF,OAAO,MAAMC,UAA6C,GAAGC,MAAM,CAACC,GAAG,CAAC,eAAe,CAAC;AAExF,OAAO,MAAMC,aAAa,GAAGT,YAAY,CAAC;EACxCU,IAAI,EAAE;IACJC,IAAI,EAAEV;EACR,CAAC;EACD;EACAW,GAAG,EAAE;IACHD,IAAI,EAAE,CAACT,MAAM,EAAEE,MAAM,EAAED,QAAQ,CAAoC;IACnEU,QAAQ,EAAE;EACZ;AACF,CAAC,EAAE,MAAM,CAAC;AAEV,OAAO,MAAMC,cAAc,GAAGhB,gBAAgB,CAAC,CAAC,CAAC;EAC/CiB,IAAI,EAAE,gBAAgB;EAEtBC,KAAK,EAAEP,aAAa,CAAC,CAAC;EAEtBQ,KAAKA,CAAED,KAAK,EAAAE,IAAA,EAAa;IAAA,IAAX;MAAEC;IAAM,CAAC,GAAAD,IAAA;IACrB,OAAO,MAAM;MACX,MAAME,IAAI,GAAGJ,KAAK,CAACN,IAAoB;MACvC,OAAAW,YAAA,CAAAL,KAAA,CAAAJ,GAAA;QAAAU,OAAA,EAAAA,CAAA,MAEMN,KAAK,CAACN,IAAI,GAAAW,YAAA,CAAAD,IAAA,gBAAcD,KAAK,CAACG,OAAO,GAAG,CAAC;MAAA;IAGjD,CAAC;EACH;A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/lib/composables/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useDate","useDefaults","useDisplay","useGoTo","useLayout","useLocale","useRtl","useTheme"],"sources":["../../src/composables/index.ts"],"sourcesContent":["/*\n * PUBLIC INTERFACES ONLY\n * Imports in our code should be to the composable directly, not this file\n */\n\nexport { useDate } from './date'\nexport { useDefaults } from './defaults'\nexport { useDisplay } from './display'\nexport { useGoTo } from './goto'\nexport { useLayout } from './layout'\nexport { useLocale, useRtl } from './locale'\nexport { useTheme } from './theme'\n"],"mappings":"AAAA;AACA;AACA;AACA;AAHA,SAKSA,OAAO;AAAA,SACPC,WAAW;AAAA,SACXC,UAAU;AAAA,SACVC,OAAO;AAAA,SACPC,SAAS;AAAA,SACTC,SAAS,EAAEC,MAAM;AAAA,SACjBC,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["useDate","useDefaults","useDisplay","useGoTo","useLayout","useLocale","useRtl","useTheme","useHotkey"],"sources":["../../src/composables/index.ts"],"sourcesContent":["/*\n * PUBLIC INTERFACES ONLY\n * Imports in our code should be to the composable directly, not this file\n */\n\nexport { useDate } from './date'\nexport { useDefaults } from './defaults'\nexport { useDisplay } from './display'\nexport { useGoTo } from './goto'\nexport { useLayout } from './layout'\nexport { useLocale, useRtl } from './locale'\nexport { useTheme } from './theme'\nexport { useHotkey } from './hotkey'\n"],"mappings":"AAAA;AACA;AACA;AACA;AAHA,SAKSA,OAAO;AAAA,SACPC,WAAW;AAAA,SACXC,UAAU;AAAA,SACVC,OAAO;AAAA,SACPC,SAAS;AAAA,SACTC,SAAS,EAAEC,MAAM;AAAA,SACjBC,QAAQ;AAAA,SACRC,SAAS","ignoreList":[]}
|