@sbc-connect/nuxt-forms 0.1.7 → 0.1.9
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/.env.example +10 -0
- package/CHANGELOG.md +15 -0
- package/app/components/Connect/ButtonControl/Buttons.vue +19 -0
- package/app/components/Connect/ButtonControl/Index.vue +59 -0
- package/app/components/Connect/ButtonControl/Wrapper.vue +10 -0
- package/app/components/Connect/Layout/Form.vue +22 -0
- package/app/components/HelloWorld/Forms.vue +2 -2
- package/app/composables/useButtonControl.ts +72 -0
- package/app/interfaces/connect-button-control.ts +17 -0
- package/app/layouts/ConnectForm.vue +5 -0
- package/app/types/forms-page-meta.d.ts +7 -0
- package/i18n/locales/en-CA.ts +3 -0
- package/i18n/locales/fr-CA.ts +3 -0
- package/modules/form-assets/index.ts +15 -0
- package/modules/form-assets/runtime/assets/connect-form-tw.css +2 -0
- package/nuxt.config.ts +23 -2
- package/package.json +5 -5
- package/app/assets/css/tw-forms.css +0 -2
package/.env.example
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
+
# Web Urls
|
|
1
2
|
NUXT_PUBLIC_BASE_URL="http://localhost:3000/"
|
|
3
|
+
NUXT_PUBLIC_REGISTRY_HOME_URL="https://dev.bcregistry.gov.bc.ca/"
|
|
4
|
+
|
|
5
|
+
# API Urls
|
|
6
|
+
# Status API
|
|
7
|
+
NUXT_PUBLIC_STATUS_API_URL="https://status-api-dev.apps.gold.devops.gov.bc.ca"
|
|
8
|
+
NUXT_PUBLIC_STATUS_API_VERSION="/api/v1"
|
|
9
|
+
|
|
10
|
+
# LaunchDarkly
|
|
11
|
+
NUXT_PUBLIC_LD_CLIENT_ID=""
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @sbc-connect/nuxt-forms
|
|
2
2
|
|
|
3
|
+
## 0.1.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#37](https://github.com/bcgov/connect-nuxt/pull/37) [`216dff5`](https://github.com/bcgov/connect-nuxt/commit/216dff5eea1cf8459fc516dc8a1985f922e84533) Thanks [@kialj876](https://github.com/kialj876)! - Button Control Component and Form Layout bcgov/entity/29338
|
|
8
|
+
|
|
9
|
+
## 0.1.8
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#32](https://github.com/bcgov/connect-nuxt/pull/32) [`66d83d1`](https://github.com/bcgov/connect-nuxt/commit/66d83d14b2ec7950057dd39a4d876a8c4096923f) Thanks [@kialj876](https://github.com/kialj876)! - Pay layer cleanup bcgov/entity#29337
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`66d83d1`](https://github.com/bcgov/connect-nuxt/commit/66d83d14b2ec7950057dd39a4d876a8c4096923f)]:
|
|
16
|
+
- @sbc-connect/nuxt-base@0.1.8
|
|
17
|
+
|
|
3
18
|
## 0.1.7
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -0,0 +1,19 @@
|
|
|
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>
|
|
@@ -0,0 +1,59 @@
|
|
|
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>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<ConnectLayout>
|
|
3
|
+
<template #header>
|
|
4
|
+
<!-- Exposes the header slot of the base layout -->
|
|
5
|
+
<slot name="header">
|
|
6
|
+
<ConnectHeader />
|
|
7
|
+
</slot>
|
|
8
|
+
</template>
|
|
9
|
+
<template #body>
|
|
10
|
+
<!-- Exposes the body slot of the base layout -->
|
|
11
|
+
<slot name="body">
|
|
12
|
+
<div class="grow max-w-full overflow-hidden">
|
|
13
|
+
<slot />
|
|
14
|
+
</div>
|
|
15
|
+
</slot>
|
|
16
|
+
</template>
|
|
17
|
+
<template #footer>
|
|
18
|
+
<ConnectButtonControlWrapper />
|
|
19
|
+
<ConnectFooter />
|
|
20
|
+
</template>
|
|
21
|
+
</ConnectLayout>
|
|
22
|
+
</template>
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineNuxtModule, createResolver } from 'nuxt/kit'
|
|
2
|
+
|
|
3
|
+
export default defineNuxtModule({
|
|
4
|
+
meta: {
|
|
5
|
+
name: 'form-assets',
|
|
6
|
+
configKey: 'formAssets'
|
|
7
|
+
},
|
|
8
|
+
defaults: {},
|
|
9
|
+
async setup(_options, _nuxt) {
|
|
10
|
+
console.info('Setting up **form** assets module')
|
|
11
|
+
const resolver = createResolver(import.meta.url)
|
|
12
|
+
|
|
13
|
+
_nuxt.options.css.push(resolver.resolve('./runtime/assets/connect-form-tw.css'))
|
|
14
|
+
}
|
|
15
|
+
})
|
package/nuxt.config.ts
CHANGED
|
@@ -8,7 +8,11 @@ export default defineNuxtConfig({
|
|
|
8
8
|
|
|
9
9
|
devtools: { enabled: false },
|
|
10
10
|
|
|
11
|
-
compatibilityDate: '2025-
|
|
11
|
+
compatibilityDate: '2025-07-10',
|
|
12
|
+
|
|
13
|
+
imports: {
|
|
14
|
+
dirs: ['enums', 'interfaces', 'types']
|
|
15
|
+
},
|
|
12
16
|
|
|
13
17
|
extends: ['@sbc-connect/nuxt-base'],
|
|
14
18
|
|
|
@@ -16,5 +20,22 @@ export default defineNuxtConfig({
|
|
|
16
20
|
'#forms': resolve('./')
|
|
17
21
|
},
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
i18n: {
|
|
24
|
+
locales: [
|
|
25
|
+
{
|
|
26
|
+
name: 'English',
|
|
27
|
+
code: 'en-CA',
|
|
28
|
+
language: 'en-CA',
|
|
29
|
+
dir: 'ltr',
|
|
30
|
+
file: 'en-CA.ts'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'Français',
|
|
34
|
+
code: 'fr-CA',
|
|
35
|
+
language: 'fr-CA',
|
|
36
|
+
dir: 'ltr',
|
|
37
|
+
file: 'fr-CA.ts'
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
20
41
|
})
|
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.9",
|
|
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.0.2",
|
|
13
13
|
"typescript": "^5.8.3",
|
|
14
14
|
"vue-tsc": "^3.0.4",
|
|
15
|
-
"@sbc-connect/
|
|
16
|
-
"@sbc-connect/
|
|
17
|
-
"@sbc-connect/
|
|
15
|
+
"@sbc-connect/playwright-config": "0.0.6",
|
|
16
|
+
"@sbc-connect/vitest-config": "0.0.6",
|
|
17
|
+
"@sbc-connect/eslint-config": "0.0.6"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@sbc-connect/nuxt-base": "0.1.
|
|
20
|
+
"@sbc-connect/nuxt-base": "0.1.8"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"preinstall": "npx only-allow pnpm",
|