srcdev-nuxt-forms 2.1.25 → 2.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.
@@ -1,11 +1,11 @@
1
1
  <template>
2
- <div class="input-error-message" :class="[elementClasses, { show: showError }, { detached: isDetached }, { hide: !showError }]" :data-Testid>
2
+ <div class="input-error-message" :id :class="[elementClasses, { show: showError }, { detached: isDetached }, { hide: !showError }]" :data-Testid>
3
3
  <div class="inner" :class="[{ show: showError }]">
4
4
  <div class="inner-content">
5
5
  <div class="inner-icon">
6
6
  <Icon name="radix-icons:circle-backslash" class="icon" />
7
7
  </div>
8
- <div class="message" :id>
8
+ <div class="message">
9
9
  <ul v-if="isArray" class="message-list">
10
10
  <li v-for="(message, index) in errorMessage" :key="index" class="message-list-item">{{ message }}</li>
11
11
  </ul>
@@ -1,9 +1,11 @@
1
1
  <template>
2
2
  <fieldset class="multiple-checkboxes-fieldset" :class="[{ error: fieldHasError }]">
3
3
  <legend :class="[{ 'has-description': hasDescription }]">{{ legend }}</legend>
4
- <template v-if="hasDescription">
4
+
5
+ <div v-if="hasDescriptionSlot" :id="`${id}-description`">
5
6
  <slot name="description"></slot>
6
- </template>
7
+ </div>
8
+
7
9
  <div class="multiple-checkboxes-items" :class="[optionsLayout]">
8
10
  <template v-for="item in fieldData.data" :key="item.id">
9
11
  <InputCheckboxRadioButton
@@ -20,6 +22,7 @@
20
22
  :optionsLayout
21
23
  :theme
22
24
  :direction
25
+ :ariaDescribedby
23
26
  >
24
27
  <template #checkedIcon>
25
28
  <slot name="checkedIcon"></slot>
@@ -43,6 +46,7 @@
43
46
  :size
44
47
  :optionsLayout
45
48
  :theme
49
+ :ariaDescribedby
46
50
  >
47
51
  <template #checkedIcon>
48
52
  <slot name="checkedIcon"></slot>
@@ -50,7 +54,7 @@
50
54
  </InputCheckboxRadioWithLabel>
51
55
  </template>
52
56
  </div>
53
- <InputError :errorMessage="errorMessage" :showError="fieldHasError" :id="name" :isDetached="true" />
57
+ <InputError :errorMessage="errorMessage" :showError="fieldHasError" :id="errorId" :isDetached="true" />
54
58
  </fieldset>
55
59
  </template>
56
60
 
@@ -138,11 +142,18 @@ const { id, name, legend, label, required, fieldHasError, placeholder, isButton,
138
142
  });
139
143
 
140
144
  const slots = useSlots();
145
+ const hasDescriptionSlot = computed(() => slots.description !== undefined);
141
146
  const hasDescription = computed(() => slots.description !== undefined);
142
147
  const { elementClasses, updateElementClasses } = useStyleClassPassthrough(styleClassPassthrough);
143
148
 
144
149
  const modelValue = defineModel();
145
150
  const fieldData = defineModel('fieldData') as Ref<IFormMultipleOptions>;
151
+
152
+ const errorId = `${name}-error-message`;
153
+ const ariaDescribedby = computed(() => {
154
+ const ariaDescribedbyId = hasDescriptionSlot.value ? `${name}-description` : null;
155
+ return fieldHasError ? errorId : ariaDescribedbyId;
156
+ });
146
157
  </script>
147
158
 
148
159
  <style lang="css">
@@ -1,11 +1,13 @@
1
1
  <template>
2
2
  <fieldset class="single-checkbox-fieldset" :class="[{ error: fieldHasError }]">
3
3
  <legend :class="[{ 'has-description': hasDescription }]">{{ legend }}</legend>
4
- <template v-if="hasDescription">
4
+
5
+ <div v-if="hasDescriptionSlot" :id="`${name}-description`">
5
6
  <slot name="description"></slot>
6
- </template>
7
+ </div>
8
+
7
9
  <div class="single-checkbox-items" :class="[optionsLayout]">
8
- <InputCheckboxRadioWithLabel type="checkbox" :id :name :required :label :fieldHasError v-model="modelValue" :trueValue :falseValue :size :theme>
10
+ <InputCheckboxRadioWithLabel type="checkbox" :id :name :required :label :fieldHasError v-model="modelValue" :trueValue :falseValue :size :theme :ariaDescribedby>
9
11
  <template #checkedIcon>
10
12
  <slot name="checkedIcon"></slot>
11
13
  </template>
@@ -14,7 +16,7 @@
14
16
  </template>
15
17
  </InputCheckboxRadioWithLabel>
16
18
  </div>
17
- <InputError :errorMessage :showError="fieldHasError" :id="name" :isDetached="true" :styleClassPassthrough="inputErrorStyles" />
19
+ <InputError :errorMessage :showError="fieldHasError" :id="errorId" :isDetached="true" :styleClassPassthrough="inputErrorStyles" />
18
20
  </fieldset>
19
21
  </template>
20
22
 
@@ -96,6 +98,7 @@ const { id, name, legend, label, required, fieldHasError, errorMessage, size, op
96
98
  });
97
99
 
98
100
  const slots = useSlots();
101
+ const hasDescriptionSlot = computed(() => slots.description !== undefined);
99
102
  const hasDescription = computed(() => slots.description !== undefined);
100
103
  const hasLabelContent = computed(() => slots.labelContent !== undefined);
101
104
 
@@ -106,6 +109,12 @@ const fieldData = defineModel('fieldData') as Ref<IFormMultipleOptions>;
106
109
 
107
110
  const inputErrorStyles = ref<string[]>(styleClassPassthrough);
108
111
 
112
+ const errorId = `${name}-error-message`;
113
+ const ariaDescribedby = computed(() => {
114
+ const ariaDescribedbyId = hasDescriptionSlot.value ? `${name}-description` : null;
115
+ return fieldHasError ? errorId : ariaDescribedbyId;
116
+ });
117
+
109
118
  watchEffect(() => {
110
119
  if (!hasDescription.value && fieldHasError) {
111
120
  inputErrorStyles.value.push('mbs-12');
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div class="input-checkbox-radio-button-button" :data-form-theme="formTheme" :class="[size, elementClasses, optionsLayout, { error: fieldHasError }]">
3
- <InputCheckboxRadioCore :isButton="true" :type :id :name :required v-model="modelValue" :size :trueValue :falseValue :fieldHasError :theme>
3
+ <InputCheckboxRadioCore :isButton="true" :type :id :name :required v-model="modelValue" :size :trueValue :falseValue :fieldHasError :theme :ariaDescribedby>
4
4
  <template #checkedIcon>
5
5
  <slot name="checkedIcon"></slot>
6
6
  </template>
@@ -20,7 +20,7 @@
20
20
  <script setup lang="ts">
21
21
  import propValidators from '../c12/prop-validators';
22
22
 
23
- const { type, id, name, label, required, fieldHasError, trueValue, falseValue, size, optionsLayout, styleClassPassthrough, theme, direction } = defineProps({
23
+ const { type, id, name, label, required, fieldHasError, trueValue, falseValue, size, optionsLayout, styleClassPassthrough, theme, direction, ariaDescribedby } = defineProps({
24
24
  type: {
25
25
  type: String as PropType<'checkbox' | 'radio'>,
26
26
  required: true,
@@ -85,6 +85,10 @@ const { type, id, name, label, required, fieldHasError, trueValue, falseValue, s
85
85
  return ['row', 'row-reverse'].includes(value);
86
86
  },
87
87
  },
88
+ ariaDescribedby: {
89
+ type: String,
90
+ default: null,
91
+ },
88
92
  });
89
93
 
90
94
  const slots = useSlots();
@@ -17,13 +17,14 @@
17
17
  v-model="modelValue"
18
18
  ref="inputField"
19
19
  :aria-checked="isChecked"
20
+ :aria-describedby
20
21
  />
21
22
  </div>
22
23
  </template>
23
24
 
24
25
  <script setup lang="ts">
25
26
  import propValidators from '../c12/prop-validators';
26
- const { isButton, type, id, name, required, trueValue, falseValue, multipleOptions, theme, styleClassPassthrough, size, fieldHasError } = defineProps({
27
+ const { isButton, type, id, name, required, trueValue, falseValue, multipleOptions, theme, styleClassPassthrough, size, fieldHasError, ariaDescribedby } = defineProps({
27
28
  isButton: {
28
29
  type: Boolean,
29
30
  default: false,
@@ -78,6 +79,10 @@ const { isButton, type, id, name, required, trueValue, falseValue, multipleOptio
78
79
  type: Array as PropType<string[]>,
79
80
  default: () => [],
80
81
  },
82
+ ariaDescribedby: {
83
+ type: String,
84
+ default: null,
85
+ },
81
86
  });
82
87
 
83
88
  const { elementClasses, updateElementClasses } = useStyleClassPassthrough(styleClassPassthrough);
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div class="input-checkbox-radio-with-label" :class="[elementClasses, optionsLayout, { error: fieldHasError }]">
3
- <InputCheckboxRadioCore :type :id :name :required v-model="modelValue" :size :trueValue :falseValue :fieldHasError :theme>
3
+ <InputCheckboxRadioCore :type :id :name :required v-model="modelValue" :size :trueValue :falseValue :fieldHasError :theme :ariaDescribedby>
4
4
  <template #checkedIcon>
5
5
  <slot name="checkedIcon"></slot>
6
6
  </template>
@@ -15,7 +15,7 @@
15
15
  <script setup lang="ts">
16
16
  import propValidators from '../c12/prop-validators';
17
17
 
18
- const { type, id, name, label, required, fieldHasError, trueValue, falseValue, size, optionsLayout, styleClassPassthrough, theme } = defineProps({
18
+ const { type, id, name, label, required, fieldHasError, trueValue, falseValue, size, optionsLayout, styleClassPassthrough, theme, ariaDescribedby } = defineProps({
19
19
  type: {
20
20
  type: String as PropType<'checkbox' | 'radio'>,
21
21
  required: true,
@@ -73,6 +73,10 @@ const { type, id, name, label, required, fieldHasError, trueValue, falseValue, s
73
73
  return propValidators.theme.includes(value);
74
74
  },
75
75
  },
76
+ ariaDescribedby: {
77
+ type: String,
78
+ default: null,
79
+ },
76
80
  });
77
81
 
78
82
  const slots = useSlots();
@@ -1,9 +1,11 @@
1
1
  <template>
2
2
  <fieldset :aria-required="required" :aria-invalid="fieldHasError" role="radiogroup" class="multiple-radiobuttons-fieldset" :class="[{ error: fieldHasError }]">
3
- <legend :class="[{ 'has-description': hasDescription }]">{{ legend }}</legend>
4
- <template v-if="hasDescription">
3
+ <legend :class="[{ 'has-description': hasDescriptionSlot }]">{{ legend }}</legend>
4
+
5
+ <div v-if="hasDescriptionSlot" :id="`${name}-description`">
5
6
  <slot name="description"></slot>
6
- </template>
7
+ </div>
8
+
7
9
  <div class="multiple-radiobuttons-items" :class="[optionsLayout]">
8
10
  <template v-for="item in fieldData.data" :key="item.id">
9
11
  <InputCheckboxRadioButton
@@ -20,6 +22,7 @@
20
22
  :optionsLayout
21
23
  :theme
22
24
  :direction
25
+ :ariaDescribedby
23
26
  >
24
27
  <template #checkedIcon>
25
28
  <slot name="checkedIcon"></slot>
@@ -43,6 +46,7 @@
43
46
  :size
44
47
  :optionsLayout
45
48
  :theme
49
+ :ariaDescribedby
46
50
  >
47
51
  <template #checkedIcon>
48
52
  <slot name="checkedIcon"></slot>
@@ -50,12 +54,12 @@
50
54
  </InputCheckboxRadioWithLabel>
51
55
  </template>
52
56
  </div>
53
- <InputError :errorMessage="errorMessage" :showError="fieldHasError" :id="name" :isDetached="true" />
57
+ <InputError :errorMessage="errorMessage" :showError="fieldHasError" :id="errorId" :isDetached="true" />
54
58
  </fieldset>
55
59
  </template>
56
60
 
57
61
  <script setup lang="ts">
58
- import propValidators from '../../c12/prop-validators';
62
+ import propValidators from '../c12/prop-validators';
59
63
  import type { IFormMultipleOptions } from '@/types/types.forms';
60
64
 
61
65
  const { id, name, legend, label, required, fieldHasError, placeholder, isButton, errorMessage, size, optionsLayout, equalCols, styleClassPassthrough, theme, direction } = defineProps({
@@ -138,9 +142,15 @@ const { id, name, legend, label, required, fieldHasError, placeholder, isButton,
138
142
  });
139
143
 
140
144
  const slots = useSlots();
141
- const hasDescription = computed(() => slots.description !== undefined);
145
+ const hasDescriptionSlot = computed(() => slots.description !== undefined);
142
146
  const { elementClasses, updateElementClasses } = useStyleClassPassthrough(styleClassPassthrough);
143
147
 
148
+ const errorId = `${name}-error-message`;
149
+ const ariaDescribedby = computed(() => {
150
+ const ariaDescribedbyId = hasDescriptionSlot.value ? `${id}-description` : null;
151
+ return fieldHasError ? errorId : ariaDescribedbyId;
152
+ });
153
+
144
154
  const modelValue = defineModel();
145
155
  const fieldData = defineModel('fieldData') as Ref<IFormMultipleOptions>;
146
156
  </script>
@@ -0,0 +1,8 @@
1
+ import { Meta, Canvas, Controls } from '@storybook/blocks';
2
+ import * as MultipleRadiobuttonsStories from './MultipleRadiobuttons.stories'
3
+
4
+ <Meta of={MultipleRadiobuttonsStories} />
5
+
6
+ <Canvas of={MultipleRadiobuttonsStories.Primary} />
7
+
8
+ <Controls of={MultipleRadiobuttonsStories.Primary} />
@@ -0,0 +1,71 @@
1
+ import type { Meta, StoryFn } from '@nuxtjs/storybook';
2
+ import MultipleRadiobuttons from '../MultipleRadiobuttons.vue';
3
+ import propValidators from '../../c12/prop-validators';
4
+ import modelData from './data/tags.json';
5
+
6
+ export default {
7
+ title: 'Components/Forms/MultipleRadiobuttons',
8
+ component: MultipleRadiobuttons,
9
+ argTypes: {
10
+ size: {
11
+ options: propValidators.size,
12
+ control: { type: 'select' },
13
+ },
14
+ weight: {
15
+ options: propValidators.weight,
16
+ control: { type: 'select' },
17
+ },
18
+ theme: {
19
+ options: propValidators.theme,
20
+ control: { type: 'select' },
21
+ default: 'primary',
22
+ },
23
+ optionsLayout: {
24
+ options: ['inline', 'equal-widths'],
25
+ control: { type: 'select' },
26
+ },
27
+ direction: {
28
+ options: ['row', 'row-reverse'],
29
+ control: { type: 'select' },
30
+ },
31
+ },
32
+ } as Meta<typeof MultipleRadiobuttons>;
33
+
34
+ const Template: StoryFn<typeof MultipleRadiobuttons> = (args) => ({
35
+ components: { MultipleRadiobuttons },
36
+ setup() {
37
+ return { args };
38
+ },
39
+ template: `
40
+ <Suspense>
41
+ <template #default>
42
+ <MultipleRadiobuttons v-bind="args">
43
+ <template v-if="${'description' in args}" v-slot:description>${args.description}</template>
44
+ </MultipleRadiobuttons>
45
+ </template>
46
+ <template #fallback>
47
+ <div>Loading...</div>
48
+ </template>
49
+ </Suspense>
50
+ `,
51
+ // template: '<MultipleRadiobuttons v-bind="args" />',
52
+ });
53
+
54
+ export const Primary = Template.bind({});
55
+ Primary.args = {
56
+ id: 'tagsRadio',
57
+ name: 'tagsRadio',
58
+ legend: 'Choose tags (as radiobuttons)',
59
+ required: true,
60
+ label: 'Check between 3 and 8 tags',
61
+ placeholder: 'eg. Type something here',
62
+ isButton: true,
63
+ errorMessage: 'Please select between 3 and 8 tags',
64
+ fieldHasError: false,
65
+ modelValue: [],
66
+ fieldData: modelData,
67
+ size: 'x-small',
68
+ optionsLayout: 'inline',
69
+ theme: 'primary',
70
+ direction: 'row',
71
+ };
@@ -0,0 +1,67 @@
1
+ {
2
+ "data": [
3
+ {
4
+ "id": "pizza",
5
+ "name": "tags",
6
+ "value": "pizza",
7
+ "label": "Pizza"
8
+ },
9
+ {
10
+ "id": "italian",
11
+ "name": "tags",
12
+ "value": "italian",
13
+ "label": "Italian"
14
+ },
15
+ {
16
+ "id": "vegetarian",
17
+ "name": "tags",
18
+ "value": "vegetarian",
19
+ "label": "Vegetarian"
20
+ },
21
+ {
22
+ "id": "stir-fry",
23
+ "name": "tags",
24
+ "value": "stir-fry",
25
+ "label": "Stir-fry"
26
+ },
27
+ {
28
+ "id": "asian",
29
+ "name": "tags",
30
+ "value": "asian",
31
+ "label": "Asian"
32
+ },
33
+ {
34
+ "id": "cookies",
35
+ "name": "tags",
36
+ "value": "cookies",
37
+ "label": "Cookies"
38
+ },
39
+ {
40
+ "id": "dessert",
41
+ "name": "tags",
42
+ "value": "dessert",
43
+ "label": "Dessert"
44
+ },
45
+ {
46
+ "id": "baking",
47
+ "name": "tags",
48
+ "value": "baking",
49
+ "label": "Baking"
50
+ },
51
+ {
52
+ "id": "pasta",
53
+ "name": "tags",
54
+ "value": "pasta",
55
+ "label": "Pasta"
56
+ },
57
+ {
58
+ "id": "chicken",
59
+ "name": "tags",
60
+ "value": "chicken",
61
+ "label": "Chicken"
62
+ }
63
+ ],
64
+ "total": 5,
65
+ "skip": 0,
66
+ "limit": 10
67
+ }
@@ -19,7 +19,7 @@
19
19
  v-model="modelValue"
20
20
  ref="inputField"
21
21
  :aria-invalid="fieldHasError"
22
- :ariaDescribedby
22
+ :aria-describedby
23
23
  :pattern="inputPattern"
24
24
  :inputmode
25
25
  @focusin="updateFocus(true)"
@@ -130,8 +130,8 @@ const formTheme = computed(() => {
130
130
 
131
131
  const errorId = `${id}-error-message`;
132
132
  const ariaDescribedby = computed(() => {
133
- const ariaDescribedby = hasDescriptionSlot ? `${id}-description` : null;
134
- return fieldHasError ? errorId : ariaDescribedby;
133
+ const ariaDescribedbyId = hasDescriptionSlot.value ? `${id}-description` : null;
134
+ return fieldHasError ? errorId : ariaDescribedbyId;
135
135
  });
136
136
 
137
137
  const modelValue = defineModel();
@@ -31,7 +31,7 @@
31
31
  <slot name="right"></slot>
32
32
  </template>
33
33
  </InputTextCore>
34
- <InputError :errorMessage="errorMessage" :showError="fieldHasError" :id="`${id}-error-message`" :isDetached="false" />
34
+ <InputError :errorMessage="errorMessage" :showError="fieldHasError" :id="errorId" :isDetached="false" />
35
35
  </div>
36
36
  </template>
37
37
 
@@ -105,8 +105,8 @@ const formTheme = computed(() => {
105
105
 
106
106
  const errorId = `${id}-error-message`;
107
107
  const ariaDescribedby = computed(() => {
108
- const ariaDescribedby = hasDescriptionSlot ? `${id}-description` : null;
109
- return fieldHasError ? errorId : ariaDescribedby;
108
+ const ariaDescribedbyId = hasDescriptionSlot.value ? `${id}-description` : null;
109
+ return fieldHasError ? errorId : ariaDescribedbyId;
110
110
  });
111
111
 
112
112
  const modelValue = defineModel();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "srcdev-nuxt-forms",
3
3
  "type": "module",
4
- "version": "2.1.25",
4
+ "version": "2.1.27",
5
5
  "main": "nuxt.config.ts",
6
6
  "scripts": {
7
7
  "clean": "rm -rf .nuxt && rm -rf .output && rm -rf .playground/.nuxt && rm -rf .playground/.output",
@@ -25,7 +25,7 @@
25
25
  "devDependencies": {
26
26
  "@iconify-json/material-symbols": "1.2.10",
27
27
  "@nuxt/eslint-config": "0.7.2",
28
- "@nuxt/icon": "1.9.1",
28
+ "@nuxt/icon": "^1.10.1",
29
29
  "@nuxt/test-utils": "3.15.1",
30
30
  "@vue/test-utils": "2.4.6",
31
31
  "eslint": "9.16.0",
@@ -34,7 +34,8 @@
34
34
  "release-it": "17.10.0",
35
35
  "typescript": "5.7.2",
36
36
  "vitest": "2.1.8",
37
- "vue": "3.5.13"
37
+ "vue": "3.5.13",
38
+ "zod": "^3.24.1"
38
39
  },
39
40
  "dependencies": {
40
41
  "@iconify-json/carbon": "1.2.4",
@@ -47,8 +48,7 @@
47
48
  "@storybook/addon-links": "8.4.6",
48
49
  "@storybook/vue3": "8.4.6",
49
50
  "http-proxy-middleware": "3.0.3",
50
- "modern-normalize": "3.0.1",
51
- "zod": "3.23.8"
51
+ "modern-normalize": "3.0.1"
52
52
  },
53
53
  "release-it": {
54
54
  "$schema": "https://unpkg.com/release-it/schema/release-it.json",