From a117d3dffc5b66463e7d344675d0d797628ff732 Mon Sep 17 00:00:00 2001 From: Romain Hamel Date: Sat, 23 Sep 2023 13:08:51 +0200 Subject: [PATCH 01/12] feat(RadioGroup): new component --- .../content/examples/FormExampleElements.vue | 8 ++ .../content/examples/RadioExample.vue | 7 +- docs/content/3.forms/6.radio.md | 22 ++- src/runtime/components/forms/Radio.vue | 20 +-- src/runtime/components/forms/RadioGroup.vue | 126 ++++++++++++++++++ 5 files changed, 156 insertions(+), 27 deletions(-) create mode 100644 src/runtime/components/forms/RadioGroup.vue diff --git a/docs/components/content/examples/FormExampleElements.vue b/docs/components/content/examples/FormExampleElements.vue index ea095f5624..2a81721a5e 100644 --- a/docs/components/content/examples/FormExampleElements.vue +++ b/docs/components/content/examples/FormExampleElements.vue @@ -17,6 +17,7 @@ const state = ref({ checkbox: undefined, toggle: undefined, radio: undefined, + radioGroup: undefined, switch: undefined, range: undefined }) @@ -39,6 +40,9 @@ const schema = z.object({ radio: z.string().refine(value => value === 'option-2', { message: 'Select Option 2' }), + radioGroup: z.string().refine(value => value === 'option-2', { + message: 'Select Option 2' + }), range: z.number().max(20, { message: 'Must be less than 20' }) }) @@ -83,6 +87,10 @@ async function submit (event: FormSubmitEvent) { + + + + {{ option.label }} diff --git a/docs/components/content/examples/RadioExample.vue b/docs/components/content/examples/RadioExample.vue index 157026f574..1482705cec 100644 --- a/docs/components/content/examples/RadioExample.vue +++ b/docs/components/content/examples/RadioExample.vue @@ -1,14 +1,11 @@ ``` :: diff --git a/src/runtime/components/forms/Radio.vue b/src/runtime/components/forms/Radio.vue index b576c5b66a..42d4021c2e 100644 --- a/src/runtime/components/forms/Radio.vue +++ b/src/runtime/components/forms/Radio.vue @@ -2,7 +2,7 @@
-
From 4c1e3e37f301fa136064fb47ec7079e39c60156a Mon Sep 17 00:00:00 2001 From: Romain Hamel Date: Thu, 28 Sep 2023 13:45:39 +0200 Subject: [PATCH 03/12] feat(RadioGroup): add legend prop & slot --- .../content/examples/RadioGroupExample.vue | 2 +- docs/content/3.forms/11.radio-group.md | 36 +++++++++++++++++-- src/runtime/components/forms/RadioGroup.vue | 15 ++++++-- src/runtime/ui.config.ts | 5 +++ 4 files changed, 51 insertions(+), 7 deletions(-) diff --git a/docs/components/content/examples/RadioGroupExample.vue b/docs/components/content/examples/RadioGroupExample.vue index f7ff5c9c4e..24747f72b0 100644 --- a/docs/components/content/examples/RadioGroupExample.vue +++ b/docs/components/content/examples/RadioGroupExample.vue @@ -14,5 +14,5 @@ const selected = ref('sms') diff --git a/docs/content/3.forms/11.radio-group.md b/docs/content/3.forms/11.radio-group.md index 22788f5ace..001ccaaa13 100644 --- a/docs/content/3.forms/11.radio-group.md +++ b/docs/content/3.forms/11.radio-group.md @@ -34,6 +34,20 @@ const selected = ref('sms') ### Style +Use the `legend` prop to add a legend to the RadioGroup. + +::component-card +--- +baseProps: + options: [{ value: 'email', label: 'Email' }, { value: 'sms', label: 'Phone (SMS)' }, { value: 'push', label: 'Push notification' }] + modelValue: 'sms' +props: + legend: 'Legend' +--- + +:: +### Style + Use the `color` prop to change the style of the RadioGroup. ::component-card @@ -64,7 +78,7 @@ props: ### `label` -Use the `#label` slot to override the content of the label. +Use the `#label` slot to override the label of each options. ::component-example #default @@ -95,10 +109,26 @@ const selected = ref('sms') ``` :: -#label - [Label]{.italic} +### `legend` +Use the `#legend` slot to override the content of the legend. + +::component-card +--- +baseProps: + options: [{ value: 'email', label: 'Email' }, { value: 'sms', label: 'Phone (SMS)' }, { value: 'push', label: 'Push notification' }] + modelValue: 'sms' +slots: + legend: Legend +--- + +#legend + [Legend]{.italic} :: ## Props :component-props + +## Preset + +:component-preset diff --git a/src/runtime/components/forms/RadioGroup.vue b/src/runtime/components/forms/RadioGroup.vue index eeffb6c0a0..b55a988fcc 100644 --- a/src/runtime/components/forms/RadioGroup.vue +++ b/src/runtime/components/forms/RadioGroup.vue @@ -1,6 +1,11 @@