@dative-gpi/foundation-shared-components 1.0.179-utils-composable → 1.0.180-acknowledge
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/FSDialogMultiFormBody.vue +3 -69
- package/components/FSEditImage.vue +3 -4
- package/components/FSTab.vue +1 -3
- package/components/fields/FSTranslateField.vue +4 -10
- package/components/fields/FSTranslateTextArea.vue +4 -9
- package/models/index.ts +1 -2
- package/package.json +4 -4
- package/composables/useAccessibilityPreferences.ts +0 -7
- package/composables/useCountUp.ts +0 -101
- package/composables/useElementVisibility.ts +0 -39
- package/models/translations.ts +0 -4
|
@@ -3,45 +3,10 @@
|
|
|
3
3
|
gap="24px"
|
|
4
4
|
>
|
|
5
5
|
<FSPagination
|
|
6
|
-
v-if="$props.mode === 'pagination'"
|
|
7
6
|
width="calc(100% - 16px)"
|
|
8
7
|
:pages="$props.steps"
|
|
9
8
|
:modelValue="currentStep - 1"
|
|
10
9
|
/>
|
|
11
|
-
<FSTabs
|
|
12
|
-
v-else-if="$props.mode === 'tabs'"
|
|
13
|
-
:tab="currentStep - 1"
|
|
14
|
-
:color="$props.tabsColor"
|
|
15
|
-
@update:tab="(val) => currentStep = val + 1"
|
|
16
|
-
>
|
|
17
|
-
<FSTab
|
|
18
|
-
v-for="(step, index) in $props.steps"
|
|
19
|
-
:key="index"
|
|
20
|
-
>
|
|
21
|
-
<slot
|
|
22
|
-
:name="`tab-${index + 1}`"
|
|
23
|
-
>
|
|
24
|
-
<FSRow>
|
|
25
|
-
<FSIcon
|
|
26
|
-
v-if="tabIconSlots[`tab-${index + 1}-icon`]"
|
|
27
|
-
>
|
|
28
|
-
<slot
|
|
29
|
-
:name="`tab-${index + 1}-icon`"
|
|
30
|
-
/>
|
|
31
|
-
</FSIcon>
|
|
32
|
-
<FSSpan
|
|
33
|
-
:font="index + 1 === currentStep ? 'text-button' : 'text-body'"
|
|
34
|
-
>
|
|
35
|
-
<slot
|
|
36
|
-
:name="`tab-${index + 1}-label`"
|
|
37
|
-
>
|
|
38
|
-
{{ $tr('ui.tabs.step.default', 'Step {0}', step) }}
|
|
39
|
-
</slot>
|
|
40
|
-
</FSSpan>
|
|
41
|
-
</FSRow>
|
|
42
|
-
</slot>
|
|
43
|
-
</FSTab>
|
|
44
|
-
</FSTabs>
|
|
45
10
|
<FSWindow
|
|
46
11
|
width="100%"
|
|
47
12
|
:modelValue="currentStep - 1"
|
|
@@ -113,11 +78,6 @@ import FSButton from "./FSButton.vue";
|
|
|
113
78
|
import FSForm from "./FSForm.vue";
|
|
114
79
|
import FSCol from "./FSCol.vue";
|
|
115
80
|
import FSRow from "./FSRow.vue";
|
|
116
|
-
import FSSpan from "./FSSpan.vue";
|
|
117
|
-
import FSTabs from "./FSTabs.vue";
|
|
118
|
-
import FSTab from "./FSTab.vue";
|
|
119
|
-
import FSIcon from "./FSIcon.vue";
|
|
120
|
-
import FSWindow from "./FSWindow.vue";
|
|
121
81
|
|
|
122
82
|
export default defineComponent({
|
|
123
83
|
name: "FSDialogMultiFormBody",
|
|
@@ -127,12 +87,7 @@ export default defineComponent({
|
|
|
127
87
|
FSButton,
|
|
128
88
|
FSForm,
|
|
129
89
|
FSCol,
|
|
130
|
-
FSRow
|
|
131
|
-
FSSpan,
|
|
132
|
-
FSTabs,
|
|
133
|
-
FSTab,
|
|
134
|
-
FSIcon,
|
|
135
|
-
FSWindow
|
|
90
|
+
FSRow
|
|
136
91
|
},
|
|
137
92
|
props: {
|
|
138
93
|
subtitle: {
|
|
@@ -223,20 +178,10 @@ export default defineComponent({
|
|
|
223
178
|
type: Boolean,
|
|
224
179
|
required: false,
|
|
225
180
|
default: false
|
|
226
|
-
}
|
|
227
|
-
mode: {
|
|
228
|
-
type: String as PropType<"pagination" | "tabs">,
|
|
229
|
-
required: false,
|
|
230
|
-
default: "pagination"
|
|
231
|
-
},
|
|
232
|
-
tabsColor: {
|
|
233
|
-
type: String as PropType<ColorBase>,
|
|
234
|
-
required: false,
|
|
235
|
-
default: ColorEnum.Primary
|
|
236
|
-
},
|
|
181
|
+
}
|
|
237
182
|
},
|
|
238
183
|
emits: ["click:cancelButton", "click:submitButton"],
|
|
239
|
-
setup(props, { emit
|
|
184
|
+
setup(props, { emit }) {
|
|
240
185
|
const { isMobileSized } = useBreakpoints();
|
|
241
186
|
const { $tr } = useTranslationsProvider();
|
|
242
187
|
|
|
@@ -244,16 +189,6 @@ export default defineComponent({
|
|
|
244
189
|
const valid = ref(false);
|
|
245
190
|
const valids = ref(Array.from({ length: props.steps }, () => false));
|
|
246
191
|
|
|
247
|
-
const hasSlot = (name: string) => !!slots[name];
|
|
248
|
-
|
|
249
|
-
const tabIconSlots = computed(() => {
|
|
250
|
-
const result: Record<string, boolean> = {};
|
|
251
|
-
for (let i = 1; i <= props.steps; i++) {
|
|
252
|
-
result[`tab-${i}-icon`] = hasSlot(`tab-${i}-icon`);
|
|
253
|
-
}
|
|
254
|
-
return result;
|
|
255
|
-
});
|
|
256
|
-
|
|
257
192
|
const maxHeight = computed(() => {
|
|
258
193
|
const other = 24 + 24 // Paddings
|
|
259
194
|
+ (isMobileSized.value ? 24 : 32) + 24 // Title
|
|
@@ -311,7 +246,6 @@ export default defineComponent({
|
|
|
311
246
|
maxHeight,
|
|
312
247
|
valids,
|
|
313
248
|
valid,
|
|
314
|
-
tabIconSlots,
|
|
315
249
|
onPrevious,
|
|
316
250
|
onSubmit
|
|
317
251
|
};
|
|
@@ -13,7 +13,7 @@ import { computed, defineComponent, type PropType } from "vue";
|
|
|
13
13
|
|
|
14
14
|
import { IMAGE_RAW_URL } from "@dative-gpi/foundation-shared-services/config";
|
|
15
15
|
|
|
16
|
-
import { useImage
|
|
16
|
+
import { useImage } from "@dative-gpi/foundation-shared-services/composables";
|
|
17
17
|
|
|
18
18
|
import FSEditImageUI from "./FSEditImageUI.vue";
|
|
19
19
|
|
|
@@ -32,11 +32,10 @@ export default defineComponent({
|
|
|
32
32
|
emits: ["update:imageId"],
|
|
33
33
|
setup(props) {
|
|
34
34
|
const { get: getImage, entity: image } = useImage();
|
|
35
|
-
const { authToken } = useAppAuthToken();
|
|
36
35
|
|
|
37
36
|
const source = computed(() => {
|
|
38
|
-
return props.imageId ? IMAGE_RAW_URL(props.imageId
|
|
39
|
-
})
|
|
37
|
+
return props.imageId ? IMAGE_RAW_URL(props.imageId) : null;
|
|
38
|
+
})
|
|
40
39
|
|
|
41
40
|
const onError = (): void => {
|
|
42
41
|
if (props.imageId) {
|
package/components/FSTab.vue
CHANGED
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
</template>
|
|
85
85
|
|
|
86
86
|
<script lang="ts">
|
|
87
|
-
import { computed, defineComponent, type PropType, ref, type StyleValue
|
|
87
|
+
import { computed, defineComponent, type PropType, ref, type StyleValue } from "vue";
|
|
88
88
|
|
|
89
89
|
import { type ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
|
|
90
90
|
import { useAppLanguages } from "@dative-gpi/foundation-shared-services/composables";
|
|
@@ -97,7 +97,6 @@ import FSButton from "../FSButton.vue";
|
|
|
97
97
|
import FSIcon from "../FSIcon.vue";
|
|
98
98
|
import FSSpan from "../FSSpan.vue";
|
|
99
99
|
import FSRow from "../FSRow.vue";
|
|
100
|
-
import type { Translation } from "@dative-gpi/foundation-shared-components/models";
|
|
101
100
|
|
|
102
101
|
export default defineComponent({
|
|
103
102
|
name: "FSTranslateField",
|
|
@@ -141,7 +140,7 @@ export default defineComponent({
|
|
|
141
140
|
default: "label"
|
|
142
141
|
},
|
|
143
142
|
translations: {
|
|
144
|
-
type: Array as PropType<
|
|
143
|
+
type: Array as PropType<{ languageCode: string; [key: string]: string }[]>,
|
|
145
144
|
required: false,
|
|
146
145
|
default: () => []
|
|
147
146
|
},
|
|
@@ -166,7 +165,7 @@ export default defineComponent({
|
|
|
166
165
|
|
|
167
166
|
const dialog = ref(false);
|
|
168
167
|
|
|
169
|
-
const innerTranslations = ref
|
|
168
|
+
const innerTranslations = ref(props.translations);
|
|
170
169
|
|
|
171
170
|
const lights = getColors(ColorEnum.Light);
|
|
172
171
|
const darks = getColors(ColorEnum.Dark);
|
|
@@ -190,8 +189,7 @@ export default defineComponent({
|
|
|
190
189
|
if (!translation || !translation[props.property]) {
|
|
191
190
|
return "";
|
|
192
191
|
}
|
|
193
|
-
|
|
194
|
-
return translation[props.property] ?? "";
|
|
192
|
+
return translation[props.property];
|
|
195
193
|
};
|
|
196
194
|
|
|
197
195
|
const setTranslation = (languageCode: string, value: string): void => {
|
|
@@ -221,10 +219,6 @@ export default defineComponent({
|
|
|
221
219
|
}
|
|
222
220
|
};
|
|
223
221
|
|
|
224
|
-
watch(() => props.translations, (newVal) => {
|
|
225
|
-
innerTranslations.value = newVal;
|
|
226
|
-
}, { immediate: true, deep: true });
|
|
227
|
-
|
|
228
222
|
return {
|
|
229
223
|
innerTranslations,
|
|
230
224
|
ColorEnum,
|
|
@@ -86,11 +86,10 @@
|
|
|
86
86
|
</template>
|
|
87
87
|
|
|
88
88
|
<script lang="ts">
|
|
89
|
-
import { computed, defineComponent, type PropType, ref, type StyleValue
|
|
89
|
+
import { computed, defineComponent, type PropType, ref, type StyleValue } from "vue";
|
|
90
90
|
|
|
91
91
|
import { type ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
|
|
92
92
|
import { useAppLanguages } from "@dative-gpi/foundation-shared-services/composables";
|
|
93
|
-
import type { Translation } from "@dative-gpi/foundation-shared-components/models";
|
|
94
93
|
|
|
95
94
|
import { useColors } from "../../composables";
|
|
96
95
|
|
|
@@ -143,7 +142,7 @@ export default defineComponent({
|
|
|
143
142
|
default: "label"
|
|
144
143
|
},
|
|
145
144
|
translations: {
|
|
146
|
-
type: Array as PropType<
|
|
145
|
+
type: Array as PropType<{ languageCode: string; [key: string]: string }[]>,
|
|
147
146
|
required: false,
|
|
148
147
|
default: () => []
|
|
149
148
|
},
|
|
@@ -165,7 +164,7 @@ export default defineComponent({
|
|
|
165
164
|
|
|
166
165
|
const dialog = ref(false);
|
|
167
166
|
|
|
168
|
-
const innerTranslations = ref
|
|
167
|
+
const innerTranslations = ref(props.translations);
|
|
169
168
|
|
|
170
169
|
const lights = getColors(ColorEnum.Light);
|
|
171
170
|
const darks = getColors(ColorEnum.Dark);
|
|
@@ -189,7 +188,7 @@ export default defineComponent({
|
|
|
189
188
|
if (!translation || !translation[props.property]) {
|
|
190
189
|
return "";
|
|
191
190
|
}
|
|
192
|
-
return translation[props.property]
|
|
191
|
+
return translation[props.property];
|
|
193
192
|
};
|
|
194
193
|
|
|
195
194
|
const setTranslation = (languageCode: string, value: string): void => {
|
|
@@ -219,10 +218,6 @@ export default defineComponent({
|
|
|
219
218
|
}
|
|
220
219
|
};
|
|
221
220
|
|
|
222
|
-
watch(() => props.translations, (newVal) => {
|
|
223
|
-
innerTranslations.value = newVal;
|
|
224
|
-
}, { immediate: true, deep: true });
|
|
225
|
-
|
|
226
221
|
return {
|
|
227
222
|
innerTranslations,
|
|
228
223
|
ColorEnum,
|
package/models/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-shared-components",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.180-acknowledge",
|
|
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": "1.0.
|
|
14
|
-
"@dative-gpi/foundation-shared-services": "1.0.
|
|
13
|
+
"@dative-gpi/foundation-shared-domain": "1.0.180-acknowledge",
|
|
14
|
+
"@dative-gpi/foundation-shared-services": "1.0.180-acknowledge"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@dative-gpi/bones-ui": "^1.0.0",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"sass": "1.71.1",
|
|
36
36
|
"sass-loader": "13.3.2"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "3c9637a41bbf9911f59a2cdd92b7a7d0961e4223"
|
|
39
39
|
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { ref, computed, onBeforeUnmount, watch } from 'vue';
|
|
2
|
-
import { useAccessibilityPreferences } from './useAccessibilityPreferences';
|
|
3
|
-
|
|
4
|
-
export function useCountUp(options: {
|
|
5
|
-
value: number | string,
|
|
6
|
-
duration?: number,
|
|
7
|
-
countUp?: boolean,
|
|
8
|
-
pad?: number,
|
|
9
|
-
startOnVisible?: boolean,
|
|
10
|
-
easing?: (t: number) => number
|
|
11
|
-
}) {
|
|
12
|
-
const {
|
|
13
|
-
value,
|
|
14
|
-
duration = 800,
|
|
15
|
-
countUp = true,
|
|
16
|
-
pad = 2,
|
|
17
|
-
startOnVisible = true,
|
|
18
|
-
easing = easeOutCubic
|
|
19
|
-
} = options;
|
|
20
|
-
|
|
21
|
-
const { prefersReducedMotion } = useAccessibilityPreferences();
|
|
22
|
-
const current = ref(0);
|
|
23
|
-
const rafId = ref(0);
|
|
24
|
-
const hasAnimated = ref(false);
|
|
25
|
-
|
|
26
|
-
// Easing function
|
|
27
|
-
function easeOutCubic(t: number) {
|
|
28
|
-
return 1 - Math.pow(1 - t, 3);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Target value computation
|
|
32
|
-
const target = computed(() => {
|
|
33
|
-
const n = Number(value);
|
|
34
|
-
return Number.isFinite(n) ? Math.trunc(n) : 0;
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// Formatted display value
|
|
38
|
-
const displayText = computed(() => {
|
|
39
|
-
const s = String(countUp ? current.value : target.value);
|
|
40
|
-
return pad > 0 ? s.padStart(pad, "0") : s;
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// Animation function
|
|
44
|
-
function animate(from: number, to: number, animDuration: number) {
|
|
45
|
-
cancelAnimationFrame(rafId.value);
|
|
46
|
-
const start = performance.now();
|
|
47
|
-
|
|
48
|
-
const step = (now: number) => {
|
|
49
|
-
const t = Math.min(1, (now - start) / animDuration);
|
|
50
|
-
const v = from + (to - from) * easing(t);
|
|
51
|
-
current.value = Math.round(v);
|
|
52
|
-
if (t < 1) {
|
|
53
|
-
rafId.value = requestAnimationFrame(step);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
rafId.value = requestAnimationFrame(step);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Start animation
|
|
61
|
-
function start() {
|
|
62
|
-
if (!countUp) {
|
|
63
|
-
current.value = target.value;
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (prefersReducedMotion) {
|
|
68
|
-
current.value = target.value;
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
animate(current.value, target.value, duration);
|
|
73
|
-
hasAnimated.value = true;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Clean up
|
|
77
|
-
onBeforeUnmount(() => {
|
|
78
|
-
cancelAnimationFrame(rafId.value);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
// The restart method can be useful when the value changes.
|
|
82
|
-
function restart() {
|
|
83
|
-
if (hasAnimated.value || !startOnVisible) {
|
|
84
|
-
start();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Monitor changes in value
|
|
89
|
-
watch(() => value, () => {
|
|
90
|
-
restart();
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
return {
|
|
94
|
-
current,
|
|
95
|
-
target,
|
|
96
|
-
displayText,
|
|
97
|
-
start,
|
|
98
|
-
restart,
|
|
99
|
-
hasAnimated
|
|
100
|
-
};
|
|
101
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { ref, onMounted, onBeforeUnmount } from 'vue';
|
|
2
|
-
|
|
3
|
-
export function useElementVisibility(element: HTMLElement | null, options: {
|
|
4
|
-
threshold?: number,
|
|
5
|
-
onVisible?: () => void
|
|
6
|
-
}) {
|
|
7
|
-
const {
|
|
8
|
-
threshold = 0.3,
|
|
9
|
-
onVisible
|
|
10
|
-
} = options;
|
|
11
|
-
|
|
12
|
-
const isVisible = ref(false);
|
|
13
|
-
const observer = ref<IntersectionObserver | null>(null);
|
|
14
|
-
|
|
15
|
-
onMounted(() => {
|
|
16
|
-
if (!element) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
observer.value = new IntersectionObserver((entries) => {
|
|
21
|
-
entries.forEach((entry) => {
|
|
22
|
-
isVisible.value = entry.isIntersecting;
|
|
23
|
-
if (entry.isIntersecting && onVisible) {
|
|
24
|
-
onVisible();
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}, { threshold });
|
|
28
|
-
|
|
29
|
-
observer.value.observe(element);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
onBeforeUnmount(() => {
|
|
33
|
-
observer.value?.disconnect();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
isVisible
|
|
38
|
-
};
|
|
39
|
-
}
|
package/models/translations.ts
DELETED