@storybook/vue3 7.0.0-beta.28 → 7.0.0-beta.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,15 +3,28 @@
3
3
  </template>
4
4
 
5
5
  <script lang="ts" setup>
6
+ import "./buttons.css"
6
7
  import { computed } from 'vue';
7
- type Props = {
8
+
9
+ const props = withDefaults(defineProps<{
10
+ /**
11
+ * The label of the button
12
+ */
8
13
  label: string,
14
+ /**
15
+ * primary or secondary button
16
+ */
9
17
  primary?: boolean,
18
+ /**
19
+ * size of the button
20
+ */
10
21
  size?: 'small' | 'medium' | 'large',
22
+ /**
23
+ * background color of the button
24
+ */
11
25
  backgroundColor?: string,
12
- }
13
26
 
14
- const props = withDefaults(defineProps<Props>(), { primary: false });
27
+ }>(), { primary: false });
15
28
 
16
29
  const emit = defineEmits<{
17
30
  (e: 'click', id: number): void;
@@ -1,4 +0,0 @@
1
- import{h}from"vue";import{sanitizeStoryContextUpdate}from"@storybook/preview-api";function normalizeFunctionalComponent(options){return typeof options=="function"?{render:options,name:options.name}:options}function prepare(rawStory,innerStory){let story=rawStory;return story==null?null:innerStory?{...normalizeFunctionalComponent(story),components:{...story.components||{},story:innerStory}}:{render(){return h(story)}}}function decorateStory(storyFn,decorators){return decorators.reduce((decorated,decorator)=>context=>{let story,decoratedStory=decorator(update=>(story=decorated({...context,...sanitizeStoryContextUpdate(update)}),story),context);return story||(story=decorated(context)),decoratedStory===story?story:prepare(decoratedStory,story)},context=>prepare(storyFn(context)))}import{dedent}from"ts-dedent";import{createApp,h as h2}from"vue";var render=(props,context)=>{let{id,component:Component}=context;if(!Component)throw new Error(`Unable to render story ${id} as the component annotation is missing from the default export`);return h2(Component,props,getSlots(props,context))},setupFunction=_app=>{},setup=fn=>{setupFunction=fn},map=new Map;function renderToCanvas({title,name,storyFn,showMain,showError,showException},canvasElement){let element,storybookApp=createApp({unmounted(){map.delete(canvasElement)},render(){return map.set(canvasElement,storybookApp),setupFunction(storybookApp),h2(element)}});if(storybookApp.config.errorHandler=e=>showException(e),element=storyFn(),!element){showError({title:`Expecting a Vue component from the story: "${name}" of "${title}".`,description:dedent`
2
- Did you forget to return the Vue component from the story?
3
- Use "() => ({ template: '<my-comp></my-comp>' })" or "() => ({ components: MyComp, template: '<my-comp></my-comp>' })" when defining the story.
4
- `});return}showMain(),map.get(canvasElement)?.unmount(),storybookApp.mount(canvasElement)}function getSlots(props,context){let{argTypes}=context,slots=Object.entries(props).filter(([key,value])=>argTypes[key]?.table?.category==="slots").map(([key,value])=>[key,()=>h2("span",JSON.stringify(value))]);return Object.fromEntries(slots)}export{decorateStory,render,setup,renderToCanvas};