@signal24/vue-foundation 4.7.0 → 4.7.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.7.0",
4
+ "version": "4.7.2",
5
5
  "description": "Common components, directives, and helpers for Vue 3 apps",
6
6
  "module": "./dist/vue-foundation.es.js",
7
7
  "bin": {
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div :id="id" class="vf-overlay vf-modal-wrap" :class="props.class" ref="overlay">
2
+ <div :id="id" class="vf-overlay vf-modal-wrap" :class="classList" ref="overlay">
3
3
  <form action="." class="vf-modal" :class="{ scrolls }" @submit.prevent="$emit('formSubmit')" ref="form">
4
4
  <div v-if="$slots.header" class="vf-modal-header">
5
5
  <slot name="header" />
@@ -16,7 +16,8 @@
16
16
  </template>
17
17
 
18
18
  <script lang="ts" setup>
19
- import { getCurrentInstance, onBeforeUnmount, onMounted, ref } from 'vue';
19
+ import { compact } from 'lodash';
20
+ import { computed, getCurrentInstance, onBeforeUnmount, onMounted, ref } from 'vue';
20
21
 
21
22
  import { maskForm, unmaskForm } from '../helpers/mask';
22
23
  import { dismissOverlayInjectionByInternalInstance } from './overlay-container';
@@ -32,11 +33,17 @@ const props = defineProps<{
32
33
  }>();
33
34
 
34
35
  defineEmits(['formSubmit']);
35
- defineExpose({ mask, unmask });
36
+ defineExpose({ mask, unmask, hide, unhide });
36
37
 
37
38
  const overlay = ref<HTMLElement>();
38
39
  const form = ref<HTMLFormElement>();
39
40
 
41
+ const isHidden = ref(false);
42
+
43
+ const classList = computed(() => {
44
+ return compact([props.class, isHidden.value && 'hidden']);
45
+ });
46
+
40
47
  onMounted(() => {
41
48
  document.body.classList.add('vf-modal-open');
42
49
 
@@ -80,6 +87,14 @@ function mask() {
80
87
  function unmask() {
81
88
  unmaskForm(form.value!);
82
89
  }
90
+
91
+ function hide() {
92
+ isHidden.value = true;
93
+ }
94
+
95
+ function unhide() {
96
+ isHidden.value = false;
97
+ }
83
98
  </script>
84
99
 
85
100
  <style lang="scss">
@@ -90,6 +105,10 @@ function unmask() {
90
105
  width: 100%;
91
106
  height: 100%;
92
107
  z-index: 100;
108
+
109
+ &.hidden {
110
+ display: none;
111
+ }
93
112
  }
94
113
 
95
114
  .vf-modal-wrap {
@@ -10,6 +10,7 @@
10
10
  v-disabled="effectiveDisabled"
11
11
  @focus="handleInputFocused"
12
12
  @blur="handleInputBlurred"
13
+ :required="required"
13
14
  />
14
15
  <div v-if="shouldDisplayOptions" ref="optionsContainer" class="vf-smart-select-options">
15
16
  <div v-if="!isLoaded" class="no-results">Loading...</div>
@@ -83,12 +84,12 @@ export default {
83
84
  noResultsText: String as PropType<string>,
84
85
  disabled: Boolean as PropType<boolean>,
85
86
  optionsListId: String as PropType<string>,
86
- debug: Boolean as PropType<boolean>
87
+ debug: Boolean as PropType<boolean>,
88
+ required: Boolean as PropType<boolean>
87
89
  },
88
90
 
89
91
  emits: {
90
92
  optionsLoaded: Object as (options: any[]) => void,
91
- createItem: Object as (searchText: string) => void,
92
93
  'update:modelValue': Object as (value: any) => void
93
94
  },
94
95
 
@@ -232,6 +233,7 @@ export default {
232
233
 
233
234
  options() {
234
235
  this.loadedOptions = this.options ?? [];
236
+ this.isLoaded = true;
235
237
  },
236
238
 
237
239
  // data
@@ -274,7 +276,7 @@ export default {
274
276
  },
275
277
 
276
278
  async mounted() {
277
- this.shouldShowCreateOption = this.$attrs['onCreateItem'] !== undefined;
279
+ this.shouldShowCreateOption = this.onCreateItem !== undefined;
278
280
 
279
281
  if (this.options) {
280
282
  this.loadedOptions = this.options;
@@ -305,13 +307,6 @@ export default {
305
307
  this.loadedOptions && this.$emit('optionsLoaded', this.loadedOptions);
306
308
  },
307
309
 
308
- handleSourceUpdate() {
309
- if (this.preload) return this.reloadOptions();
310
- if (!this.isLoaded) return;
311
- this.isLoaded = false;
312
- this.loadedOptions = [];
313
- },
314
-
315
310
  async reloadOptions() {
316
311
  const searchText = this.remoteSearch && this.isSearching && this.searchText ? this.searchText : null;
317
312
  this.isLoading = true;
@@ -509,7 +504,7 @@ export default {
509
504
  this.searchText = '';
510
505
  this.selectedOption = null;
511
506
  this.selectedOptionTitle = null;
512
- this.$emit('createItem', createText);
507
+ this.onCreateItem?.(createText);
513
508
  } else {
514
509
  const selectedDecoratedOption = this.optionsDescriptors.find(decoratedOption => decoratedOption.key == option.key);
515
510
  const realOption = selectedDecoratedOption!.ref;
@@ -534,7 +529,7 @@ export default {
534
529
  },
535
530
 
536
531
  addRemoteOption(option: GenericObject) {
537
- this.loadedOptions.push(option);
532
+ this.loadedOptions.unshift(option);
538
533
  }
539
534
  }
540
535
  };