@sbc-connect/nuxt-forms 0.1.26 → 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 +11 -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/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
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
|
+
|
|
3
14
|
## 0.1.26
|
|
4
15
|
|
|
5
16
|
### 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/vitest-config": "0.0.6"
|
|
17
|
-
"@sbc-connect/playwright-config": "0.0.7"
|
|
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",
|