@dative-gpi/foundation-shared-components 0.0.220 → 0.0.222

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.
@@ -0,0 +1,273 @@
1
+ <template>
2
+ <template
3
+ v-if="!$props.validation"
4
+ >
5
+ <FSForm
6
+ ref="formRef"
7
+ :variant="$props.variant"
8
+ @submit="onSubmit"
9
+ v-model="valid"
10
+ >
11
+ <FSCol
12
+ gap="24px"
13
+ >
14
+ <FSFadeOut
15
+ :height="height"
16
+ padding="0 8px 0 0"
17
+ >
18
+ <slot
19
+ name="body"
20
+ />
21
+ </FSFadeOut>
22
+ <FSRow
23
+ padding="0 16px 0 0"
24
+ >
25
+ <slot
26
+ name="left-footer"
27
+ />
28
+ <FSRow
29
+ class="fs-dialog-actions"
30
+ align="top-right"
31
+ :wrap="false"
32
+ >
33
+ <FSButton
34
+ :prependIcon="$props.cancelButtonPrependIcon"
35
+ :appendIcon="$props.cancelButtonAppendIcon"
36
+ :variant="$props.cancelButtonVariant"
37
+ :color="$props.cancelButtonColor"
38
+ :label="cancelLabel"
39
+ @click="() => $emit('click:cancelButton', false)"
40
+ />
41
+ <FSButton
42
+ type="submit"
43
+ :prependIcon="$props.submitButtonPrependIcon"
44
+ :appendIcon="$props.submitButtonAppendIcon"
45
+ :variant="$props.submitButtonVariant"
46
+ :color="$props.submitButtonColor"
47
+ :editable="$props.editable"
48
+ :label="submitLabel"
49
+ :load="$props.load"
50
+ />
51
+ </FSRow>
52
+ </FSRow>
53
+ </FSCol>
54
+ </FSForm>
55
+ </template>
56
+ <template
57
+ v-else
58
+ >
59
+ <FSCol
60
+ gap="24px"
61
+ >
62
+ <FSFadeOut
63
+ :height="height"
64
+ padding="0 8px 0 0"
65
+ >
66
+ <slot
67
+ name="validation"
68
+ />
69
+ </FSFadeOut>
70
+ <FSRow
71
+ padding="0 16px 0 0"
72
+ >
73
+ <slot
74
+ name="left-footer"
75
+ />
76
+ <FSRow
77
+ class="fs-dialog-actions"
78
+ align="top-right"
79
+ :wrap="false"
80
+ >
81
+ <FSButton
82
+ :prependIcon="$props.validateButtonPrependIcon"
83
+ :appendIcon="$props.validateButtonAppendIcon"
84
+ :variant="$props.validateButtonVariant"
85
+ :color="$props.validateButtonColor"
86
+ :label="validateLabel"
87
+ @click="onValidate"
88
+ />
89
+ </FSRow>
90
+ </FSRow>
91
+ </FSCol>
92
+ </template>
93
+ </template>
94
+
95
+ <script lang="ts">
96
+ import { computed, defineComponent, type PropType, ref } from "vue";
97
+
98
+ import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui/composables";
99
+ import { type ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
100
+ import { useBreakpoints } from "@dative-gpi/foundation-shared-components/composables";
101
+
102
+ import FSFadeOut from "./FSFadeOut.vue";
103
+ import FSButton from "./FSButton.vue";
104
+ import FSForm from "./FSForm.vue";
105
+ import FSRow from "./FSRow.vue";
106
+
107
+ export default defineComponent({
108
+ name: "FSDialogFormBody",
109
+ components: {
110
+ FSFadeOut,
111
+ FSButton,
112
+ FSForm,
113
+ FSRow
114
+ },
115
+ props: {
116
+ variant: {
117
+ type: String as PropType<"standard" | "submit">,
118
+ required: false,
119
+ default: "submit"
120
+ },
121
+ modelValue: {
122
+ type: Boolean,
123
+ required: false,
124
+ default: false
125
+ },
126
+ subtitle: {
127
+ type: String as PropType<string | null>,
128
+ required: false,
129
+ default: null
130
+ },
131
+ cancelButtonPrependIcon: {
132
+ type: String as PropType<string | null>,
133
+ required: false,
134
+ default: null
135
+ },
136
+ cancelButtonLabel: {
137
+ type: String as PropType<string | null>,
138
+ required: false,
139
+ default: null
140
+ },
141
+ cancelButtonAppendIcon: {
142
+ type: String as PropType<string | null>,
143
+ required: false,
144
+ default: null
145
+ },
146
+ cancelButtonVariant: {
147
+ type: String as PropType<"standard" | "full" | "icon">,
148
+ required: false,
149
+ default: "standard"
150
+ },
151
+ cancelButtonColor: {
152
+ type: String as PropType<ColorBase>,
153
+ required: false,
154
+ default: ColorEnum.Light
155
+ },
156
+ submitButtonPrependIcon: {
157
+ type: String as PropType<string | null>,
158
+ required: false,
159
+ default: null
160
+ },
161
+ submitButtonLabel: {
162
+ type: String as PropType<string | null>,
163
+ required: false,
164
+ default: null
165
+ },
166
+ submitButtonAppendIcon: {
167
+ type: String as PropType<string | null>,
168
+ required: false,
169
+ default: null
170
+ },
171
+ submitButtonVariant: {
172
+ type: String as PropType<"standard" | "full" | "icon">,
173
+ required: false,
174
+ default: "full"
175
+ },
176
+ submitButtonColor: {
177
+ type: String as PropType<ColorBase>,
178
+ required: false,
179
+ default: ColorEnum.Primary
180
+ },
181
+ validateButtonPrependIcon: {
182
+ type: String as PropType<string | null>,
183
+ required: false,
184
+ default: null
185
+ },
186
+ validateButtonLabel: {
187
+ type: String as PropType<string | null>,
188
+ required: false,
189
+ default: null
190
+ },
191
+ validateButtonAppendIcon: {
192
+ type: String as PropType<string | null>,
193
+ required: false,
194
+ default: null
195
+ },
196
+ validateButtonVariant: {
197
+ type: String as PropType<"standard" | "full" | "icon">,
198
+ required: false,
199
+ default: "standard"
200
+ },
201
+ validateButtonColor: {
202
+ type: String as PropType<ColorBase>,
203
+ required: false,
204
+ default: ColorEnum.Light
205
+ },
206
+ validation: {
207
+ type: Boolean,
208
+ required: false,
209
+ default: false
210
+ },
211
+ load: {
212
+ type: Boolean,
213
+ required: false,
214
+ default: false
215
+ },
216
+ editable: {
217
+ type: Boolean,
218
+ required: false,
219
+ default: true
220
+ }
221
+ },
222
+ emits: ["click:cancelButton", "click:submitButton", "click:validateButton"],
223
+ setup(props, { emit }) {
224
+ const { isMobileSized } = useBreakpoints();
225
+ const { $tr } = useTranslationsProvider();
226
+
227
+ const formRef = ref<HTMLElement | null>(null);
228
+ const valid = ref(false);
229
+
230
+ const height = computed(() => {
231
+ const other = 24 + 24 // Paddings
232
+ + (isMobileSized.value ? 24 : 32) + 24 // Title
233
+ + (props.subtitle ? (isMobileSized.value ? 14 : 16) + 8 : 0) // Subtitle
234
+ + (isMobileSized.value ? 36 : 40) + 24; // Footer
235
+ return `calc(100vh - 40px - ${other}px)`;
236
+ });
237
+
238
+ const cancelLabel = computed(() => {
239
+ return props.cancelButtonLabel ?? $tr("ui.button.cancel", "Cancel");
240
+ });
241
+
242
+ const submitLabel = computed(() => {
243
+ return props.submitButtonLabel ?? $tr("ui.button.submit", "Submit");
244
+ });
245
+
246
+ const validateLabel = computed(() => {
247
+ return props.validateButtonLabel ?? $tr("ui.button.validate", "Done");
248
+ });
249
+
250
+ const onSubmit = () => {
251
+ if (valid.value) {
252
+ emit("click:submitButton");
253
+ }
254
+ };
255
+
256
+ const onValidate = () => {
257
+ emit("click:validateButton");
258
+ };
259
+
260
+ return {
261
+ validateLabel,
262
+ cancelLabel,
263
+ submitLabel,
264
+ ColorEnum,
265
+ formRef,
266
+ height,
267
+ valid,
268
+ onValidate,
269
+ onSubmit
270
+ };
271
+ }
272
+ });
273
+ </script>
@@ -10,89 +10,39 @@
10
10
  <template
11
11
  #body
12
12
  >
13
- <FSWindow
14
- width="100%"
15
- :modelValue="currentStep - 1"
13
+ <FSDialogMultiFormBody
14
+ :subtitle="$props.subtitle"
15
+ :steps="$props.steps"
16
+ @click:submitButton="$emit('click:submitButton')"
17
+ @click:cancelButton="$emit('update:modelValue', false)"
18
+ v-bind="$attrs"
16
19
  >
17
- <FSForm
18
- v-for="(step, index) in $props.steps"
19
- :variant="$props.variant"
20
- :key="index"
21
- @submit="onSubmit"
22
- v-model="valid"
20
+ <template
21
+ v-for="(_, name) in $slots"
22
+ v-slot:[name]="slotData"
23
23
  >
24
- <FSCol
25
- gap="24px"
26
- >
27
- <FSFadeOut
28
- :height="height"
29
- padding="0 8px 0 0"
30
- >
31
- <slot
32
- :name="`step-${step}`"
33
- />
34
- </FSFadeOut>
35
- <FSRow
36
- padding="0 16px 0 0"
37
- >
38
- <slot
39
- name="left-footer"
40
- />
41
- <FSRow
42
- class="fs-dialog-actions"
43
- align="top-right"
44
- :wrap="false"
45
- >
46
- <FSButton
47
- :prependIcon="$props.cancelButtonPrependIcon"
48
- :appendIcon="$props.cancelButtonAppendIcon"
49
- :variant="$props.cancelButtonVariant"
50
- :color="$props.cancelButtonColor"
51
- :label="previousButtonLabel"
52
- @click="onPrevious()"
53
- />
54
- <FSButton
55
- type="submit"
56
- :prependIcon="$props.submitButtonPrependIcon"
57
- :appendIcon="$props.submitButtonAppendIcon"
58
- :color="$props.submitButtonColor"
59
- :variant="nextButtonVariant"
60
- :editable="$props.editable"
61
- :label="nextButtonLabel"
62
- :load="$props.load"
63
- />
64
- </FSRow>
65
- </FSRow>
66
- </FSCol>
67
- </FSForm>
68
- </FSWindow>
24
+ <slot
25
+ :name="name"
26
+ v-bind="slotData"
27
+ />
28
+ </template>
29
+ </FSDialogMultiFormBody>
69
30
  </template>
70
31
  </FSDialog>
71
32
  </template>
72
33
 
73
34
  <script lang="ts">
74
35
  import type { PropType} from "vue";
75
- import { computed, defineComponent, ref } from "vue";
36
+ import { defineComponent } from "vue";
76
37
 
77
- import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui/composables";
78
- import type { ColorBase} from "@dative-gpi/foundation-shared-components/models";
79
- import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
80
- import { useBreakpoints } from "@dative-gpi/foundation-shared-components/composables";
81
-
82
- import FSFadeOut from "./FSFadeOut.vue";
83
- import FSButton from "./FSButton.vue";
38
+ import FSDialogMultiFormBody from "./FSDialogMultiFormBody.vue";
84
39
  import FSDialog from "./FSDialog.vue";
85
- import FSForm from "./FSForm.vue";
86
- import FSRow from "./FSRow.vue";
87
40
 
88
41
  export default defineComponent({
89
42
  name: "FSDialogMultiForm",
90
43
  components: {
91
- FSFadeOut,
92
- FSButton,
93
- FSDialog,
94
- FSForm,
95
- FSRow
44
+ FSDialogMultiFormBody,
45
+ FSDialog
96
46
  },
97
47
  props: {
98
48
  title: {
@@ -110,11 +60,6 @@ export default defineComponent({
110
60
  required: false,
111
61
  default: "auto"
112
62
  },
113
- variant: {
114
- type: String as PropType<"standard" | "lazy" | "submit">,
115
- required: false,
116
- default: "submit"
117
- },
118
63
  modelValue: {
119
64
  type: Boolean,
120
65
  required: false,
@@ -124,134 +69,11 @@ export default defineComponent({
124
69
  type: Number,
125
70
  required: true
126
71
  },
127
- cancelButtonPrependIcon: {
128
- type: String as PropType<string | null>,
129
- required: false,
130
- default: null
131
- },
132
- cancelButtonLabel: {
133
- type: String as PropType<string | null>,
134
- required: false,
135
- default: null
136
- },
137
- cancelButtonAppendIcon: {
138
- type: String as PropType<string | null>,
139
- required: false,
140
- default: null
141
- },
142
- cancelButtonVariant: {
143
- type: String as PropType<"standard" | "full" | "icon">,
144
- required: false,
145
- default: "standard"
146
- },
147
- cancelButtonColor: {
148
- type: String as PropType<ColorBase>,
149
- required: false,
150
- default: ColorEnum.Light
151
- },
152
- submitButtonPrependIcon: {
153
- type: String as PropType<string | null>,
154
- required: false,
155
- default: null
156
- },
157
- submitButtonLabel: {
158
- type: String as PropType<string | null>,
159
- required: false,
160
- default: null
161
- },
162
- submitButtonAppendIcon: {
163
- type: String as PropType<string | null>,
164
- required: false,
165
- default: null
166
- },
167
- submitButtonVariant: {
168
- type: String as PropType<"standard" | "full" | "icon">,
169
- required: false,
170
- default: "full"
171
- },
172
- submitButtonColor: {
173
- type: String as PropType<ColorBase>,
174
- required: false,
175
- default: ColorEnum.Primary
176
- },
177
- load: {
178
- type: Boolean,
179
- required: false,
180
- default: false
181
- },
182
- editable: {
183
- type: Boolean,
184
- required: false,
185
- default: true
186
- }
187
72
  },
188
73
  emits: ["update:modelValue", "click:submitButton"],
189
- setup(props, { emit }) {
190
- const { isMobileSized } = useBreakpoints();
191
- const { $tr } = useTranslationsProvider();
192
-
193
- const currentStep = ref(1);
194
- const valid = ref(false);
195
- const valids = ref(Array.from({ length: props.steps }, () => false));
196
-
197
- const height = computed(() => {
198
- const other = 24 + 24 // Paddings
199
- + (isMobileSized.value ? 24 : 32) + 24 // Title
200
- + (props.subtitle ? (isMobileSized.value ? 14 : 16) + 8 : 0) // Subtitle
201
- + (isMobileSized.value ? 36 : 40) + 24; // Footer
202
- return `calc(100vh - 40px - ${other}px)`;
203
- });
204
-
205
- const previousButtonLabel = computed(() => {
206
- return currentStep.value == 1
207
- ? props.cancelButtonLabel ?? $tr("ui.button.cancel", "Cancel")
208
- : $tr("ui.button.back", "Back");
209
- });
210
-
211
- const nextButtonLabel = computed(() => {
212
- return currentStep.value == props.steps
213
- ? props.submitButtonLabel ?? $tr("ui.button.validate", "Validate")
214
- : $tr("ui.button.next", "Next");
215
- });
216
-
217
- const nextButtonVariant = computed(() => {
218
- return currentStep.value == props.steps
219
- ? props.submitButtonVariant ?? "full" : "standard";
220
- });
221
-
222
- const onPrevious = () => {
223
- if (currentStep.value > 1) {
224
- currentStep.value--;
225
- }
226
- else {
227
- emit("update:modelValue", false);
228
- }
229
- };
230
-
231
- const onSubmit = () => {
232
- if (valid.value) {
233
- switch (currentStep.value) {
234
- case props.steps:
235
- emit("click:submitButton");
236
- break;
237
- default:
238
- currentStep.value++;
239
- break;
240
- }
241
- }
242
- };
74
+ setup() {
243
75
 
244
76
  return {
245
- previousButtonLabel,
246
- nextButtonVariant,
247
- nextButtonLabel,
248
- currentStep,
249
- ColorEnum,
250
- height,
251
- valids,
252
- valid,
253
- onPrevious,
254
- onSubmit
255
77
  };
256
78
  }
257
79
  });