@signal24/vue-foundation 4.20.1 → 4.20.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@signal24/vue-foundation",
3
3
  "type": "module",
4
- "version": "4.20.1",
4
+ "version": "4.20.2",
5
5
  "description": "Common components, directives, and helpers for Vue 3 apps",
6
6
  "module": "./dist/vue-foundation.es.js",
7
7
  "exports": {
@@ -8,5 +8,6 @@ export * from './alert-helpers';
8
8
  export * from './modal-helpers';
9
9
  export * from './overlay-container';
10
10
  export * from './toast-helpers';
11
+ export * from './vf-smart-select.types';
11
12
 
12
13
  export { VfAjaxSelect, VfAlertModal, VfEzSmartSelect, VfModal, VfSmartSelect };
@@ -0,0 +1,7 @@
1
+ export interface VfSmartSelectOptionDescriptor<T> {
2
+ key: string | symbol;
3
+ title: string;
4
+ subtitle?: string | null;
5
+ searchContent?: string;
6
+ ref?: T;
7
+ }
@@ -21,17 +21,19 @@
21
21
  v-for="option in effectiveOptions"
22
22
  :key="String(option.key)"
23
23
  class="option"
24
- :class="{
25
- highlighted: highlightedOptionKey === option.key
26
- }"
24
+ :class="[highlightedOptionKey === option.key && 'highlighted', option.ref && classForOption?.(option.ref)]"
27
25
  @mousemove="handleOptionHover(option)"
28
26
  @mousedown="selectOption(option)"
29
27
  >
30
- <div class="title" v-html="option.title" />
31
- <div v-if="option.subtitle" class="subtitle" v-html="option.subtitle" />
28
+ <slot name="option" :option="option">
29
+ <div class="title" v-html="option.title" />
30
+ <div v-if="option.subtitle" class="subtitle" v-html="option.subtitle" />
31
+ </slot>
32
32
  </div>
33
33
  <div v-if="!effectiveOptions.length && searchText" class="no-results">
34
- {{ effectiveNoResultsText }}
34
+ <slot name="no-results">
35
+ {{ effectiveNoResultsText }}
36
+ </slot>
35
37
  </div>
36
38
  </template>
37
39
  </div>
@@ -43,20 +45,13 @@ import { debounce, isEqual } from 'lodash';
43
45
  import { computed, onMounted, type Ref, ref, watch } from 'vue';
44
46
 
45
47
  import { escapeHtml } from '../helpers/string';
48
+ import type { VfSmartSelectOptionDescriptor } from './vf-smart-select.types';
46
49
 
47
50
  const NullSymbol = Symbol('null');
48
51
  const CreateSymbol = Symbol('create');
49
52
 
50
53
  const VALID_KEYS = `\`1234567890-=[]\\;',./~!@#$%^&*()_+{}|:"<>?qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM`;
51
54
 
52
- interface OptionDescriptor {
53
- key: string | symbol;
54
- title: string;
55
- subtitle?: string | null;
56
- searchContent?: string;
57
- ref?: T;
58
- }
59
-
60
55
  const props = defineProps<{
61
56
  modelValue: V | null;
62
57
  loadOptions?: (searchText: string | null) => Promise<T[]>;
@@ -75,6 +70,7 @@ const props = defineProps<{
75
70
  labelField?: keyof T;
76
71
  formatter?: (option: T) => string;
77
72
  subtitleFormatter?: (option: T) => string;
73
+ classForOption?: (option: T) => string;
78
74
  nullTitle?: string;
79
75
  noResultsText?: string;
80
76
  disabled?: boolean;
@@ -166,7 +162,7 @@ const optionsDescriptors = computed(() => {
166
162
  subtitle,
167
163
  searchContent: searchContent.join(''),
168
164
  ref: option
169
- } as OptionDescriptor;
165
+ } as VfSmartSelectOptionDescriptor<T>;
170
166
  });
171
167
  });
172
168
 
@@ -454,7 +450,7 @@ function highlightInitialOption() {
454
450
  containerEl.scrollTop = highlightedOptionEl.offsetTop;
455
451
  }
456
452
 
457
- function handleOptionHover(option: OptionDescriptor) {
453
+ function handleOptionHover(option: VfSmartSelectOptionDescriptor<T>) {
458
454
  highlightedOptionKey.value = option ? option.key : null;
459
455
  }
460
456
 
@@ -480,7 +476,7 @@ function incrementHighlightedOption(increment: number) {
480
476
  }
481
477
  }
482
478
 
483
- function selectOption(option: OptionDescriptor) {
479
+ function selectOption(option: VfSmartSelectOptionDescriptor<T>) {
484
480
  isSearching.value = false;
485
481
 
486
482
  if (option.key == NullSymbol) {