@storybook/addon-docs 10.0.0-beta.6 → 10.0.0-beta.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/{chunk-RX6225WF.js → chunk-YDZYZRYC.js} +0 -7
- package/dist/_node-chunks/{chunk-GRMC7DCB.js → chunk-3RDFO5MA.js} +7 -7
- package/dist/_node-chunks/{chunk-6E7NEV5H.js → chunk-D6324MCA.js} +6 -6
- package/dist/_node-chunks/{chunk-WPX3EHQF.js → chunk-KITNKLDD.js} +9 -9
- package/dist/_node-chunks/{chunk-474OTJE6.js → chunk-QD6FYNJS.js} +7 -7
- package/dist/_node-chunks/{mdx-plugin-JIWJW5QN.js → mdx-plugin-VUX2G6E4.js} +12 -12
- package/dist/_node-chunks/{rehype-external-links-MDDVGRIG.js → rehype-external-links-DZ3BLVQO.js} +9 -9
- package/dist/_node-chunks/{rehype-slug-N3RD6447.js → rehype-slug-MCQJAPPE.js} +8 -8
- package/dist/blocks.js +1205 -367
- package/dist/index.js +1 -2
- package/dist/mdx-loader.js +10 -10
- package/dist/preset.js +318 -10
- package/dist/preview.js +1 -2
- package/package.json +4 -4
- package/dist/_browser-chunks/chunk-TQ5Q4DDG.js +0 -846
package/dist/blocks.js
CHANGED
|
@@ -5,9 +5,6 @@ import {
|
|
|
5
5
|
pickBy,
|
|
6
6
|
uniq
|
|
7
7
|
} from "./_browser-chunks/chunk-ZK6NW3SW.js";
|
|
8
|
-
import {
|
|
9
|
-
tocbot_default
|
|
10
|
-
} from "./_browser-chunks/chunk-TQ5Q4DDG.js";
|
|
11
8
|
import {
|
|
12
9
|
EmptyBlock,
|
|
13
10
|
Source,
|
|
@@ -259,7 +256,7 @@ var require_memoizerific = __commonJS({
|
|
|
259
256
|
});
|
|
260
257
|
|
|
261
258
|
// src/blocks/components/ArgsTable/ArgsTable.tsx
|
|
262
|
-
import
|
|
259
|
+
import React34 from "react";
|
|
263
260
|
import { once } from "storybook/internal/client-logger";
|
|
264
261
|
import { IconButton as IconButton3, Link as Link3, ResetWrapper as ResetWrapper3 } from "storybook/internal/components";
|
|
265
262
|
import { includeConditionalArg } from "storybook/internal/csf";
|
|
@@ -659,10 +656,108 @@ var DocsWrapper = styled.div(({ theme }) => ({
|
|
|
659
656
|
var DocsPageWrapper = /* @__PURE__ */ __name(({ children, toc }) => React.createElement(DocsWrapper, { className: "sbdocs sbdocs-wrapper" }, toc, React.createElement(DocsContent, { className: "sbdocs sbdocs-content" }, children)), "DocsPageWrapper");
|
|
660
657
|
|
|
661
658
|
// src/blocks/components/Preview.tsx
|
|
662
|
-
import
|
|
659
|
+
import React6, { Children, useCallback, useContext as useContext2, useState as useState3 } from "react";
|
|
663
660
|
import { ActionBar, Zoom } from "storybook/internal/components";
|
|
664
661
|
import { styled as styled4 } from "storybook/theming";
|
|
665
662
|
|
|
663
|
+
// src/blocks/blocks/DocsContext.ts
|
|
664
|
+
import { createContext } from "react";
|
|
665
|
+
if (globalThis && globalThis.__DOCS_CONTEXT__ === void 0) {
|
|
666
|
+
globalThis.__DOCS_CONTEXT__ = createContext(null);
|
|
667
|
+
globalThis.__DOCS_CONTEXT__.displayName = "DocsContext";
|
|
668
|
+
}
|
|
669
|
+
var DocsContext = globalThis ? globalThis.__DOCS_CONTEXT__ : createContext(null);
|
|
670
|
+
|
|
671
|
+
// src/blocks/blocks/Story.tsx
|
|
672
|
+
import React2, { useContext } from "react";
|
|
673
|
+
|
|
674
|
+
// src/blocks/blocks/useStory.ts
|
|
675
|
+
import { useEffect, useState } from "react";
|
|
676
|
+
function useStory(storyId, context) {
|
|
677
|
+
const stories = useStories([storyId], context);
|
|
678
|
+
return stories && stories[0];
|
|
679
|
+
}
|
|
680
|
+
__name(useStory, "useStory");
|
|
681
|
+
function useStories(storyIds, context) {
|
|
682
|
+
const [storiesById, setStories] = useState({});
|
|
683
|
+
useEffect(() => {
|
|
684
|
+
Promise.all(
|
|
685
|
+
storyIds.map(async (storyId) => {
|
|
686
|
+
const story = await context.loadStory(storyId);
|
|
687
|
+
setStories(
|
|
688
|
+
(current) => current[storyId] === story ? current : { ...current, [storyId]: story }
|
|
689
|
+
);
|
|
690
|
+
})
|
|
691
|
+
);
|
|
692
|
+
});
|
|
693
|
+
return storyIds.map((storyId) => {
|
|
694
|
+
if (storiesById[storyId]) {
|
|
695
|
+
return storiesById[storyId];
|
|
696
|
+
}
|
|
697
|
+
try {
|
|
698
|
+
return context.storyById(storyId);
|
|
699
|
+
} catch (err) {
|
|
700
|
+
return void 0;
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
__name(useStories, "useStories");
|
|
705
|
+
|
|
706
|
+
// src/blocks/blocks/Story.tsx
|
|
707
|
+
var getStoryId = /* @__PURE__ */ __name((props, context) => {
|
|
708
|
+
const { of, meta } = props;
|
|
709
|
+
if ("of" in props && of === void 0) {
|
|
710
|
+
throw new Error("Unexpected `of={undefined}`, did you mistype a CSF file reference?");
|
|
711
|
+
}
|
|
712
|
+
if (meta) {
|
|
713
|
+
context.referenceMeta(meta, false);
|
|
714
|
+
}
|
|
715
|
+
const resolved = context.resolveOf(of || "story", ["story"]);
|
|
716
|
+
return resolved.story.id;
|
|
717
|
+
}, "getStoryId");
|
|
718
|
+
var getStoryProps = /* @__PURE__ */ __name((props, story, context) => {
|
|
719
|
+
const { parameters = {} } = story || {};
|
|
720
|
+
const { docs = {} } = parameters;
|
|
721
|
+
const storyParameters = docs.story || {};
|
|
722
|
+
if (docs.disable) {
|
|
723
|
+
return null;
|
|
724
|
+
}
|
|
725
|
+
const inline = props.inline ?? storyParameters.inline ?? false;
|
|
726
|
+
if (inline) {
|
|
727
|
+
const height2 = props.height ?? storyParameters.height;
|
|
728
|
+
const autoplay = props.autoplay ?? storyParameters.autoplay ?? false;
|
|
729
|
+
return {
|
|
730
|
+
story,
|
|
731
|
+
inline: true,
|
|
732
|
+
height: height2,
|
|
733
|
+
autoplay,
|
|
734
|
+
forceInitialArgs: !!props.__forceInitialArgs,
|
|
735
|
+
primary: !!props.__primary,
|
|
736
|
+
renderStoryToElement: context.renderStoryToElement
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
const height = props.height ?? storyParameters.height ?? storyParameters.iframeHeight ?? "100px";
|
|
740
|
+
return {
|
|
741
|
+
story,
|
|
742
|
+
inline: false,
|
|
743
|
+
height,
|
|
744
|
+
primary: !!props.__primary
|
|
745
|
+
};
|
|
746
|
+
}, "getStoryProps");
|
|
747
|
+
var Story2 = /* @__PURE__ */ __name((props = { __forceInitialArgs: false, __primary: false }) => {
|
|
748
|
+
const context = useContext(DocsContext);
|
|
749
|
+
const storyId = getStoryId(props, context);
|
|
750
|
+
const story = useStory(storyId, context);
|
|
751
|
+
if (!story) {
|
|
752
|
+
return React2.createElement(StorySkeleton, null);
|
|
753
|
+
}
|
|
754
|
+
const storyProps = getStoryProps(props, story, context);
|
|
755
|
+
if (!storyProps) {
|
|
756
|
+
return null;
|
|
757
|
+
}
|
|
758
|
+
return React2.createElement(Story, { ...storyProps });
|
|
759
|
+
}, "Story");
|
|
760
|
+
|
|
666
761
|
// src/blocks/components/BlockBackgroundStyles.tsx
|
|
667
762
|
var getBlockBackgroundStyle = /* @__PURE__ */ __name((theme) => ({
|
|
668
763
|
borderRadius: theme.appBorderRadius,
|
|
@@ -672,12 +767,12 @@ var getBlockBackgroundStyle = /* @__PURE__ */ __name((theme) => ({
|
|
|
672
767
|
}), "getBlockBackgroundStyle");
|
|
673
768
|
|
|
674
769
|
// src/blocks/components/Story.tsx
|
|
675
|
-
import
|
|
770
|
+
import React4, { useEffect as useEffect2, useRef, useState as useState2 } from "react";
|
|
676
771
|
import { ErrorFormatter, Loader, getStoryHref } from "storybook/internal/components";
|
|
677
772
|
import { styled as styled2 } from "storybook/theming";
|
|
678
773
|
|
|
679
774
|
// src/blocks/components/IFrame.tsx
|
|
680
|
-
import
|
|
775
|
+
import React3, { Component } from "react";
|
|
681
776
|
var { window: globalWindow } = globalThis;
|
|
682
777
|
var _IFrame = class _IFrame extends Component {
|
|
683
778
|
constructor() {
|
|
@@ -705,7 +800,7 @@ var _IFrame = class _IFrame extends Component {
|
|
|
705
800
|
}
|
|
706
801
|
render() {
|
|
707
802
|
const { id, title, src, allowFullScreen, scale, ...rest } = this.props;
|
|
708
|
-
return
|
|
803
|
+
return React3.createElement(
|
|
709
804
|
"iframe",
|
|
710
805
|
{
|
|
711
806
|
id,
|
|
@@ -722,8 +817,8 @@ __name(_IFrame, "IFrame");
|
|
|
722
817
|
var IFrame = _IFrame;
|
|
723
818
|
|
|
724
819
|
// src/blocks/components/ZoomContext.tsx
|
|
725
|
-
import { createContext } from "react";
|
|
726
|
-
var ZoomContext =
|
|
820
|
+
import { createContext as createContext2 } from "react";
|
|
821
|
+
var ZoomContext = createContext2({
|
|
727
822
|
scale: 1
|
|
728
823
|
});
|
|
729
824
|
|
|
@@ -733,10 +828,10 @@ var BASE_URL = PREVIEW_URL || "iframe.html";
|
|
|
733
828
|
var storyBlockIdFromId = /* @__PURE__ */ __name(({ story, primary }) => `story--${story.id}${primary ? "--primary" : ""}`, "storyBlockIdFromId");
|
|
734
829
|
var InlineStory = /* @__PURE__ */ __name((props) => {
|
|
735
830
|
const storyRef = useRef();
|
|
736
|
-
const [showLoader, setShowLoader] =
|
|
737
|
-
const [error, setError] =
|
|
831
|
+
const [showLoader, setShowLoader] = useState2(true);
|
|
832
|
+
const [error, setError] = useState2();
|
|
738
833
|
const { story, height, autoplay, forceInitialArgs, renderStoryToElement } = props;
|
|
739
|
-
|
|
834
|
+
useEffect2(() => {
|
|
740
835
|
if (!(story && storyRef.current)) {
|
|
741
836
|
return () => {
|
|
742
837
|
};
|
|
@@ -759,14 +854,14 @@ var InlineStory = /* @__PURE__ */ __name((props) => {
|
|
|
759
854
|
};
|
|
760
855
|
}, [autoplay, renderStoryToElement, story]);
|
|
761
856
|
if (error) {
|
|
762
|
-
return
|
|
857
|
+
return React4.createElement("pre", null, React4.createElement(ErrorFormatter, { error }));
|
|
763
858
|
}
|
|
764
|
-
return
|
|
859
|
+
return React4.createElement(React4.Fragment, null, height ? React4.createElement("style", null, `#${storyBlockIdFromId(
|
|
765
860
|
props
|
|
766
|
-
)} { min-height: ${height}; transform: translateZ(0); overflow: auto }`) : null, showLoader &&
|
|
861
|
+
)} { min-height: ${height}; transform: translateZ(0); overflow: auto }`) : null, showLoader && React4.createElement(StorySkeleton, null), React4.createElement("div", { ref: storyRef, id: `${storyBlockIdFromId(props)}-inner`, "data-name": story.name }));
|
|
767
862
|
}, "InlineStory");
|
|
768
|
-
var IFrameStory = /* @__PURE__ */ __name(({ story, height = "500px" }) =>
|
|
769
|
-
return
|
|
863
|
+
var IFrameStory = /* @__PURE__ */ __name(({ story, height = "500px" }) => React4.createElement("div", { style: { width: "100%", height } }, React4.createElement(ZoomContext.Consumer, null, ({ scale }) => {
|
|
864
|
+
return React4.createElement(
|
|
770
865
|
IFrame,
|
|
771
866
|
{
|
|
772
867
|
key: "iframe",
|
|
@@ -789,16 +884,16 @@ var ErrorMessage = styled2.strong(({ theme }) => ({
|
|
|
789
884
|
var Story = /* @__PURE__ */ __name((props) => {
|
|
790
885
|
const { inline, story } = props;
|
|
791
886
|
if (inline && !props.autoplay && story.usesMount) {
|
|
792
|
-
return
|
|
887
|
+
return React4.createElement(ErrorMessage, null, "This story mounts inside of play. Set", " ", React4.createElement("a", { href: "https://storybook.js.org/docs/api/doc-blocks/doc-block-story?ref=ui#autoplay" }, "autoplay"), " ", "to true to view this story.");
|
|
793
888
|
}
|
|
794
|
-
return
|
|
889
|
+
return React4.createElement("div", { id: storyBlockIdFromId(props), className: "sb-story sb-unstyled", "data-story-block": "true" }, inline ? React4.createElement(InlineStory, { ...props }) : React4.createElement(IFrameStory, { ...props }));
|
|
795
890
|
}, "Story");
|
|
796
|
-
var StorySkeleton = /* @__PURE__ */ __name(() =>
|
|
891
|
+
var StorySkeleton = /* @__PURE__ */ __name(() => React4.createElement(Loader, null), "StorySkeleton");
|
|
797
892
|
|
|
798
893
|
// src/blocks/components/Toolbar.tsx
|
|
799
|
-
import
|
|
800
|
-
import { FlexBar, IconButton } from "storybook/internal/components";
|
|
801
|
-
import { ZoomIcon, ZoomOutIcon, ZoomResetIcon } from "@storybook/icons";
|
|
894
|
+
import React5 from "react";
|
|
895
|
+
import { FlexBar, IconButton, getStoryHref as getStoryHref2 } from "storybook/internal/components";
|
|
896
|
+
import { ShareAltIcon, ZoomIcon, ZoomOutIcon, ZoomResetIcon } from "@storybook/icons";
|
|
802
897
|
import { styled as styled3 } from "storybook/theming";
|
|
803
898
|
var Bar = styled3(FlexBar)({
|
|
804
899
|
position: "absolute",
|
|
@@ -827,7 +922,7 @@ var Toolbar = /* @__PURE__ */ __name(({
|
|
|
827
922
|
zoom,
|
|
828
923
|
resetZoom,
|
|
829
924
|
...rest
|
|
830
|
-
}) =>
|
|
925
|
+
}) => React5.createElement(Bar, { ...rest }, React5.createElement(Wrapper, { key: "left" }, isLoading ? [1, 2, 3].map((key) => React5.createElement(IconPlaceholder, { key })) : React5.createElement(React5.Fragment, null, React5.createElement(
|
|
831
926
|
IconButton,
|
|
832
927
|
{
|
|
833
928
|
key: "zoomin",
|
|
@@ -837,8 +932,8 @@ var Toolbar = /* @__PURE__ */ __name(({
|
|
|
837
932
|
},
|
|
838
933
|
title: "Zoom in"
|
|
839
934
|
},
|
|
840
|
-
|
|
841
|
-
),
|
|
935
|
+
React5.createElement(ZoomIcon, null)
|
|
936
|
+
), React5.createElement(
|
|
842
937
|
IconButton,
|
|
843
938
|
{
|
|
844
939
|
key: "zoomout",
|
|
@@ -848,8 +943,8 @@ var Toolbar = /* @__PURE__ */ __name(({
|
|
|
848
943
|
},
|
|
849
944
|
title: "Zoom out"
|
|
850
945
|
},
|
|
851
|
-
|
|
852
|
-
),
|
|
946
|
+
React5.createElement(ZoomOutIcon, null)
|
|
947
|
+
), React5.createElement(
|
|
853
948
|
IconButton,
|
|
854
949
|
{
|
|
855
950
|
key: "zoomreset",
|
|
@@ -859,7 +954,16 @@ var Toolbar = /* @__PURE__ */ __name(({
|
|
|
859
954
|
},
|
|
860
955
|
title: "Reset zoom"
|
|
861
956
|
},
|
|
862
|
-
|
|
957
|
+
React5.createElement(ZoomResetIcon, null)
|
|
958
|
+
))), isLoading ? React5.createElement(Wrapper, { key: "right" }, React5.createElement(IconPlaceholder, null)) : baseUrl && storyId && React5.createElement(Wrapper, { key: "right" }, React5.createElement(IconButton, { key: "opener", asChild: true }, React5.createElement(
|
|
959
|
+
"a",
|
|
960
|
+
{
|
|
961
|
+
href: getStoryHref2(baseUrl, storyId),
|
|
962
|
+
target: "_blank",
|
|
963
|
+
rel: "noopener noreferrer",
|
|
964
|
+
"aria-label": "Open canvas in new tab"
|
|
965
|
+
},
|
|
966
|
+
React5.createElement(ShareAltIcon, null)
|
|
863
967
|
)))), "Toolbar");
|
|
864
968
|
|
|
865
969
|
// src/blocks/components/Preview.tsx
|
|
@@ -937,7 +1041,7 @@ var getSource = /* @__PURE__ */ __name((withSource, expanded, setExpanded) => {
|
|
|
937
1041
|
}
|
|
938
1042
|
case expanded: {
|
|
939
1043
|
return {
|
|
940
|
-
source:
|
|
1044
|
+
source: React6.createElement(StyledSource, { ...withSource, dark: true }),
|
|
941
1045
|
actionItem: {
|
|
942
1046
|
title: "Hide code",
|
|
943
1047
|
className: "docblock-code-toggle docblock-code-toggle--expanded",
|
|
@@ -947,7 +1051,7 @@ var getSource = /* @__PURE__ */ __name((withSource, expanded, setExpanded) => {
|
|
|
947
1051
|
}
|
|
948
1052
|
default: {
|
|
949
1053
|
return {
|
|
950
|
-
source:
|
|
1054
|
+
source: React6.createElement(StyledSource, { ...withSource, dark: true }),
|
|
951
1055
|
actionItem: {
|
|
952
1056
|
title: "Show code",
|
|
953
1057
|
className: "docblock-code-toggle",
|
|
@@ -957,16 +1061,16 @@ var getSource = /* @__PURE__ */ __name((withSource, expanded, setExpanded) => {
|
|
|
957
1061
|
}
|
|
958
1062
|
}
|
|
959
1063
|
}, "getSource");
|
|
960
|
-
function
|
|
1064
|
+
function getChildProps(children) {
|
|
961
1065
|
if (Children.count(children) === 1) {
|
|
962
1066
|
const elt = children;
|
|
963
1067
|
if (elt.props) {
|
|
964
|
-
return elt.props
|
|
1068
|
+
return elt.props;
|
|
965
1069
|
}
|
|
966
1070
|
}
|
|
967
1071
|
return null;
|
|
968
1072
|
}
|
|
969
|
-
__name(
|
|
1073
|
+
__name(getChildProps, "getChildProps");
|
|
970
1074
|
var PositionedToolbar = styled4(Toolbar)({
|
|
971
1075
|
position: "absolute",
|
|
972
1076
|
top: 0,
|
|
@@ -992,16 +1096,17 @@ var Preview = /* @__PURE__ */ __name(({
|
|
|
992
1096
|
inline = false,
|
|
993
1097
|
...props
|
|
994
1098
|
}) => {
|
|
995
|
-
const [expanded, setExpanded] =
|
|
1099
|
+
const [expanded, setExpanded] = useState3(isExpanded);
|
|
996
1100
|
const { source, actionItem } = getSource(withSource, expanded, setExpanded);
|
|
997
|
-
const [scale, setScale] =
|
|
1101
|
+
const [scale, setScale] = useState3(1);
|
|
998
1102
|
const previewClasses = [className].concat(["sbdocs", "sbdocs-preview", "sb-unstyled"]);
|
|
999
1103
|
const defaultActionItems = withSource ? [actionItem] : [];
|
|
1000
|
-
const [additionalActionItems, setAdditionalActionItems] =
|
|
1104
|
+
const [additionalActionItems, setAdditionalActionItems] = useState3(
|
|
1001
1105
|
additionalActions ? [...additionalActions] : []
|
|
1002
1106
|
);
|
|
1003
1107
|
const actionItems = [...defaultActionItems, ...additionalActionItems];
|
|
1004
1108
|
const { window: globalWindow4 } = globalThis;
|
|
1109
|
+
const context = useContext2(DocsContext);
|
|
1005
1110
|
const copyToClipboard = useCallback(async (text) => {
|
|
1006
1111
|
const { createCopyToClipboardFunction } = await import("storybook/internal/components");
|
|
1007
1112
|
createCopyToClipboardFunction();
|
|
@@ -1031,25 +1136,26 @@ var Preview = /* @__PURE__ */ __name(({
|
|
|
1031
1136
|
});
|
|
1032
1137
|
}
|
|
1033
1138
|
}, "onCopyCapture");
|
|
1034
|
-
|
|
1139
|
+
const childProps = getChildProps(children);
|
|
1140
|
+
return React6.createElement(
|
|
1035
1141
|
PreviewContainer,
|
|
1036
1142
|
{
|
|
1037
1143
|
...{ withSource, withToolbar },
|
|
1038
1144
|
...props,
|
|
1039
1145
|
className: previewClasses.join(" ")
|
|
1040
1146
|
},
|
|
1041
|
-
withToolbar &&
|
|
1147
|
+
withToolbar && React6.createElement(
|
|
1042
1148
|
PositionedToolbar,
|
|
1043
1149
|
{
|
|
1044
1150
|
isLoading,
|
|
1045
1151
|
border: true,
|
|
1046
1152
|
zoom: (z2) => setScale(scale * z2),
|
|
1047
1153
|
resetZoom: () => setScale(1),
|
|
1048
|
-
storyId: getStoryId(
|
|
1154
|
+
storyId: !isLoading && childProps ? getStoryId(childProps, context) : void 0,
|
|
1049
1155
|
baseUrl: "./iframe.html"
|
|
1050
1156
|
}
|
|
1051
1157
|
),
|
|
1052
|
-
|
|
1158
|
+
React6.createElement(ZoomContext.Provider, { value: { scale } }, React6.createElement(Relative, { className: "docs-story", onCopyCapture: withSource && onCopyCapture }, React6.createElement(
|
|
1053
1159
|
ChildrenContainer,
|
|
1054
1160
|
{
|
|
1055
1161
|
isColumn: isColumn || !Array.isArray(children),
|
|
@@ -1057,8 +1163,8 @@ var Preview = /* @__PURE__ */ __name(({
|
|
|
1057
1163
|
layout,
|
|
1058
1164
|
inline
|
|
1059
1165
|
},
|
|
1060
|
-
|
|
1061
|
-
),
|
|
1166
|
+
React6.createElement(Zoom.Element, { centered: layout === "centered", scale: inline ? scale : 1 }, Array.isArray(children) ? children.map((child, i2) => React6.createElement("div", { key: i2 }, child)) : React6.createElement("div", null, children))
|
|
1167
|
+
), React6.createElement(ActionBar, { actionItems }))),
|
|
1062
1168
|
withSource && expanded && source
|
|
1063
1169
|
);
|
|
1064
1170
|
}, "Preview");
|
|
@@ -1070,24 +1176,24 @@ var StyledPreview = styled4(Preview)(() => ({
|
|
|
1070
1176
|
}));
|
|
1071
1177
|
|
|
1072
1178
|
// src/blocks/components/ArgsTable/TabbedArgsTable.tsx
|
|
1073
|
-
import
|
|
1179
|
+
import React7 from "react";
|
|
1074
1180
|
import { TabsState } from "storybook/internal/components";
|
|
1075
1181
|
var TabbedArgsTable = /* @__PURE__ */ __name(({ tabs, ...props }) => {
|
|
1076
1182
|
const entries = Object.entries(tabs);
|
|
1077
1183
|
if (entries.length === 1) {
|
|
1078
|
-
return
|
|
1184
|
+
return React7.createElement(ArgsTable, { ...entries[0][1], ...props });
|
|
1079
1185
|
}
|
|
1080
|
-
return
|
|
1186
|
+
return React7.createElement(TabsState, null, entries.map((entry, index) => {
|
|
1081
1187
|
const [label, table] = entry;
|
|
1082
1188
|
const id = `prop_table_div_${label}`;
|
|
1083
1189
|
const Component4 = "div";
|
|
1084
1190
|
const argsTableProps = index === 0 ? props : { sort: props.sort };
|
|
1085
|
-
return
|
|
1191
|
+
return React7.createElement(Component4, { key: id, id, title: label }, ({ active }) => active ? React7.createElement(ArgsTable, { key: `prop_table_${label}`, ...table, ...argsTableProps }) : null);
|
|
1086
1192
|
}));
|
|
1087
1193
|
}, "TabbedArgsTable");
|
|
1088
1194
|
|
|
1089
1195
|
// src/blocks/components/Typeset.tsx
|
|
1090
|
-
import
|
|
1196
|
+
import React8 from "react";
|
|
1091
1197
|
import { withReset as withReset2 } from "storybook/internal/components";
|
|
1092
1198
|
import { styled as styled5 } from "storybook/theming";
|
|
1093
1199
|
var Label = styled5.div(({ theme }) => ({
|
|
@@ -1117,7 +1223,7 @@ var Typeset = /* @__PURE__ */ __name(({
|
|
|
1117
1223
|
fontWeight,
|
|
1118
1224
|
sampleText,
|
|
1119
1225
|
...props
|
|
1120
|
-
}) =>
|
|
1226
|
+
}) => React8.createElement(Wrapper2, { ...props, className: "docblock-typeset sb-unstyled" }, fontSizes.map((size) => React8.createElement(TypeSpecimen, { key: size }, React8.createElement(Label, null, size), React8.createElement(
|
|
1121
1227
|
Sample,
|
|
1122
1228
|
{
|
|
1123
1229
|
style: {
|
|
@@ -1131,7 +1237,7 @@ var Typeset = /* @__PURE__ */ __name(({
|
|
|
1131
1237
|
)))), "Typeset");
|
|
1132
1238
|
|
|
1133
1239
|
// src/blocks/components/ColorPalette.tsx
|
|
1134
|
-
import
|
|
1240
|
+
import React9 from "react";
|
|
1135
1241
|
import { ResetWrapper } from "storybook/internal/components";
|
|
1136
1242
|
import { styled as styled6 } from "storybook/theming";
|
|
1137
1243
|
var ItemTitle = styled6.div(({ theme }) => ({
|
|
@@ -1230,16 +1336,16 @@ var List = styled6.div(({ theme }) => ({
|
|
|
1230
1336
|
flexDirection: "column"
|
|
1231
1337
|
}));
|
|
1232
1338
|
function renderSwatch(color, index) {
|
|
1233
|
-
return
|
|
1339
|
+
return React9.createElement(Swatch, { key: `${color}-${index}`, title: color, background: color });
|
|
1234
1340
|
}
|
|
1235
1341
|
__name(renderSwatch, "renderSwatch");
|
|
1236
1342
|
function renderSwatchLabel(color, index, colorDescription) {
|
|
1237
|
-
return
|
|
1343
|
+
return React9.createElement(SwatchLabel, { key: `${color}-${index}`, title: color }, React9.createElement("div", null, color, colorDescription && React9.createElement("span", null, colorDescription)));
|
|
1238
1344
|
}
|
|
1239
1345
|
__name(renderSwatchLabel, "renderSwatchLabel");
|
|
1240
1346
|
function renderSwatchSpecimen(colors) {
|
|
1241
1347
|
if (Array.isArray(colors)) {
|
|
1242
|
-
return
|
|
1348
|
+
return React9.createElement(SwatchSpecimen, null, React9.createElement(SwatchColors, null, colors.map((color, index) => renderSwatch(color, index))), React9.createElement(SwatchLabels, null, colors.map((color, index) => renderSwatchLabel(color, index))));
|
|
1243
1349
|
}
|
|
1244
1350
|
const swatchElements = [];
|
|
1245
1351
|
const labelElements = [];
|
|
@@ -1248,16 +1354,16 @@ function renderSwatchSpecimen(colors) {
|
|
|
1248
1354
|
swatchElements.push(renderSwatch(colorValue, swatchElements.length));
|
|
1249
1355
|
labelElements.push(renderSwatchLabel(colorKey, labelElements.length, colorValue));
|
|
1250
1356
|
}
|
|
1251
|
-
return
|
|
1357
|
+
return React9.createElement(SwatchSpecimen, null, React9.createElement(SwatchColors, null, swatchElements), React9.createElement(SwatchLabels, null, labelElements));
|
|
1252
1358
|
}
|
|
1253
1359
|
__name(renderSwatchSpecimen, "renderSwatchSpecimen");
|
|
1254
1360
|
var ColorItem = /* @__PURE__ */ __name(({ title, subtitle, colors }) => {
|
|
1255
|
-
return
|
|
1361
|
+
return React9.createElement(Item, null, React9.createElement(ItemDescription, null, React9.createElement(ItemTitle, null, title), React9.createElement(ItemSubtitle, null, subtitle)), React9.createElement(Swatches, null, renderSwatchSpecimen(colors)));
|
|
1256
1362
|
}, "ColorItem");
|
|
1257
|
-
var ColorPalette = /* @__PURE__ */ __name(({ children, ...props }) =>
|
|
1363
|
+
var ColorPalette = /* @__PURE__ */ __name(({ children, ...props }) => React9.createElement(ResetWrapper, null, React9.createElement(List, { ...props, className: "docblock-colorpalette sb-unstyled" }, React9.createElement(ListHeading, null, React9.createElement(ListName, null, "Name"), React9.createElement(ListSwatches, null, "Swatches")), children)), "ColorPalette");
|
|
1258
1364
|
|
|
1259
1365
|
// src/blocks/components/IconGallery.tsx
|
|
1260
|
-
import
|
|
1366
|
+
import React10 from "react";
|
|
1261
1367
|
import { ResetWrapper as ResetWrapper2 } from "storybook/internal/components";
|
|
1262
1368
|
import { styled as styled7 } from "storybook/theming";
|
|
1263
1369
|
var ItemLabel = styled7.div(({ theme }) => ({
|
|
@@ -1300,13 +1406,843 @@ var List2 = styled7.div({
|
|
|
1300
1406
|
gridAutoFlow: "row dense",
|
|
1301
1407
|
gridAutoRows: 50
|
|
1302
1408
|
});
|
|
1303
|
-
var IconItem = /* @__PURE__ */ __name(({ name, children }) =>
|
|
1304
|
-
var IconGallery = /* @__PURE__ */ __name(({ children, ...props }) =>
|
|
1409
|
+
var IconItem = /* @__PURE__ */ __name(({ name, children }) => React10.createElement(Item2, null, React10.createElement(ItemSpecimen, null, children), React10.createElement(ItemLabel, null, name)), "IconItem");
|
|
1410
|
+
var IconGallery = /* @__PURE__ */ __name(({ children, ...props }) => React10.createElement(ResetWrapper2, null, React10.createElement(List2, { ...props, className: "docblock-icongallery sb-unstyled" }, children)), "IconGallery");
|
|
1305
1411
|
|
|
1306
1412
|
// src/blocks/components/TableOfContents.tsx
|
|
1307
|
-
import
|
|
1413
|
+
import React11, { useEffect as useEffect3, useId } from "react";
|
|
1308
1414
|
import { NAVIGATE_URL } from "storybook/internal/core-events";
|
|
1309
1415
|
import { styled as styled8 } from "storybook/theming";
|
|
1416
|
+
|
|
1417
|
+
// ../../node_modules/tocbot/src/js/build-html.js
|
|
1418
|
+
function build_html_default(options) {
|
|
1419
|
+
const forEach = [].forEach;
|
|
1420
|
+
const some = [].some;
|
|
1421
|
+
const body = typeof window !== "undefined" && document.body;
|
|
1422
|
+
const SPACE_CHAR = " ";
|
|
1423
|
+
let tocElement;
|
|
1424
|
+
let currentlyHighlighting = true;
|
|
1425
|
+
let eventCount = 0;
|
|
1426
|
+
function createEl(d2, container) {
|
|
1427
|
+
const link = container.appendChild(createLink(d2));
|
|
1428
|
+
if (d2.children.length) {
|
|
1429
|
+
const list = createList(d2.isCollapsed);
|
|
1430
|
+
d2.children.forEach((child) => {
|
|
1431
|
+
createEl(child, list);
|
|
1432
|
+
});
|
|
1433
|
+
link.appendChild(list);
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
__name(createEl, "createEl");
|
|
1437
|
+
function render(parent, data) {
|
|
1438
|
+
const collapsed = false;
|
|
1439
|
+
const container = createList(collapsed);
|
|
1440
|
+
data.forEach((d2) => {
|
|
1441
|
+
createEl(d2, container);
|
|
1442
|
+
});
|
|
1443
|
+
tocElement = parent || tocElement;
|
|
1444
|
+
if (tocElement === null) {
|
|
1445
|
+
return;
|
|
1446
|
+
}
|
|
1447
|
+
if (tocElement.firstChild) {
|
|
1448
|
+
tocElement.removeChild(tocElement.firstChild);
|
|
1449
|
+
}
|
|
1450
|
+
if (data.length === 0) {
|
|
1451
|
+
return tocElement;
|
|
1452
|
+
}
|
|
1453
|
+
return tocElement.appendChild(container);
|
|
1454
|
+
}
|
|
1455
|
+
__name(render, "render");
|
|
1456
|
+
function createLink(data) {
|
|
1457
|
+
const item = document.createElement("li");
|
|
1458
|
+
const a2 = document.createElement("a");
|
|
1459
|
+
if (options.listItemClass) {
|
|
1460
|
+
item.setAttribute("class", options.listItemClass);
|
|
1461
|
+
}
|
|
1462
|
+
if (options.onClick) {
|
|
1463
|
+
a2.onclick = options.onClick;
|
|
1464
|
+
}
|
|
1465
|
+
if (options.includeTitleTags) {
|
|
1466
|
+
a2.setAttribute("title", data.textContent);
|
|
1467
|
+
}
|
|
1468
|
+
if (options.includeHtml && data.childNodes.length) {
|
|
1469
|
+
forEach.call(data.childNodes, (node) => {
|
|
1470
|
+
a2.appendChild(node.cloneNode(true));
|
|
1471
|
+
});
|
|
1472
|
+
} else {
|
|
1473
|
+
a2.textContent = data.textContent;
|
|
1474
|
+
}
|
|
1475
|
+
a2.setAttribute("href", `${options.basePath}#${data.id}`);
|
|
1476
|
+
a2.setAttribute(
|
|
1477
|
+
"class",
|
|
1478
|
+
`${options.linkClass + SPACE_CHAR}node-name--${data.nodeName}${SPACE_CHAR}${options.extraLinkClasses}`
|
|
1479
|
+
);
|
|
1480
|
+
item.appendChild(a2);
|
|
1481
|
+
return item;
|
|
1482
|
+
}
|
|
1483
|
+
__name(createLink, "createLink");
|
|
1484
|
+
function createList(isCollapsed) {
|
|
1485
|
+
const listElement = options.orderedList ? "ol" : "ul";
|
|
1486
|
+
const list = document.createElement(listElement);
|
|
1487
|
+
let classes = options.listClass + SPACE_CHAR + options.extraListClasses;
|
|
1488
|
+
if (isCollapsed) {
|
|
1489
|
+
classes = classes + SPACE_CHAR + options.collapsibleClass;
|
|
1490
|
+
classes = classes + SPACE_CHAR + options.isCollapsedClass;
|
|
1491
|
+
}
|
|
1492
|
+
list.setAttribute("class", classes);
|
|
1493
|
+
return list;
|
|
1494
|
+
}
|
|
1495
|
+
__name(createList, "createList");
|
|
1496
|
+
function updateFixedSidebarClass() {
|
|
1497
|
+
const scrollTop = getScrollTop();
|
|
1498
|
+
const posFixedEl = document.querySelector(options.positionFixedSelector);
|
|
1499
|
+
if (options.fixedSidebarOffset === "auto") {
|
|
1500
|
+
options.fixedSidebarOffset = tocElement.offsetTop;
|
|
1501
|
+
}
|
|
1502
|
+
if (scrollTop > options.fixedSidebarOffset) {
|
|
1503
|
+
if (posFixedEl.className.indexOf(options.positionFixedClass) === -1) {
|
|
1504
|
+
posFixedEl.className += SPACE_CHAR + options.positionFixedClass;
|
|
1505
|
+
}
|
|
1506
|
+
} else {
|
|
1507
|
+
posFixedEl.className = posFixedEl.className.replace(
|
|
1508
|
+
SPACE_CHAR + options.positionFixedClass,
|
|
1509
|
+
""
|
|
1510
|
+
);
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
__name(updateFixedSidebarClass, "updateFixedSidebarClass");
|
|
1514
|
+
function getHeadingTopPos(obj) {
|
|
1515
|
+
let position = 0;
|
|
1516
|
+
if (obj !== null) {
|
|
1517
|
+
position = obj.offsetTop;
|
|
1518
|
+
if (options.hasInnerContainers) {
|
|
1519
|
+
position += getHeadingTopPos(obj.offsetParent);
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
return position;
|
|
1523
|
+
}
|
|
1524
|
+
__name(getHeadingTopPos, "getHeadingTopPos");
|
|
1525
|
+
function updateClassname(obj, className) {
|
|
1526
|
+
if (obj && obj.className !== className) {
|
|
1527
|
+
obj.className = className;
|
|
1528
|
+
}
|
|
1529
|
+
return obj;
|
|
1530
|
+
}
|
|
1531
|
+
__name(updateClassname, "updateClassname");
|
|
1532
|
+
function updateToc(headingsArray, event) {
|
|
1533
|
+
if (options.positionFixedSelector) {
|
|
1534
|
+
updateFixedSidebarClass();
|
|
1535
|
+
}
|
|
1536
|
+
const headings = headingsArray;
|
|
1537
|
+
const clickedHref = event?.target?.getAttribute ? event?.target?.getAttribute("href") : null;
|
|
1538
|
+
const isBottomMode = clickedHref && clickedHref.charAt(0) === "#" ? getIsHeaderBottomMode(clickedHref.replace("#", "")) : false;
|
|
1539
|
+
const shouldUpdate = currentlyHighlighting || isBottomMode;
|
|
1540
|
+
if (event && eventCount < 5) {
|
|
1541
|
+
eventCount++;
|
|
1542
|
+
}
|
|
1543
|
+
if (shouldUpdate && !!tocElement && headings.length > 0) {
|
|
1544
|
+
const topHeader = getTopHeader(headings);
|
|
1545
|
+
const oldActiveTocLink = tocElement.querySelector(
|
|
1546
|
+
`.${options.activeLinkClass}`
|
|
1547
|
+
);
|
|
1548
|
+
const topHeaderId = topHeader.id.replace(
|
|
1549
|
+
/([ #;&,.+*~':"!^$[\]()=>|/\\@])/g,
|
|
1550
|
+
"\\$1"
|
|
1551
|
+
);
|
|
1552
|
+
const hashId = window.location.hash.replace("#", "");
|
|
1553
|
+
let activeId = topHeaderId;
|
|
1554
|
+
const isPageBottomMode = getIsPageBottomMode();
|
|
1555
|
+
if (clickedHref && isBottomMode) {
|
|
1556
|
+
activeId = clickedHref.replace("#", "");
|
|
1557
|
+
} else if (hashId && hashId !== topHeaderId && isPageBottomMode && (getIsHeaderBottomMode(topHeaderId) || eventCount <= 2)) {
|
|
1558
|
+
activeId = hashId;
|
|
1559
|
+
}
|
|
1560
|
+
const activeTocLink = tocElement.querySelector(
|
|
1561
|
+
`.${options.linkClass}[href="${options.basePath}#${activeId}"]`
|
|
1562
|
+
);
|
|
1563
|
+
if (oldActiveTocLink === activeTocLink) {
|
|
1564
|
+
return;
|
|
1565
|
+
}
|
|
1566
|
+
const tocLinks = tocElement.querySelectorAll(`.${options.linkClass}`);
|
|
1567
|
+
forEach.call(tocLinks, (tocLink) => {
|
|
1568
|
+
updateClassname(
|
|
1569
|
+
tocLink,
|
|
1570
|
+
tocLink.className.replace(SPACE_CHAR + options.activeLinkClass, "")
|
|
1571
|
+
);
|
|
1572
|
+
});
|
|
1573
|
+
const tocLis = tocElement.querySelectorAll(`.${options.listItemClass}`);
|
|
1574
|
+
forEach.call(tocLis, (tocLi) => {
|
|
1575
|
+
updateClassname(
|
|
1576
|
+
tocLi,
|
|
1577
|
+
tocLi.className.replace(SPACE_CHAR + options.activeListItemClass, "")
|
|
1578
|
+
);
|
|
1579
|
+
});
|
|
1580
|
+
if (activeTocLink && activeTocLink.className.indexOf(options.activeLinkClass) === -1) {
|
|
1581
|
+
activeTocLink.className += SPACE_CHAR + options.activeLinkClass;
|
|
1582
|
+
}
|
|
1583
|
+
const li = activeTocLink?.parentNode;
|
|
1584
|
+
if (li && li.className.indexOf(options.activeListItemClass) === -1) {
|
|
1585
|
+
li.className += SPACE_CHAR + options.activeListItemClass;
|
|
1586
|
+
}
|
|
1587
|
+
const tocLists = tocElement.querySelectorAll(
|
|
1588
|
+
`.${options.listClass}.${options.collapsibleClass}`
|
|
1589
|
+
);
|
|
1590
|
+
forEach.call(tocLists, (list) => {
|
|
1591
|
+
if (list.className.indexOf(options.isCollapsedClass) === -1) {
|
|
1592
|
+
list.className += SPACE_CHAR + options.isCollapsedClass;
|
|
1593
|
+
}
|
|
1594
|
+
});
|
|
1595
|
+
if (activeTocLink?.nextSibling && activeTocLink.nextSibling.className.indexOf(
|
|
1596
|
+
options.isCollapsedClass
|
|
1597
|
+
) !== -1) {
|
|
1598
|
+
updateClassname(
|
|
1599
|
+
activeTocLink.nextSibling,
|
|
1600
|
+
activeTocLink.nextSibling.className.replace(
|
|
1601
|
+
SPACE_CHAR + options.isCollapsedClass,
|
|
1602
|
+
""
|
|
1603
|
+
)
|
|
1604
|
+
);
|
|
1605
|
+
}
|
|
1606
|
+
removeCollapsedFromParents(activeTocLink?.parentNode.parentNode);
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
__name(updateToc, "updateToc");
|
|
1610
|
+
function removeCollapsedFromParents(element) {
|
|
1611
|
+
if (element && element.className.indexOf(options.collapsibleClass) !== -1 && element.className.indexOf(options.isCollapsedClass) !== -1) {
|
|
1612
|
+
updateClassname(
|
|
1613
|
+
element,
|
|
1614
|
+
element.className.replace(SPACE_CHAR + options.isCollapsedClass, "")
|
|
1615
|
+
);
|
|
1616
|
+
return removeCollapsedFromParents(element.parentNode.parentNode);
|
|
1617
|
+
}
|
|
1618
|
+
return element;
|
|
1619
|
+
}
|
|
1620
|
+
__name(removeCollapsedFromParents, "removeCollapsedFromParents");
|
|
1621
|
+
function disableTocAnimation(event) {
|
|
1622
|
+
const target = event.target || event.srcElement;
|
|
1623
|
+
if (typeof target.className !== "string" || target.className.indexOf(options.linkClass) === -1) {
|
|
1624
|
+
return;
|
|
1625
|
+
}
|
|
1626
|
+
currentlyHighlighting = false;
|
|
1627
|
+
}
|
|
1628
|
+
__name(disableTocAnimation, "disableTocAnimation");
|
|
1629
|
+
function enableTocAnimation() {
|
|
1630
|
+
currentlyHighlighting = true;
|
|
1631
|
+
}
|
|
1632
|
+
__name(enableTocAnimation, "enableTocAnimation");
|
|
1633
|
+
function getCurrentlyHighlighting() {
|
|
1634
|
+
return currentlyHighlighting;
|
|
1635
|
+
}
|
|
1636
|
+
__name(getCurrentlyHighlighting, "getCurrentlyHighlighting");
|
|
1637
|
+
function getIsHeaderBottomMode(headerId) {
|
|
1638
|
+
const scrollEl = getScrollEl();
|
|
1639
|
+
const activeHeading = document?.getElementById(headerId);
|
|
1640
|
+
const isBottomMode = activeHeading.offsetTop > scrollEl.offsetHeight - scrollEl.clientHeight * 1.4 - options.bottomModeThreshold;
|
|
1641
|
+
return isBottomMode;
|
|
1642
|
+
}
|
|
1643
|
+
__name(getIsHeaderBottomMode, "getIsHeaderBottomMode");
|
|
1644
|
+
function getIsPageBottomMode() {
|
|
1645
|
+
const scrollEl = getScrollEl();
|
|
1646
|
+
const isScrollable = scrollEl.scrollHeight > scrollEl.clientHeight;
|
|
1647
|
+
const isBottomMode = getScrollTop() + scrollEl.clientHeight > scrollEl.offsetHeight - options.bottomModeThreshold;
|
|
1648
|
+
return isScrollable && isBottomMode;
|
|
1649
|
+
}
|
|
1650
|
+
__name(getIsPageBottomMode, "getIsPageBottomMode");
|
|
1651
|
+
function getScrollEl() {
|
|
1652
|
+
let el;
|
|
1653
|
+
if (options.scrollContainer && document.querySelector(options.scrollContainer)) {
|
|
1654
|
+
el = document.querySelector(options.scrollContainer);
|
|
1655
|
+
} else {
|
|
1656
|
+
el = document.documentElement || body;
|
|
1657
|
+
}
|
|
1658
|
+
return el;
|
|
1659
|
+
}
|
|
1660
|
+
__name(getScrollEl, "getScrollEl");
|
|
1661
|
+
function getScrollTop() {
|
|
1662
|
+
const el = getScrollEl();
|
|
1663
|
+
return el?.scrollTop || 0;
|
|
1664
|
+
}
|
|
1665
|
+
__name(getScrollTop, "getScrollTop");
|
|
1666
|
+
function getTopHeader(headings, scrollTop = getScrollTop()) {
|
|
1667
|
+
let topHeader;
|
|
1668
|
+
some.call(headings, (heading, i2) => {
|
|
1669
|
+
if (getHeadingTopPos(heading) > scrollTop + options.headingsOffset + 10) {
|
|
1670
|
+
const index = i2 === 0 ? i2 : i2 - 1;
|
|
1671
|
+
topHeader = headings[index];
|
|
1672
|
+
return true;
|
|
1673
|
+
}
|
|
1674
|
+
if (i2 === headings.length - 1) {
|
|
1675
|
+
topHeader = headings[headings.length - 1];
|
|
1676
|
+
return true;
|
|
1677
|
+
}
|
|
1678
|
+
});
|
|
1679
|
+
return topHeader;
|
|
1680
|
+
}
|
|
1681
|
+
__name(getTopHeader, "getTopHeader");
|
|
1682
|
+
function updateUrlHashForHeader(headingsArray) {
|
|
1683
|
+
const scrollTop = getScrollTop();
|
|
1684
|
+
const topHeader = getTopHeader(headingsArray, scrollTop);
|
|
1685
|
+
const isPageBottomMode = getIsPageBottomMode();
|
|
1686
|
+
if ((!topHeader || scrollTop < 5) && !isPageBottomMode) {
|
|
1687
|
+
if (!(window.location.hash === "#" || window.location.hash === "")) {
|
|
1688
|
+
window.history.pushState(null, null, "#");
|
|
1689
|
+
}
|
|
1690
|
+
} else if (topHeader && !isPageBottomMode) {
|
|
1691
|
+
const newHash = `#${topHeader.id}`;
|
|
1692
|
+
if (window.location.hash !== newHash) {
|
|
1693
|
+
window.history.pushState(null, null, newHash);
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
__name(updateUrlHashForHeader, "updateUrlHashForHeader");
|
|
1698
|
+
return {
|
|
1699
|
+
enableTocAnimation,
|
|
1700
|
+
disableTocAnimation,
|
|
1701
|
+
render,
|
|
1702
|
+
updateToc,
|
|
1703
|
+
getCurrentlyHighlighting,
|
|
1704
|
+
getTopHeader,
|
|
1705
|
+
getScrollTop,
|
|
1706
|
+
updateUrlHashForHeader
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1709
|
+
__name(build_html_default, "default");
|
|
1710
|
+
|
|
1711
|
+
// ../../node_modules/tocbot/src/js/default-options.js
|
|
1712
|
+
var default_options_default = {
|
|
1713
|
+
// Where to render the table of contents.
|
|
1714
|
+
tocSelector: ".js-toc",
|
|
1715
|
+
// Or, you can pass in a DOM node instead
|
|
1716
|
+
tocElement: null,
|
|
1717
|
+
// Where to grab the headings to build the table of contents.
|
|
1718
|
+
contentSelector: ".js-toc-content",
|
|
1719
|
+
// Or, you can pass in a DOM node instead
|
|
1720
|
+
contentElement: null,
|
|
1721
|
+
// Which headings to grab inside of the contentSelector element.
|
|
1722
|
+
headingSelector: "h1, h2, h3",
|
|
1723
|
+
// Headings that match the ignoreSelector will be skipped.
|
|
1724
|
+
ignoreSelector: ".js-toc-ignore",
|
|
1725
|
+
// For headings inside relative or absolute positioned
|
|
1726
|
+
// containers within content.
|
|
1727
|
+
hasInnerContainers: false,
|
|
1728
|
+
// Main class to add to links.
|
|
1729
|
+
linkClass: "toc-link",
|
|
1730
|
+
// Extra classes to add to links.
|
|
1731
|
+
extraLinkClasses: "",
|
|
1732
|
+
// Class to add to active links,
|
|
1733
|
+
// the link corresponding to the top most heading on the page.
|
|
1734
|
+
activeLinkClass: "is-active-link",
|
|
1735
|
+
// Main class to add to lists.
|
|
1736
|
+
listClass: "toc-list",
|
|
1737
|
+
// Extra classes to add to lists.
|
|
1738
|
+
extraListClasses: "",
|
|
1739
|
+
// Class that gets added when a list should be collapsed.
|
|
1740
|
+
isCollapsedClass: "is-collapsed",
|
|
1741
|
+
// Class that gets added when a list should be able
|
|
1742
|
+
// to be collapsed but isn't necessarily collapsed.
|
|
1743
|
+
collapsibleClass: "is-collapsible",
|
|
1744
|
+
// Class to add to list items.
|
|
1745
|
+
listItemClass: "toc-list-item",
|
|
1746
|
+
// Class to add to active list items.
|
|
1747
|
+
activeListItemClass: "is-active-li",
|
|
1748
|
+
// How many heading levels should not be collapsed.
|
|
1749
|
+
// For example, number 6 will show everything since
|
|
1750
|
+
// there are only 6 heading levels and number 0 will collapse them all.
|
|
1751
|
+
// The sections that are hidden will open
|
|
1752
|
+
// and close as you scroll to headings within them.
|
|
1753
|
+
collapseDepth: 0,
|
|
1754
|
+
// Smooth scrolling enabled.
|
|
1755
|
+
scrollSmooth: true,
|
|
1756
|
+
// Smooth scroll duration.
|
|
1757
|
+
scrollSmoothDuration: 420,
|
|
1758
|
+
// Smooth scroll offset.
|
|
1759
|
+
scrollSmoothOffset: 0,
|
|
1760
|
+
// Callback for scroll end.
|
|
1761
|
+
scrollEndCallback: /* @__PURE__ */ __name(function(e2) {
|
|
1762
|
+
}, "scrollEndCallback"),
|
|
1763
|
+
// Headings offset between the headings and the top of
|
|
1764
|
+
// the document (this is meant for minor adjustments).
|
|
1765
|
+
headingsOffset: 1,
|
|
1766
|
+
// Enable the URL hash to update with the proper heading ID as
|
|
1767
|
+
// a user scrolls the page.
|
|
1768
|
+
enableUrlHashUpdateOnScroll: false,
|
|
1769
|
+
// type of scroll handler to use. to make scroll event not too rapid.
|
|
1770
|
+
// Options are: "debounce" or "throttle"
|
|
1771
|
+
// when set auto , use debounce less than 333ms , other use throttle.
|
|
1772
|
+
// for ios browser can't use history.pushState() more than 100 times per 30 seconds reason
|
|
1773
|
+
scrollHandlerType: "auto",
|
|
1774
|
+
// scrollHandler delay in ms.
|
|
1775
|
+
scrollHandlerTimeout: 50,
|
|
1776
|
+
// Timeout between events firing to make sure it's
|
|
1777
|
+
// not too rapid (for performance reasons).
|
|
1778
|
+
throttleTimeout: 50,
|
|
1779
|
+
// Element to add the positionFixedClass to.
|
|
1780
|
+
positionFixedSelector: null,
|
|
1781
|
+
// Fixed position class to add to make sidebar fixed after scrolling
|
|
1782
|
+
// down past the fixedSidebarOffset.
|
|
1783
|
+
positionFixedClass: "is-position-fixed",
|
|
1784
|
+
// fixedSidebarOffset can be any number but by default is set
|
|
1785
|
+
// to auto which sets the fixedSidebarOffset to the sidebar
|
|
1786
|
+
// element's offsetTop from the top of the document on init.
|
|
1787
|
+
fixedSidebarOffset: "auto",
|
|
1788
|
+
// includeHtml can be set to true to include the HTML markup from the
|
|
1789
|
+
// heading node instead of just including the innerText.
|
|
1790
|
+
includeHtml: false,
|
|
1791
|
+
// includeTitleTags automatically sets the html title tag of the link
|
|
1792
|
+
// to match the title. This can be useful for SEO purposes or
|
|
1793
|
+
// when truncating titles.
|
|
1794
|
+
includeTitleTags: false,
|
|
1795
|
+
// onclick function to apply to all links in toc. will be called with
|
|
1796
|
+
// the event as the first parameter, and this can be used to stop,
|
|
1797
|
+
// propagation, prevent default or perform action
|
|
1798
|
+
onClick: /* @__PURE__ */ __name(function(e2) {
|
|
1799
|
+
}, "onClick"),
|
|
1800
|
+
// orderedList can be set to false to generate unordered lists (ul)
|
|
1801
|
+
// instead of ordered lists (ol)
|
|
1802
|
+
orderedList: true,
|
|
1803
|
+
// If there is a fixed article scroll container, set to calculate offset.
|
|
1804
|
+
scrollContainer: null,
|
|
1805
|
+
// prevent ToC DOM rendering if it's already rendered by an external system.
|
|
1806
|
+
skipRendering: false,
|
|
1807
|
+
// Optional callback to change heading labels.
|
|
1808
|
+
// For example it can be used to cut down and put ellipses on multiline headings you deem too long.
|
|
1809
|
+
// Called each time a heading is parsed. Expects a string and returns the modified label to display.
|
|
1810
|
+
// Additionally, the attribute `data-heading-label` may be used on a heading to specify
|
|
1811
|
+
// a shorter string to be used in the TOC.
|
|
1812
|
+
// function (string) => string
|
|
1813
|
+
headingLabelCallback: false,
|
|
1814
|
+
// ignore headings that are hidden in DOM
|
|
1815
|
+
ignoreHiddenElements: false,
|
|
1816
|
+
// Optional callback to modify properties of parsed headings.
|
|
1817
|
+
// The heading element is passed in node parameter and information
|
|
1818
|
+
// parsed by default parser is provided in obj parameter.
|
|
1819
|
+
// Function has to return the same or modified obj.
|
|
1820
|
+
// The heading will be excluded from TOC if nothing is returned.
|
|
1821
|
+
// function (object, HTMLElement) => object | void
|
|
1822
|
+
headingObjectCallback: null,
|
|
1823
|
+
// Set the base path, useful if you use a `base` tag in `head`.
|
|
1824
|
+
basePath: "",
|
|
1825
|
+
// Only takes affect when `tocSelector` is scrolling,
|
|
1826
|
+
// keep the toc scroll position in sync with the content.
|
|
1827
|
+
disableTocScrollSync: false,
|
|
1828
|
+
// If this is null then just use `tocElement` or `tocSelector` instead
|
|
1829
|
+
// assuming `disableTocScrollSync` is set to false. This allows for
|
|
1830
|
+
// scrolling an outer element (like a nav panel w/ search) containing the toc.
|
|
1831
|
+
// Please pass an element, not a selector here.
|
|
1832
|
+
tocScrollingWrapper: null,
|
|
1833
|
+
// Offset for the toc scroll (top) position when scrolling the page.
|
|
1834
|
+
// Only effective if `disableTocScrollSync` is false.
|
|
1835
|
+
tocScrollOffset: 30,
|
|
1836
|
+
// Threshold for when bottom mode should be enabled to handle
|
|
1837
|
+
// highlighting links that cannot be scrolled to.
|
|
1838
|
+
bottomModeThreshold: 30
|
|
1839
|
+
};
|
|
1840
|
+
|
|
1841
|
+
// ../../node_modules/tocbot/src/js/parse-content.js
|
|
1842
|
+
function parseContent(options) {
|
|
1843
|
+
const reduce = [].reduce;
|
|
1844
|
+
function getLastItem(array2) {
|
|
1845
|
+
return array2[array2.length - 1];
|
|
1846
|
+
}
|
|
1847
|
+
__name(getLastItem, "getLastItem");
|
|
1848
|
+
function getHeadingLevel(heading) {
|
|
1849
|
+
return +heading.nodeName.toUpperCase().replace("H", "");
|
|
1850
|
+
}
|
|
1851
|
+
__name(getHeadingLevel, "getHeadingLevel");
|
|
1852
|
+
function isHTMLElement(maybeElement) {
|
|
1853
|
+
try {
|
|
1854
|
+
return maybeElement instanceof window.HTMLElement || maybeElement instanceof window.parent.HTMLElement;
|
|
1855
|
+
} catch (e2) {
|
|
1856
|
+
return maybeElement instanceof window.HTMLElement;
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
__name(isHTMLElement, "isHTMLElement");
|
|
1860
|
+
function getHeadingObject(heading) {
|
|
1861
|
+
if (!isHTMLElement(heading)) return heading;
|
|
1862
|
+
if (options.ignoreHiddenElements && (!heading.offsetHeight || !heading.offsetParent)) {
|
|
1863
|
+
return null;
|
|
1864
|
+
}
|
|
1865
|
+
const headingLabel = heading.getAttribute("data-heading-label") || (options.headingLabelCallback ? String(options.headingLabelCallback(heading.innerText)) : (heading.innerText || heading.textContent).trim());
|
|
1866
|
+
const obj = {
|
|
1867
|
+
id: heading.id,
|
|
1868
|
+
children: [],
|
|
1869
|
+
nodeName: heading.nodeName,
|
|
1870
|
+
headingLevel: getHeadingLevel(heading),
|
|
1871
|
+
textContent: headingLabel
|
|
1872
|
+
};
|
|
1873
|
+
if (options.includeHtml) {
|
|
1874
|
+
obj.childNodes = heading.childNodes;
|
|
1875
|
+
}
|
|
1876
|
+
if (options.headingObjectCallback) {
|
|
1877
|
+
return options.headingObjectCallback(obj, heading);
|
|
1878
|
+
}
|
|
1879
|
+
return obj;
|
|
1880
|
+
}
|
|
1881
|
+
__name(getHeadingObject, "getHeadingObject");
|
|
1882
|
+
function addNode(node, nest) {
|
|
1883
|
+
const obj = getHeadingObject(node);
|
|
1884
|
+
const level = obj.headingLevel;
|
|
1885
|
+
let array2 = nest;
|
|
1886
|
+
let lastItem = getLastItem(array2);
|
|
1887
|
+
const lastItemLevel = lastItem ? lastItem.headingLevel : 0;
|
|
1888
|
+
let counter = level - lastItemLevel;
|
|
1889
|
+
while (counter > 0) {
|
|
1890
|
+
lastItem = getLastItem(array2);
|
|
1891
|
+
if (lastItem && level === lastItem.headingLevel) {
|
|
1892
|
+
break;
|
|
1893
|
+
} else if (lastItem && lastItem.children !== void 0) {
|
|
1894
|
+
array2 = lastItem.children;
|
|
1895
|
+
}
|
|
1896
|
+
counter--;
|
|
1897
|
+
}
|
|
1898
|
+
if (level >= options.collapseDepth) {
|
|
1899
|
+
obj.isCollapsed = true;
|
|
1900
|
+
}
|
|
1901
|
+
array2.push(obj);
|
|
1902
|
+
return array2;
|
|
1903
|
+
}
|
|
1904
|
+
__name(addNode, "addNode");
|
|
1905
|
+
function selectHeadings(contentElement, headingSelector) {
|
|
1906
|
+
let selectors = headingSelector;
|
|
1907
|
+
if (options.ignoreSelector) {
|
|
1908
|
+
selectors = headingSelector.split(",").map(/* @__PURE__ */ __name(function mapSelectors(selector) {
|
|
1909
|
+
return `${selector.trim()}:not(${options.ignoreSelector})`;
|
|
1910
|
+
}, "mapSelectors"));
|
|
1911
|
+
}
|
|
1912
|
+
try {
|
|
1913
|
+
return contentElement.querySelectorAll(selectors);
|
|
1914
|
+
} catch (e2) {
|
|
1915
|
+
console.warn(`Headers not found with selector: ${selectors}`);
|
|
1916
|
+
return null;
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
__name(selectHeadings, "selectHeadings");
|
|
1920
|
+
function nestHeadingsArray(headingsArray) {
|
|
1921
|
+
return reduce.call(
|
|
1922
|
+
headingsArray,
|
|
1923
|
+
/* @__PURE__ */ __name(function reducer(prev, curr) {
|
|
1924
|
+
const currentHeading = getHeadingObject(curr);
|
|
1925
|
+
if (currentHeading) {
|
|
1926
|
+
addNode(currentHeading, prev.nest);
|
|
1927
|
+
}
|
|
1928
|
+
return prev;
|
|
1929
|
+
}, "reducer"),
|
|
1930
|
+
{
|
|
1931
|
+
nest: []
|
|
1932
|
+
}
|
|
1933
|
+
);
|
|
1934
|
+
}
|
|
1935
|
+
__name(nestHeadingsArray, "nestHeadingsArray");
|
|
1936
|
+
return {
|
|
1937
|
+
nestHeadingsArray,
|
|
1938
|
+
selectHeadings
|
|
1939
|
+
};
|
|
1940
|
+
}
|
|
1941
|
+
__name(parseContent, "parseContent");
|
|
1942
|
+
|
|
1943
|
+
// ../../node_modules/tocbot/src/js/scroll-smooth/index.js
|
|
1944
|
+
function initSmoothScrolling(options) {
|
|
1945
|
+
var duration = options.duration;
|
|
1946
|
+
var offset = options.offset;
|
|
1947
|
+
if (typeof window === "undefined" || typeof location === "undefined") return;
|
|
1948
|
+
var pageUrl = location.hash ? stripHash(location.href) : location.href;
|
|
1949
|
+
delegatedLinkHijacking();
|
|
1950
|
+
function delegatedLinkHijacking() {
|
|
1951
|
+
document.body.addEventListener("click", onClick, false);
|
|
1952
|
+
function onClick(e2) {
|
|
1953
|
+
if (!isInPageLink(e2.target) || e2.target.className.indexOf("no-smooth-scroll") > -1 || e2.target.href.charAt(e2.target.href.length - 2) === "#" && e2.target.href.charAt(e2.target.href.length - 1) === "!" || e2.target.className.indexOf(options.linkClass) === -1) {
|
|
1954
|
+
return;
|
|
1955
|
+
}
|
|
1956
|
+
jump(e2.target.hash, {
|
|
1957
|
+
duration,
|
|
1958
|
+
offset,
|
|
1959
|
+
callback: /* @__PURE__ */ __name(function() {
|
|
1960
|
+
setFocus(e2.target.hash);
|
|
1961
|
+
}, "callback")
|
|
1962
|
+
});
|
|
1963
|
+
}
|
|
1964
|
+
__name(onClick, "onClick");
|
|
1965
|
+
}
|
|
1966
|
+
__name(delegatedLinkHijacking, "delegatedLinkHijacking");
|
|
1967
|
+
function isInPageLink(n2) {
|
|
1968
|
+
return n2.tagName.toLowerCase() === "a" && (n2.hash.length > 0 || n2.href.charAt(n2.href.length - 1) === "#") && (stripHash(n2.href) === pageUrl || stripHash(n2.href) + "#" === pageUrl);
|
|
1969
|
+
}
|
|
1970
|
+
__name(isInPageLink, "isInPageLink");
|
|
1971
|
+
function stripHash(url) {
|
|
1972
|
+
return url.slice(0, url.lastIndexOf("#"));
|
|
1973
|
+
}
|
|
1974
|
+
__name(stripHash, "stripHash");
|
|
1975
|
+
function setFocus(hash) {
|
|
1976
|
+
var element = document.getElementById(hash.substring(1));
|
|
1977
|
+
if (element) {
|
|
1978
|
+
if (!/^(?:a|select|input|button|textarea)$/i.test(element.tagName)) {
|
|
1979
|
+
element.tabIndex = -1;
|
|
1980
|
+
}
|
|
1981
|
+
element.focus();
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
__name(setFocus, "setFocus");
|
|
1985
|
+
}
|
|
1986
|
+
__name(initSmoothScrolling, "initSmoothScrolling");
|
|
1987
|
+
function jump(target, options) {
|
|
1988
|
+
var start = window.pageYOffset;
|
|
1989
|
+
var opt = {
|
|
1990
|
+
duration: options.duration,
|
|
1991
|
+
offset: options.offset || 0,
|
|
1992
|
+
callback: options.callback,
|
|
1993
|
+
easing: options.easing || easeInOutQuad
|
|
1994
|
+
};
|
|
1995
|
+
var tgt = document.querySelector(
|
|
1996
|
+
'[id="' + decodeURI(target).split("#").join("") + '"]'
|
|
1997
|
+
) || document.querySelector('[id="' + target.split("#").join("") + '"]');
|
|
1998
|
+
var distance = typeof target === "string" ? opt.offset + (target ? tgt && tgt.getBoundingClientRect().top || 0 : -(document.documentElement.scrollTop || document.body.scrollTop)) : target;
|
|
1999
|
+
var duration = typeof opt.duration === "function" ? opt.duration(distance) : opt.duration;
|
|
2000
|
+
var timeStart;
|
|
2001
|
+
var timeElapsed;
|
|
2002
|
+
requestAnimationFrame(function(time) {
|
|
2003
|
+
timeStart = time;
|
|
2004
|
+
loop(time);
|
|
2005
|
+
});
|
|
2006
|
+
function loop(time) {
|
|
2007
|
+
timeElapsed = time - timeStart;
|
|
2008
|
+
window.scrollTo(0, opt.easing(timeElapsed, start, distance, duration));
|
|
2009
|
+
if (timeElapsed < duration) {
|
|
2010
|
+
requestAnimationFrame(loop);
|
|
2011
|
+
} else {
|
|
2012
|
+
end();
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
__name(loop, "loop");
|
|
2016
|
+
function end() {
|
|
2017
|
+
window.scrollTo(0, start + distance);
|
|
2018
|
+
if (typeof opt.callback === "function") {
|
|
2019
|
+
opt.callback();
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
__name(end, "end");
|
|
2023
|
+
function easeInOutQuad(t, b2, c2, d2) {
|
|
2024
|
+
t /= d2 / 2;
|
|
2025
|
+
if (t < 1) return c2 / 2 * t * t + b2;
|
|
2026
|
+
t--;
|
|
2027
|
+
return -c2 / 2 * (t * (t - 2) - 1) + b2;
|
|
2028
|
+
}
|
|
2029
|
+
__name(easeInOutQuad, "easeInOutQuad");
|
|
2030
|
+
}
|
|
2031
|
+
__name(jump, "jump");
|
|
2032
|
+
|
|
2033
|
+
// ../../node_modules/tocbot/src/js/update-toc-scroll.js
|
|
2034
|
+
function updateTocScroll(options) {
|
|
2035
|
+
const toc = options.tocScrollingWrapper || options.tocElement || document.querySelector(options.tocSelector);
|
|
2036
|
+
if (toc && toc.scrollHeight > toc.clientHeight) {
|
|
2037
|
+
const activeItem = toc.querySelector(`.${options.activeListItemClass}`);
|
|
2038
|
+
if (activeItem) {
|
|
2039
|
+
const eTop = activeItem.offsetTop;
|
|
2040
|
+
const scrollAmount = eTop - options.tocScrollOffset;
|
|
2041
|
+
toc.scrollTop = scrollAmount > 0 ? scrollAmount : 0;
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
__name(updateTocScroll, "updateTocScroll");
|
|
2046
|
+
|
|
2047
|
+
// ../../node_modules/tocbot/src/js/index-esm.js
|
|
2048
|
+
var _options = {};
|
|
2049
|
+
var _buildHtml;
|
|
2050
|
+
var _parseContent;
|
|
2051
|
+
var _headingsArray;
|
|
2052
|
+
var _scrollListener;
|
|
2053
|
+
var clickListener;
|
|
2054
|
+
function init(customOptions) {
|
|
2055
|
+
let hasInitialized = false;
|
|
2056
|
+
_options = extend(default_options_default, customOptions || {});
|
|
2057
|
+
if (_options.scrollSmooth) {
|
|
2058
|
+
_options.duration = _options.scrollSmoothDuration;
|
|
2059
|
+
_options.offset = _options.scrollSmoothOffset;
|
|
2060
|
+
initSmoothScrolling(_options);
|
|
2061
|
+
}
|
|
2062
|
+
_buildHtml = build_html_default(_options);
|
|
2063
|
+
_parseContent = parseContent(_options);
|
|
2064
|
+
destroy();
|
|
2065
|
+
const contentElement = getContentElement(_options);
|
|
2066
|
+
if (contentElement === null) {
|
|
2067
|
+
return;
|
|
2068
|
+
}
|
|
2069
|
+
const tocElement = getTocElement(_options);
|
|
2070
|
+
if (tocElement === null) {
|
|
2071
|
+
return;
|
|
2072
|
+
}
|
|
2073
|
+
_headingsArray = _parseContent.selectHeadings(
|
|
2074
|
+
contentElement,
|
|
2075
|
+
_options.headingSelector
|
|
2076
|
+
);
|
|
2077
|
+
if (_headingsArray === null) {
|
|
2078
|
+
return;
|
|
2079
|
+
}
|
|
2080
|
+
const nestedHeadingsObj = _parseContent.nestHeadingsArray(_headingsArray);
|
|
2081
|
+
const nestedHeadings = nestedHeadingsObj.nest;
|
|
2082
|
+
if (!_options.skipRendering) {
|
|
2083
|
+
_buildHtml.render(tocElement, nestedHeadings);
|
|
2084
|
+
} else {
|
|
2085
|
+
return this;
|
|
2086
|
+
}
|
|
2087
|
+
let isClick = false;
|
|
2088
|
+
const scrollHandlerTimeout = _options.scrollHandlerTimeout || _options.throttleTimeout;
|
|
2089
|
+
const scrollHandler = /* @__PURE__ */ __name((fn, delay) => getScrollHandler(fn, delay, _options.scrollHandlerType), "scrollHandler");
|
|
2090
|
+
_scrollListener = scrollHandler((e2) => {
|
|
2091
|
+
_buildHtml.updateToc(_headingsArray, e2);
|
|
2092
|
+
!_options.disableTocScrollSync && !isClick && updateTocScroll(_options);
|
|
2093
|
+
if (_options.enableUrlHashUpdateOnScroll && hasInitialized) {
|
|
2094
|
+
const enableUpdatingHash = _buildHtml.getCurrentlyHighlighting();
|
|
2095
|
+
enableUpdatingHash && _buildHtml.updateUrlHashForHeader(_headingsArray);
|
|
2096
|
+
}
|
|
2097
|
+
const isTop = e2?.target?.scrollingElement?.scrollTop === 0;
|
|
2098
|
+
if (e2 && (e2.eventPhase === 0 || e2.currentTarget === null) || isTop) {
|
|
2099
|
+
_buildHtml.updateToc(_headingsArray);
|
|
2100
|
+
_options.scrollEndCallback?.(e2);
|
|
2101
|
+
}
|
|
2102
|
+
}, scrollHandlerTimeout);
|
|
2103
|
+
if (!hasInitialized) {
|
|
2104
|
+
_scrollListener();
|
|
2105
|
+
hasInitialized = true;
|
|
2106
|
+
}
|
|
2107
|
+
window.onhashchange = window.onscrollend = (e2) => {
|
|
2108
|
+
_scrollListener(e2);
|
|
2109
|
+
};
|
|
2110
|
+
if (_options.scrollContainer && document.querySelector(_options.scrollContainer)) {
|
|
2111
|
+
document.querySelector(_options.scrollContainer).addEventListener("scroll", _scrollListener, false);
|
|
2112
|
+
document.querySelector(_options.scrollContainer).addEventListener("resize", _scrollListener, false);
|
|
2113
|
+
} else {
|
|
2114
|
+
document.addEventListener("scroll", _scrollListener, false);
|
|
2115
|
+
document.addEventListener("resize", _scrollListener, false);
|
|
2116
|
+
}
|
|
2117
|
+
let timeout = null;
|
|
2118
|
+
clickListener = throttle((event) => {
|
|
2119
|
+
isClick = true;
|
|
2120
|
+
if (_options.scrollSmooth) {
|
|
2121
|
+
_buildHtml.disableTocAnimation(event);
|
|
2122
|
+
}
|
|
2123
|
+
_buildHtml.updateToc(_headingsArray, event);
|
|
2124
|
+
timeout && clearTimeout(timeout);
|
|
2125
|
+
timeout = setTimeout(() => {
|
|
2126
|
+
_buildHtml.enableTocAnimation();
|
|
2127
|
+
}, _options.scrollSmoothDuration);
|
|
2128
|
+
setTimeout(() => {
|
|
2129
|
+
isClick = false;
|
|
2130
|
+
}, _options.scrollSmoothDuration + 100);
|
|
2131
|
+
}, _options.throttleTimeout);
|
|
2132
|
+
if (_options.scrollContainer && document.querySelector(_options.scrollContainer)) {
|
|
2133
|
+
document.querySelector(_options.scrollContainer).addEventListener("click", clickListener, false);
|
|
2134
|
+
} else {
|
|
2135
|
+
document.addEventListener("click", clickListener, false);
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
__name(init, "init");
|
|
2139
|
+
function destroy() {
|
|
2140
|
+
const tocElement = getTocElement(_options);
|
|
2141
|
+
if (tocElement === null) {
|
|
2142
|
+
return;
|
|
2143
|
+
}
|
|
2144
|
+
if (!_options.skipRendering) {
|
|
2145
|
+
if (tocElement) {
|
|
2146
|
+
tocElement.innerHTML = "";
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
if (_options.scrollContainer && document.querySelector(_options.scrollContainer)) {
|
|
2150
|
+
document.querySelector(_options.scrollContainer).removeEventListener("scroll", _scrollListener, false);
|
|
2151
|
+
document.querySelector(_options.scrollContainer).removeEventListener("resize", _scrollListener, false);
|
|
2152
|
+
if (_buildHtml) {
|
|
2153
|
+
document.querySelector(_options.scrollContainer).removeEventListener("click", clickListener, false);
|
|
2154
|
+
}
|
|
2155
|
+
} else {
|
|
2156
|
+
document.removeEventListener("scroll", _scrollListener, false);
|
|
2157
|
+
document.removeEventListener("resize", _scrollListener, false);
|
|
2158
|
+
if (_buildHtml) {
|
|
2159
|
+
document.removeEventListener("click", clickListener, false);
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
__name(destroy, "destroy");
|
|
2164
|
+
function refresh(customOptions) {
|
|
2165
|
+
destroy();
|
|
2166
|
+
init(customOptions || _options);
|
|
2167
|
+
}
|
|
2168
|
+
__name(refresh, "refresh");
|
|
2169
|
+
var hasOwnProp = Object.prototype.hasOwnProperty;
|
|
2170
|
+
function extend(...args) {
|
|
2171
|
+
const target = {};
|
|
2172
|
+
for (let i2 = 0; i2 < args.length; i2++) {
|
|
2173
|
+
const source = args[i2];
|
|
2174
|
+
for (const key in source) {
|
|
2175
|
+
if (hasOwnProp.call(source, key)) {
|
|
2176
|
+
target[key] = source[key];
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
return target;
|
|
2181
|
+
}
|
|
2182
|
+
__name(extend, "extend");
|
|
2183
|
+
function throttle(fn, threshold, scope) {
|
|
2184
|
+
threshold || (threshold = 250);
|
|
2185
|
+
let last;
|
|
2186
|
+
let deferTimer;
|
|
2187
|
+
return function(...args) {
|
|
2188
|
+
const context = scope || this;
|
|
2189
|
+
const now = +/* @__PURE__ */ new Date();
|
|
2190
|
+
if (last && now < last + threshold) {
|
|
2191
|
+
clearTimeout(deferTimer);
|
|
2192
|
+
deferTimer = setTimeout(() => {
|
|
2193
|
+
last = now;
|
|
2194
|
+
fn.apply(context, args);
|
|
2195
|
+
}, threshold);
|
|
2196
|
+
} else {
|
|
2197
|
+
last = now;
|
|
2198
|
+
fn.apply(context, args);
|
|
2199
|
+
}
|
|
2200
|
+
};
|
|
2201
|
+
}
|
|
2202
|
+
__name(throttle, "throttle");
|
|
2203
|
+
function debounce(func, wait) {
|
|
2204
|
+
let timeout;
|
|
2205
|
+
return (...args) => {
|
|
2206
|
+
clearTimeout(timeout);
|
|
2207
|
+
timeout = setTimeout(() => func.apply(this, args), wait);
|
|
2208
|
+
};
|
|
2209
|
+
}
|
|
2210
|
+
__name(debounce, "debounce");
|
|
2211
|
+
function getScrollHandler(func, timeout, type = "auto") {
|
|
2212
|
+
switch (type) {
|
|
2213
|
+
case "debounce":
|
|
2214
|
+
return debounce(func, timeout);
|
|
2215
|
+
case "throttle":
|
|
2216
|
+
return throttle(func, timeout);
|
|
2217
|
+
default:
|
|
2218
|
+
return timeout < 334 ? debounce(func, timeout) : throttle(func, timeout);
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
__name(getScrollHandler, "getScrollHandler");
|
|
2222
|
+
function getContentElement(options) {
|
|
2223
|
+
try {
|
|
2224
|
+
return options.contentElement || document.querySelector(options.contentSelector);
|
|
2225
|
+
} catch (e2) {
|
|
2226
|
+
console.warn(`Contents element not found: ${options.contentSelector}`);
|
|
2227
|
+
return null;
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
__name(getContentElement, "getContentElement");
|
|
2231
|
+
function getTocElement(options) {
|
|
2232
|
+
try {
|
|
2233
|
+
return options.tocElement || document.querySelector(options.tocSelector);
|
|
2234
|
+
} catch (e2) {
|
|
2235
|
+
console.warn(`TOC element not found: ${options.tocSelector}`);
|
|
2236
|
+
return null;
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
__name(getTocElement, "getTocElement");
|
|
2240
|
+
|
|
2241
|
+
// ../../node_modules/tocbot/index.js
|
|
2242
|
+
var tocbot = { destroy, init, refresh };
|
|
2243
|
+
var tocbot_default = tocbot;
|
|
2244
|
+
|
|
2245
|
+
// src/blocks/components/TableOfContents.tsx
|
|
1310
2246
|
var Aside = styled8.aside(() => ({
|
|
1311
2247
|
width: "10rem",
|
|
1312
2248
|
"@media (max-width: 768px)": {
|
|
@@ -1382,9 +2318,9 @@ var Heading = styled8.p(({ theme }) => ({
|
|
|
1382
2318
|
}));
|
|
1383
2319
|
var Title2 = /* @__PURE__ */ __name(({ headingId, title }) => {
|
|
1384
2320
|
if (typeof title === "string" || !title) {
|
|
1385
|
-
return
|
|
2321
|
+
return React11.createElement(Heading, { as: "h2", id: headingId, className: title ? "" : "sb-sr-only" }, title || "Table of contents");
|
|
1386
2322
|
}
|
|
1387
|
-
return
|
|
2323
|
+
return React11.createElement("div", { id: headingId }, title);
|
|
1388
2324
|
}, "Title");
|
|
1389
2325
|
var TableOfContents = /* @__PURE__ */ __name(({
|
|
1390
2326
|
title,
|
|
@@ -1396,7 +2332,7 @@ var TableOfContents = /* @__PURE__ */ __name(({
|
|
|
1396
2332
|
channel,
|
|
1397
2333
|
className
|
|
1398
2334
|
}) => {
|
|
1399
|
-
|
|
2335
|
+
useEffect3(() => {
|
|
1400
2336
|
if (disable) {
|
|
1401
2337
|
return () => {
|
|
1402
2338
|
};
|
|
@@ -1429,11 +2365,11 @@ var TableOfContents = /* @__PURE__ */ __name(({
|
|
|
1429
2365
|
};
|
|
1430
2366
|
}, [channel, disable, ignoreSelector, contentsSelector, headingSelector, unsafeTocbotOptions]);
|
|
1431
2367
|
const headingId = useId();
|
|
1432
|
-
return
|
|
2368
|
+
return React11.createElement(Aside, { className }, !disable ? React11.createElement(Nav, { "aria-labelledby": headingId }, React11.createElement(Title2, { headingId, title }), React11.createElement("div", { className: "toc-wrapper" })) : null);
|
|
1433
2369
|
}, "TableOfContents");
|
|
1434
2370
|
|
|
1435
2371
|
// src/blocks/components/ArgsTable/ArgRow.tsx
|
|
1436
|
-
import
|
|
2372
|
+
import React30, { useState as useState11 } from "react";
|
|
1437
2373
|
import { codeCommon as codeCommon3 } from "storybook/internal/components";
|
|
1438
2374
|
|
|
1439
2375
|
// ../../node_modules/markdown-to-jsx/dist/index.modern.js
|
|
@@ -1897,14 +2833,14 @@ var index_modern_default = /* @__PURE__ */ __name((n2) => {
|
|
|
1897
2833
|
import { styled as styled22 } from "storybook/theming";
|
|
1898
2834
|
|
|
1899
2835
|
// src/blocks/components/ArgsTable/ArgControl.tsx
|
|
1900
|
-
import
|
|
2836
|
+
import React27, { useCallback as useCallback6, useEffect as useEffect9, useState as useState9 } from "react";
|
|
1901
2837
|
import { Link } from "storybook/internal/components";
|
|
1902
2838
|
|
|
1903
2839
|
// src/blocks/controls/index.tsx
|
|
1904
|
-
import
|
|
2840
|
+
import React26, { Suspense, lazy } from "react";
|
|
1905
2841
|
|
|
1906
2842
|
// src/blocks/controls/Boolean.tsx
|
|
1907
|
-
import
|
|
2843
|
+
import React12, { useCallback as useCallback2 } from "react";
|
|
1908
2844
|
import { Button } from "storybook/internal/components";
|
|
1909
2845
|
import { styled as styled9 } from "storybook/theming";
|
|
1910
2846
|
var Label2 = styled9.label(({ theme }) => ({
|
|
@@ -1995,7 +2931,7 @@ var BooleanControl = /* @__PURE__ */ __name(({
|
|
|
1995
2931
|
const onSetFalse = useCallback2(() => onChange(false), [onChange]);
|
|
1996
2932
|
const readonly = !!argType?.table?.readonly;
|
|
1997
2933
|
if (value2 === void 0) {
|
|
1998
|
-
return
|
|
2934
|
+
return React12.createElement(
|
|
1999
2935
|
Button,
|
|
2000
2936
|
{
|
|
2001
2937
|
variant: "outline",
|
|
@@ -2009,7 +2945,7 @@ var BooleanControl = /* @__PURE__ */ __name(({
|
|
|
2009
2945
|
}
|
|
2010
2946
|
const controlId = getControlId(name);
|
|
2011
2947
|
const parsedValue = typeof value2 === "string" ? parse(value2) : value2;
|
|
2012
|
-
return
|
|
2948
|
+
return React12.createElement(Label2, { "aria-disabled": readonly, htmlFor: controlId, "aria-label": name }, React12.createElement(
|
|
2013
2949
|
"input",
|
|
2014
2950
|
{
|
|
2015
2951
|
id: controlId,
|
|
@@ -2020,11 +2956,11 @@ var BooleanControl = /* @__PURE__ */ __name(({
|
|
|
2020
2956
|
disabled: readonly,
|
|
2021
2957
|
...{ name, onBlur, onFocus }
|
|
2022
2958
|
}
|
|
2023
|
-
),
|
|
2959
|
+
), React12.createElement("span", { "aria-hidden": "true" }, "False"), React12.createElement("span", { "aria-hidden": "true" }, "True"));
|
|
2024
2960
|
}, "BooleanControl");
|
|
2025
2961
|
|
|
2026
2962
|
// src/blocks/controls/Date.tsx
|
|
2027
|
-
import
|
|
2963
|
+
import React13, { useEffect as useEffect4, useRef as useRef2, useState as useState4 } from "react";
|
|
2028
2964
|
import { Form } from "storybook/internal/components";
|
|
2029
2965
|
import { styled as styled10 } from "storybook/theming";
|
|
2030
2966
|
var parseDate = /* @__PURE__ */ __name((value2) => {
|
|
@@ -2079,11 +3015,11 @@ var FlexSpaced = styled10.div(({ theme }) => ({
|
|
|
2079
3015
|
}
|
|
2080
3016
|
}));
|
|
2081
3017
|
var DateControl = /* @__PURE__ */ __name(({ name, value: value2, onChange, onFocus, onBlur, argType }) => {
|
|
2082
|
-
const [valid, setValid] =
|
|
3018
|
+
const [valid, setValid] = useState4(true);
|
|
2083
3019
|
const dateRef = useRef2();
|
|
2084
3020
|
const timeRef = useRef2();
|
|
2085
3021
|
const readonly = !!argType?.table?.readonly;
|
|
2086
|
-
|
|
3022
|
+
useEffect4(() => {
|
|
2087
3023
|
if (valid !== false) {
|
|
2088
3024
|
if (dateRef && dateRef.current) {
|
|
2089
3025
|
dateRef.current.value = value2 ? formatDate(value2) : "";
|
|
@@ -2121,7 +3057,7 @@ var DateControl = /* @__PURE__ */ __name(({ name, value: value2, onChange, onFoc
|
|
|
2121
3057
|
setValid(!!time);
|
|
2122
3058
|
}, "onTimeChange");
|
|
2123
3059
|
const controlId = getControlId(name);
|
|
2124
|
-
return
|
|
3060
|
+
return React13.createElement(FlexSpaced, null, React13.createElement(
|
|
2125
3061
|
FormInput,
|
|
2126
3062
|
{
|
|
2127
3063
|
type: "date",
|
|
@@ -2133,7 +3069,7 @@ var DateControl = /* @__PURE__ */ __name(({ name, value: value2, onChange, onFoc
|
|
|
2133
3069
|
onChange: onDateChange,
|
|
2134
3070
|
...{ onFocus, onBlur }
|
|
2135
3071
|
}
|
|
2136
|
-
),
|
|
3072
|
+
), React13.createElement(
|
|
2137
3073
|
FormInput,
|
|
2138
3074
|
{
|
|
2139
3075
|
type: "time",
|
|
@@ -2144,11 +3080,11 @@ var DateControl = /* @__PURE__ */ __name(({ name, value: value2, onChange, onFoc
|
|
|
2144
3080
|
readOnly: readonly,
|
|
2145
3081
|
...{ onFocus, onBlur }
|
|
2146
3082
|
}
|
|
2147
|
-
), !valid ?
|
|
3083
|
+
), !valid ? React13.createElement("div", null, "invalid") : null);
|
|
2148
3084
|
}, "DateControl");
|
|
2149
3085
|
|
|
2150
3086
|
// src/blocks/controls/Number.tsx
|
|
2151
|
-
import
|
|
3087
|
+
import React14, { useCallback as useCallback3, useEffect as useEffect5, useRef as useRef3, useState as useState5 } from "react";
|
|
2152
3088
|
import { Button as Button2, Form as Form2 } from "storybook/internal/components";
|
|
2153
3089
|
import { styled as styled11 } from "storybook/theming";
|
|
2154
3090
|
var Wrapper3 = styled11.label({
|
|
@@ -2173,9 +3109,9 @@ var NumberControl = /* @__PURE__ */ __name(({
|
|
|
2173
3109
|
onFocus,
|
|
2174
3110
|
argType
|
|
2175
3111
|
}) => {
|
|
2176
|
-
const [inputValue, setInputValue] =
|
|
2177
|
-
const [forceVisible, setForceVisible] =
|
|
2178
|
-
const [parseError, setParseError] =
|
|
3112
|
+
const [inputValue, setInputValue] = useState5(typeof value2 === "number" ? value2 : "");
|
|
3113
|
+
const [forceVisible, setForceVisible] = useState5(false);
|
|
3114
|
+
const [parseError, setParseError] = useState5(null);
|
|
2179
3115
|
const readonly = !!argType?.table?.readonly;
|
|
2180
3116
|
const handleChange = useCallback3(
|
|
2181
3117
|
(event) => {
|
|
@@ -2196,19 +3132,19 @@ var NumberControl = /* @__PURE__ */ __name(({
|
|
|
2196
3132
|
setForceVisible(true);
|
|
2197
3133
|
}, [setForceVisible]);
|
|
2198
3134
|
const htmlElRef = useRef3(null);
|
|
2199
|
-
|
|
3135
|
+
useEffect5(() => {
|
|
2200
3136
|
if (forceVisible && htmlElRef.current) {
|
|
2201
3137
|
htmlElRef.current.select();
|
|
2202
3138
|
}
|
|
2203
3139
|
}, [forceVisible]);
|
|
2204
|
-
|
|
3140
|
+
useEffect5(() => {
|
|
2205
3141
|
const newInputValue = typeof value2 === "number" ? value2 : "";
|
|
2206
3142
|
if (inputValue !== newInputValue) {
|
|
2207
3143
|
setInputValue(newInputValue);
|
|
2208
3144
|
}
|
|
2209
3145
|
}, [value2]);
|
|
2210
3146
|
if (value2 === void 0) {
|
|
2211
|
-
return
|
|
3147
|
+
return React14.createElement(
|
|
2212
3148
|
Button2,
|
|
2213
3149
|
{
|
|
2214
3150
|
variant: "outline",
|
|
@@ -2220,7 +3156,7 @@ var NumberControl = /* @__PURE__ */ __name(({
|
|
|
2220
3156
|
"Set number"
|
|
2221
3157
|
);
|
|
2222
3158
|
}
|
|
2223
|
-
return
|
|
3159
|
+
return React14.createElement(Wrapper3, null, React14.createElement(
|
|
2224
3160
|
FormInput2,
|
|
2225
3161
|
{
|
|
2226
3162
|
ref: htmlElRef,
|
|
@@ -2239,10 +3175,10 @@ var NumberControl = /* @__PURE__ */ __name(({
|
|
|
2239
3175
|
}, "NumberControl");
|
|
2240
3176
|
|
|
2241
3177
|
// src/blocks/controls/options/Options.tsx
|
|
2242
|
-
import
|
|
3178
|
+
import React18 from "react";
|
|
2243
3179
|
|
|
2244
3180
|
// src/blocks/controls/options/Checkbox.tsx
|
|
2245
|
-
import
|
|
3181
|
+
import React15, { useEffect as useEffect6, useState as useState6 } from "react";
|
|
2246
3182
|
import { logger } from "storybook/internal/client-logger";
|
|
2247
3183
|
import { styled as styled12 } from "storybook/theming";
|
|
2248
3184
|
|
|
@@ -2306,10 +3242,10 @@ var CheckboxControl = /* @__PURE__ */ __name(({
|
|
|
2306
3242
|
}) => {
|
|
2307
3243
|
if (!options) {
|
|
2308
3244
|
logger.warn(`Checkbox with no options: ${name}`);
|
|
2309
|
-
return
|
|
3245
|
+
return React15.createElement(React15.Fragment, null, "-");
|
|
2310
3246
|
}
|
|
2311
3247
|
const initial = selectedKeys(value2 || [], options);
|
|
2312
|
-
const [selected, setSelected] =
|
|
3248
|
+
const [selected, setSelected] = useState6(initial);
|
|
2313
3249
|
const readonly = !!argType?.table?.readonly;
|
|
2314
3250
|
const handleChange = /* @__PURE__ */ __name((e2) => {
|
|
2315
3251
|
const option = e2.target.value;
|
|
@@ -2322,13 +3258,13 @@ var CheckboxControl = /* @__PURE__ */ __name(({
|
|
|
2322
3258
|
onChange(selectedValues(updated, options));
|
|
2323
3259
|
setSelected(updated);
|
|
2324
3260
|
}, "handleChange");
|
|
2325
|
-
|
|
3261
|
+
useEffect6(() => {
|
|
2326
3262
|
setSelected(selectedKeys(value2 || [], options));
|
|
2327
3263
|
}, [value2]);
|
|
2328
3264
|
const controlId = getControlId(name);
|
|
2329
|
-
return
|
|
3265
|
+
return React15.createElement(Wrapper4, { "aria-readonly": readonly, isInline }, Object.keys(options).map((key, index) => {
|
|
2330
3266
|
const id = `${controlId}-${index}`;
|
|
2331
|
-
return
|
|
3267
|
+
return React15.createElement(Label3, { key: id, htmlFor: id }, React15.createElement(
|
|
2332
3268
|
"input",
|
|
2333
3269
|
{
|
|
2334
3270
|
type: "checkbox",
|
|
@@ -2339,12 +3275,12 @@ var CheckboxControl = /* @__PURE__ */ __name(({
|
|
|
2339
3275
|
onChange: handleChange,
|
|
2340
3276
|
checked: selected?.includes(key)
|
|
2341
3277
|
}
|
|
2342
|
-
),
|
|
3278
|
+
), React15.createElement(Text, null, key));
|
|
2343
3279
|
}));
|
|
2344
3280
|
}, "CheckboxControl");
|
|
2345
3281
|
|
|
2346
3282
|
// src/blocks/controls/options/Radio.tsx
|
|
2347
|
-
import
|
|
3283
|
+
import React16 from "react";
|
|
2348
3284
|
import { logger as logger2 } from "storybook/internal/client-logger";
|
|
2349
3285
|
import { styled as styled13 } from "storybook/theming";
|
|
2350
3286
|
var Wrapper5 = styled13.div(
|
|
@@ -2398,14 +3334,14 @@ var RadioControl = /* @__PURE__ */ __name(({
|
|
|
2398
3334
|
}) => {
|
|
2399
3335
|
if (!options) {
|
|
2400
3336
|
logger2.warn(`Radio with no options: ${name}`);
|
|
2401
|
-
return
|
|
3337
|
+
return React16.createElement(React16.Fragment, null, "-");
|
|
2402
3338
|
}
|
|
2403
3339
|
const selection = selectedKey(value2, options);
|
|
2404
3340
|
const controlId = getControlId(name);
|
|
2405
3341
|
const readonly = !!argType?.table?.readonly;
|
|
2406
|
-
return
|
|
3342
|
+
return React16.createElement(Wrapper5, { "aria-readonly": readonly, isInline }, Object.keys(options).map((key, index) => {
|
|
2407
3343
|
const id = `${controlId}-${index}`;
|
|
2408
|
-
return
|
|
3344
|
+
return React16.createElement(Label4, { key: id, htmlFor: id }, React16.createElement(
|
|
2409
3345
|
"input",
|
|
2410
3346
|
{
|
|
2411
3347
|
type: "radio",
|
|
@@ -2416,12 +3352,12 @@ var RadioControl = /* @__PURE__ */ __name(({
|
|
|
2416
3352
|
onChange: (e2) => onChange(options[e2.currentTarget.value]),
|
|
2417
3353
|
checked: key === selection
|
|
2418
3354
|
}
|
|
2419
|
-
),
|
|
3355
|
+
), React16.createElement(Text2, null, key));
|
|
2420
3356
|
}));
|
|
2421
3357
|
}, "RadioControl");
|
|
2422
3358
|
|
|
2423
3359
|
// src/blocks/controls/options/Select.tsx
|
|
2424
|
-
import
|
|
3360
|
+
import React17 from "react";
|
|
2425
3361
|
import { logger as logger3 } from "storybook/internal/client-logger";
|
|
2426
3362
|
import { ChevronSmallDownIcon } from "@storybook/icons";
|
|
2427
3363
|
import { styled as styled14 } from "storybook/theming";
|
|
@@ -2499,7 +3435,7 @@ var SingleSelect = /* @__PURE__ */ __name(({ name, value: value2, options, onCha
|
|
|
2499
3435
|
const selection = selectedKey(value2, options) || NO_SELECTION;
|
|
2500
3436
|
const controlId = getControlId(name);
|
|
2501
3437
|
const readonly = !!argType?.table?.readonly;
|
|
2502
|
-
return
|
|
3438
|
+
return React17.createElement(SelectWrapper, null, React17.createElement(ChevronSmallDownIcon, null), React17.createElement(OptionsSelect, { disabled: readonly, id: controlId, value: selection, onChange: handleChange }, React17.createElement("option", { key: "no-selection", disabled: true }, NO_SELECTION), Object.keys(options).map((key) => React17.createElement("option", { key, value: key }, key))));
|
|
2503
3439
|
}, "SingleSelect");
|
|
2504
3440
|
var MultiSelect = /* @__PURE__ */ __name(({ name, value: value2, options, onChange, argType }) => {
|
|
2505
3441
|
const handleChange = /* @__PURE__ */ __name((e2) => {
|
|
@@ -2509,7 +3445,7 @@ var MultiSelect = /* @__PURE__ */ __name(({ name, value: value2, options, onChan
|
|
|
2509
3445
|
const selection = selectedKeys(value2, options);
|
|
2510
3446
|
const controlId = getControlId(name);
|
|
2511
3447
|
const readonly = !!argType?.table?.readonly;
|
|
2512
|
-
return
|
|
3448
|
+
return React17.createElement(SelectWrapper, null, React17.createElement(
|
|
2513
3449
|
OptionsSelect,
|
|
2514
3450
|
{
|
|
2515
3451
|
disabled: readonly,
|
|
@@ -2518,16 +3454,16 @@ var MultiSelect = /* @__PURE__ */ __name(({ name, value: value2, options, onChan
|
|
|
2518
3454
|
value: selection,
|
|
2519
3455
|
onChange: handleChange
|
|
2520
3456
|
},
|
|
2521
|
-
Object.keys(options).map((key) =>
|
|
3457
|
+
Object.keys(options).map((key) => React17.createElement("option", { key, value: key }, key))
|
|
2522
3458
|
));
|
|
2523
3459
|
}, "MultiSelect");
|
|
2524
3460
|
var SelectControl = /* @__PURE__ */ __name((props) => {
|
|
2525
3461
|
const { name, options } = props;
|
|
2526
3462
|
if (!options) {
|
|
2527
3463
|
logger3.warn(`Select with no options: ${name}`);
|
|
2528
|
-
return
|
|
3464
|
+
return React17.createElement(React17.Fragment, null, "-");
|
|
2529
3465
|
}
|
|
2530
|
-
return props.isMulti ?
|
|
3466
|
+
return props.isMulti ? React17.createElement(MultiSelect, { ...props }) : React17.createElement(SingleSelect, { ...props });
|
|
2531
3467
|
}, "SelectControl");
|
|
2532
3468
|
|
|
2533
3469
|
// src/blocks/controls/options/Options.tsx
|
|
@@ -2559,25 +3495,25 @@ var OptionsControl = /* @__PURE__ */ __name((props) => {
|
|
|
2559
3495
|
};
|
|
2560
3496
|
const Control = Controls[type];
|
|
2561
3497
|
if (Control) {
|
|
2562
|
-
return
|
|
3498
|
+
return React18.createElement(Control, { ...normalized });
|
|
2563
3499
|
}
|
|
2564
3500
|
throw new Error(`Unknown options type: ${type}`);
|
|
2565
3501
|
}, "OptionsControl");
|
|
2566
3502
|
|
|
2567
3503
|
// src/blocks/controls/Object.tsx
|
|
2568
|
-
import
|
|
3504
|
+
import React22, { useCallback as useCallback4, useEffect as useEffect7, useMemo, useRef as useRef4, useState as useState7 } from "react";
|
|
2569
3505
|
import { Button as Button3, Form as Form3, IconButton as IconButton2 } from "storybook/internal/components";
|
|
2570
3506
|
import { AddIcon, EyeCloseIcon, EyeIcon, SubtractIcon } from "@storybook/icons";
|
|
2571
3507
|
import { styled as styled16, useTheme } from "storybook/theming";
|
|
2572
3508
|
|
|
2573
3509
|
// src/blocks/controls/react-editable-json-tree/index.tsx
|
|
2574
|
-
import
|
|
3510
|
+
import React21, { Component as Component3 } from "react";
|
|
2575
3511
|
|
|
2576
3512
|
// src/blocks/controls/react-editable-json-tree/JsonNodes.tsx
|
|
2577
|
-
import
|
|
3513
|
+
import React20, { Component as Component2, cloneElement as cloneElement2 } from "react";
|
|
2578
3514
|
|
|
2579
3515
|
// src/blocks/controls/react-editable-json-tree/JsonNodeAccordion.tsx
|
|
2580
|
-
import
|
|
3516
|
+
import React19 from "react";
|
|
2581
3517
|
import { styled as styled15 } from "storybook/theming";
|
|
2582
3518
|
var Container = styled15.div(({ theme }) => ({
|
|
2583
3519
|
position: "relative",
|
|
@@ -2648,7 +3584,7 @@ function JsonNodeAccordion({
|
|
|
2648
3584
|
region: `${accordionKey}-region`
|
|
2649
3585
|
};
|
|
2650
3586
|
const containerTag = keyPath.length > 0 ? "li" : "div";
|
|
2651
|
-
return
|
|
3587
|
+
return React19.createElement(Container, { as: containerTag }, React19.createElement(
|
|
2652
3588
|
Trigger,
|
|
2653
3589
|
{
|
|
2654
3590
|
type: "button",
|
|
@@ -2660,7 +3596,7 @@ function JsonNodeAccordion({
|
|
|
2660
3596
|
},
|
|
2661
3597
|
name,
|
|
2662
3598
|
" :"
|
|
2663
|
-
),
|
|
3599
|
+
), React19.createElement(
|
|
2664
3600
|
Region,
|
|
2665
3601
|
{
|
|
2666
3602
|
role: "region",
|
|
@@ -2804,15 +3740,15 @@ var _JsonAddValue = class _JsonAddValue extends Component2 {
|
|
|
2804
3740
|
onKeyDown: this.onKeydown
|
|
2805
3741
|
});
|
|
2806
3742
|
}
|
|
2807
|
-
return
|
|
3743
|
+
return React20.createElement("span", { className: "rejt-add-value-node" }, inputElementKeyLayout, inputElementValueLayout, addButtonElementLayout, cancelButtonElementLayout);
|
|
2808
3744
|
}
|
|
2809
3745
|
};
|
|
2810
3746
|
__name(_JsonAddValue, "JsonAddValue");
|
|
2811
3747
|
var JsonAddValue = _JsonAddValue;
|
|
2812
3748
|
JsonAddValue.defaultProps = {
|
|
2813
3749
|
onlyValue: false,
|
|
2814
|
-
addButtonElement:
|
|
2815
|
-
cancelButtonElement:
|
|
3750
|
+
addButtonElement: React20.createElement("button", null, "+"),
|
|
3751
|
+
cancelButtonElement: React20.createElement("button", null, "c")
|
|
2816
3752
|
};
|
|
2817
3753
|
var _JsonArray = class _JsonArray extends Component2 {
|
|
2818
3754
|
constructor(props) {
|
|
@@ -2881,9 +3817,10 @@ var _JsonArray = class _JsonArray extends Component2 {
|
|
|
2881
3817
|
}).catch(logger4.error);
|
|
2882
3818
|
};
|
|
2883
3819
|
}
|
|
2884
|
-
handleAddValueAdd({
|
|
3820
|
+
handleAddValueAdd({ newValue }) {
|
|
2885
3821
|
const { data, keyPath = [], nextDeep: deep } = this.state;
|
|
2886
3822
|
const { beforeAddAction, logger: logger4 } = this.props;
|
|
3823
|
+
const key = data.length;
|
|
2887
3824
|
(beforeAddAction || Promise.resolve.bind(Promise))(key, keyPath, deep, newValue).then(() => {
|
|
2888
3825
|
data[key] = newValue;
|
|
2889
3826
|
this.setState({
|
|
@@ -2941,7 +3878,7 @@ var _JsonArray = class _JsonArray extends Component2 {
|
|
|
2941
3878
|
style: minus,
|
|
2942
3879
|
"aria-label": `remove the array '${String(name)}'`
|
|
2943
3880
|
});
|
|
2944
|
-
return
|
|
3881
|
+
return React20.createElement(React20.Fragment, null, React20.createElement("span", { style: collapsed }, "[...] ", data.length, " ", data.length === 1 ? "item" : "items"), !isReadOnly && removeItemButton);
|
|
2945
3882
|
}
|
|
2946
3883
|
renderNotCollapsed() {
|
|
2947
3884
|
const { name, data, keyPath, deep, addFormVisible, nextDeep } = this.state;
|
|
@@ -2981,7 +3918,7 @@ var _JsonArray = class _JsonArray extends Component2 {
|
|
|
2981
3918
|
const onlyValue = true;
|
|
2982
3919
|
const startObject = "[";
|
|
2983
3920
|
const endObject = "]";
|
|
2984
|
-
return
|
|
3921
|
+
return React20.createElement(React20.Fragment, null, React20.createElement("span", { className: "rejt-not-collapsed-delimiter", style: delimiter }, startObject), !addFormVisible && addItemButton, React20.createElement("ul", { className: "rejt-not-collapsed-list", style: ul }, data.map((item, index) => React20.createElement(
|
|
2985
3922
|
JsonNode,
|
|
2986
3923
|
{
|
|
2987
3924
|
key: index,
|
|
@@ -3008,7 +3945,7 @@ var _JsonArray = class _JsonArray extends Component2 {
|
|
|
3008
3945
|
logger: logger4,
|
|
3009
3946
|
onSubmitValueParser
|
|
3010
3947
|
}
|
|
3011
|
-
))), !isReadOnly && addFormVisible &&
|
|
3948
|
+
))), !isReadOnly && addFormVisible && React20.createElement("div", { className: "rejt-add-form", style: addForm }, React20.createElement(
|
|
3012
3949
|
JsonAddValue,
|
|
3013
3950
|
{
|
|
3014
3951
|
handleAdd: this.handleAddValueAdd,
|
|
@@ -3021,12 +3958,12 @@ var _JsonArray = class _JsonArray extends Component2 {
|
|
|
3021
3958
|
deep,
|
|
3022
3959
|
onSubmitValueParser
|
|
3023
3960
|
}
|
|
3024
|
-
)),
|
|
3961
|
+
)), React20.createElement("span", { className: "rejt-not-collapsed-delimiter", style: delimiter }, endObject), !isReadOnly && removeItemButton);
|
|
3025
3962
|
}
|
|
3026
3963
|
render() {
|
|
3027
3964
|
const { name, collapsed, keyPath, deep } = this.state;
|
|
3028
3965
|
const value2 = collapsed ? this.renderCollapsed() : this.renderNotCollapsed();
|
|
3029
|
-
return
|
|
3966
|
+
return React20.createElement(
|
|
3030
3967
|
JsonNodeAccordion,
|
|
3031
3968
|
{
|
|
3032
3969
|
name,
|
|
@@ -3044,8 +3981,8 @@ var JsonArray = _JsonArray;
|
|
|
3044
3981
|
JsonArray.defaultProps = {
|
|
3045
3982
|
keyPath: [],
|
|
3046
3983
|
deep: 0,
|
|
3047
|
-
minusMenuElement:
|
|
3048
|
-
plusMenuElement:
|
|
3984
|
+
minusMenuElement: React20.createElement("span", null, " - "),
|
|
3985
|
+
plusMenuElement: React20.createElement("span", null, " + ")
|
|
3049
3986
|
};
|
|
3050
3987
|
var _JsonFunctionValue = class _JsonFunctionValue extends Component2 {
|
|
3051
3988
|
constructor(props) {
|
|
@@ -3150,10 +4087,10 @@ var _JsonFunctionValue = class _JsonFunctionValue extends Component2 {
|
|
|
3150
4087
|
defaultValue: value2,
|
|
3151
4088
|
onKeyDown: this.onKeydown
|
|
3152
4089
|
});
|
|
3153
|
-
result =
|
|
4090
|
+
result = React20.createElement("span", { className: "rejt-edit-form", style: style.editForm }, textareaElementLayout);
|
|
3154
4091
|
minusElement = null;
|
|
3155
4092
|
} else {
|
|
3156
|
-
result =
|
|
4093
|
+
result = React20.createElement(
|
|
3157
4094
|
"span",
|
|
3158
4095
|
{
|
|
3159
4096
|
className: "rejt-value",
|
|
@@ -3171,7 +4108,7 @@ var _JsonFunctionValue = class _JsonFunctionValue extends Component2 {
|
|
|
3171
4108
|
});
|
|
3172
4109
|
minusElement = resultOnlyResult ? null : minusMenuLayout;
|
|
3173
4110
|
}
|
|
3174
|
-
return
|
|
4111
|
+
return React20.createElement("li", { className: "rejt-value-node", style: style.li }, React20.createElement("span", { className: "rejt-name", style: style.name }, name, " :", " "), result, minusElement);
|
|
3175
4112
|
}
|
|
3176
4113
|
};
|
|
3177
4114
|
__name(_JsonFunctionValue, "JsonFunctionValue");
|
|
@@ -3181,8 +4118,8 @@ JsonFunctionValue.defaultProps = {
|
|
|
3181
4118
|
deep: 0,
|
|
3182
4119
|
handleUpdateValue: /* @__PURE__ */ __name(() => {
|
|
3183
4120
|
}, "handleUpdateValue"),
|
|
3184
|
-
cancelButtonElement:
|
|
3185
|
-
minusMenuElement:
|
|
4121
|
+
cancelButtonElement: React20.createElement("button", null, "c"),
|
|
4122
|
+
minusMenuElement: React20.createElement("span", null, " - ")
|
|
3186
4123
|
};
|
|
3187
4124
|
var _JsonNode = class _JsonNode extends Component2 {
|
|
3188
4125
|
constructor(props) {
|
|
@@ -3223,7 +4160,7 @@ var _JsonNode = class _JsonNode extends Component2 {
|
|
|
3223
4160
|
const dataType = getObjectType(data);
|
|
3224
4161
|
switch (dataType) {
|
|
3225
4162
|
case ERROR:
|
|
3226
|
-
return
|
|
4163
|
+
return React20.createElement(
|
|
3227
4164
|
JsonObject,
|
|
3228
4165
|
{
|
|
3229
4166
|
data,
|
|
@@ -3251,7 +4188,7 @@ var _JsonNode = class _JsonNode extends Component2 {
|
|
|
3251
4188
|
}
|
|
3252
4189
|
);
|
|
3253
4190
|
case OBJECT:
|
|
3254
|
-
return
|
|
4191
|
+
return React20.createElement(
|
|
3255
4192
|
JsonObject,
|
|
3256
4193
|
{
|
|
3257
4194
|
data,
|
|
@@ -3279,7 +4216,7 @@ var _JsonNode = class _JsonNode extends Component2 {
|
|
|
3279
4216
|
}
|
|
3280
4217
|
);
|
|
3281
4218
|
case ARRAY:
|
|
3282
|
-
return
|
|
4219
|
+
return React20.createElement(
|
|
3283
4220
|
JsonArray,
|
|
3284
4221
|
{
|
|
3285
4222
|
data,
|
|
@@ -3307,7 +4244,7 @@ var _JsonNode = class _JsonNode extends Component2 {
|
|
|
3307
4244
|
}
|
|
3308
4245
|
);
|
|
3309
4246
|
case STRING:
|
|
3310
|
-
return
|
|
4247
|
+
return React20.createElement(
|
|
3311
4248
|
JsonValue,
|
|
3312
4249
|
{
|
|
3313
4250
|
name,
|
|
@@ -3328,7 +4265,7 @@ var _JsonNode = class _JsonNode extends Component2 {
|
|
|
3328
4265
|
}
|
|
3329
4266
|
);
|
|
3330
4267
|
case NUMBER:
|
|
3331
|
-
return
|
|
4268
|
+
return React20.createElement(
|
|
3332
4269
|
JsonValue,
|
|
3333
4270
|
{
|
|
3334
4271
|
name,
|
|
@@ -3349,7 +4286,7 @@ var _JsonNode = class _JsonNode extends Component2 {
|
|
|
3349
4286
|
}
|
|
3350
4287
|
);
|
|
3351
4288
|
case BOOLEAN:
|
|
3352
|
-
return
|
|
4289
|
+
return React20.createElement(
|
|
3353
4290
|
JsonValue,
|
|
3354
4291
|
{
|
|
3355
4292
|
name,
|
|
@@ -3370,7 +4307,7 @@ var _JsonNode = class _JsonNode extends Component2 {
|
|
|
3370
4307
|
}
|
|
3371
4308
|
);
|
|
3372
4309
|
case DATE:
|
|
3373
|
-
return
|
|
4310
|
+
return React20.createElement(
|
|
3374
4311
|
JsonValue,
|
|
3375
4312
|
{
|
|
3376
4313
|
name,
|
|
@@ -3391,7 +4328,7 @@ var _JsonNode = class _JsonNode extends Component2 {
|
|
|
3391
4328
|
}
|
|
3392
4329
|
);
|
|
3393
4330
|
case NULL:
|
|
3394
|
-
return
|
|
4331
|
+
return React20.createElement(
|
|
3395
4332
|
JsonValue,
|
|
3396
4333
|
{
|
|
3397
4334
|
name,
|
|
@@ -3412,7 +4349,7 @@ var _JsonNode = class _JsonNode extends Component2 {
|
|
|
3412
4349
|
}
|
|
3413
4350
|
);
|
|
3414
4351
|
case UNDEFINED:
|
|
3415
|
-
return
|
|
4352
|
+
return React20.createElement(
|
|
3416
4353
|
JsonValue,
|
|
3417
4354
|
{
|
|
3418
4355
|
name,
|
|
@@ -3433,7 +4370,7 @@ var _JsonNode = class _JsonNode extends Component2 {
|
|
|
3433
4370
|
}
|
|
3434
4371
|
);
|
|
3435
4372
|
case FUNCTION:
|
|
3436
|
-
return
|
|
4373
|
+
return React20.createElement(
|
|
3437
4374
|
JsonFunctionValue,
|
|
3438
4375
|
{
|
|
3439
4376
|
name,
|
|
@@ -3454,7 +4391,7 @@ var _JsonNode = class _JsonNode extends Component2 {
|
|
|
3454
4391
|
}
|
|
3455
4392
|
);
|
|
3456
4393
|
case SYMBOL:
|
|
3457
|
-
return
|
|
4394
|
+
return React20.createElement(
|
|
3458
4395
|
JsonValue,
|
|
3459
4396
|
{
|
|
3460
4397
|
name,
|
|
@@ -3613,7 +4550,7 @@ var _JsonObject = class _JsonObject extends Component2 {
|
|
|
3613
4550
|
style: minus,
|
|
3614
4551
|
"aria-label": `remove the object '${String(name)}'`
|
|
3615
4552
|
});
|
|
3616
|
-
return
|
|
4553
|
+
return React20.createElement(React20.Fragment, null, React20.createElement("span", { style: collapsed }, "{...}", " ", keyList.length, " ", keyList.length === 1 ? "key" : "keys"), !isReadOnly && removeItemButton);
|
|
3617
4554
|
}
|
|
3618
4555
|
renderNotCollapsed() {
|
|
3619
4556
|
const { name, data, keyPath, deep, nextDeep, addFormVisible } = this.state;
|
|
@@ -3651,7 +4588,7 @@ var _JsonObject = class _JsonObject extends Component2 {
|
|
|
3651
4588
|
style: minus,
|
|
3652
4589
|
"aria-label": `remove the object '${String(name)}'`
|
|
3653
4590
|
});
|
|
3654
|
-
const list = keyList.map((key) =>
|
|
4591
|
+
const list = keyList.map((key) => React20.createElement(
|
|
3655
4592
|
JsonNode,
|
|
3656
4593
|
{
|
|
3657
4594
|
key,
|
|
@@ -3681,7 +4618,7 @@ var _JsonObject = class _JsonObject extends Component2 {
|
|
|
3681
4618
|
));
|
|
3682
4619
|
const startObject = "{";
|
|
3683
4620
|
const endObject = "}";
|
|
3684
|
-
return
|
|
4621
|
+
return React20.createElement(React20.Fragment, null, React20.createElement("span", { className: "rejt-not-collapsed-delimiter", style: delimiter }, startObject), !isReadOnly && addItemButton, React20.createElement("ul", { className: "rejt-not-collapsed-list", style: ul }, list), !isReadOnly && addFormVisible && React20.createElement("div", { className: "rejt-add-form", style: addForm }, React20.createElement(
|
|
3685
4622
|
JsonAddValue,
|
|
3686
4623
|
{
|
|
3687
4624
|
handleAdd: this.handleAddValueAdd,
|
|
@@ -3693,12 +4630,12 @@ var _JsonObject = class _JsonObject extends Component2 {
|
|
|
3693
4630
|
deep,
|
|
3694
4631
|
onSubmitValueParser
|
|
3695
4632
|
}
|
|
3696
|
-
)),
|
|
4633
|
+
)), React20.createElement("span", { className: "rejt-not-collapsed-delimiter", style: delimiter }, endObject), !isReadOnly && removeItemButton);
|
|
3697
4634
|
}
|
|
3698
4635
|
render() {
|
|
3699
4636
|
const { name, collapsed, keyPath, deep = 0 } = this.state;
|
|
3700
4637
|
const value2 = collapsed ? this.renderCollapsed() : this.renderNotCollapsed();
|
|
3701
|
-
return
|
|
4638
|
+
return React20.createElement(
|
|
3702
4639
|
JsonNodeAccordion,
|
|
3703
4640
|
{
|
|
3704
4641
|
name,
|
|
@@ -3716,8 +4653,8 @@ var JsonObject = _JsonObject;
|
|
|
3716
4653
|
JsonObject.defaultProps = {
|
|
3717
4654
|
keyPath: [],
|
|
3718
4655
|
deep: 0,
|
|
3719
|
-
minusMenuElement:
|
|
3720
|
-
plusMenuElement:
|
|
4656
|
+
minusMenuElement: React20.createElement("span", null, " - "),
|
|
4657
|
+
plusMenuElement: React20.createElement("span", null, " + ")
|
|
3721
4658
|
};
|
|
3722
4659
|
var _JsonValue = class _JsonValue extends Component2 {
|
|
3723
4660
|
constructor(props) {
|
|
@@ -3827,7 +4764,7 @@ var _JsonValue = class _JsonValue extends Component2 {
|
|
|
3827
4764
|
style: style.minus,
|
|
3828
4765
|
"aria-label": `remove the property '${String(name)}' with value '${String(originalValue)}'${String(parentPropertyName) ? ` from '${String(parentPropertyName)}'` : ""}`
|
|
3829
4766
|
});
|
|
3830
|
-
return
|
|
4767
|
+
return React20.createElement("li", { className: "rejt-value-node", style: style.li }, React20.createElement("span", { className: "rejt-name", style: style.name }, name, " : "), isEditing ? React20.createElement("span", { className: "rejt-edit-form", style: style.editForm }, inputElementLayout) : React20.createElement(
|
|
3831
4768
|
"span",
|
|
3832
4769
|
{
|
|
3833
4770
|
className: "rejt-value",
|
|
@@ -3844,8 +4781,8 @@ JsonValue.defaultProps = {
|
|
|
3844
4781
|
keyPath: [],
|
|
3845
4782
|
deep: 0,
|
|
3846
4783
|
handleUpdateValue: /* @__PURE__ */ __name(() => Promise.resolve(), "handleUpdateValue"),
|
|
3847
|
-
cancelButtonElement:
|
|
3848
|
-
minusMenuElement:
|
|
4784
|
+
cancelButtonElement: React20.createElement("button", null, "c"),
|
|
4785
|
+
minusMenuElement: React20.createElement("span", null, " - ")
|
|
3849
4786
|
};
|
|
3850
4787
|
|
|
3851
4788
|
// src/blocks/controls/react-editable-json-tree/utils/parse.ts
|
|
@@ -3984,7 +4921,7 @@ var _JsonTree = class _JsonTree extends Component3 {
|
|
|
3984
4921
|
textareaElementFunction = /* @__PURE__ */ __name(() => textareaElement, "textareaElementFunction");
|
|
3985
4922
|
}
|
|
3986
4923
|
if (dataType === "Object" || dataType === "Array") {
|
|
3987
|
-
return
|
|
4924
|
+
return React21.createElement("div", { className: "rejt-tree" }, React21.createElement(
|
|
3988
4925
|
JsonNode,
|
|
3989
4926
|
{
|
|
3990
4927
|
data,
|
|
@@ -4041,8 +4978,8 @@ JsonTree.defaultProps = {
|
|
|
4041
4978
|
logger: { error: /* @__PURE__ */ __name(() => {
|
|
4042
4979
|
}, "error") },
|
|
4043
4980
|
onSubmitValueParser: /* @__PURE__ */ __name((isEditMode, keyPath, deep, name, rawValue) => parse3(rawValue), "onSubmitValueParser"),
|
|
4044
|
-
inputElement: /* @__PURE__ */ __name(() =>
|
|
4045
|
-
textareaElement: /* @__PURE__ */ __name(() =>
|
|
4981
|
+
inputElement: /* @__PURE__ */ __name(() => React21.createElement("input", null), "inputElement"),
|
|
4982
|
+
textareaElement: /* @__PURE__ */ __name(() => React21.createElement("textarea", null), "textareaElement"),
|
|
4046
4983
|
fallback: null
|
|
4047
4984
|
};
|
|
4048
4985
|
|
|
@@ -4212,8 +5149,8 @@ var ObjectControl = /* @__PURE__ */ __name(({ name, value: value2, onChange, arg
|
|
|
4212
5149
|
const theme = useTheme();
|
|
4213
5150
|
const data = useMemo(() => value2 && cloneDeep(value2), [value2]);
|
|
4214
5151
|
const hasData = data !== null && data !== void 0;
|
|
4215
|
-
const [showRaw, setShowRaw] =
|
|
4216
|
-
const [parseError, setParseError] =
|
|
5152
|
+
const [showRaw, setShowRaw] = useState7(!hasData);
|
|
5153
|
+
const [parseError, setParseError] = useState7(null);
|
|
4217
5154
|
const readonly = !!argType?.table?.readonly;
|
|
4218
5155
|
const updateRaw = useCallback4(
|
|
4219
5156
|
(raw) => {
|
|
@@ -4228,21 +5165,21 @@ var ObjectControl = /* @__PURE__ */ __name(({ name, value: value2, onChange, arg
|
|
|
4228
5165
|
},
|
|
4229
5166
|
[onChange]
|
|
4230
5167
|
);
|
|
4231
|
-
const [forceVisible, setForceVisible] =
|
|
5168
|
+
const [forceVisible, setForceVisible] = useState7(false);
|
|
4232
5169
|
const onForceVisible = useCallback4(() => {
|
|
4233
5170
|
onChange({});
|
|
4234
5171
|
setForceVisible(true);
|
|
4235
5172
|
}, [setForceVisible]);
|
|
4236
5173
|
const htmlElRef = useRef4(null);
|
|
4237
|
-
|
|
5174
|
+
useEffect7(() => {
|
|
4238
5175
|
if (forceVisible && htmlElRef.current) {
|
|
4239
5176
|
htmlElRef.current.select();
|
|
4240
5177
|
}
|
|
4241
5178
|
}, [forceVisible]);
|
|
4242
5179
|
if (!hasData) {
|
|
4243
|
-
return
|
|
5180
|
+
return React22.createElement(Button3, { disabled: readonly, id: getControlSetterButtonId(name), onClick: onForceVisible }, "Set object");
|
|
4244
5181
|
}
|
|
4245
|
-
const rawJSONForm =
|
|
5182
|
+
const rawJSONForm = React22.createElement(
|
|
4246
5183
|
RawInput,
|
|
4247
5184
|
{
|
|
4248
5185
|
ref: htmlElRef,
|
|
@@ -4257,7 +5194,7 @@ var ObjectControl = /* @__PURE__ */ __name(({ name, value: value2, onChange, arg
|
|
|
4257
5194
|
}
|
|
4258
5195
|
);
|
|
4259
5196
|
const isObjectOrArray = Array.isArray(value2) || typeof value2 === "object" && value2?.constructor === Object;
|
|
4260
|
-
return
|
|
5197
|
+
return React22.createElement(Wrapper6, { "aria-readonly": readonly }, isObjectOrArray && React22.createElement(
|
|
4261
5198
|
RawButton,
|
|
4262
5199
|
{
|
|
4263
5200
|
role: "switch",
|
|
@@ -4268,9 +5205,9 @@ var ObjectControl = /* @__PURE__ */ __name(({ name, value: value2, onChange, arg
|
|
|
4268
5205
|
setShowRaw((isRaw) => !isRaw);
|
|
4269
5206
|
}
|
|
4270
5207
|
},
|
|
4271
|
-
showRaw ?
|
|
4272
|
-
|
|
4273
|
-
), !showRaw ?
|
|
5208
|
+
showRaw ? React22.createElement(EyeCloseIcon, null) : React22.createElement(EyeIcon, null),
|
|
5209
|
+
React22.createElement("span", null, "RAW")
|
|
5210
|
+
), !showRaw ? React22.createElement(
|
|
4274
5211
|
JsonTree,
|
|
4275
5212
|
{
|
|
4276
5213
|
readOnly: readonly || !isObjectOrArray,
|
|
@@ -4282,18 +5219,18 @@ var ObjectControl = /* @__PURE__ */ __name(({ name, value: value2, onChange, arg
|
|
|
4282
5219
|
rootName: name,
|
|
4283
5220
|
onFullyUpdate: onChange,
|
|
4284
5221
|
getStyle: getCustomStyleFunction(theme),
|
|
4285
|
-
cancelButtonElement:
|
|
4286
|
-
addButtonElement:
|
|
4287
|
-
plusMenuElement:
|
|
4288
|
-
minusMenuElement:
|
|
4289
|
-
inputElement: (_2, __, ___, key) => key ?
|
|
5222
|
+
cancelButtonElement: React22.createElement(ButtonInline, { type: "button" }, "Cancel"),
|
|
5223
|
+
addButtonElement: React22.createElement(ButtonInline, { type: "submit", primary: true }, "Save"),
|
|
5224
|
+
plusMenuElement: React22.createElement(ActionButton, { type: "button" }, React22.createElement(AddIcon, null)),
|
|
5225
|
+
minusMenuElement: React22.createElement(ActionButton, { type: "button" }, React22.createElement(SubtractIcon, null)),
|
|
5226
|
+
inputElement: (_2, __, ___, key) => key ? React22.createElement(Input, { onFocus: selectValue, onBlur: dispatchEnterKey }) : React22.createElement(Input, null),
|
|
4290
5227
|
fallback: rawJSONForm
|
|
4291
5228
|
}
|
|
4292
5229
|
) : rawJSONForm);
|
|
4293
5230
|
}, "ObjectControl");
|
|
4294
5231
|
|
|
4295
5232
|
// src/blocks/controls/Range.tsx
|
|
4296
|
-
import
|
|
5233
|
+
import React23, { useMemo as useMemo2 } from "react";
|
|
4297
5234
|
import { styled as styled17 } from "storybook/theming";
|
|
4298
5235
|
var RangeInput = styled17.input(
|
|
4299
5236
|
({ theme, min, max, value: value2, disabled }) => ({
|
|
@@ -4466,7 +5403,7 @@ var RangeControl = /* @__PURE__ */ __name(({
|
|
|
4466
5403
|
const hasValue = value2 !== void 0;
|
|
4467
5404
|
const numberOFDecimalsPlaces = useMemo2(() => getNumberOfDecimalPlaces(step), [step]);
|
|
4468
5405
|
const readonly = !!argType?.table?.readonly;
|
|
4469
|
-
return
|
|
5406
|
+
return React23.createElement(RangeWrapper, { "aria-readonly": readonly }, React23.createElement(RangeLabel, null, min), React23.createElement(
|
|
4470
5407
|
RangeInput,
|
|
4471
5408
|
{
|
|
4472
5409
|
id: getControlId(name),
|
|
@@ -4476,11 +5413,11 @@ var RangeControl = /* @__PURE__ */ __name(({
|
|
|
4476
5413
|
...{ name, min, max, step, onFocus, onBlur },
|
|
4477
5414
|
value: value2 ?? min
|
|
4478
5415
|
}
|
|
4479
|
-
),
|
|
5416
|
+
), React23.createElement(RangeCurrentAndMaxLabel, { numberOFDecimalsPlaces, max }, hasValue ? value2.toFixed(numberOFDecimalsPlaces) : "--", " / ", max));
|
|
4480
5417
|
}, "RangeControl");
|
|
4481
5418
|
|
|
4482
5419
|
// src/blocks/controls/Text.tsx
|
|
4483
|
-
import
|
|
5420
|
+
import React24, { useCallback as useCallback5, useState as useState8 } from "react";
|
|
4484
5421
|
import { Button as Button4, Form as Form4 } from "storybook/internal/components";
|
|
4485
5422
|
import { styled as styled18 } from "storybook/theming";
|
|
4486
5423
|
var Wrapper7 = styled18.label({
|
|
@@ -4504,13 +5441,13 @@ var TextControl = /* @__PURE__ */ __name(({
|
|
|
4504
5441
|
onChange(event.target.value);
|
|
4505
5442
|
}, "handleChange");
|
|
4506
5443
|
const readonly = !!argType?.table?.readonly;
|
|
4507
|
-
const [forceVisible, setForceVisible] =
|
|
5444
|
+
const [forceVisible, setForceVisible] = useState8(false);
|
|
4508
5445
|
const onForceVisible = useCallback5(() => {
|
|
4509
5446
|
onChange("");
|
|
4510
5447
|
setForceVisible(true);
|
|
4511
5448
|
}, [setForceVisible]);
|
|
4512
5449
|
if (value2 === void 0) {
|
|
4513
|
-
return
|
|
5450
|
+
return React24.createElement(
|
|
4514
5451
|
Button4,
|
|
4515
5452
|
{
|
|
4516
5453
|
variant: "outline",
|
|
@@ -4523,7 +5460,7 @@ var TextControl = /* @__PURE__ */ __name(({
|
|
|
4523
5460
|
);
|
|
4524
5461
|
}
|
|
4525
5462
|
const isValid = typeof value2 === "string";
|
|
4526
|
-
return
|
|
5463
|
+
return React24.createElement(Wrapper7, null, React24.createElement(
|
|
4527
5464
|
Form4.Textarea,
|
|
4528
5465
|
{
|
|
4529
5466
|
id: getControlId(name),
|
|
@@ -4536,11 +5473,11 @@ var TextControl = /* @__PURE__ */ __name(({
|
|
|
4536
5473
|
valid: isValid ? void 0 : "error",
|
|
4537
5474
|
...{ name, value: isValid ? value2 : "", onFocus, onBlur }
|
|
4538
5475
|
}
|
|
4539
|
-
), maxLength &&
|
|
5476
|
+
), maxLength && React24.createElement(MaxLength, { isMaxed: value2?.length === maxLength }, value2?.length ?? 0, " / ", maxLength));
|
|
4540
5477
|
}, "TextControl");
|
|
4541
5478
|
|
|
4542
5479
|
// src/blocks/controls/Files.tsx
|
|
4543
|
-
import
|
|
5480
|
+
import React25, { useEffect as useEffect8, useRef as useRef5 } from "react";
|
|
4544
5481
|
import { Form as Form5 } from "storybook/internal/components";
|
|
4545
5482
|
import { styled as styled19 } from "storybook/theming";
|
|
4546
5483
|
var FileInput = styled19(Form5.Input)({
|
|
@@ -4572,12 +5509,12 @@ var FilesControl = /* @__PURE__ */ __name(({
|
|
|
4572
5509
|
revokeOldUrls(value2 || []);
|
|
4573
5510
|
}
|
|
4574
5511
|
__name(handleFileChange, "handleFileChange");
|
|
4575
|
-
|
|
5512
|
+
useEffect8(() => {
|
|
4576
5513
|
if (value2 == null && inputElement.current) {
|
|
4577
5514
|
inputElement.current.value = "";
|
|
4578
5515
|
}
|
|
4579
5516
|
}, [value2, name]);
|
|
4580
|
-
return
|
|
5517
|
+
return React25.createElement(
|
|
4581
5518
|
FileInput,
|
|
4582
5519
|
{
|
|
4583
5520
|
ref: inputElement,
|
|
@@ -4595,7 +5532,7 @@ var FilesControl = /* @__PURE__ */ __name(({
|
|
|
4595
5532
|
|
|
4596
5533
|
// src/blocks/controls/index.tsx
|
|
4597
5534
|
var LazyColorControl = lazy(() => import("./_browser-chunks/Color-4NTW6CRW.js"));
|
|
4598
|
-
var ColorControl = /* @__PURE__ */ __name((props) =>
|
|
5535
|
+
var ColorControl = /* @__PURE__ */ __name((props) => React26.createElement(Suspense, { fallback: React26.createElement("div", null) }, React26.createElement(LazyColorControl, { ...props })), "ColorControl");
|
|
4599
5536
|
|
|
4600
5537
|
// src/blocks/components/ArgsTable/ArgControl.tsx
|
|
4601
5538
|
var Controls2 = {
|
|
@@ -4615,12 +5552,12 @@ var Controls2 = {
|
|
|
4615
5552
|
text: TextControl,
|
|
4616
5553
|
file: FilesControl
|
|
4617
5554
|
};
|
|
4618
|
-
var NoControl = /* @__PURE__ */ __name(() =>
|
|
5555
|
+
var NoControl = /* @__PURE__ */ __name(() => React27.createElement(React27.Fragment, null, "-"), "NoControl");
|
|
4619
5556
|
var ArgControl = /* @__PURE__ */ __name(({ row, arg, updateArgs, isHovered }) => {
|
|
4620
5557
|
const { key, control } = row;
|
|
4621
|
-
const [isFocused, setFocused] =
|
|
4622
|
-
const [boxedValue, setBoxedValue] =
|
|
4623
|
-
|
|
5558
|
+
const [isFocused, setFocused] = useState9(false);
|
|
5559
|
+
const [boxedValue, setBoxedValue] = useState9({ value: arg });
|
|
5560
|
+
useEffect9(() => {
|
|
4624
5561
|
if (!isFocused) {
|
|
4625
5562
|
setBoxedValue({ value: arg });
|
|
4626
5563
|
}
|
|
@@ -4637,7 +5574,7 @@ var ArgControl = /* @__PURE__ */ __name(({ row, arg, updateArgs, isHovered }) =>
|
|
|
4637
5574
|
const onFocus = useCallback6(() => setFocused(true), []);
|
|
4638
5575
|
if (!control || control.disable) {
|
|
4639
5576
|
const canBeSetup = control?.disable !== true && row?.type?.name !== "function";
|
|
4640
|
-
return isHovered && canBeSetup ?
|
|
5577
|
+
return isHovered && canBeSetup ? React27.createElement(
|
|
4641
5578
|
Link,
|
|
4642
5579
|
{
|
|
4643
5580
|
href: "https://storybook.js.org/docs/essentials/controls?ref=ui",
|
|
@@ -4645,15 +5582,15 @@ var ArgControl = /* @__PURE__ */ __name(({ row, arg, updateArgs, isHovered }) =>
|
|
|
4645
5582
|
withArrow: true
|
|
4646
5583
|
},
|
|
4647
5584
|
"Setup controls"
|
|
4648
|
-
) :
|
|
5585
|
+
) : React27.createElement(NoControl, null);
|
|
4649
5586
|
}
|
|
4650
5587
|
const props = { name: key, argType: row, value: boxedValue.value, onChange, onBlur, onFocus };
|
|
4651
5588
|
const Control = Controls2[control.type] || NoControl;
|
|
4652
|
-
return
|
|
5589
|
+
return React27.createElement(Control, { ...props, ...control, controlType: control.type });
|
|
4653
5590
|
}, "ArgControl");
|
|
4654
5591
|
|
|
4655
5592
|
// src/blocks/components/ArgsTable/ArgJsDoc.tsx
|
|
4656
|
-
import
|
|
5593
|
+
import React28 from "react";
|
|
4657
5594
|
import { codeCommon } from "storybook/internal/components";
|
|
4658
5595
|
import { styled as styled20 } from "storybook/theming";
|
|
4659
5596
|
var Table = styled20.table(({ theme }) => ({
|
|
@@ -4713,13 +5650,13 @@ var ArgJsDoc = /* @__PURE__ */ __name(({ tags }) => {
|
|
|
4713
5650
|
if (!hasDisplayableParams && !hasDisplayableReturns && !hasDisplayableDeprecated) {
|
|
4714
5651
|
return null;
|
|
4715
5652
|
}
|
|
4716
|
-
return
|
|
4717
|
-
return
|
|
4718
|
-
}), hasDisplayableReturns &&
|
|
5653
|
+
return React28.createElement(React28.Fragment, null, React28.createElement(Table, null, React28.createElement("tbody", null, hasDisplayableDeprecated && React28.createElement("tr", { key: "deprecated" }, React28.createElement("td", { colSpan: 2 }, React28.createElement("strong", null, "Deprecated"), ": ", tags.deprecated?.toString())), hasDisplayableParams && params.map((x2) => {
|
|
5654
|
+
return React28.createElement("tr", { key: x2.name }, React28.createElement("td", null, React28.createElement("code", null, x2.name)), React28.createElement("td", null, x2.description));
|
|
5655
|
+
}), hasDisplayableReturns && React28.createElement("tr", { key: "returns" }, React28.createElement("td", null, React28.createElement("code", null, "Returns")), React28.createElement("td", null, tags.returns?.description)))));
|
|
4719
5656
|
}, "ArgJsDoc");
|
|
4720
5657
|
|
|
4721
5658
|
// src/blocks/components/ArgsTable/ArgValue.tsx
|
|
4722
|
-
import
|
|
5659
|
+
import React29, { useState as useState10 } from "react";
|
|
4723
5660
|
import { SyntaxHighlighter, WithTooltipPure, codeCommon as codeCommon2 } from "storybook/internal/components";
|
|
4724
5661
|
import { ChevronSmallDownIcon as ChevronSmallDownIcon2, ChevronSmallUpIcon } from "@storybook/icons";
|
|
4725
5662
|
var import_memoizerific = __toESM(require_memoizerific(), 1);
|
|
@@ -4790,10 +5727,10 @@ var ChevronDownIcon = styled21(ChevronSmallDownIcon2)({
|
|
|
4790
5727
|
marginLeft: 4
|
|
4791
5728
|
});
|
|
4792
5729
|
var EmptyArg = /* @__PURE__ */ __name(() => {
|
|
4793
|
-
return
|
|
5730
|
+
return React29.createElement("span", null, "-");
|
|
4794
5731
|
}, "EmptyArg");
|
|
4795
5732
|
var ArgText = /* @__PURE__ */ __name(({ text, simple }) => {
|
|
4796
|
-
return
|
|
5733
|
+
return React29.createElement(Text3, { simple }, text);
|
|
4797
5734
|
}, "ArgText");
|
|
4798
5735
|
var calculateDetailWidth = (0, import_memoizerific.default)(1e3)((detail) => {
|
|
4799
5736
|
const lines = detail.split(/\r?\n/);
|
|
@@ -4812,12 +5749,12 @@ var renderSummaryItems = /* @__PURE__ */ __name((summaryItems, isExpanded = true
|
|
|
4812
5749
|
if (!isExpanded) {
|
|
4813
5750
|
items = summaryItems.slice(0, ITEMS_BEFORE_EXPANSION);
|
|
4814
5751
|
}
|
|
4815
|
-
return items.map((item) =>
|
|
5752
|
+
return items.map((item) => React29.createElement(ArgText, { key: item, text: item === "" ? '""' : item }));
|
|
4816
5753
|
}, "renderSummaryItems");
|
|
4817
5754
|
var ArgSummary = /* @__PURE__ */ __name(({ value: value2, initialExpandedArgs }) => {
|
|
4818
5755
|
const { summary, detail } = value2;
|
|
4819
|
-
const [isOpen, setIsOpen] =
|
|
4820
|
-
const [isExpanded, setIsExpanded] =
|
|
5756
|
+
const [isOpen, setIsOpen] = useState10(false);
|
|
5757
|
+
const [isExpanded, setIsExpanded] = useState10(initialExpandedArgs || false);
|
|
4821
5758
|
if (summary === void 0 || summary === null) {
|
|
4822
5759
|
return null;
|
|
4823
5760
|
}
|
|
@@ -4825,14 +5762,14 @@ var ArgSummary = /* @__PURE__ */ __name(({ value: value2, initialExpandedArgs })
|
|
|
4825
5762
|
if (detail == null) {
|
|
4826
5763
|
const cannotBeSafelySplitted = /[(){}[\]<>]/.test(summaryAsString);
|
|
4827
5764
|
if (cannotBeSafelySplitted) {
|
|
4828
|
-
return
|
|
5765
|
+
return React29.createElement(ArgText, { text: summaryAsString });
|
|
4829
5766
|
}
|
|
4830
5767
|
const summaryItems = getSummaryItems(summaryAsString);
|
|
4831
5768
|
const itemsCount = summaryItems.length;
|
|
4832
5769
|
const hasManyItems = itemsCount > ITEMS_BEFORE_EXPANSION;
|
|
4833
|
-
return hasManyItems ?
|
|
5770
|
+
return hasManyItems ? React29.createElement(Summary, { isExpanded }, renderSummaryItems(summaryItems, isExpanded), React29.createElement(ExpandButton, { onClick: () => setIsExpanded(!isExpanded) }, isExpanded ? "Show less..." : `Show ${itemsCount - ITEMS_BEFORE_EXPANSION} more...`)) : React29.createElement(Summary, null, renderSummaryItems(summaryItems));
|
|
4834
5771
|
}
|
|
4835
|
-
return
|
|
5772
|
+
return React29.createElement(
|
|
4836
5773
|
WithTooltipPure,
|
|
4837
5774
|
{
|
|
4838
5775
|
closeOnOutsideClick: true,
|
|
@@ -4841,13 +5778,13 @@ var ArgSummary = /* @__PURE__ */ __name(({ value: value2, initialExpandedArgs })
|
|
|
4841
5778
|
onVisibleChange: (isVisible) => {
|
|
4842
5779
|
setIsOpen(isVisible);
|
|
4843
5780
|
},
|
|
4844
|
-
tooltip:
|
|
5781
|
+
tooltip: React29.createElement(Detail, { width: calculateDetailWidth(detail) }, React29.createElement(SyntaxHighlighter, { language: "jsx", format: false }, detail))
|
|
4845
5782
|
},
|
|
4846
|
-
|
|
5783
|
+
React29.createElement(Expandable, { className: "sbdocs-expandable" }, React29.createElement("span", null, summaryAsString), isOpen ? React29.createElement(ChevronUpIcon, null) : React29.createElement(ChevronDownIcon, null))
|
|
4847
5784
|
);
|
|
4848
5785
|
}, "ArgSummary");
|
|
4849
5786
|
var ArgValue = /* @__PURE__ */ __name(({ value: value2, initialExpandedArgs }) => {
|
|
4850
|
-
return value2 == null ?
|
|
5787
|
+
return value2 == null ? React29.createElement(EmptyArg, null) : React29.createElement(ArgSummary, { value: value2, initialExpandedArgs });
|
|
4851
5788
|
}, "ArgValue");
|
|
4852
5789
|
|
|
4853
5790
|
// src/blocks/components/ArgsTable/ArgRow.tsx
|
|
@@ -4899,7 +5836,7 @@ var toSummary = /* @__PURE__ */ __name((value2) => {
|
|
|
4899
5836
|
return { summary: val };
|
|
4900
5837
|
}, "toSummary");
|
|
4901
5838
|
var ArgRow = /* @__PURE__ */ __name((props) => {
|
|
4902
|
-
const [isHovered, setIsHovered] =
|
|
5839
|
+
const [isHovered, setIsHovered] = useState11(false);
|
|
4903
5840
|
const { row, updateArgs, compact, expandable, initialExpandedArgs } = props;
|
|
4904
5841
|
const { name, description } = row;
|
|
4905
5842
|
const table = row.table || {};
|
|
@@ -4907,11 +5844,11 @@ var ArgRow = /* @__PURE__ */ __name((props) => {
|
|
|
4907
5844
|
const defaultValue = table.defaultValue || row.defaultValue;
|
|
4908
5845
|
const required = row.type?.required;
|
|
4909
5846
|
const hasDescription = description != null && description !== "";
|
|
4910
|
-
return
|
|
5847
|
+
return React30.createElement("tr", { onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false) }, React30.createElement(StyledTd, { expandable: expandable ?? false }, React30.createElement(Name, null, name), required ? React30.createElement(Required, { title: "Required" }, "*") : null), compact ? null : React30.createElement("td", null, hasDescription && React30.createElement(Description, null, React30.createElement(index_modern_default, null, description)), table.jsDocTags != null ? React30.createElement(React30.Fragment, null, React30.createElement(TypeWithJsDoc, { hasDescription }, React30.createElement(ArgValue, { value: type, initialExpandedArgs })), React30.createElement(ArgJsDoc, { tags: table.jsDocTags })) : React30.createElement(Type, { hasDescription }, React30.createElement(ArgValue, { value: type, initialExpandedArgs }))), compact ? null : React30.createElement("td", null, React30.createElement(ArgValue, { value: defaultValue, initialExpandedArgs })), updateArgs ? React30.createElement("td", null, React30.createElement(ArgControl, { ...props, isHovered })) : null);
|
|
4911
5848
|
}, "ArgRow");
|
|
4912
5849
|
|
|
4913
5850
|
// src/blocks/components/ArgsTable/Empty.tsx
|
|
4914
|
-
import
|
|
5851
|
+
import React31, { useEffect as useEffect10, useState as useState12 } from "react";
|
|
4915
5852
|
import { EmptyTabContent, Link as Link2 } from "storybook/internal/components";
|
|
4916
5853
|
import { DocumentIcon } from "@storybook/icons";
|
|
4917
5854
|
import { styled as styled23 } from "storybook/theming";
|
|
@@ -4933,8 +5870,8 @@ var Links = styled23.div(({ theme }) => ({
|
|
|
4933
5870
|
gap: 25
|
|
4934
5871
|
}));
|
|
4935
5872
|
var Empty = /* @__PURE__ */ __name(({ inAddonPanel }) => {
|
|
4936
|
-
const [isLoading, setIsLoading] =
|
|
4937
|
-
|
|
5873
|
+
const [isLoading, setIsLoading] = useState12(true);
|
|
5874
|
+
useEffect10(() => {
|
|
4938
5875
|
const load = setTimeout(() => {
|
|
4939
5876
|
setIsLoading(false);
|
|
4940
5877
|
}, 100);
|
|
@@ -4943,28 +5880,28 @@ var Empty = /* @__PURE__ */ __name(({ inAddonPanel }) => {
|
|
|
4943
5880
|
if (isLoading) {
|
|
4944
5881
|
return null;
|
|
4945
5882
|
}
|
|
4946
|
-
return
|
|
5883
|
+
return React31.createElement(Wrapper8, { inAddonPanel }, React31.createElement(
|
|
4947
5884
|
EmptyTabContent,
|
|
4948
5885
|
{
|
|
4949
5886
|
title: inAddonPanel ? "Interactive story playground" : "Args table with interactive controls couldn't be auto-generated",
|
|
4950
|
-
description:
|
|
4951
|
-
footer:
|
|
5887
|
+
description: React31.createElement(React31.Fragment, null, "Controls give you an easy to use interface to test your components. Set your story args and you'll see controls appearing here automatically."),
|
|
5888
|
+
footer: React31.createElement(Links, null, inAddonPanel && React31.createElement(React31.Fragment, null, React31.createElement(
|
|
4952
5889
|
Link2,
|
|
4953
5890
|
{
|
|
4954
5891
|
href: "https://storybook.js.org/docs/essentials/controls?ref=ui",
|
|
4955
5892
|
target: "_blank",
|
|
4956
5893
|
withArrow: true
|
|
4957
5894
|
},
|
|
4958
|
-
|
|
5895
|
+
React31.createElement(DocumentIcon, null),
|
|
4959
5896
|
" Read docs"
|
|
4960
|
-
)), !inAddonPanel &&
|
|
5897
|
+
)), !inAddonPanel && React31.createElement(
|
|
4961
5898
|
Link2,
|
|
4962
5899
|
{
|
|
4963
5900
|
href: "https://storybook.js.org/docs/essentials/controls?ref=ui",
|
|
4964
5901
|
target: "_blank",
|
|
4965
5902
|
withArrow: true
|
|
4966
5903
|
},
|
|
4967
|
-
|
|
5904
|
+
React31.createElement(DocumentIcon, null),
|
|
4968
5905
|
" Learn how to set that up"
|
|
4969
5906
|
))
|
|
4970
5907
|
}
|
|
@@ -4972,7 +5909,7 @@ var Empty = /* @__PURE__ */ __name(({ inAddonPanel }) => {
|
|
|
4972
5909
|
}, "Empty");
|
|
4973
5910
|
|
|
4974
5911
|
// src/blocks/components/ArgsTable/SectionRow.tsx
|
|
4975
|
-
import
|
|
5912
|
+
import React32, { useState as useState13 } from "react";
|
|
4976
5913
|
import { ChevronDownIcon as ChevronDownIcon2, ChevronRightIcon } from "@storybook/icons";
|
|
4977
5914
|
import { styled as styled24 } from "storybook/theming";
|
|
4978
5915
|
var ExpanderIconDown = styled24(ChevronDownIcon2)(({ theme }) => ({
|
|
@@ -5054,12 +5991,12 @@ var SectionRow = /* @__PURE__ */ __name(({
|
|
|
5054
5991
|
initialExpanded = true,
|
|
5055
5992
|
colSpan = 3
|
|
5056
5993
|
}) => {
|
|
5057
|
-
const [expanded, setExpanded] =
|
|
5994
|
+
const [expanded, setExpanded] = useState13(initialExpanded);
|
|
5058
5995
|
const Level = level === "subsection" ? Subsection : Section;
|
|
5059
5996
|
const itemCount = children?.length || 0;
|
|
5060
5997
|
const caption = level === "subsection" ? `${itemCount} item${itemCount !== 1 ? "s" : ""}` : "";
|
|
5061
5998
|
const helperText = `${expanded ? "Hide" : "Show"} ${level === "subsection" ? itemCount : label} item${itemCount !== 1 ? "s" : ""}`;
|
|
5062
|
-
return
|
|
5999
|
+
return React32.createElement(React32.Fragment, null, React32.createElement(StyledTr, { title: helperText }, React32.createElement(Level, { colSpan: 1 }, React32.createElement(ClickIntercept, { onClick: (e2) => setExpanded(!expanded), tabIndex: 0 }, helperText), React32.createElement(FlexWrapper, null, expanded ? React32.createElement(ExpanderIconDown, null) : React32.createElement(ExpanderIconRight, null), label)), React32.createElement(StyledTd2, { colSpan: colSpan - 1 }, React32.createElement(
|
|
5063
6000
|
ClickIntercept,
|
|
5064
6001
|
{
|
|
5065
6002
|
onClick: (e2) => setExpanded(!expanded),
|
|
@@ -5071,7 +6008,7 @@ var SectionRow = /* @__PURE__ */ __name(({
|
|
|
5071
6008
|
}, "SectionRow");
|
|
5072
6009
|
|
|
5073
6010
|
// src/blocks/components/ArgsTable/Skeleton.tsx
|
|
5074
|
-
import
|
|
6011
|
+
import React33 from "react";
|
|
5075
6012
|
import { styled as styled25 } from "storybook/theming";
|
|
5076
6013
|
var TableWrapper = styled25.div(({ theme }) => ({
|
|
5077
6014
|
width: "100%",
|
|
@@ -5129,7 +6066,7 @@ var SkeletonText = styled25.div(
|
|
|
5129
6066
|
borderRadius: 3
|
|
5130
6067
|
})
|
|
5131
6068
|
);
|
|
5132
|
-
var Skeleton = /* @__PURE__ */ __name(() =>
|
|
6069
|
+
var Skeleton = /* @__PURE__ */ __name(() => React33.createElement(TableWrapper, null, React33.createElement(Row, null, React33.createElement(Column, { position: "first" }, React33.createElement(SkeletonText, { width: "60%" })), React33.createElement(Column, { position: "second" }, React33.createElement(SkeletonText, { width: "30%" })), React33.createElement(Column, { position: "third" }, React33.createElement(SkeletonText, { width: "60%" })), React33.createElement(Column, { position: "last" }, React33.createElement(SkeletonText, { width: "60%" }))), React33.createElement(Row, null, React33.createElement(Column, { position: "first" }, React33.createElement(SkeletonText, { width: "60%" })), React33.createElement(Column, { position: "second" }, React33.createElement(SkeletonText, { width: "80%" }), React33.createElement(SkeletonText, { width: "30%" })), React33.createElement(Column, { position: "third" }, React33.createElement(SkeletonText, { width: "60%" })), React33.createElement(Column, { position: "last" }, React33.createElement(SkeletonText, { width: "60%" }))), React33.createElement(Row, null, React33.createElement(Column, { position: "first" }, React33.createElement(SkeletonText, { width: "60%" })), React33.createElement(Column, { position: "second" }, React33.createElement(SkeletonText, { width: "80%" }), React33.createElement(SkeletonText, { width: "30%" })), React33.createElement(Column, { position: "third" }, React33.createElement(SkeletonText, { width: "60%" })), React33.createElement(Column, { position: "last" }, React33.createElement(SkeletonText, { width: "60%" }))), React33.createElement(Row, null, React33.createElement(Column, { position: "first" }, React33.createElement(SkeletonText, { width: "60%" })), React33.createElement(Column, { position: "second" }, React33.createElement(SkeletonText, { width: "80%" }), React33.createElement(SkeletonText, { width: "30%" })), React33.createElement(Column, { position: "third" }, React33.createElement(SkeletonText, { width: "60%" })), React33.createElement(Column, { position: "last" }, React33.createElement(SkeletonText, { width: "60%" })))), "Skeleton");
|
|
5133
6070
|
|
|
5134
6071
|
// src/blocks/components/ArgsTable/ArgsTable.tsx
|
|
5135
6072
|
var TableWrapper2 = styled26.table(({ theme, compact, inAddonPanel }) => ({
|
|
@@ -5330,10 +6267,10 @@ var ArgsTable = /* @__PURE__ */ __name((props) => {
|
|
|
5330
6267
|
} = props;
|
|
5331
6268
|
if ("error" in props) {
|
|
5332
6269
|
const { error } = props;
|
|
5333
|
-
return
|
|
6270
|
+
return React34.createElement(EmptyBlock, null, error, "\xA0", React34.createElement(Link3, { href: "http://storybook.js.org/docs/?ref=ui", target: "_blank", withArrow: true }, React34.createElement(DocumentIcon2, null), " Read the docs"));
|
|
5334
6271
|
}
|
|
5335
6272
|
if (isLoading) {
|
|
5336
|
-
return
|
|
6273
|
+
return React34.createElement(Skeleton, null);
|
|
5337
6274
|
}
|
|
5338
6275
|
const { rows, args, globals } = "rows" in props ? props : { rows: void 0, args: void 0, globals: void 0 };
|
|
5339
6276
|
const groups = groupRows(
|
|
@@ -5347,7 +6284,7 @@ var ArgsTable = /* @__PURE__ */ __name((props) => {
|
|
|
5347
6284
|
const hasNoSections = Object.entries(groups.sections).length === 0;
|
|
5348
6285
|
const hasNoUngroupedSubsections = Object.entries(groups.ungroupedSubsections).length === 0;
|
|
5349
6286
|
if (hasNoUngrouped && hasNoSections && hasNoUngroupedSubsections) {
|
|
5350
|
-
return
|
|
6287
|
+
return React34.createElement(Empty, { inAddonPanel });
|
|
5351
6288
|
}
|
|
5352
6289
|
let colSpan = 1;
|
|
5353
6290
|
if (updateArgs) {
|
|
@@ -5358,15 +6295,15 @@ var ArgsTable = /* @__PURE__ */ __name((props) => {
|
|
|
5358
6295
|
}
|
|
5359
6296
|
const expandable = Object.keys(groups.sections).length > 0;
|
|
5360
6297
|
const common = { updateArgs, compact, inAddonPanel, initialExpandedArgs };
|
|
5361
|
-
return
|
|
6298
|
+
return React34.createElement(ResetWrapper3, null, React34.createElement(TablePositionWrapper, null, updateArgs && !isLoading && resetArgs && React34.createElement(ButtonPositionWrapper, null, React34.createElement(
|
|
5362
6299
|
IconButton3,
|
|
5363
6300
|
{
|
|
5364
6301
|
onClick: () => resetArgs(),
|
|
5365
6302
|
"aria-label": "Reset controls",
|
|
5366
6303
|
title: "Reset controls"
|
|
5367
6304
|
},
|
|
5368
|
-
|
|
5369
|
-
)),
|
|
6305
|
+
React34.createElement(UndoIcon, null)
|
|
6306
|
+
)), React34.createElement(TableWrapper2, { ...{ compact, inAddonPanel }, className: "docblock-argstable sb-unstyled" }, React34.createElement("thead", { className: "docblock-argstable-head" }, React34.createElement("tr", null, React34.createElement("th", null, React34.createElement("span", null, "Name")), compact ? null : React34.createElement("th", null, React34.createElement("span", null, "Description")), compact ? null : React34.createElement("th", null, React34.createElement("span", null, "Default")), updateArgs ? React34.createElement("th", null, React34.createElement("span", null, "Control")) : null)), React34.createElement("tbody", { className: "docblock-argstable-body" }, groups.ungrouped.map((row) => React34.createElement(ArgRow, { key: row.key, row, arg: args && args[row.key], ...common })), Object.entries(groups.ungroupedSubsections).map(([subcategory, subsection]) => React34.createElement(
|
|
5370
6307
|
SectionRow,
|
|
5371
6308
|
{
|
|
5372
6309
|
key: subcategory,
|
|
@@ -5374,7 +6311,7 @@ var ArgsTable = /* @__PURE__ */ __name((props) => {
|
|
|
5374
6311
|
level: "subsection",
|
|
5375
6312
|
colSpan
|
|
5376
6313
|
},
|
|
5377
|
-
subsection.map((row) =>
|
|
6314
|
+
subsection.map((row) => React34.createElement(
|
|
5378
6315
|
ArgRow,
|
|
5379
6316
|
{
|
|
5380
6317
|
key: row.key,
|
|
@@ -5384,7 +6321,7 @@ var ArgsTable = /* @__PURE__ */ __name((props) => {
|
|
|
5384
6321
|
...common
|
|
5385
6322
|
}
|
|
5386
6323
|
))
|
|
5387
|
-
)), Object.entries(groups.sections).map(([category, section]) =>
|
|
6324
|
+
)), Object.entries(groups.sections).map(([category, section]) => React34.createElement(SectionRow, { key: category, label: category, level: "section", colSpan }, section.ungrouped.map((row) => React34.createElement(ArgRow, { key: row.key, row, arg: args && args[row.key], ...common })), Object.entries(section.subsections).map(([subcategory, subsection]) => React34.createElement(
|
|
5388
6325
|
SectionRow,
|
|
5389
6326
|
{
|
|
5390
6327
|
key: subcategory,
|
|
@@ -5392,7 +6329,7 @@ var ArgsTable = /* @__PURE__ */ __name((props) => {
|
|
|
5392
6329
|
level: "subsection",
|
|
5393
6330
|
colSpan
|
|
5394
6331
|
},
|
|
5395
|
-
subsection.map((row) =>
|
|
6332
|
+
subsection.map((row) => React34.createElement(
|
|
5396
6333
|
ArgRow,
|
|
5397
6334
|
{
|
|
5398
6335
|
key: row.key,
|
|
@@ -5406,28 +6343,18 @@ var ArgsTable = /* @__PURE__ */ __name((props) => {
|
|
|
5406
6343
|
}, "ArgsTable");
|
|
5407
6344
|
|
|
5408
6345
|
// src/blocks/blocks/Anchor.tsx
|
|
5409
|
-
import
|
|
6346
|
+
import React35 from "react";
|
|
5410
6347
|
var anchorBlockIdFromId = /* @__PURE__ */ __name((storyId) => `anchor--${storyId}`, "anchorBlockIdFromId");
|
|
5411
|
-
var Anchor = /* @__PURE__ */ __name(({ storyId, children }) =>
|
|
6348
|
+
var Anchor = /* @__PURE__ */ __name(({ storyId, children }) => React35.createElement("div", { id: anchorBlockIdFromId(storyId), className: "sb-anchor" }, children), "Anchor");
|
|
5412
6349
|
|
|
5413
6350
|
// src/blocks/blocks/ArgTypes.tsx
|
|
5414
|
-
import
|
|
6351
|
+
import React36 from "react";
|
|
5415
6352
|
import { filterArgTypes } from "storybook/preview-api";
|
|
5416
6353
|
|
|
5417
6354
|
// src/blocks/blocks/useOf.ts
|
|
5418
|
-
import { useContext } from "react";
|
|
5419
|
-
|
|
5420
|
-
// src/blocks/blocks/DocsContext.ts
|
|
5421
|
-
import { createContext as createContext2 } from "react";
|
|
5422
|
-
if (globalThis && globalThis.__DOCS_CONTEXT__ === void 0) {
|
|
5423
|
-
globalThis.__DOCS_CONTEXT__ = createContext2(null);
|
|
5424
|
-
globalThis.__DOCS_CONTEXT__.displayName = "DocsContext";
|
|
5425
|
-
}
|
|
5426
|
-
var DocsContext = globalThis ? globalThis.__DOCS_CONTEXT__ : createContext2(null);
|
|
5427
|
-
|
|
5428
|
-
// src/blocks/blocks/useOf.ts
|
|
6355
|
+
import { useContext as useContext3 } from "react";
|
|
5429
6356
|
var useOf = /* @__PURE__ */ __name((moduleExportOrType, validTypes) => {
|
|
5430
|
-
const context =
|
|
6357
|
+
const context = useContext3(DocsContext);
|
|
5431
6358
|
return context.resolveOf(moduleExportOrType, validTypes);
|
|
5432
6359
|
}, "useOf");
|
|
5433
6360
|
|
|
@@ -5504,7 +6431,7 @@ var ArgTypes = /* @__PURE__ */ __name((props) => {
|
|
|
5504
6431
|
const filteredArgTypes = filterArgTypes(argTypes, include, exclude);
|
|
5505
6432
|
const hasSubcomponents = Boolean(subcomponents) && Object.keys(subcomponents || {}).length > 0;
|
|
5506
6433
|
if (!hasSubcomponents) {
|
|
5507
|
-
return
|
|
6434
|
+
return React36.createElement(ArgsTable, { rows: filteredArgTypes, sort });
|
|
5508
6435
|
}
|
|
5509
6436
|
const mainComponentName = getComponentName(component) || "Main";
|
|
5510
6437
|
const subcomponentTabs = Object.fromEntries(
|
|
@@ -5524,18 +6451,18 @@ var ArgTypes = /* @__PURE__ */ __name((props) => {
|
|
|
5524
6451
|
[mainComponentName]: { rows: filteredArgTypes, sort },
|
|
5525
6452
|
...subcomponentTabs
|
|
5526
6453
|
};
|
|
5527
|
-
return
|
|
6454
|
+
return React36.createElement(TabbedArgsTable, { tabs, sort });
|
|
5528
6455
|
}, "ArgTypes");
|
|
5529
6456
|
|
|
5530
6457
|
// src/blocks/blocks/Canvas.tsx
|
|
5531
|
-
import React39, { useContext as
|
|
6458
|
+
import React39, { useContext as useContext5 } from "react";
|
|
5532
6459
|
|
|
5533
6460
|
// src/blocks/blocks/Source.tsx
|
|
5534
|
-
import
|
|
6461
|
+
import React38, { useContext as useContext4, useMemo as useMemo3 } from "react";
|
|
5535
6462
|
import { SourceType } from "storybook/internal/docs-tools";
|
|
5536
6463
|
|
|
5537
6464
|
// src/blocks/blocks/SourceContainer.tsx
|
|
5538
|
-
import
|
|
6465
|
+
import React37, { createContext as createContext3, useEffect as useEffect11, useState as useState14 } from "react";
|
|
5539
6466
|
import { SNIPPET_RENDERED } from "storybook/internal/docs-tools";
|
|
5540
6467
|
|
|
5541
6468
|
// ../../node_modules/telejson/dist/chunk-EAFQLD22.mjs
|
|
@@ -7075,8 +8002,8 @@ var SourceContainer = /* @__PURE__ */ __name(({
|
|
|
7075
8002
|
children,
|
|
7076
8003
|
channel
|
|
7077
8004
|
}) => {
|
|
7078
|
-
const [sources, setSources] =
|
|
7079
|
-
|
|
8005
|
+
const [sources, setSources] = useState14({});
|
|
8006
|
+
useEffect11(() => {
|
|
7080
8007
|
const handleSnippetRendered = /* @__PURE__ */ __name((idOrEvent, inputSource = null, inputFormat = false) => {
|
|
7081
8008
|
const {
|
|
7082
8009
|
id,
|
|
@@ -7103,15 +8030,15 @@ var SourceContainer = /* @__PURE__ */ __name(({
|
|
|
7103
8030
|
channel.on(SNIPPET_RENDERED, handleSnippetRendered);
|
|
7104
8031
|
return () => channel.off(SNIPPET_RENDERED, handleSnippetRendered);
|
|
7105
8032
|
}, []);
|
|
7106
|
-
return
|
|
8033
|
+
return React37.createElement(SourceContext.Provider, { value: { sources } }, children);
|
|
7107
8034
|
}, "SourceContainer");
|
|
7108
8035
|
|
|
7109
8036
|
// src/blocks/blocks/useTransformCode.tsx
|
|
7110
|
-
import { useEffect as
|
|
8037
|
+
import { useEffect as useEffect12, useState as useState15 } from "react";
|
|
7111
8038
|
function useTransformCode(source, transform, storyContext) {
|
|
7112
|
-
const [transformedCode, setTransformedCode] =
|
|
8039
|
+
const [transformedCode, setTransformedCode] = useState15("Transforming...");
|
|
7113
8040
|
const transformed = transform ? transform?.(source, storyContext) : source;
|
|
7114
|
-
|
|
8041
|
+
useEffect12(() => {
|
|
7115
8042
|
async function getTransformedCode() {
|
|
7116
8043
|
const transformResult = await transformed;
|
|
7117
8044
|
if (transformResult !== transformedCode) {
|
|
@@ -7207,106 +8134,16 @@ var useSourceProps = /* @__PURE__ */ __name((props, docsContext, sourceContext)
|
|
|
7207
8134
|
};
|
|
7208
8135
|
}, "useSourceProps");
|
|
7209
8136
|
var Source2 = /* @__PURE__ */ __name((props) => {
|
|
7210
|
-
const sourceContext =
|
|
7211
|
-
const docsContext =
|
|
8137
|
+
const sourceContext = useContext4(SourceContext);
|
|
8138
|
+
const docsContext = useContext4(DocsContext);
|
|
7212
8139
|
const sourceProps = useSourceProps(props, docsContext, sourceContext);
|
|
7213
|
-
return
|
|
8140
|
+
return React38.createElement(Source, { ...sourceProps });
|
|
7214
8141
|
}, "Source");
|
|
7215
8142
|
|
|
7216
|
-
// src/blocks/blocks/Story.tsx
|
|
7217
|
-
import React38, { useContext as useContext3 } from "react";
|
|
7218
|
-
|
|
7219
|
-
// src/blocks/blocks/useStory.ts
|
|
7220
|
-
import { useEffect as useEffect12, useState as useState15 } from "react";
|
|
7221
|
-
function useStory(storyId, context) {
|
|
7222
|
-
const stories = useStories([storyId], context);
|
|
7223
|
-
return stories && stories[0];
|
|
7224
|
-
}
|
|
7225
|
-
__name(useStory, "useStory");
|
|
7226
|
-
function useStories(storyIds, context) {
|
|
7227
|
-
const [storiesById, setStories] = useState15({});
|
|
7228
|
-
useEffect12(() => {
|
|
7229
|
-
Promise.all(
|
|
7230
|
-
storyIds.map(async (storyId) => {
|
|
7231
|
-
const story = await context.loadStory(storyId);
|
|
7232
|
-
setStories(
|
|
7233
|
-
(current) => current[storyId] === story ? current : { ...current, [storyId]: story }
|
|
7234
|
-
);
|
|
7235
|
-
})
|
|
7236
|
-
);
|
|
7237
|
-
});
|
|
7238
|
-
return storyIds.map((storyId) => {
|
|
7239
|
-
if (storiesById[storyId]) {
|
|
7240
|
-
return storiesById[storyId];
|
|
7241
|
-
}
|
|
7242
|
-
try {
|
|
7243
|
-
return context.storyById(storyId);
|
|
7244
|
-
} catch (err) {
|
|
7245
|
-
return void 0;
|
|
7246
|
-
}
|
|
7247
|
-
});
|
|
7248
|
-
}
|
|
7249
|
-
__name(useStories, "useStories");
|
|
7250
|
-
|
|
7251
|
-
// src/blocks/blocks/Story.tsx
|
|
7252
|
-
var getStoryId2 = /* @__PURE__ */ __name((props, context) => {
|
|
7253
|
-
const { of, meta } = props;
|
|
7254
|
-
if ("of" in props && of === void 0) {
|
|
7255
|
-
throw new Error("Unexpected `of={undefined}`, did you mistype a CSF file reference?");
|
|
7256
|
-
}
|
|
7257
|
-
if (meta) {
|
|
7258
|
-
context.referenceMeta(meta, false);
|
|
7259
|
-
}
|
|
7260
|
-
const resolved = context.resolveOf(of || "story", ["story"]);
|
|
7261
|
-
return resolved.story.id;
|
|
7262
|
-
}, "getStoryId");
|
|
7263
|
-
var getStoryProps = /* @__PURE__ */ __name((props, story, context) => {
|
|
7264
|
-
const { parameters = {} } = story || {};
|
|
7265
|
-
const { docs = {} } = parameters;
|
|
7266
|
-
const storyParameters = docs.story || {};
|
|
7267
|
-
if (docs.disable) {
|
|
7268
|
-
return null;
|
|
7269
|
-
}
|
|
7270
|
-
const inline = props.inline ?? storyParameters.inline ?? false;
|
|
7271
|
-
if (inline) {
|
|
7272
|
-
const height2 = props.height ?? storyParameters.height;
|
|
7273
|
-
const autoplay = props.autoplay ?? storyParameters.autoplay ?? false;
|
|
7274
|
-
return {
|
|
7275
|
-
story,
|
|
7276
|
-
inline: true,
|
|
7277
|
-
height: height2,
|
|
7278
|
-
autoplay,
|
|
7279
|
-
forceInitialArgs: !!props.__forceInitialArgs,
|
|
7280
|
-
primary: !!props.__primary,
|
|
7281
|
-
renderStoryToElement: context.renderStoryToElement
|
|
7282
|
-
};
|
|
7283
|
-
}
|
|
7284
|
-
const height = props.height ?? storyParameters.height ?? storyParameters.iframeHeight ?? "100px";
|
|
7285
|
-
return {
|
|
7286
|
-
story,
|
|
7287
|
-
inline: false,
|
|
7288
|
-
height,
|
|
7289
|
-
primary: !!props.__primary
|
|
7290
|
-
};
|
|
7291
|
-
}, "getStoryProps");
|
|
7292
|
-
var Story2 = /* @__PURE__ */ __name((props = { __forceInitialArgs: false, __primary: false }) => {
|
|
7293
|
-
const context = useContext3(DocsContext);
|
|
7294
|
-
const storyId = getStoryId2(props, context);
|
|
7295
|
-
const story = useStory(storyId, context);
|
|
7296
|
-
if (!story) {
|
|
7297
|
-
return React38.createElement(StorySkeleton, null);
|
|
7298
|
-
}
|
|
7299
|
-
const storyProps = getStoryProps(props, story, context);
|
|
7300
|
-
if (!storyProps) {
|
|
7301
|
-
return null;
|
|
7302
|
-
}
|
|
7303
|
-
return React38.createElement(Story, { ...storyProps });
|
|
7304
|
-
}, "Story");
|
|
7305
|
-
|
|
7306
8143
|
// src/blocks/blocks/Canvas.tsx
|
|
7307
8144
|
var Canvas = /* @__PURE__ */ __name((props) => {
|
|
7308
|
-
const docsContext =
|
|
7309
|
-
const sourceContext =
|
|
8145
|
+
const docsContext = useContext5(DocsContext);
|
|
8146
|
+
const sourceContext = useContext5(SourceContext);
|
|
7310
8147
|
const { of, source } = props;
|
|
7311
8148
|
if ("of" in props && of === void 0) {
|
|
7312
8149
|
throw new Error("Unexpected `of={undefined}`, did you mistype a CSF file reference?");
|
|
@@ -7335,7 +8172,7 @@ var Canvas = /* @__PURE__ */ __name((props) => {
|
|
|
7335
8172
|
}, "Canvas");
|
|
7336
8173
|
|
|
7337
8174
|
// src/blocks/blocks/Controls.tsx
|
|
7338
|
-
import React40, { useContext as
|
|
8175
|
+
import React40, { useContext as useContext6 } from "react";
|
|
7339
8176
|
import { filterArgTypes as filterArgTypes2 } from "storybook/preview-api";
|
|
7340
8177
|
|
|
7341
8178
|
// src/blocks/blocks/useArgs.ts
|
|
@@ -7406,7 +8243,7 @@ var Controls3 = /* @__PURE__ */ __name((props) => {
|
|
|
7406
8243
|
if ("of" in props && of === void 0) {
|
|
7407
8244
|
throw new Error("Unexpected `of={undefined}`, did you mistype a CSF file reference?");
|
|
7408
8245
|
}
|
|
7409
|
-
const context =
|
|
8246
|
+
const context = useContext6(DocsContext);
|
|
7410
8247
|
const { story } = context.resolveOf(of || "story", ["story"]);
|
|
7411
8248
|
const { parameters, argTypes, component, subcomponents } = story;
|
|
7412
8249
|
const controlsParameters = parameters.docs?.controls || {};
|
|
@@ -7468,12 +8305,12 @@ import React42 from "react";
|
|
|
7468
8305
|
import { dedent } from "ts-dedent";
|
|
7469
8306
|
|
|
7470
8307
|
// src/blocks/blocks/mdx.tsx
|
|
7471
|
-
import React41, { useContext as
|
|
8308
|
+
import React41, { useContext as useContext7 } from "react";
|
|
7472
8309
|
import { Code, components, nameSpaceClassNames } from "storybook/internal/components";
|
|
7473
8310
|
import { NAVIGATE_URL as NAVIGATE_URL2 } from "storybook/internal/core-events";
|
|
7474
8311
|
import { LinkIcon } from "@storybook/icons";
|
|
7475
8312
|
import { styled as styled27 } from "storybook/theming";
|
|
7476
|
-
var { document } = globalThis;
|
|
8313
|
+
var { document: document2 } = globalThis;
|
|
7477
8314
|
var assertIsFn = /* @__PURE__ */ __name((val) => {
|
|
7478
8315
|
if (typeof val !== "function") {
|
|
7479
8316
|
throw new Error(`Expected story function, got: ${val}`);
|
|
@@ -7510,7 +8347,7 @@ function navigate(context, url) {
|
|
|
7510
8347
|
__name(navigate, "navigate");
|
|
7511
8348
|
var A2 = components.a;
|
|
7512
8349
|
var AnchorInPage = /* @__PURE__ */ __name(({ hash, children }) => {
|
|
7513
|
-
const context =
|
|
8350
|
+
const context = useContext7(DocsContext);
|
|
7514
8351
|
return React41.createElement(
|
|
7515
8352
|
A2,
|
|
7516
8353
|
{
|
|
@@ -7518,7 +8355,7 @@ var AnchorInPage = /* @__PURE__ */ __name(({ hash, children }) => {
|
|
|
7518
8355
|
target: "_self",
|
|
7519
8356
|
onClick: (event) => {
|
|
7520
8357
|
const id = hash.substring(1);
|
|
7521
|
-
const element =
|
|
8358
|
+
const element = document2.getElementById(id);
|
|
7522
8359
|
if (element) {
|
|
7523
8360
|
navigate(context, hash);
|
|
7524
8361
|
}
|
|
@@ -7529,7 +8366,7 @@ var AnchorInPage = /* @__PURE__ */ __name(({ hash, children }) => {
|
|
|
7529
8366
|
}, "AnchorInPage");
|
|
7530
8367
|
var AnchorMdx = /* @__PURE__ */ __name((props) => {
|
|
7531
8368
|
const { href, target, children, ...rest } = props;
|
|
7532
|
-
const context =
|
|
8369
|
+
const context = useContext7(DocsContext);
|
|
7533
8370
|
if (!href || target === "_blank" || /^https?:\/\//.test(href)) {
|
|
7534
8371
|
return React41.createElement(A2, { ...props });
|
|
7535
8372
|
}
|
|
@@ -7587,7 +8424,7 @@ var HeaderWithOcticonAnchor = /* @__PURE__ */ __name(({
|
|
|
7587
8424
|
children,
|
|
7588
8425
|
...rest
|
|
7589
8426
|
}) => {
|
|
7590
|
-
const context =
|
|
8427
|
+
const context = useContext7(DocsContext);
|
|
7591
8428
|
const OcticonHeader = OcticonHeaders[as];
|
|
7592
8429
|
const hash = `#${id}`;
|
|
7593
8430
|
return React41.createElement(OcticonHeader, { id, ...rest }, React41.createElement(
|
|
@@ -7598,7 +8435,7 @@ var HeaderWithOcticonAnchor = /* @__PURE__ */ __name(({
|
|
|
7598
8435
|
tabIndex: -1,
|
|
7599
8436
|
target: "_self",
|
|
7600
8437
|
onClick: (event) => {
|
|
7601
|
-
const element =
|
|
8438
|
+
const element = document2.getElementById(id);
|
|
7602
8439
|
if (element) {
|
|
7603
8440
|
navigate(context, hash);
|
|
7604
8441
|
}
|
|
@@ -7726,7 +8563,7 @@ import React53 from "react";
|
|
|
7726
8563
|
// src/blocks/blocks/DocsContainer.tsx
|
|
7727
8564
|
import React44, { useEffect as useEffect15 } from "react";
|
|
7728
8565
|
import { ThemeProvider, ensure as ensureTheme } from "storybook/theming";
|
|
7729
|
-
var { document:
|
|
8566
|
+
var { document: document3, window: globalWindow3 } = globalThis;
|
|
7730
8567
|
var DocsContainer = /* @__PURE__ */ __name(({
|
|
7731
8568
|
context,
|
|
7732
8569
|
theme,
|
|
@@ -7744,7 +8581,7 @@ var DocsContainer = /* @__PURE__ */ __name(({
|
|
|
7744
8581
|
try {
|
|
7745
8582
|
url = new URL(globalWindow3.parent.location.toString());
|
|
7746
8583
|
if (url.hash) {
|
|
7747
|
-
const element =
|
|
8584
|
+
const element = document3.getElementById(decodeURIComponent(url.hash.substring(1)));
|
|
7748
8585
|
if (element) {
|
|
7749
8586
|
setTimeout(() => {
|
|
7750
8587
|
scrollToElement(element);
|
|
@@ -7774,7 +8611,7 @@ var DocsContainer = /* @__PURE__ */ __name(({
|
|
|
7774
8611
|
import React52 from "react";
|
|
7775
8612
|
|
|
7776
8613
|
// src/blocks/blocks/Primary.tsx
|
|
7777
|
-
import React48, { useContext as
|
|
8614
|
+
import React48, { useContext as useContext8 } from "react";
|
|
7778
8615
|
|
|
7779
8616
|
// src/blocks/blocks/DocsStory.tsx
|
|
7780
8617
|
import React47 from "react";
|
|
@@ -7894,13 +8731,13 @@ var Primary = /* @__PURE__ */ __name((props) => {
|
|
|
7894
8731
|
throw new Error("Unexpected `of={undefined}`, did you mistype a CSF file reference?");
|
|
7895
8732
|
}
|
|
7896
8733
|
const { csfFile } = useOf(of || "meta", ["meta"]);
|
|
7897
|
-
const context =
|
|
8734
|
+
const context = useContext8(DocsContext);
|
|
7898
8735
|
const primaryStory = context.componentStoriesFromCSFFile(csfFile)[0];
|
|
7899
8736
|
return primaryStory ? React48.createElement(DocsStory, { of: primaryStory.moduleExport, expanded: false, __primary: true, withToolbar: true }) : null;
|
|
7900
8737
|
}, "Primary");
|
|
7901
8738
|
|
|
7902
8739
|
// src/blocks/blocks/Stories.tsx
|
|
7903
|
-
import React49, { useContext as
|
|
8740
|
+
import React49, { useContext as useContext9 } from "react";
|
|
7904
8741
|
import { styled as styled28 } from "storybook/theming";
|
|
7905
8742
|
var StyledHeading = styled28(Heading2)(({ theme }) => ({
|
|
7906
8743
|
fontSize: `${theme.typography.size.s2 - 1}px`,
|
|
@@ -7917,7 +8754,7 @@ var StyledHeading = styled28(Heading2)(({ theme }) => ({
|
|
|
7917
8754
|
}
|
|
7918
8755
|
}));
|
|
7919
8756
|
var Stories = /* @__PURE__ */ __name(({ title = "Stories", includePrimary = true }) => {
|
|
7920
|
-
const { componentStories, projectAnnotations, getStoryContext } =
|
|
8757
|
+
const { componentStories, projectAnnotations, getStoryContext } = useContext9(DocsContext);
|
|
7921
8758
|
let stories = componentStories();
|
|
7922
8759
|
const { stories: { filter } = { filter: void 0 } } = projectAnnotations.parameters?.docs || {};
|
|
7923
8760
|
if (filter) {
|
|
@@ -8085,7 +8922,8 @@ var _ExternalPreview = class _ExternalPreview extends Preview2 {
|
|
|
8085
8922
|
importPath,
|
|
8086
8923
|
title,
|
|
8087
8924
|
name,
|
|
8088
|
-
type: "story"
|
|
8925
|
+
type: "story",
|
|
8926
|
+
subtype: "story"
|
|
8089
8927
|
};
|
|
8090
8928
|
});
|
|
8091
8929
|
this.onStoriesChanged({ storyIndex: this.storyIndex });
|
|
@@ -8143,9 +8981,9 @@ var ExternalDocsContainer = /* @__PURE__ */ __name(({ projectAnnotations, childr
|
|
|
8143
8981
|
}, "ExternalDocsContainer");
|
|
8144
8982
|
|
|
8145
8983
|
// src/blocks/blocks/Meta.tsx
|
|
8146
|
-
import React56, { useContext as
|
|
8984
|
+
import React56, { useContext as useContext10 } from "react";
|
|
8147
8985
|
var Meta = /* @__PURE__ */ __name(({ of }) => {
|
|
8148
|
-
const context =
|
|
8986
|
+
const context = useContext10(DocsContext);
|
|
8149
8987
|
if (of) {
|
|
8150
8988
|
context.referenceMeta(of, true);
|
|
8151
8989
|
}
|
|
@@ -8225,7 +9063,7 @@ export {
|
|
|
8225
9063
|
format,
|
|
8226
9064
|
formatDate,
|
|
8227
9065
|
formatTime,
|
|
8228
|
-
|
|
9066
|
+
getStoryId,
|
|
8229
9067
|
getStoryProps,
|
|
8230
9068
|
parse2 as parse,
|
|
8231
9069
|
parseDate,
|