@sbc-connect/nuxt-forms 0.1.25 → 0.1.27
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/CHANGELOG.md +20 -0
- package/app/components/Connect/Form/Address/City.vue +3 -2
- package/app/components/Connect/Form/Address/Country.vue +9 -54
- package/app/components/Connect/Form/Address/DeliveryInstructions.vue +1 -1
- package/app/components/Connect/Form/Address/PostalCode.vue +7 -5
- package/app/components/Connect/Form/Address/Region.vue +7 -52
- package/app/components/Connect/Form/Address/Street.vue +18 -5
- package/app/components/Connect/Form/Address/StreetAdditional.vue +1 -1
- package/app/components/Connect/Form/Address/index.vue +6 -0
- package/app/components/Connect/Form/Input.vue +1 -1
- package/app/components/Connect/Form/Textarea.vue +1 -1
- package/app/components/Connect/Layout/Form.vue +1 -2
- package/app/composables/useCanadaPost.ts +10 -4
- package/app/types/forms-page-meta.d.ts +3 -5
- package/package.json +3 -3
- package/app/components/Connect/ButtonControl/Buttons.vue +0 -19
- package/app/components/Connect/ButtonControl/Index.vue +0 -59
- package/app/components/Connect/ButtonControl/Wrapper.vue +0 -10
- package/app/composables/useButtonControl.ts +0 -72
- package/app/interfaces/connect-button-control.ts +0 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @sbc-connect/nuxt-forms
|
|
2
2
|
|
|
3
|
+
## 0.1.27
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#85](https://github.com/bcgov/connect-nuxt/pull/85) [`6b0f70a`](https://github.com/bcgov/connect-nuxt/commit/6b0f70ab895a26c0b049dce84b130d6a04fd911e) Thanks [@kialj876](https://github.com/kialj876)! - Common layout updates, default state key for tombstone, fee store - waive fees, add prioirty, expose cached fees
|
|
8
|
+
|
|
9
|
+
- [#84](https://github.com/bcgov/connect-nuxt/pull/84) [`f37700a`](https://github.com/bcgov/connect-nuxt/commit/f37700ab568335df724a5e9472a5e0b4198704b5) Thanks [@deetz99](https://github.com/deetz99)! - Cleanup model types and floating labels.
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`f37700a`](https://github.com/bcgov/connect-nuxt/commit/f37700ab568335df724a5e9472a5e0b4198704b5), [`6b0f70a`](https://github.com/bcgov/connect-nuxt/commit/6b0f70ab895a26c0b049dce84b130d6a04fd911e), [`ba04c84`](https://github.com/bcgov/connect-nuxt/commit/ba04c8424353b32af0811534d9c3edd31e15d39e)]:
|
|
12
|
+
- @sbc-connect/nuxt-base@0.1.25
|
|
13
|
+
|
|
14
|
+
## 0.1.26
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#80](https://github.com/bcgov/connect-nuxt/pull/80) [`0615542`](https://github.com/bcgov/connect-nuxt/commit/06155422d0a8d61ee862bb3483330610b4a9434d) Thanks [@deetz99](https://github.com/deetz99)! - feat: Move button control to base and handle loading state internally
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`0615542`](https://github.com/bcgov/connect-nuxt/commit/06155422d0a8d61ee862bb3483330610b4a9434d)]:
|
|
21
|
+
- @sbc-connect/nuxt-base@0.1.24
|
|
22
|
+
|
|
3
23
|
## 0.1.25
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
defineProps<{
|
|
3
3
|
parentId: string
|
|
4
4
|
schemaPrefix: string
|
|
5
|
+
required?: boolean
|
|
5
6
|
}>()
|
|
6
7
|
|
|
7
|
-
const model = defineModel<string>({
|
|
8
|
+
const model = defineModel<string | undefined>({ required: true })
|
|
8
9
|
</script>
|
|
9
10
|
|
|
10
11
|
<template>
|
|
@@ -13,7 +14,7 @@ const model = defineModel<string>({ default: '' })
|
|
|
13
14
|
:data-testid="`${parentId}-field-city`"
|
|
14
15
|
:input-id="`${parentId}-input-city`"
|
|
15
16
|
:name="schemaPrefix + '.city'"
|
|
16
|
-
required
|
|
17
|
+
:required
|
|
17
18
|
:label="$t('connect.label.city')"
|
|
18
19
|
/>
|
|
19
20
|
</template>
|
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import type { SelectItem } from '@nuxt/ui'
|
|
2
3
|
import { isoCountriesListSortedByName as countries } from '#forms/app/utils/isoCountriesList'
|
|
3
4
|
|
|
4
5
|
defineProps<{
|
|
5
6
|
parentId: string
|
|
6
7
|
schemaPrefix: string
|
|
7
8
|
disabled?: boolean
|
|
9
|
+
required?: boolean
|
|
8
10
|
}>()
|
|
9
11
|
|
|
10
12
|
defineEmits<{
|
|
11
13
|
change: []
|
|
12
14
|
}>()
|
|
13
15
|
|
|
14
|
-
const model = defineModel<string>({
|
|
16
|
+
const model = defineModel<string | undefined>({ required: true })
|
|
15
17
|
|
|
16
|
-
const
|
|
17
|
-
if (model.value) {
|
|
18
|
-
const found = countries.find(c => c.alpha_2 === model.value)?.name
|
|
19
|
-
return found ?? ''
|
|
20
|
-
}
|
|
21
|
-
return ''
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
const options = [
|
|
18
|
+
const options: SelectItem[] = [
|
|
25
19
|
countries.find(c => c.alpha_2 === 'CA')!,
|
|
26
20
|
countries.find(c => c.alpha_2 === 'US')!,
|
|
21
|
+
{ type: 'separator' },
|
|
27
22
|
...countries
|
|
28
23
|
]
|
|
29
24
|
</script>
|
|
@@ -35,58 +30,18 @@ const options = [
|
|
|
35
30
|
class="grow"
|
|
36
31
|
>
|
|
37
32
|
<template #default="{ error }">
|
|
38
|
-
<
|
|
33
|
+
<ConnectSelect
|
|
39
34
|
:id="`${parentId}-input-country`"
|
|
40
35
|
v-model="model"
|
|
41
|
-
:
|
|
36
|
+
:label="$t('connect.label.country')"
|
|
42
37
|
:items="options"
|
|
43
38
|
value-key="alpha_2"
|
|
44
39
|
label-key="name"
|
|
45
40
|
class="w-full"
|
|
46
|
-
:class="error ? 'shadow-input-error ring-0' : ''"
|
|
47
41
|
:disabled
|
|
48
|
-
:
|
|
49
|
-
:aria-required="true"
|
|
50
|
-
:ui="{
|
|
51
|
-
base: error
|
|
52
|
-
? 'shadow-input-error focus:shadow-input-error data-[state=open]:shadow-input-error'
|
|
53
|
-
: '',
|
|
54
|
-
trailingIcon: error
|
|
55
|
-
? 'text-error group-data-[state=open]:text-error group-focus:text-error'
|
|
56
|
-
: '',
|
|
57
|
-
item: 'nth-2:border-b nth-2:border-gray-200',
|
|
58
|
-
itemTrailingIcon: 'hidden',
|
|
59
|
-
}"
|
|
42
|
+
:required
|
|
60
43
|
@change="$emit('change')"
|
|
61
|
-
|
|
62
|
-
<template #default="{ modelValue }">
|
|
63
|
-
<div class="relative px-2.5 pb-2 pt-6 w-full">
|
|
64
|
-
<span
|
|
65
|
-
aria-hidden="true"
|
|
66
|
-
:class="[
|
|
67
|
-
!modelValue
|
|
68
|
-
? 'top-1/2 -translate-y-1/2'
|
|
69
|
-
: 'top-1 -translate-y-none text-xs',
|
|
70
|
-
error
|
|
71
|
-
? 'text-red-600 group-data-[state=open]:text-red-600 group-focus:text-red-600'
|
|
72
|
-
: '',
|
|
73
|
-
'absolute left-0 px-2.5 text-sm transition-all',
|
|
74
|
-
'group-data-[state=open]:text-primary group-focus:text-primary',
|
|
75
|
-
]"
|
|
76
|
-
>
|
|
77
|
-
{{ $t('connect.label.country') }}
|
|
78
|
-
</span>
|
|
79
|
-
<div class="h-6">
|
|
80
|
-
<span
|
|
81
|
-
v-if="modelValue"
|
|
82
|
-
class="line-clamp-1 text-left"
|
|
83
|
-
>
|
|
84
|
-
{{ displayedCountryName }}
|
|
85
|
-
</span>
|
|
86
|
-
</div>
|
|
87
|
-
</div>
|
|
88
|
-
</template>
|
|
89
|
-
</USelect>
|
|
44
|
+
/>
|
|
90
45
|
<div
|
|
91
46
|
v-if="!$slots.help && !error"
|
|
92
47
|
class="h-4 mt-1"
|
|
@@ -4,14 +4,16 @@ defineProps<{
|
|
|
4
4
|
schemaPrefix: string
|
|
5
5
|
disabled?: boolean
|
|
6
6
|
country?: string
|
|
7
|
+
required?: boolean
|
|
7
8
|
}>()
|
|
8
9
|
|
|
9
|
-
const model = defineModel({
|
|
10
|
+
const model = defineModel<string | undefined>({
|
|
10
11
|
set(value) {
|
|
11
|
-
|
|
12
|
+
if (value) {
|
|
13
|
+
return value.toUpperCase()
|
|
14
|
+
}
|
|
12
15
|
},
|
|
13
|
-
|
|
14
|
-
default: ''
|
|
16
|
+
required: true
|
|
15
17
|
})
|
|
16
18
|
</script>
|
|
17
19
|
|
|
@@ -22,7 +24,7 @@ const model = defineModel({
|
|
|
22
24
|
:data-testid="`${parentId}-field-postalCode`"
|
|
23
25
|
:input-id="`${parentId}-input-postalCode`"
|
|
24
26
|
:disabled
|
|
25
|
-
required
|
|
27
|
+
:required
|
|
26
28
|
:label="country === 'US'
|
|
27
29
|
? $t('connect.label.zipCode')
|
|
28
30
|
: $t('connect.label.postalCode')
|
|
@@ -8,9 +8,10 @@ const {
|
|
|
8
8
|
schemaPrefix: string
|
|
9
9
|
disabled?: boolean
|
|
10
10
|
maxlength?: string
|
|
11
|
+
required?: boolean
|
|
11
12
|
}>()
|
|
12
13
|
|
|
13
|
-
const model = defineModel<string>({
|
|
14
|
+
const model = defineModel<string | undefined>({ required: true })
|
|
14
15
|
|
|
15
16
|
const regions = computed(() => {
|
|
16
17
|
switch (country) {
|
|
@@ -22,14 +23,6 @@ const regions = computed(() => {
|
|
|
22
23
|
return []
|
|
23
24
|
}
|
|
24
25
|
})
|
|
25
|
-
|
|
26
|
-
const displayedRegionName = computed(() => {
|
|
27
|
-
if (model.value) {
|
|
28
|
-
const found = regions.value.find(r => r.code === model.value)?.name
|
|
29
|
-
return found ?? ''
|
|
30
|
-
}
|
|
31
|
-
return ''
|
|
32
|
-
})
|
|
33
26
|
</script>
|
|
34
27
|
|
|
35
28
|
<template>
|
|
@@ -39,56 +32,18 @@ const displayedRegionName = computed(() => {
|
|
|
39
32
|
:data-testid="`${parentId}-field-region`"
|
|
40
33
|
>
|
|
41
34
|
<template #default="{ error }">
|
|
42
|
-
<
|
|
35
|
+
<ConnectSelect
|
|
43
36
|
v-if="country === 'US' || country === 'CA'"
|
|
44
37
|
:id="`${parentId}-input-region`"
|
|
45
38
|
v-model="model"
|
|
46
|
-
:
|
|
39
|
+
:label="country === 'CA' ? $t('connect.label.province') : $t('connect.label.state')"
|
|
47
40
|
:items="regions"
|
|
48
|
-
:aria-label="country === 'CA' ? $t('connect.label.province') : $t('connect.label.state')"
|
|
49
41
|
value-key="code"
|
|
50
42
|
label-key="name"
|
|
51
|
-
:
|
|
43
|
+
:required
|
|
52
44
|
:disabled
|
|
53
|
-
class="w-full grow
|
|
54
|
-
|
|
55
|
-
base: error
|
|
56
|
-
? 'shadow-input-error focus:shadow-input-error data-[state=open]:shadow-input-error'
|
|
57
|
-
: '',
|
|
58
|
-
trailingIcon: error
|
|
59
|
-
? 'text-error group-data-[state=open]:text-error group-focus:text-error'
|
|
60
|
-
: '',
|
|
61
|
-
}"
|
|
62
|
-
>
|
|
63
|
-
<template #default="{ modelValue }">
|
|
64
|
-
<div class="relative px-2.5 pb-2 pt-6 w-full">
|
|
65
|
-
<span
|
|
66
|
-
aria-hidden="true"
|
|
67
|
-
class="absolute left-0 px-2.5 text-sm transition-all"
|
|
68
|
-
:class="[
|
|
69
|
-
!modelValue
|
|
70
|
-
? 'top-1/2 -translate-y-1/2'
|
|
71
|
-
: 'top-1 -translate-y-none text-xs',
|
|
72
|
-
error
|
|
73
|
-
? 'text-error group-data-[state=open]:text-error group-focus:text-error'
|
|
74
|
-
: 'group-data-[state=open]:text-primary group-focus:text-primary',
|
|
75
|
-
'absolute left-0 px-2.5 text-sm transition-all',
|
|
76
|
-
'',
|
|
77
|
-
]"
|
|
78
|
-
>
|
|
79
|
-
{{ country === 'CA' ? $t('connect.label.province') : $t('connect.label.state') }}
|
|
80
|
-
</span>
|
|
81
|
-
<div class="h-6">
|
|
82
|
-
<span
|
|
83
|
-
v-if="modelValue"
|
|
84
|
-
class="line-clamp-1 text-left"
|
|
85
|
-
>
|
|
86
|
-
{{ displayedRegionName }}
|
|
87
|
-
</span>
|
|
88
|
-
</div>
|
|
89
|
-
</div>
|
|
90
|
-
</template>
|
|
91
|
-
</USelect>
|
|
45
|
+
class="w-full grow"
|
|
46
|
+
/>
|
|
92
47
|
<ConnectInput
|
|
93
48
|
v-else
|
|
94
49
|
:id="`${parentId}-input-region`"
|
|
@@ -3,25 +3,27 @@ const {
|
|
|
3
3
|
schemaPrefix,
|
|
4
4
|
helpText = 'none',
|
|
5
5
|
country,
|
|
6
|
-
disableAddressComplete
|
|
6
|
+
disableAddressComplete,
|
|
7
|
+
parentId
|
|
7
8
|
} = defineProps<{
|
|
8
9
|
parentId: string
|
|
9
10
|
country?: string
|
|
10
11
|
schemaPrefix: string
|
|
11
12
|
disableAddressComplete?: boolean
|
|
12
13
|
helpText?: 'allow-po' | 'no-po' | 'none'
|
|
14
|
+
required?: boolean
|
|
13
15
|
}>()
|
|
14
16
|
|
|
15
|
-
const model = defineModel<string>({
|
|
17
|
+
const model = defineModel<string | undefined>({ required: true })
|
|
16
18
|
|
|
17
19
|
const emit = defineEmits<{
|
|
18
20
|
addressComplete: [value: ConnectAddress]
|
|
19
21
|
}>()
|
|
20
22
|
|
|
21
|
-
const { address: canadaPostAddress, enableAddressComplete } = useCanadaPost()
|
|
23
|
+
const { address: canadaPostAddress, enableAddressComplete, destroyAddressComplete } = useCanadaPost()
|
|
22
24
|
|
|
23
25
|
const addressComplete = (id: string) => {
|
|
24
|
-
if (!disableAddressComplete && country
|
|
26
|
+
if (!disableAddressComplete && country === 'CA') {
|
|
25
27
|
enableAddressComplete(id, country, false)
|
|
26
28
|
}
|
|
27
29
|
}
|
|
@@ -29,6 +31,17 @@ const addressComplete = (id: string) => {
|
|
|
29
31
|
watch(canadaPostAddress, (newAddress) => {
|
|
30
32
|
emit('addressComplete', newAddress)
|
|
31
33
|
})
|
|
34
|
+
|
|
35
|
+
watch(
|
|
36
|
+
() => country,
|
|
37
|
+
(v) => {
|
|
38
|
+
if (v !== 'CA') {
|
|
39
|
+
destroyAddressComplete()
|
|
40
|
+
} else if (!disableAddressComplete) {
|
|
41
|
+
enableAddressComplete(`${parentId}-input-street`, v, false)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
)
|
|
32
45
|
</script>
|
|
33
46
|
|
|
34
47
|
<template>
|
|
@@ -44,7 +57,7 @@ watch(canadaPostAddress, (newAddress) => {
|
|
|
44
57
|
: $t('connect.text.addressCanBePOBox')
|
|
45
58
|
"
|
|
46
59
|
:label="$t('connect.label.street')"
|
|
47
|
-
required
|
|
60
|
+
:required
|
|
48
61
|
@keypress.once="addressComplete(`${parentId}-input-street`)"
|
|
49
62
|
@click="addressComplete(`${parentId}-input-street`)"
|
|
50
63
|
/>
|
|
@@ -16,6 +16,7 @@ const {
|
|
|
16
16
|
excludedFields?: Array<keyof ConnectAddress>
|
|
17
17
|
disableAddressComplete?: boolean
|
|
18
18
|
streetHelpText?: 'allow-po' | 'no-po' | 'none'
|
|
19
|
+
required?: boolean
|
|
19
20
|
}>()
|
|
20
21
|
|
|
21
22
|
const state = defineModel<Partial<ConnectAddress>>({ required: true })
|
|
@@ -54,6 +55,7 @@ async function populateAddressComplete(e: ConnectAddress) {
|
|
|
54
55
|
:parent-id="id"
|
|
55
56
|
:schema-prefix="schemaPrefix"
|
|
56
57
|
:disabled="disabledFields?.includes('country')"
|
|
58
|
+
:required
|
|
57
59
|
@change="state.region = ''"
|
|
58
60
|
/>
|
|
59
61
|
|
|
@@ -66,6 +68,7 @@ async function populateAddressComplete(e: ConnectAddress) {
|
|
|
66
68
|
:disable-address-complete="disableAddressComplete"
|
|
67
69
|
:disabled="disabledFields?.includes('street')"
|
|
68
70
|
:help-text="streetHelpText"
|
|
71
|
+
:required
|
|
69
72
|
@address-complete="populateAddressComplete"
|
|
70
73
|
/>
|
|
71
74
|
|
|
@@ -84,6 +87,7 @@ async function populateAddressComplete(e: ConnectAddress) {
|
|
|
84
87
|
:parent-id="id"
|
|
85
88
|
:schema-prefix="schemaPrefix"
|
|
86
89
|
:disabled="disabledFields?.includes('city')"
|
|
90
|
+
:required
|
|
87
91
|
/>
|
|
88
92
|
|
|
89
93
|
<ConnectFormAddressRegion
|
|
@@ -93,6 +97,7 @@ async function populateAddressComplete(e: ConnectAddress) {
|
|
|
93
97
|
:schema-prefix="schemaPrefix"
|
|
94
98
|
:country="state.country"
|
|
95
99
|
:disabled="disabledFields?.includes('region')"
|
|
100
|
+
:required
|
|
96
101
|
/>
|
|
97
102
|
|
|
98
103
|
<ConnectFormAddressPostalCode
|
|
@@ -102,6 +107,7 @@ async function populateAddressComplete(e: ConnectAddress) {
|
|
|
102
107
|
:schema-prefix="schemaPrefix"
|
|
103
108
|
:country="state.country"
|
|
104
109
|
:disabled="disabledFields?.includes('postalCode')"
|
|
110
|
+
:required
|
|
105
111
|
/>
|
|
106
112
|
</div>
|
|
107
113
|
|
|
@@ -42,9 +42,8 @@ export const useCanadaPost = () => {
|
|
|
42
42
|
console.warn('AddressComplete not initialized due to missing script and/or key')
|
|
43
43
|
return
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
45
|
+
destroyAddressComplete();
|
|
46
|
+
|
|
48
47
|
(window as any).currentAddressComplete = createAddressComplete(pca, key, id, countryIso2, countrySelect)
|
|
49
48
|
}
|
|
50
49
|
|
|
@@ -60,9 +59,16 @@ export const useCanadaPost = () => {
|
|
|
60
59
|
address.unitNumber = addressComplete.SubBuilding
|
|
61
60
|
}
|
|
62
61
|
|
|
62
|
+
const destroyAddressComplete = () => {
|
|
63
|
+
if ((window as any).currentAddressComplete) {
|
|
64
|
+
(window as any).currentAddressComplete.destroy()
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
63
68
|
return {
|
|
64
69
|
activeAddressField,
|
|
65
70
|
address,
|
|
66
|
-
enableAddressComplete
|
|
71
|
+
enableAddressComplete,
|
|
72
|
+
destroyAddressComplete
|
|
67
73
|
}
|
|
68
74
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sbc-connect/nuxt-forms",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.27",
|
|
5
5
|
"repository": "github:bcgov/connect-nuxt",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "./nuxt.config.ts",
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
"nuxt": "4.1.3",
|
|
13
13
|
"typescript": "5.9.3",
|
|
14
14
|
"vue-tsc": "3.1.2",
|
|
15
|
+
"@sbc-connect/playwright-config": "0.0.8",
|
|
15
16
|
"@sbc-connect/eslint-config": "0.0.8",
|
|
16
|
-
"@sbc-connect/playwright-config": "0.0.7",
|
|
17
17
|
"@sbc-connect/vitest-config": "0.0.6"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@sbc-connect/nuxt-base": "0.1.
|
|
20
|
+
"@sbc-connect/nuxt-base": "0.1.25"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"preinstall": "npx only-allow pnpm",
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
defineProps<{ buttons: ConnectButton[], position: 'left' | 'right' }>()
|
|
3
|
-
</script>
|
|
4
|
-
|
|
5
|
-
<template>
|
|
6
|
-
<div
|
|
7
|
-
v-for="(button, i) in buttons"
|
|
8
|
-
:key="`${position}-button-` + i"
|
|
9
|
-
data-testid="button-wrapper"
|
|
10
|
-
>
|
|
11
|
-
<UButton
|
|
12
|
-
class="max-w-fit px-7 py-3 mb-1"
|
|
13
|
-
v-bind="button"
|
|
14
|
-
/>
|
|
15
|
-
<p :class="['text-center', !button.removeAlertSpacing ? 'h-[1.25rem]' : '']">
|
|
16
|
-
<span v-if="button.alertText" class="text-error">{{ button.alertText }}</span>
|
|
17
|
-
</p>
|
|
18
|
-
</div>
|
|
19
|
-
</template>
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
const buttonControl = computed(() => useRoute().meta.buttonControl as ConnectButtonControl)
|
|
3
|
-
const leftGroup = computed(() => buttonControl.value?.leftGroup || [])
|
|
4
|
-
const rightGroup = computed(() => buttonControl.value?.rightGroup || [])
|
|
5
|
-
const leftAlertText = computed(() => buttonControl.value?.leftGroup.alertText || undefined)
|
|
6
|
-
const rightAlertText = computed(() => buttonControl.value?.rightGroup.alertText || undefined)
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<template>
|
|
10
|
-
<div
|
|
11
|
-
class="@container"
|
|
12
|
-
data-testid="connect-button-control"
|
|
13
|
-
>
|
|
14
|
-
<div class="grid grid-cols-1 gap-4 @3xl:grid-cols-2">
|
|
15
|
-
<div>
|
|
16
|
-
<div
|
|
17
|
-
class="flex justify-center @3xl:justify-start"
|
|
18
|
-
data-testid="left-buttons"
|
|
19
|
-
>
|
|
20
|
-
<div
|
|
21
|
-
class="relative flex flex-col flex-wrap gap-4 justify-center"
|
|
22
|
-
:class="leftGroup.stacked ? '' : 'flex-row'"
|
|
23
|
-
>
|
|
24
|
-
<div
|
|
25
|
-
v-if="leftAlertText"
|
|
26
|
-
class="absolute flex flex-wrap justify-start bottom-1/3 right-[-13rem] w-[12rem]"
|
|
27
|
-
>
|
|
28
|
-
<p class="text-error" role="alert">
|
|
29
|
-
{{ leftAlertText }}
|
|
30
|
-
</p>
|
|
31
|
-
</div>
|
|
32
|
-
<ConnectButtonControlButtons :buttons="leftGroup.buttons" :position="'left'" />
|
|
33
|
-
</div>
|
|
34
|
-
</div>
|
|
35
|
-
</div>
|
|
36
|
-
<div>
|
|
37
|
-
<div
|
|
38
|
-
class="flex justify-center @3xl:justify-end"
|
|
39
|
-
data-testid="right-buttons"
|
|
40
|
-
>
|
|
41
|
-
<div
|
|
42
|
-
class="relative flex flex-col flex-wrap gap-4 justify-center"
|
|
43
|
-
:class="rightGroup.stacked ? '' : 'flex-row'"
|
|
44
|
-
>
|
|
45
|
-
<div
|
|
46
|
-
v-if="rightAlertText"
|
|
47
|
-
class="absolute flex flex-wrap justify-end bottom-1/3 left-[-13rem] w-[12rem]"
|
|
48
|
-
>
|
|
49
|
-
<p class="text-error" role="alert">
|
|
50
|
-
{{ rightAlertText }}
|
|
51
|
-
</p>
|
|
52
|
-
</div>
|
|
53
|
-
<ConnectButtonControlButtons :buttons="rightGroup.buttons" :position="'right'" />
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
</div>
|
|
58
|
-
</div>
|
|
59
|
-
</template>
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
export const useButtonControl = () => {
|
|
2
|
-
const route = useRoute()
|
|
3
|
-
|
|
4
|
-
function setButtonControl(buttonControl: ConnectButtonControl) {
|
|
5
|
-
// @ts-expect-error; typescript complains about the object type being too large
|
|
6
|
-
route.meta.buttonControl = buttonControl
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function getButtonControl(): ConnectButtonControl {
|
|
10
|
-
return route.meta.buttonControl as ConnectButtonControl
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function handleButtonLoading(reset: boolean, buttonGrp?: 'left' | 'right', buttonIndex?: number) {
|
|
14
|
-
// set button control for loading / disabling buttons on submit or save or reset to default
|
|
15
|
-
const updateButtonGrp = (buttonArray: ConnectButton[], grp: 'left' | 'right') => {
|
|
16
|
-
for (const [index, element] of buttonArray.entries()) {
|
|
17
|
-
if (reset) {
|
|
18
|
-
element.disabled = false
|
|
19
|
-
element.loading = false
|
|
20
|
-
} else {
|
|
21
|
-
element.loading = (grp === buttonGrp) && index === buttonIndex
|
|
22
|
-
element.disabled = !element.loading
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const buttonControl = getButtonControl()
|
|
27
|
-
// update left buttons with loading / disabled as required
|
|
28
|
-
updateButtonGrp(buttonControl.leftGroup.buttons, 'left')
|
|
29
|
-
// update right buttons with loading / disabled as required
|
|
30
|
-
updateButtonGrp(buttonControl.rightGroup.buttons, 'right')
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async function setAlertText(reset: boolean, grp?: 'left' | 'right', index?: number, text?: string) {
|
|
34
|
-
const resetButtonGrp = (buttonArray: ConnectButton[]) => {
|
|
35
|
-
for (const element of buttonArray) {
|
|
36
|
-
element.alertText = undefined
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
// clear existing text
|
|
40
|
-
if (route.meta.buttonControl) {
|
|
41
|
-
route.meta.buttonControl.leftGroup.alertText = undefined
|
|
42
|
-
route.meta.buttonControl.rightGroup.alertText = undefined
|
|
43
|
-
resetButtonGrp(route.meta.buttonControl.leftGroup.buttons)
|
|
44
|
-
resetButtonGrp(route.meta.buttonControl.rightGroup.buttons)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// only continue if not resetting
|
|
48
|
-
if (!reset) {
|
|
49
|
-
// required for dom to clear existing content
|
|
50
|
-
// allows screenreader alert for the same content if set multiple times
|
|
51
|
-
await nextTick()
|
|
52
|
-
// set content
|
|
53
|
-
if (route.meta.buttonControl) {
|
|
54
|
-
if (index === undefined) {
|
|
55
|
-
route.meta.buttonControl.leftGroup.alertText = (grp === 'left') ? text : undefined
|
|
56
|
-
route.meta.buttonControl.rightGroup.alertText = (grp === 'right') ? text : undefined
|
|
57
|
-
} else if (grp === 'left' && route.meta.buttonControl.leftGroup.buttons[index]) {
|
|
58
|
-
route.meta.buttonControl.leftGroup.buttons[index].alertText = text
|
|
59
|
-
} else if (grp === 'right' && route.meta.buttonControl.rightGroup.buttons[index]) {
|
|
60
|
-
route.meta.buttonControl.rightGroup.buttons[index].alertText = text
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
getButtonControl,
|
|
68
|
-
setButtonControl,
|
|
69
|
-
handleButtonLoading,
|
|
70
|
-
setAlertText
|
|
71
|
-
}
|
|
72
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ButtonProps } from '@nuxt/ui'
|
|
2
|
-
|
|
3
|
-
export interface ConnectButton extends ButtonProps {
|
|
4
|
-
alertText?: string
|
|
5
|
-
removeAlertSpacing?: boolean
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface ConnectButtonGroup {
|
|
9
|
-
alertText?: string
|
|
10
|
-
buttons: ConnectButton[]
|
|
11
|
-
stacked?: boolean
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface ConnectButtonControl {
|
|
15
|
-
leftGroup: ConnectButtonGroup
|
|
16
|
-
rightGroup: ConnectButtonGroup
|
|
17
|
-
}
|