Replies: 1 comment
-
This doesn't seem to be limited to Angular. I tried to convert your stories to a React equivalent and the only difference was that where you got a string input, React showed an Object input. I think it is just the docs addon isn't handling I don't know is there is a good solution, at the moment, but if you just want the functionality and don't mind the code being odd then the following could work. It is not something I really think is a good solution though. export const INLINE_CHECK: Story = {
render: args => ({
props: {
...args,
inputs: new Set(args.inputs) // Manually mapping the array to a set.
},
}),
args: {
// inputs: new Set([MyEnum.A]),
inputs: [MyEnum.A] as any, // Using an array, even though it is the wrong type.
},
argTypes: {
inputs: {
options: [MyEnum.A, MyEnum.B],
control: { type: 'inline-check' },
},
},
}; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
I have got a component that takes a Set<T> as input.
By default this is shown as a string input in Storybook, but I would like to use a control such as 'inline-check'.
This causes the error following error:
Apparently the options are treated as an array rather than a Set. How can I use Sets instead, e.g. is there a way to map a prop into a form usable by the control and vice versa?
Additional information
For the reproduction, I have two almost identical components: SetsComponent and ArraysComponent. ArraysComponent works as expected, and I would like SetsComponent to work in the same way in Storybook
Create a reproduction
https://stackblitz.com/edit/github-m5gfbn?file=src%2Fstories%2Fsets.stories.ts
Beta Was this translation helpful? Give feedback.
All reactions