storybook-framework-qwik 0.0.7 → 0.1.0

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.
@@ -0,0 +1,3 @@
1
+ import { FunctionComponent } from '@builder.io/qwik';
2
+ import { Args } from './types.js';
3
+ export declare const componentToJSX: (Component: FunctionComponent, args: Args) => import("@builder.io/qwik/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx } from "@builder.io/qwik/jsx-runtime";
2
+ export const componentToJSX = (Component, args) => {
3
+ return _jsx(Component, { ...args });
4
+ };
package/dist/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- export type { StorybookConfig } from '@storybook/builder-vite';
2
1
  export * from './types.js';
package/dist/preset.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { StorybookConfig } from '@storybook/builder-vite';
2
- export declare const core: StorybookConfig['core'];
3
- export declare const viteFinal: StorybookConfig['viteFinal'];
4
- export declare const previewAnnotations: StorybookConfig['previewAnnotations'];
1
+ import type { StorybookViteConfig } from '@storybook/builder-vite';
2
+ export declare const core: StorybookViteConfig['core'];
3
+ export declare const viteFinal: StorybookViteConfig['viteFinal'];
4
+ export declare const previewAnnotations: StorybookViteConfig['previewAnnotations'];
5
5
  export declare const previewHead: (head: string) => string;
package/dist/preset.js CHANGED
@@ -9,7 +9,7 @@ export const viteFinal = async (defaultConfig, options) => {
9
9
  build: {
10
10
  target: 'es2020',
11
11
  rollupOptions: {
12
- external: ['@qwik-city-sw-register', '@qwik-city-plan'],
12
+ external: ['@qwik-city-plan'],
13
13
  },
14
14
  },
15
15
  });
package/dist/preview.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { render as renderQwik } from '@builder.io/qwik';
2
+ import { componentToJSX } from './component-to-jsx.js';
2
3
  // returns the Qwik component as a JSX element (</MyComponent>)
3
4
  // If a story has a custom renderer, it will replace this function.
4
5
  export const render = (args, context) => {
5
6
  const { component } = context;
6
7
  if (typeof component === 'function') {
7
- return component(args, context.name);
8
+ return componentToJSX(component, args);
8
9
  }
9
10
  return component;
10
11
  };
@@ -15,7 +16,7 @@ export async function renderToCanvas({ storyFn, showMain }, canvasElement) {
15
16
  canvasElement.append(container);
16
17
  showMain();
17
18
  }
18
- // I don't know how to to HMR stuff correctly, and Vite seems to keep referencing old files when you make a change.
19
+ // I don't know how to do HMR stuff correctly, and Vite seems to keep referencing old files when you make a change.
19
20
  // Force a reload when vite notifies of an update as a dirty temporary workaround.
20
21
  const viteHotMeta = import.meta.hot;
21
22
  if (viteHotMeta) {
@@ -1,6 +1,4 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "@builder.io/qwik/jsx-runtime";
2
2
  import { QwikCityMockProvider } from '@builder.io/qwik-city';
3
3
  /** Wraps story in QwikCityMockProvider */
4
- export const qwikCityDecorator = (Story) =>
5
- // Something is out of sync with the JSXNode generated here and the type expected by Decorator
6
- (_jsx(QwikCityMockProvider, { children: Story() }));
4
+ export const qwikCityDecorator = (Story) => (_jsx(QwikCityMockProvider, { children: Story() }));
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Component } from '@builder.io/qwik';
2
2
  import { WebRenderer } from '@storybook/types';
3
3
  export type { Args, ArgTypes, Parameters, StrictArgs } from '@storybook/types';
4
- import type { AnnotatedStoryFn, Args, ComponentAnnotations, StoryAnnotations, DecoratorFunction, LoaderFunction, StoryContext as GenericStoryContext, StrictArgs } from '@storybook/types';
4
+ import type { AnnotatedStoryFn, Args, ComponentAnnotations, StoryAnnotations, DecoratorFunction, LoaderFunction, StoryContext as GenericStoryContext, StrictArgs, StorybookConfig as StorybookConfigBase } from '@storybook/types';
5
5
  export interface QwikRenderer<T> extends WebRenderer {
6
6
  component: Component<T>;
7
7
  storyResult: ReturnType<Component<T>>;
@@ -27,3 +27,8 @@ export type StoryObj<TArgs = Args> = StoryAnnotations<QwikRenderer<TArgs>, TArgs
27
27
  export type Decorator<TArgs = StrictArgs> = DecoratorFunction<QwikRenderer<TArgs>, TArgs>;
28
28
  export type Loader<TArgs = StrictArgs> = LoaderFunction<QwikRenderer<TArgs>, TArgs>;
29
29
  export type StoryContext<TArgs = StrictArgs> = GenericStoryContext<QwikRenderer<TArgs>, TArgs>;
30
+ export type StorybookConfig = Omit<StorybookConfigBase, 'framework'> & {
31
+ framework: 'storybook-framework-qwik' | {
32
+ name: 'storybook-framework-qwik';
33
+ };
34
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storybook-framework-qwik",
3
- "version": "0.0.7",
3
+ "version": "0.1.0",
4
4
  "description": "Storybook for Qwik: View Qwik components in isolation.",
5
5
  "keywords": [
6
6
  "storybook",
@@ -76,10 +76,11 @@
76
76
  "types": "dist/index.d.ts",
77
77
  "scripts": {
78
78
  "watch": "tsc --watch --outDir ./dist --listEmittedFiles",
79
- "build": "tsc --outDir ./dist --listEmittedFiles"
79
+ "build": "tsc --outDir ./dist --listEmittedFiles",
80
+ "semantic-release": "semantic-release"
80
81
  },
81
82
  "dependencies": {
82
- "@storybook/builder-vite": "^7.0.0-beta.7"
83
+ "@storybook/builder-vite": ">=7.0.0-beta.7"
83
84
  },
84
85
  "peerDependencies": {
85
86
  "@builder.io/qwik": ">=0.15.2"
@@ -88,8 +89,11 @@
88
89
  "@builder.io/qwik-city": ">=0.0.128"
89
90
  },
90
91
  "devDependencies": {
91
- "@types/node": "^16.0.0",
92
- "typescript": "~4.9.3"
92
+ "@suin/semantic-release-yarn": "1.1.0",
93
+ "@types/node": "^18",
94
+ "semantic-release": "^21.0.0",
95
+ "typescript": "~5.0.2",
96
+ "vite": "^4.2.1"
93
97
  },
94
98
  "engines": {
95
99
  "node": "^14.18 || >=16"
@@ -97,4 +101,4 @@
97
101
  "publishConfig": {
98
102
  "access": "public"
99
103
  }
100
- }
104
+ }
@@ -0,0 +1 @@
1
+ declare module 'global';
@@ -53,7 +53,7 @@ export const Button = component$<ButtonProps>(
53
53
  return (
54
54
  <button
55
55
  class={classes}
56
- style={{ backgroundColor }}
56
+ style={backgroundColor ? { backgroundColor } : {}}
57
57
  onClick$={(event, element) => onClick$?.(event, element)}
58
58
  >
59
59
  <Slot />
@@ -1,17 +1,18 @@
1
- import { Meta } from "storybook-framework-qwik";
2
- import { StoryExample, StoryExampleProps } from "./story-example";
1
+ import React from 'react';
2
+ import { Meta } from 'storybook-framework-qwik';
3
+ import { StoryExample, StoryExampleProps } from './story-example';
3
4
 
4
5
  export default {
5
- title: "Story Example",
6
+ title: 'Story Example',
6
7
  args: {
7
- label: "Example label",
8
- color: "red",
8
+ label: 'Example label',
9
+ color: 'red',
9
10
  },
10
11
  argTypes: {
11
12
  color: {
12
- options: ["red", "green", "blue"],
13
+ options: ['red', 'green', 'blue'],
13
14
  control: {
14
- type: "select",
15
+ type: 'select',
15
16
  },
16
17
  },
17
18
  },