@sbc-connect/nuxt-forms 0.1.24 → 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 CHANGED
@@ -1,5 +1,25 @@
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
+
12
+ ## 0.1.25
13
+
14
+ ### Patch Changes
15
+
16
+ - [#77](https://github.com/bcgov/connect-nuxt/pull/77) [`86ec3d0`](https://github.com/bcgov/connect-nuxt/commit/86ec3d03baa7dae3137f6c4c96a328f13eb46ce5) Thanks [@deetz99](https://github.com/deetz99)! - fix: update SbcCountrySubdivision type name to ConnectCountrySubdivision
17
+
18
+ - [#77](https://github.com/bcgov/connect-nuxt/pull/77) [`86ec3d0`](https://github.com/bcgov/connect-nuxt/commit/86ec3d03baa7dae3137f6c4c96a328f13eb46ce5) Thanks [@deetz99](https://github.com/deetz99)! - Update dependencies
19
+
20
+ - Updated dependencies [[`86ec3d0`](https://github.com/bcgov/connect-nuxt/commit/86ec3d03baa7dae3137f6c4c96a328f13eb46ce5), [`86ec3d0`](https://github.com/bcgov/connect-nuxt/commit/86ec3d03baa7dae3137f6c4c96a328f13eb46ce5), [`86ec3d0`](https://github.com/bcgov/connect-nuxt/commit/86ec3d03baa7dae3137f6c4c96a328f13eb46ce5)]:
21
+ - @sbc-connect/nuxt-base@0.1.23
22
+
3
23
  ## 0.1.24
4
24
 
5
25
  ### Patch Changes
@@ -1,7 +1,5 @@
1
- declare module '#app' {
2
- interface PageMeta {
3
- buttonControl?: ConnectButtonControl
4
- }
5
- }
1
+ // declare module '#app' {
2
+ // interface PageMeta {}
3
+ // }
6
4
 
7
5
  export {}
@@ -1,4 +1,4 @@
1
- type SbcCountrySubdivision = {
1
+ type ConnectCountrySubdivision = {
2
2
  code: string
3
3
  name: string
4
4
  }
@@ -1941,7 +1941,7 @@ export const isoCountriesList: Array<Iso3166_1Country> = [
1941
1941
  ]
1942
1942
 
1943
1943
  // canada
1944
- const subdivisionsCa: SbcCountrySubdivision[] = [
1944
+ const subdivisionsCa: ConnectCountrySubdivision[] = [
1945
1945
  { code: 'AB', name: 'Alberta' },
1946
1946
  { code: 'BC', name: 'British Columbia' },
1947
1947
  { code: 'MB', name: 'Manitoba' },
@@ -1958,7 +1958,7 @@ const subdivisionsCa: SbcCountrySubdivision[] = [
1958
1958
  ]
1959
1959
 
1960
1960
  // us
1961
- const subdivisionsUs: SbcCountrySubdivision[] = [
1961
+ const subdivisionsUs: ConnectCountrySubdivision[] = [
1962
1962
  { name: 'Alabama', code: 'AL' },
1963
1963
  { name: 'Alaska', code: 'AK' },
1964
1964
  { name: 'American Samoa', code: 'AS' },
package/package.json CHANGED
@@ -1,24 +1,23 @@
1
1
  {
2
2
  "name": "@sbc-connect/nuxt-forms",
3
3
  "type": "module",
4
- "version": "0.1.24",
4
+ "version": "0.1.26",
5
5
  "repository": "github:bcgov/connect-nuxt",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "./nuxt.config.ts",
8
8
  "devDependencies": {
9
- "@axe-core/playwright": "^4.10.2",
10
- "@vitest/coverage-v8": "^3.2.4",
11
- "dotenv": "^17.2.1",
12
- "nuxt": "^4.0.2",
13
- "typescript": "^5.8.3",
14
- "vue-tsc": "^3.0.4",
15
- "@sbc-connect/eslint-config": "0.0.7",
16
- "@sbc-connect/playwright-config": "0.0.7",
17
- "@sbc-connect/vitest-config": "0.0.6"
9
+ "@axe-core/playwright": "4.11.0",
10
+ "@vitest/coverage-v8": "3.2.4",
11
+ "dotenv": "17.2.3",
12
+ "nuxt": "4.1.3",
13
+ "typescript": "5.9.3",
14
+ "vue-tsc": "3.1.2",
15
+ "@sbc-connect/eslint-config": "0.0.8",
16
+ "@sbc-connect/vitest-config": "0.0.6",
17
+ "@sbc-connect/playwright-config": "0.0.7"
18
18
  },
19
19
  "dependencies": {
20
- "zod": "^4.0.17",
21
- "@sbc-connect/nuxt-base": "0.1.22"
20
+ "@sbc-connect/nuxt-base": "0.1.24"
22
21
  },
23
22
  "scripts": {
24
23
  "preinstall": "npx only-allow pnpm",
@@ -32,6 +31,7 @@
32
31
  "test": "pnpm run test:unit; pnpm run test:e2e",
33
32
  "test:unit": "vitest run --passWithNoTests",
34
33
  "test:unit:watch": "vitest",
34
+ "test:unit:cov": "vitest --dir tests/unit --coverage",
35
35
  "test:e2e": "npx playwright test",
36
36
  "test:e2e:ui": "npx playwright test --ui",
37
37
  "typecheck": "npx nuxt typecheck"
@@ -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,10 +0,0 @@
1
- <template>
2
- <div
3
- class="bg-shade-inverted pb-6 pt-10"
4
- data-testid="connect-button-control-wrapper"
5
- >
6
- <div class="app-inner-container app-body">
7
- <ConnectButtonControl />
8
- </div>
9
- </div>
10
- </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
- }