@storybook/addon-docs 10.5.0-alpha.6 → 10.5.0-alpha.7
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-HPMS3VGC.js → chunk-2WTY7RHL.js} +198 -198
- package/dist/_node-chunks/{chunk-5KAVE6JH.js → chunk-AR7B7DGI.js} +18 -9
- package/dist/_node-chunks/{chunk-EVYDPJBT.js → chunk-BS47STAB.js} +6 -6
- package/dist/_node-chunks/{chunk-7GHLECTU.js → chunk-ZM6M6OKB.js} +6 -6
- package/dist/_node-chunks/{mdx-plugin-SQGKMDRV.js → mdx-plugin-R2MYDMMD.js} +11 -11
- package/dist/_node-chunks/{rehype-external-links-55SSEHL7.js → rehype-external-links-QE2YWBRR.js} +9 -9
- package/dist/_node-chunks/{rehype-slug-2JQMJ6CC.js → rehype-slug-EPMUVHIS.js} +8 -8
- package/dist/angular/index.js +1 -1
- package/dist/blocks.js +277 -110
- package/dist/ember/index.js +1 -1
- package/dist/index.js +2 -2
- package/dist/manager.js +1 -1
- package/dist/mdx-loader.js +10 -10
- package/dist/preset.js +9 -9
- package/dist/preview.js +2 -2
- package/package.json +4 -4
package/dist/blocks.js
CHANGED
|
@@ -11,7 +11,7 @@ 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
17
|
import React23 from "react";
|
|
@@ -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 = {
|
|
@@ -4277,7 +4281,7 @@ function useStories(storyIds, context) {
|
|
|
4277
4281
|
// src/blocks/blocks/with-mdx-component-override.tsx
|
|
4278
4282
|
import React25 from "react";
|
|
4279
4283
|
import { useMDXComponents } from "@mdx-js/react";
|
|
4280
|
-
var MDX_WRAPPED_BLOCK = Symbol("mdxWrappedBlock"), MdxWrappedBlockContext = React25.createContext(null), withMdxComponentOverride = (blockName, Block) => {
|
|
4284
|
+
var MDX_WRAPPED_BLOCK = /* @__PURE__ */ Symbol("mdxWrappedBlock"), MdxWrappedBlockContext = React25.createContext(null), withMdxComponentOverride = (blockName, Block) => {
|
|
4281
4285
|
let WrappedBlock = (props) => {
|
|
4282
4286
|
let wrappedBlocks = React25.useContext(MdxWrappedBlockContext), Override = useMDXComponents()[blockName];
|
|
4283
4287
|
if (wrappedBlocks?.has(blockName) || Override === WrappedBlock)
|
|
@@ -5547,10 +5551,72 @@ import React36 from "react";
|
|
|
5547
5551
|
var anchorBlockIdFromId = (storyId) => `anchor--${storyId}`, Anchor = ({ storyId, children }) => React36.createElement("div", { id: anchorBlockIdFromId(storyId), className: "sb-anchor" }, children);
|
|
5548
5552
|
|
|
5549
5553
|
// src/blocks/blocks/ArgTypes.tsx
|
|
5550
|
-
import React37 from "react";
|
|
5554
|
+
import React37, { useContext as useContext4 } from "react";
|
|
5551
5555
|
import { InvalidBlockOfPropError as InvalidBlockOfPropError2 } from "storybook/internal/preview-errors";
|
|
5552
5556
|
import { filterArgTypes } from "storybook/preview-api";
|
|
5553
5557
|
|
|
5558
|
+
// src/blocks/blocks/argTypesShared.ts
|
|
5559
|
+
import {
|
|
5560
|
+
getServiceSubcomponentArgTypes,
|
|
5561
|
+
mergeServiceArgTypes
|
|
5562
|
+
} from "storybook/internal/docs-tools";
|
|
5563
|
+
|
|
5564
|
+
// src/blocks/blocks/useServiceDocgen.ts
|
|
5565
|
+
import { useCallback as useCallback7, useMemo as useMemo4, useRef as useRef6, useSyncExternalStore } from "react";
|
|
5566
|
+
import { getService } from "storybook/preview-api";
|
|
5567
|
+
function useServiceDocgen(id) {
|
|
5568
|
+
let snapshotCache = useRef6({ id: void 0, value: void 0 }), service = useMemo4(() => {
|
|
5569
|
+
try {
|
|
5570
|
+
return getService("core/docgen");
|
|
5571
|
+
} catch {
|
|
5572
|
+
return;
|
|
5573
|
+
}
|
|
5574
|
+
}, []), getSnapshot = useCallback7(() => snapshotCache.current.id === id ? snapshotCache.current.value : void 0, [id]), subscribe = useCallback7(
|
|
5575
|
+
(listener) => service && id ? service.queries.getDocgen.subscribe({ id }, (value) => {
|
|
5576
|
+
snapshotCache.current = { id, value }, listener();
|
|
5577
|
+
}) : () => {
|
|
5578
|
+
},
|
|
5579
|
+
[service, id]
|
|
5580
|
+
);
|
|
5581
|
+
return useSyncExternalStore(subscribe, getSnapshot);
|
|
5582
|
+
}
|
|
5583
|
+
|
|
5584
|
+
// src/blocks/blocks/argTypesShared.ts
|
|
5585
|
+
function extractComponentArgTypes(component, parameters) {
|
|
5586
|
+
let { extractArgTypes } = parameters.docs || {};
|
|
5587
|
+
if (!extractArgTypes)
|
|
5588
|
+
throw new Error("Args unsupported. See Args documentation for your framework." /* ARGS_UNSUPPORTED */);
|
|
5589
|
+
return extractArgTypes(component);
|
|
5590
|
+
}
|
|
5591
|
+
function extractSubcomponentArgTypes(subcomponents, parameters) {
|
|
5592
|
+
return Object.fromEntries(
|
|
5593
|
+
Object.entries(subcomponents || {}).map(([key, comp]) => [
|
|
5594
|
+
key,
|
|
5595
|
+
extractComponentArgTypes(comp, parameters)
|
|
5596
|
+
])
|
|
5597
|
+
);
|
|
5598
|
+
}
|
|
5599
|
+
function useDocgenServiceRows({
|
|
5600
|
+
componentId,
|
|
5601
|
+
storyId,
|
|
5602
|
+
parameters,
|
|
5603
|
+
initialArgs,
|
|
5604
|
+
customArgTypes
|
|
5605
|
+
}) {
|
|
5606
|
+
let servicePayload = useServiceDocgen(componentId);
|
|
5607
|
+
return !servicePayload || !componentId ? null : {
|
|
5608
|
+
serviceComponentName: servicePayload.name,
|
|
5609
|
+
mainRows: mergeServiceArgTypes({
|
|
5610
|
+
payload: servicePayload,
|
|
5611
|
+
storyId: storyId ?? componentId,
|
|
5612
|
+
parameters,
|
|
5613
|
+
initialArgs,
|
|
5614
|
+
customArgTypes
|
|
5615
|
+
}),
|
|
5616
|
+
subcomponentRows: getServiceSubcomponentArgTypes(servicePayload)
|
|
5617
|
+
};
|
|
5618
|
+
}
|
|
5619
|
+
|
|
5554
5620
|
// src/blocks/blocks/useOf.ts
|
|
5555
5621
|
import { useContext as useContext3 } from "react";
|
|
5556
5622
|
var useOf = (moduleExportOrType, validTypes) => useContext3(DocsContext).resolveOf(moduleExportOrType, validTypes);
|
|
@@ -5569,68 +5635,112 @@ function scrollToElement(element, block = "start") {
|
|
|
5569
5635
|
}
|
|
5570
5636
|
|
|
5571
5637
|
// src/blocks/blocks/ArgTypes.tsx
|
|
5572
|
-
function
|
|
5573
|
-
let {
|
|
5574
|
-
if (
|
|
5575
|
-
throw new
|
|
5576
|
-
|
|
5577
|
-
}
|
|
5578
|
-
function getArgTypesFromResolved(resolved) {
|
|
5638
|
+
function useResolveArgTypes(props) {
|
|
5639
|
+
let { of } = props;
|
|
5640
|
+
if ("of" in props && of === void 0)
|
|
5641
|
+
throw new InvalidBlockOfPropError2();
|
|
5642
|
+
let context = useContext4(DocsContext), resolved = useOf(of || "meta"), resolvedArgTypes;
|
|
5579
5643
|
if (resolved.type === "component") {
|
|
5580
5644
|
let {
|
|
5581
|
-
component
|
|
5582
|
-
projectAnnotations: { parameters
|
|
5645
|
+
component,
|
|
5646
|
+
projectAnnotations: { parameters }
|
|
5583
5647
|
} = resolved;
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
component
|
|
5648
|
+
resolvedArgTypes = {
|
|
5649
|
+
parameters,
|
|
5650
|
+
// Bare `of={Component}` has no story/meta annotations; the docgen service is addressed by
|
|
5651
|
+
// component id, recovered from the CSF file that declares this component.
|
|
5652
|
+
componentId: context.getComponentId(component),
|
|
5653
|
+
argTypes: extractComponentArgTypes(component, parameters),
|
|
5654
|
+
component
|
|
5655
|
+
};
|
|
5656
|
+
} else if (resolved.type === "meta") {
|
|
5657
|
+
let { id, argTypes, parameters, initialArgs, component, subcomponents } = resolved.preparedMeta;
|
|
5658
|
+
resolvedArgTypes = {
|
|
5659
|
+
parameters,
|
|
5660
|
+
componentId: id.split("--")[0],
|
|
5661
|
+
initialArgs,
|
|
5662
|
+
argTypes,
|
|
5663
|
+
component,
|
|
5664
|
+
subcomponents
|
|
5665
|
+
};
|
|
5666
|
+
} else {
|
|
5667
|
+
let { id, argTypes, parameters, initialArgs, component, subcomponents } = resolved.story;
|
|
5668
|
+
resolvedArgTypes = {
|
|
5669
|
+
parameters,
|
|
5670
|
+
componentId: id.split("--")[0],
|
|
5671
|
+
storyId: id,
|
|
5672
|
+
initialArgs,
|
|
5673
|
+
argTypes,
|
|
5674
|
+
component,
|
|
5675
|
+
subcomponents
|
|
5588
5676
|
};
|
|
5589
5677
|
}
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
}
|
|
5599
|
-
return { argTypes, parameters, component, subcomponents };
|
|
5678
|
+
let argTypesParameters = resolvedArgTypes.parameters?.docs?.argTypes || {};
|
|
5679
|
+
return {
|
|
5680
|
+
...resolvedArgTypes,
|
|
5681
|
+
filterProps: {
|
|
5682
|
+
include: props.include ?? argTypesParameters.include,
|
|
5683
|
+
exclude: props.exclude ?? argTypesParameters.exclude,
|
|
5684
|
+
sort: props.sort ?? argTypesParameters.sort
|
|
5685
|
+
}
|
|
5686
|
+
};
|
|
5600
5687
|
}
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5688
|
+
function renderArgTypesTables({
|
|
5689
|
+
mainName = "Main",
|
|
5690
|
+
mainRows,
|
|
5691
|
+
subcomponentRows,
|
|
5692
|
+
include,
|
|
5693
|
+
exclude,
|
|
5694
|
+
sort
|
|
5695
|
+
}) {
|
|
5696
|
+
let filteredMainRows = filterArgTypes(mainRows, include, exclude);
|
|
5697
|
+
if (Object.keys(subcomponentRows).length === 0)
|
|
5698
|
+
return React37.createElement(ArgsTable, { rows: filteredMainRows, sort });
|
|
5699
|
+
let tabs = {
|
|
5700
|
+
[mainName]: { rows: filteredMainRows, sort },
|
|
5701
|
+
...Object.fromEntries(
|
|
5702
|
+
Object.entries(subcomponentRows).map(([key, rows]) => [
|
|
5703
|
+
key,
|
|
5704
|
+
{
|
|
5705
|
+
rows: filterArgTypes(rows, include, exclude),
|
|
5706
|
+
sort
|
|
5707
|
+
}
|
|
5708
|
+
])
|
|
5709
|
+
)
|
|
5623
5710
|
};
|
|
5624
5711
|
return React37.createElement(TabbedArgsTable, { tabs, sort });
|
|
5625
|
-
}
|
|
5712
|
+
}
|
|
5713
|
+
var LegacyArgTypes = (props) => {
|
|
5714
|
+
let { argTypes, parameters, component, subcomponents, filterProps } = useResolveArgTypes(props);
|
|
5715
|
+
return argTypes ? renderArgTypesTables({
|
|
5716
|
+
mainName: getComponentName(component),
|
|
5717
|
+
mainRows: argTypes,
|
|
5718
|
+
subcomponentRows: extractSubcomponentArgTypes(subcomponents, parameters),
|
|
5719
|
+
...filterProps
|
|
5720
|
+
}) : null;
|
|
5721
|
+
}, DocgenServiceArgTypes = (props) => {
|
|
5722
|
+
let { argTypes, parameters, componentId, storyId, initialArgs, filterProps, component } = useResolveArgTypes(props), serviceRows = useDocgenServiceRows({
|
|
5723
|
+
componentId,
|
|
5724
|
+
storyId,
|
|
5725
|
+
parameters,
|
|
5726
|
+
initialArgs,
|
|
5727
|
+
customArgTypes: argTypes
|
|
5728
|
+
});
|
|
5729
|
+
return serviceRows ? renderArgTypesTables({
|
|
5730
|
+
mainName: getComponentName(component) ?? serviceRows.serviceComponentName,
|
|
5731
|
+
mainRows: serviceRows.mainRows,
|
|
5732
|
+
subcomponentRows: serviceRows.subcomponentRows,
|
|
5733
|
+
...filterProps
|
|
5734
|
+
}) : null;
|
|
5735
|
+
}, ArgTypesImpl = (props) => globalThis.FEATURES?.experimentalDocgenServer ? React37.createElement(DocgenServiceArgTypes, { ...props }) : React37.createElement(LegacyArgTypes, { ...props }), ArgTypes = withMdxComponentOverride("ArgTypes", ArgTypesImpl);
|
|
5626
5736
|
|
|
5627
5737
|
// src/blocks/blocks/Canvas.tsx
|
|
5628
|
-
import React40, { useCallback as
|
|
5738
|
+
import React40, { useCallback as useCallback8, useContext as useContext6 } from "react";
|
|
5629
5739
|
import { FORCE_REMOUNT } from "storybook/internal/core-events";
|
|
5630
5740
|
import { InvalidBlockOfPropError as InvalidBlockOfPropError4 } from "storybook/internal/preview-errors";
|
|
5631
5741
|
|
|
5632
5742
|
// src/blocks/blocks/Source.tsx
|
|
5633
|
-
import React39, { useContext as
|
|
5743
|
+
import React39, { useContext as useContext5, useMemo as useMemo5 } from "react";
|
|
5634
5744
|
import { SourceType } from "storybook/internal/docs-tools";
|
|
5635
5745
|
import { InvalidBlockOfPropError as InvalidBlockOfPropError3 } from "storybook/internal/preview-errors";
|
|
5636
5746
|
|
|
@@ -5801,7 +5911,7 @@ var require_es_object_atoms = __commonJS({
|
|
|
5801
5911
|
return !1;
|
|
5802
5912
|
if (typeof Symbol.iterator == "symbol")
|
|
5803
5913
|
return !0;
|
|
5804
|
-
var obj = {}, sym = Symbol("test"), symObj = Object(sym);
|
|
5914
|
+
var obj = {}, sym = /* @__PURE__ */ Symbol("test"), symObj = Object(sym);
|
|
5805
5915
|
if (typeof sym == "string" || Object.prototype.toString.call(sym) !== "[object Symbol]" || Object.prototype.toString.call(symObj) !== "[object Symbol]")
|
|
5806
5916
|
return !1;
|
|
5807
5917
|
var symVal = 42;
|
|
@@ -5829,7 +5939,7 @@ var require_es_object_atoms = __commonJS({
|
|
|
5829
5939
|
"use strict";
|
|
5830
5940
|
var origSymbol = typeof Symbol < "u" && Symbol, hasSymbolSham = require_shams();
|
|
5831
5941
|
module.exports = function() {
|
|
5832
|
-
return typeof origSymbol != "function" || typeof Symbol != "function" || typeof origSymbol("foo") != "symbol" || typeof Symbol("bar") != "symbol" ? !1 : hasSymbolSham();
|
|
5942
|
+
return typeof origSymbol != "function" || typeof Symbol != "function" || typeof origSymbol("foo") != "symbol" || typeof /* @__PURE__ */ Symbol("bar") != "symbol" ? !1 : hasSymbolSham();
|
|
5833
5943
|
};
|
|
5834
5944
|
}
|
|
5835
5945
|
}), require_Reflect_getPrototypeOf = __commonJS({
|
|
@@ -6718,7 +6828,7 @@ var EMPTY_SOURCE_CONTEXT = { sources: {} }, getStorySource = (storyId, args, sou
|
|
|
6718
6828
|
type === SourceType.AUTO && snippet && isArgsStory ? snippet : sourceParameters.originalSource || "", transformer = transformFromProps ?? sourceParameters.transform, transformedCode = transformer ? useTransformCode(code, transformer, storyContext) : code;
|
|
6719
6829
|
return sourceParameters.code !== void 0 ? sourceParameters.code : transformedCode;
|
|
6720
6830
|
}, useSourceProps = (props, docsContext, sourceContext) => {
|
|
6721
|
-
let { of } = props, story =
|
|
6831
|
+
let { of } = props, story = useMemo5(() => {
|
|
6722
6832
|
if (of)
|
|
6723
6833
|
return docsContext.resolveOf(of, ["story"]).story;
|
|
6724
6834
|
try {
|
|
@@ -6746,19 +6856,19 @@ var EMPTY_SOURCE_CONTEXT = { sources: {} }, getStorySource = (storyId, args, sou
|
|
|
6746
6856
|
dark
|
|
6747
6857
|
});
|
|
6748
6858
|
}, SourceWithStorySnippet = (props) => {
|
|
6749
|
-
let sourceContext =
|
|
6859
|
+
let sourceContext = useContext5(SourceContext), docsContext = useContext5(DocsContext), sourceProps = useSourceProps(props, docsContext, sourceContext);
|
|
6750
6860
|
return React39.createElement(Source, { ...sourceProps });
|
|
6751
6861
|
}, SourceWithCode = (props) => {
|
|
6752
|
-
let docsContext =
|
|
6862
|
+
let docsContext = useContext5(DocsContext), sourceProps = useSourceProps(props, docsContext, EMPTY_SOURCE_CONTEXT);
|
|
6753
6863
|
return React39.createElement(Source, { ...sourceProps });
|
|
6754
6864
|
}, SourceImpl = (props) => props.code !== void 0 ? React39.createElement(SourceWithCode, { ...props }) : React39.createElement(SourceWithStorySnippet, { ...props }), Source2 = withMdxComponentOverride("Source", SourceImpl);
|
|
6755
6865
|
|
|
6756
6866
|
// src/blocks/blocks/Canvas.tsx
|
|
6757
6867
|
var CanvasImpl = (props) => {
|
|
6758
|
-
let docsContext =
|
|
6868
|
+
let docsContext = useContext6(DocsContext), sourceContext = useContext6(SourceContext), { of, source } = props;
|
|
6759
6869
|
if ("of" in props && of === void 0)
|
|
6760
6870
|
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 =
|
|
6871
|
+
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 = useCallback8(() => {
|
|
6762
6872
|
docsContext.channel.emit(FORCE_REMOUNT, { storyId: story.id });
|
|
6763
6873
|
}, [docsContext.channel, story.id]);
|
|
6764
6874
|
return React40.createElement(
|
|
@@ -6778,11 +6888,11 @@ var CanvasImpl = (props) => {
|
|
|
6778
6888
|
}, Canvas = withMdxComponentOverride("Canvas", CanvasImpl);
|
|
6779
6889
|
|
|
6780
6890
|
// src/blocks/blocks/Controls.tsx
|
|
6781
|
-
import React41, { useContext as
|
|
6891
|
+
import React41, { useContext as useContext8 } from "react";
|
|
6782
6892
|
import { filterArgTypes as filterArgTypes2 } from "storybook/preview-api";
|
|
6783
6893
|
|
|
6784
6894
|
// src/blocks/blocks/useArgs.ts
|
|
6785
|
-
import { useCallback as
|
|
6895
|
+
import { useCallback as useCallback9, useEffect as useEffect13, useState as useState16 } from "react";
|
|
6786
6896
|
import {
|
|
6787
6897
|
RESET_STORY_ARGS,
|
|
6788
6898
|
STORY_ARGS_UPDATED,
|
|
@@ -6801,10 +6911,10 @@ var useArgs = (story, context) => {
|
|
|
6801
6911
|
};
|
|
6802
6912
|
return context.channel.on(STORY_ARGS_UPDATED, onArgsUpdated), () => context.channel.off(STORY_ARGS_UPDATED, onArgsUpdated);
|
|
6803
6913
|
}, [storyId, context.channel]);
|
|
6804
|
-
let updateArgs =
|
|
6914
|
+
let updateArgs = useCallback9(
|
|
6805
6915
|
(updatedArgs) => context.channel.emit(UPDATE_STORY_ARGS, { storyId, updatedArgs }),
|
|
6806
6916
|
[storyId, context.channel]
|
|
6807
|
-
), resetArgs =
|
|
6917
|
+
), resetArgs = useCallback9(
|
|
6808
6918
|
(argNames) => context.channel.emit(RESET_STORY_ARGS, { storyId, argNames }),
|
|
6809
6919
|
[storyId, context.channel]
|
|
6810
6920
|
);
|
|
@@ -6825,32 +6935,48 @@ var useGlobals = (story, context) => {
|
|
|
6825
6935
|
};
|
|
6826
6936
|
|
|
6827
6937
|
// src/blocks/blocks/usePrimaryStory.ts
|
|
6828
|
-
import { useContext as
|
|
6938
|
+
import { useContext as useContext7 } from "react";
|
|
6829
6939
|
import { Tag } from "storybook/internal/preview-api";
|
|
6830
6940
|
var usePrimaryStory = () => {
|
|
6831
|
-
let context =
|
|
6941
|
+
let context = useContext7(DocsContext), stories = context.componentStories();
|
|
6832
6942
|
return context.filterByAutodocs === !1 ? stories[0] : stories.find((story) => story.tags.includes(Tag.AUTODOCS));
|
|
6833
6943
|
};
|
|
6834
6944
|
|
|
6835
6945
|
// src/blocks/blocks/Controls.tsx
|
|
6836
|
-
function
|
|
6837
|
-
let
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6946
|
+
function getControlsFilterProps(story, props) {
|
|
6947
|
+
let controlsParameters = story.parameters.docs?.controls || {};
|
|
6948
|
+
return {
|
|
6949
|
+
include: props.include ?? controlsParameters.include,
|
|
6950
|
+
exclude: props.exclude ?? controlsParameters.exclude,
|
|
6951
|
+
sort: props.sort ?? controlsParameters.sort
|
|
6952
|
+
};
|
|
6841
6953
|
}
|
|
6842
|
-
|
|
6843
|
-
let
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
6954
|
+
function useControlsInteractiveState(story, context) {
|
|
6955
|
+
let controlsId = $bdb11010cef70236$export$f680877a34711e37(), [args, updateArgs, resetArgs] = useArgs(story, context), [globals] = useGlobals(story, context);
|
|
6956
|
+
return { controlsId, args, globals, updateArgs, resetArgs };
|
|
6957
|
+
}
|
|
6958
|
+
var ControlsTables = ({
|
|
6959
|
+
mainName = "Story",
|
|
6960
|
+
mainRows,
|
|
6961
|
+
subcomponentRows,
|
|
6962
|
+
include,
|
|
6963
|
+
exclude,
|
|
6964
|
+
sort,
|
|
6965
|
+
storyId,
|
|
6966
|
+
controlsId,
|
|
6967
|
+
args,
|
|
6968
|
+
globals,
|
|
6969
|
+
updateArgs,
|
|
6970
|
+
resetArgs
|
|
6971
|
+
}) => {
|
|
6972
|
+
let filteredMainRows = filterArgTypes2(mainRows, include, exclude);
|
|
6973
|
+
if (Object.keys(subcomponentRows).length === 0)
|
|
6974
|
+
return Object.keys(filteredMainRows).length > 0 || Object.keys(args).length > 0 ? React41.createElement(
|
|
6849
6975
|
ArgsTable,
|
|
6850
6976
|
{
|
|
6851
|
-
storyId
|
|
6977
|
+
storyId,
|
|
6852
6978
|
controlsId,
|
|
6853
|
-
rows:
|
|
6979
|
+
rows: filteredMainRows,
|
|
6854
6980
|
sort,
|
|
6855
6981
|
args,
|
|
6856
6982
|
globals,
|
|
@@ -6858,17 +6984,17 @@ var ControlsImpl = (props) => {
|
|
|
6858
6984
|
resetArgs
|
|
6859
6985
|
}
|
|
6860
6986
|
) : null;
|
|
6861
|
-
let
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6987
|
+
let tabs = {
|
|
6988
|
+
[mainName]: { rows: filteredMainRows, sort },
|
|
6989
|
+
...Object.fromEntries(
|
|
6990
|
+
Object.entries(subcomponentRows).map(([key, rows]) => [
|
|
6991
|
+
key,
|
|
6992
|
+
{
|
|
6993
|
+
rows: filterArgTypes2(rows, include, exclude),
|
|
6994
|
+
sort
|
|
6995
|
+
}
|
|
6996
|
+
])
|
|
6997
|
+
)
|
|
6872
6998
|
};
|
|
6873
6999
|
return React41.createElement(
|
|
6874
7000
|
TabbedArgsTable,
|
|
@@ -6879,14 +7005,52 @@ var ControlsImpl = (props) => {
|
|
|
6879
7005
|
globals,
|
|
6880
7006
|
updateArgs,
|
|
6881
7007
|
resetArgs,
|
|
6882
|
-
storyId
|
|
7008
|
+
storyId,
|
|
6883
7009
|
controlsId
|
|
6884
7010
|
}
|
|
6885
7011
|
);
|
|
7012
|
+
}, LegacyControls = ({ story, context, ...props }) => {
|
|
7013
|
+
let { parameters, argTypes, component, subcomponents } = story, filterProps = getControlsFilterProps(story, props), interactiveState = useControlsInteractiveState(story, context);
|
|
7014
|
+
return argTypes ? React41.createElement(
|
|
7015
|
+
ControlsTables,
|
|
7016
|
+
{
|
|
7017
|
+
mainName: getComponentName(component) || "Story",
|
|
7018
|
+
mainRows: argTypes,
|
|
7019
|
+
subcomponentRows: extractSubcomponentArgTypes(subcomponents, parameters),
|
|
7020
|
+
...filterProps,
|
|
7021
|
+
storyId: story.id,
|
|
7022
|
+
...interactiveState
|
|
7023
|
+
}
|
|
7024
|
+
) : null;
|
|
7025
|
+
}, DocgenServiceControls = ({ story, context, ...props }) => {
|
|
7026
|
+
let { parameters, argTypes, component } = story, filterProps = getControlsFilterProps(story, props), interactiveState = useControlsInteractiveState(story, context), serviceRows = useDocgenServiceRows({
|
|
7027
|
+
componentId: story.id.split("--")[0],
|
|
7028
|
+
storyId: story.id,
|
|
7029
|
+
parameters,
|
|
7030
|
+
initialArgs: story.initialArgs,
|
|
7031
|
+
customArgTypes: argTypes
|
|
7032
|
+
});
|
|
7033
|
+
return serviceRows ? React41.createElement(
|
|
7034
|
+
ControlsTables,
|
|
7035
|
+
{
|
|
7036
|
+
mainName: getComponentName(component) ?? serviceRows.serviceComponentName,
|
|
7037
|
+
mainRows: serviceRows.mainRows,
|
|
7038
|
+
subcomponentRows: serviceRows.subcomponentRows,
|
|
7039
|
+
...filterProps,
|
|
7040
|
+
storyId: story.id,
|
|
7041
|
+
...interactiveState
|
|
7042
|
+
}
|
|
7043
|
+
) : null;
|
|
7044
|
+
}, ControlsImpl = (props) => {
|
|
7045
|
+
let { of } = props, context = useContext8(DocsContext), primaryStory = usePrimaryStory(), story = of ? context.resolveOf(of, ["story"]).story : primaryStory;
|
|
7046
|
+
if (!story)
|
|
7047
|
+
return null;
|
|
7048
|
+
let storyProps = { ...props, story, context };
|
|
7049
|
+
return globalThis.FEATURES?.experimentalDocgenServer ? React41.createElement(DocgenServiceControls, { ...storyProps }) : React41.createElement(LegacyControls, { ...storyProps });
|
|
6886
7050
|
}, Controls3 = withMdxComponentOverride("Controls", ControlsImpl);
|
|
6887
7051
|
|
|
6888
7052
|
// src/blocks/blocks/Description.tsx
|
|
6889
|
-
import React44 from "react";
|
|
7053
|
+
import React44, { useContext as useContext10 } from "react";
|
|
6890
7054
|
import { InvalidBlockOfPropError as InvalidBlockOfPropError5 } from "storybook/internal/preview-errors";
|
|
6891
7055
|
|
|
6892
7056
|
// src/blocks/blocks/Markdown.tsx
|
|
@@ -6894,7 +7058,7 @@ import React43 from "react";
|
|
|
6894
7058
|
import { dedent } from "ts-dedent";
|
|
6895
7059
|
|
|
6896
7060
|
// src/blocks/blocks/mdx.tsx
|
|
6897
|
-
import React42, { useContext as
|
|
7061
|
+
import React42, { useContext as useContext9 } from "react";
|
|
6898
7062
|
import { Button as Button8, Code, components, nameSpaceClassNames } from "storybook/internal/components";
|
|
6899
7063
|
import { NAVIGATE_URL as NAVIGATE_URL2 } from "storybook/internal/core-events";
|
|
6900
7064
|
import { LinkIcon } from "@storybook/icons";
|
|
@@ -6928,7 +7092,7 @@ function navigate(context, url) {
|
|
|
6928
7092
|
context.channel.emit(NAVIGATE_URL2, url);
|
|
6929
7093
|
}
|
|
6930
7094
|
var A2 = components.a, AnchorInPage = ({ hash, children }) => {
|
|
6931
|
-
let context =
|
|
7095
|
+
let context = useContext9(DocsContext);
|
|
6932
7096
|
return React42.createElement(
|
|
6933
7097
|
A2,
|
|
6934
7098
|
{
|
|
@@ -6942,7 +7106,7 @@ var A2 = components.a, AnchorInPage = ({ hash, children }) => {
|
|
|
6942
7106
|
children
|
|
6943
7107
|
);
|
|
6944
7108
|
}, AnchorMdx = (props) => {
|
|
6945
|
-
let { href, target, children, ...rest } = props, context =
|
|
7109
|
+
let { href, target, children, ...rest } = props, context = useContext9(DocsContext);
|
|
6946
7110
|
return !href || target === "_blank" || /^https?:\/\//.test(href) ? React42.createElement(A2, { ...props }) : href.startsWith("#") ? React42.createElement(AnchorInPage, { hash: href }, children) : React42.createElement(
|
|
6947
7111
|
A2,
|
|
6948
7112
|
{
|
|
@@ -6999,7 +7163,7 @@ var A2 = components.a, AnchorInPage = ({ hash, children }) => {
|
|
|
6999
7163
|
children,
|
|
7000
7164
|
...rest
|
|
7001
7165
|
}) => {
|
|
7002
|
-
let context =
|
|
7166
|
+
let context = useContext9(DocsContext), OcticonHeader = OcticonHeaders[as], hash = `#${id}`;
|
|
7003
7167
|
return React42.createElement(OcticonHeader, { id, ...rest }, React42.createElement(OcticonAlignmentWrapper, { className: "sb-unstyled" }, React42.createElement(OcticonAnchorWrapper, null, React42.createElement(
|
|
7004
7168
|
Button8,
|
|
7005
7169
|
{
|
|
@@ -7079,7 +7243,7 @@ var MarkdownImpl = (props) => {
|
|
|
7079
7243
|
}, Markdown = withMdxComponentOverride("Markdown", MarkdownImpl);
|
|
7080
7244
|
|
|
7081
7245
|
// 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) => {
|
|
7246
|
+
var DescriptionType = /* @__PURE__ */ ((DescriptionType2) => (DescriptionType2.INFO = "info", DescriptionType2.NOTES = "notes", DescriptionType2.DOCGEN = "docgen", DescriptionType2.AUTO = "auto", DescriptionType2))(DescriptionType || {}), getDescriptionFromResolvedOf = (resolvedOf, serviceComponentDescription) => {
|
|
7083
7247
|
switch (resolvedOf.type) {
|
|
7084
7248
|
case "story":
|
|
7085
7249
|
return resolvedOf.story.parameters.docs?.description?.story || null;
|
|
@@ -7088,7 +7252,7 @@ var DescriptionType = /* @__PURE__ */ ((DescriptionType2) => (DescriptionType2.I
|
|
|
7088
7252
|
return metaDescription || parameters.docs?.extractComponentDescription?.(component, {
|
|
7089
7253
|
component,
|
|
7090
7254
|
parameters
|
|
7091
|
-
}) || null;
|
|
7255
|
+
}) || serviceComponentDescription || null;
|
|
7092
7256
|
}
|
|
7093
7257
|
case "component": {
|
|
7094
7258
|
let {
|
|
@@ -7098,18 +7262,21 @@ var DescriptionType = /* @__PURE__ */ ((DescriptionType2) => (DescriptionType2.I
|
|
|
7098
7262
|
return parameters?.docs?.extractComponentDescription?.(component, {
|
|
7099
7263
|
component,
|
|
7100
7264
|
parameters
|
|
7101
|
-
}) || null;
|
|
7265
|
+
}) || serviceComponentDescription || null;
|
|
7102
7266
|
}
|
|
7103
7267
|
default:
|
|
7104
7268
|
throw new Error(
|
|
7105
7269
|
`Unrecognized module type resolved from 'useOf', got: ${resolvedOf.type}`
|
|
7106
7270
|
);
|
|
7107
7271
|
}
|
|
7272
|
+
}, useServiceComponentDescription = (resolvedOf) => {
|
|
7273
|
+
let context = useContext10(DocsContext), componentId;
|
|
7274
|
+
return globalThis.FEATURES?.experimentalDocgenServer && (resolvedOf.type === "meta" ? componentId = resolvedOf.preparedMeta.componentId : resolvedOf.type === "component" && (componentId = context.getComponentId(resolvedOf.component))), useServiceDocgen(componentId)?.description || void 0;
|
|
7108
7275
|
}, DescriptionImpl = (props) => {
|
|
7109
7276
|
let { of } = props;
|
|
7110
7277
|
if ("of" in props && of === void 0)
|
|
7111
7278
|
throw new InvalidBlockOfPropError5();
|
|
7112
|
-
let resolvedOf = useOf(of || "meta"), markdown = getDescriptionFromResolvedOf(resolvedOf);
|
|
7279
|
+
let resolvedOf = useOf(of || "meta"), serviceComponentDescription = useServiceComponentDescription(resolvedOf), markdown = getDescriptionFromResolvedOf(resolvedOf, serviceComponentDescription);
|
|
7113
7280
|
return markdown ? React44.createElement(Markdown, null, markdown) : null;
|
|
7114
7281
|
}, Description2 = withMdxComponentOverride("Description", DescriptionImpl);
|
|
7115
7282
|
|
|
@@ -7117,7 +7284,7 @@ var DescriptionType = /* @__PURE__ */ ((DescriptionType2) => (DescriptionType2.I
|
|
|
7117
7284
|
import React54 from "react";
|
|
7118
7285
|
|
|
7119
7286
|
// src/blocks/blocks/DocsContainer.tsx
|
|
7120
|
-
import React45, { useEffect as useEffect15, useMemo as
|
|
7287
|
+
import React45, { useEffect as useEffect15, useMemo as useMemo6 } from "react";
|
|
7121
7288
|
import { ThemeProvider, ensure as ensureTheme } from "storybook/theming";
|
|
7122
7289
|
|
|
7123
7290
|
// src/blocks/blocks/DocsSluggerContext.ts
|
|
@@ -7178,7 +7345,7 @@ var { document: document3, window: globalWindow3 } = globalThis, DocsContainer =
|
|
|
7178
7345
|
theme,
|
|
7179
7346
|
children
|
|
7180
7347
|
}) => {
|
|
7181
|
-
let slugger =
|
|
7348
|
+
let slugger = useMemo6(() => createDocsSlugger(), []), toc;
|
|
7182
7349
|
try {
|
|
7183
7350
|
toc = context.resolveOf("meta", ["meta"]).preparedMeta.parameters?.docs?.toc;
|
|
7184
7351
|
} catch {
|
|
@@ -7273,7 +7440,7 @@ var PrimaryImpl = () => {
|
|
|
7273
7440
|
}, Primary = withMdxComponentOverride("Primary", PrimaryImpl);
|
|
7274
7441
|
|
|
7275
7442
|
// src/blocks/blocks/Stories.tsx
|
|
7276
|
-
import React50, { useContext as
|
|
7443
|
+
import React50, { useContext as useContext11 } from "react";
|
|
7277
7444
|
import { Tag as Tag2 } from "storybook/internal/preview-api";
|
|
7278
7445
|
import { styled as styled29 } from "storybook/theming";
|
|
7279
7446
|
var StyledHeading = styled29(Heading2)(({ theme }) => ({
|
|
@@ -7290,7 +7457,7 @@ var StyledHeading = styled29(Heading2)(({ theme }) => ({
|
|
|
7290
7457
|
marginTop: "56px"
|
|
7291
7458
|
}
|
|
7292
7459
|
})), StoriesImpl = ({ title = "Stories", includePrimary = !0 }) => {
|
|
7293
|
-
let { componentStories, projectAnnotations, getStoryContext } =
|
|
7460
|
+
let { componentStories, projectAnnotations, getStoryContext } = useContext11(DocsContext), stories = componentStories(), { stories: { filter } = { filter: void 0 } } = projectAnnotations.parameters?.docs || {};
|
|
7294
7461
|
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
7462
|
(story) => story && React50.createElement(DocsStory, { key: story.id, of: story.moduleExport, expanded: !0, __forceInitialArgs: !0 })
|
|
7296
7463
|
));
|
|
@@ -7356,7 +7523,7 @@ function Docs({
|
|
|
7356
7523
|
}
|
|
7357
7524
|
|
|
7358
7525
|
// src/blocks/blocks/external/ExternalDocs.tsx
|
|
7359
|
-
import React55, { useRef as
|
|
7526
|
+
import React55, { useRef as useRef7 } from "react";
|
|
7360
7527
|
import { deprecate as deprecate2 } from "storybook/internal/client-logger";
|
|
7361
7528
|
import { composeConfigs as composeConfigs2 } from "storybook/preview-api";
|
|
7362
7529
|
|
|
@@ -7439,7 +7606,7 @@ var ConstantMap = class {
|
|
|
7439
7606
|
|
|
7440
7607
|
// src/blocks/blocks/external/ExternalDocs.tsx
|
|
7441
7608
|
function usePreview(projectAnnotations) {
|
|
7442
|
-
let previewRef =
|
|
7609
|
+
let previewRef = useRef7();
|
|
7443
7610
|
return previewRef.current || (previewRef.current = new ExternalPreview(projectAnnotations)), previewRef.current;
|
|
7444
7611
|
}
|
|
7445
7612
|
function ExternalDocs({
|
|
@@ -7461,9 +7628,9 @@ import { ThemeProvider as ThemeProvider2, ensure, themes } from "storybook/themi
|
|
|
7461
7628
|
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
7629
|
|
|
7463
7630
|
// src/blocks/blocks/Meta.tsx
|
|
7464
|
-
import React57, { useContext as
|
|
7631
|
+
import React57, { useContext as useContext12 } from "react";
|
|
7465
7632
|
var Meta = ({ of }) => {
|
|
7466
|
-
let context =
|
|
7633
|
+
let context = useContext12(DocsContext);
|
|
7467
7634
|
of && context.referenceMeta(of, !0);
|
|
7468
7635
|
try {
|
|
7469
7636
|
let primary = context.storyById();
|
package/dist/ember/index.js
CHANGED