From 827eddd6b34e0119e895e6c88cb1452118964b25 Mon Sep 17 00:00:00 2001 From: Maksim Nedoshev Date: Sat, 8 Jul 2023 20:19:39 +0300 Subject: [PATCH 1/3] raw --- packages/docs/modules/vuestic.ts | 6 +- .../radio/examples/ComplexOptions.vue | 28 ++++++++ .../ui-elements/radio/examples/Default.vue | 14 ++-- .../ui-elements/radio/examples/Options.vue | 16 +++++ .../ui-elements/radio/examples/Validation.vue | 30 ++++++++ .../page-config/ui-elements/radio/index.ts | 13 ++++ packages/ui/src/components/index.ts | 11 +-- .../ui/src/components/va-radio/VaRadio.vue | 71 +++++++++++++++---- packages/ui/src/components/va-radio/types.ts | 5 +- 9 files changed, 164 insertions(+), 30 deletions(-) create mode 100644 packages/docs/page-config/ui-elements/radio/examples/ComplexOptions.vue create mode 100644 packages/docs/page-config/ui-elements/radio/examples/Options.vue create mode 100644 packages/docs/page-config/ui-elements/radio/examples/Validation.vue diff --git a/packages/docs/modules/vuestic.ts b/packages/docs/modules/vuestic.ts index c05ab0dadb..b05f70fcb6 100644 --- a/packages/docs/modules/vuestic.ts +++ b/packages/docs/modules/vuestic.ts @@ -23,8 +23,10 @@ export default defineNuxtModule({ }, setup (options, nuxt) { - // Fix CSS variables made by v-bind in component: they're not rendered in cjs (SSG). - addVitePlugin(componentVBindFix({ sourcemap: false })) + if (!nuxt.options.dev) { + // Fix CSS variables made by v-bind in component: they're not rendered in cjs (SSG). + addVitePlugin(componentVBindFix({ sourcemap: false })) + } nuxt.options.alias['@vuestic/ag-grid-theme'] = resolve(__dirname, '../../ag-grid-theme/src/styles/index.scss'); nuxt.options.alias['vuestic-ui/styles/typography.css'] = resolve(__dirname, '../../ui/src/styles/typography/typography.scss'); diff --git a/packages/docs/page-config/ui-elements/radio/examples/ComplexOptions.vue b/packages/docs/page-config/ui-elements/radio/examples/ComplexOptions.vue new file mode 100644 index 0000000000..81723d1e15 --- /dev/null +++ b/packages/docs/page-config/ui-elements/radio/examples/ComplexOptions.vue @@ -0,0 +1,28 @@ + + + diff --git a/packages/docs/page-config/ui-elements/radio/examples/Default.vue b/packages/docs/page-config/ui-elements/radio/examples/Default.vue index a44231ece1..5dab7a15da 100644 --- a/packages/docs/page-config/ui-elements/radio/examples/Default.vue +++ b/packages/docs/page-config/ui-elements/radio/examples/Default.vue @@ -1,18 +1,22 @@ diff --git a/packages/docs/page-config/ui-elements/radio/examples/Validation.vue b/packages/docs/page-config/ui-elements/radio/examples/Validation.vue new file mode 100644 index 0000000000..d782bad810 --- /dev/null +++ b/packages/docs/page-config/ui-elements/radio/examples/Validation.vue @@ -0,0 +1,30 @@ + + + diff --git a/packages/docs/page-config/ui-elements/radio/index.ts b/packages/docs/page-config/ui-elements/radio/index.ts index 819a672848..a825da3d6b 100644 --- a/packages/docs/page-config/ui-elements/radio/index.ts +++ b/packages/docs/page-config/ui-elements/radio/index.ts @@ -12,6 +12,19 @@ export default definePageConfig({ title: "Default", description: "Default usage of the `va-radio` component." }), + + block.example("Options", { + title: "Multiple Options", + description: "You can use `options` prop to pass an array of options to the component. Then multiple components will be rendered." + }), + + block.example("ComplexOptions", { + description: "You can use more complex options with `textBy` and `valueBy` props if needed." + }), + block.example("Validation", { + description: "Passing multiple `options` at the same time allows you to use validation `rules`.", + }), + block.example("Color", { title: "Colors", description: "With `color` prop you can change the color of the component." diff --git a/packages/ui/src/components/index.ts b/packages/ui/src/components/index.ts index 0b5b94091f..c247b1e0b0 100644 --- a/packages/ui/src/components/index.ts +++ b/packages/ui/src/components/index.ts @@ -9,7 +9,14 @@ * @notice this exports used in `vuestic-ui` package. Make sure add component to vuestic-plugin as well. */ +// Components used in other components +export * from './va-input' export * from './va-fallback' +export * from './va-collapse' +export * from './va-card' +export * from './va-button' + +// Other components export * from './va-accordion' export * from './va-affix' export * from './va-alert' @@ -23,12 +30,9 @@ export * from './va-breadcrumbs' export * from './va-button-dropdown' export * from './va-button-group' export * from './va-button-toggle' -export * from './va-button' -export * from './va-card' export * from './va-carousel' export * from './va-checkbox' export * from './va-chip' -export * from './va-collapse' export * from './va-color-indicator' export * from './va-color-input' export * from './va-color-palette' @@ -46,7 +50,6 @@ export * from './va-icon' export * from './va-image' export * from './va-infinite-scroll' export * from './va-inner-loading' -export * from './va-input' export * from './va-list' export * from './va-modal' export * from './va-navbar' diff --git a/packages/ui/src/components/va-radio/VaRadio.vue b/packages/ui/src/components/va-radio/VaRadio.vue index a761cad34b..4030db486b 100644 --- a/packages/ui/src/components/va-radio/VaRadio.vue +++ b/packages/ui/src/components/va-radio/VaRadio.vue @@ -1,6 +1,5 @@ diff --git a/packages/docs/page-config/ui-elements/radio/examples/Default.vue b/packages/docs/page-config/ui-elements/radio/examples/Default.vue index 5dab7a15da..8e34cbc59d 100644 --- a/packages/docs/page-config/ui-elements/radio/examples/Default.vue +++ b/packages/docs/page-config/ui-elements/radio/examples/Default.vue @@ -2,14 +2,17 @@ diff --git a/packages/docs/page-config/ui-elements/radio/examples/NoOption.vue b/packages/docs/page-config/ui-elements/radio/examples/NoOption.vue deleted file mode 100644 index 3f9e13a8e5..0000000000 --- a/packages/docs/page-config/ui-elements/radio/examples/NoOption.vue +++ /dev/null @@ -1,15 +0,0 @@ - - - diff --git a/packages/docs/page-config/ui-elements/radio/examples/Slot.vue b/packages/docs/page-config/ui-elements/radio/examples/Slot.vue new file mode 100644 index 0000000000..a307cbd665 --- /dev/null +++ b/packages/docs/page-config/ui-elements/radio/examples/Slot.vue @@ -0,0 +1,31 @@ + + + + + \ No newline at end of file diff --git a/packages/docs/page-config/ui-elements/radio/examples/Validation.vue b/packages/docs/page-config/ui-elements/radio/examples/Validation.vue index d782bad810..d9c0eb9461 100644 --- a/packages/docs/page-config/ui-elements/radio/examples/Validation.vue +++ b/packages/docs/page-config/ui-elements/radio/examples/Validation.vue @@ -1,6 +1,10 @@ diff --git a/packages/docs/page-config/ui-elements/radio/index.ts b/packages/docs/page-config/ui-elements/radio/index.ts index 6a6572af50..e12b1f6ec4 100644 --- a/packages/docs/page-config/ui-elements/radio/index.ts +++ b/packages/docs/page-config/ui-elements/radio/index.ts @@ -10,14 +10,13 @@ export default definePageConfig({ block.example("Default", { title: "Default", - description: "Default usage of the `va-radio` component." + description: "Default usage of the `va-radio` component. Make sure to add a `name` prop to group them together." }), block.example("Options", { title: "Multiple Options", description: "You can use `options` prop to pass an array of options to the component. Then multiple components will be rendered.`" }), - block.alert('Prefer using `options` prop over `option`, because it will handle keyboard navigation automatically.'), block.example("ComplexOptions", { description: "You can use more complex options with `textBy` and `valueBy` props if needed." }), @@ -25,11 +24,6 @@ export default definePageConfig({ description: "Passing multiple `options` at the same time allows you to use validation `rules`.", }), - block.example("NoOption", { - title: "Without option", - description: "In case you just need a radio input without option and want to handle everything manually `v-model` will be used as Boolean and represent if radio is checked." - }), - block.example("Color", { title: "Colors", description: "With `color` prop you can change the color of the component." @@ -42,6 +36,24 @@ export default definePageConfig({ title: "Disabled", description: "With `disabled` prop you can disable a user interaction with `va-radio` component." }), + block.example("Slot", { + title: "Slot", + description: "You can use `default` slot to pass a custom content as text to the component. You can also change icon appearance with `icon` slot." + }), + + block.subtitle('Accessibility'), + block.paragraph(` +Each option has [radio](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/radio_role)[[target=_blank]] role attribute. +If \`options\` prop is used the component has a [radiogroup](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/radiogroup_role)[[target=_blank]] role attribute, +otherwise you need to add \`role="radiogroup"\` on parent element manually. + +[aria-checked](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-checked)[[target=_blank]] is applied on option automatically. + +Always set \`name\` prop on the component to group options together for correct keyboard navigation. + +Set [aria-label](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label)[[target=_blank]] or [aria-labelledby](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-labelledby)[[target=_blank]] attribute on the component to provide a label for screen readers for radio-group if needed. +By default radio element labeled by text from option. + `.trim()), block.subtitle("API"), block.api("VaRadio", apiDescription, apiOptions), diff --git a/packages/ui/src/components/va-radio/VaRadio.vue b/packages/ui/src/components/va-radio/VaRadio.vue index e60016a1e8..136732fd5b 100644 --- a/packages/ui/src/components/va-radio/VaRadio.vue +++ b/packages/ui/src/components/va-radio/VaRadio.vue @@ -15,35 +15,47 @@ :key="index" :class="radioClass(option)" class="va-radio va-radio__square" - role="radio" - @click="selectOption(getValue(option))" - @keydown.space.prevent="selectOption(getValue(option))" > -