@storybook/react-native-ui-lite 10.3.0-next.3 → 10.3.0-next.5
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/index.js +236 -233
- package/package.json +6 -6
- package/src/LegendList.tsx +14 -0
- package/src/SearchResults.tsx +2 -17
- package/src/Tree.tsx +1 -1
package/dist/index.js
CHANGED
|
@@ -424,26 +424,34 @@ StoryNode.displayName = "StoryNode";
|
|
|
424
424
|
// src/Tree.tsx
|
|
425
425
|
var import_react_native_theming3 = require("@storybook/react-native-theming");
|
|
426
426
|
var import_react_native_ui_common = require("@storybook/react-native-ui-common");
|
|
427
|
-
var
|
|
428
|
-
var
|
|
429
|
-
|
|
427
|
+
var import_react5 = __toESM(require("react"));
|
|
428
|
+
var import_react_native4 = require("react-native");
|
|
429
|
+
|
|
430
|
+
// src/LegendList.tsx
|
|
431
|
+
var import_react3 = require("@legendapp/list/react");
|
|
432
|
+
var import_react_native2 = require("@legendapp/list/react-native");
|
|
433
|
+
var import_react_native3 = require("react-native");
|
|
434
|
+
var isWeb = import_react_native3.Platform.OS === "web";
|
|
435
|
+
var LegendList = isWeb ? import_react3.LegendList : import_react_native2.LegendList;
|
|
436
|
+
|
|
437
|
+
// src/Tree.tsx
|
|
430
438
|
var import_react_native_safe_area_context = require("react-native-safe-area-context");
|
|
431
439
|
|
|
432
440
|
// src/SelectedNodeProvider.tsx
|
|
433
|
-
var
|
|
441
|
+
var import_react4 = require("react");
|
|
434
442
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
435
|
-
var SelectedNodeContext = (0,
|
|
443
|
+
var SelectedNodeContext = (0, import_react4.createContext)({
|
|
436
444
|
registerCallback: () => {
|
|
437
445
|
},
|
|
438
446
|
scrollCallback: () => {
|
|
439
447
|
}
|
|
440
448
|
});
|
|
441
449
|
var SelectedNodeProvider = ({ children }) => {
|
|
442
|
-
const [scrollCallbackValue, setScrollCallback] = (0,
|
|
443
|
-
const registerCallback = (0,
|
|
450
|
+
const [scrollCallbackValue, setScrollCallback] = (0, import_react4.useState)(null);
|
|
451
|
+
const registerCallback = (0, import_react4.useCallback)((callback) => {
|
|
444
452
|
setScrollCallback(() => callback);
|
|
445
453
|
}, []);
|
|
446
|
-
const scrollCallback = (0,
|
|
454
|
+
const scrollCallback = (0, import_react4.useCallback)(
|
|
447
455
|
(options) => {
|
|
448
456
|
scrollCallbackValue?.(options);
|
|
449
457
|
},
|
|
@@ -460,11 +468,11 @@ var SelectedNodeProvider = ({ children }) => {
|
|
|
460
468
|
}
|
|
461
469
|
);
|
|
462
470
|
};
|
|
463
|
-
var useSelectedNode = () => (0,
|
|
471
|
+
var useSelectedNode = () => (0, import_react4.useContext)(SelectedNodeContext);
|
|
464
472
|
|
|
465
473
|
// src/Tree.tsx
|
|
466
474
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
467
|
-
var Node =
|
|
475
|
+
var Node = import_react5.default.memo(function Node2({
|
|
468
476
|
item,
|
|
469
477
|
refId,
|
|
470
478
|
isOrphan: _isOrphan,
|
|
@@ -599,12 +607,12 @@ var ROOT_ITEM_HEIGHT = 54;
|
|
|
599
607
|
var getEstimatedItemSize = (item, _index) => {
|
|
600
608
|
return item?.isRoot ? ROOT_ITEM_HEIGHT : ITEM_HEIGHT;
|
|
601
609
|
};
|
|
602
|
-
var Tree =
|
|
610
|
+
var Tree = import_react5.default.memo(function Tree2({ isMain, refId, data, status, docsMode, selectedStoryId, onSelectStoryId }) {
|
|
603
611
|
const { registerCallback } = useSelectedNode();
|
|
604
|
-
const [idToScrolllOnMount, setIdToScrolllOnMount] = (0,
|
|
612
|
+
const [idToScrolllOnMount, setIdToScrolllOnMount] = (0, import_react5.useState)(null);
|
|
605
613
|
const insets = (0, import_react_native_safe_area_context.useSafeAreaInsets)();
|
|
606
|
-
const listRef = (0,
|
|
607
|
-
const [rootIds, orphanIds, initialExpanded] = (0,
|
|
614
|
+
const listRef = (0, import_react5.useRef)(null);
|
|
615
|
+
const [rootIds, orphanIds, initialExpanded] = (0, import_react5.useMemo)(
|
|
608
616
|
() => Object.keys(data).reduce(
|
|
609
617
|
(acc, id) => {
|
|
610
618
|
const item = data[id];
|
|
@@ -617,7 +625,7 @@ var Tree = import_react4.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
617
625
|
),
|
|
618
626
|
[data]
|
|
619
627
|
);
|
|
620
|
-
const { expandableDescendants } = (0,
|
|
628
|
+
const { expandableDescendants } = (0, import_react5.useMemo)(() => {
|
|
621
629
|
return [...orphanIds, ...rootIds].reduce(
|
|
622
630
|
(acc, nodeId) => {
|
|
623
631
|
acc.expandableDescendants[nodeId] = (0, import_react_native_ui_common.getDescendantIds)(data, nodeId, false).filter(
|
|
@@ -628,7 +636,7 @@ var Tree = import_react4.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
628
636
|
{ orphansFirst: [], expandableDescendants: {} }
|
|
629
637
|
);
|
|
630
638
|
}, [data, rootIds, orphanIds]);
|
|
631
|
-
const singleStoryComponentIds = (0,
|
|
639
|
+
const singleStoryComponentIds = (0, import_react5.useMemo)(() => {
|
|
632
640
|
return Object.keys(data).filter((id) => {
|
|
633
641
|
const entry = data[id];
|
|
634
642
|
if (entry.type !== "component") return false;
|
|
@@ -640,11 +648,11 @@ var Tree = import_react4.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
640
648
|
return false;
|
|
641
649
|
});
|
|
642
650
|
}, [data]);
|
|
643
|
-
const collapsedItems = (0,
|
|
651
|
+
const collapsedItems = (0, import_react5.useMemo)(
|
|
644
652
|
() => Object.keys(data).filter((id) => !singleStoryComponentIds.includes(id)),
|
|
645
653
|
[singleStoryComponentIds, data]
|
|
646
654
|
);
|
|
647
|
-
const collapsedData = (0,
|
|
655
|
+
const collapsedData = (0, import_react5.useMemo)(() => {
|
|
648
656
|
return singleStoryComponentIds.reduce(
|
|
649
657
|
(acc, id) => {
|
|
650
658
|
const { children, parent, name } = data[id];
|
|
@@ -673,7 +681,7 @@ var Tree = import_react4.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
673
681
|
selectedStoryId,
|
|
674
682
|
onSelectStoryId
|
|
675
683
|
});
|
|
676
|
-
const parentMap = (0,
|
|
684
|
+
const parentMap = (0, import_react5.useMemo)(() => {
|
|
677
685
|
const map = {};
|
|
678
686
|
collapsedItems.forEach((id) => {
|
|
679
687
|
const item = collapsedData[id];
|
|
@@ -681,7 +689,7 @@ var Tree = import_react4.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
681
689
|
});
|
|
682
690
|
return map;
|
|
683
691
|
}, [collapsedItems, collapsedData]);
|
|
684
|
-
const isItemVisible = (0,
|
|
692
|
+
const isItemVisible = (0, import_react5.useCallback)(
|
|
685
693
|
(itemId) => {
|
|
686
694
|
const item = collapsedData[itemId];
|
|
687
695
|
if (item.type === "root") return true;
|
|
@@ -695,7 +703,7 @@ var Tree = import_react4.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
695
703
|
},
|
|
696
704
|
[collapsedData, expanded, parentMap]
|
|
697
705
|
);
|
|
698
|
-
const treeData = (0,
|
|
706
|
+
const treeData = (0, import_react5.useMemo)(() => {
|
|
699
707
|
return collapsedItems.map((itemId) => {
|
|
700
708
|
const item = collapsedData[itemId];
|
|
701
709
|
if (!isItemVisible(itemId)) {
|
|
@@ -720,7 +728,7 @@ var Tree = import_react4.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
720
728
|
};
|
|
721
729
|
}).filter(Boolean);
|
|
722
730
|
}, [collapsedData, collapsedItems, expandableDescendants, expanded, isItemVisible, orphanIds]);
|
|
723
|
-
const renderItem = (0,
|
|
731
|
+
const renderItem = (0, import_react5.useCallback)(
|
|
724
732
|
({ item: treeItem }) => {
|
|
725
733
|
const { itemId, item, isRoot } = treeItem;
|
|
726
734
|
const id = (0, import_react_native_ui_common.createId)(itemId, refId);
|
|
@@ -765,13 +773,13 @@ var Tree = import_react4.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
765
773
|
},
|
|
766
774
|
[docsMode, expanded, onSelectStoryId, refId, selectedStoryId, setExpanded, status]
|
|
767
775
|
);
|
|
768
|
-
const keyExtractor = (0,
|
|
776
|
+
const keyExtractor = (0, import_react5.useCallback)(
|
|
769
777
|
(item) => {
|
|
770
778
|
return (0, import_react_native_ui_common.createId)(item.itemId, refId);
|
|
771
779
|
},
|
|
772
780
|
[refId]
|
|
773
781
|
);
|
|
774
|
-
const contentContainerStyle2 = (0,
|
|
782
|
+
const contentContainerStyle2 = (0, import_react5.useMemo)(
|
|
775
783
|
() => ({
|
|
776
784
|
marginTop: isMain && orphanIds.length > 0 ? 20 : 0,
|
|
777
785
|
paddingBottom: insets.bottom + 20,
|
|
@@ -779,7 +787,7 @@ var Tree = import_react4.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
779
787
|
}),
|
|
780
788
|
[isMain, orphanIds.length, insets.bottom]
|
|
781
789
|
);
|
|
782
|
-
(0,
|
|
790
|
+
(0, import_react5.useLayoutEffect)(() => {
|
|
783
791
|
registerCallback(({ id: nextId, animated }) => {
|
|
784
792
|
const targetId = nextId ?? selectedStoryId;
|
|
785
793
|
const ancestorIds = (0, import_react_native_ui_common.getAncestorIds)(collapsedData, targetId);
|
|
@@ -787,7 +795,7 @@ var Tree = import_react4.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
787
795
|
setIdToScrolllOnMount(targetId);
|
|
788
796
|
});
|
|
789
797
|
}, [collapsedData, registerCallback, selectedStoryId, setExpanded]);
|
|
790
|
-
(0,
|
|
798
|
+
(0, import_react5.useEffect)(() => {
|
|
791
799
|
if (idToScrolllOnMount) {
|
|
792
800
|
const index = treeData.findIndex((item) => {
|
|
793
801
|
return item.itemId === idToScrolllOnMount;
|
|
@@ -803,8 +811,8 @@ var Tree = import_react4.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
803
811
|
}
|
|
804
812
|
}
|
|
805
813
|
}, [idToScrolllOnMount, treeData]);
|
|
806
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
807
|
-
|
|
814
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native4.View, { style: flexStyle, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
815
|
+
LegendList,
|
|
808
816
|
{
|
|
809
817
|
ref: listRef,
|
|
810
818
|
style: flexStyle,
|
|
@@ -818,13 +826,13 @@ var Tree = import_react4.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
818
826
|
}
|
|
819
827
|
) });
|
|
820
828
|
});
|
|
821
|
-
var Root =
|
|
829
|
+
var Root = import_react5.default.memo(function Root2({
|
|
822
830
|
setExpanded,
|
|
823
831
|
isFullyExpanded,
|
|
824
832
|
expandableDescendants,
|
|
825
833
|
...props
|
|
826
834
|
}) {
|
|
827
|
-
const setFullyExpanded = (0,
|
|
835
|
+
const setFullyExpanded = (0, import_react5.useCallback)(
|
|
828
836
|
() => setExpanded({ ids: expandableDescendants, value: !isFullyExpanded }),
|
|
829
837
|
[setExpanded, isFullyExpanded, expandableDescendants]
|
|
830
838
|
);
|
|
@@ -840,17 +848,17 @@ var Root = import_react4.default.memo(function Root2({
|
|
|
840
848
|
});
|
|
841
849
|
|
|
842
850
|
// src/Explorer.tsx
|
|
843
|
-
var
|
|
851
|
+
var import_react7 = __toESM(require("react"));
|
|
844
852
|
|
|
845
853
|
// src/Refs.tsx
|
|
846
|
-
var
|
|
854
|
+
var import_react6 = __toESM(require("react"));
|
|
847
855
|
var import_react_native_theming4 = require("@storybook/react-native-theming");
|
|
848
856
|
var import_react_native_ui_common2 = require("@storybook/react-native-ui-common");
|
|
849
857
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
850
858
|
var Wrapper2 = import_react_native_theming4.styled.View(() => ({
|
|
851
859
|
flex: 1
|
|
852
860
|
}));
|
|
853
|
-
var Ref =
|
|
861
|
+
var Ref = import_react6.default.memo(
|
|
854
862
|
function Ref2(props) {
|
|
855
863
|
const {
|
|
856
864
|
index,
|
|
@@ -866,20 +874,20 @@ var Ref = import_react5.default.memo(
|
|
|
866
874
|
previewInitialized,
|
|
867
875
|
setSelection
|
|
868
876
|
} = props;
|
|
869
|
-
const length = (0,
|
|
877
|
+
const length = (0, import_react6.useMemo)(() => index ? Object.keys(index).length : 0, [index]);
|
|
870
878
|
const isLoadingInjected = type === "auto-inject" && !previewInitialized || type === "server-checked";
|
|
871
879
|
const isLoading = isLoadingMain || isLoadingInjected || type === "unknown";
|
|
872
880
|
const isError = !!indexError;
|
|
873
881
|
const isEmpty = !isLoading && length === 0;
|
|
874
882
|
const isAuthRequired = !!loginUrl && length === 0;
|
|
875
883
|
const state = (0, import_react_native_ui_common2.getStateType)(isLoading, isAuthRequired, isError, isEmpty);
|
|
876
|
-
const [isExpanded, setExpanded] = (0,
|
|
877
|
-
(0,
|
|
884
|
+
const [isExpanded, setExpanded] = (0, import_react6.useState)(expanded);
|
|
885
|
+
(0, import_react6.useEffect)(() => {
|
|
878
886
|
if (index && selectedStoryId && index[selectedStoryId]) {
|
|
879
887
|
setExpanded(true);
|
|
880
888
|
}
|
|
881
889
|
}, [setExpanded, index, selectedStoryId]);
|
|
882
|
-
const onSelectStoryId = (0,
|
|
890
|
+
const onSelectStoryId = (0, import_react6.useCallback)(
|
|
883
891
|
(storyId) => {
|
|
884
892
|
setSelection({ refId, storyId });
|
|
885
893
|
},
|
|
@@ -902,26 +910,26 @@ var Ref = import_react5.default.memo(
|
|
|
902
910
|
);
|
|
903
911
|
|
|
904
912
|
// src/Explorer.tsx
|
|
905
|
-
var
|
|
913
|
+
var import_react_native5 = require("react-native");
|
|
906
914
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
907
|
-
var
|
|
915
|
+
var import_react8 = require("react");
|
|
908
916
|
var containerStyle = { flex: 1 };
|
|
909
|
-
var Explorer =
|
|
917
|
+
var Explorer = import_react7.default.memo(function Explorer2({
|
|
910
918
|
isLoading,
|
|
911
919
|
isBrowsing,
|
|
912
920
|
dataset,
|
|
913
921
|
selected,
|
|
914
922
|
setSelection
|
|
915
923
|
}) {
|
|
916
|
-
const containerRef = (0,
|
|
924
|
+
const containerRef = (0, import_react7.useRef)(null);
|
|
917
925
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
918
|
-
|
|
926
|
+
import_react_native5.View,
|
|
919
927
|
{
|
|
920
928
|
ref: containerRef,
|
|
921
929
|
style: containerStyle,
|
|
922
930
|
id: "storybook-explorer-tree",
|
|
923
931
|
testID: "storybook-explorer-tree",
|
|
924
|
-
children: dataset.entries.map(([refId, ref]) => /* @__PURE__ */ (0,
|
|
932
|
+
children: dataset.entries.map(([refId, ref]) => /* @__PURE__ */ (0, import_react8.createElement)(
|
|
925
933
|
Ref,
|
|
926
934
|
{
|
|
927
935
|
...ref,
|
|
@@ -939,8 +947,8 @@ var Explorer = import_react6.default.memo(function Explorer2({
|
|
|
939
947
|
// src/Sidebar.tsx
|
|
940
948
|
var import_react_native_theming7 = require("@storybook/react-native-theming");
|
|
941
949
|
var import_react_native_ui_common5 = require("@storybook/react-native-ui-common");
|
|
942
|
-
var
|
|
943
|
-
var
|
|
950
|
+
var import_react12 = __toESM(require("react"));
|
|
951
|
+
var import_react_native8 = require("react-native");
|
|
944
952
|
|
|
945
953
|
// src/constants.ts
|
|
946
954
|
var BREAKPOINT = 1e3;
|
|
@@ -949,9 +957,9 @@ var DEFAULT_REF_ID = "storybook_internal";
|
|
|
949
957
|
|
|
950
958
|
// src/Search.tsx
|
|
951
959
|
var import_react_native_theming5 = require("@storybook/react-native-theming");
|
|
952
|
-
var
|
|
953
|
-
var
|
|
954
|
-
var
|
|
960
|
+
var import_react9 = require("@nozbe/microfuzz/react");
|
|
961
|
+
var import_react10 = __toESM(require("react"));
|
|
962
|
+
var import_react_native6 = require("react-native");
|
|
955
963
|
var import_react_native_ui_common3 = require("@storybook/react-native-ui-common");
|
|
956
964
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
957
965
|
var DEFAULT_MAX_SEARCH_RESULTS = 50;
|
|
@@ -969,7 +977,7 @@ var SearchIconWrapper = import_react_native_theming5.styled.View({
|
|
|
969
977
|
var SearchField = import_react_native_theming5.styled.View({
|
|
970
978
|
flexShrink: 0
|
|
971
979
|
});
|
|
972
|
-
var inputPlatformSpecificStyles =
|
|
980
|
+
var inputPlatformSpecificStyles = import_react_native6.Platform.select({
|
|
973
981
|
macos: {
|
|
974
982
|
paddingVertical: 6
|
|
975
983
|
},
|
|
@@ -981,7 +989,7 @@ var inputPlatformSpecificStyles = import_react_native4.Platform.select({
|
|
|
981
989
|
height: 32
|
|
982
990
|
}
|
|
983
991
|
});
|
|
984
|
-
var Input = (0, import_react_native_theming5.styled)(
|
|
992
|
+
var Input = (0, import_react_native_theming5.styled)(import_react_native6.TextInput)(({ theme }) => ({
|
|
985
993
|
...inputPlatformSpecificStyles,
|
|
986
994
|
paddingLeft: 28,
|
|
987
995
|
paddingRight: 28,
|
|
@@ -1009,14 +1017,14 @@ var ClearIcon = import_react_native_theming5.styled.TouchableOpacity(({ theme })
|
|
|
1009
1017
|
}));
|
|
1010
1018
|
var flexStyle2 = { flex: 1 };
|
|
1011
1019
|
var searchFieldWrapperStyle = { paddingHorizontal: 10, marginBottom: 4 };
|
|
1012
|
-
var Search =
|
|
1020
|
+
var Search = import_react10.default.memo(function Search2({ children, dataset, setSelection, getLastViewed, initialQuery = "" }) {
|
|
1013
1021
|
const theme = (0, import_react_native_theming5.useTheme)();
|
|
1014
|
-
const inputRef = (0,
|
|
1015
|
-
const [inputValue, setInputValue] = (0,
|
|
1016
|
-
const [isOpen, setIsOpen] = (0,
|
|
1017
|
-
const [allComponents, showAllComponents] = (0,
|
|
1022
|
+
const inputRef = (0, import_react10.useRef)(null);
|
|
1023
|
+
const [inputValue, setInputValue] = (0, import_react10.useState)(initialQuery);
|
|
1024
|
+
const [isOpen, setIsOpen] = (0, import_react10.useState)(false);
|
|
1025
|
+
const [allComponents, showAllComponents] = (0, import_react10.useState)(false);
|
|
1018
1026
|
const { scrollCallback } = useSelectedNode();
|
|
1019
|
-
const selectStory = (0,
|
|
1027
|
+
const selectStory = (0, import_react10.useCallback)(
|
|
1020
1028
|
(id, refId) => {
|
|
1021
1029
|
setSelection({ storyId: id, refId });
|
|
1022
1030
|
inputRef.current?.blur();
|
|
@@ -1026,7 +1034,7 @@ var Search = import_react9.default.memo(function Search2({ children, dataset, se
|
|
|
1026
1034
|
},
|
|
1027
1035
|
[scrollCallback, setSelection]
|
|
1028
1036
|
);
|
|
1029
|
-
const getItemProps = (0,
|
|
1037
|
+
const getItemProps = (0, import_react10.useCallback)(
|
|
1030
1038
|
({ item: result }) => {
|
|
1031
1039
|
return {
|
|
1032
1040
|
icon: result?.item?.type === "component" ? "component" : "story",
|
|
@@ -1047,8 +1055,8 @@ var Search = import_react9.default.memo(function Search2({ children, dataset, se
|
|
|
1047
1055
|
},
|
|
1048
1056
|
[selectStory]
|
|
1049
1057
|
);
|
|
1050
|
-
const deferredDataset = (0,
|
|
1051
|
-
const searchList = (0,
|
|
1058
|
+
const deferredDataset = (0, import_react10.useDeferredValue)(dataset);
|
|
1059
|
+
const searchList = (0, import_react10.useMemo)(() => {
|
|
1052
1060
|
return deferredDataset.entries.reduce((acc, [refId, { index }]) => {
|
|
1053
1061
|
if (index) {
|
|
1054
1062
|
acc.push(
|
|
@@ -1060,10 +1068,10 @@ var Search = import_react9.default.memo(function Search2({ children, dataset, se
|
|
|
1060
1068
|
return acc;
|
|
1061
1069
|
}, []);
|
|
1062
1070
|
}, [deferredDataset]);
|
|
1063
|
-
const deferredQuery = (0,
|
|
1064
|
-
const queryText = (0,
|
|
1065
|
-
const getText = (0,
|
|
1066
|
-
const mapResultItem = (0,
|
|
1071
|
+
const deferredQuery = (0, import_react10.useDeferredValue)(inputValue);
|
|
1072
|
+
const queryText = (0, import_react10.useMemo)(() => deferredQuery ? deferredQuery.trim() : "", [deferredQuery]);
|
|
1073
|
+
const getText = (0, import_react10.useCallback)((item) => [item.name, item.path?.join(" ") ?? ""], []);
|
|
1074
|
+
const mapResultItem = (0, import_react10.useCallback)(
|
|
1067
1075
|
({
|
|
1068
1076
|
item,
|
|
1069
1077
|
score,
|
|
@@ -1075,13 +1083,13 @@ var Search = import_react9.default.memo(function Search2({ children, dataset, se
|
|
|
1075
1083
|
}),
|
|
1076
1084
|
[]
|
|
1077
1085
|
);
|
|
1078
|
-
const fuzzyResults = (0,
|
|
1086
|
+
const fuzzyResults = (0, import_react9.useFuzzySearchList)({
|
|
1079
1087
|
list: searchList,
|
|
1080
1088
|
queryText,
|
|
1081
1089
|
getText,
|
|
1082
1090
|
mapResultItem
|
|
1083
1091
|
});
|
|
1084
|
-
const results = (0,
|
|
1092
|
+
const results = (0, import_react10.useMemo)(() => {
|
|
1085
1093
|
if (!queryText) return [];
|
|
1086
1094
|
const maxResults = allComponents ? 1e3 : DEFAULT_MAX_SEARCH_RESULTS;
|
|
1087
1095
|
const processedResults = [];
|
|
@@ -1110,8 +1118,8 @@ var Search = import_react9.default.memo(function Search2({ children, dataset, se
|
|
|
1110
1118
|
}
|
|
1111
1119
|
return processedResults;
|
|
1112
1120
|
}, [queryText, fuzzyResults, allComponents]);
|
|
1113
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1114
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1121
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_native6.View, { style: flexStyle2, children: [
|
|
1122
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native6.View, { style: searchFieldWrapperStyle, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(SearchField, { children: [
|
|
1115
1123
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SearchIconWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SearchIcon, {}) }),
|
|
1116
1124
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1117
1125
|
Input,
|
|
@@ -1135,7 +1143,7 @@ var Search = import_react9.default.memo(function Search2({ children, dataset, se
|
|
|
1135
1143
|
}
|
|
1136
1144
|
)
|
|
1137
1145
|
] }) }),
|
|
1138
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1146
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native6.View, { style: flexStyle2, children: children({
|
|
1139
1147
|
query: queryText,
|
|
1140
1148
|
results,
|
|
1141
1149
|
isBrowsing: !isOpen || !inputValue.length,
|
|
@@ -1148,15 +1156,13 @@ var Search = import_react9.default.memo(function Search2({ children, dataset, se
|
|
|
1148
1156
|
});
|
|
1149
1157
|
|
|
1150
1158
|
// src/SearchResults.tsx
|
|
1151
|
-
var import_list2 = require("@legendapp/list");
|
|
1152
1159
|
var import_react_native_theming6 = require("@storybook/react-native-theming");
|
|
1153
1160
|
var import_react_native_ui_common4 = require("@storybook/react-native-ui-common");
|
|
1154
1161
|
var import_polished2 = require("polished");
|
|
1155
|
-
var
|
|
1156
|
-
var
|
|
1162
|
+
var import_react11 = __toESM(require("react"));
|
|
1163
|
+
var import_react_native7 = require("react-native");
|
|
1157
1164
|
var import_react_native_safe_area_context2 = require("react-native-safe-area-context");
|
|
1158
1165
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1159
|
-
var isWeb = import_react_native5.Platform.OS === "web";
|
|
1160
1166
|
var noResultsFirstLineStyle = { marginBottom: 4 };
|
|
1161
1167
|
var flexStyle3 = { flex: 1 };
|
|
1162
1168
|
var ResultRow = import_react_native_theming6.styled.TouchableOpacity(
|
|
@@ -1224,7 +1230,7 @@ var RecentlyOpenedTitle = import_react_native_theming6.styled.View(({ theme }) =
|
|
|
1224
1230
|
marginBottom: 4,
|
|
1225
1231
|
alignItems: "center"
|
|
1226
1232
|
}));
|
|
1227
|
-
var Highlight =
|
|
1233
|
+
var Highlight = import_react11.default.memo(
|
|
1228
1234
|
function Highlight2({ children, text, ranges }) {
|
|
1229
1235
|
if (!ranges || ranges.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { children: children ?? text });
|
|
1230
1236
|
const { nodes: result } = ranges.reduce(
|
|
@@ -1259,7 +1265,7 @@ var PathText = import_react_native_theming6.styled.Text(({ theme }) => ({
|
|
|
1259
1265
|
fontSize: theme.typography.size.s1 - 1,
|
|
1260
1266
|
color: theme.textMutedColor
|
|
1261
1267
|
}));
|
|
1262
|
-
var Result =
|
|
1268
|
+
var Result = import_react11.default.memo(function Result2({
|
|
1263
1269
|
item,
|
|
1264
1270
|
matches,
|
|
1265
1271
|
icon: _icon,
|
|
@@ -1267,7 +1273,7 @@ var Result = import_react10.default.memo(function Result2({
|
|
|
1267
1273
|
...props
|
|
1268
1274
|
}) {
|
|
1269
1275
|
const theme = (0, import_react_native_theming6.useTheme)();
|
|
1270
|
-
const press = (0,
|
|
1276
|
+
const press = (0, import_react11.useCallback)(
|
|
1271
1277
|
(event) => {
|
|
1272
1278
|
event.preventDefault();
|
|
1273
1279
|
onPress?.(event);
|
|
@@ -1299,7 +1305,7 @@ var Result = import_react10.default.memo(function Result2({
|
|
|
1299
1305
|
var Text = import_react_native_theming6.styled.Text(({ theme }) => ({
|
|
1300
1306
|
color: theme.color.defaultText
|
|
1301
1307
|
}));
|
|
1302
|
-
var SearchResults =
|
|
1308
|
+
var SearchResults = import_react11.default.memo(function SearchResults2({
|
|
1303
1309
|
query,
|
|
1304
1310
|
results,
|
|
1305
1311
|
closeMenu,
|
|
@@ -1308,11 +1314,11 @@ var SearchResults = import_react10.default.memo(function SearchResults2({
|
|
|
1308
1314
|
clearLastViewed
|
|
1309
1315
|
}) {
|
|
1310
1316
|
const insets = (0, import_react_native_safe_area_context2.useSafeAreaInsets)();
|
|
1311
|
-
const handleClearLastViewed = (0,
|
|
1317
|
+
const handleClearLastViewed = (0, import_react11.useCallback)(() => {
|
|
1312
1318
|
clearLastViewed();
|
|
1313
1319
|
closeMenu();
|
|
1314
1320
|
}, [clearLastViewed, closeMenu]);
|
|
1315
|
-
const contentContainerStyle2 = (0,
|
|
1321
|
+
const contentContainerStyle2 = (0, import_react11.useMemo)(
|
|
1316
1322
|
() => ({
|
|
1317
1323
|
paddingHorizontal: 10,
|
|
1318
1324
|
paddingTop: 8,
|
|
@@ -1320,7 +1326,7 @@ var SearchResults = import_react10.default.memo(function SearchResults2({
|
|
|
1320
1326
|
}),
|
|
1321
1327
|
[insets.bottom]
|
|
1322
1328
|
);
|
|
1323
|
-
const listData = (0,
|
|
1329
|
+
const listData = (0, import_react11.useMemo)(() => {
|
|
1324
1330
|
const items = [];
|
|
1325
1331
|
if (results.length > 0 && !query) {
|
|
1326
1332
|
items.push({ type: "header", clearLastViewed: handleClearLastViewed });
|
|
@@ -1337,7 +1343,7 @@ var SearchResults = import_react10.default.memo(function SearchResults2({
|
|
|
1337
1343
|
});
|
|
1338
1344
|
return items;
|
|
1339
1345
|
}, [results, query, handleClearLastViewed]);
|
|
1340
|
-
const keyExtractor = (0,
|
|
1346
|
+
const keyExtractor = (0, import_react11.useCallback)((item) => {
|
|
1341
1347
|
switch (item.type) {
|
|
1342
1348
|
case "header":
|
|
1343
1349
|
return "header";
|
|
@@ -1351,7 +1357,7 @@ var SearchResults = import_react10.default.memo(function SearchResults2({
|
|
|
1351
1357
|
}
|
|
1352
1358
|
}
|
|
1353
1359
|
}, []);
|
|
1354
|
-
const renderItem = (0,
|
|
1360
|
+
const renderItem = (0, import_react11.useCallback)(
|
|
1355
1361
|
({ item: listItem }) => {
|
|
1356
1362
|
switch (listItem.type) {
|
|
1357
1363
|
case "header":
|
|
@@ -1401,11 +1407,8 @@ var SearchResults = import_react10.default.memo(function SearchResults2({
|
|
|
1401
1407
|
},
|
|
1402
1408
|
[getItemProps, highlightedIndex]
|
|
1403
1409
|
);
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
}
|
|
1407
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native5.View, { style: flexStyle3, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1408
|
-
import_list2.LegendList,
|
|
1410
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native7.View, { style: flexStyle3, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1411
|
+
LegendList,
|
|
1409
1412
|
{
|
|
1410
1413
|
style: flexStyle3,
|
|
1411
1414
|
data: listData,
|
|
@@ -1437,16 +1440,16 @@ var noneStyle = {
|
|
|
1437
1440
|
width: 0,
|
|
1438
1441
|
opacity: 0
|
|
1439
1442
|
};
|
|
1440
|
-
var Swap =
|
|
1443
|
+
var Swap = import_react12.default.memo(function Swap2({
|
|
1441
1444
|
children,
|
|
1442
1445
|
condition
|
|
1443
1446
|
}) {
|
|
1444
|
-
const [a, b] =
|
|
1445
|
-
const aStyle = (0,
|
|
1446
|
-
const bStyle = (0,
|
|
1447
|
+
const [a, b] = import_react12.default.Children.toArray(children);
|
|
1448
|
+
const aStyle = (0, import_react12.useMemo)(() => condition ? flexStyle4 : noneStyle, [condition]);
|
|
1449
|
+
const bStyle = (0, import_react12.useMemo)(() => condition ? noneStyle : flexStyle4, [condition]);
|
|
1447
1450
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
1448
1451
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1449
|
-
|
|
1452
|
+
import_react_native8.View,
|
|
1450
1453
|
{
|
|
1451
1454
|
style: aStyle,
|
|
1452
1455
|
accessibilityElementsHidden: !condition,
|
|
@@ -1455,7 +1458,7 @@ var Swap = import_react11.default.memo(function Swap2({
|
|
|
1455
1458
|
}
|
|
1456
1459
|
),
|
|
1457
1460
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1458
|
-
|
|
1461
|
+
import_react_native8.View,
|
|
1459
1462
|
{
|
|
1460
1463
|
style: bStyle,
|
|
1461
1464
|
accessibilityElementsHidden: condition,
|
|
@@ -1466,7 +1469,7 @@ var Swap = import_react11.default.memo(function Swap2({
|
|
|
1466
1469
|
] });
|
|
1467
1470
|
});
|
|
1468
1471
|
var useCombination = (index, indexError, previewInitialized, status, refs) => {
|
|
1469
|
-
const hash = (0,
|
|
1472
|
+
const hash = (0, import_react12.useMemo)(
|
|
1470
1473
|
() => ({
|
|
1471
1474
|
[DEFAULT_REF_ID]: {
|
|
1472
1475
|
index,
|
|
@@ -1481,9 +1484,9 @@ var useCombination = (index, indexError, previewInitialized, status, refs) => {
|
|
|
1481
1484
|
}),
|
|
1482
1485
|
[refs, index, indexError, previewInitialized, status]
|
|
1483
1486
|
);
|
|
1484
|
-
return (0,
|
|
1487
|
+
return (0, import_react12.useMemo)(() => ({ hash, entries: Object.entries(hash) }), [hash]);
|
|
1485
1488
|
};
|
|
1486
|
-
var Sidebar =
|
|
1489
|
+
var Sidebar = import_react12.default.memo(function Sidebar2({
|
|
1487
1490
|
storyId = null,
|
|
1488
1491
|
refId = DEFAULT_REF_ID,
|
|
1489
1492
|
index,
|
|
@@ -1493,7 +1496,7 @@ var Sidebar = import_react11.default.memo(function Sidebar2({
|
|
|
1493
1496
|
refs = {},
|
|
1494
1497
|
setSelection
|
|
1495
1498
|
}) {
|
|
1496
|
-
const selected = (0,
|
|
1499
|
+
const selected = (0, import_react12.useMemo)(() => storyId && { storyId, refId }, [storyId, refId]);
|
|
1497
1500
|
const dataset = useCombination(index, indexError, previewInitialized, status, refs);
|
|
1498
1501
|
const lastViewedProps = (0, import_react_native_ui_common5.useLastViewed)(selected);
|
|
1499
1502
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Container, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Top, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Search, { dataset, setSelection, ...lastViewedProps, children: ({ query, results, isBrowsing, closeMenu, getItemProps, highlightedIndex }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Swap, { condition: isBrowsing, children: [
|
|
@@ -1526,8 +1529,8 @@ var Sidebar = import_react11.default.memo(function Sidebar2({
|
|
|
1526
1529
|
var import_portal2 = require("@gorhom/portal");
|
|
1527
1530
|
var import_react_native_theming11 = require("@storybook/react-native-theming");
|
|
1528
1531
|
var import_react_native_ui_common7 = require("@storybook/react-native-ui-common");
|
|
1529
|
-
var
|
|
1530
|
-
var
|
|
1532
|
+
var import_react18 = require("react");
|
|
1533
|
+
var import_react_native14 = require("react-native");
|
|
1531
1534
|
var import_react_native_safe_area_context4 = require("react-native-safe-area-context");
|
|
1532
1535
|
var import_core_events = require("storybook/internal/core-events");
|
|
1533
1536
|
var import_manager_api2 = require("storybook/manager-api");
|
|
@@ -1535,18 +1538,18 @@ var import_manager_api2 = require("storybook/manager-api");
|
|
|
1535
1538
|
// src/MobileAddonsPanel.tsx
|
|
1536
1539
|
var import_react_native_theming8 = require("@storybook/react-native-theming");
|
|
1537
1540
|
var import_react_native_ui_common6 = require("@storybook/react-native-ui-common");
|
|
1538
|
-
var
|
|
1539
|
-
var
|
|
1541
|
+
var import_react14 = require("react");
|
|
1542
|
+
var import_react_native10 = require("react-native");
|
|
1540
1543
|
var import_manager_api = require("storybook/manager-api");
|
|
1541
1544
|
var import_types = require("storybook/internal/types");
|
|
1542
1545
|
|
|
1543
1546
|
// src/useAnimatedValue.ts
|
|
1544
|
-
var
|
|
1545
|
-
var
|
|
1547
|
+
var import_react13 = require("react");
|
|
1548
|
+
var import_react_native9 = require("react-native");
|
|
1546
1549
|
function useAnimatedValue(initialValue, config) {
|
|
1547
|
-
const ref = (0,
|
|
1550
|
+
const ref = (0, import_react13.useRef)(null);
|
|
1548
1551
|
if (ref.current == null) {
|
|
1549
|
-
ref.current = new
|
|
1552
|
+
ref.current = new import_react_native9.Animated.Value(initialValue, config);
|
|
1550
1553
|
}
|
|
1551
1554
|
return ref.current;
|
|
1552
1555
|
}
|
|
@@ -1554,94 +1557,94 @@ function useAnimatedValue(initialValue, config) {
|
|
|
1554
1557
|
// src/MobileAddonsPanel.tsx
|
|
1555
1558
|
var import_react_native_safe_area_context3 = require("react-native-safe-area-context");
|
|
1556
1559
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1557
|
-
var MobileAddonsPanel = (0,
|
|
1560
|
+
var MobileAddonsPanel = (0, import_react14.forwardRef)(
|
|
1558
1561
|
({ storyId }, ref) => {
|
|
1559
1562
|
const theme = (0, import_react_native_theming8.useTheme)();
|
|
1560
|
-
const { height } = (0,
|
|
1563
|
+
const { height } = (0, import_react_native10.useWindowDimensions)();
|
|
1561
1564
|
const panelHeight = useAnimatedValue(0);
|
|
1562
1565
|
const positionBottomAnimation = useAnimatedValue(height / 2);
|
|
1563
|
-
const [isOpen, setIsOpen] = (0,
|
|
1564
|
-
const setMobileMenuOpen = (0,
|
|
1566
|
+
const [isOpen, setIsOpen] = (0, import_react14.useState)(false);
|
|
1567
|
+
const setMobileMenuOpen = (0, import_react14.useCallback)(
|
|
1565
1568
|
(open) => {
|
|
1566
1569
|
setIsOpen(open);
|
|
1567
1570
|
if (open) {
|
|
1568
|
-
|
|
1569
|
-
|
|
1571
|
+
import_react_native10.Animated.parallel([
|
|
1572
|
+
import_react_native10.Animated.timing(positionBottomAnimation, {
|
|
1570
1573
|
toValue: 0,
|
|
1571
1574
|
// Negative to move up
|
|
1572
1575
|
duration: 350,
|
|
1573
1576
|
useNativeDriver: false,
|
|
1574
|
-
easing:
|
|
1577
|
+
easing: import_react_native10.Easing.inOut(import_react_native10.Easing.cubic)
|
|
1575
1578
|
}),
|
|
1576
|
-
|
|
1579
|
+
import_react_native10.Animated.timing(panelHeight, {
|
|
1577
1580
|
toValue: height / 2,
|
|
1578
1581
|
duration: 350,
|
|
1579
1582
|
useNativeDriver: false,
|
|
1580
|
-
easing:
|
|
1583
|
+
easing: import_react_native10.Easing.inOut(import_react_native10.Easing.cubic)
|
|
1581
1584
|
})
|
|
1582
1585
|
]).start();
|
|
1583
1586
|
} else {
|
|
1584
|
-
|
|
1585
|
-
|
|
1587
|
+
import_react_native10.Animated.parallel([
|
|
1588
|
+
import_react_native10.Animated.timing(positionBottomAnimation, {
|
|
1586
1589
|
toValue: height / 2,
|
|
1587
1590
|
duration: 350,
|
|
1588
1591
|
useNativeDriver: false,
|
|
1589
|
-
easing:
|
|
1592
|
+
easing: import_react_native10.Easing.inOut(import_react_native10.Easing.cubic)
|
|
1590
1593
|
}),
|
|
1591
|
-
|
|
1594
|
+
import_react_native10.Animated.timing(panelHeight, {
|
|
1592
1595
|
toValue: 0,
|
|
1593
1596
|
duration: 350,
|
|
1594
1597
|
useNativeDriver: false,
|
|
1595
|
-
easing:
|
|
1598
|
+
easing: import_react_native10.Easing.inOut(import_react_native10.Easing.cubic)
|
|
1596
1599
|
})
|
|
1597
1600
|
]).start();
|
|
1598
1601
|
}
|
|
1599
1602
|
},
|
|
1600
1603
|
[height, positionBottomAnimation, panelHeight]
|
|
1601
1604
|
);
|
|
1602
|
-
(0,
|
|
1605
|
+
(0, import_react14.useEffect)(() => {
|
|
1603
1606
|
const handleKeyboardShow = ({ endCoordinates, duration, easing }) => {
|
|
1604
1607
|
if (isOpen) {
|
|
1605
|
-
|
|
1606
|
-
|
|
1608
|
+
import_react_native10.Animated.parallel([
|
|
1609
|
+
import_react_native10.Animated.timing(panelHeight, {
|
|
1607
1610
|
toValue: (height - endCoordinates.height) / 2,
|
|
1608
1611
|
duration,
|
|
1609
1612
|
useNativeDriver: false,
|
|
1610
|
-
easing:
|
|
1613
|
+
easing: import_react_native10.Easing[easing] || import_react_native10.Easing.out(import_react_native10.Easing.ease)
|
|
1611
1614
|
}),
|
|
1612
|
-
|
|
1615
|
+
import_react_native10.Animated.timing(positionBottomAnimation, {
|
|
1613
1616
|
toValue: -endCoordinates.height,
|
|
1614
1617
|
// Negative to move up
|
|
1615
1618
|
duration,
|
|
1616
1619
|
useNativeDriver: false,
|
|
1617
|
-
easing:
|
|
1620
|
+
easing: import_react_native10.Easing[easing] || import_react_native10.Easing.out(import_react_native10.Easing.ease)
|
|
1618
1621
|
})
|
|
1619
1622
|
]).start();
|
|
1620
1623
|
}
|
|
1621
1624
|
};
|
|
1622
1625
|
const handleKeyboardHide = ({ duration, easing }) => {
|
|
1623
1626
|
if (isOpen) {
|
|
1624
|
-
|
|
1625
|
-
|
|
1627
|
+
import_react_native10.Animated.parallel([
|
|
1628
|
+
import_react_native10.Animated.timing(positionBottomAnimation, {
|
|
1626
1629
|
toValue: 0,
|
|
1627
1630
|
// Back to original position
|
|
1628
1631
|
duration,
|
|
1629
1632
|
useNativeDriver: false,
|
|
1630
|
-
easing:
|
|
1633
|
+
easing: import_react_native10.Easing[easing] || import_react_native10.Easing.out(import_react_native10.Easing.ease)
|
|
1631
1634
|
}),
|
|
1632
|
-
|
|
1635
|
+
import_react_native10.Animated.timing(panelHeight, {
|
|
1633
1636
|
toValue: height / 2,
|
|
1634
1637
|
duration,
|
|
1635
1638
|
useNativeDriver: false,
|
|
1636
|
-
easing:
|
|
1639
|
+
easing: import_react_native10.Easing[easing] || import_react_native10.Easing.out(import_react_native10.Easing.ease)
|
|
1637
1640
|
})
|
|
1638
1641
|
]).start();
|
|
1639
1642
|
}
|
|
1640
1643
|
};
|
|
1641
|
-
const showSubscription =
|
|
1642
|
-
const willShowSubscription =
|
|
1643
|
-
const hideSubscription =
|
|
1644
|
-
const didHideSubscription =
|
|
1644
|
+
const showSubscription = import_react_native10.Keyboard.addListener("keyboardDidShow", handleKeyboardShow);
|
|
1645
|
+
const willShowSubscription = import_react_native10.Keyboard.addListener("keyboardWillShow", handleKeyboardShow);
|
|
1646
|
+
const hideSubscription = import_react_native10.Keyboard.addListener("keyboardWillHide", handleKeyboardHide);
|
|
1647
|
+
const didHideSubscription = import_react_native10.Keyboard.addListener("keyboardDidHide", handleKeyboardHide);
|
|
1645
1648
|
return () => {
|
|
1646
1649
|
showSubscription.remove();
|
|
1647
1650
|
willShowSubscription.remove();
|
|
@@ -1649,7 +1652,7 @@ var MobileAddonsPanel = (0, import_react13.forwardRef)(
|
|
|
1649
1652
|
didHideSubscription.remove();
|
|
1650
1653
|
};
|
|
1651
1654
|
}, [height, panelHeight, positionBottomAnimation, isOpen]);
|
|
1652
|
-
(0,
|
|
1655
|
+
(0, import_react14.useImperativeHandle)(ref, () => ({
|
|
1653
1656
|
setAddonsPanelOpen: (open) => {
|
|
1654
1657
|
if (open) {
|
|
1655
1658
|
setMobileMenuOpen(true);
|
|
@@ -1659,7 +1662,7 @@ var MobileAddonsPanel = (0, import_react13.forwardRef)(
|
|
|
1659
1662
|
}
|
|
1660
1663
|
}));
|
|
1661
1664
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1662
|
-
|
|
1665
|
+
import_react_native10.Animated.View,
|
|
1663
1666
|
{
|
|
1664
1667
|
style: {
|
|
1665
1668
|
position: "absolute",
|
|
@@ -1673,14 +1676,14 @@ var MobileAddonsPanel = (0, import_react13.forwardRef)(
|
|
|
1673
1676
|
accessibilityElementsHidden: !isOpen,
|
|
1674
1677
|
importantForAccessibility: isOpen ? "auto" : "no-hide-descendants",
|
|
1675
1678
|
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1676
|
-
|
|
1679
|
+
import_react_native10.View,
|
|
1677
1680
|
{
|
|
1678
1681
|
style: {
|
|
1679
1682
|
flex: 1,
|
|
1680
1683
|
justifyContent: "flex-end"
|
|
1681
1684
|
},
|
|
1682
1685
|
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1683
|
-
|
|
1686
|
+
import_react_native10.View,
|
|
1684
1687
|
{
|
|
1685
1688
|
style: {
|
|
1686
1689
|
height: "100%",
|
|
@@ -1688,14 +1691,14 @@ var MobileAddonsPanel = (0, import_react13.forwardRef)(
|
|
|
1688
1691
|
paddingTop: 10,
|
|
1689
1692
|
borderTopColor: theme.appBorderColor,
|
|
1690
1693
|
borderTopWidth: 1,
|
|
1691
|
-
paddingBottom:
|
|
1694
|
+
paddingBottom: import_react_native10.Platform.OS === "android" ? 16 : 0
|
|
1692
1695
|
},
|
|
1693
1696
|
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1694
1697
|
AddonsTabs,
|
|
1695
1698
|
{
|
|
1696
1699
|
onClose: () => {
|
|
1697
1700
|
setMobileMenuOpen(false);
|
|
1698
|
-
|
|
1701
|
+
import_react_native10.Keyboard.dismiss();
|
|
1699
1702
|
},
|
|
1700
1703
|
storyId
|
|
1701
1704
|
}
|
|
@@ -1740,18 +1743,18 @@ var hitSlop = { top: 10, right: 10, bottom: 10, left: 10 };
|
|
|
1740
1743
|
var AddonsTabs = ({ onClose, storyId }) => {
|
|
1741
1744
|
const panels = import_manager_api.addons.getElements(import_types.Addon_TypesEnum.PANEL);
|
|
1742
1745
|
const insets = (0, import_react_native_safe_area_context3.useSafeAreaInsets)();
|
|
1743
|
-
const [addonSelected, setAddonSelected] = (0,
|
|
1744
|
-
const panelEntries = (0,
|
|
1746
|
+
const [addonSelected, setAddonSelected] = (0, import_react14.useState)(Object.keys(panels)[0]);
|
|
1747
|
+
const panelEntries = (0, import_react14.useMemo)(() => Object.entries(panels), [panels]);
|
|
1745
1748
|
const scrollContentContainerStyle = (0, import_react_native_ui_common6.useStyle)(
|
|
1746
1749
|
() => ({
|
|
1747
1750
|
paddingBottom: insets.bottom + 16
|
|
1748
1751
|
}),
|
|
1749
1752
|
[insets]
|
|
1750
1753
|
);
|
|
1751
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1752
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1754
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_native10.View, { style: addonsTabsContainerStyle, children: [
|
|
1755
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_native10.View, { style: addonsTabsStyle, children: [
|
|
1753
1756
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1754
|
-
|
|
1757
|
+
import_react_native10.ScrollView,
|
|
1755
1758
|
{
|
|
1756
1759
|
horizontal: true,
|
|
1757
1760
|
showsHorizontalScrollIndicator: false,
|
|
@@ -1783,11 +1786,11 @@ var AddonsTabs = ({ onClose, storyId }) => {
|
|
|
1783
1786
|
)
|
|
1784
1787
|
] }),
|
|
1785
1788
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1786
|
-
|
|
1789
|
+
import_react_native10.ScrollView,
|
|
1787
1790
|
{
|
|
1788
1791
|
style: addonsScrollStyle,
|
|
1789
1792
|
contentContainerStyle: scrollContentContainerStyle,
|
|
1790
|
-
children: !storyId ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1793
|
+
children: !storyId ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native10.View, { style: centeredStyle, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native10.Text, { children: "No Story Selected" }) }) : panelEntries.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native10.View, { style: centeredStyle, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native10.Text, { children: "No addons loaded." }) }) : panelEntries.map(([id, p]) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native10.View, { style: id === addonSelected ? void 0 : hiddenStyle, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PanelRenderer, { panel: p }) }, id))
|
|
1791
1794
|
},
|
|
1792
1795
|
`addons-scroll-${storyId}`
|
|
1793
1796
|
)
|
|
@@ -1827,8 +1830,8 @@ var TabText = import_react_native_theming8.styled.Text(({ theme, active }) => ({
|
|
|
1827
1830
|
// src/MobileMenuDrawer.tsx
|
|
1828
1831
|
var import_portal = require("@gorhom/portal");
|
|
1829
1832
|
var import_react_native_theming9 = require("@storybook/react-native-theming");
|
|
1830
|
-
var
|
|
1831
|
-
var
|
|
1833
|
+
var import_react15 = require("react");
|
|
1834
|
+
var import_react_native11 = require("react-native");
|
|
1832
1835
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1833
1836
|
var flexStyle5 = { flex: 1 };
|
|
1834
1837
|
var portalContainerStyle = {
|
|
@@ -1841,48 +1844,48 @@ var portalContainerStyle = {
|
|
|
1841
1844
|
zIndex: 1e3
|
|
1842
1845
|
};
|
|
1843
1846
|
var useAnimatedModalHeight = () => {
|
|
1844
|
-
const { height } = (0,
|
|
1847
|
+
const { height } = (0, import_react_native11.useWindowDimensions)();
|
|
1845
1848
|
const animatedHeight = useAnimatedValue(0.65 * height);
|
|
1846
|
-
(0,
|
|
1849
|
+
(0, import_react15.useEffect)(() => {
|
|
1847
1850
|
const modalHeight = 0.65 * height;
|
|
1848
1851
|
const maxModalHeight = 0.85 * height;
|
|
1849
|
-
const expand = (duration = 250) =>
|
|
1852
|
+
const expand = (duration = 250) => import_react_native11.Animated.timing(animatedHeight, {
|
|
1850
1853
|
toValue: maxModalHeight,
|
|
1851
1854
|
duration,
|
|
1852
|
-
easing:
|
|
1855
|
+
easing: import_react_native11.Easing.out(import_react_native11.Easing.quad),
|
|
1853
1856
|
useNativeDriver: false
|
|
1854
1857
|
}).start();
|
|
1855
|
-
const collapse = (duration = 250) =>
|
|
1858
|
+
const collapse = (duration = 250) => import_react_native11.Animated.timing(animatedHeight, {
|
|
1856
1859
|
toValue: modalHeight,
|
|
1857
1860
|
duration,
|
|
1858
|
-
easing:
|
|
1861
|
+
easing: import_react_native11.Easing.out(import_react_native11.Easing.quad),
|
|
1859
1862
|
useNativeDriver: false
|
|
1860
1863
|
}).start();
|
|
1861
1864
|
const handleKeyboardWillShow = (e) => {
|
|
1862
|
-
if (
|
|
1865
|
+
if (import_react_native11.Platform.OS === "ios") {
|
|
1863
1866
|
expand(e.duration);
|
|
1864
1867
|
}
|
|
1865
1868
|
};
|
|
1866
1869
|
const handleKeyboardDidShow = (e) => {
|
|
1867
|
-
if (
|
|
1870
|
+
if (import_react_native11.Platform.OS === "android") {
|
|
1868
1871
|
expand();
|
|
1869
1872
|
}
|
|
1870
1873
|
};
|
|
1871
1874
|
const handleKeyboardWillHide = (e) => {
|
|
1872
|
-
if (
|
|
1875
|
+
if (import_react_native11.Platform.OS === "ios") {
|
|
1873
1876
|
collapse(e.duration);
|
|
1874
1877
|
}
|
|
1875
1878
|
};
|
|
1876
1879
|
const handleKeyboardDidHide = (e) => {
|
|
1877
|
-
if (
|
|
1880
|
+
if (import_react_native11.Platform.OS === "android") {
|
|
1878
1881
|
collapse();
|
|
1879
1882
|
}
|
|
1880
1883
|
};
|
|
1881
1884
|
const subscriptions = [
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1885
|
+
import_react_native11.Keyboard.addListener("keyboardWillShow", handleKeyboardWillShow),
|
|
1886
|
+
import_react_native11.Keyboard.addListener("keyboardDidShow", handleKeyboardDidShow),
|
|
1887
|
+
import_react_native11.Keyboard.addListener("keyboardWillHide", handleKeyboardWillHide),
|
|
1888
|
+
import_react_native11.Keyboard.addListener("keyboardDidHide", handleKeyboardDidHide)
|
|
1886
1889
|
];
|
|
1887
1890
|
return () => {
|
|
1888
1891
|
subscriptions.forEach((subscription) => subscription.remove());
|
|
@@ -1890,25 +1893,25 @@ var useAnimatedModalHeight = () => {
|
|
|
1890
1893
|
}, [animatedHeight, height]);
|
|
1891
1894
|
return animatedHeight;
|
|
1892
1895
|
};
|
|
1893
|
-
var MobileMenuDrawer = (0,
|
|
1894
|
-
(0,
|
|
1896
|
+
var MobileMenuDrawer = (0, import_react15.memo)(
|
|
1897
|
+
(0, import_react15.forwardRef)(
|
|
1895
1898
|
({ children, onVisibilityChange }, ref) => {
|
|
1896
|
-
const [isVisible, setIsVisible] = (0,
|
|
1899
|
+
const [isVisible, setIsVisible] = (0, import_react15.useState)(false);
|
|
1897
1900
|
const { scrollCallback } = useSelectedNode();
|
|
1898
1901
|
const theme = (0, import_react_native_theming9.useTheme)();
|
|
1899
|
-
const { height } = (0,
|
|
1902
|
+
const { height } = (0, import_react_native11.useWindowDimensions)();
|
|
1900
1903
|
const animatedHeight = useAnimatedModalHeight();
|
|
1901
1904
|
const slideAnim = useAnimatedValue(height);
|
|
1902
1905
|
const dragY = useAnimatedValue(0);
|
|
1903
|
-
const openDrawer = (0,
|
|
1906
|
+
const openDrawer = (0, import_react15.useCallback)(() => {
|
|
1904
1907
|
dragY.setValue(0);
|
|
1905
1908
|
slideAnim.setValue(height);
|
|
1906
1909
|
setIsVisible(true);
|
|
1907
1910
|
onVisibilityChange?.(true);
|
|
1908
|
-
|
|
1911
|
+
import_react_native11.Animated.timing(slideAnim, {
|
|
1909
1912
|
toValue: 0,
|
|
1910
1913
|
duration: 300,
|
|
1911
|
-
easing:
|
|
1914
|
+
easing: import_react_native11.Easing.out(import_react_native11.Easing.quad),
|
|
1912
1915
|
useNativeDriver: true
|
|
1913
1916
|
}).start(({ finished }) => {
|
|
1914
1917
|
if (finished) {
|
|
@@ -1916,13 +1919,13 @@ var MobileMenuDrawer = (0, import_react14.memo)(
|
|
|
1916
1919
|
}
|
|
1917
1920
|
});
|
|
1918
1921
|
}, [dragY, height, onVisibilityChange, scrollCallback, slideAnim]);
|
|
1919
|
-
const closeDrawer = (0,
|
|
1920
|
-
|
|
1922
|
+
const closeDrawer = (0, import_react15.useCallback)(() => {
|
|
1923
|
+
import_react_native11.Keyboard.dismiss();
|
|
1921
1924
|
onVisibilityChange?.(false);
|
|
1922
|
-
|
|
1925
|
+
import_react_native11.Animated.timing(slideAnim, {
|
|
1923
1926
|
toValue: height,
|
|
1924
1927
|
duration: 300,
|
|
1925
|
-
easing:
|
|
1928
|
+
easing: import_react_native11.Easing.in(import_react_native11.Easing.quad),
|
|
1926
1929
|
useNativeDriver: true
|
|
1927
1930
|
}).start(({ finished }) => {
|
|
1928
1931
|
if (finished) {
|
|
@@ -1930,8 +1933,8 @@ var MobileMenuDrawer = (0, import_react14.memo)(
|
|
|
1930
1933
|
}
|
|
1931
1934
|
});
|
|
1932
1935
|
}, [height, onVisibilityChange, slideAnim]);
|
|
1933
|
-
const panResponder = (0,
|
|
1934
|
-
() =>
|
|
1936
|
+
const panResponder = (0, import_react15.useMemo)(
|
|
1937
|
+
() => import_react_native11.PanResponder.create({
|
|
1935
1938
|
onStartShouldSetPanResponder: () => true,
|
|
1936
1939
|
onMoveShouldSetPanResponder: (_, gestureState) => {
|
|
1937
1940
|
return gestureState.dy > 0;
|
|
@@ -1945,10 +1948,10 @@ var MobileMenuDrawer = (0, import_react14.memo)(
|
|
|
1945
1948
|
if (gestureState.dy > 50) {
|
|
1946
1949
|
closeDrawer();
|
|
1947
1950
|
} else {
|
|
1948
|
-
|
|
1951
|
+
import_react_native11.Animated.timing(dragY, {
|
|
1949
1952
|
toValue: 0,
|
|
1950
1953
|
duration: 300,
|
|
1951
|
-
easing:
|
|
1954
|
+
easing: import_react_native11.Easing.out(import_react_native11.Easing.quad),
|
|
1952
1955
|
useNativeDriver: true
|
|
1953
1956
|
}).start();
|
|
1954
1957
|
}
|
|
@@ -1956,7 +1959,7 @@ var MobileMenuDrawer = (0, import_react14.memo)(
|
|
|
1956
1959
|
}),
|
|
1957
1960
|
[closeDrawer, dragY]
|
|
1958
1961
|
);
|
|
1959
|
-
(0,
|
|
1962
|
+
(0, import_react15.useImperativeHandle)(ref, () => ({
|
|
1960
1963
|
setMobileMenuOpen: (open) => {
|
|
1961
1964
|
if (open) {
|
|
1962
1965
|
openDrawer();
|
|
@@ -1965,7 +1968,7 @@ var MobileMenuDrawer = (0, import_react14.memo)(
|
|
|
1965
1968
|
}
|
|
1966
1969
|
}
|
|
1967
1970
|
}));
|
|
1968
|
-
const handleStyle = (0,
|
|
1971
|
+
const handleStyle = (0, import_react15.useMemo)(
|
|
1969
1972
|
() => ({
|
|
1970
1973
|
width: 40,
|
|
1971
1974
|
height: 5,
|
|
@@ -1975,7 +1978,7 @@ var MobileMenuDrawer = (0, import_react14.memo)(
|
|
|
1975
1978
|
}),
|
|
1976
1979
|
[theme.color.mediumdark]
|
|
1977
1980
|
);
|
|
1978
|
-
const drawerContainerStyle = (0,
|
|
1981
|
+
const drawerContainerStyle = (0, import_react15.useMemo)(
|
|
1979
1982
|
() => ({
|
|
1980
1983
|
flex: 1,
|
|
1981
1984
|
borderTopColor: theme.appBorderColor,
|
|
@@ -1987,7 +1990,7 @@ var MobileMenuDrawer = (0, import_react14.memo)(
|
|
|
1987
1990
|
}),
|
|
1988
1991
|
[theme.appBorderColor, theme.background.content, theme.color.border]
|
|
1989
1992
|
);
|
|
1990
|
-
const dragHandleWrapperStyle = (0,
|
|
1993
|
+
const dragHandleWrapperStyle = (0, import_react15.useMemo)(
|
|
1991
1994
|
() => ({
|
|
1992
1995
|
alignItems: "center",
|
|
1993
1996
|
justifyContent: "center",
|
|
@@ -1997,7 +2000,7 @@ var MobileMenuDrawer = (0, import_react14.memo)(
|
|
|
1997
2000
|
}),
|
|
1998
2001
|
[theme.background.content]
|
|
1999
2002
|
);
|
|
2000
|
-
const childrenWrapperStyle = (0,
|
|
2003
|
+
const childrenWrapperStyle = (0, import_react15.useMemo)(
|
|
2001
2004
|
() => ({
|
|
2002
2005
|
flex: 1,
|
|
2003
2006
|
backgroundColor: theme.background.content
|
|
@@ -2005,7 +2008,7 @@ var MobileMenuDrawer = (0, import_react14.memo)(
|
|
|
2005
2008
|
[theme.background.content]
|
|
2006
2009
|
);
|
|
2007
2010
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_portal.Portal, { hostName: "storybook-lite-ui-root", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
2008
|
-
|
|
2011
|
+
import_react_native11.Animated.View,
|
|
2009
2012
|
{
|
|
2010
2013
|
style: [portalContainerStyle, { transform: [{ translateY: slideAnim }] }],
|
|
2011
2014
|
pointerEvents: isVisible ? "auto" : "none",
|
|
@@ -2013,8 +2016,8 @@ var MobileMenuDrawer = (0, import_react14.memo)(
|
|
|
2013
2016
|
importantForAccessibility: isVisible ? "auto" : "no-hide-descendants",
|
|
2014
2017
|
accessibilityViewIsModal: isVisible,
|
|
2015
2018
|
children: [
|
|
2016
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2017
|
-
|
|
2019
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native11.View, { style: flexStyle5, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2020
|
+
import_react_native11.Pressable,
|
|
2018
2021
|
{
|
|
2019
2022
|
style: flexStyle5,
|
|
2020
2023
|
onPress: closeDrawer,
|
|
@@ -2023,14 +2026,14 @@ var MobileMenuDrawer = (0, import_react14.memo)(
|
|
|
2023
2026
|
}
|
|
2024
2027
|
) }),
|
|
2025
2028
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2026
|
-
|
|
2029
|
+
import_react_native11.Animated.View,
|
|
2027
2030
|
{
|
|
2028
2031
|
style: {
|
|
2029
2032
|
height: animatedHeight
|
|
2030
2033
|
},
|
|
2031
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
2032
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2033
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2034
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react_native11.Animated.View, { style: [drawerContainerStyle, { transform: [{ translateY: dragY }] }], children: [
|
|
2035
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native11.View, { ...panResponder.panHandlers, style: dragHandleWrapperStyle, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native11.View, { style: handleStyle }) }),
|
|
2036
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native11.View, { style: childrenWrapperStyle, children })
|
|
2034
2037
|
] })
|
|
2035
2038
|
}
|
|
2036
2039
|
)
|
|
@@ -2043,21 +2046,21 @@ var MobileMenuDrawer = (0, import_react14.memo)(
|
|
|
2043
2046
|
|
|
2044
2047
|
// src/ResizeHandle.tsx
|
|
2045
2048
|
var import_react_native_theming10 = require("@storybook/react-native-theming");
|
|
2046
|
-
var
|
|
2047
|
-
var
|
|
2049
|
+
var import_react16 = require("react");
|
|
2050
|
+
var import_react_native12 = require("react-native");
|
|
2048
2051
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2049
|
-
var ResizeHandle = (0,
|
|
2052
|
+
var ResizeHandle = (0, import_react16.memo)(function ResizeHandle2({
|
|
2050
2053
|
direction,
|
|
2051
2054
|
onResize,
|
|
2052
2055
|
onResizeStart,
|
|
2053
2056
|
onResizeEnd
|
|
2054
2057
|
}) {
|
|
2055
2058
|
const theme = (0, import_react_native_theming10.useTheme)();
|
|
2056
|
-
const [active, setActive] = (0,
|
|
2057
|
-
const startValueRef = (0,
|
|
2059
|
+
const [active, setActive] = (0, import_react16.useState)(false);
|
|
2060
|
+
const startValueRef = (0, import_react16.useRef)(0);
|
|
2058
2061
|
const isHorizontal = direction === "horizontal";
|
|
2059
|
-
const panResponder = (0,
|
|
2060
|
-
() =>
|
|
2062
|
+
const panResponder = (0, import_react16.useMemo)(
|
|
2063
|
+
() => import_react_native12.PanResponder.create({
|
|
2061
2064
|
onStartShouldSetPanResponder: () => true,
|
|
2062
2065
|
onMoveShouldSetPanResponder: () => true,
|
|
2063
2066
|
onPanResponderTerminationRequest: () => false,
|
|
@@ -2084,7 +2087,7 @@ var ResizeHandle = (0, import_react15.memo)(function ResizeHandle2({
|
|
|
2084
2087
|
}),
|
|
2085
2088
|
[isHorizontal, onResize, onResizeStart, onResizeEnd]
|
|
2086
2089
|
);
|
|
2087
|
-
const style = (0,
|
|
2090
|
+
const style = (0, import_react16.useMemo)(() => {
|
|
2088
2091
|
const borderColor = active ? theme.barSelectedColor : theme.appBorderColor;
|
|
2089
2092
|
if (isHorizontal) {
|
|
2090
2093
|
return {
|
|
@@ -2109,22 +2112,22 @@ var ResizeHandle = (0, import_react15.memo)(function ResizeHandle2({
|
|
|
2109
2112
|
cursor: "row-resize"
|
|
2110
2113
|
};
|
|
2111
2114
|
}, [active, isHorizontal, theme.appBorderColor, theme.barSelectedColor]);
|
|
2112
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2115
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native12.View, { ...panResponder.panHandlers, style });
|
|
2113
2116
|
});
|
|
2114
2117
|
|
|
2115
2118
|
// src/StorybookLogo.tsx
|
|
2116
|
-
var
|
|
2117
|
-
var
|
|
2119
|
+
var import_react17 = require("react");
|
|
2120
|
+
var import_react_native13 = require("react-native");
|
|
2118
2121
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2119
2122
|
var WIDTH = 125;
|
|
2120
2123
|
var HEIGHT = 25;
|
|
2121
2124
|
var NoBrandLogo = ({ theme }) => theme.base === "light" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Logo, { height: HEIGHT, width: WIDTH }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DarkLogo, { height: HEIGHT, width: WIDTH });
|
|
2122
2125
|
function isElement(value) {
|
|
2123
|
-
return (0,
|
|
2126
|
+
return (0, import_react17.isValidElement)(value);
|
|
2124
2127
|
}
|
|
2125
2128
|
var BrandLogo = ({ theme }) => {
|
|
2126
2129
|
const imageHasNoWidthOrHeight = typeof theme.brand.image === "object" && typeof theme.brand.image === "object" && "uri" in theme.brand.image && (!("height" in theme.brand.image) || !("width" in theme.brand.image));
|
|
2127
|
-
(0,
|
|
2130
|
+
(0, import_react17.useEffect)(() => {
|
|
2128
2131
|
if (imageHasNoWidthOrHeight) {
|
|
2129
2132
|
console.warn(
|
|
2130
2133
|
"STORYBOOK: When using a remote image as the brand logo, you must also set the width and height.\nFor example: brand: { image: { uri: 'https://sb.com/img.png', height: 25, width: 25}}"
|
|
@@ -2138,7 +2141,7 @@ var BrandLogo = ({ theme }) => {
|
|
|
2138
2141
|
return theme.brand.image;
|
|
2139
2142
|
}
|
|
2140
2143
|
const image = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2141
|
-
|
|
2144
|
+
import_react_native13.Image,
|
|
2142
2145
|
{
|
|
2143
2146
|
source: theme.brand.image,
|
|
2144
2147
|
resizeMode: theme.brand.resizeMode ?? "contain",
|
|
@@ -2147,10 +2150,10 @@ var BrandLogo = ({ theme }) => {
|
|
|
2147
2150
|
);
|
|
2148
2151
|
if (theme.brand.url) {
|
|
2149
2152
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2150
|
-
|
|
2153
|
+
import_react_native13.TouchableOpacity,
|
|
2151
2154
|
{
|
|
2152
2155
|
onPress: () => {
|
|
2153
|
-
if (theme.brand.url)
|
|
2156
|
+
if (theme.brand.url) import_react_native13.Linking.openURL(theme.brand.url);
|
|
2154
2157
|
},
|
|
2155
2158
|
accessibilityRole: "link",
|
|
2156
2159
|
accessibilityLabel: theme.brand.title ?? "Brand logo",
|
|
@@ -2162,7 +2165,7 @@ var BrandLogo = ({ theme }) => {
|
|
|
2162
2165
|
}
|
|
2163
2166
|
};
|
|
2164
2167
|
var BrandTitle = ({ theme }) => {
|
|
2165
|
-
const brandTitleStyle = (0,
|
|
2168
|
+
const brandTitleStyle = (0, import_react17.useMemo)(() => {
|
|
2166
2169
|
return {
|
|
2167
2170
|
width: WIDTH,
|
|
2168
2171
|
height: HEIGHT,
|
|
@@ -2170,13 +2173,13 @@ var BrandTitle = ({ theme }) => {
|
|
|
2170
2173
|
fontSize: theme.typography.size.m1
|
|
2171
2174
|
};
|
|
2172
2175
|
}, [theme]);
|
|
2173
|
-
const title = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2176
|
+
const title = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native13.Text, { style: brandTitleStyle, numberOfLines: 1, ellipsizeMode: "tail", children: theme.brand.title });
|
|
2174
2177
|
if (theme.brand.url) {
|
|
2175
2178
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2176
|
-
|
|
2179
|
+
import_react_native13.TouchableOpacity,
|
|
2177
2180
|
{
|
|
2178
2181
|
onPress: () => {
|
|
2179
|
-
if (theme.brand.url)
|
|
2182
|
+
if (theme.brand.url) import_react_native13.Linking.openURL(theme.brand.url);
|
|
2180
2183
|
},
|
|
2181
2184
|
accessibilityRole: "link",
|
|
2182
2185
|
accessibilityLabel: theme.brand.title,
|
|
@@ -2188,8 +2191,8 @@ var BrandTitle = ({ theme }) => {
|
|
|
2188
2191
|
}
|
|
2189
2192
|
};
|
|
2190
2193
|
var StorybookLogo = ({ theme }) => {
|
|
2191
|
-
const image = (0,
|
|
2192
|
-
const title = (0,
|
|
2194
|
+
const image = (0, import_react17.useMemo)(() => theme.brand?.image, [theme.brand?.image]);
|
|
2195
|
+
const title = (0, import_react17.useMemo)(() => theme.brand?.title, [theme.brand?.title]);
|
|
2193
2196
|
if (image) {
|
|
2194
2197
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(BrandLogo, { theme });
|
|
2195
2198
|
} else if (title) {
|
|
@@ -2263,24 +2266,24 @@ var Layout = ({
|
|
|
2263
2266
|
"desktopAddonsPanelHeight",
|
|
2264
2267
|
300
|
|
2265
2268
|
);
|
|
2266
|
-
const { width: windowWidth, height: windowHeight } = (0,
|
|
2267
|
-
const handleSidebarResize = (0,
|
|
2269
|
+
const { width: windowWidth, height: windowHeight } = (0, import_react_native14.useWindowDimensions)();
|
|
2270
|
+
const handleSidebarResize = (0, import_react18.useCallback)(
|
|
2268
2271
|
(delta) => {
|
|
2269
2272
|
setSidebarWidth((prev) => Math.min(Math.max(prev + delta, 180), windowWidth * 0.5));
|
|
2270
2273
|
},
|
|
2271
2274
|
[setSidebarWidth, windowWidth]
|
|
2272
2275
|
);
|
|
2273
|
-
const handleAddonsPanelResize = (0,
|
|
2276
|
+
const handleAddonsPanelResize = (0, import_react18.useCallback)(
|
|
2274
2277
|
(delta) => {
|
|
2275
2278
|
setAddonsPanelHeight((prev) => Math.min(Math.max(prev - delta, 100), windowHeight * 0.6));
|
|
2276
2279
|
},
|
|
2277
2280
|
[setAddonsPanelHeight, windowHeight]
|
|
2278
2281
|
);
|
|
2279
|
-
const [isResizing, setIsResizing] = (0,
|
|
2280
|
-
const onResizeStart = (0,
|
|
2281
|
-
const onResizeEnd = (0,
|
|
2282
|
-
const [uiHidden, setUiHidden] = (0,
|
|
2283
|
-
(0,
|
|
2282
|
+
const [isResizing, setIsResizing] = (0, import_react18.useState)(false);
|
|
2283
|
+
const onResizeStart = (0, import_react18.useCallback)(() => setIsResizing(true), []);
|
|
2284
|
+
const onResizeEnd = (0, import_react18.useCallback)(() => setIsResizing(false), []);
|
|
2285
|
+
const [uiHidden, setUiHidden] = (0, import_react18.useState)(false);
|
|
2286
|
+
(0, import_react18.useLayoutEffect)(() => {
|
|
2284
2287
|
setUiHidden(story?.parameters?.storybookUIVisibility === "hidden");
|
|
2285
2288
|
}, [story?.parameters?.storybookUIVisibility]);
|
|
2286
2289
|
const desktopSidebarStyle = (0, import_react_native_ui_common7.useStyle)(
|
|
@@ -2350,23 +2353,23 @@ var Layout = ({
|
|
|
2350
2353
|
}),
|
|
2351
2354
|
[theme.barTextColor]
|
|
2352
2355
|
);
|
|
2353
|
-
const mobileMenuDrawerRef = (0,
|
|
2354
|
-
const addonPanelRef = (0,
|
|
2355
|
-
const [isDrawerOpen, setIsDrawerOpen] = (0,
|
|
2356
|
-
const setSelection = (0,
|
|
2356
|
+
const mobileMenuDrawerRef = (0, import_react18.useRef)(null);
|
|
2357
|
+
const addonPanelRef = (0, import_react18.useRef)(null);
|
|
2358
|
+
const [isDrawerOpen, setIsDrawerOpen] = (0, import_react18.useState)(false);
|
|
2359
|
+
const setSelection = (0, import_react18.useCallback)(({ storyId: newStoryId }) => {
|
|
2357
2360
|
const channel = import_manager_api2.addons.getChannel();
|
|
2358
2361
|
channel.emit(import_core_events.SET_CURRENT_STORY, { storyId: newStoryId });
|
|
2359
2362
|
}, []);
|
|
2360
2363
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2361
|
-
|
|
2364
|
+
import_react_native14.View,
|
|
2362
2365
|
{
|
|
2363
2366
|
style: containerStyle2,
|
|
2364
2367
|
accessibilityElementsHidden: isDrawerOpen,
|
|
2365
2368
|
importantForAccessibility: isDrawerOpen ? "no-hide-descendants" : "auto",
|
|
2366
2369
|
children: [
|
|
2367
2370
|
isDesktop ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
2368
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2369
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2371
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native14.View, { style: desktopSidebarStyle, pointerEvents: isResizing ? "none" : "auto", children: desktopSidebarOpen ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
2372
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native14.View, { style: desktopLogoContainer, children: [
|
|
2370
2373
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(StorybookLogo, { theme }),
|
|
2371
2374
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2372
2375
|
import_react_native_ui_common7.IconButton,
|
|
@@ -2377,7 +2380,7 @@ var Layout = ({
|
|
|
2377
2380
|
}
|
|
2378
2381
|
)
|
|
2379
2382
|
] }),
|
|
2380
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2383
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native14.View, { style: flexStyle6, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2381
2384
|
Sidebar,
|
|
2382
2385
|
{
|
|
2383
2386
|
previewInitialized: true,
|
|
@@ -2408,9 +2411,9 @@ var Layout = ({
|
|
|
2408
2411
|
}
|
|
2409
2412
|
) : null
|
|
2410
2413
|
] }) : null,
|
|
2411
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2414
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native14.View, { style: mobileContentStyle, children: [
|
|
2412
2415
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2413
|
-
|
|
2416
|
+
import_react_native14.View,
|
|
2414
2417
|
{
|
|
2415
2418
|
style: isDesktop ? storyContentStyle : contentContainerStyle,
|
|
2416
2419
|
pointerEvents: isResizing ? "none" : "auto",
|
|
@@ -2418,7 +2421,7 @@ var Layout = ({
|
|
|
2418
2421
|
}
|
|
2419
2422
|
),
|
|
2420
2423
|
story?.parameters?.hideFullScreenButton || isDesktop ? null : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2421
|
-
|
|
2424
|
+
import_react_native14.TouchableOpacity,
|
|
2422
2425
|
{
|
|
2423
2426
|
style: fullScreenButtonStyle,
|
|
2424
2427
|
hitSlop: { top: 10, bottom: 10, left: 10, right: 10 },
|
|
@@ -2438,7 +2441,7 @@ var Layout = ({
|
|
|
2438
2441
|
onResizeEnd
|
|
2439
2442
|
}
|
|
2440
2443
|
) : null,
|
|
2441
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2444
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native14.View, { style: desktopAddonsPanelStyle, pointerEvents: isResizing ? "none" : "auto", children: desktopAddonsPanelOpen ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(AddonsTabs, { storyId: story?.id, onClose: () => setDesktopAddonsPanelOpen(false) }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2442
2445
|
import_react_native_ui_common7.IconButton,
|
|
2443
2446
|
{
|
|
2444
2447
|
style: iconFloatRightStyle,
|
|
@@ -2461,7 +2464,7 @@ var Layout = ({
|
|
|
2461
2464
|
accessibilityLabel: "Open story list",
|
|
2462
2465
|
children: [
|
|
2463
2466
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(MenuIcon, { color: theme.color.mediumdark }),
|
|
2464
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2467
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native14.Text, { style: navButtonTextStyle, numberOfLines: 1, children: [
|
|
2465
2468
|
story?.title,
|
|
2466
2469
|
"/",
|
|
2467
2470
|
story?.name
|
|
@@ -2481,7 +2484,7 @@ var Layout = ({
|
|
|
2481
2484
|
)
|
|
2482
2485
|
] }) }) : null,
|
|
2483
2486
|
isDesktop ? null : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(MobileMenuDrawer, { ref: mobileMenuDrawerRef, onVisibilityChange: setIsDrawerOpen, children: [
|
|
2484
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2487
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native14.View, { style: mobileMenuDrawerContentStyle, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(StorybookLogo, { theme }) }),
|
|
2485
2488
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2486
2489
|
Sidebar,
|
|
2487
2490
|
{
|