@sbc-connect/nuxt-forms 0.1.25 → 0.1.26
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 +9 -0
- package/app/types/forms-page-meta.d.ts +3 -5
- package/package.json +4 -4
- 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,14 @@
|
|
|
1
1
|
# @sbc-connect/nuxt-forms
|
|
2
2
|
|
|
3
|
+
## 0.1.26
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#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
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`0615542`](https://github.com/bcgov/connect-nuxt/commit/06155422d0a8d61ee862bb3483330610b4a9434d)]:
|
|
10
|
+
- @sbc-connect/nuxt-base@0.1.24
|
|
11
|
+
|
|
3
12
|
## 0.1.25
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
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.26",
|
|
5
5
|
"repository": "github:bcgov/connect-nuxt",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "./nuxt.config.ts",
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"typescript": "5.9.3",
|
|
14
14
|
"vue-tsc": "3.1.2",
|
|
15
15
|
"@sbc-connect/eslint-config": "0.0.8",
|
|
16
|
-
"@sbc-connect/
|
|
17
|
-
"@sbc-connect/
|
|
16
|
+
"@sbc-connect/vitest-config": "0.0.6",
|
|
17
|
+
"@sbc-connect/playwright-config": "0.0.7"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@sbc-connect/nuxt-base": "0.1.
|
|
20
|
+
"@sbc-connect/nuxt-base": "0.1.24"
|
|
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
|
-
}
|