@storybook/addon-docs 10.5.0-alpha.6 → 10.5.0-alpha.8
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/_browser-chunks/{Color-MQE2NRD4.js → Color-AVMI7ZZZ.js} +3 -3
- package/dist/_browser-chunks/{DocsRenderer-LL677BLK.js → DocsRenderer-JROSPFPF.js} +1 -1
- package/dist/_browser-chunks/{chunk-S4QKU6I5.js → chunk-6Z2O5XYJ.js} +2 -2
- package/dist/_browser-chunks/{chunk-SL3VIQZ3.js → chunk-UAWMPV5J.js} +5 -1
- package/dist/_node-chunks/{chunk-EVYDPJBT.js → chunk-NDIMOQRQ.js} +6 -6
- package/dist/_node-chunks/{chunk-HPMS3VGC.js → chunk-Q33Y654V.js} +198 -198
- package/dist/_node-chunks/{chunk-7GHLECTU.js → chunk-RDCEJST6.js} +6 -6
- package/dist/_node-chunks/{chunk-5KAVE6JH.js → chunk-X327Z4QW.js} +18 -9
- package/dist/_node-chunks/{mdx-plugin-SQGKMDRV.js → mdx-plugin-XDOSSZCW.js} +11 -11
- package/dist/_node-chunks/{rehype-external-links-55SSEHL7.js → rehype-external-links-2RDYL6C3.js} +9 -9
- package/dist/_node-chunks/{rehype-slug-2JQMJ6CC.js → rehype-slug-D2I7KZ4I.js} +8 -8
- package/dist/angular/index.js +1 -1
- package/dist/blocks.d.ts +1 -1
- package/dist/blocks.js +428 -143
- package/dist/ember/index.js +1 -1
- package/dist/index.d.ts +14 -2
- package/dist/index.js +2 -2
- package/dist/manager.js +33 -25
- package/dist/mdx-loader.js +10 -10
- package/dist/preset.js +456 -31
- package/dist/preview.js +2 -2
- package/package.json +4 -4
package/dist/blocks.js
CHANGED
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
curriedTransparentize$1,
|
|
12
12
|
rgba
|
|
13
13
|
} from "./_browser-chunks/chunk-SPXYZZB5.js";
|
|
14
|
-
import "./_browser-chunks/chunk-
|
|
14
|
+
import "./_browser-chunks/chunk-UAWMPV5J.js";
|
|
15
15
|
|
|
16
16
|
// src/blocks/components/ArgsTable/ArgsTable.tsx
|
|
17
|
-
import React23 from "react";
|
|
17
|
+
import React23, { useCallback as useCallback6, useEffect as useEffect8, useRef as useRef5, useState as useState11 } from "react";
|
|
18
18
|
import { once } from "storybook/internal/client-logger";
|
|
19
19
|
import { Button as Button5, Link as Link3, ResetWrapper } from "storybook/internal/components";
|
|
20
20
|
import { includeConditionalArg } from "storybook/internal/csf";
|
|
@@ -2433,7 +2433,7 @@ var { window: globalWindow } = globalThis, Wrapper4 = styled8.div(({ theme }) =>
|
|
|
2433
2433
|
onChange,
|
|
2434
2434
|
argType
|
|
2435
2435
|
}) => {
|
|
2436
|
-
let data = useMemo(() => value && cloneDeep(value), [value]), hasData = data != null, [showRaw, setShowRaw] = useState4(!hasData), [parseError, setParseError] = useState4(null), readonly = !!argType?.table?.readonly, updateRaw = useCallback3(
|
|
2436
|
+
let data = useMemo(() => value && cloneDeep(value), [value]), hasData = data != null, [showRaw, setShowRaw] = useState4(!hasData), hadDataRef = useRef3(hasData), [parseError, setParseError] = useState4(null), readonly = !!argType?.table?.readonly, updateRaw = useCallback3(
|
|
2437
2437
|
(raw) => {
|
|
2438
2438
|
try {
|
|
2439
2439
|
raw && onChange(JSON.parse(raw)), setParseError(null);
|
|
@@ -2444,7 +2444,11 @@ var { window: globalWindow } = globalThis, Wrapper4 = styled8.div(({ theme }) =>
|
|
|
2444
2444
|
[onChange]
|
|
2445
2445
|
), [forceVisible, setForceVisible] = useState4(!1), onForceVisible = useCallback3(() => {
|
|
2446
2446
|
onChange({}), setForceVisible(!0);
|
|
2447
|
-
}, [onChange, setForceVisible])
|
|
2447
|
+
}, [onChange, setForceVisible]);
|
|
2448
|
+
useEffect4(() => {
|
|
2449
|
+
!hadDataRef.current && hasData && showRaw && !forceVisible && setShowRaw(!1), hadDataRef.current = hasData;
|
|
2450
|
+
}, [forceVisible, hasData, showRaw]);
|
|
2451
|
+
let htmlElRef = useRef3(null);
|
|
2448
2452
|
useEffect4(() => {
|
|
2449
2453
|
forceVisible && htmlElRef.current && htmlElRef.current.select();
|
|
2450
2454
|
}, [forceVisible]);
|
|
@@ -2770,7 +2774,7 @@ var FilesControl = ({
|
|
|
2770
2774
|
};
|
|
2771
2775
|
|
|
2772
2776
|
// src/blocks/controls/index.tsx
|
|
2773
|
-
var LazyColorControl = lazy(() => import("./_browser-chunks/Color-
|
|
2777
|
+
var LazyColorControl = lazy(() => import("./_browser-chunks/Color-AVMI7ZZZ.js")), ColorControl = (props) => React15.createElement(Suspense, { fallback: React15.createElement("div", null) }, React15.createElement(LazyColorControl, { ...props }));
|
|
2774
2778
|
|
|
2775
2779
|
// src/blocks/components/ArgsTable/ArgControl.tsx
|
|
2776
2780
|
var Controls2 = {
|
|
@@ -3438,14 +3442,20 @@ var sortFns = {
|
|
|
3438
3442
|
isLoading,
|
|
3439
3443
|
storyId,
|
|
3440
3444
|
controlsId
|
|
3441
|
-
} = props;
|
|
3445
|
+
} = props, { rows, args, globals } = "rows" in props ? props : { rows: void 0, args: void 0, globals: void 0 }, isResettingRef = useRef5(!1), [isResetting, setIsResetting] = useState11(!1);
|
|
3446
|
+
useEffect8(() => {
|
|
3447
|
+
isResettingRef.current = !1, setIsResetting(!1);
|
|
3448
|
+
}, [args]);
|
|
3449
|
+
let handleResetClick = useCallback6(() => {
|
|
3450
|
+
!isResettingRef.current && resetArgs && (isResettingRef.current = !0, setIsResetting(!0), resetArgs());
|
|
3451
|
+
}, [resetArgs]);
|
|
3442
3452
|
if ("error" in props) {
|
|
3443
3453
|
let { error } = props;
|
|
3444
3454
|
return React23.createElement(EmptyBlock, null, error, "\xA0", React23.createElement(Link3, { href: "http://storybook.js.org/docs/?ref=ui", target: "_blank", withArrow: !0 }, React23.createElement(DocumentIcon2, null), " Read the docs"));
|
|
3445
3455
|
}
|
|
3446
3456
|
if (isLoading)
|
|
3447
3457
|
return React23.createElement(Skeleton, null);
|
|
3448
|
-
let
|
|
3458
|
+
let groups = groupRows(
|
|
3449
3459
|
pickBy(
|
|
3450
3460
|
rows || {},
|
|
3451
3461
|
(row) => !row?.table?.disable && safeIncludeConditionalArg(row, args || {}, globals || {})
|
|
@@ -3469,8 +3479,9 @@ var sortFns = {
|
|
|
3469
3479
|
{
|
|
3470
3480
|
variant: "ghost",
|
|
3471
3481
|
padding: "small",
|
|
3472
|
-
onClick:
|
|
3473
|
-
|
|
3482
|
+
onClick: handleResetClick,
|
|
3483
|
+
disabled: isResetting,
|
|
3484
|
+
ariaLabel: isResetting ? "Resetting controls..." : "Reset controls"
|
|
3474
3485
|
},
|
|
3475
3486
|
React23.createElement(UndoIcon, null)
|
|
3476
3487
|
)), React23.createElement(
|
|
@@ -3917,7 +3928,7 @@ var toGlobalSelector = (element) => `& :where(${element}:not(.sb-anchor, .sb-uns
|
|
|
3917
3928
|
})), DocsPageWrapper = ({ children, toc }) => React24.createElement(DocsWrapper, { className: "sbdocs sbdocs-wrapper" }, toc, React24.createElement(DocsContent, { className: "sbdocs sbdocs-content" }, children));
|
|
3918
3929
|
|
|
3919
3930
|
// src/blocks/components/Preview.tsx
|
|
3920
|
-
import React30, { Children, useCallback as
|
|
3931
|
+
import React30, { Children, useCallback as useCallback7, useContext as useContext2, useMemo as useMemo3, useState as useState14 } from "react";
|
|
3921
3932
|
import { logger as logger4 } from "storybook/internal/client-logger";
|
|
3922
3933
|
import { Bar, Button as Button7, ToggleButton as ToggleButton2, Zoom } from "storybook/internal/components";
|
|
3923
3934
|
import { CopyIcon, MarkupIcon } from "@storybook/icons";
|
|
@@ -4247,14 +4258,14 @@ import React26, { useContext } from "react";
|
|
|
4247
4258
|
import { InvalidBlockOfPropError } from "storybook/internal/preview-errors";
|
|
4248
4259
|
|
|
4249
4260
|
// src/blocks/blocks/useStory.ts
|
|
4250
|
-
import { useEffect as
|
|
4261
|
+
import { useEffect as useEffect9, useState as useState12 } from "react";
|
|
4251
4262
|
function useStory(storyId, context) {
|
|
4252
4263
|
let stories = useStories([storyId], context);
|
|
4253
4264
|
return stories && stories[0];
|
|
4254
4265
|
}
|
|
4255
4266
|
function useStories(storyIds, context) {
|
|
4256
|
-
let [storiesById, setStories] =
|
|
4257
|
-
return
|
|
4267
|
+
let [storiesById, setStories] = useState12({});
|
|
4268
|
+
return useEffect9(() => {
|
|
4258
4269
|
Promise.all(
|
|
4259
4270
|
storyIds.map(async (storyId) => {
|
|
4260
4271
|
let story = await context.loadStory(storyId);
|
|
@@ -4277,7 +4288,7 @@ function useStories(storyIds, context) {
|
|
|
4277
4288
|
// src/blocks/blocks/with-mdx-component-override.tsx
|
|
4278
4289
|
import React25 from "react";
|
|
4279
4290
|
import { useMDXComponents } from "@mdx-js/react";
|
|
4280
|
-
var MDX_WRAPPED_BLOCK = Symbol("mdxWrappedBlock"), MdxWrappedBlockContext = React25.createContext(null), withMdxComponentOverride = (blockName, Block) => {
|
|
4291
|
+
var MDX_WRAPPED_BLOCK = /* @__PURE__ */ Symbol("mdxWrappedBlock"), MdxWrappedBlockContext = React25.createContext(null), withMdxComponentOverride = (blockName, Block) => {
|
|
4281
4292
|
let WrappedBlock = (props) => {
|
|
4282
4293
|
let wrappedBlocks = React25.useContext(MdxWrappedBlockContext), Override = useMDXComponents()[blockName];
|
|
4283
4294
|
if (wrappedBlocks?.has(blockName) || Override === WrappedBlock)
|
|
@@ -4337,7 +4348,7 @@ var getBlockBackgroundStyle = (theme) => ({
|
|
|
4337
4348
|
});
|
|
4338
4349
|
|
|
4339
4350
|
// src/blocks/components/Story.tsx
|
|
4340
|
-
import React28, { useEffect as
|
|
4351
|
+
import React28, { useEffect as useEffect10, useRef as useRef6, useState as useState13 } from "react";
|
|
4341
4352
|
import { ErrorFormatter, Loader } from "storybook/internal/components";
|
|
4342
4353
|
import { styled as styled20 } from "storybook/theming";
|
|
4343
4354
|
|
|
@@ -4396,8 +4407,8 @@ var ZoomContext = createContext2({
|
|
|
4396
4407
|
|
|
4397
4408
|
// src/blocks/components/Story.tsx
|
|
4398
4409
|
var storyBlockIdFromId = ({ story, primary }) => `story--${story.id}${primary ? "--primary" : ""}`, InlineStory = (props) => {
|
|
4399
|
-
let storyRef =
|
|
4400
|
-
return
|
|
4410
|
+
let storyRef = useRef6(), [showLoader, setShowLoader] = useState13(!0), [error, setError] = useState13(), { story, height, autoplay, forceInitialArgs, renderStoryToElement } = props;
|
|
4411
|
+
return useEffect10(() => {
|
|
4401
4412
|
if (!(story && storyRef.current))
|
|
4402
4413
|
return () => {
|
|
4403
4414
|
};
|
|
@@ -4616,13 +4627,13 @@ var PositionedToolbar = styled22(Toolbar)({
|
|
|
4616
4627
|
onReloadStory,
|
|
4617
4628
|
...props
|
|
4618
4629
|
}) => {
|
|
4619
|
-
let [expanded, setExpanded] =
|
|
4630
|
+
let [expanded, setExpanded] = useState14(isExpanded), [copied, setCopied] = useState14(null), [scale, setScale] = useState14(1), additionalActionItems = useMemo3(
|
|
4620
4631
|
() => additionalActions ? [...additionalActions] : [],
|
|
4621
4632
|
[additionalActions]
|
|
4622
|
-
), sourceId = $bdb11010cef70236$export$f680877a34711e37(), previewClasses = [className].concat(["sbdocs", "sbdocs-preview", "sb-unstyled"]), context = useContext2(DocsContext), copyToClipboard =
|
|
4633
|
+
), sourceId = $bdb11010cef70236$export$f680877a34711e37(), previewClasses = [className].concat(["sbdocs", "sbdocs-preview", "sb-unstyled"]), context = useContext2(DocsContext), copyToClipboard = useCallback7(async (text) => {
|
|
4623
4634
|
let { createCopyToClipboardFunction } = await import("storybook/internal/components");
|
|
4624
4635
|
await createCopyToClipboardFunction()(text);
|
|
4625
|
-
}, []), handleCopyCode =
|
|
4636
|
+
}, []), handleCopyCode = useCallback7(async () => {
|
|
4626
4637
|
try {
|
|
4627
4638
|
await copyToClipboard(withSource?.code ?? ""), setCopied("Copied!");
|
|
4628
4639
|
} catch (err) {
|
|
@@ -4914,7 +4925,7 @@ var ItemLabel = styled26.div(({ theme }) => ({
|
|
|
4914
4925
|
}), IconItem = ({ name, children }) => React34.createElement(Item2, null, React34.createElement(ItemSpecimen, null, children), React34.createElement(ItemLabel, null, name)), IconGallery = ({ children, ...props }) => React34.createElement(ResetWrapper3, null, React34.createElement(List2, { ...props, className: "docblock-icongallery sb-unstyled" }, children));
|
|
4915
4926
|
|
|
4916
4927
|
// src/blocks/components/TableOfContents.tsx
|
|
4917
|
-
import React35, { useEffect as
|
|
4928
|
+
import React35, { useEffect as useEffect11 } from "react";
|
|
4918
4929
|
import { NAVIGATE_URL } from "storybook/internal/core-events";
|
|
4919
4930
|
import { styled as styled27 } from "storybook/theming";
|
|
4920
4931
|
|
|
@@ -5512,7 +5523,7 @@ var Aside = styled27.aside(() => ({
|
|
|
5512
5523
|
channel,
|
|
5513
5524
|
className
|
|
5514
5525
|
}) => {
|
|
5515
|
-
|
|
5526
|
+
useEffect11(() => {
|
|
5516
5527
|
if (disable)
|
|
5517
5528
|
return () => {
|
|
5518
5529
|
};
|
|
@@ -5547,10 +5558,110 @@ import React36 from "react";
|
|
|
5547
5558
|
var anchorBlockIdFromId = (storyId) => `anchor--${storyId}`, Anchor = ({ storyId, children }) => React36.createElement("div", { id: anchorBlockIdFromId(storyId), className: "sb-anchor" }, children);
|
|
5548
5559
|
|
|
5549
5560
|
// src/blocks/blocks/ArgTypes.tsx
|
|
5550
|
-
import React37 from "react";
|
|
5561
|
+
import React37, { useContext as useContext4 } from "react";
|
|
5551
5562
|
import { InvalidBlockOfPropError as InvalidBlockOfPropError2 } from "storybook/internal/preview-errors";
|
|
5552
5563
|
import { filterArgTypes } from "storybook/preview-api";
|
|
5553
5564
|
|
|
5565
|
+
// src/blocks/blocks/argTypesShared.ts
|
|
5566
|
+
import {
|
|
5567
|
+
getServiceSubcomponentArgTypes,
|
|
5568
|
+
mergeServiceArgTypes
|
|
5569
|
+
} from "storybook/internal/docs-tools";
|
|
5570
|
+
|
|
5571
|
+
// src/blocks/blocks/use-service-docgen.ts
|
|
5572
|
+
import { getService } from "storybook/preview-api";
|
|
5573
|
+
|
|
5574
|
+
// src/blocks/blocks/use-query-subscription.ts
|
|
5575
|
+
import { useCallback as useCallback8, useRef as useRef7 } from "react";
|
|
5576
|
+
import { seedQueryState } from "storybook/open-service";
|
|
5577
|
+
|
|
5578
|
+
// src/blocks/blocks/useSyncExternalStoreShim.ts
|
|
5579
|
+
import { useEffect as useEffect12, useLayoutEffect, useState as useState15 } from "react";
|
|
5580
|
+
function useSyncExternalStoreShim(subscribe, getSnapshot) {
|
|
5581
|
+
let value = getSnapshot(), [{ inst }, forceUpdate] = useState15({ inst: { value, getSnapshot } });
|
|
5582
|
+
return useLayoutEffect(() => {
|
|
5583
|
+
inst.value = value, inst.getSnapshot = getSnapshot, didSnapshotChange(inst) && forceUpdate({ inst });
|
|
5584
|
+
}, [subscribe, value, getSnapshot]), useEffect12(() => (didSnapshotChange(inst) && forceUpdate({ inst }), subscribe(() => {
|
|
5585
|
+
didSnapshotChange(inst) && forceUpdate({ inst });
|
|
5586
|
+
})), [subscribe]), value;
|
|
5587
|
+
}
|
|
5588
|
+
function didSnapshotChange(inst) {
|
|
5589
|
+
let latestGetSnapshot = inst.getSnapshot, prevValue = inst.value;
|
|
5590
|
+
try {
|
|
5591
|
+
let nextValue = latestGetSnapshot();
|
|
5592
|
+
return !Object.is(prevValue, nextValue);
|
|
5593
|
+
} catch {
|
|
5594
|
+
return !0;
|
|
5595
|
+
}
|
|
5596
|
+
}
|
|
5597
|
+
|
|
5598
|
+
// src/blocks/blocks/use-query-subscription.ts
|
|
5599
|
+
function useQuerySubscription(cacheKey, query, input, selector) {
|
|
5600
|
+
let cache = useRef7(void 0);
|
|
5601
|
+
(cache.current?.key !== cacheKey || cache.current.selector !== selector) && (cache.current = {
|
|
5602
|
+
key: cacheKey,
|
|
5603
|
+
selector,
|
|
5604
|
+
state: selector ? seedQueryState(query, input, selector) : seedQueryState(query, input)
|
|
5605
|
+
});
|
|
5606
|
+
let inputRef = useRef7(input);
|
|
5607
|
+
inputRef.current = input;
|
|
5608
|
+
let subscribe = useCallback8(
|
|
5609
|
+
(listener) => {
|
|
5610
|
+
let onQueryState = (state) => {
|
|
5611
|
+
cache.current = { key: cacheKey, selector, state }, listener();
|
|
5612
|
+
};
|
|
5613
|
+
return selector ? query.subscribe(inputRef.current, selector, onQueryState) : query.subscribe(inputRef.current, onQueryState);
|
|
5614
|
+
},
|
|
5615
|
+
[query, cacheKey, selector]
|
|
5616
|
+
), getSnapshot = useCallback8(() => cache.current.state, []);
|
|
5617
|
+
return useSyncExternalStoreShim(subscribe, getSnapshot);
|
|
5618
|
+
}
|
|
5619
|
+
|
|
5620
|
+
// src/blocks/blocks/use-service-docgen.ts
|
|
5621
|
+
function useServiceDocgen(id) {
|
|
5622
|
+
let service = getService("core/docgen");
|
|
5623
|
+
return useQuerySubscription(id, service.queries.docgen, { id });
|
|
5624
|
+
}
|
|
5625
|
+
|
|
5626
|
+
// src/blocks/blocks/argTypesShared.ts
|
|
5627
|
+
function extractComponentArgTypes(component, parameters) {
|
|
5628
|
+
let { extractArgTypes } = parameters.docs || {};
|
|
5629
|
+
if (!extractArgTypes)
|
|
5630
|
+
throw new Error("Args unsupported. See Args documentation for your framework." /* ARGS_UNSUPPORTED */);
|
|
5631
|
+
return extractArgTypes(component);
|
|
5632
|
+
}
|
|
5633
|
+
function extractSubcomponentArgTypes(subcomponents, parameters) {
|
|
5634
|
+
return Object.fromEntries(
|
|
5635
|
+
Object.entries(subcomponents || {}).map(([key, comp]) => [
|
|
5636
|
+
key,
|
|
5637
|
+
extractComponentArgTypes(comp, parameters)
|
|
5638
|
+
])
|
|
5639
|
+
);
|
|
5640
|
+
}
|
|
5641
|
+
function useDocgenServiceRows({
|
|
5642
|
+
componentId,
|
|
5643
|
+
storyId,
|
|
5644
|
+
parameters,
|
|
5645
|
+
initialArgs,
|
|
5646
|
+
customArgTypes
|
|
5647
|
+
}) {
|
|
5648
|
+
let { data: servicePayload, isInitialLoading } = useServiceDocgen(componentId);
|
|
5649
|
+
return servicePayload ? {
|
|
5650
|
+
rows: {
|
|
5651
|
+
serviceComponentName: servicePayload.name,
|
|
5652
|
+
mainRows: mergeServiceArgTypes({
|
|
5653
|
+
payload: servicePayload,
|
|
5654
|
+
storyId: storyId ?? componentId,
|
|
5655
|
+
parameters,
|
|
5656
|
+
initialArgs,
|
|
5657
|
+
customArgTypes
|
|
5658
|
+
}),
|
|
5659
|
+
subcomponentRows: getServiceSubcomponentArgTypes(servicePayload)
|
|
5660
|
+
},
|
|
5661
|
+
isInitialLoading
|
|
5662
|
+
} : { rows: null, isInitialLoading };
|
|
5663
|
+
}
|
|
5664
|
+
|
|
5554
5665
|
// src/blocks/blocks/useOf.ts
|
|
5555
5666
|
import { useContext as useContext3 } from "react";
|
|
5556
5667
|
var useOf = (moduleExportOrType, validTypes) => useContext3(DocsContext).resolveOf(moduleExportOrType, validTypes);
|
|
@@ -5569,73 +5680,117 @@ function scrollToElement(element, block = "start") {
|
|
|
5569
5680
|
}
|
|
5570
5681
|
|
|
5571
5682
|
// src/blocks/blocks/ArgTypes.tsx
|
|
5572
|
-
function
|
|
5573
|
-
let {
|
|
5574
|
-
if (
|
|
5575
|
-
throw new
|
|
5576
|
-
|
|
5577
|
-
}
|
|
5578
|
-
function getArgTypesFromResolved(resolved) {
|
|
5683
|
+
function useResolveArgTypes(props) {
|
|
5684
|
+
let { of } = props;
|
|
5685
|
+
if ("of" in props && of === void 0)
|
|
5686
|
+
throw new InvalidBlockOfPropError2();
|
|
5687
|
+
let context = useContext4(DocsContext), resolved = useOf(of || "meta"), resolvedArgTypes;
|
|
5579
5688
|
if (resolved.type === "component") {
|
|
5580
5689
|
let {
|
|
5581
|
-
component
|
|
5582
|
-
projectAnnotations: { parameters
|
|
5690
|
+
component,
|
|
5691
|
+
projectAnnotations: { parameters }
|
|
5583
5692
|
} = resolved;
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
component
|
|
5693
|
+
resolvedArgTypes = {
|
|
5694
|
+
parameters,
|
|
5695
|
+
// Bare `of={Component}` has no story/meta annotations; the docgen service is addressed by
|
|
5696
|
+
// component id, recovered from the CSF file that declares this component.
|
|
5697
|
+
componentId: context.getComponentId(component),
|
|
5698
|
+
argTypes: extractComponentArgTypes(component, parameters),
|
|
5699
|
+
component
|
|
5700
|
+
};
|
|
5701
|
+
} else if (resolved.type === "meta") {
|
|
5702
|
+
let { id, argTypes, parameters, initialArgs, component, subcomponents } = resolved.preparedMeta;
|
|
5703
|
+
resolvedArgTypes = {
|
|
5704
|
+
parameters,
|
|
5705
|
+
componentId: id.split("--")[0],
|
|
5706
|
+
initialArgs,
|
|
5707
|
+
argTypes,
|
|
5708
|
+
component,
|
|
5709
|
+
subcomponents
|
|
5710
|
+
};
|
|
5711
|
+
} else {
|
|
5712
|
+
let { id, argTypes, parameters, initialArgs, component, subcomponents } = resolved.story;
|
|
5713
|
+
resolvedArgTypes = {
|
|
5714
|
+
parameters,
|
|
5715
|
+
componentId: id.split("--")[0],
|
|
5716
|
+
storyId: id,
|
|
5717
|
+
initialArgs,
|
|
5718
|
+
argTypes,
|
|
5719
|
+
component,
|
|
5720
|
+
subcomponents
|
|
5588
5721
|
};
|
|
5589
5722
|
}
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
}
|
|
5599
|
-
return { argTypes, parameters, component, subcomponents };
|
|
5723
|
+
let argTypesParameters = resolvedArgTypes.parameters?.docs?.argTypes || {};
|
|
5724
|
+
return {
|
|
5725
|
+
...resolvedArgTypes,
|
|
5726
|
+
filterProps: {
|
|
5727
|
+
include: props.include ?? argTypesParameters.include,
|
|
5728
|
+
exclude: props.exclude ?? argTypesParameters.exclude,
|
|
5729
|
+
sort: props.sort ?? argTypesParameters.sort
|
|
5730
|
+
}
|
|
5731
|
+
};
|
|
5600
5732
|
}
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5733
|
+
function renderArgTypesTables({
|
|
5734
|
+
mainName = "Main",
|
|
5735
|
+
mainRows,
|
|
5736
|
+
subcomponentRows,
|
|
5737
|
+
include,
|
|
5738
|
+
exclude,
|
|
5739
|
+
sort
|
|
5740
|
+
}) {
|
|
5741
|
+
let filteredMainRows = filterArgTypes(mainRows, include, exclude);
|
|
5742
|
+
if (Object.keys(subcomponentRows).length === 0)
|
|
5743
|
+
return React37.createElement(ArgsTable, { rows: filteredMainRows, sort });
|
|
5744
|
+
let tabs = {
|
|
5745
|
+
[mainName]: { rows: filteredMainRows, sort },
|
|
5746
|
+
...Object.fromEntries(
|
|
5747
|
+
Object.entries(subcomponentRows).map(([key, rows]) => [
|
|
5748
|
+
key,
|
|
5749
|
+
{
|
|
5750
|
+
rows: filterArgTypes(rows, include, exclude),
|
|
5751
|
+
sort
|
|
5752
|
+
}
|
|
5753
|
+
])
|
|
5754
|
+
)
|
|
5623
5755
|
};
|
|
5624
5756
|
return React37.createElement(TabbedArgsTable, { tabs, sort });
|
|
5625
|
-
}
|
|
5757
|
+
}
|
|
5758
|
+
var LegacyArgTypes = (props) => {
|
|
5759
|
+
let { argTypes, parameters, component, subcomponents, filterProps } = useResolveArgTypes(props);
|
|
5760
|
+
return argTypes ? renderArgTypesTables({
|
|
5761
|
+
mainName: getComponentName(component),
|
|
5762
|
+
mainRows: argTypes,
|
|
5763
|
+
subcomponentRows: extractSubcomponentArgTypes(subcomponents, parameters),
|
|
5764
|
+
...filterProps
|
|
5765
|
+
}) : null;
|
|
5766
|
+
}, DocgenServiceArgTypes = (props) => {
|
|
5767
|
+
let { argTypes, parameters, componentId, storyId, initialArgs, filterProps, component } = useResolveArgTypes(props), { rows: serviceRows, isInitialLoading } = useDocgenServiceRows({
|
|
5768
|
+
componentId,
|
|
5769
|
+
storyId,
|
|
5770
|
+
parameters,
|
|
5771
|
+
initialArgs,
|
|
5772
|
+
customArgTypes: argTypes
|
|
5773
|
+
});
|
|
5774
|
+
return isInitialLoading ? React37.createElement(ArgsTable, { isLoading: !0 }) : serviceRows ? renderArgTypesTables({
|
|
5775
|
+
mainName: getComponentName(component) ?? serviceRows.serviceComponentName,
|
|
5776
|
+
mainRows: serviceRows.mainRows,
|
|
5777
|
+
subcomponentRows: serviceRows.subcomponentRows,
|
|
5778
|
+
...filterProps
|
|
5779
|
+
}) : null;
|
|
5780
|
+
}, ArgTypesImpl = (props) => globalThis.FEATURES?.experimentalDocgenServer ? React37.createElement(DocgenServiceArgTypes, { ...props }) : React37.createElement(LegacyArgTypes, { ...props }), ArgTypes = withMdxComponentOverride("ArgTypes", ArgTypesImpl);
|
|
5626
5781
|
|
|
5627
5782
|
// src/blocks/blocks/Canvas.tsx
|
|
5628
|
-
import React40, { useCallback as
|
|
5783
|
+
import React40, { useCallback as useCallback10, useContext as useContext6 } from "react";
|
|
5629
5784
|
import { FORCE_REMOUNT } from "storybook/internal/core-events";
|
|
5630
5785
|
import { InvalidBlockOfPropError as InvalidBlockOfPropError4 } from "storybook/internal/preview-errors";
|
|
5631
5786
|
|
|
5632
5787
|
// src/blocks/blocks/Source.tsx
|
|
5633
|
-
import React39, { useContext as
|
|
5788
|
+
import React39, { useContext as useContext5, useMemo as useMemo4 } from "react";
|
|
5634
5789
|
import { SourceType } from "storybook/internal/docs-tools";
|
|
5635
5790
|
import { InvalidBlockOfPropError as InvalidBlockOfPropError3 } from "storybook/internal/preview-errors";
|
|
5636
5791
|
|
|
5637
5792
|
// src/blocks/blocks/SourceContainer.tsx
|
|
5638
|
-
import React38, { createContext as createContext3, useEffect as
|
|
5793
|
+
import React38, { createContext as createContext3, useEffect as useEffect13, useState as useState16 } from "react";
|
|
5639
5794
|
import { SNIPPET_RENDERED } from "storybook/internal/docs-tools";
|
|
5640
5795
|
|
|
5641
5796
|
// ../../../node_modules/telejson/dist/chunk-EAFQLD22.mjs
|
|
@@ -5801,7 +5956,7 @@ var require_es_object_atoms = __commonJS({
|
|
|
5801
5956
|
return !1;
|
|
5802
5957
|
if (typeof Symbol.iterator == "symbol")
|
|
5803
5958
|
return !0;
|
|
5804
|
-
var obj = {}, sym = Symbol("test"), symObj = Object(sym);
|
|
5959
|
+
var obj = {}, sym = /* @__PURE__ */ Symbol("test"), symObj = Object(sym);
|
|
5805
5960
|
if (typeof sym == "string" || Object.prototype.toString.call(sym) !== "[object Symbol]" || Object.prototype.toString.call(symObj) !== "[object Symbol]")
|
|
5806
5961
|
return !1;
|
|
5807
5962
|
var symVal = 42;
|
|
@@ -5829,7 +5984,7 @@ var require_es_object_atoms = __commonJS({
|
|
|
5829
5984
|
"use strict";
|
|
5830
5985
|
var origSymbol = typeof Symbol < "u" && Symbol, hasSymbolSham = require_shams();
|
|
5831
5986
|
module.exports = function() {
|
|
5832
|
-
return typeof origSymbol != "function" || typeof Symbol != "function" || typeof origSymbol("foo") != "symbol" || typeof Symbol("bar") != "symbol" ? !1 : hasSymbolSham();
|
|
5987
|
+
return typeof origSymbol != "function" || typeof Symbol != "function" || typeof origSymbol("foo") != "symbol" || typeof /* @__PURE__ */ Symbol("bar") != "symbol" ? !1 : hasSymbolSham();
|
|
5833
5988
|
};
|
|
5834
5989
|
}
|
|
5835
5990
|
}), require_Reflect_getPrototypeOf = __commonJS({
|
|
@@ -6666,8 +6821,8 @@ var SourceContext = createContext3({ sources: {} }), UNKNOWN_ARGS_HASH = "--unkn
|
|
|
6666
6821
|
children,
|
|
6667
6822
|
channel
|
|
6668
6823
|
}) => {
|
|
6669
|
-
let [sources, setSources] =
|
|
6670
|
-
return
|
|
6824
|
+
let [sources, setSources] = useState16({});
|
|
6825
|
+
return useEffect13(() => {
|
|
6671
6826
|
let handleSnippetRendered = (idOrEvent, inputSource = null, inputFormat = !1) => {
|
|
6672
6827
|
let {
|
|
6673
6828
|
id,
|
|
@@ -6691,11 +6846,34 @@ var SourceContext = createContext3({ sources: {} }), UNKNOWN_ARGS_HASH = "--unkn
|
|
|
6691
6846
|
}, []), React38.createElement(SourceContext.Provider, { value: { sources } }, children);
|
|
6692
6847
|
};
|
|
6693
6848
|
|
|
6849
|
+
// src/blocks/blocks/use-service-story-docs.ts
|
|
6850
|
+
import { useCallback as useCallback9 } from "react";
|
|
6851
|
+
import { selectSnippetForStory, selectStoryDoc } from "storybook/open-service";
|
|
6852
|
+
import { getService as getService2 } from "storybook/preview-api";
|
|
6853
|
+
function useServiceStory(storyId, selector) {
|
|
6854
|
+
let componentId = storyId.split("--")[0], service = getService2("core/story-docs"), boundSelector = useCallback9(
|
|
6855
|
+
(payload) => selector(payload, storyId),
|
|
6856
|
+
[selector, storyId]
|
|
6857
|
+
);
|
|
6858
|
+
return useQuerySubscription(
|
|
6859
|
+
storyId,
|
|
6860
|
+
service.queries.storyDocs,
|
|
6861
|
+
{ id: componentId },
|
|
6862
|
+
boundSelector
|
|
6863
|
+
);
|
|
6864
|
+
}
|
|
6865
|
+
function useServiceStoryDoc(storyId) {
|
|
6866
|
+
return useServiceStory(storyId, selectStoryDoc);
|
|
6867
|
+
}
|
|
6868
|
+
function useServiceStorySnippet(storyId) {
|
|
6869
|
+
return useServiceStory(storyId, selectSnippetForStory);
|
|
6870
|
+
}
|
|
6871
|
+
|
|
6694
6872
|
// src/blocks/blocks/useTransformCode.tsx
|
|
6695
|
-
import { useEffect as
|
|
6873
|
+
import { useEffect as useEffect14, useState as useState17 } from "react";
|
|
6696
6874
|
function useTransformCode(source, transform, storyContext) {
|
|
6697
|
-
let [transformedCode, setTransformedCode] =
|
|
6698
|
-
return
|
|
6875
|
+
let [transformedCode, setTransformedCode] = useState17("Transforming..."), transformed = transform ? transform?.(source, storyContext) : source;
|
|
6876
|
+
return useEffect14(() => {
|
|
6699
6877
|
async function getTransformedCode() {
|
|
6700
6878
|
let transformResult = await transformed;
|
|
6701
6879
|
transformResult !== transformedCode && setTransformedCode(transformResult);
|
|
@@ -6710,14 +6888,15 @@ var EMPTY_SOURCE_CONTEXT = { sources: {} }, getStorySource = (storyId, args, sou
|
|
|
6710
6888
|
return sourceMap?.[argsHash(args)] || sourceMap?.[UNKNOWN_ARGS_HASH] || { code: "" };
|
|
6711
6889
|
}, useCode = ({
|
|
6712
6890
|
snippet,
|
|
6891
|
+
serviceSnippet,
|
|
6713
6892
|
storyContext,
|
|
6714
6893
|
typeFromProps,
|
|
6715
6894
|
transformFromProps
|
|
6716
6895
|
}) => {
|
|
6717
|
-
let parameters = storyContext.parameters ?? {}, { __isArgsStory: isArgsStory } = parameters, sourceParameters = parameters.docs?.source || {}, type = typeFromProps || sourceParameters.type || SourceType.AUTO, code = /* if user has explicitly set this as dynamic, use snippet */ type === SourceType.DYNAMIC || // if this is an args story and there's a snippet
|
|
6718
|
-
type === SourceType.AUTO &&
|
|
6896
|
+
let parameters = storyContext.parameters ?? {}, { __isArgsStory: isArgsStory } = parameters, sourceParameters = parameters.docs?.source || {}, type = typeFromProps || sourceParameters.type || SourceType.AUTO, staticSnippet = serviceSnippet || snippet, code = /* if user has explicitly set this as dynamic, use snippet */ type === SourceType.DYNAMIC || // if this is an args story and there's a snippet
|
|
6897
|
+
type === SourceType.AUTO && staticSnippet && isArgsStory ? staticSnippet : sourceParameters.originalSource || "", transformer = transformFromProps ?? sourceParameters.transform, transformedCode = transformer ? useTransformCode(code, transformer, storyContext) : code;
|
|
6719
6898
|
return sourceParameters.code !== void 0 ? sourceParameters.code : transformedCode;
|
|
6720
|
-
}, useSourceProps = (props, docsContext, sourceContext) => {
|
|
6899
|
+
}, useSourceProps = (props, docsContext, sourceContext, serviceSnippet = "") => {
|
|
6721
6900
|
let { of } = props, story = useMemo4(() => {
|
|
6722
6901
|
if (of)
|
|
6723
6902
|
return docsContext.resolveOf(of, ["story"]).story;
|
|
@@ -6727,6 +6906,7 @@ var EMPTY_SOURCE_CONTEXT = { sources: {} }, getStorySource = (storyId, args, sou
|
|
|
6727
6906
|
}
|
|
6728
6907
|
}, [docsContext, of]), storyContext = story ? docsContext.getStoryContext(story) : {}, argsForSource = props.__forceInitialArgs ? storyContext.initialArgs : storyContext.unmappedArgs, source = story ? getStorySource(story.id, argsForSource, sourceContext) : null, transformedCode = useCode({
|
|
6729
6908
|
snippet: source ? source.code : "",
|
|
6909
|
+
serviceSnippet,
|
|
6730
6910
|
storyContext: { ...storyContext, args: argsForSource },
|
|
6731
6911
|
typeFromProps: props.type,
|
|
6732
6912
|
transformFromProps: props.transform
|
|
@@ -6745,20 +6925,41 @@ var EMPTY_SOURCE_CONTEXT = { sources: {} }, getStorySource = (storyId, args, sou
|
|
|
6745
6925
|
language,
|
|
6746
6926
|
dark
|
|
6747
6927
|
});
|
|
6928
|
+
}, SourceWithStoryDocsSnippet = ({ storyId, docsContext, sourceContext, ...props }) => {
|
|
6929
|
+
let serviceSnippet = useServiceStorySnippet(storyId).data ?? "", sourceProps = useSourceProps(props, docsContext, sourceContext, serviceSnippet);
|
|
6930
|
+
return React39.createElement(Source, { ...sourceProps });
|
|
6748
6931
|
}, SourceWithStorySnippet = (props) => {
|
|
6749
|
-
let sourceContext =
|
|
6932
|
+
let { of } = props, sourceContext = useContext5(SourceContext), docsContext = useContext5(DocsContext), story = useMemo4(() => {
|
|
6933
|
+
if (of)
|
|
6934
|
+
return docsContext.resolveOf(of, ["story"]).story;
|
|
6935
|
+
try {
|
|
6936
|
+
return docsContext.storyById();
|
|
6937
|
+
} catch {
|
|
6938
|
+
}
|
|
6939
|
+
}, [docsContext, of]);
|
|
6940
|
+
if (globalThis.FEATURES?.experimentalDocgenServer && story?.id)
|
|
6941
|
+
return React39.createElement(
|
|
6942
|
+
SourceWithStoryDocsSnippet,
|
|
6943
|
+
{
|
|
6944
|
+
...props,
|
|
6945
|
+
docsContext,
|
|
6946
|
+
sourceContext,
|
|
6947
|
+
storyId: story.id
|
|
6948
|
+
}
|
|
6949
|
+
);
|
|
6950
|
+
let sourceProps = useSourceProps(props, docsContext, sourceContext);
|
|
6750
6951
|
return React39.createElement(Source, { ...sourceProps });
|
|
6751
6952
|
}, SourceWithCode = (props) => {
|
|
6752
|
-
let docsContext =
|
|
6953
|
+
let docsContext = useContext5(DocsContext), sourceProps = useSourceProps(props, docsContext, EMPTY_SOURCE_CONTEXT);
|
|
6753
6954
|
return React39.createElement(Source, { ...sourceProps });
|
|
6754
6955
|
}, SourceImpl = (props) => props.code !== void 0 ? React39.createElement(SourceWithCode, { ...props }) : React39.createElement(SourceWithStorySnippet, { ...props }), Source2 = withMdxComponentOverride("Source", SourceImpl);
|
|
6755
6956
|
|
|
6756
6957
|
// src/blocks/blocks/Canvas.tsx
|
|
6757
6958
|
var CanvasImpl = (props) => {
|
|
6758
|
-
let docsContext =
|
|
6959
|
+
let docsContext = useContext6(DocsContext), sourceContext = useContext6(SourceContext), { of, source } = props;
|
|
6759
6960
|
if ("of" in props && of === void 0)
|
|
6760
6961
|
throw new InvalidBlockOfPropError4();
|
|
6761
|
-
let { story } = useOf(of || "story", ["story"]), sourceProps = useSourceProps({ ...source, ...of && { of } }, docsContext, sourceContext), layout = props.layout ?? story.parameters.layout ?? story.parameters.docs?.canvas?.layout ?? "padded", withToolbar = props.withToolbar ?? story.parameters.docs?.canvas?.withToolbar ?? !1, additionalActions = props.additionalActions ?? story.parameters.docs?.canvas?.additionalActions, sourceState = props.sourceState ?? story.parameters.docs?.canvas?.sourceState ?? "hidden", className = props.className ?? story.parameters.docs?.canvas?.className, inline = props.story?.inline ?? story.parameters?.docs?.story?.inline ?? !1, handleReloadStory =
|
|
6962
|
+
let { story } = useOf(of || "story", ["story"]), sourceProps = useSourceProps({ ...source, ...of && { of } }, docsContext, sourceContext), layout = props.layout ?? story.parameters.layout ?? story.parameters.docs?.canvas?.layout ?? "padded", withToolbar = props.withToolbar ?? story.parameters.docs?.canvas?.withToolbar ?? !1, additionalActions = props.additionalActions ?? story.parameters.docs?.canvas?.additionalActions, sourceState = props.sourceState ?? story.parameters.docs?.canvas?.sourceState ?? "hidden", className = props.className ?? story.parameters.docs?.canvas?.className, inline = props.story?.inline ?? story.parameters?.docs?.story?.inline ?? !1, handleReloadStory = useCallback10(() => {
|
|
6762
6963
|
docsContext.channel.emit(FORCE_REMOUNT, { storyId: story.id });
|
|
6763
6964
|
}, [docsContext.channel, story.id]);
|
|
6764
6965
|
return React40.createElement(
|
|
@@ -6778,11 +6979,11 @@ var CanvasImpl = (props) => {
|
|
|
6778
6979
|
}, Canvas = withMdxComponentOverride("Canvas", CanvasImpl);
|
|
6779
6980
|
|
|
6780
6981
|
// src/blocks/blocks/Controls.tsx
|
|
6781
|
-
import React41, { useContext as
|
|
6982
|
+
import React41, { useContext as useContext8 } from "react";
|
|
6782
6983
|
import { filterArgTypes as filterArgTypes2 } from "storybook/preview-api";
|
|
6783
6984
|
|
|
6784
6985
|
// src/blocks/blocks/useArgs.ts
|
|
6785
|
-
import { useCallback as
|
|
6986
|
+
import { useCallback as useCallback11, useEffect as useEffect15, useState as useState18 } from "react";
|
|
6786
6987
|
import {
|
|
6787
6988
|
RESET_STORY_ARGS,
|
|
6788
6989
|
STORY_ARGS_UPDATED,
|
|
@@ -6794,17 +6995,17 @@ var useArgs = (story, context) => {
|
|
|
6794
6995
|
throw new Error("No result when story was defined");
|
|
6795
6996
|
return result;
|
|
6796
6997
|
}, useArgsIfDefined = (story, context) => {
|
|
6797
|
-
let storyContext = story ? context.getStoryContext(story) : { args: {} }, { id: storyId } = story || { id: "none" }, [args, setArgs] =
|
|
6798
|
-
|
|
6998
|
+
let storyContext = story ? context.getStoryContext(story) : { args: {} }, { id: storyId } = story || { id: "none" }, [args, setArgs] = useState18(storyContext.args);
|
|
6999
|
+
useEffect15(() => {
|
|
6799
7000
|
let onArgsUpdated = (changed) => {
|
|
6800
7001
|
changed.storyId === storyId && setArgs(changed.args);
|
|
6801
7002
|
};
|
|
6802
7003
|
return context.channel.on(STORY_ARGS_UPDATED, onArgsUpdated), () => context.channel.off(STORY_ARGS_UPDATED, onArgsUpdated);
|
|
6803
7004
|
}, [storyId, context.channel]);
|
|
6804
|
-
let updateArgs =
|
|
7005
|
+
let updateArgs = useCallback11(
|
|
6805
7006
|
(updatedArgs) => context.channel.emit(UPDATE_STORY_ARGS, { storyId, updatedArgs }),
|
|
6806
7007
|
[storyId, context.channel]
|
|
6807
|
-
), resetArgs =
|
|
7008
|
+
), resetArgs = useCallback11(
|
|
6808
7009
|
(argNames) => context.channel.emit(RESET_STORY_ARGS, { storyId, argNames }),
|
|
6809
7010
|
[storyId, context.channel]
|
|
6810
7011
|
);
|
|
@@ -6812,11 +7013,11 @@ var useArgs = (story, context) => {
|
|
|
6812
7013
|
};
|
|
6813
7014
|
|
|
6814
7015
|
// src/blocks/blocks/useGlobals.ts
|
|
6815
|
-
import { useEffect as
|
|
7016
|
+
import { useEffect as useEffect16, useState as useState19 } from "react";
|
|
6816
7017
|
import { GLOBALS_UPDATED } from "storybook/internal/core-events";
|
|
6817
7018
|
var useGlobals = (story, context) => {
|
|
6818
|
-
let storyContext = context.getStoryContext(story), [globals, setGlobals] =
|
|
6819
|
-
return
|
|
7019
|
+
let storyContext = context.getStoryContext(story), [globals, setGlobals] = useState19(storyContext.globals);
|
|
7020
|
+
return useEffect16(() => {
|
|
6820
7021
|
let onGlobalsUpdated = (changed) => {
|
|
6821
7022
|
setGlobals(changed.globals);
|
|
6822
7023
|
};
|
|
@@ -6825,32 +7026,48 @@ var useGlobals = (story, context) => {
|
|
|
6825
7026
|
};
|
|
6826
7027
|
|
|
6827
7028
|
// src/blocks/blocks/usePrimaryStory.ts
|
|
6828
|
-
import { useContext as
|
|
7029
|
+
import { useContext as useContext7 } from "react";
|
|
6829
7030
|
import { Tag } from "storybook/internal/preview-api";
|
|
6830
7031
|
var usePrimaryStory = () => {
|
|
6831
|
-
let context =
|
|
7032
|
+
let context = useContext7(DocsContext), stories = context.componentStories();
|
|
6832
7033
|
return context.filterByAutodocs === !1 ? stories[0] : stories.find((story) => story.tags.includes(Tag.AUTODOCS));
|
|
6833
7034
|
};
|
|
6834
7035
|
|
|
6835
7036
|
// src/blocks/blocks/Controls.tsx
|
|
6836
|
-
function
|
|
6837
|
-
let
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
7037
|
+
function getControlsFilterProps(story, props) {
|
|
7038
|
+
let controlsParameters = story.parameters.docs?.controls || {};
|
|
7039
|
+
return {
|
|
7040
|
+
include: props.include ?? controlsParameters.include,
|
|
7041
|
+
exclude: props.exclude ?? controlsParameters.exclude,
|
|
7042
|
+
sort: props.sort ?? controlsParameters.sort
|
|
7043
|
+
};
|
|
6841
7044
|
}
|
|
6842
|
-
|
|
6843
|
-
let
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
7045
|
+
function useControlsInteractiveState(story, context) {
|
|
7046
|
+
let controlsId = $bdb11010cef70236$export$f680877a34711e37(), [args, updateArgs, resetArgs] = useArgs(story, context), [globals] = useGlobals(story, context);
|
|
7047
|
+
return { controlsId, args, globals, updateArgs, resetArgs };
|
|
7048
|
+
}
|
|
7049
|
+
var ControlsTables = ({
|
|
7050
|
+
mainName = "Story",
|
|
7051
|
+
mainRows,
|
|
7052
|
+
subcomponentRows,
|
|
7053
|
+
include,
|
|
7054
|
+
exclude,
|
|
7055
|
+
sort,
|
|
7056
|
+
storyId,
|
|
7057
|
+
controlsId,
|
|
7058
|
+
args,
|
|
7059
|
+
globals,
|
|
7060
|
+
updateArgs,
|
|
7061
|
+
resetArgs
|
|
7062
|
+
}) => {
|
|
7063
|
+
let filteredMainRows = filterArgTypes2(mainRows, include, exclude);
|
|
7064
|
+
if (Object.keys(subcomponentRows).length === 0)
|
|
7065
|
+
return Object.keys(filteredMainRows).length > 0 || Object.keys(args).length > 0 ? React41.createElement(
|
|
6849
7066
|
ArgsTable,
|
|
6850
7067
|
{
|
|
6851
|
-
storyId
|
|
7068
|
+
storyId,
|
|
6852
7069
|
controlsId,
|
|
6853
|
-
rows:
|
|
7070
|
+
rows: filteredMainRows,
|
|
6854
7071
|
sort,
|
|
6855
7072
|
args,
|
|
6856
7073
|
globals,
|
|
@@ -6858,17 +7075,17 @@ var ControlsImpl = (props) => {
|
|
|
6858
7075
|
resetArgs
|
|
6859
7076
|
}
|
|
6860
7077
|
) : null;
|
|
6861
|
-
let
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
7078
|
+
let tabs = {
|
|
7079
|
+
[mainName]: { rows: filteredMainRows, sort },
|
|
7080
|
+
...Object.fromEntries(
|
|
7081
|
+
Object.entries(subcomponentRows).map(([key, rows]) => [
|
|
7082
|
+
key,
|
|
7083
|
+
{
|
|
7084
|
+
rows: filterArgTypes2(rows, include, exclude),
|
|
7085
|
+
sort
|
|
7086
|
+
}
|
|
7087
|
+
])
|
|
7088
|
+
)
|
|
6872
7089
|
};
|
|
6873
7090
|
return React41.createElement(
|
|
6874
7091
|
TabbedArgsTable,
|
|
@@ -6879,14 +7096,52 @@ var ControlsImpl = (props) => {
|
|
|
6879
7096
|
globals,
|
|
6880
7097
|
updateArgs,
|
|
6881
7098
|
resetArgs,
|
|
6882
|
-
storyId
|
|
7099
|
+
storyId,
|
|
6883
7100
|
controlsId
|
|
6884
7101
|
}
|
|
6885
7102
|
);
|
|
7103
|
+
}, LegacyControls = ({ story, context, ...props }) => {
|
|
7104
|
+
let { parameters, argTypes, component, subcomponents } = story, filterProps = getControlsFilterProps(story, props), interactiveState = useControlsInteractiveState(story, context);
|
|
7105
|
+
return argTypes ? React41.createElement(
|
|
7106
|
+
ControlsTables,
|
|
7107
|
+
{
|
|
7108
|
+
mainName: getComponentName(component) || "Story",
|
|
7109
|
+
mainRows: argTypes,
|
|
7110
|
+
subcomponentRows: extractSubcomponentArgTypes(subcomponents, parameters),
|
|
7111
|
+
...filterProps,
|
|
7112
|
+
storyId: story.id,
|
|
7113
|
+
...interactiveState
|
|
7114
|
+
}
|
|
7115
|
+
) : null;
|
|
7116
|
+
}, DocgenServiceControls = ({ story, context, ...props }) => {
|
|
7117
|
+
let { parameters, argTypes, component } = story, filterProps = getControlsFilterProps(story, props), interactiveState = useControlsInteractiveState(story, context), { rows: serviceRows, isInitialLoading } = useDocgenServiceRows({
|
|
7118
|
+
componentId: story.id.split("--")[0],
|
|
7119
|
+
storyId: story.id,
|
|
7120
|
+
parameters,
|
|
7121
|
+
initialArgs: story.initialArgs,
|
|
7122
|
+
customArgTypes: argTypes
|
|
7123
|
+
});
|
|
7124
|
+
return isInitialLoading ? React41.createElement(ArgsTable, { isLoading: !0 }) : serviceRows ? React41.createElement(
|
|
7125
|
+
ControlsTables,
|
|
7126
|
+
{
|
|
7127
|
+
mainName: getComponentName(component) ?? serviceRows.serviceComponentName,
|
|
7128
|
+
mainRows: serviceRows.mainRows,
|
|
7129
|
+
subcomponentRows: serviceRows.subcomponentRows,
|
|
7130
|
+
...filterProps,
|
|
7131
|
+
storyId: story.id,
|
|
7132
|
+
...interactiveState
|
|
7133
|
+
}
|
|
7134
|
+
) : null;
|
|
7135
|
+
}, ControlsImpl = (props) => {
|
|
7136
|
+
let { of } = props, context = useContext8(DocsContext), primaryStory = usePrimaryStory(), story = of ? context.resolveOf(of, ["story"]).story : primaryStory;
|
|
7137
|
+
if (!story)
|
|
7138
|
+
return null;
|
|
7139
|
+
let storyProps = { ...props, story, context };
|
|
7140
|
+
return globalThis.FEATURES?.experimentalDocgenServer ? React41.createElement(DocgenServiceControls, { ...storyProps }) : React41.createElement(LegacyControls, { ...storyProps });
|
|
6886
7141
|
}, Controls3 = withMdxComponentOverride("Controls", ControlsImpl);
|
|
6887
7142
|
|
|
6888
7143
|
// src/blocks/blocks/Description.tsx
|
|
6889
|
-
import React44 from "react";
|
|
7144
|
+
import React44, { useContext as useContext10 } from "react";
|
|
6890
7145
|
import { InvalidBlockOfPropError as InvalidBlockOfPropError5 } from "storybook/internal/preview-errors";
|
|
6891
7146
|
|
|
6892
7147
|
// src/blocks/blocks/Markdown.tsx
|
|
@@ -6894,7 +7149,7 @@ import React43 from "react";
|
|
|
6894
7149
|
import { dedent } from "ts-dedent";
|
|
6895
7150
|
|
|
6896
7151
|
// src/blocks/blocks/mdx.tsx
|
|
6897
|
-
import React42, { useContext as
|
|
7152
|
+
import React42, { useContext as useContext9 } from "react";
|
|
6898
7153
|
import { Button as Button8, Code, components, nameSpaceClassNames } from "storybook/internal/components";
|
|
6899
7154
|
import { NAVIGATE_URL as NAVIGATE_URL2 } from "storybook/internal/core-events";
|
|
6900
7155
|
import { LinkIcon } from "@storybook/icons";
|
|
@@ -6928,7 +7183,7 @@ function navigate(context, url) {
|
|
|
6928
7183
|
context.channel.emit(NAVIGATE_URL2, url);
|
|
6929
7184
|
}
|
|
6930
7185
|
var A2 = components.a, AnchorInPage = ({ hash, children }) => {
|
|
6931
|
-
let context =
|
|
7186
|
+
let context = useContext9(DocsContext);
|
|
6932
7187
|
return React42.createElement(
|
|
6933
7188
|
A2,
|
|
6934
7189
|
{
|
|
@@ -6942,7 +7197,7 @@ var A2 = components.a, AnchorInPage = ({ hash, children }) => {
|
|
|
6942
7197
|
children
|
|
6943
7198
|
);
|
|
6944
7199
|
}, AnchorMdx = (props) => {
|
|
6945
|
-
let { href, target, children, ...rest } = props, context =
|
|
7200
|
+
let { href, target, children, ...rest } = props, context = useContext9(DocsContext);
|
|
6946
7201
|
return !href || target === "_blank" || /^https?:\/\//.test(href) ? React42.createElement(A2, { ...props }) : href.startsWith("#") ? React42.createElement(AnchorInPage, { hash: href }, children) : React42.createElement(
|
|
6947
7202
|
A2,
|
|
6948
7203
|
{
|
|
@@ -6999,7 +7254,7 @@ var A2 = components.a, AnchorInPage = ({ hash, children }) => {
|
|
|
6999
7254
|
children,
|
|
7000
7255
|
...rest
|
|
7001
7256
|
}) => {
|
|
7002
|
-
let context =
|
|
7257
|
+
let context = useContext9(DocsContext), OcticonHeader = OcticonHeaders[as], hash = `#${id}`;
|
|
7003
7258
|
return React42.createElement(OcticonHeader, { id, ...rest }, React42.createElement(OcticonAlignmentWrapper, { className: "sb-unstyled" }, React42.createElement(OcticonAnchorWrapper, null, React42.createElement(
|
|
7004
7259
|
Button8,
|
|
7005
7260
|
{
|
|
@@ -7079,16 +7334,18 @@ var MarkdownImpl = (props) => {
|
|
|
7079
7334
|
}, Markdown = withMdxComponentOverride("Markdown", MarkdownImpl);
|
|
7080
7335
|
|
|
7081
7336
|
// src/blocks/blocks/Description.tsx
|
|
7082
|
-
var DescriptionType = /* @__PURE__ */ ((DescriptionType2) => (DescriptionType2.INFO = "info", DescriptionType2.NOTES = "notes", DescriptionType2.DOCGEN = "docgen", DescriptionType2.AUTO = "auto", DescriptionType2))(DescriptionType || {}), getDescriptionFromResolvedOf = (resolvedOf) => {
|
|
7337
|
+
var DescriptionType = /* @__PURE__ */ ((DescriptionType2) => (DescriptionType2.INFO = "info", DescriptionType2.NOTES = "notes", DescriptionType2.DOCGEN = "docgen", DescriptionType2.AUTO = "auto", DescriptionType2))(DescriptionType || {}), getDescriptionFromResolvedOf = (resolvedOf, serviceComponentDescription, storyDocsDescription) => {
|
|
7083
7338
|
switch (resolvedOf.type) {
|
|
7084
|
-
case "story":
|
|
7085
|
-
|
|
7339
|
+
case "story": {
|
|
7340
|
+
let storyDescription = resolvedOf.story.parameters.docs?.description?.story;
|
|
7341
|
+
return storyDescription !== void 0 ? storyDescription : storyDocsDescription ?? null;
|
|
7342
|
+
}
|
|
7086
7343
|
case "meta": {
|
|
7087
7344
|
let { parameters, component } = resolvedOf.preparedMeta, metaDescription = parameters.docs?.description?.component;
|
|
7088
7345
|
return metaDescription || parameters.docs?.extractComponentDescription?.(component, {
|
|
7089
7346
|
component,
|
|
7090
7347
|
parameters
|
|
7091
|
-
}) || null;
|
|
7348
|
+
}) || serviceComponentDescription || null;
|
|
7092
7349
|
}
|
|
7093
7350
|
case "component": {
|
|
7094
7351
|
let {
|
|
@@ -7098,26 +7355,54 @@ var DescriptionType = /* @__PURE__ */ ((DescriptionType2) => (DescriptionType2.I
|
|
|
7098
7355
|
return parameters?.docs?.extractComponentDescription?.(component, {
|
|
7099
7356
|
component,
|
|
7100
7357
|
parameters
|
|
7101
|
-
}) || null;
|
|
7358
|
+
}) || serviceComponentDescription || null;
|
|
7102
7359
|
}
|
|
7103
7360
|
default:
|
|
7104
7361
|
throw new Error(
|
|
7105
7362
|
`Unrecognized module type resolved from 'useOf', got: ${resolvedOf.type}`
|
|
7106
7363
|
);
|
|
7107
7364
|
}
|
|
7365
|
+
}, DescriptionBody = ({ resolvedOf, serviceComponentDescription, storyDocsDescription }) => {
|
|
7366
|
+
let markdown = getDescriptionFromResolvedOf(
|
|
7367
|
+
resolvedOf,
|
|
7368
|
+
serviceComponentDescription,
|
|
7369
|
+
storyDocsDescription
|
|
7370
|
+
);
|
|
7371
|
+
return markdown ? React44.createElement(Markdown, null, markdown) : null;
|
|
7372
|
+
}, DescriptionStoryWithServices = ({
|
|
7373
|
+
resolvedOf
|
|
7374
|
+
}) => {
|
|
7375
|
+
let storyDocsDescription = useServiceStoryDoc(resolvedOf.story.id).data?.description;
|
|
7376
|
+
return React44.createElement(DescriptionBody, { resolvedOf, storyDocsDescription });
|
|
7377
|
+
}, DescriptionComponentWithServices = ({ resolvedOf, componentId }) => {
|
|
7378
|
+
let serviceComponentDescription = useServiceDocgen(componentId).data?.description || void 0;
|
|
7379
|
+
return React44.createElement(
|
|
7380
|
+
DescriptionBody,
|
|
7381
|
+
{
|
|
7382
|
+
resolvedOf,
|
|
7383
|
+
serviceComponentDescription
|
|
7384
|
+
}
|
|
7385
|
+
);
|
|
7108
7386
|
}, DescriptionImpl = (props) => {
|
|
7109
7387
|
let { of } = props;
|
|
7110
7388
|
if ("of" in props && of === void 0)
|
|
7111
7389
|
throw new InvalidBlockOfPropError5();
|
|
7112
|
-
let resolvedOf = useOf(of || "meta"),
|
|
7113
|
-
|
|
7390
|
+
let resolvedOf = useOf(of || "meta"), context = useContext10(DocsContext);
|
|
7391
|
+
if (globalThis.FEATURES?.experimentalDocgenServer) {
|
|
7392
|
+
if (resolvedOf.type === "story")
|
|
7393
|
+
return React44.createElement(DescriptionStoryWithServices, { resolvedOf });
|
|
7394
|
+
let componentId = resolvedOf.type === "meta" ? resolvedOf.preparedMeta.componentId : context.getComponentId(resolvedOf.component);
|
|
7395
|
+
if (componentId)
|
|
7396
|
+
return React44.createElement(DescriptionComponentWithServices, { resolvedOf, componentId });
|
|
7397
|
+
}
|
|
7398
|
+
return React44.createElement(DescriptionBody, { resolvedOf });
|
|
7114
7399
|
}, Description2 = withMdxComponentOverride("Description", DescriptionImpl);
|
|
7115
7400
|
|
|
7116
7401
|
// src/blocks/blocks/Docs.tsx
|
|
7117
7402
|
import React54 from "react";
|
|
7118
7403
|
|
|
7119
7404
|
// src/blocks/blocks/DocsContainer.tsx
|
|
7120
|
-
import React45, { useEffect as
|
|
7405
|
+
import React45, { useEffect as useEffect17, useMemo as useMemo5 } from "react";
|
|
7121
7406
|
import { ThemeProvider, ensure as ensureTheme } from "storybook/theming";
|
|
7122
7407
|
|
|
7123
7408
|
// src/blocks/blocks/DocsSluggerContext.ts
|
|
@@ -7184,7 +7469,7 @@ var { document: document3, window: globalWindow3 } = globalThis, DocsContainer =
|
|
|
7184
7469
|
} catch {
|
|
7185
7470
|
toc = context?.projectAnnotations?.parameters?.docs?.toc;
|
|
7186
7471
|
}
|
|
7187
|
-
return
|
|
7472
|
+
return useEffect17(() => {
|
|
7188
7473
|
let url;
|
|
7189
7474
|
try {
|
|
7190
7475
|
if (url = new URL(globalWindow3.parent.location.toString()), url.hash) {
|
|
@@ -7273,7 +7558,7 @@ var PrimaryImpl = () => {
|
|
|
7273
7558
|
}, Primary = withMdxComponentOverride("Primary", PrimaryImpl);
|
|
7274
7559
|
|
|
7275
7560
|
// src/blocks/blocks/Stories.tsx
|
|
7276
|
-
import React50, { useContext as
|
|
7561
|
+
import React50, { useContext as useContext11 } from "react";
|
|
7277
7562
|
import { Tag as Tag2 } from "storybook/internal/preview-api";
|
|
7278
7563
|
import { styled as styled29 } from "storybook/theming";
|
|
7279
7564
|
var StyledHeading = styled29(Heading2)(({ theme }) => ({
|
|
@@ -7290,7 +7575,7 @@ var StyledHeading = styled29(Heading2)(({ theme }) => ({
|
|
|
7290
7575
|
marginTop: "56px"
|
|
7291
7576
|
}
|
|
7292
7577
|
})), StoriesImpl = ({ title = "Stories", includePrimary = !0 }) => {
|
|
7293
|
-
let { componentStories, projectAnnotations, getStoryContext } =
|
|
7578
|
+
let { componentStories, projectAnnotations, getStoryContext } = useContext11(DocsContext), stories = componentStories(), filter = projectAnnotations.parameters?.docs?.stories?.filter;
|
|
7294
7579
|
return filter && (stories = stories.filter((story) => filter(story, getStoryContext(story)))), stories.some((story) => story.tags?.includes(Tag2.AUTODOCS)) && (stories = stories.filter((story) => story.tags?.includes(Tag2.AUTODOCS) && !story.usesMount)), includePrimary || (stories = stories.slice(1)), !stories || stories.length === 0 ? null : React50.createElement(React50.Fragment, null, typeof title == "string" ? React50.createElement(StyledHeading, null, title) : title, stories.map(
|
|
7295
7580
|
(story) => story && React50.createElement(DocsStory, { key: story.id, of: story.moduleExport, expanded: !0, __forceInitialArgs: !0 })
|
|
7296
7581
|
));
|
|
@@ -7356,7 +7641,7 @@ function Docs({
|
|
|
7356
7641
|
}
|
|
7357
7642
|
|
|
7358
7643
|
// src/blocks/blocks/external/ExternalDocs.tsx
|
|
7359
|
-
import React55, { useRef as
|
|
7644
|
+
import React55, { useRef as useRef8 } from "react";
|
|
7360
7645
|
import { deprecate as deprecate2 } from "storybook/internal/client-logger";
|
|
7361
7646
|
import { composeConfigs as composeConfigs2 } from "storybook/preview-api";
|
|
7362
7647
|
|
|
@@ -7439,7 +7724,7 @@ var ConstantMap = class {
|
|
|
7439
7724
|
|
|
7440
7725
|
// src/blocks/blocks/external/ExternalDocs.tsx
|
|
7441
7726
|
function usePreview(projectAnnotations) {
|
|
7442
|
-
let previewRef =
|
|
7727
|
+
let previewRef = useRef8();
|
|
7443
7728
|
return previewRef.current || (previewRef.current = new ExternalPreview(projectAnnotations)), previewRef.current;
|
|
7444
7729
|
}
|
|
7445
7730
|
function ExternalDocs({
|
|
@@ -7461,9 +7746,9 @@ import { ThemeProvider as ThemeProvider2, ensure, themes } from "storybook/themi
|
|
|
7461
7746
|
var preview, ExternalDocsContainer = ({ projectAnnotations, children }) => (deprecate3("ExternalDocsContainer is deprecated and will be removed in Storybook 11."), preview || (preview = new ExternalPreview(projectAnnotations)), React56.createElement(DocsContext.Provider, { value: preview.docsContext() }, React56.createElement(ThemeProvider2, { theme: ensure(themes.light) }, children)));
|
|
7462
7747
|
|
|
7463
7748
|
// src/blocks/blocks/Meta.tsx
|
|
7464
|
-
import React57, { useContext as
|
|
7749
|
+
import React57, { useContext as useContext12 } from "react";
|
|
7465
7750
|
var Meta = ({ of }) => {
|
|
7466
|
-
let context =
|
|
7751
|
+
let context = useContext12(DocsContext);
|
|
7467
7752
|
of && context.referenceMeta(of, !0);
|
|
7468
7753
|
try {
|
|
7469
7754
|
let primary = context.storyById();
|