diff --git a/.gitignore b/.gitignore
index 34d51dfa..dd425c1e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
node_modules/
coverage/
+storybook-static/
.eslintcache
.DS_Store
dist/
diff --git a/.storybook/main.js b/.storybook/main.js
index 6007a4df..40dd8ff7 100644
--- a/.storybook/main.js
+++ b/.storybook/main.js
@@ -1,3 +1,8 @@
module.exports = {
- stories: ['../stories/**/*.stories.{js,mdx}'],
+ stories: ['../stories/**/*.stories.{js,ts,mdx}'],
+ docs: {
+ //👇 See the table below for the list of supported options
+ autodocs: 'tag',
+ defaultName: 'Documentation',
+ },
};
diff --git a/stories/cosmoz-autocomplete.stories.js b/stories/cosmoz-autocomplete.stories.js
index 3f4688aa..29b9895a 100644
--- a/stories/cosmoz-autocomplete.stories.js
+++ b/stories/cosmoz-autocomplete.stories.js
@@ -5,118 +5,188 @@ import { colors } from './data';
export default {
title: 'Autocomplete',
component: 'cosmoz-autocomplete',
+ tags: ['autodocs'],
+ argTypes: {
+ label: { control: 'text' },
+ textProperty: { control: 'text' },
+ limit: { control: 'number' },
+ defaultIndex: { control: 'number' },
+ hideEmpty: { control: 'boolean' },
+ disabled: { control: 'boolean' },
+ placeholder: { control: 'text' },
+ showSingle: { control: 'boolean' },
+ preserveOrder: { control: 'boolean' },
+ min: { control: 'number' },
+ wrap: { control: 'boolean' },
+ },
};
-const css = html`
-
- `,
- basic = () => html`
- ${css}
-
- `,
- single = () => html`
- ${css}
-
- `,
- hideEmpty = () => html`
- ${css}
-
- `,
- defaultIndex = () => html`
- ${css}
-
-
- `,
- disabled = () => html`
- ${css}
-
- `,
- placeholder = () => html`
- ${css}
-
- `;
-export { basic, single, hideEmpty, defaultIndex, disabled, placeholder };
+const CSS = html`
+
+`;
+
+const Autocomplete = ({
+ source,
+ limit,
+ textProperty,
+ min,
+ label = '',
+ value = [],
+ hideEmpty = false,
+ disabled = false,
+ placeholder = '',
+ defaultIndex = 0,
+ showSingle = false,
+ preserveOrder = false,
+ wrap = false,
+}) => html`
+ ${CSS}
+
+`;
+
+export const Basic = Autocomplete.bind({});
+Basic.args = {
+ label: 'Choose color',
+ source: colors,
+ textProperty: 'text',
+ value: [colors[0], colors[3]],
+};
+
+export const Single = Autocomplete.bind({});
+Single.args = {
+ label: 'Choose color',
+ source: colors,
+ textProperty: 'text',
+ limit: 1,
+ value: [colors[2]],
+};
-export const overflown = () =>
- html` ${css}
- `;
+export const HideEmpty = Autocomplete.bind({});
+HideEmpty.args = {
+ label: 'Choose color',
+ source: colors,
+ textProperty: 'text',
+ limit: 1,
+ value: [colors[2]],
+ hideEmpty: true,
+};
-export const wrap = () =>
- html` ${css}
- `;
+export const DefaultIndex = Autocomplete.bind({});
+DefaultIndex.args = {
+ label: 'Choose color',
+ source: colors,
+ textProperty: 'text',
+ limit: 1,
+ defaultIndex: -1,
+};
-export const select = () => html`
- ${css}
+export const DefaultIndexSingleValue = Autocomplete.bind({});
+DefaultIndexSingleValue.args = {
+ label: 'Choose color (single value)',
+ source: colors.slice(0, 1),
+ textProperty: 'text',
+ limit: 1,
+ defaultIndex: -1,
+};
+
+export const Disabled = Autocomplete.bind({});
+Disabled.args = {
+ label: 'Choose color',
+ source: colors,
+ textProperty: 'text',
+ limit: 1,
+ value: colors[0],
+ disabled: true,
+};
+
+export const Placeholder = Autocomplete.bind({});
+Placeholder.args = {
+ placeholder: 'Choose color (placeholder text)',
+ source: colors,
+ limit: 1,
+ textProperty: 'text',
+ value: colors[0],
+};
+
+export const Select = Autocomplete.bind({});
+Select.args = {
+ label: 'Choose color',
+ source: colors,
+ limit: 1,
+ textProperty: 'text',
+ value: colors[2],
+ showSingle: true,
+ preserveOrder: true,
+ min: 1,
+};
+
+const AutocompleteWithInlineCSS = ({
+ source,
+ limit,
+ textProperty,
+ min,
+ label = '',
+ value = [],
+ hideEmpty = false,
+ disabled = false,
+ placeholder = '',
+ defaultIndex = 0,
+ showSingle = false,
+ preserveOrder = false,
+ wrap = false,
+}) => html`
+ ${CSS}
`;
+
+export const Overflown = AutocompleteWithInlineCSS.bind({});
+Overflown.args = {
+ label: 'Choose color',
+ source: colors,
+ textProperty: 'text',
+ value: [colors[0], colors[1], colors[2]],
+};
+
+export const Wrap = AutocompleteWithInlineCSS.bind({});
+Wrap.args = {
+ label: 'Choose color',
+ source: colors,
+ textProperty: 'text',
+ value: [colors[0], colors[1], colors[2]],
+ wrap: true,
+};
diff --git a/stories/data.js b/stories/data.js
index f328e6b1..62d44740 100644
--- a/stories/data.js
+++ b/stories/data.js
@@ -6,7 +6,7 @@ const colors = [
'White',
'Brown',
'Aqua',
- 'Nothing'
-].map(text => ({ text }));
+ 'Nothing',
+].map((text) => ({ text }));
export { colors };