@storybook/react 11.0.0-alpha.7 → 11.0.0-alpha.9
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.
- package/dist/_node-chunks/{chunk-EH6QRX5B.js → chunk-AV7GEKV7.js} +682 -751
- package/dist/docgen/docgen-worker.js +12 -11
- package/dist/index.d.ts +3 -3
- package/dist/preset.js +134 -119
- package/package.json +2 -5
- package/template/cli/js/Button.jsx +11 -23
- package/template/cli/js/Header.jsx +8 -12
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_ynn8fkacxge from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_ynn8fkacxge from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_ynn8fkacxge from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_ynn8fkacxge.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_ynn8fkacxge.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_ynn8fkacxge.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -15,10 +15,10 @@ import {
|
|
|
15
15
|
extractArgTypes,
|
|
16
16
|
posix,
|
|
17
17
|
resolveStoryFileComponents
|
|
18
|
-
} from "../_node-chunks/chunk-
|
|
18
|
+
} from "../_node-chunks/chunk-AV7GEKV7.js";
|
|
19
19
|
|
|
20
20
|
// src/docgen/docgen-worker.ts
|
|
21
|
-
import { createLazyDocgenMiddleware } from "storybook/internal/common";
|
|
21
|
+
import { createLazyDocgenMiddleware, loadTypeScriptCompilerApi } from "storybook/internal/common";
|
|
22
22
|
import { logger } from "storybook/internal/node-logger";
|
|
23
23
|
|
|
24
24
|
// src/docgen/buildDocgen.ts
|
|
@@ -94,10 +94,11 @@ async function buildDocgenPayload(input, context) {
|
|
|
94
94
|
var createDocgenProvider = () => createLazyDocgenMiddleware({
|
|
95
95
|
createManager: async () => {
|
|
96
96
|
try {
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
return new ComponentMetaManager(
|
|
98
|
+
await loadTypeScriptCompilerApi(() => import("typescript"))
|
|
99
|
+
);
|
|
99
100
|
} catch (err) {
|
|
100
|
-
logger.
|
|
101
|
+
logger.warn(`React docgen is unavailable. ${err instanceof Error ? err.message : err}`);
|
|
101
102
|
return;
|
|
102
103
|
}
|
|
103
104
|
},
|
package/dist/index.d.ts
CHANGED
|
@@ -837,19 +837,19 @@ Except<BaseType, Keys> // Pick the keys that should be mutable from the base typ
|
|
|
837
837
|
/**
|
|
838
838
|
* Metadata to configure the stories for a component.
|
|
839
839
|
*
|
|
840
|
-
* @see [
|
|
840
|
+
* @see [Meta](https://storybook.js.org/docs/writing-stories/csf#meta)
|
|
841
841
|
*/
|
|
842
842
|
type Meta<TCmpOrArgs = Args$1> = [TCmpOrArgs] extends [ComponentType<any>] ? ComponentAnnotations<ReactRenderer, ComponentProps<TCmpOrArgs>> : ComponentAnnotations<ReactRenderer, TCmpOrArgs>;
|
|
843
843
|
/**
|
|
844
844
|
* Story function that represents a CSFv2 component example.
|
|
845
845
|
*
|
|
846
|
-
* @see [
|
|
846
|
+
* @see [Stories](https://storybook.js.org/docs/writing-stories/csf#stories)
|
|
847
847
|
*/
|
|
848
848
|
type StoryFn<TCmpOrArgs = Args$1> = [TCmpOrArgs] extends [ComponentType<any>] ? AnnotatedStoryFn<ReactRenderer, ComponentProps<TCmpOrArgs>> : AnnotatedStoryFn<ReactRenderer, TCmpOrArgs>;
|
|
849
849
|
/**
|
|
850
850
|
* Story object that represents a CSFv3 component example.
|
|
851
851
|
*
|
|
852
|
-
* @see [
|
|
852
|
+
* @see [Stories](https://storybook.js.org/docs/writing-stories/csf#stories)
|
|
853
853
|
*/
|
|
854
854
|
type StoryObj<TMetaOrCmpOrArgs = Args$1> = [TMetaOrCmpOrArgs] extends [{
|
|
855
855
|
render?: ArgsStoryFn<ReactRenderer, any>;
|
package/dist/preset.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_ynn8fkacxge from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_ynn8fkacxge from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_ynn8fkacxge from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_ynn8fkacxge.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_ynn8fkacxge.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_ynn8fkacxge.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -20,11 +20,12 @@ import {
|
|
|
20
20
|
getCodeSnippet,
|
|
21
21
|
invalidateCache,
|
|
22
22
|
invalidateParser,
|
|
23
|
+
isAbsolute,
|
|
23
24
|
join,
|
|
24
25
|
parseWithReactDocgen,
|
|
25
26
|
posix,
|
|
26
27
|
resolveStoryFileComponents
|
|
27
|
-
} from "./_node-chunks/chunk-
|
|
28
|
+
} from "./_node-chunks/chunk-AV7GEKV7.js";
|
|
28
29
|
|
|
29
30
|
// ../../../node_modules/semver/internal/constants.js
|
|
30
31
|
var require_constants = __commonJS({
|
|
@@ -73,7 +74,7 @@ var require_re = __commonJS({
|
|
|
73
74
|
MAX_LENGTH
|
|
74
75
|
} = require_constants(), debug = require_debug();
|
|
75
76
|
exports = module.exports = {};
|
|
76
|
-
var re = exports.re = [], safeRe = exports.safeRe = [], src = exports.src = [], safeSrc = exports.safeSrc = [],
|
|
77
|
+
var re = exports.re = [], safeRe = exports.safeRe = [], src = exports.src = [], safeSrc = exports.safeSrc = [], t = exports.t = {}, R = 0, LETTERDASHNUMBER = "[a-zA-Z0-9-]", safeRegexReplacements = [
|
|
77
78
|
["\\s", 1],
|
|
78
79
|
["\\d", MAX_LENGTH],
|
|
79
80
|
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
|
|
@@ -83,51 +84,51 @@ var require_re = __commonJS({
|
|
|
83
84
|
return value;
|
|
84
85
|
}, createToken = (name, value, isGlobal) => {
|
|
85
86
|
let safe = makeSafeRegex(value), index = R++;
|
|
86
|
-
debug(name, index, value),
|
|
87
|
+
debug(name, index, value), t[name] = index, src[index] = value, safeSrc[index] = safe, re[index] = new RegExp(value, isGlobal ? "g" : void 0), safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
|
|
87
88
|
};
|
|
88
89
|
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
|
|
89
90
|
createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
|
|
90
91
|
createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
91
|
-
createToken("MAINVERSION", `(${src[
|
|
92
|
-
createToken("MAINVERSIONLOOSE", `(${src[
|
|
93
|
-
createToken("PRERELEASEIDENTIFIER", `(?:${src[
|
|
94
|
-
createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[
|
|
95
|
-
createToken("PRERELEASE", `(?:-(${src[
|
|
96
|
-
createToken("PRERELEASELOOSE", `(?:-?(${src[
|
|
92
|
+
createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
|
|
93
|
+
createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
94
|
+
createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
|
|
95
|
+
createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
96
|
+
createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
97
|
+
createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
97
98
|
createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
|
|
98
|
-
createToken("BUILD", `(?:\\+(${src[
|
|
99
|
-
createToken("FULLPLAIN", `v?${src[
|
|
100
|
-
createToken("FULL", `^${src[
|
|
101
|
-
createToken("LOOSEPLAIN", `[v=\\s]*${src[
|
|
102
|
-
createToken("LOOSE", `^${src[
|
|
99
|
+
createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
100
|
+
createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
|
|
101
|
+
createToken("FULL", `^${src[t.FULLPLAIN]}$`);
|
|
102
|
+
createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
|
|
103
|
+
createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
|
|
103
104
|
createToken("GTLT", "((?:<|>)?=?)");
|
|
104
|
-
createToken("XRANGEIDENTIFIERLOOSE", `${src[
|
|
105
|
-
createToken("XRANGEIDENTIFIER", `${src[
|
|
106
|
-
createToken("XRANGEPLAIN", `[v=\\s]*(${src[
|
|
107
|
-
createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[
|
|
108
|
-
createToken("XRANGE", `^${src[
|
|
109
|
-
createToken("XRANGELOOSE", `^${src[
|
|
105
|
+
createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
106
|
+
createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
107
|
+
createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
|
|
108
|
+
createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
|
|
109
|
+
createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
110
|
+
createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
110
111
|
createToken("COERCEPLAIN", `(^|[^\\d])(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
111
|
-
createToken("COERCE", `${src[
|
|
112
|
-
createToken("COERCEFULL", src[
|
|
113
|
-
createToken("COERCERTL", src[
|
|
114
|
-
createToken("COERCERTLFULL", src[
|
|
112
|
+
createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
113
|
+
createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
|
|
114
|
+
createToken("COERCERTL", src[t.COERCE], !0);
|
|
115
|
+
createToken("COERCERTLFULL", src[t.COERCEFULL], !0);
|
|
115
116
|
createToken("LONETILDE", "(?:~>?)");
|
|
116
|
-
createToken("TILDETRIM", `(\\s*)${src[
|
|
117
|
+
createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, !0);
|
|
117
118
|
exports.tildeTrimReplace = "$1~";
|
|
118
|
-
createToken("TILDE", `^${src[
|
|
119
|
-
createToken("TILDELOOSE", `^${src[
|
|
119
|
+
createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
120
|
+
createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
120
121
|
createToken("LONECARET", "(?:\\^)");
|
|
121
|
-
createToken("CARETTRIM", `(\\s*)${src[
|
|
122
|
+
createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, !0);
|
|
122
123
|
exports.caretTrimReplace = "$1^";
|
|
123
|
-
createToken("CARET", `^${src[
|
|
124
|
-
createToken("CARETLOOSE", `^${src[
|
|
125
|
-
createToken("COMPARATORLOOSE", `^${src[
|
|
126
|
-
createToken("COMPARATOR", `^${src[
|
|
127
|
-
createToken("COMPARATORTRIM", `(\\s*)${src[
|
|
124
|
+
createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
125
|
+
createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
126
|
+
createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
127
|
+
createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
128
|
+
createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, !0);
|
|
128
129
|
exports.comparatorTrimReplace = "$1$2$3";
|
|
129
|
-
createToken("HYPHENRANGE", `^\\s*(${src[
|
|
130
|
-
createToken("HYPHENRANGELOOSE", `^\\s*(${src[
|
|
130
|
+
createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
|
|
131
|
+
createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
|
|
131
132
|
createToken("STAR", "(<|>)?=?\\s*\\*");
|
|
132
133
|
createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
|
|
133
134
|
createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
@@ -164,7 +165,7 @@ var require_identifiers = __commonJS({
|
|
|
164
165
|
var require_semver = __commonJS({
|
|
165
166
|
"../../../node_modules/semver/classes/semver.js"(exports, module) {
|
|
166
167
|
"use strict";
|
|
167
|
-
var debug = require_debug(), { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants(), { safeRe: re, t
|
|
168
|
+
var debug = require_debug(), { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants(), { safeRe: re, t } = require_re(), parseOptions = require_parse_options(), { compareIdentifiers } = require_identifiers(), isPrereleaseIdentifier = (prerelease, identifier) => {
|
|
168
169
|
let identifiers = identifier.split(".");
|
|
169
170
|
if (identifiers.length > prerelease.length)
|
|
170
171
|
return !1;
|
|
@@ -185,7 +186,7 @@ var require_semver = __commonJS({
|
|
|
185
186
|
`version is longer than ${MAX_LENGTH} characters`
|
|
186
187
|
);
|
|
187
188
|
debug("SemVer", version, options), this.options = options, this.loose = !!options.loose, this.includePrerelease = !!options.includePrerelease;
|
|
188
|
-
let m = version.trim().match(options.loose ? re[
|
|
189
|
+
let m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
189
190
|
if (!m)
|
|
190
191
|
throw new TypeError(`Invalid Version: ${version}`);
|
|
191
192
|
if (this.raw = version, this.major = +m[1], this.minor = +m[2], this.patch = +m[3], this.major > MAX_SAFE_INTEGER || this.major < 0)
|
|
@@ -264,7 +265,7 @@ var require_semver = __commonJS({
|
|
|
264
265
|
if (!identifier && identifierBase === !1)
|
|
265
266
|
throw new Error("invalid increment argument: identifier is empty");
|
|
266
267
|
if (identifier) {
|
|
267
|
-
let match = `-${identifier}`.match(this.options.loose ? re[
|
|
268
|
+
let match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
|
|
268
269
|
if (!match || match[1] !== identifier)
|
|
269
270
|
throw new Error(`invalid identifier: ${identifier}`);
|
|
270
271
|
}
|
|
@@ -604,7 +605,7 @@ var require_cmp = __commonJS({
|
|
|
604
605
|
var require_coerce = __commonJS({
|
|
605
606
|
"../../../node_modules/semver/functions/coerce.js"(exports, module) {
|
|
606
607
|
"use strict";
|
|
607
|
-
var SemVer = require_semver(), parse2 = require_parse(), { safeRe: re, t
|
|
608
|
+
var SemVer = require_semver(), parse2 = require_parse(), { safeRe: re, t } = require_re(), coerce = (version, options) => {
|
|
608
609
|
if (version instanceof SemVer)
|
|
609
610
|
return version;
|
|
610
611
|
if (typeof version == "number" && (version = String(version)), typeof version != "string")
|
|
@@ -612,9 +613,9 @@ var require_coerce = __commonJS({
|
|
|
612
613
|
options = options || {};
|
|
613
614
|
let match = null;
|
|
614
615
|
if (!options.rtl)
|
|
615
|
-
match = version.match(options.includePrerelease ? re[
|
|
616
|
+
match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
|
|
616
617
|
else {
|
|
617
|
-
let coerceRtlRegex = options.includePrerelease ? re[
|
|
618
|
+
let coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL], next;
|
|
618
619
|
for (; (next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length); )
|
|
619
620
|
(!match || next.index + next[0].length !== match.index + match[0].length) && (match = next), coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
|
|
620
621
|
coerceRtlRegex.lastIndex = -1;
|
|
@@ -737,10 +738,10 @@ var require_range = __commonJS({
|
|
|
737
738
|
let memoKey = ((this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE)) + ":" + range, cached = cache.get(memoKey);
|
|
738
739
|
if (cached)
|
|
739
740
|
return cached;
|
|
740
|
-
let loose = this.options.loose, hr = loose ? re[
|
|
741
|
-
range = range.replace(hr, hyphenReplace(this.options.includePrerelease)), debug("hyphen replace", range), range = range.replace(re[
|
|
741
|
+
let loose = this.options.loose, hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
|
|
742
|
+
range = range.replace(hr, hyphenReplace(this.options.includePrerelease)), debug("hyphen replace", range), range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace), debug("comparator trim", range), range = range.replace(re[t.TILDETRIM], tildeTrimReplace), debug("tilde trim", range), range = range.replace(re[t.CARETTRIM], caretTrimReplace), debug("caret trim", range);
|
|
742
743
|
let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
|
|
743
|
-
loose && (rangeList = rangeList.filter((comp) => (debug("loose invalid filter", comp, this.options), !!comp.match(re[
|
|
744
|
+
loose && (rangeList = rangeList.filter((comp) => (debug("loose invalid filter", comp, this.options), !!comp.match(re[t.COMPARATORLOOSE])))), debug("range list", rangeList);
|
|
744
745
|
let rangeMap = /* @__PURE__ */ new Map(), comparators = rangeList.map((comp) => new Comparator(comp, this.options));
|
|
745
746
|
for (let comp of comparators) {
|
|
746
747
|
if (isNullSet(comp))
|
|
@@ -776,17 +777,17 @@ var require_range = __commonJS({
|
|
|
776
777
|
var LRU = require_lrucache(), cache = new LRU(), parseOptions = require_parse_options(), Comparator = require_comparator(), debug = require_debug(), SemVer = require_semver(), {
|
|
777
778
|
safeRe: re,
|
|
778
779
|
src,
|
|
779
|
-
t
|
|
780
|
+
t,
|
|
780
781
|
comparatorTrimReplace,
|
|
781
782
|
tildeTrimReplace,
|
|
782
783
|
caretTrimReplace
|
|
783
|
-
} = require_re(), { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants(), BUILDSTRIPRE = new RegExp(src[
|
|
784
|
+
} = require_re(), { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants(), BUILDSTRIPRE = new RegExp(src[t.BUILD], "g"), isNullSet = (c) => c.value === "<0.0.0-0", isAny = (c) => c.value === "", isSatisfiable = (comparators, options) => {
|
|
784
785
|
let result = !0, remainingComparators = comparators.slice(), testComparator = remainingComparators.pop();
|
|
785
786
|
for (; result && remainingComparators.length; )
|
|
786
787
|
result = remainingComparators.every((otherComparator) => testComparator.intersects(otherComparator, options)), testComparator = remainingComparators.pop();
|
|
787
788
|
return result;
|
|
788
|
-
}, parseComparator = (comp, options) => (comp = comp.replace(re[
|
|
789
|
-
let r = options.loose ? re[
|
|
789
|
+
}, parseComparator = (comp, options) => (comp = comp.replace(re[t.BUILD], ""), debug("comp", comp, options), comp = replaceCarets(comp, options), debug("caret", comp), comp = replaceTildes(comp, options), debug("tildes", comp), comp = replaceXRanges(comp, options), debug("xrange", comp), comp = replaceStars(comp, options), debug("stars", comp), comp), isX = (id) => !id || id.toLowerCase() === "x" || id === "*", invalidXRangeOrder = (M, m, p) => isX(M) && !isX(m) || isX(m) && p && !isX(p), replaceTildes = (comp, options) => comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" "), replaceTilde = (comp, options) => {
|
|
790
|
+
let r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE], z = options.includePrerelease ? "-0" : "";
|
|
790
791
|
return comp.replace(r, (_, M, m, p, pr) => {
|
|
791
792
|
debug("tilde", comp, _, M, m, p, pr);
|
|
792
793
|
let ret;
|
|
@@ -794,7 +795,7 @@ var require_range = __commonJS({
|
|
|
794
795
|
});
|
|
795
796
|
}, replaceCarets = (comp, options) => comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" "), replaceCaret = (comp, options) => {
|
|
796
797
|
debug("caret", comp, options);
|
|
797
|
-
let r = options.loose ? re[
|
|
798
|
+
let r = options.loose ? re[t.CARETLOOSE] : re[t.CARET], z = options.includePrerelease ? "-0" : "";
|
|
798
799
|
return comp.replace(r, (_, M, m, p, pr) => {
|
|
799
800
|
debug("caret", comp, _, M, m, p, pr);
|
|
800
801
|
let ret;
|
|
@@ -802,14 +803,14 @@ var require_range = __commonJS({
|
|
|
802
803
|
});
|
|
803
804
|
}, replaceXRanges = (comp, options) => (debug("replaceXRanges", comp, options), comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ")), replaceXRange = (comp, options) => {
|
|
804
805
|
comp = comp.trim();
|
|
805
|
-
let r = options.loose ? re[
|
|
806
|
+
let r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
806
807
|
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
|
807
808
|
if (debug("xRange", comp, ret, gtlt, M, m, p, pr), invalidXRangeOrder(M, m, p))
|
|
808
809
|
return comp;
|
|
809
810
|
let xM = isX(M), xm = xM || isX(m), xp = xm || isX(p), anyX = xp;
|
|
810
811
|
return gtlt === "=" && anyX && (gtlt = ""), pr = options.includePrerelease ? "-0" : "", xM ? gtlt === ">" || gtlt === "<" ? ret = "<0.0.0-0" : ret = "*" : gtlt && anyX ? (xm && (m = 0), p = 0, gtlt === ">" ? (gtlt = ">=", xm ? (M = +M + 1, m = 0, p = 0) : (m = +m + 1, p = 0)) : gtlt === "<=" && (gtlt = "<", xm ? M = +M + 1 : m = +m + 1), gtlt === "<" && (pr = "-0"), ret = `${gtlt + M}.${m}.${p}${pr}`) : xm ? ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0` : xp && (ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`), debug("xRange return", ret), ret;
|
|
811
812
|
});
|
|
812
|
-
}, replaceStars = (comp, options) => (debug("replaceStars", comp, options), comp.trim().replace(re[
|
|
813
|
+
}, replaceStars = (comp, options) => (debug("replaceStars", comp, options), comp.trim().replace(re[t.STAR], "")), replaceGTE0 = (comp, options) => (debug("replaceGTE0", comp, options), comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "")), hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => (isX(fM) ? from = "" : isX(fm) ? from = `>=${fM}.0.0${incPr ? "-0" : ""}` : isX(fp) ? from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}` : fpr ? from = `>=${from}` : from = `>=${from}${incPr ? "-0" : ""}`, isX(tM) ? to = "" : isX(tm) ? to = `<${+tM + 1}.0.0-0` : isX(tp) ? to = `<${tM}.${+tm + 1}.0-0` : tpr ? to = `<=${tM}.${tm}.${tp}-${tpr}` : incPr ? to = `<${tM}.${tm}.${+tp + 1}-0` : to = `<=${to}`, `${from} ${to}`.trim()), testSet = (set, version, options) => {
|
|
813
814
|
for (let i = 0; i < set.length; i++)
|
|
814
815
|
if (!set[i].test(version))
|
|
815
816
|
return !1;
|
|
@@ -844,7 +845,7 @@ var require_comparator = __commonJS({
|
|
|
844
845
|
comp = comp.trim().split(/\s+/).join(" "), debug("comparator", comp, options), this.options = options, this.loose = !!options.loose, this.parse(comp), this.semver === ANY ? this.value = "" : this.value = this.operator + this.semver.version, debug("comp", this);
|
|
845
846
|
}
|
|
846
847
|
parse(comp) {
|
|
847
|
-
let r = this.options.loose ? re[
|
|
848
|
+
let r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR], m = comp.match(r);
|
|
848
849
|
if (!m)
|
|
849
850
|
throw new TypeError(`Invalid comparator: ${comp}`);
|
|
850
851
|
this.operator = m[1] !== void 0 ? m[1] : "", this.operator === "=" && (this.operator = ""), m[2] ? this.semver = new SemVer(m[2], this.options.loose) : this.semver = ANY;
|
|
@@ -870,7 +871,7 @@ var require_comparator = __commonJS({
|
|
|
870
871
|
}
|
|
871
872
|
};
|
|
872
873
|
module.exports = Comparator;
|
|
873
|
-
var parseOptions = require_parse_options(), { safeRe: re, t
|
|
874
|
+
var parseOptions = require_parse_options(), { safeRe: re, t } = require_re(), cmp = require_cmp(), debug = require_debug(), SemVer = require_semver(), Range = require_range();
|
|
874
875
|
}
|
|
875
876
|
});
|
|
876
877
|
|
|
@@ -1216,7 +1217,7 @@ var require_semver2 = __commonJS({
|
|
|
1216
1217
|
// src/preset.ts
|
|
1217
1218
|
import path2, { join as join3 } from "node:path";
|
|
1218
1219
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
1219
|
-
import { getProjectRoot } from "storybook/internal/common";
|
|
1220
|
+
import { getProjectRoot, isTypeScriptReadyForDocgen } from "storybook/internal/common";
|
|
1220
1221
|
|
|
1221
1222
|
// ../../core/src/shared/utils/module.ts
|
|
1222
1223
|
import nodeModule, { createRequire } from "node:module";
|
|
@@ -1359,8 +1360,8 @@ var normalize = function(path3) {
|
|
|
1359
1360
|
if (path3.length === 0)
|
|
1360
1361
|
return ".";
|
|
1361
1362
|
path3 = normalizeWindowsPath(path3);
|
|
1362
|
-
let isUNCPath = path3.match(_UNC_REGEX), isPathAbsolute =
|
|
1363
|
-
return path3 = normalizeString(path3, !isPathAbsolute), path3.length === 0 ? isPathAbsolute ? "/" : trailingSeparator ? "./" : "." : (trailingSeparator && (path3 += "/"), _DRIVE_LETTER_RE.test(path3) && (path3 += "/"), isUNCPath ? isPathAbsolute ? `//${path3}` : `//./${path3}` : isPathAbsolute && !
|
|
1363
|
+
let isUNCPath = path3.match(_UNC_REGEX), isPathAbsolute = isAbsolute2(path3), trailingSeparator = path3[path3.length - 1] === "/";
|
|
1364
|
+
return path3 = normalizeString(path3, !isPathAbsolute), path3.length === 0 ? isPathAbsolute ? "/" : trailingSeparator ? "./" : "." : (trailingSeparator && (path3 += "/"), _DRIVE_LETTER_RE.test(path3) && (path3 += "/"), isUNCPath ? isPathAbsolute ? `//${path3}` : `//./${path3}` : isPathAbsolute && !isAbsolute2(path3) ? `/${path3}` : path3);
|
|
1364
1365
|
}, join2 = function(...arguments_) {
|
|
1365
1366
|
if (arguments_.length === 0)
|
|
1366
1367
|
return ".";
|
|
@@ -1399,12 +1400,12 @@ function normalizeString(path3, allowAboveRoot) {
|
|
|
1399
1400
|
}
|
|
1400
1401
|
return res;
|
|
1401
1402
|
}
|
|
1402
|
-
var
|
|
1403
|
+
var isAbsolute2 = function(p) {
|
|
1403
1404
|
return _IS_ABSOLUTE_RE.test(p);
|
|
1404
1405
|
};
|
|
1405
1406
|
var dirname = function(p) {
|
|
1406
1407
|
let segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
1407
|
-
return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (
|
|
1408
|
+
return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute2(p) ? "/" : ".");
|
|
1408
1409
|
};
|
|
1409
1410
|
|
|
1410
1411
|
// ../../core/src/shared/utils/module.ts
|
|
@@ -1423,6 +1424,40 @@ var importMetaResolve = (...args) => typeof import.meta.resolve != "function" &&
|
|
|
1423
1424
|
}
|
|
1424
1425
|
};
|
|
1425
1426
|
|
|
1427
|
+
// src/preview-react-alias.ts
|
|
1428
|
+
var reactResolveAlias = ({ react, reactDom }) => ({
|
|
1429
|
+
react,
|
|
1430
|
+
...isAbsolute(reactDom) ? { "react-dom/server": `${reactDom}/server.browser.js` } : {},
|
|
1431
|
+
"react-dom": reactDom
|
|
1432
|
+
}), reactViteAlias = ({ react, reactDom }) => [
|
|
1433
|
+
...isAbsolute(reactDom) ? [{ find: /^react-dom\/server$/, replacement: `${reactDom}/server.browser.js` }] : [],
|
|
1434
|
+
{ find: /^react-dom(\/.*)?$/, replacement: `${reactDom}$1` },
|
|
1435
|
+
{ find: /^react(\/.*)?$/, replacement: `${react}$1` }
|
|
1436
|
+
], reactDedupeVitePlugin = (target) => ({
|
|
1437
|
+
name: "storybook:react-dedupe",
|
|
1438
|
+
enforce: "pre",
|
|
1439
|
+
config: () => ({
|
|
1440
|
+
resolve: {
|
|
1441
|
+
alias: reactViteAlias(target)
|
|
1442
|
+
}
|
|
1443
|
+
})
|
|
1444
|
+
}), prependReactDedupePlugin = (config, target) => ({
|
|
1445
|
+
...config,
|
|
1446
|
+
plugins: [reactDedupeVitePlugin(target), ...config.plugins ?? []]
|
|
1447
|
+
}), aliasReactInWebpack = (config, target) => {
|
|
1448
|
+
let alias = reactResolveAlias(target), current = config.resolve?.alias, nextAlias = Array.isArray(current) ? [
|
|
1449
|
+
...current,
|
|
1450
|
+
...Object.entries(alias).map(([name, aliasPath]) => ({ name, alias: aliasPath }))
|
|
1451
|
+
] : { ...current, ...alias };
|
|
1452
|
+
return {
|
|
1453
|
+
...config,
|
|
1454
|
+
resolve: {
|
|
1455
|
+
...config.resolve,
|
|
1456
|
+
alias: nextAlias
|
|
1457
|
+
}
|
|
1458
|
+
};
|
|
1459
|
+
};
|
|
1460
|
+
|
|
1426
1461
|
// src/componentManifest/reactDocgen/extractReactDocgenInfo.ts
|
|
1427
1462
|
import { logger } from "storybook/internal/node-logger";
|
|
1428
1463
|
function getComponentDocgen(filePath, componentName) {
|
|
@@ -1549,13 +1584,15 @@ import {
|
|
|
1549
1584
|
} from "storybook/internal/common";
|
|
1550
1585
|
|
|
1551
1586
|
// src/componentManifest/componentMetaManagerSingleton.ts
|
|
1587
|
+
import { loadTypeScriptCompilerApi } from "storybook/internal/common";
|
|
1552
1588
|
import { logger as logger3 } from "storybook/internal/node-logger";
|
|
1553
1589
|
var componentMetaManagerPromise;
|
|
1554
1590
|
function getSharedComponentMetaManager() {
|
|
1555
1591
|
return componentMetaManagerPromise || (componentMetaManagerPromise = (async () => {
|
|
1556
1592
|
try {
|
|
1557
|
-
|
|
1558
|
-
|
|
1593
|
+
return new ComponentMetaManager(
|
|
1594
|
+
await loadTypeScriptCompilerApi(() => import("typescript"))
|
|
1595
|
+
);
|
|
1559
1596
|
} catch (err) {
|
|
1560
1597
|
logger3.debug(`[reactComponentMeta] Skipping component metadata extraction: ${err}`);
|
|
1561
1598
|
return;
|
|
@@ -1645,7 +1682,6 @@ var manifests = async (existingManifests = {}, options) => {
|
|
|
1645
1682
|
};
|
|
1646
1683
|
|
|
1647
1684
|
// src/enrichCsf.ts
|
|
1648
|
-
import { recast, types as t } from "storybook/internal/babel";
|
|
1649
1685
|
import { getPrettier } from "storybook/internal/common";
|
|
1650
1686
|
var enrichCsf = async (input, options) => {
|
|
1651
1687
|
let features2 = await options.presets.apply("features");
|
|
@@ -1654,16 +1690,16 @@ var enrichCsf = async (input, options) => {
|
|
|
1654
1690
|
let promises = Object.keys(csf._stories).map(async (key) => {
|
|
1655
1691
|
if (!csfSource._meta?.component)
|
|
1656
1692
|
return;
|
|
1657
|
-
let { format: format3 } = await getPrettier(),
|
|
1693
|
+
let { format: format3 } = await getPrettier(), code, snippet;
|
|
1658
1694
|
try {
|
|
1659
|
-
|
|
1695
|
+
code = getCodeSnippet(csfSource, key, csfSource._meta?.component).code;
|
|
1660
1696
|
} catch (e) {
|
|
1661
1697
|
if (!(e instanceof Error))
|
|
1662
1698
|
return;
|
|
1663
1699
|
snippet = e.message;
|
|
1664
1700
|
}
|
|
1665
1701
|
try {
|
|
1666
|
-
!snippet &&
|
|
1702
|
+
!snippet && code && (snippet = await format3(code, {
|
|
1667
1703
|
filepath: join(process.cwd(), "component.tsx")
|
|
1668
1704
|
}));
|
|
1669
1705
|
} catch (e) {
|
|
@@ -1673,45 +1709,9 @@ var enrichCsf = async (input, options) => {
|
|
|
1673
1709
|
}
|
|
1674
1710
|
if (!snippet)
|
|
1675
1711
|
return;
|
|
1676
|
-
let
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
), docsParameter = t.optionalMemberExpression(
|
|
1680
|
-
originalParameters,
|
|
1681
|
-
t.identifier("docs"),
|
|
1682
|
-
!1,
|
|
1683
|
-
!0
|
|
1684
|
-
);
|
|
1685
|
-
csf._ast.program.body.push(
|
|
1686
|
-
t.expressionStatement(
|
|
1687
|
-
t.assignmentExpression(
|
|
1688
|
-
"=",
|
|
1689
|
-
originalParameters,
|
|
1690
|
-
t.objectExpression([
|
|
1691
|
-
t.spreadElement(originalParameters),
|
|
1692
|
-
t.objectProperty(
|
|
1693
|
-
t.identifier("docs"),
|
|
1694
|
-
t.objectExpression([
|
|
1695
|
-
t.spreadElement(docsParameter),
|
|
1696
|
-
t.objectProperty(
|
|
1697
|
-
t.identifier("source"),
|
|
1698
|
-
t.objectExpression([
|
|
1699
|
-
t.objectProperty(t.identifier("code"), t.stringLiteral(snippet)),
|
|
1700
|
-
t.spreadElement(
|
|
1701
|
-
t.optionalMemberExpression(
|
|
1702
|
-
docsParameter,
|
|
1703
|
-
t.identifier("source"),
|
|
1704
|
-
!1,
|
|
1705
|
-
!0
|
|
1706
|
-
)
|
|
1707
|
-
)
|
|
1708
|
-
])
|
|
1709
|
-
)
|
|
1710
|
-
])
|
|
1711
|
-
)
|
|
1712
|
-
])
|
|
1713
|
-
)
|
|
1714
|
-
)
|
|
1712
|
+
let parameters = `${key}${csf._metaIsFactory ? ".input" : ""}.parameters`;
|
|
1713
|
+
csf.appendStatement(
|
|
1714
|
+
`${parameters} = { ...${parameters}, docs: { ...${parameters}?.docs, source: { code: ${JSON.stringify(snippet)}, ...${parameters}?.docs?.source } } };`
|
|
1715
1715
|
);
|
|
1716
1716
|
});
|
|
1717
1717
|
await Promise.all(promises);
|
|
@@ -1777,13 +1777,7 @@ var experimental_storyDocsProvider = async (nextStoryDocs, options) => {
|
|
|
1777
1777
|
};
|
|
1778
1778
|
|
|
1779
1779
|
// src/preset.ts
|
|
1780
|
-
var isDocgenProviderEnabled = () => {
|
|
1781
|
-
try {
|
|
1782
|
-
return import.meta.resolve("typescript"), !0;
|
|
1783
|
-
} catch {
|
|
1784
|
-
return !1;
|
|
1785
|
-
}
|
|
1786
|
-
}, features = async (existing) => ({
|
|
1780
|
+
var isDocgenProviderEnabled = (_existing, options) => isTypeScriptReadyForDocgen((specifier) => import.meta.resolve(specifier), options), features = async (existing) => ({
|
|
1787
1781
|
...existing,
|
|
1788
1782
|
componentsManifest: !0
|
|
1789
1783
|
}), previewAnnotations = async (input = [], options) => {
|
|
@@ -1803,13 +1797,23 @@ var isDocgenProviderEnabled = () => {
|
|
|
1803
1797
|
try {
|
|
1804
1798
|
return {
|
|
1805
1799
|
...existing,
|
|
1806
|
-
react: resolvePackageDir("react"),
|
|
1807
|
-
reactDom: resolvePackageDir("react-dom")
|
|
1800
|
+
react: resolvePackageDir("react", import.meta.url),
|
|
1801
|
+
reactDom: resolvePackageDir("react-dom", import.meta.url)
|
|
1808
1802
|
};
|
|
1809
1803
|
} catch {
|
|
1810
1804
|
return existing;
|
|
1811
1805
|
}
|
|
1806
|
+
}, readReactAliasTarget = async (options) => {
|
|
1807
|
+
let resolved = await options.presets.apply("resolvedReact", {});
|
|
1808
|
+
return !resolved?.react || !resolved.reactDom ? null : { react: resolved.react, reactDom: resolved.reactDom };
|
|
1809
|
+
}, viteFinal = async (config = {}, options) => {
|
|
1810
|
+
let target = await readReactAliasTarget(options);
|
|
1811
|
+
return target ? prependReactDedupePlugin(config, target) : config;
|
|
1812
1812
|
};
|
|
1813
|
+
async function webpack(config = {}, options) {
|
|
1814
|
+
let target = await readReactAliasTarget(options);
|
|
1815
|
+
return target ? aliasReactInWebpack(config, target) : config;
|
|
1816
|
+
}
|
|
1813
1817
|
async function internal_getArgTypesData(_input, options) {
|
|
1814
1818
|
let { componentFilePath, componentExportName, presets } = options ?? {};
|
|
1815
1819
|
if (!componentFilePath)
|
|
@@ -1834,6 +1838,15 @@ async function internal_getArgTypesData(_input, options) {
|
|
|
1834
1838
|
}), argTypesData;
|
|
1835
1839
|
}
|
|
1836
1840
|
var optimizeViteDeps = [
|
|
1841
|
+
// The vitest project-annotations setup file imports this renderer's entry previews through a
|
|
1842
|
+
// virtual module, and those chunks import React by the bare specifier. In the observed failure
|
|
1843
|
+
// (react 19.3.1, vite 7.3.7, vitest 5.0.5, chromium browser mode) the dependency scan had not
|
|
1844
|
+
// registered plain `react`, so the browser loaded react's CJS index.js raw and module linking
|
|
1845
|
+
// failed with "The requested module 'react/index.js' does not provide an export named 'default'".
|
|
1846
|
+
// Projects only hit this when their stories use the automatic JSX runtime and never import
|
|
1847
|
+
// `react` by name; a story importing `react` (for `useState`, say) registers it in the scan
|
|
1848
|
+
// and masks the failure.
|
|
1849
|
+
"react",
|
|
1837
1850
|
"react-dom/client",
|
|
1838
1851
|
"react-dom/test-utils",
|
|
1839
1852
|
"react/jsx-runtime"
|
|
@@ -1848,5 +1861,7 @@ export {
|
|
|
1848
1861
|
isDocgenProviderEnabled,
|
|
1849
1862
|
optimizeViteDeps,
|
|
1850
1863
|
previewAnnotations,
|
|
1851
|
-
resolvedReact
|
|
1864
|
+
resolvedReact,
|
|
1865
|
+
viteFinal,
|
|
1866
|
+
webpack
|
|
1852
1867
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react",
|
|
3
|
-
"version": "11.0.0-alpha.
|
|
3
|
+
"version": "11.0.0-alpha.9",
|
|
4
4
|
"description": "Storybook React renderer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"@types/react-dom": "^18.0.0 || ^19.0.0",
|
|
82
82
|
"react": "^18.0.0 || ^19.0.0",
|
|
83
83
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
84
|
-
"storybook": "^11.0.0-alpha.
|
|
84
|
+
"storybook": "^11.0.0-alpha.9",
|
|
85
85
|
"typescript": "^5.9.0 || ^6.0.0 || ^7.0.0"
|
|
86
86
|
},
|
|
87
87
|
"peerDependenciesMeta": {
|
|
@@ -90,9 +90,6 @@
|
|
|
90
90
|
},
|
|
91
91
|
"@types/react-dom": {
|
|
92
92
|
"optional": true
|
|
93
|
-
},
|
|
94
|
-
"typescript": {
|
|
95
|
-
"optional": true
|
|
96
93
|
}
|
|
97
94
|
},
|
|
98
95
|
"publishConfig": {
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
|
|
5
3
|
import './button.css';
|
|
6
4
|
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
5
|
+
/**
|
|
6
|
+
* Primary UI component for user interaction
|
|
7
|
+
*
|
|
8
|
+
* @param {object} props
|
|
9
|
+
* @param {boolean} [props.primary=false] Is this the principal call to action on the page?
|
|
10
|
+
* @param {string} [props.backgroundColor] What background color to use
|
|
11
|
+
* @param {'small' | 'medium' | 'large'} [props.size='medium'] How large should the button be?
|
|
12
|
+
* @param {string} props.label Button contents
|
|
13
|
+
* @param {() => void} [props.onClick] Optional click handler
|
|
14
|
+
*/
|
|
15
|
+
export const Button = ({ primary = false, backgroundColor, size = 'medium', label, ...props }) => {
|
|
15
16
|
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
|
16
17
|
return (
|
|
17
18
|
<button
|
|
@@ -24,16 +25,3 @@ export const Button = ({
|
|
|
24
25
|
</button>
|
|
25
26
|
);
|
|
26
27
|
};
|
|
27
|
-
|
|
28
|
-
Button.propTypes = {
|
|
29
|
-
/** Is this the principal call to action on the page? */
|
|
30
|
-
primary: PropTypes.bool,
|
|
31
|
-
/** What background color to use */
|
|
32
|
-
backgroundColor: PropTypes.string,
|
|
33
|
-
/** How large should the button be? */
|
|
34
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
35
|
-
/** Button contents */
|
|
36
|
-
label: PropTypes.string.isRequired,
|
|
37
|
-
/** Optional click handler */
|
|
38
|
-
onClick: PropTypes.func,
|
|
39
|
-
};
|