@repobuddy/storybook 2.0.1 → 2.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.
Files changed (103) hide show
  1. package/esm/index.d.ts +574 -13
  2. package/esm/index.js +491 -12
  3. package/esm/manager/index.d.ts +38 -1
  4. package/esm/manager/index.js +32 -1
  5. package/esm/storybook-addon-tag-badges/index.d.ts +95 -2
  6. package/esm/storybook-addon-tag-badges/index.js +207 -1
  7. package/esm/storybook-dark-mode/index.d.ts +110 -3
  8. package/esm/storybook-dark-mode/index.js +342 -3
  9. package/package.json +4 -12
  10. package/cjs/components/show_html.d.ts +0 -16
  11. package/cjs/components/show_html.js +0 -29
  12. package/cjs/decorators/show_doc_source.d.ts +0 -6
  13. package/cjs/decorators/show_doc_source.js +0 -38
  14. package/cjs/index.d.ts +0 -13
  15. package/cjs/index.js +0 -137
  16. package/cjs/manager/brand_title.d.ts +0 -35
  17. package/cjs/manager/brand_title.js +0 -12
  18. package/cjs/manager/index.d.ts +0 -1
  19. package/cjs/manager/index.js +0 -16
  20. package/cjs/parameters/define_actions_param.d.ts +0 -24
  21. package/cjs/parameters/define_actions_param.js +0 -11
  22. package/cjs/parameters/define_backgrounds_param.d.ts +0 -45
  23. package/cjs/parameters/define_backgrounds_param.js +0 -10
  24. package/cjs/parameters/define_docs_param.d.ts +0 -217
  25. package/cjs/parameters/define_docs_param.js +0 -11
  26. package/cjs/parameters/define_layout_param.d.ts +0 -20
  27. package/cjs/parameters/define_layout_param.js +0 -10
  28. package/cjs/parameters/define_parameters.d.ts +0 -39
  29. package/cjs/parameters/define_parameters.js +0 -9
  30. package/cjs/parameters/define_test_param.d.ts +0 -34
  31. package/cjs/parameters/define_test_param.js +0 -11
  32. package/cjs/parameters/define_viewport_param.d.ts +0 -78
  33. package/cjs/parameters/define_viewport_param.js +0 -11
  34. package/cjs/parameters/story_sort.d.ts +0 -27
  35. package/cjs/parameters/story_sort.js +0 -1
  36. package/cjs/storybook-addon-tag-badges/index.d.ts +0 -2
  37. package/cjs/storybook-addon-tag-badges/index.js +0 -16
  38. package/cjs/storybook-addon-tag-badges/tag_badges.d.ts +0 -41
  39. package/cjs/storybook-addon-tag-badges/tag_badges.js +0 -179
  40. package/cjs/storybook-addon-tag-badges/types.d.ts +0 -9
  41. package/cjs/storybook-addon-tag-badges/types.js +0 -1
  42. package/cjs/storybook-dark-mode/dark_mode_docs_container.d.ts +0 -26
  43. package/cjs/storybook-dark-mode/dark_mode_docs_container.js +0 -23
  44. package/cjs/storybook-dark-mode/define_dark_mode.d.ts +0 -54
  45. package/cjs/storybook-dark-mode/define_dark_mode.js +0 -11
  46. package/cjs/storybook-dark-mode/index.d.ts +0 -3
  47. package/cjs/storybook-dark-mode/index.js +0 -38
  48. package/cjs/storybook-dark-mode/with_dark_mode.d.ts +0 -22
  49. package/cjs/storybook-dark-mode/with_dark_mode.js +0 -54
  50. package/cjs/testing/decorators/when_running_in_test.d.ts +0 -5
  51. package/cjs/testing/decorators/when_running_in_test.js +0 -12
  52. package/cjs/testing/decorators/when_running_in_text.ctx.d.ts +0 -3
  53. package/cjs/testing/decorators/when_running_in_text.ctx.js +0 -10
  54. package/cjs/types.d.ts +0 -41
  55. package/cjs/types.js +0 -1
  56. package/cjs/variants/index.d.ts +0 -1
  57. package/cjs/variants/index.js +0 -8
  58. package/cjs/variants/package.json +0 -3
  59. package/cjs/variants/preset.d.ts +0 -11
  60. package/cjs/variants/preset.js +0 -3
  61. package/esm/components/show_html.d.ts +0 -16
  62. package/esm/components/show_html.js +0 -19
  63. package/esm/decorators/show_doc_source.d.ts +0 -6
  64. package/esm/decorators/show_doc_source.js +0 -28
  65. package/esm/manager/brand_title.d.ts +0 -35
  66. package/esm/manager/brand_title.js +0 -6
  67. package/esm/parameters/define_actions_param.d.ts +0 -24
  68. package/esm/parameters/define_actions_param.js +0 -3
  69. package/esm/parameters/define_backgrounds_param.d.ts +0 -45
  70. package/esm/parameters/define_backgrounds_param.js +0 -3
  71. package/esm/parameters/define_docs_param.d.ts +0 -217
  72. package/esm/parameters/define_docs_param.js +0 -3
  73. package/esm/parameters/define_layout_param.d.ts +0 -20
  74. package/esm/parameters/define_layout_param.js +0 -3
  75. package/esm/parameters/define_parameters.d.ts +0 -39
  76. package/esm/parameters/define_parameters.js +0 -3
  77. package/esm/parameters/define_test_param.d.ts +0 -34
  78. package/esm/parameters/define_test_param.js +0 -3
  79. package/esm/parameters/define_viewport_param.d.ts +0 -78
  80. package/esm/parameters/define_viewport_param.js +0 -3
  81. package/esm/parameters/story_sort.d.ts +0 -27
  82. package/esm/parameters/story_sort.js +0 -0
  83. package/esm/storybook-addon-tag-badges/tag_badges.d.ts +0 -41
  84. package/esm/storybook-addon-tag-badges/tag_badges.js +0 -189
  85. package/esm/storybook-addon-tag-badges/types.d.ts +0 -9
  86. package/esm/storybook-addon-tag-badges/types.js +0 -0
  87. package/esm/storybook-dark-mode/dark_mode_docs_container.d.ts +0 -26
  88. package/esm/storybook-dark-mode/dark_mode_docs_container.js +0 -21
  89. package/esm/storybook-dark-mode/define_dark_mode.d.ts +0 -54
  90. package/esm/storybook-dark-mode/define_dark_mode.js +0 -3
  91. package/esm/storybook-dark-mode/with_dark_mode.d.ts +0 -22
  92. package/esm/storybook-dark-mode/with_dark_mode.js +0 -46
  93. package/esm/testing/decorators/when_running_in_test.d.ts +0 -5
  94. package/esm/testing/decorators/when_running_in_test.js +0 -6
  95. package/esm/testing/decorators/when_running_in_text.ctx.d.ts +0 -3
  96. package/esm/testing/decorators/when_running_in_text.ctx.js +0 -4
  97. package/esm/types.d.ts +0 -41
  98. package/esm/types.js +0 -0
  99. package/esm/variants/index.d.ts +0 -1
  100. package/esm/variants/index.js +0 -2
  101. package/esm/variants/package.json +0 -3
  102. package/esm/variants/preset.d.ts +0 -11
  103. package/esm/variants/preset.js +0 -1
package/esm/index.js CHANGED
@@ -1,12 +1,491 @@
1
- export * from "@repobuddy/test";
2
- export * from "./components/show_html.tsx";
3
- export * from "./decorators/show_doc_source.tsx";
4
- export * from "./parameters/define_actions_param.ts";
5
- export * from "./parameters/define_backgrounds_param.ts";
6
- export * from "./parameters/define_docs_param.ts";
7
- export * from "./parameters/define_layout_param.ts";
8
- export * from "./parameters/define_parameters.ts";
9
- export * from "./parameters/define_test_param.ts";
10
- export * from "./parameters/define_viewport_param.ts";
11
- export * from "./parameters/story_sort.ts";
12
- export * from "./testing/decorators/when_running_in_test.tsx";
1
+ import { isRunningInTest } from "@repobuddy/test";
2
+ import { prettify } from "htmlfy";
3
+ import { useEffect, useState } from "react";
4
+ import { SyntaxHighlighter } from "storybook/internal/components";
5
+ import { addons } from "storybook/preview-api";
6
+ import { ThemeProvider, convert, themes } from "storybook/theming";
7
+
8
+ export * from "@repobuddy/test"
9
+
10
+ //#region rolldown:runtime
11
+ var __create = Object.create;
12
+ var __defProp = Object.defineProperty;
13
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
14
+ var __getOwnPropNames = Object.getOwnPropertyNames;
15
+ var __getProtoOf = Object.getPrototypeOf;
16
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
17
+ var __commonJS = (cb, mod) => function() {
18
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
23
+ key = keys[i];
24
+ if (!__hasOwnProp.call(to, key) && key !== except) {
25
+ __defProp(to, key, {
26
+ get: ((k) => from[k]).bind(null, key),
27
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
28
+ });
29
+ }
30
+ }
31
+ }
32
+ return to;
33
+ };
34
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
35
+ value: mod,
36
+ enumerable: true
37
+ }) : target, mod));
38
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
39
+ if (typeof require !== "undefined") return require.apply(this, arguments);
40
+ throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function.");
41
+ });
42
+
43
+ //#endregion
44
+ //#region ../../node_modules/.pnpm/react@19.2.0/node_modules/react/cjs/react-jsx-runtime.development.js
45
+ /**
46
+ * @license React
47
+ * react-jsx-runtime.development.js
48
+ *
49
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
50
+ *
51
+ * This source code is licensed under the MIT license found in the
52
+ * LICENSE file in the root directory of this source tree.
53
+ */
54
+ var require_react_jsx_runtime_development = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/react@19.2.0/node_modules/react/cjs/react-jsx-runtime.development.js": ((exports) => {
55
+ (function() {
56
+ function getComponentNameFromType(type) {
57
+ if (null == type) return null;
58
+ if ("function" === typeof type) return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
59
+ if ("string" === typeof type) return type;
60
+ switch (type) {
61
+ case REACT_FRAGMENT_TYPE: return "Fragment";
62
+ case REACT_PROFILER_TYPE: return "Profiler";
63
+ case REACT_STRICT_MODE_TYPE: return "StrictMode";
64
+ case REACT_SUSPENSE_TYPE: return "Suspense";
65
+ case REACT_SUSPENSE_LIST_TYPE: return "SuspenseList";
66
+ case REACT_ACTIVITY_TYPE: return "Activity";
67
+ }
68
+ if ("object" === typeof type) switch ("number" === typeof type.tag && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), type.$$typeof) {
69
+ case REACT_PORTAL_TYPE: return "Portal";
70
+ case REACT_CONTEXT_TYPE: return type.displayName || "Context";
71
+ case REACT_CONSUMER_TYPE: return (type._context.displayName || "Context") + ".Consumer";
72
+ case REACT_FORWARD_REF_TYPE:
73
+ var innerType = type.render;
74
+ type = type.displayName;
75
+ type || (type = innerType.displayName || innerType.name || "", type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef");
76
+ return type;
77
+ case REACT_MEMO_TYPE: return innerType = type.displayName || null, null !== innerType ? innerType : getComponentNameFromType(type.type) || "Memo";
78
+ case REACT_LAZY_TYPE:
79
+ innerType = type._payload;
80
+ type = type._init;
81
+ try {
82
+ return getComponentNameFromType(type(innerType));
83
+ } catch (x) {}
84
+ }
85
+ return null;
86
+ }
87
+ function testStringCoercion(value) {
88
+ return "" + value;
89
+ }
90
+ function checkKeyStringCoercion(value) {
91
+ try {
92
+ testStringCoercion(value);
93
+ var JSCompiler_inline_result = !1;
94
+ } catch (e) {
95
+ JSCompiler_inline_result = !0;
96
+ }
97
+ if (JSCompiler_inline_result) {
98
+ JSCompiler_inline_result = console;
99
+ var JSCompiler_temp_const = JSCompiler_inline_result.error;
100
+ var JSCompiler_inline_result$jscomp$0 = "function" === typeof Symbol && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
101
+ JSCompiler_temp_const.call(JSCompiler_inline_result, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", JSCompiler_inline_result$jscomp$0);
102
+ return testStringCoercion(value);
103
+ }
104
+ }
105
+ function getTaskName(type) {
106
+ if (type === REACT_FRAGMENT_TYPE) return "<>";
107
+ if ("object" === typeof type && null !== type && type.$$typeof === REACT_LAZY_TYPE) return "<...>";
108
+ try {
109
+ var name = getComponentNameFromType(type);
110
+ return name ? "<" + name + ">" : "<...>";
111
+ } catch (x) {
112
+ return "<...>";
113
+ }
114
+ }
115
+ function getOwner() {
116
+ var dispatcher = ReactSharedInternals.A;
117
+ return null === dispatcher ? null : dispatcher.getOwner();
118
+ }
119
+ function UnknownOwner() {
120
+ return Error("react-stack-top-frame");
121
+ }
122
+ function hasValidKey(config) {
123
+ if (hasOwnProperty.call(config, "key")) {
124
+ var getter = Object.getOwnPropertyDescriptor(config, "key").get;
125
+ if (getter && getter.isReactWarning) return !1;
126
+ }
127
+ return void 0 !== config.key;
128
+ }
129
+ function defineKeyPropWarningGetter(props, displayName) {
130
+ function warnAboutAccessingKey() {
131
+ specialPropKeyWarningShown || (specialPropKeyWarningShown = !0, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", displayName));
132
+ }
133
+ warnAboutAccessingKey.isReactWarning = !0;
134
+ Object.defineProperty(props, "key", {
135
+ get: warnAboutAccessingKey,
136
+ configurable: !0
137
+ });
138
+ }
139
+ function elementRefGetterWithDeprecationWarning() {
140
+ var componentName = getComponentNameFromType(this.type);
141
+ didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."));
142
+ componentName = this.props.ref;
143
+ return void 0 !== componentName ? componentName : null;
144
+ }
145
+ function ReactElement(type, key, props, owner, debugStack, debugTask) {
146
+ var refProp = props.ref;
147
+ type = {
148
+ $$typeof: REACT_ELEMENT_TYPE,
149
+ type,
150
+ key,
151
+ props,
152
+ _owner: owner
153
+ };
154
+ null !== (void 0 !== refProp ? refProp : null) ? Object.defineProperty(type, "ref", {
155
+ enumerable: !1,
156
+ get: elementRefGetterWithDeprecationWarning
157
+ }) : Object.defineProperty(type, "ref", {
158
+ enumerable: !1,
159
+ value: null
160
+ });
161
+ type._store = {};
162
+ Object.defineProperty(type._store, "validated", {
163
+ configurable: !1,
164
+ enumerable: !1,
165
+ writable: !0,
166
+ value: 0
167
+ });
168
+ Object.defineProperty(type, "_debugInfo", {
169
+ configurable: !1,
170
+ enumerable: !1,
171
+ writable: !0,
172
+ value: null
173
+ });
174
+ Object.defineProperty(type, "_debugStack", {
175
+ configurable: !1,
176
+ enumerable: !1,
177
+ writable: !0,
178
+ value: debugStack
179
+ });
180
+ Object.defineProperty(type, "_debugTask", {
181
+ configurable: !1,
182
+ enumerable: !1,
183
+ writable: !0,
184
+ value: debugTask
185
+ });
186
+ Object.freeze && (Object.freeze(type.props), Object.freeze(type));
187
+ return type;
188
+ }
189
+ function jsxDEVImpl(type, config, maybeKey, isStaticChildren, debugStack, debugTask) {
190
+ var children = config.children;
191
+ if (void 0 !== children) if (isStaticChildren) if (isArrayImpl(children)) {
192
+ for (isStaticChildren = 0; isStaticChildren < children.length; isStaticChildren++) validateChildKeys(children[isStaticChildren]);
193
+ Object.freeze && Object.freeze(children);
194
+ } else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
195
+ else validateChildKeys(children);
196
+ if (hasOwnProperty.call(config, "key")) {
197
+ children = getComponentNameFromType(type);
198
+ var keys = Object.keys(config).filter(function(k) {
199
+ return "key" !== k;
200
+ });
201
+ isStaticChildren = 0 < keys.length ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
202
+ didWarnAboutKeySpread[children + isStaticChildren] || (keys = 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", isStaticChildren, children, keys, children), didWarnAboutKeySpread[children + isStaticChildren] = !0);
203
+ }
204
+ children = null;
205
+ void 0 !== maybeKey && (checkKeyStringCoercion(maybeKey), children = "" + maybeKey);
206
+ hasValidKey(config) && (checkKeyStringCoercion(config.key), children = "" + config.key);
207
+ if ("key" in config) {
208
+ maybeKey = {};
209
+ for (var propName in config) "key" !== propName && (maybeKey[propName] = config[propName]);
210
+ } else maybeKey = config;
211
+ children && defineKeyPropWarningGetter(maybeKey, "function" === typeof type ? type.displayName || type.name || "Unknown" : type);
212
+ return ReactElement(type, children, maybeKey, getOwner(), debugStack, debugTask);
213
+ }
214
+ function validateChildKeys(node) {
215
+ isValidElement(node) ? node._store && (node._store.validated = 1) : "object" === typeof node && null !== node && node.$$typeof === REACT_LAZY_TYPE && ("fulfilled" === node._payload.status ? isValidElement(node._payload.value) && node._payload.value._store && (node._payload.value._store.validated = 1) : node._store && (node._store.validated = 1));
216
+ }
217
+ function isValidElement(object) {
218
+ return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
219
+ }
220
+ var React = __require("react"), REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = Symbol.for("react.activity"), REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), ReactSharedInternals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, hasOwnProperty = Object.prototype.hasOwnProperty, isArrayImpl = Array.isArray, createTask = console.createTask ? console.createTask : function() {
221
+ return null;
222
+ };
223
+ React = { react_stack_bottom_frame: function(callStackForError) {
224
+ return callStackForError();
225
+ } };
226
+ var specialPropKeyWarningShown;
227
+ var didWarnAboutElementRef = {};
228
+ var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(React, UnknownOwner)();
229
+ var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
230
+ var didWarnAboutKeySpread = {};
231
+ exports.Fragment = REACT_FRAGMENT_TYPE;
232
+ exports.jsx = function(type, config, maybeKey) {
233
+ var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
234
+ return jsxDEVImpl(type, config, maybeKey, !1, trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack, trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask);
235
+ };
236
+ exports.jsxs = function(type, config, maybeKey) {
237
+ var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
238
+ return jsxDEVImpl(type, config, maybeKey, !0, trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack, trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask);
239
+ };
240
+ })();
241
+ }) });
242
+
243
+ //#endregion
244
+ //#region ../../node_modules/.pnpm/react@19.2.0/node_modules/react/jsx-runtime.js
245
+ var require_jsx_runtime = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/react@19.2.0/node_modules/react/jsx-runtime.js": ((exports, module) => {
246
+ module.exports = require_react_jsx_runtime_development();
247
+ }) });
248
+
249
+ //#endregion
250
+ //#region src/components/show_html.tsx
251
+ var import_jsx_runtime = /* @__PURE__ */ __toESM(require_jsx_runtime());
252
+ /**
253
+ * A component that displays the HTML of a subject element.
254
+ * Uses `htmlfy` internally to format and prettify the HTML output.
255
+ *
256
+ * @param selector - CSS selector to find the subject element. Defaults to '[data-testid="subject"]'
257
+ * @param config - Configuration options passed to htmlfy's prettify function
258
+ * @param props - Additional props (className, style) passed to the pre element
259
+ * @returns A pre element containing the formatted HTML
260
+ */
261
+ function ShowHtml({ selector = "[data-testid=\"subject\"]", config, ...props }) {
262
+ const [html, setHtml] = useState("");
263
+ useEffect(() => {
264
+ const subject = document.querySelector(selector);
265
+ if (subject) setHtml(prettify(subject.outerHTML, {
266
+ tag_wrap: 40,
267
+ ...config
268
+ }));
269
+ else setHtml("No subject found");
270
+ }, [selector]);
271
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", {
272
+ ...props,
273
+ children: html
274
+ });
275
+ }
276
+
277
+ //#endregion
278
+ //#region src/decorators/show_doc_source.tsx
279
+ const channel = addons.getChannel();
280
+ /**
281
+ * A decorator that shows the source code of a story above the rendered story.
282
+ * The source code is taken from the story's `parameters.docs.source.code`.
283
+ */
284
+ function showDocSource() {
285
+ return (Story, { parameters: { docs, darkMode } }) => {
286
+ const storedItem = window.localStorage.getItem("sb-addon-themes-3");
287
+ const current = typeof storedItem === "string" ? JSON.parse(storedItem).current : darkMode?.current;
288
+ const [isDark, setIsDark] = useState((darkMode?.stylePreview && current === "dark") ?? false);
289
+ useEffect(() => {
290
+ channel.on("DARK_MODE", setIsDark);
291
+ return () => channel.off("DARK_MODE", setIsDark);
292
+ }, []);
293
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeProvider, {
294
+ theme: convert(docs?.theme ?? (isDark ? themes.dark : themes.light)),
295
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
296
+ style: {
297
+ display: "flex",
298
+ flexDirection: "column",
299
+ gap: "1rem"
300
+ },
301
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SyntaxHighlighter, {
302
+ language: docs?.source?.language,
303
+ children: docs?.source?.code
304
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Story, {})]
305
+ })
306
+ });
307
+ };
308
+ }
309
+
310
+ //#endregion
311
+ //#region src/parameters/define_actions_param.ts
312
+ /**
313
+ * Defines actions parameters for Storybook stories.
314
+ *
315
+ * @see https://storybook.js.org/docs/essentials/actions#parameters
316
+ *
317
+ * @param actions - Configuration for actions parameters
318
+ * @returns An object containing the actions parameter configuration
319
+ */
320
+ function defineActionsParam(actions) {
321
+ return { actions };
322
+ }
323
+
324
+ //#endregion
325
+ //#region src/parameters/define_backgrounds_param.ts
326
+ /**
327
+ * Defines backgrounds parameters for Storybook stories.
328
+ *
329
+ * @param backgrounds - The backgrounds configuration
330
+ * @returns An object containing the backgrounds parameter configuration
331
+ */
332
+ const defineBackgroundsParam = (backgrounds) => ({ backgrounds });
333
+
334
+ //#endregion
335
+ //#region src/parameters/define_docs_param.ts
336
+ /**
337
+ * Defines docs parameters for Storybook stories.
338
+ *
339
+ * @param docs - Configuration for docs parameters including options for:
340
+ * - Controls display and sorting
341
+ * - Story rendering (autoplay, height, inline vs iframe)
342
+ * - And other docs-related settings
343
+ * @returns An object containing the docs parameter configuration
344
+ *
345
+ * @example
346
+ * ```ts
347
+ * import { defineDocsParam } from '@repobuddy/storybook'
348
+ *
349
+ * export default {
350
+ * parameters: defineDocsParam({
351
+ * controls: {
352
+ * sort: 'alpha',
353
+ * exclude: ['internal*']
354
+ * },
355
+ * story: {
356
+ * inline: true,
357
+ * height: '400px'
358
+ * }
359
+ * })
360
+ * }
361
+ * ```
362
+ */
363
+ function defineDocsParam(docs) {
364
+ return { docs };
365
+ }
366
+
367
+ //#endregion
368
+ //#region src/parameters/define_layout_param.ts
369
+ /**
370
+ * Helper function to define the layout parameter for a story
371
+ *
372
+ * @see https://storybook.js.org/docs/api/parameters#layout
373
+ *
374
+ * @param layout - The layout type to use ('padded', 'fullscreen', or 'centered')
375
+ * @returns An object containing the layout parameter
376
+ * @example
377
+ * ```ts
378
+ * export const MyStory = {
379
+ * parameters: defineLayoutParam('centered')
380
+ * }
381
+ * ```
382
+ */
383
+ const defineLayoutParam = (layout) => ({ layout });
384
+
385
+ //#endregion
386
+ //#region src/parameters/define_parameters.ts
387
+ /**
388
+ * Defines parameters for Storybook stories, combining built-in parameters with custom ones.
389
+ *
390
+ * @param parameters - Configuration object containing both built-in Storybook parameters and custom parameters
391
+ * @returns The combined parameters object
392
+ *
393
+ * @example
394
+ * ```ts
395
+ * import { defineParameters } from '@repobuddy/storybook'
396
+ *
397
+ * export default {
398
+ * parameters: defineParameters({
399
+ * // Built-in parameters
400
+ * layout: 'centered',
401
+ * backgrounds: {
402
+ * default: 'light',
403
+ * values: [
404
+ * { name: 'light', value: '#ffffff' },
405
+ * { name: 'dark', value: '#333333' }
406
+ * ]
407
+ * },
408
+ * // Custom parameters
409
+ * myCustomParam: {
410
+ * someValue: true
411
+ * }
412
+ * })
413
+ * }
414
+ * ```
415
+ */
416
+ function defineParameters(param, ...rest) {
417
+ return rest.reduce((acc, param$1) => Object.assign(acc, param$1), param);
418
+ }
419
+
420
+ //#endregion
421
+ //#region src/parameters/define_test_param.ts
422
+ /**
423
+ * Defines test parameters for Storybook stories.
424
+ *
425
+ * @see https://storybook.js.org/docs/api/parameters#test
426
+ *
427
+ * @param test - Configuration for test parameters
428
+ * @returns An object containing the test parameter configuration
429
+ *
430
+ * @example
431
+ * defineTestParam({
432
+ * clearMocks: true,
433
+ * mockReset: true,
434
+ * restoreMocks: true,
435
+ * dangerouslyIgnoreUnhandledErrors: true
436
+ * })
437
+ */
438
+ function defineTestParam(test) {
439
+ return { test };
440
+ }
441
+
442
+ //#endregion
443
+ //#region src/parameters/define_viewport_param.ts
444
+ /**
445
+ * Defines viewport parameters for Storybook stories.
446
+ *
447
+ * @see https://storybook.js.org/docs/api/parameters#viewport
448
+ *
449
+ * @param viewport - Configuration for viewport parameters including:
450
+ * - viewports: Custom viewport definitions
451
+ * - defaultViewport: The default viewport to use
452
+ * - defaultOrientation: Default orientation (landscape/portrait)
453
+ * - disabled: Whether viewport controls are disabled
454
+ * @returns An object containing the viewport parameter configuration
455
+ *
456
+ * @example
457
+ * ```ts
458
+ * defineViewportParam({
459
+ * viewports: {
460
+ * mobile: {
461
+ * name: 'Mobile',
462
+ * styles: { width: '320px', height: '568px' },
463
+ * type: 'mobile'
464
+ * }
465
+ * },
466
+ * defaultViewport: 'mobile',
467
+ * defaultOrientation: 'portrait'
468
+ * })
469
+ * ```
470
+ */
471
+ function defineViewportParam(viewport) {
472
+ return { viewport };
473
+ }
474
+
475
+ //#endregion
476
+ //#region src/testing/decorators/when_running_in_text.ctx.ts
477
+ const ctx = { isRunningInTest };
478
+
479
+ //#endregion
480
+ //#region src/testing/decorators/when_running_in_test.tsx
481
+ /**
482
+ * executes the specified decorator or handler if the code is running in test.
483
+ */
484
+ function whenRunningInTest(decoratorOrHandler) {
485
+ return function RunInTest(Story, context) {
486
+ return ctx.isRunningInTest() ? decoratorOrHandler(Story, context) ?? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Story, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Story, {});
487
+ };
488
+ }
489
+
490
+ //#endregion
491
+ export { ShowHtml, defineActionsParam, defineBackgroundsParam, defineDocsParam, defineLayoutParam, defineParameters, defineTestParam, defineViewportParam, showDocSource, whenRunningInTest };
@@ -1 +1,38 @@
1
- export * from './brand_title.js';
1
+ //#region src/manager/brand_title.d.ts
2
+ interface BrandTitleOptions {
3
+ /**
4
+ * The title to display in the brand title.
5
+ * It can be a simple string or raw HTML.
6
+ */
7
+ title: string;
8
+ /**
9
+ * The logo to display in the brand title.
10
+ * It can be a simple string or raw HTML (e.g. `<svg>`).
11
+ */
12
+ logo?: string | undefined;
13
+ }
14
+ /**
15
+ * Creates a brand title element for the Storybook manager UI.
16
+ *
17
+ * @param options - The options for customizing the brand title
18
+ * @param options.title - The title text or HTML to display
19
+ * @param options.logo - Optional logo HTML to display before the title
20
+ * @returns An HTML string containing the brand title element
21
+ *
22
+ * @example
23
+ *
24
+ * ```ts
25
+ * import { brandTitle } from '@repobuddy/storybook'
26
+ * import { addons } from 'storybook/manager-api'
27
+ *
28
+ * addons.setConfig({
29
+ * brandTitle: brandTitle({
30
+ * title: 'My Storybook',
31
+ * logo: '<img src="logo.png" alt="Logo" width="24" height="24">'
32
+ * })
33
+ * })
34
+ * ```
35
+ */
36
+ declare function brandTitle(options: BrandTitleOptions): string;
37
+ //#endregion
38
+ export { BrandTitleOptions, brandTitle };
@@ -1 +1,32 @@
1
- export * from "./brand_title.js";
1
+ //#region src/manager/brand_title.ts
2
+ /**
3
+ * Creates a brand title element for the Storybook manager UI.
4
+ *
5
+ * @param options - The options for customizing the brand title
6
+ * @param options.title - The title text or HTML to display
7
+ * @param options.logo - Optional logo HTML to display before the title
8
+ * @returns An HTML string containing the brand title element
9
+ *
10
+ * @example
11
+ *
12
+ * ```ts
13
+ * import { brandTitle } from '@repobuddy/storybook'
14
+ * import { addons } from 'storybook/manager-api'
15
+ *
16
+ * addons.setConfig({
17
+ * brandTitle: brandTitle({
18
+ * title: 'My Storybook',
19
+ * logo: '<img src="logo.png" alt="Logo" width="24" height="24">'
20
+ * })
21
+ * })
22
+ * ```
23
+ */
24
+ function brandTitle(options) {
25
+ return `<span style="display: flex; align-items: center; gap: 2px;">
26
+ ${options.logo ?? ""}
27
+ ${options.title}
28
+ </span>`;
29
+ }
30
+
31
+ //#endregion
32
+ export { brandTitle };
@@ -1,2 +1,95 @@
1
- export * from './tag_badges.js';
2
- export type * from './types.js';
1
+ import { TagBadgeParameters } from "storybook-addon-tag-badges/manager-helpers";
2
+ import { Args, Meta as Meta$1, StoryObj as StoryObj$1 } from "@storybook/react-vite";
3
+
4
+ //#region src/storybook-addon-tag-badges/tag_badges.d.ts
5
+ type TagBadgeParameter = TagBadgeParameters[0];
6
+ /**
7
+ * Type representing the names of predefined tags used in Storybook stories.
8
+ */
9
+ type TagNames = 'editor' | 'new' | 'beta' | 'props' | 'deprecated' | 'outdated' | 'danger' | 'todo' | 'code-only' | 'snapshot' | 'unit' | 'integration' | 'keyboard' | 'internal';
10
+ /**
11
+ * Configuration for story tag badges that appear in the Storybook sidebar.
12
+ * Each badge is associated with a specific tag and displays an emoji with a tooltip.
13
+ *
14
+ * The badges help visually identify stories with certain characteristics:
15
+ * - ✏️ Editor - Stories with live editor
16
+ * - 🆕 New - Recently added stories
17
+ * - 🅱️ Beta - Stories for features in beta
18
+ * - 🪦 Deprecated - Stories for deprecated features
19
+ * - ⚠️ Outdated - Stories that need updating
20
+ * - 🚨 Danger - Stories demonstrating dangerous patterns
21
+ * - 📋 Todo - Stories marked as todo/incomplete
22
+ * - 📝 Code Only - Stories without visual examples
23
+ * - 📸 Snapshot - Stories with snapshot tests
24
+ * - 🧪 Unit - Stories with unit tests
25
+ * - 🔗 Integration - Stories with integration tests
26
+ *
27
+ * Also includes the default version badge from `storybook-addon-tag-badges`.
28
+ */
29
+ declare const editorBadge: TagBadgeParameter;
30
+ declare const newBadge: TagBadgeParameter;
31
+ declare const betaBadge: TagBadgeParameter;
32
+ declare const propsBadge: TagBadgeParameter;
33
+ declare const deprecatedBadge: TagBadgeParameter;
34
+ declare const outdatedBadge: TagBadgeParameter;
35
+ declare const dangerBadge: TagBadgeParameter;
36
+ declare const todoBadge: TagBadgeParameter;
37
+ declare const codeOnlyBadge: TagBadgeParameter;
38
+ declare const snapshotBadge: TagBadgeParameter;
39
+ declare const unitBadge: TagBadgeParameter;
40
+ declare const integrationBadge: TagBadgeParameter;
41
+ declare const keyboardBadge: TagBadgeParameter;
42
+ declare const internalBadge: TagBadgeParameter;
43
+ declare const tagBadges: TagBadgeParameters;
44
+ //#endregion
45
+ //#region src/types.d.ts
46
+ /**
47
+ * Extends the Storybook Meta type with custom tag types
48
+ * @template TCmpOrArgs - The component or args type
49
+ * @template M - The base Meta type
50
+ * @template E - The extension type containing tagType
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * // Create a generic Meta type for a project
55
+ * type Meta<TCmpOrArgs = Args> = ExtendMeta<TCmpOrArgs, Meta<TCmpOrArgs>, { tagType: 'tag1' | 'tag2' }>
56
+ *
57
+ * // Create a specific Meta type for a component
58
+ * type Meta = ExtendMeta<typeof Component, Meta<typeof Component>, { tagType: 'tag1' | 'tag2' }>
59
+ * ```
60
+ */
61
+ type ExtendMeta<TCmpOrArgs, M extends Meta$1<TCmpOrArgs>, E extends {
62
+ tag: string;
63
+ }> = Omit<M, 'tags'> & {
64
+ tags?: Array<E['tag'] | (string & {})> | undefined;
65
+ };
66
+ /**
67
+ * Extends the Storybook StoryObj type with custom tag types
68
+ * @template TMetaOrCmpOrArgs - The meta, component or args type
69
+ * @template S - The base StoryObj type
70
+ * @template E - The extension type containing tagType
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * // Create a generic StoryObj type for a project
75
+ * type StoryObj<TMetaOrCmpOrArgs = Args> = ExtendStoryObj<TMetaOrCmpOrArgs, StoryObj<TMetaOrCmpOrArgs>, { tagType: 'tag1' | 'tag2' }>
76
+ *
77
+ * // Create a specific StoryObj type for a component
78
+ * type StoryObj = ExtendStoryObj<typeof Component, StoryObj<typeof Component>, { tagType: 'tag1' | 'tag2' }>
79
+ * ```
80
+ */
81
+ type ExtendStoryObj<TMetaOrCmpOrArgs, S extends StoryObj$1<TMetaOrCmpOrArgs>, E extends {
82
+ tag: string;
83
+ }> = Omit<S, 'tags'> & {
84
+ tags?: Array<E['tag'] | (string & {})> | undefined;
85
+ };
86
+ //#endregion
87
+ //#region src/storybook-addon-tag-badges/types.d.ts
88
+ type Meta<TCmpOrArgs = Args> = ExtendMeta<TCmpOrArgs, Meta$1<TCmpOrArgs>, {
89
+ tag: TagNames;
90
+ }>;
91
+ type StoryObj<TMetaOrCmpOrArgs = Args> = ExtendStoryObj<TMetaOrCmpOrArgs, StoryObj$1<TMetaOrCmpOrArgs>, {
92
+ tag: TagNames;
93
+ }>;
94
+ //#endregion
95
+ export { Meta, StoryObj, TagNames, betaBadge, codeOnlyBadge, dangerBadge, deprecatedBadge, editorBadge, integrationBadge, internalBadge, keyboardBadge, newBadge, outdatedBadge, propsBadge, snapshotBadge, tagBadges, todoBadge, unitBadge };