@bagelink/vue 0.0.138 → 0.0.142

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.
@@ -11,20 +11,20 @@
11
11
  v-if="deleteCandidate === i"
12
12
  >
13
13
  <p class="txt14">
14
- {{ context?.formPlaceholders?.sure }}
14
+ {{ formPlaceholders?.sure }}
15
15
  </p>
16
16
  <Btn
17
17
  thin
18
18
  color="red"
19
19
  @click="deleteContact(contact.id)"
20
20
  >
21
- {{ context?.formPlaceholders?.delete }}
21
+ {{ formPlaceholders?.delete }}
22
22
  </Btn>
23
23
  <Btn
24
24
  thin
25
25
  @click="deleteCandidate = -1"
26
26
  >
27
- {{ context?.formPlaceholders?.cancel }}
27
+ {{ formPlaceholders?.cancel }}
28
28
  </Btn>
29
29
  </div>
30
30
  <Checkbox
@@ -35,18 +35,18 @@
35
35
  class="bglform-contact-label"
36
36
  v-model="contact.label"
37
37
  type="text"
38
- :placeholder="context?.formPlaceholders?.label"
38
+ :placeholder="formPlaceholders?.label"
39
39
  >
40
40
 
41
41
  <input
42
42
  v-model="contact.email"
43
- :placeholder="context?.formPlaceholders?.email"
43
+ :placeholder="formPlaceholders?.email"
44
44
  v-if="context?.id === 'email'"
45
45
  type="email"
46
46
  >
47
47
  <input
48
48
  v-model="contact.phone"
49
- :placeholder="context?.formPlaceholders?.phone"
49
+ :placeholder="formPlaceholders?.phone"
50
50
  v-if="context?.id === 'phone'"
51
51
  type="tel"
52
52
  >
@@ -68,7 +68,7 @@
68
68
  thin
69
69
  @click="val.push({})"
70
70
  >
71
- {{ context?.formPlaceholders?.add }} {{ context?.label }}
71
+ {{ formPlaceholders?.add }} {{ context?.label }}
72
72
  </Btn>
73
73
  </div>
74
74
  </div>
@@ -83,16 +83,20 @@ import Checkbox from '../form/inputs/Checkbox.vue';
83
83
 
84
84
  export interface ContactArrContext {
85
85
  label?: string;
86
- formPlaceholders?: {
87
- sure?: string
88
- delete?: string
89
- cancel?: string
90
- label?: string
91
- email?: string
92
- phone?: string
93
- add?: string
86
+ id?: string;
87
+ value: any[];
88
+ node: Record<string, any>;
89
+ attrs: {
90
+ formPlaceholders?: {
91
+ sure?: string
92
+ delete?: string
93
+ cancel?: string
94
+ label?: string
95
+ email?: string
96
+ phone?: string
97
+ add?: string
98
+ };
94
99
  };
95
- [key: string]: any;
96
100
  }
97
101
  const bagel = useBagel();
98
102
 
@@ -100,6 +104,8 @@ const props = defineProps<{
100
104
  context: ContactArrContext
101
105
  }>();
102
106
 
107
+ const formPlaceholders = $computed(() => props.context?.attrs?.formPlaceholders);
108
+
103
109
  let val = $ref<any[]>([]);
104
110
  let deleteCandidate = $ref<number>(-1);
105
111
 
@@ -106,8 +106,8 @@ const files = $ref<UploadFile[]>([]);
106
106
 
107
107
  const props = withDefaults(defineProps<{
108
108
  context: Record<string, any>;
109
- dragDropLabel: string;
110
- browseLabel: string;
109
+ dragDropLabel?: string;
110
+ browseLabel?: string;
111
111
  }>(), {
112
112
  dragDropLabel: 'Drag and drop your files here',
113
113
  browseLabel: 'or browse',
@@ -1,5 +1,5 @@
1
1
  import {
2
- h, InjectionKey, ref, inject, defineComponent,
2
+ h, InjectionKey, inject, defineComponent,
3
3
  } from 'vue';
4
4
  import type { Plugin } from 'vue';
5
5
  import type { BtnOptions } from '@bagelink/vue';
@@ -51,30 +51,32 @@ interface ModalComponentProps {
51
51
 
52
52
  export const ModalPlugin: Plugin = {
53
53
  install: (app) => {
54
- const modalStack = ref<ModalComponentProps[]>([]);
54
+ const modalStack = $ref<ModalComponentProps[]>([]);
55
+
56
+ const hideModal = (index: number) => {
57
+ // console.log('hideModal', index);
58
+ modalStack.splice(index, 1);
59
+ };
60
+
55
61
  const showModal = (
56
62
  isForm: boolean,
57
63
  options: ModalOptions | ModalFormOptions,
58
64
  slots: Record<string, any> = {},
59
65
  ) => {
60
- modalStack.value.push({
66
+ modalStack.push({
61
67
  modalOptions: options,
62
68
  isModalForm: isForm,
63
69
  componentSlots: slots,
64
70
  });
65
71
  };
66
72
 
67
- const hideModal = (index: number) => {
68
- // console.log('hideModal', index);
69
- modalStack.value.splice(index, 1);
70
- };
71
-
72
73
  app.provide(ModalSymbol, {
73
74
  modalForm: (options: ModalFormOptions, slots?: Record<string, any>) => showModal(true, options, slots),
74
75
  showModal: (options: ModalOptions, slots?: Record<string, any>) => showModal(false, options, slots),
75
- hideModal: (index = modalStack.value.length - 1) => hideModal(index),
76
+ hideModal: (index = modalStack.length - 1) => hideModal(index),
76
77
  // modalOptions,
77
78
  });
79
+
78
80
  const ModalComponent = defineComponent({
79
81
  data() {
80
82
  return {
@@ -82,7 +84,7 @@ export const ModalPlugin: Plugin = {
82
84
  };
83
85
  },
84
86
  render() {
85
- return modalStack.value.map((modal, index) => {
87
+ return modalStack.map((modal, index) => {
86
88
  const renderComponent = modal.isModalForm ? ModalForm : Modal;
87
89
  return h(
88
90
  renderComponent,
@@ -50,4 +50,10 @@ export const useFormkit = () => {
50
50
 
51
51
  export const initials = (...strArr: string[]) => strArr.map((str) => str?.charAt(0)).join('');
52
52
 
53
+ export function useEscape(event: KeyboardEvent, closeModel: () => void) {
54
+ if (event.key === 'Escape') {
55
+ closeModel();
56
+ }
57
+ }
58
+
53
59
  export { formatString } from './strings';