vuetify 3.3.15 → 3.3.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/json/attributes.json +427 -403
  2. package/dist/json/importMap.json +4 -4
  3. package/dist/json/tags.json +1 -0
  4. package/dist/json/web-types.json +908 -879
  5. package/dist/vuetify-labs.css +245 -240
  6. package/dist/vuetify-labs.d.ts +162 -144
  7. package/dist/vuetify-labs.esm.js +121 -136
  8. package/dist/vuetify-labs.esm.js.map +1 -1
  9. package/dist/vuetify-labs.js +121 -136
  10. package/dist/vuetify-labs.min.css +2 -2
  11. package/dist/vuetify.css +92 -88
  12. package/dist/vuetify.d.ts +99 -81
  13. package/dist/vuetify.esm.js +113 -130
  14. package/dist/vuetify.esm.js.map +1 -1
  15. package/dist/vuetify.js +113 -130
  16. package/dist/vuetify.js.map +1 -1
  17. package/dist/vuetify.min.css +2 -2
  18. package/dist/vuetify.min.js +223 -224
  19. package/dist/vuetify.min.js.map +1 -1
  20. package/lib/blueprints/index.d.mts +2 -0
  21. package/lib/blueprints/md1.d.mts +2 -0
  22. package/lib/blueprints/md2.d.mts +2 -0
  23. package/lib/blueprints/md3.d.mts +2 -0
  24. package/lib/components/VAutocomplete/VAutocomplete.mjs +16 -26
  25. package/lib/components/VAutocomplete/VAutocomplete.mjs.map +1 -1
  26. package/lib/components/VAutocomplete/index.d.mts +40 -38
  27. package/lib/components/VColorPicker/VColorPickerCanvas.css +1 -0
  28. package/lib/components/VColorPicker/VColorPickerCanvas.mjs +28 -34
  29. package/lib/components/VColorPicker/VColorPickerCanvas.mjs.map +1 -1
  30. package/lib/components/VColorPicker/VColorPickerCanvas.sass +1 -0
  31. package/lib/components/VCombobox/VCombobox.mjs +15 -25
  32. package/lib/components/VCombobox/VCombobox.mjs.map +1 -1
  33. package/lib/components/VCombobox/index.d.mts +40 -38
  34. package/lib/components/VField/VField.css +3 -2
  35. package/lib/components/VField/VField.sass +3 -2
  36. package/lib/components/VLabel/VLabel.css +1 -0
  37. package/lib/components/VLabel/VLabel.sass +1 -0
  38. package/lib/components/VLabel/_variables.scss +1 -1
  39. package/lib/components/VList/index.d.mts +21 -3
  40. package/lib/components/VSelect/VSelect.mjs +9 -23
  41. package/lib/components/VSelect/VSelect.mjs.map +1 -1
  42. package/lib/components/VSelect/index.d.mts +14 -11
  43. package/lib/components/VSelectionControl/VSelectionControl.css +1 -1
  44. package/lib/components/VSelectionControl/VSelectionControl.sass +1 -1
  45. package/lib/components/VTabs/VTab.css +1 -0
  46. package/lib/components/VTabs/VTab.mjs +2 -3
  47. package/lib/components/VTabs/VTab.mjs.map +1 -1
  48. package/lib/components/VTabs/VTab.sass +1 -0
  49. package/lib/components/VTabs/_variables.scss +1 -0
  50. package/lib/components/index.d.mts +96 -80
  51. package/lib/composables/filter.mjs +4 -4
  52. package/lib/composables/filter.mjs.map +1 -1
  53. package/lib/composables/list-items.mjs +26 -15
  54. package/lib/composables/list-items.mjs.map +1 -1
  55. package/lib/entry-bundler.mjs +1 -1
  56. package/lib/framework.mjs +1 -1
  57. package/lib/index.d.mts +3 -1
  58. package/lib/labs/VBottomSheet/VBottomSheet.css +1 -0
  59. package/lib/labs/VBottomSheet/VBottomSheet.sass +2 -0
  60. package/lib/labs/VBottomSheet/_variables.scss +1 -0
  61. package/lib/labs/VDataIterator/index.d.mts +30 -26
  62. package/lib/labs/VDataTable/index.d.mts +43 -39
  63. package/lib/labs/VDataTable/types.mjs.map +1 -1
  64. package/lib/labs/VDatePicker/VDatePicker.mjs +4 -2
  65. package/lib/labs/VDatePicker/VDatePicker.mjs.map +1 -1
  66. package/lib/labs/VDatePicker/VDatePickerControls.mjs +4 -4
  67. package/lib/labs/VDatePicker/VDatePickerControls.mjs.map +1 -1
  68. package/lib/labs/VDatePicker/VDatePickerYears.css +1 -1
  69. package/lib/labs/VDatePicker/VDatePickerYears.sass +1 -1
  70. package/lib/labs/VDatePicker/index.d.mts +24 -24
  71. package/lib/labs/VDateRangePicker/index.d.mts +8 -8
  72. package/lib/labs/components.d.mts +80 -76
  73. package/lib/labs/date/DateAdapter.mjs.map +1 -1
  74. package/lib/labs/date/adapters/vuetify.d.mts +4 -0
  75. package/lib/labs/date/adapters/vuetify.mjs +13 -0
  76. package/lib/labs/date/adapters/vuetify.mjs.map +1 -1
  77. package/lib/labs/date/index.d.mts +4 -0
  78. package/package.json +2 -2
@@ -4708,10 +4708,14 @@ type VInput = InstanceType<typeof VInput>;
4708
4708
  * - multiple matches (start, end), probably shouldn't overlap
4709
4709
  */
4710
4710
  type FilterMatch = boolean | number | [number, number] | [number, number][];
4711
- type FilterFunction = (value: string, query: string, item?: any) => FilterMatch;
4711
+ type FilterFunction = (value: string, query: string, item?: InternalItem) => FilterMatch;
4712
4712
  type FilterKeyFunctions = Record<string, FilterFunction>;
4713
4713
  type FilterKeys = string | string[];
4714
4714
  type FilterMode = 'some' | 'every' | 'union' | 'intersection';
4715
+ interface InternalItem<T = any> {
4716
+ value: any;
4717
+ raw: T;
4718
+ }
4715
4719
 
4716
4720
  interface ScrollStrategyData {
4717
4721
  root: Ref<HTMLElement | undefined>;
@@ -4769,16 +4773,14 @@ declare function connectedLocationStrategy(data: LocationStrategyData, props: St
4769
4773
  } | undefined;
4770
4774
  };
4771
4775
 
4772
- interface ListItem<T = any> {
4776
+ interface ListItem<T = any> extends InternalItem<T> {
4773
4777
  title: string;
4774
- value: any;
4775
4778
  props: {
4776
4779
  [key: string]: any;
4777
4780
  title: string;
4778
4781
  value: any;
4779
4782
  };
4780
4783
  children?: ListItem<T>[];
4781
- raw: T;
4782
4784
  }
4783
4785
 
4784
4786
  type Primitive$2 = string | number | boolean | symbol;
@@ -4818,6 +4820,9 @@ declare const VAutocomplete: {
4818
4820
  rules?: readonly ValidationRule[] | undefined;
4819
4821
  centerAffix?: boolean | undefined;
4820
4822
  persistentHint?: boolean | undefined;
4823
+ filterMode?: FilterMode | undefined;
4824
+ noFilter?: boolean | undefined;
4825
+ filterKeys?: NonNullable<FilterKeys> | undefined;
4821
4826
  itemTitle?: SelectItemKey | undefined;
4822
4827
  itemValue?: SelectItemKey | undefined;
4823
4828
  itemChildren?: NonNullable<SelectItemKey> | undefined;
@@ -4835,9 +4840,6 @@ declare const VAutocomplete: {
4835
4840
  hideSelected?: boolean | undefined;
4836
4841
  menuIcon?: IconValue | undefined;
4837
4842
  openOnClear?: boolean | undefined;
4838
- filterMode?: FilterMode | undefined;
4839
- noFilter?: boolean | undefined;
4840
- filterKeys?: NonNullable<FilterKeys> | undefined;
4841
4843
  search?: string | undefined;
4842
4844
  key?: string | number | symbol | undefined;
4843
4845
  id?: string | undefined;
@@ -4906,6 +4908,8 @@ declare const VAutocomplete: {
4906
4908
  hint?: string | undefined;
4907
4909
  hideDetails?: boolean | "auto" | undefined;
4908
4910
  baseColor?: string | undefined;
4911
+ customFilter?: FilterFunction | undefined;
4912
+ customKeyFilter?: FilterKeyFunctions | undefined;
4909
4913
  suffix?: string | undefined;
4910
4914
  counterValue?: ((value: any) => number) | undefined;
4911
4915
  modelModifiers?: Record<string, boolean> | undefined;
@@ -5025,8 +5029,6 @@ declare const VAutocomplete: {
5025
5029
  } | undefined;
5026
5030
  itemColor?: string | undefined;
5027
5031
  "onUpdate:menu"?: ((val: boolean) => any) | undefined;
5028
- customFilter?: FilterFunction | undefined;
5029
- customKeyFilter?: FilterKeyFunctions | undefined;
5030
5032
  autoSelectFirst?: boolean | "exact" | undefined;
5031
5033
  "onUpdate:search"?: ((val: any) => any) | undefined;
5032
5034
  };
@@ -5129,6 +5131,9 @@ declare const VAutocomplete: {
5129
5131
  maxErrors: string | number;
5130
5132
  rules: readonly ValidationRule[];
5131
5133
  persistentHint: boolean;
5134
+ filterMode: FilterMode;
5135
+ noFilter: boolean;
5136
+ filterKeys: NonNullable<FilterKeys>;
5132
5137
  itemTitle: SelectItemKey;
5133
5138
  itemValue: SelectItemKey;
5134
5139
  itemChildren: NonNullable<SelectItemKey>;
@@ -5146,9 +5151,6 @@ declare const VAutocomplete: {
5146
5151
  hideSelected: boolean;
5147
5152
  menuIcon: IconValue;
5148
5153
  openOnClear: boolean;
5149
- filterMode: FilterMode;
5150
- noFilter: boolean;
5151
- filterKeys: NonNullable<FilterKeys>;
5152
5154
  } & {
5153
5155
  search?: string | undefined;
5154
5156
  id?: string | undefined;
@@ -5177,6 +5179,8 @@ declare const VAutocomplete: {
5177
5179
  hint?: string | undefined;
5178
5180
  hideDetails?: boolean | "auto" | undefined;
5179
5181
  baseColor?: string | undefined;
5182
+ customFilter?: FilterFunction | undefined;
5183
+ customKeyFilter?: FilterKeyFunctions | undefined;
5180
5184
  suffix?: string | undefined;
5181
5185
  counterValue?: ((value: any) => number) | undefined;
5182
5186
  modelModifiers?: Record<string, boolean> | undefined;
@@ -5295,8 +5299,6 @@ declare const VAutocomplete: {
5295
5299
  attach?: string | boolean | Element | undefined;
5296
5300
  } | undefined;
5297
5301
  itemColor?: string | undefined;
5298
- customFilter?: FilterFunction | undefined;
5299
- customKeyFilter?: FilterKeyFunctions | undefined;
5300
5302
  autoSelectFirst?: boolean | "exact" | undefined;
5301
5303
  } & {
5302
5304
  "onUpdate:modelValue"?: ((val: any) => any) | undefined;
@@ -5338,6 +5340,9 @@ declare const VAutocomplete: {
5338
5340
  rules: readonly ValidationRule[];
5339
5341
  centerAffix: boolean;
5340
5342
  persistentHint: boolean;
5343
+ filterMode: FilterMode;
5344
+ noFilter: boolean;
5345
+ filterKeys: NonNullable<FilterKeys>;
5341
5346
  itemTitle: SelectItemKey;
5342
5347
  itemValue: SelectItemKey;
5343
5348
  itemChildren: NonNullable<SelectItemKey>;
@@ -5355,9 +5360,6 @@ declare const VAutocomplete: {
5355
5360
  hideSelected: boolean;
5356
5361
  menuIcon: IconValue;
5357
5362
  openOnClear: boolean;
5358
- filterMode: FilterMode;
5359
- noFilter: boolean;
5360
- filterKeys: NonNullable<FilterKeys>;
5361
5363
  }, {}, string, vue.SlotsType<Partial<{
5362
5364
  message: (arg: VMessageSlot) => vue.VNode<vue.RendererNode, vue.RendererElement, {
5363
5365
  [key: string]: any;
@@ -5466,6 +5468,9 @@ declare const VAutocomplete: {
5466
5468
  maxErrors: string | number;
5467
5469
  rules: readonly ValidationRule[];
5468
5470
  persistentHint: boolean;
5471
+ filterMode: FilterMode;
5472
+ noFilter: boolean;
5473
+ filterKeys: NonNullable<FilterKeys>;
5469
5474
  itemTitle: SelectItemKey;
5470
5475
  itemValue: SelectItemKey;
5471
5476
  itemChildren: NonNullable<SelectItemKey>;
@@ -5483,9 +5488,6 @@ declare const VAutocomplete: {
5483
5488
  hideSelected: boolean;
5484
5489
  menuIcon: IconValue;
5485
5490
  openOnClear: boolean;
5486
- filterMode: FilterMode;
5487
- noFilter: boolean;
5488
- filterKeys: NonNullable<FilterKeys>;
5489
5491
  } & {
5490
5492
  search?: string | undefined;
5491
5493
  id?: string | undefined;
@@ -5514,6 +5516,8 @@ declare const VAutocomplete: {
5514
5516
  hint?: string | undefined;
5515
5517
  hideDetails?: boolean | "auto" | undefined;
5516
5518
  baseColor?: string | undefined;
5519
+ customFilter?: FilterFunction | undefined;
5520
+ customKeyFilter?: FilterKeyFunctions | undefined;
5517
5521
  suffix?: string | undefined;
5518
5522
  counterValue?: ((value: any) => number) | undefined;
5519
5523
  modelModifiers?: Record<string, boolean> | undefined;
@@ -5632,8 +5636,6 @@ declare const VAutocomplete: {
5632
5636
  attach?: string | boolean | Element | undefined;
5633
5637
  } | undefined;
5634
5638
  itemColor?: string | undefined;
5635
- customFilter?: FilterFunction | undefined;
5636
- customKeyFilter?: FilterKeyFunctions | undefined;
5637
5639
  autoSelectFirst?: boolean | "exact" | undefined;
5638
5640
  } & {
5639
5641
  "onUpdate:modelValue"?: ((val: any) => any) | undefined;
@@ -5672,6 +5674,9 @@ declare const VAutocomplete: {
5672
5674
  maxErrors: string | number;
5673
5675
  rules: readonly ValidationRule[];
5674
5676
  persistentHint: boolean;
5677
+ filterMode: FilterMode;
5678
+ noFilter: boolean;
5679
+ filterKeys: NonNullable<FilterKeys>;
5675
5680
  itemTitle: SelectItemKey;
5676
5681
  itemValue: SelectItemKey;
5677
5682
  itemChildren: NonNullable<SelectItemKey>;
@@ -5689,9 +5694,6 @@ declare const VAutocomplete: {
5689
5694
  hideSelected: boolean;
5690
5695
  menuIcon: IconValue;
5691
5696
  openOnClear: boolean;
5692
- filterMode: FilterMode;
5693
- noFilter: boolean;
5694
- filterKeys: NonNullable<FilterKeys>;
5695
5697
  } & {
5696
5698
  search?: string | undefined;
5697
5699
  id?: string | undefined;
@@ -5720,6 +5722,8 @@ declare const VAutocomplete: {
5720
5722
  hint?: string | undefined;
5721
5723
  hideDetails?: boolean | "auto" | undefined;
5722
5724
  baseColor?: string | undefined;
5725
+ customFilter?: FilterFunction | undefined;
5726
+ customKeyFilter?: FilterKeyFunctions | undefined;
5723
5727
  suffix?: string | undefined;
5724
5728
  counterValue?: ((value: any) => number) | undefined;
5725
5729
  modelModifiers?: Record<string, boolean> | undefined;
@@ -5838,8 +5842,6 @@ declare const VAutocomplete: {
5838
5842
  attach?: string | boolean | Element | undefined;
5839
5843
  } | undefined;
5840
5844
  itemColor?: string | undefined;
5841
- customFilter?: FilterFunction | undefined;
5842
- customKeyFilter?: FilterKeyFunctions | undefined;
5843
5845
  autoSelectFirst?: boolean | "exact" | undefined;
5844
5846
  } & {
5845
5847
  "onUpdate:modelValue"?: ((val: any) => any) | undefined;
@@ -5881,6 +5883,9 @@ declare const VAutocomplete: {
5881
5883
  rules: readonly ValidationRule[];
5882
5884
  centerAffix: boolean;
5883
5885
  persistentHint: boolean;
5886
+ filterMode: FilterMode;
5887
+ noFilter: boolean;
5888
+ filterKeys: NonNullable<FilterKeys>;
5884
5889
  itemTitle: SelectItemKey;
5885
5890
  itemValue: SelectItemKey;
5886
5891
  itemChildren: NonNullable<SelectItemKey>;
@@ -5898,9 +5903,6 @@ declare const VAutocomplete: {
5898
5903
  hideSelected: boolean;
5899
5904
  menuIcon: IconValue;
5900
5905
  openOnClear: boolean;
5901
- filterMode: FilterMode;
5902
- noFilter: boolean;
5903
- filterKeys: NonNullable<FilterKeys>;
5904
5906
  }, {}, string, vue.SlotsType<Partial<{
5905
5907
  message: (arg: VMessageSlot) => vue.VNode<vue.RendererNode, vue.RendererElement, {
5906
5908
  [key: string]: any;
@@ -6154,6 +6156,10 @@ declare const VAutocomplete: {
6154
6156
  default: string;
6155
6157
  };
6156
6158
  returnObject: BooleanConstructor;
6159
+ valueComparator: {
6160
+ type: PropType<typeof deepEqual>;
6161
+ default: typeof deepEqual;
6162
+ };
6157
6163
  chips: BooleanConstructor;
6158
6164
  closableChips: BooleanConstructor;
6159
6165
  closeText: {
@@ -6294,10 +6300,6 @@ declare const VAutocomplete: {
6294
6300
  default: string;
6295
6301
  };
6296
6302
  openOnClear: BooleanConstructor;
6297
- valueComparator: {
6298
- type: PropType<typeof deepEqual>;
6299
- default: typeof deepEqual;
6300
- };
6301
6303
  itemColor: StringConstructor;
6302
6304
  customFilter: PropType<FilterFunction>;
6303
6305
  customKeyFilter: PropType<FilterKeyFunctions>;
@@ -6459,6 +6461,10 @@ declare const VAutocomplete: {
6459
6461
  default: string;
6460
6462
  };
6461
6463
  returnObject: BooleanConstructor;
6464
+ valueComparator: {
6465
+ type: PropType<typeof deepEqual>;
6466
+ default: typeof deepEqual;
6467
+ };
6462
6468
  chips: BooleanConstructor;
6463
6469
  closableChips: BooleanConstructor;
6464
6470
  closeText: {
@@ -6599,10 +6605,6 @@ declare const VAutocomplete: {
6599
6605
  default: string;
6600
6606
  };
6601
6607
  openOnClear: BooleanConstructor;
6602
- valueComparator: {
6603
- type: PropType<typeof deepEqual>;
6604
- default: typeof deepEqual;
6605
- };
6606
6608
  itemColor: StringConstructor;
6607
6609
  customFilter: PropType<FilterFunction>;
6608
6610
  customKeyFilter: PropType<FilterKeyFunctions>;
@@ -17825,6 +17827,9 @@ declare const VCombobox: {
17825
17827
  rules?: readonly ValidationRule[] | undefined;
17826
17828
  centerAffix?: boolean | undefined;
17827
17829
  persistentHint?: boolean | undefined;
17830
+ filterMode?: FilterMode | undefined;
17831
+ noFilter?: boolean | undefined;
17832
+ filterKeys?: NonNullable<FilterKeys> | undefined;
17828
17833
  itemTitle?: SelectItemKey | undefined;
17829
17834
  itemValue?: SelectItemKey | undefined;
17830
17835
  itemChildren?: NonNullable<SelectItemKey> | undefined;
@@ -17842,9 +17847,6 @@ declare const VCombobox: {
17842
17847
  hideSelected?: boolean | undefined;
17843
17848
  menuIcon?: IconValue | undefined;
17844
17849
  openOnClear?: boolean | undefined;
17845
- filterMode?: FilterMode | undefined;
17846
- noFilter?: boolean | undefined;
17847
- filterKeys?: NonNullable<FilterKeys> | undefined;
17848
17850
  key?: string | number | symbol | undefined;
17849
17851
  id?: string | undefined;
17850
17852
  name?: string | undefined;
@@ -17913,6 +17915,8 @@ declare const VCombobox: {
17913
17915
  hint?: string | undefined;
17914
17916
  hideDetails?: boolean | "auto" | undefined;
17915
17917
  baseColor?: string | undefined;
17918
+ customFilter?: FilterFunction | undefined;
17919
+ customKeyFilter?: FilterKeyFunctions | undefined;
17916
17920
  suffix?: string | undefined;
17917
17921
  counterValue?: ((value: any) => number) | undefined;
17918
17922
  modelModifiers?: Record<string, boolean> | undefined;
@@ -18032,8 +18036,6 @@ declare const VCombobox: {
18032
18036
  } | undefined;
18033
18037
  itemColor?: string | undefined;
18034
18038
  "onUpdate:menu"?: ((val: boolean) => any) | undefined;
18035
- customFilter?: FilterFunction | undefined;
18036
- customKeyFilter?: FilterKeyFunctions | undefined;
18037
18039
  autoSelectFirst?: boolean | "exact" | undefined;
18038
18040
  "onUpdate:search"?: ((val: string) => any) | undefined;
18039
18041
  };
@@ -18136,6 +18138,9 @@ declare const VCombobox: {
18136
18138
  maxErrors: string | number;
18137
18139
  rules: readonly ValidationRule[];
18138
18140
  persistentHint: boolean;
18141
+ filterMode: FilterMode;
18142
+ noFilter: boolean;
18143
+ filterKeys: NonNullable<FilterKeys>;
18139
18144
  itemTitle: SelectItemKey;
18140
18145
  itemValue: SelectItemKey;
18141
18146
  itemChildren: NonNullable<SelectItemKey>;
@@ -18153,9 +18158,6 @@ declare const VCombobox: {
18153
18158
  hideSelected: boolean;
18154
18159
  menuIcon: IconValue;
18155
18160
  openOnClear: boolean;
18156
- filterMode: FilterMode;
18157
- noFilter: boolean;
18158
- filterKeys: NonNullable<FilterKeys>;
18159
18161
  } & {
18160
18162
  id?: string | undefined;
18161
18163
  name?: string | undefined;
@@ -18184,6 +18186,8 @@ declare const VCombobox: {
18184
18186
  hint?: string | undefined;
18185
18187
  hideDetails?: boolean | "auto" | undefined;
18186
18188
  baseColor?: string | undefined;
18189
+ customFilter?: FilterFunction | undefined;
18190
+ customKeyFilter?: FilterKeyFunctions | undefined;
18187
18191
  suffix?: string | undefined;
18188
18192
  counterValue?: ((value: any) => number) | undefined;
18189
18193
  modelModifiers?: Record<string, boolean> | undefined;
@@ -18302,8 +18306,6 @@ declare const VCombobox: {
18302
18306
  attach?: string | boolean | Element | undefined;
18303
18307
  } | undefined;
18304
18308
  itemColor?: string | undefined;
18305
- customFilter?: FilterFunction | undefined;
18306
- customKeyFilter?: FilterKeyFunctions | undefined;
18307
18309
  autoSelectFirst?: boolean | "exact" | undefined;
18308
18310
  } & {
18309
18311
  "onUpdate:modelValue"?: ((val: any) => any) | undefined;
@@ -18345,6 +18347,9 @@ declare const VCombobox: {
18345
18347
  rules: readonly ValidationRule[];
18346
18348
  centerAffix: boolean;
18347
18349
  persistentHint: boolean;
18350
+ filterMode: FilterMode;
18351
+ noFilter: boolean;
18352
+ filterKeys: NonNullable<FilterKeys>;
18348
18353
  itemTitle: SelectItemKey;
18349
18354
  itemValue: SelectItemKey;
18350
18355
  itemChildren: NonNullable<SelectItemKey>;
@@ -18362,9 +18367,6 @@ declare const VCombobox: {
18362
18367
  hideSelected: boolean;
18363
18368
  menuIcon: IconValue;
18364
18369
  openOnClear: boolean;
18365
- filterMode: FilterMode;
18366
- noFilter: boolean;
18367
- filterKeys: NonNullable<FilterKeys>;
18368
18370
  }, {}, string, vue.SlotsType<Partial<{
18369
18371
  message: (arg: VMessageSlot) => vue.VNode<vue.RendererNode, vue.RendererElement, {
18370
18372
  [key: string]: any;
@@ -18473,6 +18475,9 @@ declare const VCombobox: {
18473
18475
  maxErrors: string | number;
18474
18476
  rules: readonly ValidationRule[];
18475
18477
  persistentHint: boolean;
18478
+ filterMode: FilterMode;
18479
+ noFilter: boolean;
18480
+ filterKeys: NonNullable<FilterKeys>;
18476
18481
  itemTitle: SelectItemKey;
18477
18482
  itemValue: SelectItemKey;
18478
18483
  itemChildren: NonNullable<SelectItemKey>;
@@ -18490,9 +18495,6 @@ declare const VCombobox: {
18490
18495
  hideSelected: boolean;
18491
18496
  menuIcon: IconValue;
18492
18497
  openOnClear: boolean;
18493
- filterMode: FilterMode;
18494
- noFilter: boolean;
18495
- filterKeys: NonNullable<FilterKeys>;
18496
18498
  } & {
18497
18499
  id?: string | undefined;
18498
18500
  name?: string | undefined;
@@ -18521,6 +18523,8 @@ declare const VCombobox: {
18521
18523
  hint?: string | undefined;
18522
18524
  hideDetails?: boolean | "auto" | undefined;
18523
18525
  baseColor?: string | undefined;
18526
+ customFilter?: FilterFunction | undefined;
18527
+ customKeyFilter?: FilterKeyFunctions | undefined;
18524
18528
  suffix?: string | undefined;
18525
18529
  counterValue?: ((value: any) => number) | undefined;
18526
18530
  modelModifiers?: Record<string, boolean> | undefined;
@@ -18639,8 +18643,6 @@ declare const VCombobox: {
18639
18643
  attach?: string | boolean | Element | undefined;
18640
18644
  } | undefined;
18641
18645
  itemColor?: string | undefined;
18642
- customFilter?: FilterFunction | undefined;
18643
- customKeyFilter?: FilterKeyFunctions | undefined;
18644
18646
  autoSelectFirst?: boolean | "exact" | undefined;
18645
18647
  } & {
18646
18648
  "onUpdate:modelValue"?: ((val: any) => any) | undefined;
@@ -18679,6 +18681,9 @@ declare const VCombobox: {
18679
18681
  maxErrors: string | number;
18680
18682
  rules: readonly ValidationRule[];
18681
18683
  persistentHint: boolean;
18684
+ filterMode: FilterMode;
18685
+ noFilter: boolean;
18686
+ filterKeys: NonNullable<FilterKeys>;
18682
18687
  itemTitle: SelectItemKey;
18683
18688
  itemValue: SelectItemKey;
18684
18689
  itemChildren: NonNullable<SelectItemKey>;
@@ -18696,9 +18701,6 @@ declare const VCombobox: {
18696
18701
  hideSelected: boolean;
18697
18702
  menuIcon: IconValue;
18698
18703
  openOnClear: boolean;
18699
- filterMode: FilterMode;
18700
- noFilter: boolean;
18701
- filterKeys: NonNullable<FilterKeys>;
18702
18704
  } & {
18703
18705
  id?: string | undefined;
18704
18706
  name?: string | undefined;
@@ -18727,6 +18729,8 @@ declare const VCombobox: {
18727
18729
  hint?: string | undefined;
18728
18730
  hideDetails?: boolean | "auto" | undefined;
18729
18731
  baseColor?: string | undefined;
18732
+ customFilter?: FilterFunction | undefined;
18733
+ customKeyFilter?: FilterKeyFunctions | undefined;
18730
18734
  suffix?: string | undefined;
18731
18735
  counterValue?: ((value: any) => number) | undefined;
18732
18736
  modelModifiers?: Record<string, boolean> | undefined;
@@ -18845,8 +18849,6 @@ declare const VCombobox: {
18845
18849
  attach?: string | boolean | Element | undefined;
18846
18850
  } | undefined;
18847
18851
  itemColor?: string | undefined;
18848
- customFilter?: FilterFunction | undefined;
18849
- customKeyFilter?: FilterKeyFunctions | undefined;
18850
18852
  autoSelectFirst?: boolean | "exact" | undefined;
18851
18853
  } & {
18852
18854
  "onUpdate:modelValue"?: ((val: any) => any) | undefined;
@@ -18888,6 +18890,9 @@ declare const VCombobox: {
18888
18890
  rules: readonly ValidationRule[];
18889
18891
  centerAffix: boolean;
18890
18892
  persistentHint: boolean;
18893
+ filterMode: FilterMode;
18894
+ noFilter: boolean;
18895
+ filterKeys: NonNullable<FilterKeys>;
18891
18896
  itemTitle: SelectItemKey;
18892
18897
  itemValue: SelectItemKey;
18893
18898
  itemChildren: NonNullable<SelectItemKey>;
@@ -18905,9 +18910,6 @@ declare const VCombobox: {
18905
18910
  hideSelected: boolean;
18906
18911
  menuIcon: IconValue;
18907
18912
  openOnClear: boolean;
18908
- filterMode: FilterMode;
18909
- noFilter: boolean;
18910
- filterKeys: NonNullable<FilterKeys>;
18911
18913
  }, {}, string, vue.SlotsType<Partial<{
18912
18914
  message: (arg: VMessageSlot) => vue.VNode<vue.RendererNode, vue.RendererElement, {
18913
18915
  [key: string]: any;
@@ -19164,6 +19166,10 @@ declare const VCombobox: {
19164
19166
  type: PropType<boolean>;
19165
19167
  default: boolean;
19166
19168
  };
19169
+ valueComparator: {
19170
+ type: PropType<typeof deepEqual>;
19171
+ default: typeof deepEqual;
19172
+ };
19167
19173
  chips: BooleanConstructor;
19168
19174
  closableChips: BooleanConstructor;
19169
19175
  closeText: {
@@ -19307,10 +19313,6 @@ declare const VCombobox: {
19307
19313
  default: string;
19308
19314
  };
19309
19315
  openOnClear: BooleanConstructor;
19310
- valueComparator: {
19311
- type: PropType<typeof deepEqual>;
19312
- default: typeof deepEqual;
19313
- };
19314
19316
  itemColor: StringConstructor;
19315
19317
  customFilter: PropType<FilterFunction>;
19316
19318
  customKeyFilter: PropType<FilterKeyFunctions>;
@@ -19475,6 +19477,10 @@ declare const VCombobox: {
19475
19477
  type: PropType<boolean>;
19476
19478
  default: boolean;
19477
19479
  };
19480
+ valueComparator: {
19481
+ type: PropType<typeof deepEqual>;
19482
+ default: typeof deepEqual;
19483
+ };
19478
19484
  chips: BooleanConstructor;
19479
19485
  closableChips: BooleanConstructor;
19480
19486
  closeText: {
@@ -19618,10 +19624,6 @@ declare const VCombobox: {
19618
19624
  default: string;
19619
19625
  };
19620
19626
  openOnClear: BooleanConstructor;
19621
- valueComparator: {
19622
- type: PropType<typeof deepEqual>;
19623
- default: typeof deepEqual;
19624
- };
19625
19627
  itemColor: StringConstructor;
19626
19628
  customFilter: PropType<FilterFunction>;
19627
19629
  customKeyFilter: PropType<FilterKeyFunctions>;
@@ -30382,6 +30384,7 @@ declare const VList: {
30382
30384
  rounded?: string | number | boolean | undefined;
30383
30385
  density?: Density | undefined;
30384
30386
  variant?: NonNullable<"flat" | "text" | "elevated" | "tonal" | "outlined" | "plain"> | undefined;
30387
+ valueComparator?: typeof deepEqual | undefined;
30385
30388
  selectStrategy?: NonNullable<SelectStrategy> | undefined;
30386
30389
  openStrategy?: NonNullable<OpenStrategyProp> | undefined;
30387
30390
  lines?: false | "one" | "two" | "three" | undefined;
@@ -30560,6 +30563,7 @@ declare const VList: {
30560
30563
  mandatory: boolean;
30561
30564
  density: Density;
30562
30565
  variant: NonNullable<"flat" | "text" | "elevated" | "tonal" | "outlined" | "plain">;
30566
+ valueComparator: typeof deepEqual;
30563
30567
  selectStrategy: NonNullable<SelectStrategy>;
30564
30568
  openStrategy: NonNullable<OpenStrategyProp>;
30565
30569
  lines: false | "one" | "two" | "three";
@@ -30627,6 +30631,7 @@ declare const VList: {
30627
30631
  rounded: string | number | boolean;
30628
30632
  density: Density;
30629
30633
  variant: NonNullable<"flat" | "text" | "elevated" | "tonal" | "outlined" | "plain">;
30634
+ valueComparator: typeof deepEqual;
30630
30635
  selectStrategy: NonNullable<SelectStrategy>;
30631
30636
  openStrategy: NonNullable<OpenStrategyProp>;
30632
30637
  lines: false | "one" | "two" | "three";
@@ -30734,6 +30739,7 @@ declare const VList: {
30734
30739
  mandatory: boolean;
30735
30740
  density: Density;
30736
30741
  variant: NonNullable<"flat" | "text" | "elevated" | "tonal" | "outlined" | "plain">;
30742
+ valueComparator: typeof deepEqual;
30737
30743
  selectStrategy: NonNullable<SelectStrategy>;
30738
30744
  openStrategy: NonNullable<OpenStrategyProp>;
30739
30745
  lines: false | "one" | "two" | "three";
@@ -30791,6 +30797,7 @@ declare const VList: {
30791
30797
  mandatory: boolean;
30792
30798
  density: Density;
30793
30799
  variant: NonNullable<"flat" | "text" | "elevated" | "tonal" | "outlined" | "plain">;
30800
+ valueComparator: typeof deepEqual;
30794
30801
  selectStrategy: NonNullable<SelectStrategy>;
30795
30802
  openStrategy: NonNullable<OpenStrategyProp>;
30796
30803
  lines: false | "one" | "two" | "three";
@@ -30858,6 +30865,7 @@ declare const VList: {
30858
30865
  rounded: string | number | boolean;
30859
30866
  density: Density;
30860
30867
  variant: NonNullable<"flat" | "text" | "elevated" | "tonal" | "outlined" | "plain">;
30868
+ valueComparator: typeof deepEqual;
30861
30869
  selectStrategy: NonNullable<SelectStrategy>;
30862
30870
  openStrategy: NonNullable<OpenStrategyProp>;
30863
30871
  lines: false | "one" | "two" | "three";
@@ -30981,6 +30989,10 @@ declare const VList: {
30981
30989
  default: string;
30982
30990
  };
30983
30991
  returnObject: BooleanConstructor;
30992
+ valueComparator: {
30993
+ type: PropType<typeof deepEqual>;
30994
+ default: typeof deepEqual;
30995
+ };
30984
30996
  itemType: {
30985
30997
  type: StringConstructor;
30986
30998
  default: string;
@@ -31067,6 +31079,10 @@ declare const VList: {
31067
31079
  default: string;
31068
31080
  };
31069
31081
  returnObject: BooleanConstructor;
31082
+ valueComparator: {
31083
+ type: PropType<typeof deepEqual>;
31084
+ default: typeof deepEqual;
31085
+ };
31070
31086
  itemType: {
31071
31087
  type: StringConstructor;
31072
31088
  default: string;
@@ -41589,6 +41605,10 @@ declare const VSelect: {
41589
41605
  default: string;
41590
41606
  };
41591
41607
  returnObject: BooleanConstructor;
41608
+ valueComparator: {
41609
+ type: PropType<typeof deepEqual>;
41610
+ default: typeof deepEqual;
41611
+ };
41592
41612
  chips: BooleanConstructor;
41593
41613
  closableChips: BooleanConstructor;
41594
41614
  closeText: {
@@ -41729,10 +41749,6 @@ declare const VSelect: {
41729
41749
  default: string;
41730
41750
  };
41731
41751
  openOnClear: BooleanConstructor;
41732
- valueComparator: {
41733
- type: PropType<typeof deepEqual>;
41734
- default: typeof deepEqual;
41735
- };
41736
41752
  itemColor: StringConstructor;
41737
41753
  }, vue.ExtractPropTypes<{
41738
41754
  transition: Omit<{
@@ -41883,6 +41899,10 @@ declare const VSelect: {
41883
41899
  default: string;
41884
41900
  };
41885
41901
  returnObject: BooleanConstructor;
41902
+ valueComparator: {
41903
+ type: PropType<typeof deepEqual>;
41904
+ default: typeof deepEqual;
41905
+ };
41886
41906
  chips: BooleanConstructor;
41887
41907
  closableChips: BooleanConstructor;
41888
41908
  closeText: {
@@ -42023,10 +42043,6 @@ declare const VSelect: {
42023
42043
  default: string;
42024
42044
  };
42025
42045
  openOnClear: BooleanConstructor;
42026
- valueComparator: {
42027
- type: PropType<typeof deepEqual>;
42028
- default: typeof deepEqual;
42029
- };
42030
42046
  itemColor: StringConstructor;
42031
42047
  }>>;
42032
42048
  type VSelect = InstanceType<typeof VSelect>;
@@ -27,15 +27,15 @@ export function filterItems(items, query, options) {
27
27
  const customFiltersLength = Object.keys(options?.customKeyFilter ?? {}).length;
28
28
  if (!items?.length) return array;
29
29
  loop: for (let i = 0; i < items.length; i++) {
30
- const item = items[i];
30
+ const [item, transformed = item] = wrapInArray(items[i]);
31
31
  const customMatches = {};
32
32
  const defaultMatches = {};
33
33
  let match = -1;
34
34
  if (query && !options?.noFilter) {
35
35
  if (typeof item === 'object') {
36
- const filterKeys = keys || Object.keys(item);
36
+ const filterKeys = keys || Object.keys(transformed);
37
37
  for (const key of filterKeys) {
38
- const value = getPropertyFromItem(item, key, item);
38
+ const value = getPropertyFromItem(transformed, key, transformed);
39
39
  const keyFilter = options?.customKeyFilter?.[key];
40
40
  match = keyFilter ? keyFilter(value, query, item) : filter(value, query, item);
41
41
  if (match !== -1 && match !== false) {
@@ -69,7 +69,7 @@ export function filterItems(items, query, options) {
69
69
  export function useFilter(props, items, query, options) {
70
70
  const filteredItems = ref([]);
71
71
  const filteredMatches = ref(new Map());
72
- const transformedItems = computed(() => options?.transform ? unref(items).map(options?.transform) : unref(items));
72
+ const transformedItems = computed(() => options?.transform ? unref(items).map(item => [item, options.transform(item)]) : unref(items));
73
73
  watchEffect(() => {
74
74
  const _query = typeof query === 'function' ? query() : unref(query);
75
75
  const strQuery = typeof _query !== 'string' && typeof _query !== 'number' ? '' : String(_query);
@@ -1 +1 @@
1
- {"version":3,"file":"filter.mjs","names":["computed","ref","unref","watchEffect","getPropertyFromItem","propsFactory","wrapInArray","defaultFilter","value","query","item","toString","toLocaleLowerCase","indexOf","makeFilterProps","customFilter","Function","customKeyFilter","Object","filterKeys","Array","String","filterMode","type","default","noFilter","Boolean","filterItems","items","options","array","filter","keys","customFiltersLength","length","loop","i","customMatches","defaultMatches","match","key","keyFilter","title","defaultMatchesLength","customMatchesLength","push","index","matches","useFilter","props","filteredItems","filteredMatches","Map","transformedItems","transform","map","_query","strQuery","results","originalItems","_filteredItems","_filteredMatches","forEach","_ref","set","getMatches","get"],"sources":["../../src/composables/filter.ts"],"sourcesContent":["/* eslint-disable max-statements */\n/* eslint-disable no-labels */\n\n// Utilities\nimport { computed, ref, 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 * - match without highlight\n * - single match (index), length already known\n * - single match (start, end)\n * - multiple matches (start, end), probably shouldn't overlap\n */\nexport type FilterMatch = boolean | number | [number, number] | [number, number][]\nexport type FilterFunction = (value: string, query: string, item?: any) => 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\n// Composables\nexport const defaultFilter: FilterFunction = (value, query, item) => {\n if (value == null || query == null) return -1\n\n return value.toString().toLocaleLowerCase().indexOf(query.toString().toLocaleLowerCase())\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: any[],\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, FilterMatch> }[] = []\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 = items[i]\n const customMatches: Record<string, FilterMatch> = {}\n const defaultMatches: Record<string, FilterMatch> = {}\n let match: FilterMatch = -1\n\n if (query && !options?.noFilter) {\n if (typeof item === 'object') {\n const filterKeys = keys || Object.keys(item)\n\n for (const key of filterKeys) {\n const value = getPropertyFromItem(item as any, key, item)\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] = match\n else defaultMatches[key] = match\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 = match\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 { value: unknown }> (\n props: FilterProps,\n items: MaybeRef<T[]>,\n query: Ref<string | undefined> | (() => string | undefined),\n options?: {\n transform?: (item: T) => any\n }\n) {\n const filteredItems: Ref<T[]> = ref([])\n const filteredMatches: Ref<Map<unknown, Record<string, FilterMatch>>> = ref(new Map())\n const transformedItems = computed(() => options?.transform ? unref(items).map(options?.transform) : unref(items))\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: props.customKeyFilter,\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"],"mappings":"AAAA;AACA;;AAEA;AACA,SAASA,QAAQ,EAAEC,GAAG,EAAEC,KAAK,EAAEC,WAAW,QAAQ,KAAK;AAAA,SAC9CC,mBAAmB,EAAEC,YAAY,EAAEC,WAAW,6BAEvD;AAwBA;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;EAE7C,OAAOD,KAAK,CAACG,QAAQ,EAAE,CAACC,iBAAiB,EAAE,CAACC,OAAO,CAACJ,KAAK,CAACE,QAAQ,EAAE,CAACC,iBAAiB,EAAE,CAAC;AAC3F,CAAC;AAED,OAAO,MAAME,eAAe,GAAGT,YAAY,CAAC;EAC1CU,YAAY,EAAEC,QAAoC;EAClDC,eAAe,EAAEC,MAAsC;EACvDC,UAAU,EAAE,CAACC,KAAK,EAA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gB,IAAA;MACjC,MAAMrD,IAAI,GAAGiD,aAAa,CAACb,KAAK,CAAC;MACjCc,cAAc,CAACf,IAAI,CAACnC,IAAI,CAAC;MACzBmD,gBAAgB,CAACG,GAAG,CAACtD,IAAI,CAACF,KAAK,EAAEuC,OAAO,CAAC;IAC3C,CAAC,CAAC;IACFG,aAAa,CAAC1C,KAAK,GAAGoD,cAAc;IACpCT,eAAe,CAAC3C,KAAK,GAAGqD,gBAAgB;EAC1C,CAAC,CAAC;EAEF,SAASI,UAAUA,CAAEvD,IAAO,EAAE;IAC5B,OAAOyC,eAAe,CAAC3C,KAAK,CAAC0D,GAAG,CAACxD,IAAI,CAACF,KAAK,CAAC;EAC9C;EAEA,OAAO;IAAE0C,aAAa;IAAEC,eAAe;IAAEc;EAAW,CAAC;AACvD"}
1
+ {"version":3,"file":"filter.mjs","names":["computed","ref","unref","watchEffect","getPropertyFromItem","propsFactory","wrapInArray","defaultFilter","value","query","item","toString","toLocaleLowerCase","indexOf","makeFilterProps","customFilter","Function","customKeyFilter","Object","filterKeys","Array","String","filterMode","type","default","noFilter","Boolean","filterItems","items","options","array","filter","keys","customFiltersLength","length","loop","i","transformed","customMatches","defaultMatches","match","key","keyFilter","title","defaultMatchesLength","customMatchesLength","push","index","matches","useFilter","props","filteredItems","filteredMatches","Map","transformedItems","transform","map","_query","strQuery","results","originalItems","_filteredItems","_filteredMatches","forEach","_ref","set","getMatches","get"],"sources":["../../src/composables/filter.ts"],"sourcesContent":["/* eslint-disable max-statements */\n/* eslint-disable no-labels */\n\n// Utilities\nimport { computed, ref, 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 * - match without highlight\n * - single match (index), length already known\n * - single match (start, end)\n * - multiple matches (start, end), probably shouldn't overlap\n */\nexport type FilterMatch = boolean | number | [number, number] | [number, number][]\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\n return value.toString().toLocaleLowerCase().indexOf(query.toString().toLocaleLowerCase())\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, FilterMatch> }[] = []\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, FilterMatch> = {}\n const defaultMatches: Record<string, FilterMatch> = {}\n let match: FilterMatch = -1\n\n if (query && !options?.noFilter) {\n if (typeof item === 'object') {\n const filterKeys = keys || Object.keys(transformed)\n\n for (const key of filterKeys) {\n const value = getPropertyFromItem(transformed, key, transformed)\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] = match\n else defaultMatches[key] = match\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 = match\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 }\n) {\n const filteredItems: Ref<T[]> = ref([])\n const filteredMatches: Ref<Map<unknown, Record<string, FilterMatch>>> = ref(new Map())\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: props.customKeyFilter,\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"],"mappings":"AAAA;AACA;;AAEA;AACA,SAASA,QAAQ,EAAEC,GAAG,EAAEC,KAAK,EAAEC,WAAW,QAAQ,KAAK;AAAA,SAC9CC,mBAAmB,EAAEC,YAAY,EAAEC,WAAW,6BAEvD;AA6BA;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;EAE7C,OAAOD,KAAK,CAACG,QAAQ,EAAE,CAACC,iBAAiB,EAAE,CAACC,OAAO,CAACJ,KAAK,CAACE,QAAQ,EAAE,CAACC,iBAAiB,EAAE,CAAC;AAC3F,CAAC;AAED,OAAO,MAAME,eAAe,GAAGT,YAAY,CAAC;EAC1CU,YAAY,EAAEC,QAAoC;EAClDC,eAAe,EAAEC,MAAsC;EACvDC,UAAU,EAAE,CAACC,KAAK,EAAEC,MAAM,CAAyB;EACnDC,UAAU,EAAE;IACVC,IAAI,EAAEF,MAA8B;IACpCG,OAAO,EAAE;EACX,CAAC;EACDC,QAAQ,EAAEC;AACZ,CAAC,EAAE,QAAQ,CAAC;AAEZ,OAAO,SAASC,WAAWA,CACzBC,KAA4F,EAC5FnB,KAAa,EACboB,OAMC,EACD;EACA,MAAMC,KAAgE,GAAG,EAAE;EAC3E;EACA,MAAMC,MAAM,GAAGF,OAAO,EAAEL,OAAO,IAAIjB,aAAa;EAChD,MAAMyB,IAAI,GAAGH,OAAO,EAAEV,UAAU,GAAGb,WAAW,CAACuB,OAAO,CAACV,UAAU,CAAC,GAAG,KAAK;EAC1E,MAAMc,mBAAmB,GAAGf,MAAM,CAACc,IAAI,CAACH,OAAO,EAAEZ,eAAe,IAAI,CAAC,CAAC,CAAC,CAACiB,MAAM;EAE9E,IAAI,CAACN,KAAK,EAAEM,MA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