import type { StoryObj, Meta } from '@storybook/vue3'
import SearchListField from './SearchListField.vue'
import { fn } from '@storybook/test'
const meta = {
title: 'Composants/Formulaires/SearchListField',
component: SearchListField,
parameters: {
layout: 'fullscreen',
controls: { exclude: ['filteredItems', 'search', 'emitChangeEvent', 'onUpdate:modelValue'] },
},
decorators: [
() => ({
template: '
',
}),
],
argTypes: {
modelValue: {
default: '[]',
},
items: { control: { type: 'object' } },
returnObject: {
description: 'Si true, retourne l\'objet entier au lieu de la valeur',
control: 'boolean',
},
label: {
description: 'Label du champ de recherche',
control: 'text',
default: 'Rechercher',
},
listLabel: {
description: 'Legend pour le fieldset contenant la liste des éléments sélectionnables',
control: 'text',
default: 'Liste des éléments',
},
},
} satisfies Meta
export default meta
type Story = StoryObj
/**
* Story par défaut
*/
export const Default: Story = {
args: {
'modelValue': [],
'items': [
{
label: 'Chirurgien-dentiste',
value: 'chirurgien-dentiste',
},
{
label: 'Infirmier',
value: 'infirmier',
},
{
label: 'Orthophoniste',
value: 'orthophoniste',
},
{
label: 'Orthoptiste',
value: 'orthoptiste',
},
{
label: 'Pédicure-podologue',
value: 'pedicure-podologue',
},
{
label: 'Pharmacien',
value: 'pharmacien',
},
],
'label': 'Filtrer la liste des professions',
'listLabel': 'Choisisser parmi la liste des professions',
'onUpdate:modelValue': fn(),
},
render: (args) => {
return {
components: { SearchListField },
setup() {
return { args }
},
template: `
Valeur(s) sélectionnée(s) :
{{ args.modelValue }}
`,
}
},
parameters: {
sourceCode: [
{
name: 'Template',
code: `
{{ modelValue }}
`,
},
{
name: 'Script',
code: `
`,
},
],
},
}
export const WithReturnObject: Story = {
args: {
'modelValue': [],
'returnObject': true,
'items': [
{
label: 'Chirurgien-dentiste',
value: 'chirurgien-dentiste',
},
{
label: 'Infirmier',
value: 'infirmier',
},
{
label: 'Orthophoniste',
value: 'orthophoniste',
},
{
label: 'Orthoptiste',
value: 'orthoptiste',
},
{
label: 'Pédicure-podologue',
value: 'pedicure-podologue',
},
{
label: 'Pharmacien',
value: 'pharmacien',
},
],
'label': 'Filtrer la liste des professions',
'listLabel': 'Choisisser parmi la liste des professions',
'onUpdate:modelValue': fn(),
},
argTypes: {
returnObject: { control: false },
},
render: (args) => {
return {
components: { SearchListField },
setup() {
return { args }
},
template: `
Valeur(s) sélectionnée(s) :
{{ args.modelValue }}
`,
}
},
parameters: {
sourceCode: [
{
name: 'Template',
code: `
{{ modelValue }}
`,
},
{
name: 'Script',
code: `
`,
},
],
},
}