@dative-gpi/foundation-shared-components 0.0.129 → 0.0.130
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/components/FSButton.vue +10 -5
- package/components/FSToggleSet.vue +30 -9
- package/components/fields/FSAutocompleteField.vue +55 -102
- package/components/fields/FSSelectField.vue +24 -62
- package/composables/useRules.ts +0 -11
- package/package.json +4 -4
- package/components/fields/FSToggleField.vue +0 -148
package/components/FSButton.vue
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
>
|
|
26
26
|
<FSIcon
|
|
27
27
|
v-if="$props.prependIcon || $props.icon"
|
|
28
|
-
size="
|
|
28
|
+
:size="$props.iconSize"
|
|
29
29
|
>
|
|
30
30
|
{{ $props.prependIcon ?? $props.icon }}
|
|
31
31
|
</FSIcon>
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
>
|
|
46
46
|
<FSIcon
|
|
47
47
|
v-if="$props.appendIcon"
|
|
48
|
-
size="
|
|
48
|
+
:size="$props.iconSize"
|
|
49
49
|
>
|
|
50
50
|
{{ $props.appendIcon }}
|
|
51
51
|
</FSIcon>
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
>
|
|
80
80
|
<FSIcon
|
|
81
81
|
v-if="$props.icon"
|
|
82
|
-
size="
|
|
82
|
+
:size="$props.iconSize"
|
|
83
83
|
>
|
|
84
84
|
{{ $props.icon }}
|
|
85
85
|
</FSIcon>
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
>
|
|
99
99
|
<FSIcon
|
|
100
100
|
v-if="$props.icon"
|
|
101
|
-
size="
|
|
101
|
+
:size="$props.iconSize"
|
|
102
102
|
>
|
|
103
103
|
{{ $props.icon }}
|
|
104
104
|
</FSIcon>
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
>
|
|
115
115
|
<FSIcon
|
|
116
116
|
v-if="$props.icon"
|
|
117
|
-
size="
|
|
117
|
+
:size="$props.iconSize"
|
|
118
118
|
>
|
|
119
119
|
{{ $props.icon }}
|
|
120
120
|
</FSIcon>
|
|
@@ -178,6 +178,11 @@ export default defineComponent({
|
|
|
178
178
|
required: false,
|
|
179
179
|
default: null
|
|
180
180
|
},
|
|
181
|
+
iconSize: {
|
|
182
|
+
type: [Array, String, Number] as PropType<"s" | "m" | "l" | string[] | number[] | string | number | null>,
|
|
183
|
+
required: false,
|
|
184
|
+
default: "l"
|
|
185
|
+
},
|
|
181
186
|
variant: {
|
|
182
187
|
type: String as PropType<"standard" | "full" | "icon">,
|
|
183
188
|
required: false,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<v-input
|
|
3
3
|
class="fs-toggle-set"
|
|
4
|
+
:rules="$props.rules"
|
|
4
5
|
:modelValue="$props.modelValue"
|
|
5
6
|
>
|
|
6
7
|
<FSWrapGroup
|
|
@@ -109,6 +110,16 @@ export default defineComponent({
|
|
|
109
110
|
FSButton
|
|
110
111
|
},
|
|
111
112
|
props: {
|
|
113
|
+
padding: {
|
|
114
|
+
type: [Array, String, Number] as PropType<string[] | number[] | string | number | null>,
|
|
115
|
+
required: false,
|
|
116
|
+
default: "0"
|
|
117
|
+
},
|
|
118
|
+
gap: {
|
|
119
|
+
type: [Array, String, Number] as PropType<string[] | number[] | string | number | null>,
|
|
120
|
+
required: false,
|
|
121
|
+
default: "8px"
|
|
122
|
+
},
|
|
112
123
|
values: {
|
|
113
124
|
type: Array as PropType<FSToggle[]>,
|
|
114
125
|
required: false,
|
|
@@ -129,6 +140,11 @@ export default defineComponent({
|
|
|
129
140
|
required: false,
|
|
130
141
|
default: "standard"
|
|
131
142
|
},
|
|
143
|
+
errorVariant: {
|
|
144
|
+
type: String as PropType<"standard" | "full" | "icon">,
|
|
145
|
+
required: false,
|
|
146
|
+
default: "standard"
|
|
147
|
+
},
|
|
132
148
|
buttonClass: {
|
|
133
149
|
type: [Array, String] as PropType<string[] | string>,
|
|
134
150
|
required: false,
|
|
@@ -139,8 +155,8 @@ export default defineComponent({
|
|
|
139
155
|
required: false,
|
|
140
156
|
default: null
|
|
141
157
|
},
|
|
142
|
-
|
|
143
|
-
type: [Array, String
|
|
158
|
+
errorClass: {
|
|
159
|
+
type: [Array, String] as PropType<string[] | string>,
|
|
144
160
|
required: false,
|
|
145
161
|
default: null
|
|
146
162
|
},
|
|
@@ -154,15 +170,20 @@ export default defineComponent({
|
|
|
154
170
|
required: false,
|
|
155
171
|
default: ColorEnum.Primary
|
|
156
172
|
},
|
|
157
|
-
|
|
158
|
-
type:
|
|
173
|
+
errorColor: {
|
|
174
|
+
type: String as PropType<ColorBase>,
|
|
159
175
|
required: false,
|
|
160
|
-
default:
|
|
176
|
+
default: ColorEnum.Error
|
|
161
177
|
},
|
|
162
|
-
|
|
163
|
-
type:
|
|
178
|
+
rules: {
|
|
179
|
+
type: Array as PropType<any[]>,
|
|
164
180
|
required: false,
|
|
165
|
-
default:
|
|
181
|
+
default: () => []
|
|
182
|
+
},
|
|
183
|
+
modelValue: {
|
|
184
|
+
type: [Array, String, Number] as PropType<(string | number)[] | string | number | null>,
|
|
185
|
+
required: false,
|
|
186
|
+
default: null
|
|
166
187
|
},
|
|
167
188
|
multiple: {
|
|
168
189
|
type: Boolean,
|
|
@@ -181,7 +202,7 @@ export default defineComponent({
|
|
|
181
202
|
}
|
|
182
203
|
},
|
|
183
204
|
emits: ["update:modelValue"],
|
|
184
|
-
setup(props, { emit }) {
|
|
205
|
+
setup(props, { emit }) {
|
|
185
206
|
const toggleSetRef = ref(null);
|
|
186
207
|
|
|
187
208
|
const getVariant = (value: FSToggle): "standard" | "full" | "icon" => {
|
|
@@ -21,17 +21,16 @@
|
|
|
21
21
|
v-if="isExtraSmall"
|
|
22
22
|
>
|
|
23
23
|
<FSTextField
|
|
24
|
-
:
|
|
24
|
+
:validationValue="$props.modelValue"
|
|
25
25
|
:description="$props.description"
|
|
26
26
|
:hideHeader="$props.hideHeader"
|
|
27
|
-
:required="$props.required"
|
|
28
27
|
:clearable="$props.clearable"
|
|
29
28
|
:editable="$props.editable"
|
|
30
|
-
:
|
|
29
|
+
:required="$props.required"
|
|
30
|
+
:label="$props.label"
|
|
31
31
|
:rules="$props.rules"
|
|
32
32
|
:messages="messages"
|
|
33
|
-
:
|
|
34
|
-
:validationValue="$props.modelValue"
|
|
33
|
+
:readonly="true"
|
|
35
34
|
:modelValue="mobileValue"
|
|
36
35
|
@update:modelValue="$emit('update:modelValue', $event)"
|
|
37
36
|
@click="openMobileOverlay"
|
|
@@ -132,62 +131,57 @@
|
|
|
132
131
|
<template
|
|
133
132
|
v-else
|
|
134
133
|
>
|
|
135
|
-
<FSToggleField
|
|
136
|
-
v-if="$props.toggleSet"
|
|
137
|
-
:label="$props.label"
|
|
138
|
-
:description="$props.description"
|
|
139
|
-
:hideHeader="$props.hideHeader"
|
|
140
|
-
:items="$props.items"
|
|
141
|
-
:returnObject="$props.returnObject"
|
|
142
|
-
:required="$props.required"
|
|
143
|
-
:editable="$props.editable"
|
|
144
|
-
:multiple="$props.multiple"
|
|
145
|
-
:rules="$props.rules"
|
|
146
|
-
:validateOn="validateOn"
|
|
147
|
-
:modelValue="$props.modelValue"
|
|
148
|
-
@update:modelValue="onUpdate"
|
|
149
|
-
v-bind="$attrs"
|
|
150
|
-
>
|
|
151
|
-
<template
|
|
152
|
-
v-for="(_, name) in toggleSetSlots"
|
|
153
|
-
v-slot:[name]="slotData"
|
|
154
|
-
>
|
|
155
|
-
<slot
|
|
156
|
-
:name="`toggle-set-${name}`"
|
|
157
|
-
v-bind="slotData"
|
|
158
|
-
/>
|
|
159
|
-
</template>
|
|
160
|
-
</FSToggleField>
|
|
161
134
|
<FSBaseField
|
|
162
|
-
v-else
|
|
163
|
-
:label="$props.label"
|
|
164
135
|
:description="$props.description"
|
|
165
136
|
:hideHeader="$props.hideHeader"
|
|
166
137
|
:required="$props.required"
|
|
167
138
|
:editable="$props.editable"
|
|
139
|
+
:label="$props.label"
|
|
168
140
|
:messages="messages"
|
|
169
141
|
>
|
|
142
|
+
<FSToggleSet
|
|
143
|
+
v-if="$props.toggleSet"
|
|
144
|
+
:editable="$props.editable"
|
|
145
|
+
:multiple="$props.multiple"
|
|
146
|
+
:required="$props.required"
|
|
147
|
+
:values="$props.items"
|
|
148
|
+
:rules="$props.rules"
|
|
149
|
+
:modelValue="$props.modelValue"
|
|
150
|
+
@update:modelValue="$emit('update:modelValue', $event)"
|
|
151
|
+
v-bind="$attrs"
|
|
152
|
+
>
|
|
153
|
+
<template
|
|
154
|
+
v-for="(_, name) in toggleSetSlots"
|
|
155
|
+
v-slot:[name]="slotData"
|
|
156
|
+
>
|
|
157
|
+
<slot
|
|
158
|
+
:name="`toggle-set-${name}`"
|
|
159
|
+
v-bind="slotData"
|
|
160
|
+
/>
|
|
161
|
+
</template>
|
|
162
|
+
</FSToggleSet>
|
|
170
163
|
<v-autocomplete
|
|
164
|
+
v-else
|
|
171
165
|
class="fs-autocomplete-field"
|
|
172
166
|
variant="outlined"
|
|
173
|
-
:
|
|
174
|
-
:style="style"
|
|
175
|
-
:listProps="listStyle"
|
|
176
|
-
:class="classes"
|
|
177
|
-
:persistentClear="true"
|
|
178
|
-
:hideDetails="true"
|
|
179
|
-
:items="$props.items"
|
|
180
|
-
:autoSelectFirst="true"
|
|
181
|
-
:multiple="$props.multiple"
|
|
167
|
+
:clearable="$props.clearable && $props.editable && !!$props.modelValue"
|
|
182
168
|
:itemTitle="$props.itemTitle"
|
|
183
169
|
:itemValue="$props.itemValue"
|
|
184
170
|
:readonly="!$props.editable"
|
|
185
|
-
:
|
|
186
|
-
:returnObject="$props.returnObject"
|
|
187
|
-
:rules="$props.rules"
|
|
171
|
+
:multiple="$props.multiple"
|
|
188
172
|
:validateOn="validateOn"
|
|
173
|
+
:autoSelectFirst="true"
|
|
174
|
+
:persistentClear="true"
|
|
175
|
+
:listProps="listStyle"
|
|
176
|
+
:returnObject="false"
|
|
177
|
+
:items="$props.items"
|
|
178
|
+
:rules="$props.rules"
|
|
179
|
+
:hideDetails="true"
|
|
180
|
+
:menuIcon="null"
|
|
181
|
+
:class="classes"
|
|
182
|
+
:style="style"
|
|
189
183
|
:modelValue="$props.modelValue"
|
|
190
|
-
@update:modelValue="
|
|
184
|
+
@update:modelValue="$emit('update:modelValue', $event)"
|
|
191
185
|
@click="onClick"
|
|
192
186
|
v-model:search="search"
|
|
193
187
|
v-bind="$attrs"
|
|
@@ -298,9 +292,9 @@ import { useBreakpoints, useColors, useRules, useSlots } from "@dative-gpi/found
|
|
|
298
292
|
import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
|
|
299
293
|
|
|
300
294
|
import FSSearchField from "./FSSearchField.vue";
|
|
301
|
-
import FSToggleField from "./FSToggleField.vue";
|
|
302
295
|
import FSDialogMenu from "../FSDialogMenu.vue";
|
|
303
296
|
import FSRadioGroup from "../FSRadioGroup.vue";
|
|
297
|
+
import FSToggleSet from "../FSToggleSet.vue";
|
|
304
298
|
import FSBaseField from "./FSBaseField.vue";
|
|
305
299
|
import FSTextField from "./FSTextField.vue";
|
|
306
300
|
import FSCheckbox from "../FSCheckbox.vue";
|
|
@@ -315,11 +309,11 @@ export default defineComponent({
|
|
|
315
309
|
name: "FSAutocompleteField",
|
|
316
310
|
components: {
|
|
317
311
|
FSSearchField,
|
|
318
|
-
FSToggleField,
|
|
319
312
|
FSDialogMenu,
|
|
320
313
|
FSRadioGroup,
|
|
321
314
|
FSBaseField,
|
|
322
315
|
FSTextField,
|
|
316
|
+
FSToggleSet,
|
|
323
317
|
FSCheckbox,
|
|
324
318
|
FSFadeOut,
|
|
325
319
|
FSButton,
|
|
@@ -368,11 +362,6 @@ export default defineComponent({
|
|
|
368
362
|
required: false,
|
|
369
363
|
default: false
|
|
370
364
|
},
|
|
371
|
-
returnObject: {
|
|
372
|
-
type: Boolean,
|
|
373
|
-
required: false,
|
|
374
|
-
default: false
|
|
375
|
-
},
|
|
376
365
|
required: {
|
|
377
366
|
type: Boolean,
|
|
378
367
|
required: false,
|
|
@@ -551,70 +540,35 @@ export default defineComponent({
|
|
|
551
540
|
};
|
|
552
541
|
|
|
553
542
|
const onRadioChange = (value: string | null) => {
|
|
554
|
-
|
|
555
|
-
emit("update:modelValue", props.items.find((item: any) => item[props.itemValue] === value) ?? null);
|
|
556
|
-
}
|
|
557
|
-
else {
|
|
558
|
-
emit("update:modelValue", value);
|
|
559
|
-
}
|
|
543
|
+
emit("update:modelValue", value);
|
|
560
544
|
dialog.value = false;
|
|
561
545
|
};
|
|
562
546
|
|
|
563
547
|
const onCheckboxChange = (value: string) => {
|
|
564
|
-
if (props.
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
if (props.modelValue.find(item => item[props.itemValue] === value)) {
|
|
568
|
-
emit("update:modelValue", props.modelValue.filter((item: any) => item[props.itemValue] !== value));
|
|
569
|
-
}
|
|
570
|
-
else {
|
|
571
|
-
if (item) {
|
|
572
|
-
emit("update:modelValue", [...props.modelValue, item]);
|
|
573
|
-
}
|
|
574
|
-
}
|
|
548
|
+
if (Array.isArray(props.modelValue)) {
|
|
549
|
+
if (props.modelValue.includes(value)) {
|
|
550
|
+
emit("update:modelValue", props.modelValue.filter((item: any) => item !== value));
|
|
575
551
|
}
|
|
576
552
|
else {
|
|
577
|
-
|
|
578
|
-
if (props.modelValue[props.itemValue] === value) {
|
|
579
|
-
emit("update:modelValue", []);
|
|
580
|
-
}
|
|
581
|
-
else {
|
|
582
|
-
emit("update:modelValue", [props.modelValue, item]);
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
else {
|
|
586
|
-
emit("update:modelValue", [item]);
|
|
587
|
-
}
|
|
553
|
+
emit("update:modelValue", [...props.modelValue, value]);
|
|
588
554
|
}
|
|
589
555
|
}
|
|
590
556
|
else {
|
|
591
|
-
if (
|
|
592
|
-
|
|
593
|
-
emit("update:modelValue", props.modelValue.filter((item: any) => item !== value));
|
|
594
|
-
}
|
|
595
|
-
else {
|
|
596
|
-
emit("update:modelValue", [...props.modelValue, value]);
|
|
597
|
-
}
|
|
557
|
+
if (props.modelValue === value) {
|
|
558
|
+
emit("update:modelValue", []);
|
|
598
559
|
}
|
|
599
560
|
else {
|
|
600
|
-
|
|
601
|
-
emit("update:modelValue", []);
|
|
602
|
-
}
|
|
603
|
-
else {
|
|
604
|
-
emit("update:modelValue", [props.modelValue, value]);
|
|
605
|
-
}
|
|
561
|
+
emit("update:modelValue", [props.modelValue, value]);
|
|
606
562
|
}
|
|
607
563
|
}
|
|
608
564
|
};
|
|
609
565
|
|
|
610
|
-
const onUpdate = (value: string[] | string) => {
|
|
611
|
-
emit("update:modelValue", value);
|
|
612
|
-
};
|
|
613
|
-
|
|
614
566
|
const onClick = () => {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
567
|
+
if (props.modelValue) {
|
|
568
|
+
search.value = "";
|
|
569
|
+
emit("update:search", search.value);
|
|
570
|
+
emit("update:modelValue", null);
|
|
571
|
+
}
|
|
618
572
|
}
|
|
619
573
|
|
|
620
574
|
watch(search, () => {
|
|
@@ -642,7 +596,6 @@ export default defineComponent({
|
|
|
642
596
|
onCheckboxChange,
|
|
643
597
|
mobileItemProps,
|
|
644
598
|
onRadioChange,
|
|
645
|
-
onUpdate,
|
|
646
599
|
onClick
|
|
647
600
|
};
|
|
648
601
|
}
|
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
v-if="isExtraSmall"
|
|
5
5
|
>
|
|
6
6
|
<FSTextField
|
|
7
|
-
:
|
|
7
|
+
:validationValue="$props.modelValue"
|
|
8
8
|
:description="$props.description"
|
|
9
9
|
:hideHeader="$props.hideHeader"
|
|
10
|
-
:required="$props.required"
|
|
11
10
|
:clearable="$props.clearable"
|
|
12
11
|
:editable="$props.editable"
|
|
13
|
-
:
|
|
12
|
+
:required="$props.required"
|
|
13
|
+
:validateOn="validateOn"
|
|
14
|
+
:label="$props.label"
|
|
14
15
|
:rules="$props.rules"
|
|
15
16
|
:messages="messages"
|
|
16
|
-
:
|
|
17
|
-
:validationValue="$props.modelValue"
|
|
17
|
+
:readonly="true"
|
|
18
18
|
:modelValue="mobileValue"
|
|
19
19
|
@update:modelValue="$emit('update:modelValue', $event)"
|
|
20
20
|
@click="openMobileOverlay"
|
|
@@ -113,30 +113,30 @@
|
|
|
113
113
|
v-else
|
|
114
114
|
>
|
|
115
115
|
<FSBaseField
|
|
116
|
-
:label="$props.label"
|
|
117
116
|
:description="$props.description"
|
|
118
117
|
:hideHeader="$props.hideHeader"
|
|
119
118
|
:required="$props.required"
|
|
120
119
|
:editable="$props.editable"
|
|
120
|
+
:label="$props.label"
|
|
121
121
|
:messages="messages"
|
|
122
122
|
>
|
|
123
123
|
<v-select
|
|
124
124
|
class="fs-select-field"
|
|
125
125
|
variant="outlined"
|
|
126
|
-
:
|
|
127
|
-
:style="style"
|
|
128
|
-
:listProps="listStyle"
|
|
129
|
-
:persistentClear="true"
|
|
130
|
-
:hideDetails="true"
|
|
131
|
-
:items="$props.items"
|
|
126
|
+
:clearable="$props.clearable && $props.editable && !!$props.modelValue"
|
|
132
127
|
:itemTitle="$props.itemTitle"
|
|
133
128
|
:itemValue="$props.itemValue"
|
|
134
129
|
:readonly="!$props.editable"
|
|
135
|
-
:clearable="$props.clearable && $props.editable && !!$props.modelValue"
|
|
136
|
-
:returnObject="$props.returnObject"
|
|
137
|
-
:rules="$props.rules"
|
|
138
|
-
:validateOn="validateOn"
|
|
139
130
|
:multiple="$props.multiple"
|
|
131
|
+
:validateOn="validateOn"
|
|
132
|
+
:persistentClear="true"
|
|
133
|
+
:listProps="listStyle"
|
|
134
|
+
:returnObject="false"
|
|
135
|
+
:items="$props.items"
|
|
136
|
+
:rules="$props.rules"
|
|
137
|
+
:hideDetails="true"
|
|
138
|
+
:menuIcon="null"
|
|
139
|
+
:style="style"
|
|
140
140
|
:modelValue="$props.modelValue"
|
|
141
141
|
@update:modelValue="$emit('update:modelValue', $event)"
|
|
142
142
|
v-bind="$attrs"
|
|
@@ -306,11 +306,6 @@ export default defineComponent({
|
|
|
306
306
|
required: false,
|
|
307
307
|
default: false
|
|
308
308
|
},
|
|
309
|
-
returnObject: {
|
|
310
|
-
type: Boolean,
|
|
311
|
-
required: false,
|
|
312
|
-
default: false
|
|
313
|
-
},
|
|
314
309
|
required: {
|
|
315
310
|
type: Boolean,
|
|
316
311
|
required: false,
|
|
@@ -449,58 +444,25 @@ export default defineComponent({
|
|
|
449
444
|
};
|
|
450
445
|
|
|
451
446
|
const onRadioChange = (value: string | null) => {
|
|
452
|
-
|
|
453
|
-
emit("update:modelValue", props.items.find((item: any) => item[props.itemValue] === value) ?? null);
|
|
454
|
-
}
|
|
455
|
-
else {
|
|
456
|
-
emit("update:modelValue", value);
|
|
457
|
-
}
|
|
447
|
+
emit("update:modelValue", value);
|
|
458
448
|
dialog.value = false;
|
|
459
449
|
};
|
|
460
450
|
|
|
461
451
|
const onCheckboxChange = (value: string) => {
|
|
462
|
-
if (props.
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
if (props.modelValue.find(item => item[props.itemValue] === value)) {
|
|
466
|
-
emit("update:modelValue", props.modelValue.filter((item: any) => item[props.itemValue] !== value));
|
|
467
|
-
}
|
|
468
|
-
else {
|
|
469
|
-
if (item) {
|
|
470
|
-
emit("update:modelValue", [...props.modelValue, item]);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
452
|
+
if (Array.isArray(props.modelValue)) {
|
|
453
|
+
if (props.modelValue.includes(value)) {
|
|
454
|
+
emit("update:modelValue", props.modelValue.filter((item: any) => item !== value));
|
|
473
455
|
}
|
|
474
456
|
else {
|
|
475
|
-
|
|
476
|
-
if (props.modelValue[props.itemValue] === value) {
|
|
477
|
-
emit("update:modelValue", []);
|
|
478
|
-
}
|
|
479
|
-
else {
|
|
480
|
-
emit("update:modelValue", [props.modelValue, item]);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
else {
|
|
484
|
-
emit("update:modelValue", [item]);
|
|
485
|
-
}
|
|
457
|
+
emit("update:modelValue", [...props.modelValue, value]);
|
|
486
458
|
}
|
|
487
459
|
}
|
|
488
460
|
else {
|
|
489
|
-
if (
|
|
490
|
-
|
|
491
|
-
emit("update:modelValue", props.modelValue.filter((item: any) => item !== value));
|
|
492
|
-
}
|
|
493
|
-
else {
|
|
494
|
-
emit("update:modelValue", [...props.modelValue, value]);
|
|
495
|
-
}
|
|
461
|
+
if (props.modelValue === value) {
|
|
462
|
+
emit("update:modelValue", []);
|
|
496
463
|
}
|
|
497
464
|
else {
|
|
498
|
-
|
|
499
|
-
emit("update:modelValue", []);
|
|
500
|
-
}
|
|
501
|
-
else {
|
|
502
|
-
emit("update:modelValue", [props.modelValue, value]);
|
|
503
|
-
}
|
|
465
|
+
emit("update:modelValue", [props.modelValue, value]);
|
|
504
466
|
}
|
|
505
467
|
}
|
|
506
468
|
};
|
package/composables/useRules.ts
CHANGED
|
@@ -11,16 +11,6 @@ export const useRules = () => {
|
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
const forceErrors = (messagesLength: number, updated: boolean): boolean => {
|
|
15
|
-
if (messagesLength <= 0) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
switch (innerValidateOn.value) {
|
|
19
|
-
case "submit": return submitted.value;
|
|
20
|
-
case "input": return submitted.value || updated;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
14
|
const getMessages = (modelValue: any, rules: any[], checkArray: boolean = false): string[] => {
|
|
25
15
|
if (!rules || !rules.length) {
|
|
26
16
|
return [];
|
|
@@ -71,7 +61,6 @@ export const useRules = () => {
|
|
|
71
61
|
|
|
72
62
|
return {
|
|
73
63
|
validateOn,
|
|
74
|
-
forceErrors,
|
|
75
64
|
getMessages
|
|
76
65
|
};
|
|
77
66
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-shared-components",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.130",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dative-gpi/foundation-shared-domain": "0.0.
|
|
14
|
-
"@dative-gpi/foundation-shared-services": "0.0.
|
|
13
|
+
"@dative-gpi/foundation-shared-domain": "0.0.130",
|
|
14
|
+
"@dative-gpi/foundation-shared-services": "0.0.130",
|
|
15
15
|
"@fontsource/montserrat": "^5.0.16",
|
|
16
16
|
"@lexical/clipboard": "^0.12.5",
|
|
17
17
|
"@lexical/history": "^0.12.5",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"sass": "^1.69.5",
|
|
33
33
|
"sass-loader": "^13.3.2"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "c595834a1af9272a46df01ffdc93b8dee851a2e8"
|
|
36
36
|
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<FSBaseField
|
|
3
|
-
:label="$props.label"
|
|
4
|
-
:description="$props.description"
|
|
5
|
-
:hideHeader="$props.hideHeader"
|
|
6
|
-
:required="$props.required"
|
|
7
|
-
:editable="$props.editable"
|
|
8
|
-
:messages="messages"
|
|
9
|
-
>
|
|
10
|
-
<FSToggleSet
|
|
11
|
-
variant="slide"
|
|
12
|
-
:buttonColor="buttonColor"
|
|
13
|
-
:values="$props.items"
|
|
14
|
-
:multiple="$props.multiple"
|
|
15
|
-
:required="$props.required"
|
|
16
|
-
:editable="$props.editable"
|
|
17
|
-
:modelValue="$props.modelValue"
|
|
18
|
-
@update:modelValue="onUpdate"
|
|
19
|
-
v-bind="$attrs"
|
|
20
|
-
>
|
|
21
|
-
<template
|
|
22
|
-
v-for="(_, name) in $slots"
|
|
23
|
-
v-slot:[name]="slotData"
|
|
24
|
-
>
|
|
25
|
-
<slot
|
|
26
|
-
:name="name"
|
|
27
|
-
v-bind="slotData"
|
|
28
|
-
/>
|
|
29
|
-
</template>
|
|
30
|
-
</FSToggleSet>
|
|
31
|
-
</FSBaseField>
|
|
32
|
-
</template>
|
|
33
|
-
|
|
34
|
-
<script lang="ts">
|
|
35
|
-
import { computed, defineComponent, PropType, ref } from "vue";
|
|
36
|
-
|
|
37
|
-
import { useRules } from "../../composables";
|
|
38
|
-
import { ColorEnum } from "../../models";
|
|
39
|
-
|
|
40
|
-
import FSToggleSet from "../FSToggleSet.vue";
|
|
41
|
-
import FSBaseField from "./FSBaseField.vue";
|
|
42
|
-
|
|
43
|
-
export default defineComponent({
|
|
44
|
-
name: "FSTextField",
|
|
45
|
-
components: {
|
|
46
|
-
FSBaseField,
|
|
47
|
-
FSToggleSet
|
|
48
|
-
},
|
|
49
|
-
props: {
|
|
50
|
-
label: {
|
|
51
|
-
type: String as PropType<string | null>,
|
|
52
|
-
required: false,
|
|
53
|
-
default: null
|
|
54
|
-
},
|
|
55
|
-
description: {
|
|
56
|
-
type: String as PropType<string | null>,
|
|
57
|
-
required: false,
|
|
58
|
-
default: null
|
|
59
|
-
},
|
|
60
|
-
items: {
|
|
61
|
-
type: Array as PropType<any[]>,
|
|
62
|
-
required: true
|
|
63
|
-
},
|
|
64
|
-
itemValue: {
|
|
65
|
-
type: String,
|
|
66
|
-
required: false,
|
|
67
|
-
default: "id"
|
|
68
|
-
},
|
|
69
|
-
itemTitle: {
|
|
70
|
-
type: String,
|
|
71
|
-
required: false,
|
|
72
|
-
default: "label"
|
|
73
|
-
},
|
|
74
|
-
modelValue: {
|
|
75
|
-
type: [Array, String] as PropType<string[] | string | null>,
|
|
76
|
-
required: false,
|
|
77
|
-
default: null
|
|
78
|
-
},
|
|
79
|
-
multiple: {
|
|
80
|
-
type: Boolean,
|
|
81
|
-
required: false,
|
|
82
|
-
default: false
|
|
83
|
-
},
|
|
84
|
-
hideHeader: {
|
|
85
|
-
type: Boolean,
|
|
86
|
-
required: false,
|
|
87
|
-
default: false
|
|
88
|
-
},
|
|
89
|
-
returnObject: {
|
|
90
|
-
type: Boolean,
|
|
91
|
-
required: false,
|
|
92
|
-
default: false
|
|
93
|
-
},
|
|
94
|
-
required: {
|
|
95
|
-
type: Boolean,
|
|
96
|
-
required: false,
|
|
97
|
-
default: false
|
|
98
|
-
},
|
|
99
|
-
rules: {
|
|
100
|
-
type: Array as PropType<any[]>,
|
|
101
|
-
required: false,
|
|
102
|
-
default: () => []
|
|
103
|
-
},
|
|
104
|
-
editable: {
|
|
105
|
-
type: Boolean,
|
|
106
|
-
required: false,
|
|
107
|
-
default: true
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
emits: ["update:modelValue"],
|
|
111
|
-
setup(props, { emit }) {
|
|
112
|
-
const { forceErrors, getMessages } = useRules();
|
|
113
|
-
|
|
114
|
-
const updated = ref(false);
|
|
115
|
-
|
|
116
|
-
const messages = computed((): string[] => getMessages(props.modelValue, props.rules));
|
|
117
|
-
|
|
118
|
-
const buttonColor = computed((): ColorEnum => {
|
|
119
|
-
if (forceErrors(messages.value.length, updated.value)) {
|
|
120
|
-
return ColorEnum.Error;
|
|
121
|
-
}
|
|
122
|
-
return ColorEnum.Light;
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
const onUpdate = (value: string[] | string | null) => {
|
|
126
|
-
updated.value = true;
|
|
127
|
-
if (props.returnObject) {
|
|
128
|
-
if (Array.isArray(value)) {
|
|
129
|
-
emit("update:modelValue", props.items.filter((item: any) => value.includes(item[props.itemValue])));
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
emit("update:modelValue", props.items.find((item: any) => item[props.itemValue] === value) ?? null);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
emit("update:modelValue", value);
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
return {
|
|
141
|
-
buttonColor,
|
|
142
|
-
ColorEnum,
|
|
143
|
-
messages,
|
|
144
|
-
onUpdate
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
</script>
|