@signal24/vue-foundation 3.8.1 → 4.1.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.
Files changed (127) hide show
  1. package/.eslintrc.cjs +35 -0
  2. package/.prettierrc.json +4 -2
  3. package/dist/src/components/ajax-select.vue.d.ts +21 -0
  4. package/dist/src/components/alert-helpers.d.ts +8 -0
  5. package/dist/src/components/alert-modal.vue.d.ts +27 -0
  6. package/dist/src/components/ez-smart-select.vue.d.ts +27 -0
  7. package/dist/src/components/index.d.ts +8 -0
  8. package/dist/src/components/modal-container.d.ts +33 -0
  9. package/dist/src/components/modal.vue.d.ts +34 -0
  10. package/dist/src/components/smart-select.vue.d.ts +121 -0
  11. package/dist/src/config.d.ts +8 -0
  12. package/dist/src/directives/autofocus.d.ts +2 -0
  13. package/dist/src/directives/confirm-button.d.ts +2 -0
  14. package/dist/src/directives/date-input.d.ts +2 -0
  15. package/dist/src/directives/datetime.d.ts +2 -0
  16. package/dist/src/directives/disabled.d.ts +2 -0
  17. package/dist/src/directives/duration.d.ts +2 -0
  18. package/dist/src/directives/index.d.ts +24 -0
  19. package/dist/src/directives/infinite-scroll.d.ts +3 -0
  20. package/dist/src/directives/readonly.d.ts +2 -0
  21. package/dist/src/directives/tooltip.d.ts +41 -0
  22. package/dist/src/filters/index.d.ts +39 -0
  23. package/dist/src/helpers/array.d.ts +3 -0
  24. package/dist/src/helpers/context-menu.d.ts +13 -0
  25. package/dist/src/helpers/delay.d.ts +2 -0
  26. package/dist/src/helpers/error.d.ts +7 -0
  27. package/dist/src/helpers/index.d.ts +9 -0
  28. package/dist/src/helpers/mask.d.ts +15 -0
  29. package/dist/src/helpers/number.d.ts +1 -0
  30. package/dist/src/helpers/object.d.ts +2 -0
  31. package/dist/src/helpers/openapi.d.ts +34 -0
  32. package/dist/src/helpers/string.d.ts +5 -0
  33. package/dist/src/hooks/index.d.ts +2 -0
  34. package/dist/src/hooks/infinite-scroll.d.ts +30 -0
  35. package/dist/src/hooks/resize-watcher.d.ts +1 -0
  36. package/dist/src/index.d.ts +8 -0
  37. package/dist/src/types.d.ts +14 -0
  38. package/dist/src/vite-plugins/index.d.ts +1 -0
  39. package/dist/src/vite-plugins/index.js +2 -0
  40. package/dist/src/vite-plugins/vite-openapi-plugin.cli.d.ts +2 -0
  41. package/dist/src/vite-plugins/vite-openapi-plugin.cli.js +10 -0
  42. package/dist/src/vite-plugins/vite-openapi-plugin.d.ts +5 -0
  43. package/dist/src/vite-plugins/vite-openapi-plugin.js +58 -0
  44. package/dist/vue-foundation.css +1 -1
  45. package/dist/vue-foundation.es.js +880 -1880
  46. package/package.json +47 -16
  47. package/src/components/ajax-select.vue +44 -23
  48. package/src/components/alert-helpers.ts +45 -0
  49. package/src/components/alert-modal.vue +68 -0
  50. package/src/components/ez-smart-select.vue +51 -0
  51. package/src/components/index.ts +10 -0
  52. package/src/components/modal-container.ts +131 -0
  53. package/src/components/modal.vue +44 -129
  54. package/src/components/smart-select.vue +196 -243
  55. package/src/config.ts +15 -0
  56. package/src/directives/autofocus.ts +20 -0
  57. package/src/directives/confirm-button.ts +50 -0
  58. package/src/directives/date-input.ts +19 -0
  59. package/src/directives/datetime.ts +48 -0
  60. package/src/directives/disabled.ts +30 -0
  61. package/src/directives/duration.ts +79 -0
  62. package/src/directives/index.ts +37 -0
  63. package/src/directives/infinite-scroll.ts +9 -0
  64. package/src/directives/readonly.ts +15 -0
  65. package/src/directives/tooltip.ts +190 -0
  66. package/src/filters/index.ts +79 -0
  67. package/src/helpers/array.ts +7 -0
  68. package/src/helpers/context-menu.ts +108 -0
  69. package/src/helpers/delay.ts +2 -0
  70. package/src/helpers/error.ts +41 -0
  71. package/src/helpers/index.ts +9 -0
  72. package/src/helpers/mask.ts +105 -0
  73. package/src/helpers/number.ts +3 -0
  74. package/src/helpers/object.ts +19 -0
  75. package/src/helpers/openapi.ts +82 -0
  76. package/src/helpers/string.ts +27 -0
  77. package/src/hooks/index.ts +2 -0
  78. package/src/hooks/infinite-scroll.ts +107 -0
  79. package/src/hooks/resize-watcher.ts +8 -0
  80. package/src/index.ts +14 -0
  81. package/src/types.ts +14 -0
  82. package/src/vite-plugins/index.ts +2 -0
  83. package/src/vite-plugins/vite-openapi-plugin.cli.ts +15 -0
  84. package/src/vite-plugins/vite-openapi-plugin.ts +71 -0
  85. package/tsconfig.app.json +22 -0
  86. package/tsconfig.json +14 -0
  87. package/tsconfig.node.json +9 -0
  88. package/tsconfig.vite-plugins.json +10 -0
  89. package/tsconfig.vitest.json +9 -0
  90. package/vite.config.js +37 -35
  91. package/vitest.config.js +17 -0
  92. package/.eslintrc.js +0 -16
  93. package/CHANGES.md +0 -2
  94. package/dist/vue-foundation.cjs.js +0 -5
  95. package/dist/vue-foundation.umd.js +0 -6
  96. package/postcss.config.cjs +0 -5
  97. package/src/app.js +0 -25
  98. package/src/components/alert.vue +0 -130
  99. package/src/components/index.js +0 -12
  100. package/src/config.js +0 -11
  101. package/src/directives/autofocus.js +0 -17
  102. package/src/directives/confirm-button.js +0 -40
  103. package/src/directives/date-input.js +0 -18
  104. package/src/directives/datetime.js +0 -46
  105. package/src/directives/disabled.js +0 -28
  106. package/src/directives/duration.js +0 -72
  107. package/src/directives/index.js +0 -10
  108. package/src/directives/infinite-scroll.js +0 -17
  109. package/src/directives/readonly.js +0 -17
  110. package/src/directives/tooltip.js +0 -178
  111. package/src/directives/user-text.js +0 -11
  112. package/src/filters/index.js +0 -82
  113. package/src/helpers/array.js +0 -99
  114. package/src/helpers/context-menu.js +0 -66
  115. package/src/helpers/delay.js +0 -3
  116. package/src/helpers/error.js +0 -36
  117. package/src/helpers/http.js +0 -44
  118. package/src/helpers/index.js +0 -9
  119. package/src/helpers/mask.js +0 -90
  120. package/src/helpers/number.js +0 -6
  121. package/src/helpers/string.js +0 -36
  122. package/src/helpers/vue.js +0 -5
  123. package/src/index.js +0 -33
  124. package/src/plugins/index.js +0 -10
  125. package/src/plugins/infinite-scroll/hook.js +0 -30
  126. package/src/plugins/infinite-scroll.js +0 -100
  127. package/src/plugins/resize-watcher.js +0 -28
@@ -1,15 +1,10 @@
1
1
  <template>
2
2
  <Teleport to="#vf-modal-target">
3
- <div :id="id" class="vf-overlay vf-modal-wrap" :class="class">
4
- <form
5
- action="."
6
- class="vf-modal"
7
- :class="{ scrolls: $isPropTruthy(this.scrolls) }"
8
- @submit.prevent="$emit('formSubmit')"
9
- >
3
+ <div :id="id" class="vf-overlay vf-modal-wrap" :class="props.class" ref="overlay">
4
+ <form action="." class="vf-modal" :class="{ scrolls }" @submit.prevent="$emit('formSubmit')">
10
5
  <div v-if="$slots.header" class="vf-modal-header">
11
6
  <slot name="header" />
12
- <i v-if="$isPropTruthy(this.closeX)" class="close" @click="$parent.$dismiss()"></i>
7
+ <i v-if="props.closeX" class="close" @click="closeParent"></i>
13
8
  </div>
14
9
  <div class="vf-modal-content">
15
10
  <slot />
@@ -22,137 +17,57 @@
22
17
  </Teleport>
23
18
  </template>
24
19
 
25
- <script>
26
- export default {
27
- props: ['id', 'closeOnMaskClick', 'scrolls', 'closeX', 'class'],
28
- emits: ['formSubmit'],
29
-
30
- beforeCreate() {
31
- const targetEl = document.getElementById('vf-modal-target') ?? document.createElement('div');
32
- targetEl.id = 'vf-modal-target';
33
- targetEl.removeAttribute('inert');
34
- document.body.appendChild(targetEl);
35
- },
36
-
37
- mounted() {
38
- window.addEventListener('keydown', this.handleEscapeKey);
39
- document.body.classList.add('vf-modal-open');
40
-
41
- if (this.$isPropTruthy(this.closeOnMaskClick)) {
42
- this.$el.addEventListener('click', e => {
43
- if (e.target == this.$el) this.$parent.$dismiss();
44
- });
45
- }
46
- },
47
-
48
- unmounted() {
49
- window.removeEventListener('keydown', this.handleEscapeKey);
50
-
51
- let areOtherModalsOpen = document.body.querySelectorAll('.vf-modal').length > 0;
52
- areOtherModalsOpen || document.body.classList.remove('vf-modal-open');
53
- },
54
-
55
- methods: {
56
- handleEscapeKey(e) {
57
- if (e.key === 'Esc' || e.key === 'Escape') {
58
- const modalWraps = document.querySelectorAll('.vf-modal-wrap');
59
- if (modalWraps[modalWraps.length - 1] === this.$el) {
60
- this.$parent.$dismiss();
61
- }
62
- }
63
- }
64
- }
65
- };
66
-
67
- import app from '../app';
68
- import { markRaw } from 'vue';
69
- import cloneDeep from 'lodash/cloneDeep';
70
-
71
- let modalConfigs = {};
72
-
73
- function bootModal(modalId) {
74
- const config = modalConfigs[modalId];
75
-
76
- this.$modalOpener = config.opener;
77
- this.$modalResult = undefined;
78
-
79
- this.$options.storeParent = this.$modalOpener;
80
-
81
- let originalDataFn = this.$options.data;
82
- this.$options.data = function () {
83
- const injectedData = config.injectedData || {};
84
- const keepOriginalKeys = this.$options.keepOriginal || [];
85
- let data = originalDataFn ? originalDataFn.apply(this) : {};
86
-
87
- for (let key in injectedData) {
88
- if (!keepOriginalKeys.includes(key)) {
89
- if (
90
- injectedData[key] !== null &&
91
- typeof injectedData[key] == 'object' &&
92
- injectedData[key].constructor === Object
93
- ) {
94
- data[key] = cloneDeep(injectedData[key]);
95
- } else {
96
- data[key] = injectedData[key];
97
- }
98
- }
99
- }
20
+ <script lang="ts" setup>
21
+ import { defineProps, getCurrentInstance, onBeforeUnmount, onMounted, ref } from 'vue';
100
22
 
101
- return data;
102
- };
23
+ import { removeModalInjectionByInternalInstance } from './modal-container';
103
24
 
104
- this.$dismiss = (...args) => {
105
- return new Promise(resolve => {
106
- // setTimeout allows the form submission handler to run before the form is unmounted,
107
- // in the event the submit button has a click handler. otherwise, the console will
108
- // report "Form submission canceled because the form is not connected."
109
- setTimeout(() => {
110
- delete modalConfigs[modalId];
25
+ const props = defineProps<{
26
+ id?: string;
27
+ closeOnMaskClick?: boolean;
28
+ scrolls?: boolean;
29
+ closeX?: boolean;
30
+ class?: string;
31
+ }>();
111
32
 
112
- let rootInjections = app.vm.store.rootInjections;
33
+ defineEmits(['formSubmit']);
113
34
 
114
- const rootInjection = rootInjections.find(injection => injection.__modalId === modalId);
115
- if (!rootInjection) return;
35
+ const overlay = ref<HTMLElement>();
36
+
37
+ onMounted(() => {
38
+ window.addEventListener('keydown', handleEscapeKey);
39
+ document.body.classList.add('vf-modal-open');
40
+
41
+ if (props.closeOnMaskClick) {
42
+ overlay.value?.addEventListener('click', handleOverlayClick);
43
+ }
44
+ });
116
45
 
117
- rootInjections.remove(rootInjection);
118
- this.$nextTick(() => {
119
- config.resolve.apply(this, args[0] !== undefined ? args : this.$modalResult);
120
- resolve();
121
- });
122
- }, 0);
123
- });
124
- };
46
+ onBeforeUnmount(() => {
47
+ let areOtherModalsOpen = document.body.querySelectorAll('.vf-modal').length > 0;
48
+ areOtherModalsOpen || document.body.classList.remove('vf-modal-open');
49
+ });
125
50
 
126
- config.instanceCreationCallback && config.instanceCreationCallback(this);
51
+ function handleOverlayClick(e: MouseEvent) {
52
+ if (e.target == overlay.value) {
53
+ closeParent();
54
+ }
127
55
  }
128
56
 
129
- app.mixin({
130
- beforeCreate() {
131
- const modalId = this.$options.__modalId || this.$options.__file;
132
- if (modalId && modalConfigs[modalId]) bootModal.call(this, modalId);
57
+ function handleEscapeKey(e: KeyboardEvent) {
58
+ if (e.key === 'Esc' || e.key === 'Escape') {
59
+ const modalWraps = document.querySelectorAll('.vf-modal-wrap');
60
+ // make sure we're the topmost modal
61
+ if (modalWraps[modalWraps.length - 1] === overlay.value) {
62
+ closeParent();
63
+ }
133
64
  }
134
- });
65
+ }
135
66
 
136
- app.config.globalProperties.$modal = function (classDef, injectedData, instanceCreationCallback) {
137
- return new Promise((resolve, reject) => {
138
- const modalId = classDef.__modalId || classDef.__file || Math.random().toString(36).substring(2, 10);
139
- classDef.__modalId = modalId;
140
-
141
- modalConfigs[modalId] = {
142
- opener: this,
143
- injectedData,
144
- instanceCreationCallback,
145
- resolve
146
- };
147
-
148
- this.$nextTick(() => {
149
- app.vm.store.rootInjections.push(markRaw(classDef));
150
- });
151
- });
152
- };
153
-
154
- // TODO: see about a injecting a root modal container & HMR inside it
155
- // modals, on render, can hot move themselves to body end
67
+ function closeParent() {
68
+ const instance = getCurrentInstance();
69
+ removeModalInjectionByInternalInstance(instance!);
70
+ }
156
71
  </script>
157
72
 
158
73
  <style lang="scss">