diff --git a/src/components/NeDropdownFilter.vue b/src/components/NeDropdownFilter.vue new file mode 100644 index 0000000..7051fc8 --- /dev/null +++ b/src/components/NeDropdownFilter.vue @@ -0,0 +1,242 @@ + + + + + + + + {{ openMenuAriaLabel }} + + + + + + {{ label }} + + + + + + + + + + + + {{ clearFilterLabel }} + + + + + + + + + + + {{ option.label }} + + {{ option.description }} + + + + + + + + + + + + {{ option.label }} + + {{ option.description }} + + + + + + + + + + diff --git a/src/main.ts b/src/main.ts index c7f7a62..08d7213 100644 --- a/src/main.ts +++ b/src/main.ts @@ -36,6 +36,7 @@ export { default as NeToastNotification } from '@/components/NeToastNotification export { default as NeModal } from '@/components/NeModal.vue' export { default as NeHeading } from '@/components/NeHeading.vue' export { default as NeListbox } from '@/components/NeListbox.vue' +export { default as NeDropdownFilter } from '@/components/NeDropdownFilter.vue' // types export export type { NeComboboxOption } from '@/components/NeCombobox.vue' @@ -43,6 +44,7 @@ export type { Tab } from '@/components/NeTabs.vue' export type { NeNotification } from '@/components/NeToastNotification.vue' export type { NeListboxOption } from '@/components/NeListbox.vue' export type { NeDropdownItem } from '@/components/NeDropdown.vue' +export type { FilterOption, FilterKind } from '@/components/NeDropdownFilter.vue' // library functions export export { diff --git a/stories/NeDropdownFilter.stories.ts b/stories/NeDropdownFilter.stories.ts new file mode 100644 index 0000000..a63054d --- /dev/null +++ b/stories/NeDropdownFilter.stories.ts @@ -0,0 +1,175 @@ +// Copyright (C) 2024 Nethesis S.r.l. +// SPDX-License-Identifier: GPL-3.0-or-later + +import type { Meta, StoryObj } from '@storybook/vue3' +import { NeDropdownFilter, NeButton } from '../src/main' +import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' + +const meta = { + title: 'NeDropdownFilter', + component: NeDropdownFilter, + tags: ['autodocs'], + argTypes: { + kind: { control: 'inline-radio', options: ['radio', 'checkbox'] }, + size: { control: 'inline-radio', options: ['xs', 'sm', 'md', 'lg', 'xl'] } + }, + args: { + label: 'Filter label', + options: [ + { + id: 'option1', + label: 'Option 1' + }, + { + id: 'option2', + label: 'Option 2' + }, + { + id: 'option3', + label: 'Option 3', + disabled: true + }, + { + id: 'option4', + label: 'Option 4' + } + ], + kind: 'checkbox', + clearFilterLabel: 'Clear filter', + openMenuAriaLabel: 'Open filter', + showClearFilter: true, + showSelectionCount: true, + alignToRight: false, + size: 'md', + disabled: false, + id: '' + } +} satisfies Meta + +export default meta +type Story = StoryObj + +const template = '' + +export const CheckboxOptions: Story = { + render: (args) => ({ + components: { NeDropdownFilter }, + setup() { + return { args } + }, + template: template + }), + args: {} +} + +export const RadioOptions: Story = { + render: (args) => ({ + components: { NeDropdownFilter }, + setup() { + return { args } + }, + template: template + }), + args: { + kind: 'radio' + } +} + +export const OptionsWithDescription: Story = { + render: (args) => ({ + components: { NeDropdownFilter }, + setup() { + return { args } + }, + template: template + }), + args: { + options: [ + { + id: 'option1', + label: 'Option 1', + description: 'Description for option 1', + disabled: false + }, + { + id: 'option2', + label: 'Option 2', + description: 'Description for option 2', + disabled: false + }, + { + id: 'option3', + label: 'Option 3', + description: 'Description for option 3', + disabled: true + }, + { + id: 'option4', + label: 'Option 4', + description: 'Description for option 4', + disabled: false + } + ] + } +} + +export const NoClearFilter: Story = { + render: (args) => ({ + components: { NeDropdownFilter }, + setup() { + return { args } + }, + template: template + }), + args: { + kind: 'checkbox', + showClearFilter: false + } +} + +const alignToRightTemplate = ` + +` + +export const AlignToRight: Story = { + render: (args) => ({ + components: { NeDropdownFilter }, + setup() { + return { args } + }, + template: alignToRightTemplate + }), + args: { alignToRight: true } +} + +export const Disabled: Story = { + render: (args) => ({ + components: { NeDropdownFilter }, + setup() { + return { args } + }, + template: template + }), + args: { + disabled: true + } +} + +const withSlotTemplate = ` + + + Button slot + + +` + +export const ButtonSlot: Story = { + render: (args) => ({ + components: { NeDropdownFilter, NeButton, FontAwesomeIcon }, + setup() { + return { args } + }, + template: withSlotTemplate + }), + args: {} +}