@bagelink/vue 0.0.190 → 0.0.192

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 (30) hide show
  1. package/dist/components/Btn.vue.d.ts +11 -7
  2. package/dist/components/Btn.vue.d.ts.map +1 -1
  3. package/dist/components/ListView.vue.d.ts.map +1 -1
  4. package/dist/components/form/inputs/DatePicker.vue.d.ts +4 -4
  5. package/dist/components/form/inputs/DatePicker.vue.d.ts.map +1 -1
  6. package/dist/components/form/inputs/RadioPillsInput.vue.d.ts +31 -0
  7. package/dist/components/form/inputs/RadioPillsInput.vue.d.ts.map +1 -0
  8. package/dist/components/form/inputs/TextInput.vue.d.ts +5 -0
  9. package/dist/components/form/inputs/TextInput.vue.d.ts.map +1 -1
  10. package/dist/components/form/inputs/index.d.ts +1 -0
  11. package/dist/components/form/inputs/index.d.ts.map +1 -1
  12. package/dist/components/formkit/AddressArray.vue.d.ts.map +1 -1
  13. package/dist/components/formkit/BankDetailsArray.vue.d.ts.map +1 -1
  14. package/dist/components/formkit/ContactArrayFormKit.vue.d.ts.map +1 -1
  15. package/dist/index.cjs +13033 -3563
  16. package/dist/index.mjs +13034 -3564
  17. package/dist/style.css +479 -350
  18. package/package.json +1 -1
  19. package/src/components/Btn.vue +165 -146
  20. package/src/components/ListView.vue +0 -1
  21. package/src/components/PersonPreview.vue +1 -1
  22. package/src/components/form/inputs/DatePicker.vue +96 -80
  23. package/src/components/form/inputs/RadioPillsInput.vue +89 -0
  24. package/src/components/form/inputs/TextInput.vue +53 -11
  25. package/src/components/form/inputs/index.ts +1 -0
  26. package/src/components/formkit/AddressArray.vue +173 -150
  27. package/src/components/formkit/BankDetailsArray.vue +197 -174
  28. package/src/components/formkit/ContactArrayFormKit.vue +140 -123
  29. package/src/styles/layout.css +83 -0
  30. package/src/styles/theme.css +45 -16
@@ -0,0 +1,89 @@
1
+ <template>
2
+ <div class="flex gap-2 flex-wrap">
3
+ <div class="radio-pill" v-for="({id,label,value}, index) in cumputedOptions" :key="index">
4
+ <input
5
+ type="radio"
6
+ :id="id"
7
+ :name="name"
8
+ :value="value"
9
+ :checked="selectedValue === value"
10
+ @change="handleSelect"
11
+ >
12
+ <label :for="id">{{ label }}</label>
13
+ </div>
14
+ </div>
15
+ </template>
16
+
17
+ <script setup lang="ts">
18
+ import { onMounted, watch } from 'vue';
19
+
20
+ interface RadioOption {
21
+ id: string;
22
+ label: string;
23
+ value: any;
24
+ }
25
+ const emits = defineEmits(['update:modelValue']);
26
+
27
+ const props = defineProps<{
28
+ options?: RadioOption[],
29
+ stringOptions: string[],
30
+ modelValue: any,
31
+ name: string,
32
+ }>();
33
+
34
+ const cumputedOptions = $computed(() => props.options || props.stringOptions.map((v) => ({
35
+ id: v,
36
+ label: v,
37
+ value: v,
38
+ })));
39
+
40
+ let selectedValue = $ref('');
41
+
42
+ function handleSelect(e: Event) {
43
+ const newVal = (e.target as any)?.value;
44
+ emits('update:modelValue', newVal);
45
+ selectedValue = newVal;
46
+ }
47
+ watch(
48
+ () => props.modelValue,
49
+ (newVal, oldVal) => {
50
+ if (newVal === oldVal || oldVal === undefined) return;
51
+ if (selectedValue !== newVal) selectedValue = newVal;
52
+ },
53
+ { immediate: true },
54
+ );
55
+
56
+ onMounted(() => {
57
+ selectedValue = props.modelValue;
58
+ });
59
+ </script>
60
+
61
+ <style scoped>
62
+ .radio-pill label {
63
+ color: var(--bgl-primary);
64
+ white-space: nowrap;
65
+ border-radius: calc(var(--btn-border-radius) * 2);
66
+ outline: 1px solid var(--bgl-primary);
67
+ padding-left: calc(var(--btn-padding) / 2);
68
+ padding-right: calc(var(--btn-padding) / 2);
69
+ padding-top: calc(var(--btn-padding) / 6);
70
+ padding-bottom: calc(var(--btn-padding) / 6);
71
+ cursor: pointer;
72
+ transition: var(--bgl-transition);
73
+ background: var(--bgl-white);
74
+ user-select: none;
75
+ }
76
+
77
+ .radio-pill label:hover {
78
+ filter: var(--bgl-hover-filter);
79
+ }
80
+
81
+ .radio-pill input {
82
+ display: none;
83
+ }
84
+
85
+ .radio-pill input:checked~label {
86
+ background: var(--bgl-primary);
87
+ color: var(--bgl-white);
88
+ }
89
+ </style>
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div
3
3
  class="bagel-input"
4
- :class="{ small, shrink, toggleEdit, editMode }"
4
+ :class="{ small, shrink, toggleEdit, editMode, textInputIconWrap:icon, txtInputIconStart:iconStart}"
5
5
  :title="title"
6
6
  >
7
7
  <label :for="id">
@@ -20,9 +20,22 @@
20
20
  @keydown.enter="toggleEditAction"
21
21
  >
22
22
  </label>
23
+
24
+ <MaterialIcon
25
+ class="iconStart"
26
+ v-if="iconStart"
27
+ :icon="iconStart"
28
+ />
29
+ <MaterialIcon
30
+ v-if="icon"
31
+ :icon="icon"
32
+ />
23
33
  <Btn
24
34
  class="toggleEditBtn"
25
- v-if="toggleEdit" thin @click="toggleEditAction" :icon="editMode?'check':'edit'"
35
+ v-if="toggleEdit"
36
+ thin
37
+ @click="toggleEditAction"
38
+ :icon="editMode ? 'check' : 'edit'"
26
39
  flat
27
40
  />
28
41
  </div>
@@ -30,7 +43,9 @@
30
43
 
31
44
  <script setup lang="ts">
32
45
  import { watch } from 'vue';
33
- import { debounce, Btn } from '@bagelink/vue';
46
+ import {
47
+ debounce, Btn, type MaterialIcons, MaterialIcon,
48
+ } from '@bagelink/vue';
34
49
 
35
50
  const emit = defineEmits(['update:modelValue', 'debounce']);
36
51
  const props = withDefaults(
@@ -47,6 +62,8 @@ const props = withDefaults(
47
62
  toggleEdit?: boolean;
48
63
  type?: string;
49
64
  nativeInputAttrs?: Record<string, any>;
65
+ icon?: MaterialIcons;
66
+ iconStart?: MaterialIcons;
50
67
  }>(),
51
68
  {
52
69
  type: 'text',
@@ -54,7 +71,7 @@ const props = withDefaults(
54
71
  modelValue: '',
55
72
  },
56
73
  );
57
- let inputVal = $ref<string|number>();
74
+ let inputVal = $ref<string | number>();
58
75
  let editMode = $ref<boolean>(!props.toggleEdit);
59
76
 
60
77
  const input = $ref<HTMLInputElement>();
@@ -90,36 +107,61 @@ watch(
90
107
  </script>
91
108
 
92
109
  <style>
93
- .bagel-input.shrink, .bagel-input.shrink input{
110
+ .bagel-input.shrink,
111
+ .bagel-input.shrink input {
94
112
  min-width: unset !important;
95
113
  /* width: auto; */
96
114
  }
97
115
  </style>
98
116
 
99
117
  <style scoped>
100
- .bagel-input input[disabled]{
118
+ .bagel-input input[disabled] {
101
119
  background: none;
102
120
  }
103
121
 
104
122
  .bagel-input.toggleEdit:hover {
105
123
  background-color: var(--input-bg);
106
124
  }
107
- .bagel-input.small{
108
- margin-bottom:0;
125
+
126
+ .bagel-input.small {
127
+ margin-bottom: 0;
109
128
  height: 30px;
110
129
  }
111
130
 
112
- .toggleEditBtn{
131
+ .toggleEditBtn {
113
132
  position: absolute;
114
133
  right: -24px;
115
134
  top: 4;
116
135
  opacity: 0;
117
136
  }
118
- .bagel-input:hover .toggleEditBtn, .bagel-input.editMode .toggleEditBtn{
137
+
138
+ .textInputIconWrap {
139
+ position: relative;
140
+ }
141
+ .textInputIconWrap .icon-font {
142
+ position: absolute;
143
+ inset-inline-end: 0.7rem;
144
+ top:50%;
145
+ line-height: 0;
146
+ color: var(--bgl-gray);
147
+ }
148
+ .txtInputIconStart .iconStart{
149
+ position: absolute;
150
+ inset-inline-start: 0.7rem;
151
+ top:50%;
152
+ line-height: 0;
153
+ color: var(--bgl-gray);
154
+ }
155
+ .txtInputIconStart input{
156
+ padding-inline-start: 2rem;
157
+ }
158
+
159
+ .bagel-input:hover .toggleEditBtn,
160
+ .bagel-input.editMode .toggleEditBtn {
119
161
  opacity: 1;
120
162
  }
121
163
 
122
- .bagel-input.small input{
164
+ .bagel-input.small input {
123
165
  height: 30px;
124
166
  }
125
167
  </style>
@@ -21,3 +21,4 @@ export { default as ColorPicker } from './ColorPicker.vue';
21
21
  export { default as DynamicLinkField } from './DynamicLinkField.vue';
22
22
  export { default as PlainText } from './PlainText.vue';
23
23
  export { default as DatePicker } from './DatePicker.vue';
24
+ export { default as RadioPillsInput } from './RadioPillsInput.vue';
@@ -1,226 +1,249 @@
1
1
  <template>
2
- <div class="bagel-input">
3
- <div class="mt-1">
4
- <div class="bglform-contact mb-3" v-for="(address, i) in val" :key="i">
5
- <div class="bglform-contact-confirm" v-if="deleteCandidate === i">
6
- <p class="txt14">
7
- {{ formPlaceholders?.sure }}
8
- </p>
9
- <Btn thin color="red" @click="deleteContact(address.id)">
10
- {{ formPlaceholders?.delete }}
11
- </Btn>
12
- <Btn thin @click="deleteCandidate = -1">
13
- {{ formPlaceholders?.cancel }}
14
- </Btn>
15
- </div>
16
- <Checkbox
17
- v-model="address.primary"
18
- @update:model-value="($event) => primaryHandler(i, $event)"
19
- />
20
- <input
21
- class="bglform-contact-label"
22
- v-model="address.label"
23
- type="text"
24
- :placeholder="formPlaceholders?.label"
25
- />
26
- <div class="bglform-contact-address">
27
- <input
28
- v-model="address.street"
29
- :placeholder="formPlaceholders?.street"
30
- type="text"
31
- />
32
- <div class="bglform-contact-address-flex">
33
- <input
34
- v-model="address.city"
35
- :placeholder="formPlaceholders?.city"
36
- type="text"
37
- />
38
- <input
39
- v-model="address.postal_code"
40
- :placeholder="formPlaceholders?.zip"
41
- type="text"
42
- />
43
- </div>
44
- <input
45
- v-model="address.country"
46
- :placeholder="formPlaceholders?.country"
47
- type="text"
48
- />
49
- </div>
50
- <div class="bglform-address-del">
51
- <Btn thin @click="deleteCandidate = i" icon="delete" color="gray" />
52
- </div>
53
- </div>
54
- <Btn class="add-btn" color="blue" flat thin @click="addNew">
55
- {{ formPlaceholders?.add }}
56
- {{ context?.label }}
57
- </Btn>
58
- </div>
59
- </div>
2
+ <div class="bagel-input">
3
+ <div class="mt-1">
4
+ <div
5
+ class="bglform-contact mb-3"
6
+ v-for="(address, i) in val"
7
+ :key="i"
8
+ >
9
+ <div
10
+ class="bglform-contact-confirm"
11
+ v-if="deleteCandidate === i"
12
+ >
13
+ <p class="txt14">
14
+ {{ formPlaceholders?.sure }}
15
+ </p>
16
+ <Btn
17
+ thin
18
+ color="red"
19
+ @click="deleteContact(address.id)"
20
+ >
21
+ {{ formPlaceholders?.delete }}
22
+ </Btn>
23
+ <Btn
24
+ thin
25
+ @click="deleteCandidate = -1"
26
+ >
27
+ {{ formPlaceholders?.cancel }}
28
+ </Btn>
29
+ </div>
30
+ <Checkbox
31
+ v-model="address.primary"
32
+ @update:model-value="($event) => primaryHandler(i, $event)"
33
+ />
34
+ <input
35
+ class="bglform-contact-label"
36
+ v-model="address.label"
37
+ type="text"
38
+ :placeholder="formPlaceholders?.label"
39
+ >
40
+ <div class="bglform-contact-address">
41
+ <input
42
+ v-model="address.street"
43
+ :placeholder="formPlaceholders?.street"
44
+ type="text"
45
+ >
46
+ <div class="bglform-contact-address-flex">
47
+ <input
48
+ v-model="address.city"
49
+ :placeholder="formPlaceholders?.city"
50
+ type="text"
51
+ >
52
+ <input
53
+ v-model="address.postal_code"
54
+ :placeholder="formPlaceholders?.zip"
55
+ type="text"
56
+ >
57
+ </div>
58
+ <input
59
+ v-model="address.country"
60
+ :placeholder="formPlaceholders?.country"
61
+ type="text"
62
+ >
63
+ </div>
64
+ <div class="bglform-address-del">
65
+ <Btn
66
+ thin
67
+ @click="deleteCandidate = i"
68
+ icon="delete"
69
+ color="gray"
70
+ />
71
+ </div>
72
+ </div>
73
+ <Btn
74
+ class="add-btn"
75
+ flat
76
+ thin
77
+ @click="addNew"
78
+ >
79
+ {{ formPlaceholders?.add }}
80
+ {{ context?.label }}
81
+ </Btn>
82
+ </div>
83
+ </div>
60
84
  </template>
61
85
 
62
86
  <script setup lang="ts">
63
- import { watch } from "vue";
87
+ import { watch } from 'vue';
64
88
  // import type { BagelField } from '@bagelink/vue';
65
89
 
66
- import { Btn, useBagel } from "@bagelink/vue";
67
- import Checkbox from "../form/inputs/Checkbox.vue";
90
+ import { Btn, useBagel } from '@bagelink/vue';
91
+ import Checkbox from '../form/inputs/Checkbox.vue';
68
92
 
69
93
  export interface AddressArrContext {
70
- label?: string;
71
- id?: string;
72
- value: any[];
73
- node: Record<string, any>;
74
- attrs: {
75
- formPlaceholders?: {
76
- add?: string;
77
- cancel?: string;
78
- city?: string;
79
- country?: string;
80
- delete?: string;
81
- label?: string;
82
- sure?: string;
83
- zip?: string;
84
- street?: string;
85
- };
86
- };
94
+ label?: string;
95
+ id?: string;
96
+ value: any[];
97
+ node: Record<string, any>;
98
+ attrs: {
99
+ formPlaceholders?: {
100
+ add?: string;
101
+ cancel?: string;
102
+ city?: string;
103
+ country?: string;
104
+ delete?: string;
105
+ label?: string;
106
+ sure?: string;
107
+ zip?: string;
108
+ street?: string;
109
+ };
110
+ };
87
111
  }
88
112
  const bagel = useBagel();
89
113
  const props = defineProps<{
90
- context: AddressArrContext;
114
+ context: AddressArrContext;
91
115
  }>();
92
116
  const formPlaceholders = $computed(
93
- () => props.context?.attrs?.formPlaceholders
117
+ () => props.context?.attrs?.formPlaceholders,
94
118
  );
95
119
 
96
120
  let val = $ref<any[]>([]);
97
121
  const addNew = () => {
98
- if (!val) val = [{}];
99
- else val.push({});
122
+ if (!val) val = [{}];
123
+ else val.push({});
100
124
  };
101
125
 
102
126
  let deleteCandidate = $ref<number>(-1);
103
127
 
104
128
  const del = (i: number) => {
105
- val.splice(i, 1);
129
+ val.splice(i, 1);
106
130
  };
107
131
 
108
132
  const deleteContact = async (id: string) => {
109
- await bagel.delete(`/person/contact/${id}`);
110
- const index = val.findIndex((v) => v.id === id);
111
- deleteCandidate = -1;
112
- del(index);
133
+ await bagel.delete(`/person/contact/${id}`);
134
+ const index = val.findIndex((v) => v.id === id);
135
+ deleteCandidate = -1;
136
+ del(index);
113
137
  };
114
138
 
115
139
  const primaryHandler = (i: number, isPrimary: boolean) => {
116
- if (!isPrimary) return;
117
- val?.forEach((contact, index) => {
118
- if (index !== i) contact.primary = false;
119
- });
140
+ if (!isPrimary) return;
141
+ val?.forEach((contact, index) => {
142
+ if (index !== i) contact.primary = false;
143
+ });
120
144
  };
121
145
 
122
146
  watch(
123
- () => props.context?.value,
124
- () => {
125
- val = props.context?.value;
126
- },
127
- { immediate: true }
147
+ () => props.context?.value,
148
+ () => {
149
+ val = props.context?.value;
150
+ },
151
+ { immediate: true },
128
152
  );
129
153
 
130
154
  watch(
131
- () => val,
132
- () => {
133
- props.context?.node.input(val);
134
- }
155
+ () => val,
156
+ () => {
157
+ props.context?.node.input(val);
158
+ },
135
159
  );
136
160
  </script>
137
161
 
138
162
  <style>
139
163
  .bglform-contact-confirm {
140
- position: absolute;
141
- background: rgba(255, 255, 255, 0.5);
142
- height: 100%;
143
- width: 100%;
144
- display: flex;
145
- align-items: center;
146
- justify-content: center;
147
- gap: 0.5rem;
148
- backdrop-filter: blur(1px);
164
+ position: absolute;
165
+ background: rgba(255, 255, 255, 0.5);
166
+ height: 100%;
167
+ width: 100%;
168
+ display: flex;
169
+ align-items: center;
170
+ justify-content: center;
171
+ gap: 0.5rem;
172
+ backdrop-filter: blur(1px);
149
173
  }
150
174
  </style>
151
175
  <style scoped>
152
176
  .bglform-contact {
153
- display: flex;
154
- gap: 0.5rem;
155
- max-width: 700px;
156
- position: relative;
177
+ display: flex;
178
+ gap: 0.5rem;
179
+ max-width: 700px;
180
+ position: relative;
157
181
  }
158
182
 
159
183
  .bglform-contact-label {
160
- flex-basis: 140px;
184
+ flex-basis: 140px;
161
185
  }
162
186
 
163
187
  .bglform-contact-address {
164
- display: flex;
165
- flex-direction: column;
166
- gap: 0.5rem;
188
+ display: flex;
189
+ flex-direction: column;
190
+ gap: 0.5rem;
167
191
  }
168
192
 
169
193
  .bglform-contact input[type="checkbox"] {
170
- width: 30px;
171
- min-width: 0;
194
+ width: 30px;
195
+ min-width: 0;
172
196
  }
173
197
 
174
198
  .light.thin.btn-txt.btn {
175
- padding-left: calc(var(--btn-padding) / 4);
176
- padding-right: calc(var(--btn-padding) / 4);
199
+ padding-left: calc(var(--btn-padding) / 4);
200
+ padding-right: calc(var(--btn-padding) / 4);
177
201
  }
178
202
 
179
203
  .bglform-address-del {
180
- margin-top: 6px;
204
+ margin-top: 6px;
181
205
  }
182
206
 
183
207
  .bglform-contact-address-flex {
184
- display: flex;
185
- gap: 0.5rem;
208
+ display: flex;
209
+ gap: 0.5rem;
186
210
  }
187
211
 
188
212
  .add-btn {
189
- display: flex;
190
- gap: 0.5rem;
191
- align-items: center;
192
- margin-inline-start: 1rem;
213
+ display: flex;
214
+ gap: 0.5rem;
215
+ align-items: center;
216
+ margin-inline-start: 1rem;
193
217
  }
194
218
 
195
219
  .add-btn:active {
196
- background: none !important;
220
+ background: none !important;
197
221
  }
198
222
 
199
223
  .add-btn::before {
200
- content: "+";
201
- font-size: 10px;
202
- background: var(--bgl-blue-light);
203
- border-radius: 100%;
204
- height: 14px;
205
- width: 14px;
206
- display: flex;
207
- align-items: center;
208
- justify-content: center;
209
- color: var(--bgl-primary);
224
+ content: "+";
225
+ font-size: 10px;
226
+ background: var(--bgl-blue-light);
227
+ border-radius: 100%;
228
+ height: 14px;
229
+ width: 14px;
230
+ display: flex;
231
+ align-items: center;
232
+ justify-content: center;
233
+ color: var(--bgl-primary);
210
234
  }
211
235
 
212
236
  .add-btn:hover::before {
213
- background: var(--bgl-primary);
214
- color: var(--bgl-white);
237
+ background: var(--bgl-primary);
238
+ color: var(--bgl-white);
215
239
  }
216
240
 
217
241
  @media screen and (max-width: 910px) {
218
- .bglform-contact-address-flex {
219
- flex-wrap: wrap;
220
- }
221
-
222
- .bglform-contact-label {
223
- min-width: 0;
224
- }
225
- }
226
- </style>
242
+ .bglform-contact-address-flex {
243
+ flex-wrap: wrap;
244
+ }
245
+
246
+ .bglform-contact-label {
247
+ min-width: 0;
248
+ }
249
+ }</style>