diff --git a/docs/app.vue b/docs/app.vue index c2456593..d5def598 100644 --- a/docs/app.vue +++ b/docs/app.vue @@ -62,10 +62,10 @@ const sections = [ { label: 'Getting Started', links: [{ label: 'Usage', to: '/' }, { label: 'Examples', to: '/examples' }, { label: 'Migration', to: '/migration' }, { label: 'Dark mode', to: '/dark' }] }, { label: 'Elements', links: [{ label: 'Avatar', to: '/components/Avatar' }, { label: 'AvatarGroup', to: '/components/AvatarGroup' }, { label: 'Badge', to: '/components/Badge' }, { label: 'Button', to: '/components/Button' }, { label: 'Dropdown', to: '/components/Dropdown' }, { label: 'Icon', to: '/components/Icon' }] }, { label: 'Feedback', links: [{ label: 'Alert', to: '/components/Alert' }] }, - { label: 'Forms', links: [{ label: 'Checkbox', to: '/components/Checkbox' }, { label: 'Input', to: '/components/Input' }, { label: 'InputGroup', to: '/components/InputGroup' }, { label: 'Radio', to: '/components/Radio' }, { label: 'RadioGroup', to: '/components/RadioGroup' }, { label: 'Select', to: '/components/Select' }, { label: 'SelectCustom', to: '/components/SelectCustom' }, { label: 'Textarea', to: '/components/Textarea' }, { label: 'Toggle', to: '/components/Toggle' }, { label: 'ToggleGroup', to: '/components/ToggleGroup' }] }, + { label: 'Forms', links: [{ label: 'Checkbox', to: '/components/Checkbox' }, { label: 'Input', to: '/components/Input' }, { label: 'FormGroup', to: '/components/FormGroup' }, { label: 'Radio', to: '/components/Radio' }, { label: 'RadioGroup', to: '/components/RadioGroup' }, { label: 'Select', to: '/components/Select' }, { label: 'SelectCustom', to: '/components/SelectCustom' }, { label: 'Textarea', to: '/components/Textarea' }, { label: 'Toggle', to: '/components/Toggle' }] }, { label: 'Layout', links: [{ label: 'Card', to: '/components/Card' }, { label: 'Container', to: '/components/Container' }] }, { label: 'Navigation', links: [{ label: 'Pills', to: '/components/Pills' }, { label: 'Tabs', to: '/components/Tabs' }, { label: 'VerticalNavigation', to: '/components/VerticalNavigation' }] }, - { label: 'Overlays', links: [{ label: 'Modal', to: '/components/Modal' }, { label: 'Notification', to: '/components/Notification' }, { label: 'Popover', to: '/components/Popover' }, { label: 'Slideover', to: '/components/Slideover' }, { label: 'Tooltip', to: '/components/Tooltip' }] } + { label: 'Overlays', links: [{ label: 'Modal', to: '/components/Modal' }, { label: 'Notification', to: '/components/Notification' }, { label: 'Popover', to: '/components/Popover' }, { label: 'Tooltip', to: '/components/Tooltip' }] } ] diff --git a/docs/pages/components/[component].vue b/docs/pages/components/[component].vue index ddcd49d6..fad9b07b 100644 --- a/docs/pages/components/[component].vue +++ b/docs/pages/components/[component].vue @@ -1,17 +1,30 @@ - - - + + + + + + + + + + - - + @@ -70,6 +83,9 @@ const is = `U${params.component}` const component = nuxtApp.vueApp.component(is) +const toggle = ref(false) +const modal = ref(false) + const defaultProps = { Button: { label: 'Button text' @@ -115,14 +131,22 @@ const defaultProps = { name: 'input', placeholder: 'Enter text' }, - InputGroup: { + FormGroup: { name: 'input', label: 'Input group', - slot: 'Input' + slots: { + default: { + component: 'Input', + props: { + name: 'input', + placeholder: 'Works with every form element' + } + } + } }, - ToggleGroup: { - name: 'input', - label: 'Toggle group' + Toggle: { + modelValue: toggle, + 'onUpdate:modelValue': (v) => { toggle.value = v } }, Checkbox: { name: 'checkbox' @@ -130,6 +154,20 @@ const defaultProps = { Radio: { name: 'radio' }, + RadioGroup: { + name: 'radio', + label: 'Radio group', + options: [ + { + label: 'Option 1', + value: 'option-1' + }, + { + label: 'Option 2', + value: 'option-2' + } + ] + }, Select: { name: 'select', options: ['English', 'Spanish', 'French', 'German', 'Chinese'] @@ -144,13 +182,40 @@ const defaultProps = { id: '1', title: 'Notification title', callback: 'alert(\'Timer expired\')' + }, + Modal: { + modelValue: modal, + 'onUpdate:modelValue': (v) => { modal.value = v }, + slots: { + default: { + tag: 'div', + html: 'Modal content' + }, + footer: { + component: 'Button', + props: { + label: 'Close', + onClick: () => { modal.value = false } + } + } + } + }, + Popover: { + slots: { + panel: { + tag: 'div', + class: 'u-bg-gray-100 rounded-lg shadow-lg ring-1 ring-black ring-opacity-5 p-6', + html: 'Popover content' + } + } } } +const componentDefaultProps = defaultProps[params.component] || {} const { props: componentProps } = await component.__asyncLoader() const refProps = Object.entries(componentProps).map(([key, prop]) => { - const defaultValue = (defaultProps[params.component] || {})[key] + const defaultValue = componentDefaultProps[key] let value = defaultValue || (typeof prop.default === 'function' ? prop.default() : prop.default) let type = prop.type if (Array.isArray(type)) { @@ -188,6 +253,13 @@ const refProps = Object.entries(componentProps).map(([key, prop]) => { } }) +const eventProps = Object.entries(componentDefaultProps) + .filter(([key]) => !refProps.find(prop => prop.key === key)) + .reduce((acc, [key, value]) => { + acc[key] = value + return acc + }, {}) + const props = ref(refProps) const boundProps = computed(() => { const bound = {} diff --git a/docs/pages/examples.vue b/docs/pages/examples.vue index 4ec6e2cf..ea2102a5 100644 --- a/docs/pages/examples.vue +++ b/docs/pages/examples.vue @@ -153,21 +153,14 @@ - - - - - Toggle: - - @@ -183,23 +176,21 @@ - - - + + + - - - + + + + + + + - - diff --git a/docs/pages/migration.vue b/docs/pages/migration.vue index de3f1fda..3e662b83 100644 --- a/docs/pages/migration.vue +++ b/docs/pages/migration.vue @@ -101,13 +101,6 @@ const components = [ nuxt3: true, capi: true }, - { - label: 'ToggleGroup', - to: '/components/ToggleGroup', - nuxt3: true, - capi: true, - preset: true - }, { label: 'Alert', to: '/components/Alert' @@ -123,8 +116,8 @@ const components = [ preset: true }, { - label: 'InputGroup', - to: '/components/InputGroup', + label: 'FormGroup', + to: '/components/FormGroup', nuxt3: true, capi: true, preset: true @@ -201,10 +194,6 @@ const components = [ nuxt3: true, capi: true }, - { - label: 'Slideover', - to: '/components/Slideover' - }, { label: 'Tooltip', to: '/components/Tooltip', diff --git a/src/components/forms/InputGroup.vue b/src/components/forms/FormGroup.vue similarity index 97% rename from src/components/forms/InputGroup.vue rename to src/components/forms/FormGroup.vue index 0def3651..24107e25 100644 --- a/src/components/forms/InputGroup.vue +++ b/src/components/forms/FormGroup.vue @@ -6,6 +6,7 @@ v-if="label" :for="name" :class="labelClass" + @click="onLabelClick" > {{ label }} * diff --git a/src/components/forms/ToggleGroup.vue b/src/components/forms/ToggleGroup.vue deleted file mode 100644 index b820e580..00000000 --- a/src/components/forms/ToggleGroup.vue +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - {{ label }} - * - - - {{ hint }} - - - - - - - {{ help }} - - - - - - diff --git a/src/components/overlays/Modal.vue b/src/components/overlays/Modal.vue index 9ce65ad4..1c523502 100644 --- a/src/components/overlays/Modal.vue +++ b/src/components/overlays/Modal.vue @@ -64,10 +64,6 @@ export default { modelValue: { type: Boolean, default: false - }, - title: { - type: String, - default: null } }, emits: ['update:modelValue'], diff --git a/src/components/overlays/Slideover.vue b/src/components/overlays/Slideover.vue deleted file mode 100644 index 3b5abeff..00000000 --- a/src/components/overlays/Slideover.vue +++ /dev/null @@ -1,210 +0,0 @@ - - - - - - - - - - - - - - - - - {{ title }} - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/components/overlays/Tooltip.vue b/src/components/overlays/Tooltip.vue index b1582739..41c06da3 100644 --- a/src/components/overlays/Tooltip.vue +++ b/src/components/overlays/Tooltip.vue @@ -44,7 +44,7 @@ export default { }, wrapperClass: { type: String, - default: 'relative' + default: 'relative inline-flex' }, containerClass: { type: String,
- {{ help }} -