@storybook/vue3 10.6.0-alpha.2 → 10.6.0-alpha.4

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.
@@ -69,12 +69,16 @@ var ARG_TYPE_SECTIONS = ["props", "events", "slots", "exposed", "expose"], extra
69
69
  return;
70
70
  let tableType = { summary: docgenInfo.type.replace(" | undefined", "") };
71
71
  if (section === "props") {
72
- let propInfo = docgenInfo, defaultValue = propInfo.default ? { summary: propInfo.default } : void 0;
72
+ let propInfo = docgenInfo, defaultValue = propInfo.default ? { summary: propInfo.default } : void 0, type = convertVueComponentMetaProp(propInfo), enumLabels = getEnumMemberLabels(propInfo.schema);
73
73
  return {
74
74
  name: propInfo.name,
75
75
  description: formatDescriptionWithTags(propInfo.description, propInfo.tags),
76
76
  defaultValue,
77
- type: convertVueComponentMetaProp(propInfo),
77
+ type,
78
+ // A TS enum member is selected by its runtime value, so the qualified name it is written
79
+ // as can only be a label. "control.type" is left to inferControls, which picks radio or
80
+ // select by option count just like it does for a plain literal union.
81
+ ...enumLabels && type.name === "enum" ? { options: type.value, control: { labels: enumLabels } } : {},
78
82
  table: {
79
83
  type: tableType,
80
84
  defaultValue,
@@ -95,7 +99,7 @@ var ARG_TYPE_SECTIONS = ["props", "events", "slots", "exposed", "expose"], extra
95
99
  switch (schema.kind) {
96
100
  case "enum": {
97
101
  let definedSchemas = schema.schema?.filter((item) => item !== "undefined") ?? [];
98
- return isBooleanSchema(definedSchemas) ? { name: "boolean", required } : isLiteralUnionSchema(definedSchemas) || isEnumSchema(definedSchemas) ? { name: "enum", value: definedSchemas.map((literal) => literal.replace(/"/g, "")), required } : definedSchemas.length === 1 ? convertVueComponentMetaProp({
102
+ return isBooleanSchema(definedSchemas) ? { name: "boolean", required } : isSelectableUnionSchema(definedSchemas) ? { name: "enum", value: definedSchemas.map(selectableValue), required } : isEnumSchema(definedSchemas) ? fallbackSbType : definedSchemas.length === 1 ? convertVueComponentMetaProp({
99
103
  schema: definedSchemas[0],
100
104
  type: propInfo.type,
101
105
  required
@@ -140,9 +144,12 @@ var ARG_TYPE_SECTIONS = ["props", "events", "slots", "exposed", "expose"], extra
140
144
  default:
141
145
  return fallbackSbType;
142
146
  }
143
- }, formatDescriptionWithTags = (description, tags) => !tags?.length || !description ? description ?? "" : `${tags.map((tag) => `@${tag.name}: ${tag.text}`).join("<br>")}<br><br>${description}`, isLiteralUnionSchema = (schemas) => schemas.every(
144
- (schema) => typeof schema == "string" && schema.startsWith('"') && schema.endsWith('"')
145
- ), isEnumSchema = (schemas) => schemas.every((schema) => typeof schema == "string" && schema.includes(".")), isBooleanSchema = (schemas) => schemas.length === 2 && schemas.includes("true") && schemas.includes("false");
147
+ }, formatDescriptionWithTags = (description, tags) => !tags?.length || !description ? description ?? "" : `${tags.map((tag) => `@${tag.name}: ${tag.text}`).join("<br>")}<br><br>${description}`, isLiteralSchema = (schema) => typeof schema == "object" && schema.kind === "literal", isQuotedLiteral = (schema) => typeof schema == "string" && schema.startsWith('"') && schema.endsWith('"'), isSelectableUnionSchema = (schemas) => schemas.every((schema) => isQuotedLiteral(schema) || isLiteralSchema(schema)), selectableValue = (schema) => isLiteralSchema(schema) ? JSON.parse(schema.value) : schema.replace(/"/g, ""), getEnumMemberLabels = (schema) => {
148
+ if (typeof schema != "object" || schema.kind !== "enum")
149
+ return;
150
+ let members = (schema.schema ?? []).filter(isLiteralSchema);
151
+ return members.length ? Object.fromEntries(members.map((member) => [selectableValue(member), member.type])) : void 0;
152
+ }, isEnumSchema = (schemas) => schemas.every((schema) => typeof schema == "string" && schema.includes(".")), isBooleanSchema = (schemas) => schemas.length === 2 && schemas.includes("true") && schemas.includes("false");
146
153
 
147
154
  // src/render.ts
148
155
  import { createApp, h, isReactive, isVNode, reactive } from "vue";
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_cpbkhyrn9zg from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_cpbkhyrn9zg from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_cpbkhyrn9zg from "node:module";
1
+ import CJS_COMPAT_NODE_URL_gx8u2w437qe from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_gx8u2w437qe from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_gx8u2w437qe from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_cpbkhyrn9zg.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_cpbkhyrn9zg.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_cpbkhyrn9zg.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_gx8u2w437qe.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_gx8u2w437qe.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_gx8u2w437qe.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -5,7 +5,7 @@ import {
5
5
  parameters,
6
6
  render,
7
7
  renderToCanvas
8
- } from "./_browser-chunks/chunk-6VQEMAYE.js";
8
+ } from "./_browser-chunks/chunk-X42PMG4S.js";
9
9
  import "./_browser-chunks/chunk-4BE7D4DS.js";
10
10
  export {
11
11
  decorateStory as applyDecorators,
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  entry_preview_exports,
3
3
  renderToCanvas,
4
4
  setup
5
- } from "./_browser-chunks/chunk-6VQEMAYE.js";
5
+ } from "./_browser-chunks/chunk-X42PMG4S.js";
6
6
  import {
7
7
  entry_preview_docs_exports
8
8
  } from "./_browser-chunks/chunk-PW3RLJ6I.js";
package/dist/preset.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_cpbkhyrn9zg from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_cpbkhyrn9zg from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_cpbkhyrn9zg from "node:module";
1
+ import CJS_COMPAT_NODE_URL_gx8u2w437qe from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_gx8u2w437qe from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_gx8u2w437qe from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_cpbkhyrn9zg.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_cpbkhyrn9zg.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_cpbkhyrn9zg.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_gx8u2w437qe.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_gx8u2w437qe.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_gx8u2w437qe.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -18,7 +18,7 @@ var previewAnnotations = async (input = [], options) => {
18
18
  docsEnabled ? [fileURLToPath(import.meta.resolve("@storybook/vue3/entry-preview-docs"))] : []
19
19
  );
20
20
  }, experimental_importParsers = async (input = []) => {
21
- let { vueImportParser } = await import("./_node-chunks/parsers-27PLHUJ3.js");
21
+ let { vueImportParser } = await import("./_node-chunks/parsers-OMLY3BJL.js");
22
22
  return [...input, vueImportParser];
23
23
  };
24
24
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/vue3",
3
- "version": "10.6.0-alpha.2",
3
+ "version": "10.6.0-alpha.4",
4
4
  "description": "Storybook Vue 3 renderer: Develop, document, and test UI components in isolation",
5
5
  "keywords": [
6
6
  "storybook",
@@ -61,7 +61,7 @@
61
61
  "vue-tsc": "latest"
62
62
  },
63
63
  "peerDependencies": {
64
- "storybook": "^10.6.0-alpha.2",
64
+ "storybook": "^10.6.0-alpha.4",
65
65
  "vue": "^3.0.0"
66
66
  },
67
67
  "publishConfig": {