@procore/storybook-addon 4.7.0 → 4.7.2

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.
@@ -53,7 +53,6 @@ var preset_exports = {};
53
53
  __export(preset_exports, {
54
54
  addons: () => addons,
55
55
  babelDefault: () => babelDefault,
56
- default: () => preset_default,
57
56
  previewHead: () => previewHead_default,
58
57
  typescript: () => typescript
59
58
  });
@@ -62,13 +61,239 @@ module.exports = __toCommonJS(preset_exports);
62
61
  // src/configurations/babel.ts
63
62
  var import_package = require("@babel/runtime/package.json");
64
63
  var import_package2 = require("core-js/package.json");
64
+
65
+ // ../../node_modules/pathe/dist/shared/pathe.ff20891b.mjs
66
+ var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
67
+ function normalizeWindowsPath(input = "") {
68
+ if (!input) {
69
+ return input;
70
+ }
71
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
72
+ }
73
+ var _UNC_REGEX = /^[/\\]{2}/;
74
+ var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
75
+ var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
76
+ var _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
77
+ var sep = "/";
78
+ var delimiter = ":";
79
+ var normalize = function(path2) {
80
+ if (path2.length === 0) {
81
+ return ".";
82
+ }
83
+ path2 = normalizeWindowsPath(path2);
84
+ const isUNCPath = path2.match(_UNC_REGEX);
85
+ const isPathAbsolute = isAbsolute(path2);
86
+ const trailingSeparator = path2[path2.length - 1] === "/";
87
+ path2 = normalizeString(path2, !isPathAbsolute);
88
+ if (path2.length === 0) {
89
+ if (isPathAbsolute) {
90
+ return "/";
91
+ }
92
+ return trailingSeparator ? "./" : ".";
93
+ }
94
+ if (trailingSeparator) {
95
+ path2 += "/";
96
+ }
97
+ if (_DRIVE_LETTER_RE.test(path2)) {
98
+ path2 += "/";
99
+ }
100
+ if (isUNCPath) {
101
+ if (!isPathAbsolute) {
102
+ return `//./${path2}`;
103
+ }
104
+ return `//${path2}`;
105
+ }
106
+ return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
107
+ };
108
+ var join = function(...arguments_) {
109
+ if (arguments_.length === 0) {
110
+ return ".";
111
+ }
112
+ let joined;
113
+ for (const argument of arguments_) {
114
+ if (argument && argument.length > 0) {
115
+ if (joined === void 0) {
116
+ joined = argument;
117
+ } else {
118
+ joined += `/${argument}`;
119
+ }
120
+ }
121
+ }
122
+ if (joined === void 0) {
123
+ return ".";
124
+ }
125
+ return normalize(joined.replace(/\/\/+/g, "/"));
126
+ };
127
+ function cwd() {
128
+ if (typeof process !== "undefined" && typeof process.cwd === "function") {
129
+ return process.cwd().replace(/\\/g, "/");
130
+ }
131
+ return "/";
132
+ }
133
+ var resolve = function(...arguments_) {
134
+ arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
135
+ let resolvedPath = "";
136
+ let resolvedAbsolute = false;
137
+ for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
138
+ const path2 = index >= 0 ? arguments_[index] : cwd();
139
+ if (!path2 || path2.length === 0) {
140
+ continue;
141
+ }
142
+ resolvedPath = `${path2}/${resolvedPath}`;
143
+ resolvedAbsolute = isAbsolute(path2);
144
+ }
145
+ resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
146
+ if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
147
+ return `/${resolvedPath}`;
148
+ }
149
+ return resolvedPath.length > 0 ? resolvedPath : ".";
150
+ };
151
+ function normalizeString(path2, allowAboveRoot) {
152
+ let res = "";
153
+ let lastSegmentLength = 0;
154
+ let lastSlash = -1;
155
+ let dots = 0;
156
+ let char = null;
157
+ for (let index = 0; index <= path2.length; ++index) {
158
+ if (index < path2.length) {
159
+ char = path2[index];
160
+ } else if (char === "/") {
161
+ break;
162
+ } else {
163
+ char = "/";
164
+ }
165
+ if (char === "/") {
166
+ if (lastSlash === index - 1 || dots === 1) ;
167
+ else if (dots === 2) {
168
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
169
+ if (res.length > 2) {
170
+ const lastSlashIndex = res.lastIndexOf("/");
171
+ if (lastSlashIndex === -1) {
172
+ res = "";
173
+ lastSegmentLength = 0;
174
+ } else {
175
+ res = res.slice(0, lastSlashIndex);
176
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
177
+ }
178
+ lastSlash = index;
179
+ dots = 0;
180
+ continue;
181
+ } else if (res.length > 0) {
182
+ res = "";
183
+ lastSegmentLength = 0;
184
+ lastSlash = index;
185
+ dots = 0;
186
+ continue;
187
+ }
188
+ }
189
+ if (allowAboveRoot) {
190
+ res += res.length > 0 ? "/.." : "..";
191
+ lastSegmentLength = 2;
192
+ }
193
+ } else {
194
+ if (res.length > 0) {
195
+ res += `/${path2.slice(lastSlash + 1, index)}`;
196
+ } else {
197
+ res = path2.slice(lastSlash + 1, index);
198
+ }
199
+ lastSegmentLength = index - lastSlash - 1;
200
+ }
201
+ lastSlash = index;
202
+ dots = 0;
203
+ } else if (char === "." && dots !== -1) {
204
+ ++dots;
205
+ } else {
206
+ dots = -1;
207
+ }
208
+ }
209
+ return res;
210
+ }
211
+ var isAbsolute = function(p) {
212
+ return _IS_ABSOLUTE_RE.test(p);
213
+ };
214
+ var toNamespacedPath = function(p) {
215
+ return normalizeWindowsPath(p);
216
+ };
217
+ var _EXTNAME_RE = /.(\.[^./]+)$/;
218
+ var extname = function(p) {
219
+ const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
220
+ return match && match[1] || "";
221
+ };
222
+ var relative = function(from, to) {
223
+ const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
224
+ const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
225
+ if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
226
+ return _to.join("/");
227
+ }
228
+ const _fromCopy = [..._from];
229
+ for (const segment of _fromCopy) {
230
+ if (_to[0] !== segment) {
231
+ break;
232
+ }
233
+ _from.shift();
234
+ _to.shift();
235
+ }
236
+ return [..._from.map(() => ".."), ..._to].join("/");
237
+ };
238
+ var dirname = function(p) {
239
+ const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
240
+ if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
241
+ segments[0] += "/";
242
+ }
243
+ return segments.join("/") || (isAbsolute(p) ? "/" : ".");
244
+ };
245
+ var format = function(p) {
246
+ const segments = [p.root, p.dir, p.base ?? p.name + p.ext].filter(Boolean);
247
+ return normalizeWindowsPath(
248
+ p.root ? resolve(...segments) : segments.join("/")
249
+ );
250
+ };
251
+ var basename = function(p, extension) {
252
+ const lastSegment = normalizeWindowsPath(p).split("/").pop();
253
+ return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
254
+ };
255
+ var parse = function(p) {
256
+ const root = normalizeWindowsPath(p).split("/").shift() || "/";
257
+ const base = basename(p);
258
+ const extension = extname(base);
259
+ return {
260
+ root,
261
+ dir: dirname(p),
262
+ base,
263
+ ext: extension,
264
+ name: base.slice(0, base.length - extension.length)
265
+ };
266
+ };
267
+ var path = {
268
+ __proto__: null,
269
+ basename,
270
+ delimiter,
271
+ dirname,
272
+ extname,
273
+ format,
274
+ isAbsolute,
275
+ join,
276
+ normalize,
277
+ normalizeString,
278
+ parse,
279
+ relative,
280
+ resolve,
281
+ sep,
282
+ toNamespacedPath
283
+ };
284
+
285
+ // src/configurations/babel.ts
65
286
  var import_getCacheIdentifier = __toESM(require_getCacheIdentifier(), 1);
66
287
  var targets = "defaults";
67
288
  var transformRuntimeOptions = {
68
289
  // By default, babel assumes babel/runtime version 7.0.0-beta.0,
69
290
  // explicitly resolving to match the provided helper functions.
70
291
  // https://github.com/babel/babel/issues/10261
71
- version: import_package.version
292
+ version: import_package.version,
293
+ // Undocumented option that lets us encapsulate our runtime, ensuring
294
+ // the correct version is used
295
+ // https://github.com/babel/babel/blob/090c364a90fe73d36a30707fc612ce037bdbbb24/packages/babel-plugin-transform-runtime/src/index.js#L35-L42
296
+ absoluteRuntime: path.dirname(require.resolve("@babel/runtime/package.json"))
72
297
  };
73
298
  function createConfigForReact() {
74
299
  const env = process.env.NODE_ENV || "development";
@@ -185,57 +410,35 @@ function requireIfExists(moduleName) {
185
410
  }
186
411
 
187
412
  // src/preset.ts
413
+ var findBabelConfig = require("find-babel-config");
188
414
  var addons = () => {
189
415
  const sassImplementation = requireIfExists("sass");
190
416
  return [
191
417
  {
192
- name: "@storybook/addon-styling-webpack",
418
+ name: "@storybook/addon-styling",
193
419
  options: {
194
- rules: [
195
- {
196
- test: /\.scss$/,
197
- use: [
198
- "style-loader",
199
- {
200
- loader: "css-loader",
201
- options: {
202
- modules: {
203
- localIdentName: "[name]__[local]--[hash:base64:5]"
204
- }
205
- }
206
- },
207
- {
208
- loader: "sass-loader",
209
- options: {
210
- ...sassImplementation ? {
211
- implementation: sassImplementation
212
- } : {}
213
- }
214
- }
215
- ]
216
- },
217
- {
218
- test: /\.css$/,
219
- use: [
220
- "style-loader",
221
- {
222
- loader: "css-loader",
223
- options: {
224
- modules: {
225
- localIdentName: "[name]__[local]--[hash:base64:5]"
226
- }
227
- }
228
- }
229
- ]
420
+ ...sassImplementation ? {
421
+ sass: {
422
+ implementation: sassImplementation
230
423
  }
231
- ]
424
+ } : {},
425
+ cssModules: { localIdentName: "[name]__[local]--[hash:base64:5]" }
232
426
  }
233
427
  },
234
- "@storybook/addon-docs",
428
+ "@storybook/addon-essentials",
429
+ "@storybook/addon-storysource",
235
430
  "@storybook/addon-a11y"
236
431
  ];
237
432
  };
238
- function babelDefault() {
433
+ function babelDefault(config) {
434
+ const cwd2 = process.cwd();
435
+ const { file } = findBabelConfig.sync(cwd2, 1);
436
+ if (file) {
437
+ return config;
438
+ }
439
+ console.log(
440
+ "Could not find babel config file, using babel config from @procore/storybook-addon"
441
+ );
239
442
  return createConfigForReact();
240
443
  }
241
444
  var typescript = {
@@ -245,12 +448,6 @@ var typescript = {
245
448
  },
246
449
  reactDocgen: false
247
450
  };
248
- var preset_default = {
249
- addons: addons(),
250
- babelDefault,
251
- typescript,
252
- previewHead: previewHead_default
253
- };
254
451
  // Annotate the CommonJS export names for ESM import in node:
255
452
  0 && (module.exports = {
256
453
  addons,
@@ -8,61 +8,15 @@ declare function export_default(head: any, _options?: Record<PropertyKey, any>,
8
8
  declare const addons: () => (string | {
9
9
  name: string;
10
10
  options: {
11
- rules: {
12
- test: RegExp;
13
- use: (string | {
14
- loader: string;
15
- options: {
16
- modules: {
17
- localIdentName: string;
18
- };
19
- };
20
- } | {
21
- loader: string;
22
- options: {
23
- implementation?: any;
24
- modules?: undefined;
25
- };
26
- })[];
27
- }[];
11
+ cssModules: {
12
+ localIdentName: string;
13
+ };
14
+ sass?: {
15
+ implementation: any;
16
+ } | undefined;
28
17
  };
29
18
  })[];
30
- declare function babelDefault(): {
31
- babelrc: boolean;
32
- cacheCompression: boolean;
33
- cacheDirectory: boolean;
34
- cacheIdentifier: string;
35
- assumptions: {
36
- privateFieldsAsProperties: boolean;
37
- setPublicClassFields: boolean;
38
- };
39
- compact: boolean;
40
- configFile: boolean;
41
- sourceType: string;
42
- targets: string;
43
- plugins: ((string | {
44
- version: string;
45
- })[] | (string | {
46
- loaderMap: {
47
- svg: {
48
- ReactComponent: string;
49
- };
50
- };
51
- })[] | (string | {
52
- minify: boolean;
53
- ssr: boolean;
54
- displayName: boolean;
55
- fileName: boolean;
56
- transpileTemplateLiterals: boolean;
57
- pure: boolean;
58
- })[])[];
59
- presets: (string | (string | {
60
- useBuiltIns: string;
61
- corejs: string;
62
- })[] | (string | {
63
- useBuiltIns: boolean;
64
- })[])[];
65
- };
19
+ declare function babelDefault(config: any): any;
66
20
  declare const typescript: {
67
21
  checkOptions: {
68
22
  check: boolean;
@@ -71,38 +25,4 @@ declare const typescript: {
71
25
  reactDocgen: boolean;
72
26
  };
73
27
 
74
- declare const _default: {
75
- addons: (string | {
76
- name: string;
77
- options: {
78
- rules: {
79
- test: RegExp;
80
- use: (string | {
81
- loader: string;
82
- options: {
83
- modules: {
84
- localIdentName: string;
85
- };
86
- };
87
- } | {
88
- loader: string;
89
- options: {
90
- implementation?: any;
91
- modules?: undefined;
92
- };
93
- })[];
94
- }[];
95
- };
96
- })[];
97
- babelDefault: typeof babelDefault;
98
- typescript: {
99
- checkOptions: {
100
- check: boolean;
101
- exclude: RegExp;
102
- };
103
- reactDocgen: boolean;
104
- };
105
- previewHead: typeof export_default;
106
- };
107
-
108
- export { addons, babelDefault, _default as default, export_default as previewHead, typescript };
28
+ export { addons, babelDefault, export_default as previewHead, typescript };
@@ -8,61 +8,15 @@ declare function export_default(head: any, _options?: Record<PropertyKey, any>,
8
8
  declare const addons: () => (string | {
9
9
  name: string;
10
10
  options: {
11
- rules: {
12
- test: RegExp;
13
- use: (string | {
14
- loader: string;
15
- options: {
16
- modules: {
17
- localIdentName: string;
18
- };
19
- };
20
- } | {
21
- loader: string;
22
- options: {
23
- implementation?: any;
24
- modules?: undefined;
25
- };
26
- })[];
27
- }[];
11
+ cssModules: {
12
+ localIdentName: string;
13
+ };
14
+ sass?: {
15
+ implementation: any;
16
+ } | undefined;
28
17
  };
29
18
  })[];
30
- declare function babelDefault(): {
31
- babelrc: boolean;
32
- cacheCompression: boolean;
33
- cacheDirectory: boolean;
34
- cacheIdentifier: string;
35
- assumptions: {
36
- privateFieldsAsProperties: boolean;
37
- setPublicClassFields: boolean;
38
- };
39
- compact: boolean;
40
- configFile: boolean;
41
- sourceType: string;
42
- targets: string;
43
- plugins: ((string | {
44
- version: string;
45
- })[] | (string | {
46
- loaderMap: {
47
- svg: {
48
- ReactComponent: string;
49
- };
50
- };
51
- })[] | (string | {
52
- minify: boolean;
53
- ssr: boolean;
54
- displayName: boolean;
55
- fileName: boolean;
56
- transpileTemplateLiterals: boolean;
57
- pure: boolean;
58
- })[])[];
59
- presets: (string | (string | {
60
- useBuiltIns: string;
61
- corejs: string;
62
- })[] | (string | {
63
- useBuiltIns: boolean;
64
- })[])[];
65
- };
19
+ declare function babelDefault(config: any): any;
66
20
  declare const typescript: {
67
21
  checkOptions: {
68
22
  check: boolean;
@@ -71,38 +25,4 @@ declare const typescript: {
71
25
  reactDocgen: boolean;
72
26
  };
73
27
 
74
- declare const _default: {
75
- addons: (string | {
76
- name: string;
77
- options: {
78
- rules: {
79
- test: RegExp;
80
- use: (string | {
81
- loader: string;
82
- options: {
83
- modules: {
84
- localIdentName: string;
85
- };
86
- };
87
- } | {
88
- loader: string;
89
- options: {
90
- implementation?: any;
91
- modules?: undefined;
92
- };
93
- })[];
94
- }[];
95
- };
96
- })[];
97
- babelDefault: typeof babelDefault;
98
- typescript: {
99
- checkOptions: {
100
- check: boolean;
101
- exclude: RegExp;
102
- };
103
- reactDocgen: boolean;
104
- };
105
- previewHead: typeof export_default;
106
- };
107
-
108
- export { addons, babelDefault, _default as default, export_default as previewHead, typescript };
28
+ export { addons, babelDefault, export_default as previewHead, typescript };