/* eslint-disable import/no-extraneous-dependencies */
import { storiesOf, html } from '@open-wc/demoing-storybook';
import { localize } from '@lion/localize';
import '@lion/radio/lion-radio.js';
import '@lion/form/lion-form.js';
import '../lion-radio-group.js';
storiesOf('Forms|Radio Group', module)
.add(
'Default',
() => html`
`,
)
.add(
'Pre Select',
() => html`
`,
)
.add(
'Disabled',
() => html`
`,
)
.add('Validation', () => {
const submit = () => {
const form = document.querySelector('#form');
if (form.errorState === false) {
console.log(form.serializeGroup());
}
};
return html`
`;
})
.add('Validation Item', () => {
const isBrontosaurus = value => {
const selectedValue = value['dinos[]'].find(v => v.checked === true);
return {
isBrontosaurus: selectedValue ? selectedValue.value === 'brontosaurus' : false,
};
};
localize.locale = 'en-GB';
try {
localize.addData('en-GB', 'lion-validate+isBrontosaurus', {
error: {
isBrontosaurus: 'You need to select "brontosaurus"',
},
});
} catch (error) {
// expected as it's a demo
}
return html`
`;
});