@storybook/react-native-ui-lite 10.2.0 → 10.2.2-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +591 -437
- package/package.json +7 -6
- package/src/Explorer.tsx +4 -2
- package/src/Layout.tsx +54 -47
- package/src/MobileMenuDrawer.tsx +141 -87
- package/src/Refs.tsx +1 -1
- package/src/Search.tsx +140 -118
- package/src/SearchResults.stories.tsx +6 -44
- package/src/SearchResults.tsx +181 -82
- package/src/SelectedNodeProvider.tsx +19 -34
- package/src/Sidebar.tsx +20 -11
- package/src/Tree.tsx +179 -70
- package/src/TreeNode.tsx +15 -14
package/dist/index.js
CHANGED
|
@@ -319,7 +319,7 @@ function StoryIcon({
|
|
|
319
319
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
320
320
|
var BranchNodeText = import_react_native_theming2.styled.Text(({ theme }) => ({
|
|
321
321
|
textAlign: "left",
|
|
322
|
-
fontSize: theme.typography.size.s2,
|
|
322
|
+
fontSize: theme.typography.size.s2 + 1,
|
|
323
323
|
flexShrink: 1,
|
|
324
324
|
color: theme.color.defaultText
|
|
325
325
|
}));
|
|
@@ -329,15 +329,15 @@ var BranchNode = import_react_native_theming2.styled.TouchableOpacity(({ depth =
|
|
|
329
329
|
cursor: "pointer",
|
|
330
330
|
display: "flex",
|
|
331
331
|
flexDirection: "row",
|
|
332
|
-
alignItems: "
|
|
332
|
+
alignItems: "center",
|
|
333
333
|
alignSelf: "flex-start",
|
|
334
334
|
paddingLeft: (isExpandable ? 8 : 22) + depth * 18,
|
|
335
335
|
backgroundColor: "transparent",
|
|
336
|
-
minHeight:
|
|
336
|
+
minHeight: 34,
|
|
337
337
|
borderRadius: 4,
|
|
338
338
|
gap: 6,
|
|
339
|
-
paddingTop:
|
|
340
|
-
paddingBottom:
|
|
339
|
+
paddingTop: 8,
|
|
340
|
+
paddingBottom: 7,
|
|
341
341
|
// will this actually do anything?
|
|
342
342
|
"&:hover, &:focus": {
|
|
343
343
|
backgroundColor: (0, import_polished.transparentize)(0.93, theme.color.secondary),
|
|
@@ -352,20 +352,20 @@ var LeafNode = import_react_native_theming2.styled.TouchableOpacity(
|
|
|
352
352
|
display: "flex",
|
|
353
353
|
gap: 6,
|
|
354
354
|
flexDirection: "row",
|
|
355
|
-
alignItems: "
|
|
355
|
+
alignItems: "center",
|
|
356
356
|
paddingLeft: 22 + depth * 18,
|
|
357
|
-
paddingTop:
|
|
358
|
-
paddingBottom:
|
|
357
|
+
paddingTop: 8,
|
|
358
|
+
paddingBottom: 7,
|
|
359
359
|
backgroundColor: selected ? theme.color.secondary : void 0,
|
|
360
360
|
// not sure 👇
|
|
361
361
|
width: "100%",
|
|
362
362
|
borderRadius: 4,
|
|
363
363
|
paddingRight: 20,
|
|
364
|
-
minHeight:
|
|
364
|
+
minHeight: 34
|
|
365
365
|
})
|
|
366
366
|
);
|
|
367
367
|
var LeafNodeText = import_react_native_theming2.styled.Text(({ theme, selected }) => ({
|
|
368
|
-
fontSize: theme.typography.size.s2,
|
|
368
|
+
fontSize: theme.typography.size.s2 + 1,
|
|
369
369
|
flexShrink: 1,
|
|
370
370
|
fontWeight: selected ? "bold" : "normal",
|
|
371
371
|
color: selected ? theme.color.lightest : theme.color.defaultText
|
|
@@ -374,8 +374,7 @@ var Wrapper = import_react_native_theming2.styled.View({
|
|
|
374
374
|
display: "flex",
|
|
375
375
|
flexDirection: "row",
|
|
376
376
|
alignItems: "center",
|
|
377
|
-
gap: 6
|
|
378
|
-
marginTop: 2
|
|
377
|
+
gap: 6
|
|
379
378
|
});
|
|
380
379
|
var GroupNode = import_react2.default.memo(function GroupNode2({
|
|
381
380
|
children,
|
|
@@ -392,7 +391,7 @@ var GroupNode = import_react2.default.memo(function GroupNode2({
|
|
|
392
391
|
isExpandable && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CollapseIcon, { isExpanded }),
|
|
393
392
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(GroupIcon, { width: 14, height: 14, color })
|
|
394
393
|
] }, `group-${props.id}-${color}`),
|
|
395
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BranchNodeText, { children })
|
|
394
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BranchNodeText, { numberOfLines: 1, children })
|
|
396
395
|
] });
|
|
397
396
|
});
|
|
398
397
|
var ComponentNode = import_react2.default.memo(
|
|
@@ -406,7 +405,7 @@ var ComponentNode = import_react2.default.memo(
|
|
|
406
405
|
isExpandable && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CollapseIcon, { isExpanded }),
|
|
407
406
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ComponentIcon, { width: 12, height: 12, color })
|
|
408
407
|
] }, `component-${props.id}-${color}`),
|
|
409
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BranchNodeText, { children })
|
|
408
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BranchNodeText, { numberOfLines: 1, children })
|
|
410
409
|
] });
|
|
411
410
|
}
|
|
412
411
|
);
|
|
@@ -418,7 +417,7 @@ var StoryNode = import_react2.default.memo(
|
|
|
418
417
|
}, [props.selected, theme.color.lightest, theme.color.seafoam]);
|
|
419
418
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(LeafNode, { ...props, ref, children: [
|
|
420
419
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(StoryIcon, { width: 14, height: 14, color }) }, `story-${props.id}-${color}`),
|
|
421
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LeafNodeText, { selected: props.selected, children })
|
|
420
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LeafNodeText, { selected: props.selected, numberOfLines: 1, children })
|
|
422
421
|
] });
|
|
423
422
|
})
|
|
424
423
|
);
|
|
@@ -428,44 +427,36 @@ StoryNode.displayName = "StoryNode";
|
|
|
428
427
|
var import_react_native_theming3 = require("@storybook/react-native-theming");
|
|
429
428
|
var import_react_native_ui_common = require("@storybook/react-native-ui-common");
|
|
430
429
|
var import_react4 = __toESM(require("react"));
|
|
430
|
+
var import_react_native2 = require("react-native");
|
|
431
|
+
var import_list = require("@legendapp/list");
|
|
432
|
+
var import_react_native_safe_area_context = require("react-native-safe-area-context");
|
|
431
433
|
|
|
432
434
|
// src/SelectedNodeProvider.tsx
|
|
433
435
|
var import_react3 = require("react");
|
|
434
436
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
435
437
|
var SelectedNodeContext = (0, import_react3.createContext)({
|
|
436
|
-
|
|
437
|
-
setNodeRef: () => {
|
|
438
|
-
},
|
|
439
|
-
scrollToSelectedNode: () => {
|
|
438
|
+
registerCallback: () => {
|
|
440
439
|
},
|
|
441
|
-
|
|
440
|
+
scrollCallback: () => {
|
|
441
|
+
}
|
|
442
442
|
});
|
|
443
443
|
var SelectedNodeProvider = ({ children }) => {
|
|
444
|
-
const
|
|
445
|
-
const
|
|
446
|
-
|
|
447
|
-
}, []);
|
|
448
|
-
const scrollRef = (0, import_react3.useRef)(null);
|
|
449
|
-
const scrollToSelectedNode = (0, import_react3.useCallback)(() => {
|
|
450
|
-
setTimeout(() => {
|
|
451
|
-
if (nodeRef?.current && scrollRef?.current) {
|
|
452
|
-
try {
|
|
453
|
-
nodeRef.current.measureLayout?.(scrollRef.current, (_x, y) => {
|
|
454
|
-
scrollRef.current?.scrollTo({ y: y - 100, animated: true });
|
|
455
|
-
});
|
|
456
|
-
} catch (_error) {
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
}, 500);
|
|
444
|
+
const [scrollCallbackValue, setScrollCallback] = (0, import_react3.useState)(null);
|
|
445
|
+
const registerCallback = (0, import_react3.useCallback)((callback) => {
|
|
446
|
+
setScrollCallback(() => callback);
|
|
460
447
|
}, []);
|
|
448
|
+
const scrollCallback = (0, import_react3.useCallback)(
|
|
449
|
+
(options) => {
|
|
450
|
+
scrollCallbackValue?.(options);
|
|
451
|
+
},
|
|
452
|
+
[scrollCallbackValue]
|
|
453
|
+
);
|
|
461
454
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
462
455
|
SelectedNodeContext.Provider,
|
|
463
456
|
{
|
|
464
457
|
value: {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
scrollToSelectedNode,
|
|
468
|
-
scrollRef
|
|
458
|
+
scrollCallback,
|
|
459
|
+
registerCallback
|
|
469
460
|
},
|
|
470
461
|
children
|
|
471
462
|
}
|
|
@@ -482,7 +473,7 @@ var Node = import_react4.default.memo(function Node2({
|
|
|
482
473
|
item,
|
|
483
474
|
refId,
|
|
484
475
|
isOrphan,
|
|
485
|
-
isDisplayed,
|
|
476
|
+
isDisplayed: _isDisplayed,
|
|
486
477
|
isSelected,
|
|
487
478
|
isFullyExpanded,
|
|
488
479
|
color: _2,
|
|
@@ -491,24 +482,11 @@ var Node = import_react4.default.memo(function Node2({
|
|
|
491
482
|
setExpanded,
|
|
492
483
|
onSelectStoryId
|
|
493
484
|
}) {
|
|
494
|
-
const { setNodeRef } = useSelectedNode();
|
|
495
|
-
const setRef = (0, import_react4.useCallback)(
|
|
496
|
-
(node) => {
|
|
497
|
-
if (isSelected && node) {
|
|
498
|
-
setNodeRef(node);
|
|
499
|
-
}
|
|
500
|
-
},
|
|
501
|
-
[isSelected, setNodeRef]
|
|
502
|
-
);
|
|
503
|
-
if (!isDisplayed) {
|
|
504
|
-
return null;
|
|
505
|
-
}
|
|
506
485
|
const id = (0, import_react_native_ui_common.createId)(item.id, refId);
|
|
507
486
|
if (item.type === "story") {
|
|
508
487
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LeafNodeStyleWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
509
488
|
StoryNode,
|
|
510
489
|
{
|
|
511
|
-
ref: setRef,
|
|
512
490
|
selected: isSelected,
|
|
513
491
|
id,
|
|
514
492
|
depth: isOrphan ? item.depth : item.depth - 1,
|
|
@@ -526,6 +504,7 @@ var Node = import_react4.default.memo(function Node2({
|
|
|
526
504
|
CollapseButton,
|
|
527
505
|
{
|
|
528
506
|
"data-action": "collapse-root",
|
|
507
|
+
hitSlop: { top: 10, bottom: 10, left: 10, right: 10 },
|
|
529
508
|
onPress: (event) => {
|
|
530
509
|
event.preventDefault();
|
|
531
510
|
setExpanded({ ids: [item.id], value: !isExpanded });
|
|
@@ -543,6 +522,7 @@ var Node = import_react4.default.memo(function Node2({
|
|
|
543
522
|
"aria-label": isFullyExpanded ? "Expand" : "Collapse",
|
|
544
523
|
"data-action": "expand-all",
|
|
545
524
|
"data-expanded": isFullyExpanded,
|
|
525
|
+
hitSlop: { top: 10, bottom: 10, left: 10, right: 10 },
|
|
546
526
|
onPress: (event) => {
|
|
547
527
|
event.preventDefault();
|
|
548
528
|
setFullyExpanded();
|
|
@@ -584,7 +564,7 @@ var LeafNodeStyleWrapper = import_react_native_theming3.styled.View(({ theme })
|
|
|
584
564
|
paddingRight: 20,
|
|
585
565
|
color: theme.color.defaultText,
|
|
586
566
|
backgroundColor: "transparent",
|
|
587
|
-
minHeight:
|
|
567
|
+
minHeight: 34,
|
|
588
568
|
borderRadius: 4
|
|
589
569
|
}));
|
|
590
570
|
var RootNode = import_react_native_theming3.styled.View(() => ({
|
|
@@ -594,7 +574,7 @@ var RootNode = import_react_native_theming3.styled.View(() => ({
|
|
|
594
574
|
justifyContent: "space-between",
|
|
595
575
|
marginTop: 16,
|
|
596
576
|
marginBottom: 4,
|
|
597
|
-
minHeight:
|
|
577
|
+
minHeight: 34
|
|
598
578
|
}));
|
|
599
579
|
var RootNodeText = import_react_native_theming3.styled.Text(({ theme }) => ({
|
|
600
580
|
fontSize: theme.typography.size.s1 - 1,
|
|
@@ -613,10 +593,19 @@ var CollapseButton = import_react_native_theming3.styled.TouchableOpacity(() =>
|
|
|
613
593
|
gap: 6,
|
|
614
594
|
alignItems: "center",
|
|
615
595
|
cursor: "pointer",
|
|
616
|
-
height:
|
|
596
|
+
height: 34
|
|
617
597
|
}));
|
|
598
|
+
var flexStyle = { flex: 1 };
|
|
599
|
+
var ITEM_HEIGHT = 34;
|
|
600
|
+
var ROOT_ITEM_HEIGHT = 54;
|
|
601
|
+
var getEstimatedItemSize = (item, _index) => {
|
|
602
|
+
return item?.isRoot ? ROOT_ITEM_HEIGHT : ITEM_HEIGHT;
|
|
603
|
+
};
|
|
618
604
|
var Tree = import_react4.default.memo(function Tree2({ isMain, refId, data, status, docsMode, selectedStoryId, onSelectStoryId }) {
|
|
619
|
-
const
|
|
605
|
+
const { registerCallback } = useSelectedNode();
|
|
606
|
+
const [idToScrolllOnMount, setIdToScrolllOnMount] = (0, import_react4.useState)(null);
|
|
607
|
+
const insets = (0, import_react_native_safe_area_context.useSafeAreaInsets)();
|
|
608
|
+
const listRef = (0, import_react4.useRef)(null);
|
|
620
609
|
const [rootIds, orphanIds, initialExpanded] = (0, import_react4.useMemo)(
|
|
621
610
|
() => Object.keys(data).reduce(
|
|
622
611
|
(acc, id) => {
|
|
@@ -655,9 +644,7 @@ var Tree = import_react4.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
655
644
|
}, [data]);
|
|
656
645
|
const collapsedItems = (0, import_react4.useMemo)(
|
|
657
646
|
() => Object.keys(data).filter((id) => !singleStoryComponentIds.includes(id)),
|
|
658
|
-
|
|
659
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
660
|
-
[singleStoryComponentIds]
|
|
647
|
+
[singleStoryComponentIds, data]
|
|
661
648
|
);
|
|
662
649
|
const collapsedData = (0, import_react4.useMemo)(() => {
|
|
663
650
|
return singleStoryComponentIds.reduce(
|
|
@@ -679,13 +666,7 @@ var Tree = import_react4.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
679
666
|
},
|
|
680
667
|
{ ...data }
|
|
681
668
|
);
|
|
682
|
-
}, [data]);
|
|
683
|
-
const ancestry = (0, import_react4.useMemo)(() => {
|
|
684
|
-
return collapsedItems.reduce(
|
|
685
|
-
(acc, id) => Object.assign(acc, { [id]: (0, import_react_native_ui_common.getAncestorIds)(collapsedData, id) }),
|
|
686
|
-
{}
|
|
687
|
-
);
|
|
688
|
-
}, [collapsedItems, collapsedData]);
|
|
669
|
+
}, [data, singleStoryComponentIds]);
|
|
689
670
|
const [expanded, setExpanded] = (0, import_react_native_ui_common.useExpanded)({
|
|
690
671
|
refId,
|
|
691
672
|
data: collapsedData,
|
|
@@ -694,13 +675,58 @@ var Tree = import_react4.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
694
675
|
selectedStoryId,
|
|
695
676
|
onSelectStoryId
|
|
696
677
|
});
|
|
697
|
-
const
|
|
678
|
+
const parentMap = (0, import_react4.useMemo)(() => {
|
|
679
|
+
const map = {};
|
|
680
|
+
collapsedItems.forEach((id) => {
|
|
681
|
+
const item = collapsedData[id];
|
|
682
|
+
map[id] = "parent" in item && item.parent || null;
|
|
683
|
+
});
|
|
684
|
+
return map;
|
|
685
|
+
}, [collapsedItems, collapsedData]);
|
|
686
|
+
const isItemVisible = (0, import_react4.useCallback)(
|
|
687
|
+
(itemId) => {
|
|
688
|
+
const item = collapsedData[itemId];
|
|
689
|
+
if (item.type === "root") return true;
|
|
690
|
+
if (!("parent" in item) || !item.parent) return true;
|
|
691
|
+
let currentId = item.parent;
|
|
692
|
+
while (currentId) {
|
|
693
|
+
if (!expanded[currentId]) return false;
|
|
694
|
+
currentId = parentMap[currentId];
|
|
695
|
+
}
|
|
696
|
+
return true;
|
|
697
|
+
},
|
|
698
|
+
[collapsedData, expanded, parentMap]
|
|
699
|
+
);
|
|
700
|
+
const treeData = (0, import_react4.useMemo)(() => {
|
|
698
701
|
return collapsedItems.map((itemId) => {
|
|
699
702
|
const item = collapsedData[itemId];
|
|
700
|
-
|
|
703
|
+
if (!isItemVisible(itemId)) {
|
|
704
|
+
return null;
|
|
705
|
+
}
|
|
701
706
|
if (item.type === "root") {
|
|
702
707
|
const descendants = expandableDescendants[item.id];
|
|
703
708
|
const isFullyExpanded = descendants.every((d) => expanded[d]);
|
|
709
|
+
return {
|
|
710
|
+
itemId,
|
|
711
|
+
item,
|
|
712
|
+
isRoot: true,
|
|
713
|
+
isFullyExpanded,
|
|
714
|
+
descendants
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
return {
|
|
718
|
+
itemId,
|
|
719
|
+
item,
|
|
720
|
+
isRoot: false,
|
|
721
|
+
isOrphan: orphanIds.some((oid) => itemId === oid || itemId.startsWith(`${oid}-`))
|
|
722
|
+
};
|
|
723
|
+
}).filter(Boolean);
|
|
724
|
+
}, [collapsedData, collapsedItems, expandableDescendants, expanded, isItemVisible, orphanIds]);
|
|
725
|
+
const renderItem = (0, import_react4.useCallback)(
|
|
726
|
+
({ item: treeItem }) => {
|
|
727
|
+
const { itemId, item, isRoot } = treeItem;
|
|
728
|
+
const id = (0, import_react_native_ui_common.createId)(itemId, refId);
|
|
729
|
+
if (isRoot) {
|
|
704
730
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
705
731
|
Root,
|
|
706
732
|
{
|
|
@@ -711,8 +737,8 @@ var Tree = import_react4.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
711
737
|
isSelected: selectedStoryId === itemId,
|
|
712
738
|
isExpanded: !!expanded[itemId],
|
|
713
739
|
setExpanded,
|
|
714
|
-
isFullyExpanded,
|
|
715
|
-
expandableDescendants: descendants,
|
|
740
|
+
isFullyExpanded: treeItem.isFullyExpanded,
|
|
741
|
+
expandableDescendants: treeItem.descendants,
|
|
716
742
|
onSelectStoryId,
|
|
717
743
|
docsMode: false,
|
|
718
744
|
color: "",
|
|
@@ -721,7 +747,6 @@ var Tree = import_react4.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
721
747
|
id
|
|
722
748
|
);
|
|
723
749
|
}
|
|
724
|
-
const isDisplayed = !item.parent || ancestry[itemId].every((a) => expanded[a]);
|
|
725
750
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
726
751
|
Node,
|
|
727
752
|
{
|
|
@@ -730,8 +755,8 @@ var Tree = import_react4.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
730
755
|
refId,
|
|
731
756
|
color: null,
|
|
732
757
|
docsMode,
|
|
733
|
-
isOrphan:
|
|
734
|
-
isDisplayed,
|
|
758
|
+
isOrphan: treeItem.isOrphan,
|
|
759
|
+
isDisplayed: true,
|
|
735
760
|
isSelected: selectedStoryId === itemId,
|
|
736
761
|
isExpanded: !!expanded[itemId],
|
|
737
762
|
setExpanded,
|
|
@@ -739,27 +764,62 @@ var Tree = import_react4.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
739
764
|
},
|
|
740
765
|
id
|
|
741
766
|
);
|
|
767
|
+
},
|
|
768
|
+
[docsMode, expanded, onSelectStoryId, refId, selectedStoryId, setExpanded, status]
|
|
769
|
+
);
|
|
770
|
+
const keyExtractor = (0, import_react4.useCallback)(
|
|
771
|
+
(item) => {
|
|
772
|
+
return (0, import_react_native_ui_common.createId)(item.itemId, refId);
|
|
773
|
+
},
|
|
774
|
+
[refId]
|
|
775
|
+
);
|
|
776
|
+
const contentContainerStyle2 = (0, import_react4.useMemo)(
|
|
777
|
+
() => ({
|
|
778
|
+
marginTop: isMain && orphanIds.length > 0 ? 20 : 0,
|
|
779
|
+
paddingBottom: insets.bottom + 20,
|
|
780
|
+
paddingLeft: 6
|
|
781
|
+
}),
|
|
782
|
+
[isMain, orphanIds.length, insets.bottom]
|
|
783
|
+
);
|
|
784
|
+
(0, import_react4.useLayoutEffect)(() => {
|
|
785
|
+
registerCallback(({ id: nextId, animated }) => {
|
|
786
|
+
const targetId = nextId ?? selectedStoryId;
|
|
787
|
+
const ancestorIds = (0, import_react_native_ui_common.getAncestorIds)(collapsedData, targetId);
|
|
788
|
+
setExpanded({ ids: [...ancestorIds, targetId], value: true });
|
|
789
|
+
setIdToScrolllOnMount(targetId);
|
|
742
790
|
});
|
|
743
|
-
}, [
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
791
|
+
}, [collapsedData, registerCallback, selectedStoryId, setExpanded]);
|
|
792
|
+
(0, import_react4.useEffect)(() => {
|
|
793
|
+
if (idToScrolllOnMount) {
|
|
794
|
+
const index = treeData.findIndex((item) => {
|
|
795
|
+
return item.itemId === idToScrolllOnMount;
|
|
796
|
+
});
|
|
797
|
+
if (index >= 0) {
|
|
798
|
+
listRef.current?.scrollToIndex({
|
|
799
|
+
index,
|
|
800
|
+
animated: false,
|
|
801
|
+
viewPosition: 0.5,
|
|
802
|
+
viewOffset: 100
|
|
803
|
+
});
|
|
804
|
+
setIdToScrolllOnMount(null);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}, [idToScrolllOnMount, treeData]);
|
|
808
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native2.View, { style: flexStyle, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
809
|
+
import_list.LegendList,
|
|
810
|
+
{
|
|
811
|
+
ref: listRef,
|
|
812
|
+
style: flexStyle,
|
|
813
|
+
data: treeData,
|
|
814
|
+
renderItem,
|
|
815
|
+
keyExtractor,
|
|
816
|
+
contentContainerStyle: contentContainerStyle2,
|
|
817
|
+
getFixedItemSize: getEstimatedItemSize,
|
|
818
|
+
keyboardShouldPersistTaps: "handled",
|
|
819
|
+
recycleItems: true
|
|
820
|
+
}
|
|
821
|
+
) });
|
|
758
822
|
});
|
|
759
|
-
var Container = import_react_native_theming3.styled.View((props) => ({
|
|
760
|
-
marginTop: props.hasOrphans ? 20 : 0,
|
|
761
|
-
marginBottom: 20
|
|
762
|
-
}));
|
|
763
823
|
var Root = import_react4.default.memo(function Root2({
|
|
764
824
|
setExpanded,
|
|
765
825
|
isFullyExpanded,
|
|
@@ -790,7 +850,7 @@ var import_react_native_theming4 = require("@storybook/react-native-theming");
|
|
|
790
850
|
var import_react_native_ui_common2 = require("@storybook/react-native-ui-common");
|
|
791
851
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
792
852
|
var Wrapper2 = import_react_native_theming4.styled.View(() => ({
|
|
793
|
-
|
|
853
|
+
flex: 1
|
|
794
854
|
}));
|
|
795
855
|
var Ref = import_react5.default.memo(
|
|
796
856
|
function Ref2(props) {
|
|
@@ -844,9 +904,10 @@ var Ref = import_react5.default.memo(
|
|
|
844
904
|
);
|
|
845
905
|
|
|
846
906
|
// src/Explorer.tsx
|
|
847
|
-
var
|
|
907
|
+
var import_react_native3 = require("react-native");
|
|
848
908
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
849
909
|
var import_react7 = require("react");
|
|
910
|
+
var containerStyle = { flex: 1 };
|
|
850
911
|
var Explorer = import_react6.default.memo(function Explorer2({
|
|
851
912
|
isLoading,
|
|
852
913
|
isBrowsing,
|
|
@@ -855,7 +916,7 @@ var Explorer = import_react6.default.memo(function Explorer2({
|
|
|
855
916
|
setSelection
|
|
856
917
|
}) {
|
|
857
918
|
const containerRef = (0, import_react6.useRef)(null);
|
|
858
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
919
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native3.View, { ref: containerRef, style: containerStyle, children: dataset.entries.map(([refId, ref]) => /* @__PURE__ */ (0, import_react7.createElement)(
|
|
859
920
|
Ref,
|
|
860
921
|
{
|
|
861
922
|
...ref,
|
|
@@ -872,7 +933,7 @@ var Explorer = import_react6.default.memo(function Explorer2({
|
|
|
872
933
|
var import_react_native_theming7 = require("@storybook/react-native-theming");
|
|
873
934
|
var import_react_native_ui_common5 = require("@storybook/react-native-ui-common");
|
|
874
935
|
var import_react11 = __toESM(require("react"));
|
|
875
|
-
var
|
|
936
|
+
var import_react_native6 = require("react-native");
|
|
876
937
|
|
|
877
938
|
// src/constants.ts
|
|
878
939
|
var BREAKPOINT = 1e3;
|
|
@@ -881,28 +942,12 @@ var DEFAULT_REF_ID = "storybook_internal";
|
|
|
881
942
|
|
|
882
943
|
// src/Search.tsx
|
|
883
944
|
var import_react_native_theming5 = require("@storybook/react-native-theming");
|
|
884
|
-
var
|
|
885
|
-
var
|
|
886
|
-
var
|
|
945
|
+
var import_react8 = require("@nozbe/microfuzz/react");
|
|
946
|
+
var import_react9 = __toESM(require("react"));
|
|
947
|
+
var import_react_native4 = require("react-native");
|
|
887
948
|
var import_react_native_ui_common3 = require("@storybook/react-native-ui-common");
|
|
888
949
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
889
950
|
var DEFAULT_MAX_SEARCH_RESULTS = 50;
|
|
890
|
-
var options = {
|
|
891
|
-
shouldSort: true,
|
|
892
|
-
tokenize: true,
|
|
893
|
-
findAllMatches: true,
|
|
894
|
-
includeScore: true,
|
|
895
|
-
includeMatches: true,
|
|
896
|
-
threshold: 0.2,
|
|
897
|
-
location: 0,
|
|
898
|
-
distance: 100,
|
|
899
|
-
maxPatternLength: 32,
|
|
900
|
-
minMatchCharLength: 1,
|
|
901
|
-
keys: [
|
|
902
|
-
{ name: "name", weight: 0.7 },
|
|
903
|
-
{ name: "path", weight: 0.3 }
|
|
904
|
-
]
|
|
905
|
-
};
|
|
906
951
|
var SearchIconWrapper = import_react_native_theming5.styled.View({
|
|
907
952
|
position: "absolute",
|
|
908
953
|
top: 0,
|
|
@@ -915,11 +960,9 @@ var SearchIconWrapper = import_react_native_theming5.styled.View({
|
|
|
915
960
|
height: "100%"
|
|
916
961
|
});
|
|
917
962
|
var SearchField = import_react_native_theming5.styled.View({
|
|
918
|
-
|
|
919
|
-
flexDirection: "column",
|
|
920
|
-
position: "relative"
|
|
963
|
+
flexShrink: 0
|
|
921
964
|
});
|
|
922
|
-
var inputPlatformSpecificStyles =
|
|
965
|
+
var inputPlatformSpecificStyles = import_react_native4.Platform.select({
|
|
923
966
|
macos: {
|
|
924
967
|
paddingVertical: 6
|
|
925
968
|
},
|
|
@@ -931,7 +974,7 @@ var inputPlatformSpecificStyles = import_react_native3.Platform.select({
|
|
|
931
974
|
height: 32
|
|
932
975
|
}
|
|
933
976
|
});
|
|
934
|
-
var Input = (0, import_react_native_theming5.styled)(
|
|
977
|
+
var Input = (0, import_react_native_theming5.styled)(import_react_native4.TextInput)(({ theme }) => ({
|
|
935
978
|
...inputPlatformSpecificStyles,
|
|
936
979
|
paddingLeft: 28,
|
|
937
980
|
paddingRight: 28,
|
|
@@ -947,36 +990,39 @@ var ClearIcon = import_react_native_theming5.styled.TouchableOpacity(({ theme })
|
|
|
947
990
|
position: "absolute",
|
|
948
991
|
top: 0,
|
|
949
992
|
bottom: 0,
|
|
950
|
-
right:
|
|
993
|
+
right: 0,
|
|
951
994
|
zIndex: 1,
|
|
952
995
|
color: theme.textMutedColor,
|
|
953
996
|
cursor: "pointer",
|
|
954
997
|
display: "flex",
|
|
955
998
|
alignItems: "center",
|
|
956
999
|
justifyContent: "center",
|
|
957
|
-
height: "100%"
|
|
1000
|
+
height: "100%",
|
|
1001
|
+
paddingHorizontal: 12
|
|
958
1002
|
}));
|
|
959
|
-
var
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
const
|
|
963
|
-
const
|
|
964
|
-
const
|
|
965
|
-
const
|
|
1003
|
+
var flexStyle2 = { flex: 1 };
|
|
1004
|
+
var searchFieldWrapperStyle = { paddingHorizontal: 10, marginBottom: 4 };
|
|
1005
|
+
var Search = import_react9.default.memo(function Search2({ children, dataset, setSelection, getLastViewed, initialQuery = "" }) {
|
|
1006
|
+
const theme = (0, import_react_native_theming5.useTheme)();
|
|
1007
|
+
const inputRef = (0, import_react9.useRef)(null);
|
|
1008
|
+
const [inputValue, setInputValue] = (0, import_react9.useState)(initialQuery);
|
|
1009
|
+
const [isOpen, setIsOpen] = (0, import_react9.useState)(false);
|
|
1010
|
+
const [allComponents, showAllComponents] = (0, import_react9.useState)(false);
|
|
1011
|
+
const { scrollCallback } = useSelectedNode();
|
|
1012
|
+
const selectStory = (0, import_react9.useCallback)(
|
|
966
1013
|
(id, refId) => {
|
|
967
1014
|
setSelection({ storyId: id, refId });
|
|
968
1015
|
inputRef.current?.blur();
|
|
969
1016
|
setIsOpen(false);
|
|
970
1017
|
showAllComponents(false);
|
|
971
|
-
|
|
1018
|
+
scrollCallback({ id, animated: false });
|
|
972
1019
|
},
|
|
973
|
-
[
|
|
1020
|
+
[scrollCallback, setSelection]
|
|
974
1021
|
);
|
|
975
|
-
const getItemProps = (0,
|
|
1022
|
+
const getItemProps = (0, import_react9.useCallback)(
|
|
976
1023
|
({ item: result }) => {
|
|
977
1024
|
return {
|
|
978
1025
|
icon: result?.item?.type === "component" ? "component" : "story",
|
|
979
|
-
result,
|
|
980
1026
|
onPress: () => {
|
|
981
1027
|
if (result?.item?.type === "story") {
|
|
982
1028
|
selectStory(result.item.id, result.item.refId);
|
|
@@ -987,7 +1033,6 @@ var Search = import_react8.default.memo(function Search2({ children, dataset, se
|
|
|
987
1033
|
}
|
|
988
1034
|
},
|
|
989
1035
|
score: result.score,
|
|
990
|
-
refIndex: result.refIndex,
|
|
991
1036
|
item: result.item,
|
|
992
1037
|
matches: result.matches,
|
|
993
1038
|
isHighlighted: false
|
|
@@ -995,65 +1040,71 @@ var Search = import_react8.default.memo(function Search2({ children, dataset, se
|
|
|
995
1040
|
},
|
|
996
1041
|
[selectStory]
|
|
997
1042
|
);
|
|
998
|
-
const
|
|
999
|
-
|
|
1043
|
+
const deferredDataset = (0, import_react9.useDeferredValue)(dataset);
|
|
1044
|
+
const searchList = (0, import_react9.useMemo)(() => {
|
|
1045
|
+
return deferredDataset.entries.reduce((acc, [refId, { index }]) => {
|
|
1000
1046
|
if (index) {
|
|
1001
1047
|
acc.push(
|
|
1002
1048
|
...Object.values(index).map((item) => {
|
|
1003
|
-
return (0, import_react_native_ui_common3.searchItem)(item,
|
|
1049
|
+
return (0, import_react_native_ui_common3.searchItem)(item, deferredDataset.hash[refId]);
|
|
1004
1050
|
})
|
|
1005
1051
|
);
|
|
1006
1052
|
}
|
|
1007
1053
|
return acc;
|
|
1008
1054
|
}, []);
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
const
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1055
|
+
}, [deferredDataset]);
|
|
1056
|
+
const deferredQuery = (0, import_react9.useDeferredValue)(inputValue);
|
|
1057
|
+
const queryText = (0, import_react9.useMemo)(() => deferredQuery ? deferredQuery.trim() : "", [deferredQuery]);
|
|
1058
|
+
const getText = (0, import_react9.useCallback)((item) => [item.name, item.path?.join(" ") ?? ""], []);
|
|
1059
|
+
const mapResultItem = (0, import_react9.useCallback)(
|
|
1060
|
+
({
|
|
1061
|
+
item,
|
|
1062
|
+
score,
|
|
1063
|
+
matches
|
|
1064
|
+
}) => ({
|
|
1065
|
+
item,
|
|
1066
|
+
score,
|
|
1067
|
+
matches: matches ?? []
|
|
1068
|
+
}),
|
|
1069
|
+
[]
|
|
1070
|
+
);
|
|
1071
|
+
const fuzzyResults = (0, import_react8.useFuzzySearchList)({
|
|
1072
|
+
list: searchList,
|
|
1073
|
+
queryText,
|
|
1074
|
+
getText,
|
|
1075
|
+
mapResultItem
|
|
1076
|
+
});
|
|
1077
|
+
const results = (0, import_react9.useMemo)(() => {
|
|
1078
|
+
if (!queryText) return [];
|
|
1079
|
+
const maxResults = allComponents ? 1e3 : DEFAULT_MAX_SEARCH_RESULTS;
|
|
1080
|
+
const processedResults = [];
|
|
1081
|
+
const resultIds = /* @__PURE__ */ new Set();
|
|
1082
|
+
let totalDistinctCount = 0;
|
|
1083
|
+
for (const result of fuzzyResults) {
|
|
1084
|
+
const { item } = result;
|
|
1085
|
+
if (!(item.type === "component" || item.type === "docs" || item.type === "story") || resultIds.has(item.parent)) {
|
|
1086
|
+
continue;
|
|
1033
1087
|
}
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
if (data && data.index && data.index[storyId]) {
|
|
1039
|
-
const story = data.index[storyId];
|
|
1040
|
-
const item = story.type === "story" ? data.index[story.parent] : story;
|
|
1041
|
-
if (!acc.some((res) => res.item.refId === refId && res.item.id === item.id)) {
|
|
1042
|
-
acc.push({ item: (0, import_react_native_ui_common3.searchItem)(item, dataset.hash[refId]), matches: [], score: 0 });
|
|
1043
|
-
}
|
|
1044
|
-
}
|
|
1045
|
-
return acc;
|
|
1046
|
-
}, []);
|
|
1088
|
+
resultIds.add(item.id);
|
|
1089
|
+
totalDistinctCount++;
|
|
1090
|
+
if (processedResults.length < maxResults) {
|
|
1091
|
+
processedResults.push(result);
|
|
1047
1092
|
}
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1093
|
+
if (allComponents && processedResults.length >= maxResults) {
|
|
1094
|
+
break;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
if (!allComponents && totalDistinctCount > DEFAULT_MAX_SEARCH_RESULTS) {
|
|
1098
|
+
processedResults.push({
|
|
1099
|
+
showAll: () => showAllComponents(true),
|
|
1100
|
+
totalCount: totalDistinctCount,
|
|
1101
|
+
moreCount: totalDistinctCount - DEFAULT_MAX_SEARCH_RESULTS
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
return processedResults;
|
|
1105
|
+
}, [queryText, fuzzyResults, allComponents]);
|
|
1106
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_native4.View, { style: flexStyle2, children: [
|
|
1107
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native4.View, { style: searchFieldWrapperStyle, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(SearchField, { children: [
|
|
1057
1108
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SearchIconWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SearchIcon, {}) }),
|
|
1058
1109
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1059
1110
|
Input,
|
|
@@ -1071,35 +1122,34 @@ var Search = import_react8.default.memo(function Search2({ children, dataset, se
|
|
|
1071
1122
|
setInputValue("");
|
|
1072
1123
|
inputRef.current.clear();
|
|
1073
1124
|
},
|
|
1074
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CloseIcon, {})
|
|
1125
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CloseIcon, { color: theme.textMutedColor })
|
|
1075
1126
|
}
|
|
1076
1127
|
)
|
|
1077
|
-
] }),
|
|
1078
|
-
children({
|
|
1079
|
-
query:
|
|
1128
|
+
] }) }),
|
|
1129
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native4.View, { style: flexStyle2, children: children({
|
|
1130
|
+
query: queryText,
|
|
1080
1131
|
results,
|
|
1081
1132
|
isBrowsing: !isOpen || !inputValue.length,
|
|
1082
1133
|
closeMenu: () => {
|
|
1083
1134
|
},
|
|
1084
1135
|
getItemProps,
|
|
1085
1136
|
highlightedIndex: null
|
|
1086
|
-
})
|
|
1137
|
+
}) })
|
|
1087
1138
|
] });
|
|
1088
1139
|
});
|
|
1089
1140
|
|
|
1090
1141
|
// src/SearchResults.tsx
|
|
1142
|
+
var import_list2 = require("@legendapp/list");
|
|
1091
1143
|
var import_react_native_theming6 = require("@storybook/react-native-theming");
|
|
1092
1144
|
var import_react_native_ui_common4 = require("@storybook/react-native-ui-common");
|
|
1093
1145
|
var import_polished2 = require("polished");
|
|
1094
|
-
var
|
|
1095
|
-
var
|
|
1146
|
+
var import_react10 = __toESM(require("react"));
|
|
1147
|
+
var import_react_native5 = require("react-native");
|
|
1148
|
+
var import_react_native_safe_area_context2 = require("react-native-safe-area-context");
|
|
1096
1149
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1097
|
-
var
|
|
1098
|
-
var
|
|
1099
|
-
|
|
1100
|
-
padding: 0,
|
|
1101
|
-
marginTop: 8
|
|
1102
|
-
});
|
|
1150
|
+
var isWeb = import_react_native5.Platform.OS === "web";
|
|
1151
|
+
var noResultsFirstLineStyle = { marginBottom: 4 };
|
|
1152
|
+
var flexStyle3 = { flex: 1 };
|
|
1103
1153
|
var ResultRow = import_react_native_theming6.styled.TouchableOpacity(
|
|
1104
1154
|
({ theme, isHighlighted }) => ({
|
|
1105
1155
|
width: "100%",
|
|
@@ -1112,10 +1162,10 @@ var ResultRow = import_react_native_theming6.styled.TouchableOpacity(
|
|
|
1112
1162
|
color: theme.color.defaultText,
|
|
1113
1163
|
fontSize: theme.typography.size.s2,
|
|
1114
1164
|
backgroundColor: isHighlighted ? theme.background.hoverable : "transparent",
|
|
1115
|
-
minHeight:
|
|
1165
|
+
minHeight: 34,
|
|
1116
1166
|
borderRadius: 4,
|
|
1117
1167
|
gap: 6,
|
|
1118
|
-
paddingTop:
|
|
1168
|
+
paddingTop: 8,
|
|
1119
1169
|
paddingBottom: 7,
|
|
1120
1170
|
paddingLeft: 8,
|
|
1121
1171
|
paddingRight: 8,
|
|
@@ -1134,11 +1184,16 @@ var ResultRowContent = import_react_native_theming6.styled.View(() => ({
|
|
|
1134
1184
|
}));
|
|
1135
1185
|
var NoResults = import_react_native_theming6.styled.View(({ theme }) => ({
|
|
1136
1186
|
marginTop: 20,
|
|
1137
|
-
|
|
1187
|
+
alignItems: "center",
|
|
1138
1188
|
fontSize: theme.typography.size.s2,
|
|
1139
1189
|
lineHeight: 18,
|
|
1140
1190
|
color: theme.color.defaultText
|
|
1141
1191
|
}));
|
|
1192
|
+
var NoResultsText = import_react_native_theming6.styled.Text(({ theme }) => ({
|
|
1193
|
+
fontSize: theme.typography.size.s2,
|
|
1194
|
+
color: theme.textMutedColor,
|
|
1195
|
+
textAlign: "center"
|
|
1196
|
+
}));
|
|
1142
1197
|
var Mark = import_react_native_theming6.styled.Text(({ theme }) => ({
|
|
1143
1198
|
backgroundColor: "transparent",
|
|
1144
1199
|
color: theme.color.secondary
|
|
@@ -1152,7 +1207,7 @@ var RecentlyOpenedTitle = import_react_native_theming6.styled.View(({ theme }) =
|
|
|
1152
1207
|
justifyContent: "space-between",
|
|
1153
1208
|
fontSize: theme.typography.size.s1 - 1,
|
|
1154
1209
|
fontWeight: theme.typography.weight.bold,
|
|
1155
|
-
minHeight:
|
|
1210
|
+
minHeight: 34,
|
|
1156
1211
|
// letterSpacing: '0.16em', <-- todo
|
|
1157
1212
|
textTransform: "uppercase",
|
|
1158
1213
|
color: theme.textMutedColor,
|
|
@@ -1160,28 +1215,29 @@ var RecentlyOpenedTitle = import_react_native_theming6.styled.View(({ theme }) =
|
|
|
1160
1215
|
marginBottom: 4,
|
|
1161
1216
|
alignItems: "center"
|
|
1162
1217
|
}));
|
|
1163
|
-
var Highlight =
|
|
1164
|
-
function Highlight2({ children,
|
|
1165
|
-
if (!
|
|
1166
|
-
const {
|
|
1167
|
-
const { nodes: result } = indices.reduce(
|
|
1218
|
+
var Highlight = import_react10.default.memo(
|
|
1219
|
+
function Highlight2({ children, text, ranges }) {
|
|
1220
|
+
if (!ranges || ranges.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { children: children ?? text });
|
|
1221
|
+
const { nodes: result } = ranges.reduce(
|
|
1168
1222
|
({ cursor, nodes }, [start, end], index, { length }) => {
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1223
|
+
if (cursor < start) {
|
|
1224
|
+
nodes.push(/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { children: text.slice(cursor, start) }, `text-${index}`));
|
|
1225
|
+
}
|
|
1226
|
+
nodes.push(/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Mark, { children: text.slice(start, end + 1) }, `mark-${index}`));
|
|
1227
|
+
if (index === length - 1 && end + 1 < text.length) {
|
|
1228
|
+
nodes.push(/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { children: text.slice(end + 1) }, `last-${index}`));
|
|
1173
1229
|
}
|
|
1174
1230
|
return { cursor: end + 1, nodes };
|
|
1175
1231
|
},
|
|
1176
1232
|
{ cursor: 0, nodes: [] }
|
|
1177
1233
|
);
|
|
1178
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { children: result }
|
|
1234
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { children: result });
|
|
1179
1235
|
}
|
|
1180
1236
|
);
|
|
1181
1237
|
var Title = import_react_native_theming6.styled.Text(({ theme }) => ({
|
|
1182
1238
|
justifyContent: "flex-start",
|
|
1183
1239
|
color: theme.textMutedColor,
|
|
1184
|
-
fontSize: theme.typography.size.s2
|
|
1240
|
+
fontSize: theme.typography.size.s2 + 1
|
|
1185
1241
|
}));
|
|
1186
1242
|
var Path = import_react_native_theming6.styled.View(({ theme }) => ({
|
|
1187
1243
|
justifyContent: "flex-start",
|
|
@@ -1194,46 +1250,38 @@ var PathText = import_react_native_theming6.styled.Text(({ theme }) => ({
|
|
|
1194
1250
|
fontSize: theme.typography.size.s1 - 1,
|
|
1195
1251
|
color: theme.textMutedColor
|
|
1196
1252
|
}));
|
|
1197
|
-
var Result =
|
|
1253
|
+
var Result = import_react10.default.memo(function Result2({
|
|
1198
1254
|
item,
|
|
1199
1255
|
matches,
|
|
1200
1256
|
icon: _icon,
|
|
1201
1257
|
onPress,
|
|
1202
1258
|
...props
|
|
1203
1259
|
}) {
|
|
1204
|
-
const
|
|
1260
|
+
const theme = (0, import_react_native_theming6.useTheme)();
|
|
1261
|
+
const press = (0, import_react10.useCallback)(
|
|
1205
1262
|
(event) => {
|
|
1206
1263
|
event.preventDefault();
|
|
1207
1264
|
onPress?.(event);
|
|
1208
1265
|
},
|
|
1209
1266
|
[onPress]
|
|
1210
1267
|
);
|
|
1211
|
-
const
|
|
1212
|
-
const
|
|
1268
|
+
const nameHighlights = matches?.[0];
|
|
1269
|
+
const pathString = item.path?.join(" ") ?? "";
|
|
1213
1270
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(ResultRow, { ...props, onPress: press, children: [
|
|
1214
1271
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(IconWrapper, { children: [
|
|
1215
|
-
item.type === "component" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ComponentIcon, { width: 14, height: 14 }),
|
|
1216
|
-
item.type === "story" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(StoryIcon, { width: 14, height: 14 })
|
|
1272
|
+
item.type === "component" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ComponentIcon, { width: 14, height: 14, color: theme.color.secondary }),
|
|
1273
|
+
item.type === "story" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(StoryIcon, { width: 14, height: 14, color: theme.color.seafoam })
|
|
1217
1274
|
] }),
|
|
1218
1275
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(ResultRowContent, { testID: "search-result-item--label", children: [
|
|
1219
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Title, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Highlight, {
|
|
1220
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Path, { children:
|
|
1221
|
-
const pathSeparator = index === item.path.length - 1 ? "" : "/";
|
|
1222
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native4.View, { style: { flexShrink: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PathText, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1223
|
-
Highlight,
|
|
1224
|
-
{
|
|
1225
|
-
match: pathMatches.find((match) => match.refIndex === index),
|
|
1226
|
-
children: `${group}${pathSeparator}`
|
|
1227
|
-
}
|
|
1228
|
-
) }) }, index);
|
|
1229
|
-
}) })
|
|
1276
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Title, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Highlight, { text: item.name, ranges: nameHighlights, children: item.name }) }),
|
|
1277
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Path, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PathText, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Highlight, { text: pathString, ranges: matches?.[1], children: item.path?.join(" / ") }) }) })
|
|
1230
1278
|
] })
|
|
1231
1279
|
] });
|
|
1232
1280
|
});
|
|
1233
1281
|
var Text = import_react_native_theming6.styled.Text(({ theme }) => ({
|
|
1234
1282
|
color: theme.color.defaultText
|
|
1235
1283
|
}));
|
|
1236
|
-
var SearchResults =
|
|
1284
|
+
var SearchResults = import_react10.default.memo(function SearchResults2({
|
|
1237
1285
|
query,
|
|
1238
1286
|
results,
|
|
1239
1287
|
closeMenu,
|
|
@@ -1241,70 +1289,140 @@ var SearchResults = import_react9.default.memo(function SearchResults2({
|
|
|
1241
1289
|
highlightedIndex,
|
|
1242
1290
|
clearLastViewed
|
|
1243
1291
|
}) {
|
|
1244
|
-
const
|
|
1292
|
+
const insets = (0, import_react_native_safe_area_context2.useSafeAreaInsets)();
|
|
1293
|
+
const handleClearLastViewed = (0, import_react10.useCallback)(() => {
|
|
1245
1294
|
clearLastViewed();
|
|
1246
1295
|
closeMenu();
|
|
1247
|
-
};
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1296
|
+
}, [clearLastViewed, closeMenu]);
|
|
1297
|
+
const contentContainerStyle2 = (0, import_react10.useMemo)(
|
|
1298
|
+
() => ({
|
|
1299
|
+
paddingHorizontal: 10,
|
|
1300
|
+
paddingTop: 8,
|
|
1301
|
+
paddingBottom: insets.bottom + 20
|
|
1302
|
+
}),
|
|
1303
|
+
[insets.bottom]
|
|
1304
|
+
);
|
|
1305
|
+
const listData = (0, import_react10.useMemo)(() => {
|
|
1306
|
+
const items = [];
|
|
1307
|
+
if (results.length > 0 && !query) {
|
|
1308
|
+
items.push({ type: "header", clearLastViewed: handleClearLastViewed });
|
|
1309
|
+
}
|
|
1310
|
+
if (results.length === 0 && query) {
|
|
1311
|
+
items.push({ type: "noResults" });
|
|
1312
|
+
}
|
|
1313
|
+
results.forEach((result, index) => {
|
|
1258
1314
|
if ((0, import_react_native_ui_common4.isExpandType)(result)) {
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
...result,
|
|
1263
|
-
...getItemProps({ key: `${index}`, index, item: result }),
|
|
1264
|
-
size: "small",
|
|
1265
|
-
text: `Show ${result.moreCount} more results`
|
|
1266
|
-
}
|
|
1267
|
-
) }, "search-result-expand");
|
|
1315
|
+
items.push({ type: "expand", result, index });
|
|
1316
|
+
} else {
|
|
1317
|
+
items.push({ type: "result", result, index });
|
|
1268
1318
|
}
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1319
|
+
});
|
|
1320
|
+
return items;
|
|
1321
|
+
}, [results, query, handleClearLastViewed]);
|
|
1322
|
+
const keyExtractor = (0, import_react10.useCallback)((item) => {
|
|
1323
|
+
switch (item.type) {
|
|
1324
|
+
case "header":
|
|
1325
|
+
return "header";
|
|
1326
|
+
case "noResults":
|
|
1327
|
+
return "no-results";
|
|
1328
|
+
case "expand":
|
|
1329
|
+
return "expand";
|
|
1330
|
+
case "result": {
|
|
1331
|
+
const { item: resultItem } = item.result;
|
|
1332
|
+
return `${resultItem.refId}::${resultItem.id}`;
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
}, []);
|
|
1336
|
+
const renderItem = (0, import_react10.useCallback)(
|
|
1337
|
+
({ item: listItem }) => {
|
|
1338
|
+
switch (listItem.type) {
|
|
1339
|
+
case "header":
|
|
1340
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(RecentlyOpenedTitle, { children: [
|
|
1341
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { children: "Recently opened" }),
|
|
1342
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native_ui_common4.IconButton, { onPress: listItem.clearLastViewed })
|
|
1343
|
+
] });
|
|
1344
|
+
case "noResults":
|
|
1345
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(NoResults, { children: [
|
|
1346
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(NoResultsText, { style: noResultsFirstLineStyle, children: "No components found" }),
|
|
1347
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(NoResultsText, { children: "Find components by name or path." })
|
|
1348
|
+
] });
|
|
1349
|
+
case "expand": {
|
|
1350
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(MoreWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1351
|
+
import_react_native_ui_common4.Button,
|
|
1352
|
+
{
|
|
1353
|
+
...listItem.result,
|
|
1354
|
+
...getItemProps({
|
|
1355
|
+
key: `${listItem.index}`,
|
|
1356
|
+
index: listItem.index,
|
|
1357
|
+
item: listItem.result
|
|
1358
|
+
}),
|
|
1359
|
+
size: "small",
|
|
1360
|
+
text: `Show ${listItem.result.moreCount} more results`
|
|
1361
|
+
}
|
|
1362
|
+
) });
|
|
1278
1363
|
}
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1364
|
+
case "result": {
|
|
1365
|
+
const { item: resultItem } = listItem.result;
|
|
1366
|
+
const key = `${resultItem.refId}::${resultItem.id}`;
|
|
1367
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1368
|
+
Result,
|
|
1369
|
+
{
|
|
1370
|
+
...listItem.result,
|
|
1371
|
+
...getItemProps({ key, index: listItem.index, item: listItem.result }),
|
|
1372
|
+
isHighlighted: highlightedIndex === listItem.index
|
|
1373
|
+
}
|
|
1374
|
+
);
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
},
|
|
1378
|
+
[getItemProps, highlightedIndex]
|
|
1379
|
+
);
|
|
1380
|
+
if (isWeb) {
|
|
1381
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native5.View, { style: flexStyle3, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { flex: 1, overflow: "auto", ...contentContainerStyle2 }, children: listData.map((item) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { children: renderItem({ item }) }, keyExtractor(item))) }) });
|
|
1382
|
+
}
|
|
1383
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native5.View, { style: flexStyle3, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1384
|
+
import_list2.LegendList,
|
|
1385
|
+
{
|
|
1386
|
+
style: flexStyle3,
|
|
1387
|
+
data: listData,
|
|
1388
|
+
renderItem,
|
|
1389
|
+
keyExtractor,
|
|
1390
|
+
contentContainerStyle: contentContainerStyle2,
|
|
1391
|
+
estimatedItemSize: 50,
|
|
1392
|
+
keyboardShouldPersistTaps: "handled",
|
|
1393
|
+
recycleItems: true
|
|
1394
|
+
}
|
|
1395
|
+
) });
|
|
1282
1396
|
});
|
|
1283
1397
|
|
|
1284
1398
|
// src/Sidebar.tsx
|
|
1285
1399
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1286
|
-
var
|
|
1287
|
-
|
|
1288
|
-
height: "100%",
|
|
1289
|
-
display: "flex",
|
|
1400
|
+
var Container = import_react_native_theming7.styled.View(({ theme }) => ({
|
|
1401
|
+
flex: 1,
|
|
1290
1402
|
flexDirection: "column",
|
|
1291
1403
|
backgroundColor: theme.background.content
|
|
1292
1404
|
}));
|
|
1293
1405
|
var Top = import_react_native_theming7.styled.View({
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
paddingTop: 16,
|
|
1297
|
-
flex: 1,
|
|
1298
|
-
flexDirection: "row"
|
|
1406
|
+
paddingTop: 8,
|
|
1407
|
+
flex: 1
|
|
1299
1408
|
});
|
|
1409
|
+
var flexStyle4 = { flex: 1 };
|
|
1410
|
+
var noneStyle = {
|
|
1411
|
+
// display: 'none',
|
|
1412
|
+
height: 1,
|
|
1413
|
+
width: 0,
|
|
1414
|
+
opacity: 0
|
|
1415
|
+
};
|
|
1300
1416
|
var Swap = import_react11.default.memo(function Swap2({
|
|
1301
1417
|
children,
|
|
1302
1418
|
condition
|
|
1303
1419
|
}) {
|
|
1304
1420
|
const [a, b] = import_react11.default.Children.toArray(children);
|
|
1421
|
+
const aStyle = (0, import_react11.useMemo)(() => condition ? flexStyle4 : noneStyle, [condition]);
|
|
1422
|
+
const bStyle = (0, import_react11.useMemo)(() => condition ? noneStyle : flexStyle4, [condition]);
|
|
1305
1423
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
1306
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1307
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1424
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native6.View, { style: aStyle, children: a }),
|
|
1425
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native6.View, { style: bStyle, children: b })
|
|
1308
1426
|
] });
|
|
1309
1427
|
});
|
|
1310
1428
|
var useCombination = (index, indexError, previewInitialized, status, refs) => {
|
|
@@ -1338,7 +1456,7 @@ var Sidebar = import_react11.default.memo(function Sidebar2({
|
|
|
1338
1456
|
const selected = (0, import_react11.useMemo)(() => storyId && { storyId, refId }, [storyId, refId]);
|
|
1339
1457
|
const dataset = useCombination(index, indexError, previewInitialized, status, refs);
|
|
1340
1458
|
const lastViewedProps = (0, import_react_native_ui_common5.useLastViewed)(selected);
|
|
1341
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1459
|
+
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: [
|
|
1342
1460
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1343
1461
|
Explorer,
|
|
1344
1462
|
{
|
|
@@ -1365,12 +1483,12 @@ var Sidebar = import_react11.default.memo(function Sidebar2({
|
|
|
1365
1483
|
});
|
|
1366
1484
|
|
|
1367
1485
|
// src/Layout.tsx
|
|
1368
|
-
var
|
|
1486
|
+
var import_portal2 = require("@gorhom/portal");
|
|
1369
1487
|
var import_react_native_theming10 = require("@storybook/react-native-theming");
|
|
1370
1488
|
var import_react_native_ui_common7 = require("@storybook/react-native-ui-common");
|
|
1371
1489
|
var import_react16 = require("react");
|
|
1372
|
-
var
|
|
1373
|
-
var
|
|
1490
|
+
var import_react_native11 = require("react-native");
|
|
1491
|
+
var import_react_native_safe_area_context4 = require("react-native-safe-area-context");
|
|
1374
1492
|
var import_core_events = require("storybook/internal/core-events");
|
|
1375
1493
|
var import_manager_api2 = require("storybook/manager-api");
|
|
1376
1494
|
|
|
@@ -1378,28 +1496,28 @@ var import_manager_api2 = require("storybook/manager-api");
|
|
|
1378
1496
|
var import_react_native_theming8 = require("@storybook/react-native-theming");
|
|
1379
1497
|
var import_react_native_ui_common6 = require("@storybook/react-native-ui-common");
|
|
1380
1498
|
var import_react13 = require("react");
|
|
1381
|
-
var
|
|
1499
|
+
var import_react_native8 = require("react-native");
|
|
1382
1500
|
var import_manager_api = require("storybook/manager-api");
|
|
1383
1501
|
var import_types = require("storybook/internal/types");
|
|
1384
1502
|
|
|
1385
1503
|
// src/useAnimatedValue.ts
|
|
1386
1504
|
var import_react12 = require("react");
|
|
1387
|
-
var
|
|
1505
|
+
var import_react_native7 = require("react-native");
|
|
1388
1506
|
function useAnimatedValue(initialValue, config) {
|
|
1389
1507
|
const ref = (0, import_react12.useRef)(null);
|
|
1390
1508
|
if (ref.current == null) {
|
|
1391
|
-
ref.current = new
|
|
1509
|
+
ref.current = new import_react_native7.Animated.Value(initialValue, config);
|
|
1392
1510
|
}
|
|
1393
1511
|
return ref.current;
|
|
1394
1512
|
}
|
|
1395
1513
|
|
|
1396
1514
|
// src/MobileAddonsPanel.tsx
|
|
1397
|
-
var
|
|
1515
|
+
var import_react_native_safe_area_context3 = require("react-native-safe-area-context");
|
|
1398
1516
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1399
1517
|
var MobileAddonsPanel = (0, import_react13.forwardRef)(
|
|
1400
1518
|
({ storyId }, ref) => {
|
|
1401
1519
|
const theme = (0, import_react_native_theming8.useTheme)();
|
|
1402
|
-
const { height } = (0,
|
|
1520
|
+
const { height } = (0, import_react_native8.useWindowDimensions)();
|
|
1403
1521
|
const panelHeight = useAnimatedValue(0);
|
|
1404
1522
|
const positionBottomAnimation = useAnimatedValue(height / 2);
|
|
1405
1523
|
const [isOpen, setIsOpen] = (0, import_react13.useState)(false);
|
|
@@ -1407,34 +1525,34 @@ var MobileAddonsPanel = (0, import_react13.forwardRef)(
|
|
|
1407
1525
|
(open) => {
|
|
1408
1526
|
setIsOpen(open);
|
|
1409
1527
|
if (open) {
|
|
1410
|
-
|
|
1411
|
-
|
|
1528
|
+
import_react_native8.Animated.parallel([
|
|
1529
|
+
import_react_native8.Animated.timing(positionBottomAnimation, {
|
|
1412
1530
|
toValue: 0,
|
|
1413
1531
|
// Negative to move up
|
|
1414
1532
|
duration: 350,
|
|
1415
1533
|
useNativeDriver: false,
|
|
1416
|
-
easing:
|
|
1534
|
+
easing: import_react_native8.Easing.inOut(import_react_native8.Easing.cubic)
|
|
1417
1535
|
}),
|
|
1418
|
-
|
|
1536
|
+
import_react_native8.Animated.timing(panelHeight, {
|
|
1419
1537
|
toValue: height / 2,
|
|
1420
1538
|
duration: 350,
|
|
1421
1539
|
useNativeDriver: false,
|
|
1422
|
-
easing:
|
|
1540
|
+
easing: import_react_native8.Easing.inOut(import_react_native8.Easing.cubic)
|
|
1423
1541
|
})
|
|
1424
1542
|
]).start();
|
|
1425
1543
|
} else {
|
|
1426
|
-
|
|
1427
|
-
|
|
1544
|
+
import_react_native8.Animated.parallel([
|
|
1545
|
+
import_react_native8.Animated.timing(positionBottomAnimation, {
|
|
1428
1546
|
toValue: height / 2,
|
|
1429
1547
|
duration: 350,
|
|
1430
1548
|
useNativeDriver: false,
|
|
1431
|
-
easing:
|
|
1549
|
+
easing: import_react_native8.Easing.inOut(import_react_native8.Easing.cubic)
|
|
1432
1550
|
}),
|
|
1433
|
-
|
|
1551
|
+
import_react_native8.Animated.timing(panelHeight, {
|
|
1434
1552
|
toValue: 0,
|
|
1435
1553
|
duration: 350,
|
|
1436
1554
|
useNativeDriver: false,
|
|
1437
|
-
easing:
|
|
1555
|
+
easing: import_react_native8.Easing.inOut(import_react_native8.Easing.cubic)
|
|
1438
1556
|
})
|
|
1439
1557
|
]).start();
|
|
1440
1558
|
}
|
|
@@ -1444,46 +1562,46 @@ var MobileAddonsPanel = (0, import_react13.forwardRef)(
|
|
|
1444
1562
|
(0, import_react13.useEffect)(() => {
|
|
1445
1563
|
const handleKeyboardShow = ({ endCoordinates, duration, easing }) => {
|
|
1446
1564
|
if (isOpen) {
|
|
1447
|
-
|
|
1448
|
-
|
|
1565
|
+
import_react_native8.Animated.parallel([
|
|
1566
|
+
import_react_native8.Animated.timing(panelHeight, {
|
|
1449
1567
|
toValue: (height - endCoordinates.height) / 2,
|
|
1450
1568
|
duration,
|
|
1451
1569
|
useNativeDriver: false,
|
|
1452
|
-
easing:
|
|
1570
|
+
easing: import_react_native8.Easing[easing] || import_react_native8.Easing.out(import_react_native8.Easing.ease)
|
|
1453
1571
|
}),
|
|
1454
|
-
|
|
1572
|
+
import_react_native8.Animated.timing(positionBottomAnimation, {
|
|
1455
1573
|
toValue: -endCoordinates.height,
|
|
1456
1574
|
// Negative to move up
|
|
1457
1575
|
duration,
|
|
1458
1576
|
useNativeDriver: false,
|
|
1459
|
-
easing:
|
|
1577
|
+
easing: import_react_native8.Easing[easing] || import_react_native8.Easing.out(import_react_native8.Easing.ease)
|
|
1460
1578
|
})
|
|
1461
1579
|
]).start();
|
|
1462
1580
|
}
|
|
1463
1581
|
};
|
|
1464
1582
|
const handleKeyboardHide = ({ duration, easing }) => {
|
|
1465
1583
|
if (isOpen) {
|
|
1466
|
-
|
|
1467
|
-
|
|
1584
|
+
import_react_native8.Animated.parallel([
|
|
1585
|
+
import_react_native8.Animated.timing(positionBottomAnimation, {
|
|
1468
1586
|
toValue: 0,
|
|
1469
1587
|
// Back to original position
|
|
1470
1588
|
duration,
|
|
1471
1589
|
useNativeDriver: false,
|
|
1472
|
-
easing:
|
|
1590
|
+
easing: import_react_native8.Easing[easing] || import_react_native8.Easing.out(import_react_native8.Easing.ease)
|
|
1473
1591
|
}),
|
|
1474
|
-
|
|
1592
|
+
import_react_native8.Animated.timing(panelHeight, {
|
|
1475
1593
|
toValue: height / 2,
|
|
1476
1594
|
duration,
|
|
1477
1595
|
useNativeDriver: false,
|
|
1478
|
-
easing:
|
|
1596
|
+
easing: import_react_native8.Easing[easing] || import_react_native8.Easing.out(import_react_native8.Easing.ease)
|
|
1479
1597
|
})
|
|
1480
1598
|
]).start();
|
|
1481
1599
|
}
|
|
1482
1600
|
};
|
|
1483
|
-
const showSubscription =
|
|
1484
|
-
const willShowSubscription =
|
|
1485
|
-
const hideSubscription =
|
|
1486
|
-
const didHideSubscription =
|
|
1601
|
+
const showSubscription = import_react_native8.Keyboard.addListener("keyboardDidShow", handleKeyboardShow);
|
|
1602
|
+
const willShowSubscription = import_react_native8.Keyboard.addListener("keyboardWillShow", handleKeyboardShow);
|
|
1603
|
+
const hideSubscription = import_react_native8.Keyboard.addListener("keyboardWillHide", handleKeyboardHide);
|
|
1604
|
+
const didHideSubscription = import_react_native8.Keyboard.addListener("keyboardDidHide", handleKeyboardHide);
|
|
1487
1605
|
return () => {
|
|
1488
1606
|
showSubscription.remove();
|
|
1489
1607
|
willShowSubscription.remove();
|
|
@@ -1501,7 +1619,7 @@ var MobileAddonsPanel = (0, import_react13.forwardRef)(
|
|
|
1501
1619
|
}
|
|
1502
1620
|
}));
|
|
1503
1621
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1504
|
-
|
|
1622
|
+
import_react_native8.Animated.View,
|
|
1505
1623
|
{
|
|
1506
1624
|
style: {
|
|
1507
1625
|
position: "absolute",
|
|
@@ -1512,13 +1630,13 @@ var MobileAddonsPanel = (0, import_react13.forwardRef)(
|
|
|
1512
1630
|
transform: [{ translateY: positionBottomAnimation }]
|
|
1513
1631
|
},
|
|
1514
1632
|
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1515
|
-
|
|
1633
|
+
import_react_native8.View,
|
|
1516
1634
|
{
|
|
1517
1635
|
style: {
|
|
1518
1636
|
justifyContent: "flex-end"
|
|
1519
1637
|
},
|
|
1520
1638
|
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1521
|
-
|
|
1639
|
+
import_react_native8.View,
|
|
1522
1640
|
{
|
|
1523
1641
|
style: {
|
|
1524
1642
|
height: "100%",
|
|
@@ -1526,14 +1644,14 @@ var MobileAddonsPanel = (0, import_react13.forwardRef)(
|
|
|
1526
1644
|
paddingTop: 10,
|
|
1527
1645
|
borderTopColor: theme.appBorderColor,
|
|
1528
1646
|
borderTopWidth: 1,
|
|
1529
|
-
paddingBottom:
|
|
1647
|
+
paddingBottom: import_react_native8.Platform.OS === "android" ? 16 : 0
|
|
1530
1648
|
},
|
|
1531
1649
|
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1532
1650
|
AddonsTabs,
|
|
1533
1651
|
{
|
|
1534
1652
|
onClose: () => {
|
|
1535
1653
|
setMobileMenuOpen(false);
|
|
1536
|
-
|
|
1654
|
+
import_react_native8.Keyboard.dismiss();
|
|
1537
1655
|
},
|
|
1538
1656
|
storyId
|
|
1539
1657
|
}
|
|
@@ -1574,14 +1692,14 @@ var centeredStyle = {
|
|
|
1574
1692
|
var hitSlop = { top: 10, right: 10, bottom: 10, left: 10 };
|
|
1575
1693
|
var AddonsTabs = ({ onClose, storyId }) => {
|
|
1576
1694
|
const panels = import_manager_api.addons.getElements(import_types.Addon_TypesEnum.PANEL);
|
|
1577
|
-
const insets = (0,
|
|
1695
|
+
const insets = (0, import_react_native_safe_area_context3.useSafeAreaInsets)();
|
|
1578
1696
|
const [addonSelected, setAddonSelected] = (0, import_react13.useState)(Object.keys(panels)[0]);
|
|
1579
1697
|
const panel = (0, import_react13.useMemo)(() => {
|
|
1580
1698
|
if (!storyId) {
|
|
1581
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1699
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native8.View, { style: centeredStyle, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native8.Text, { children: "No Story Selected" }) });
|
|
1582
1700
|
}
|
|
1583
1701
|
if (Object.keys(panels).length === 0) {
|
|
1584
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1702
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native8.View, { style: centeredStyle, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native8.Text, { children: "No addons loaded." }) });
|
|
1585
1703
|
}
|
|
1586
1704
|
return panels[addonSelected].render({ active: true });
|
|
1587
1705
|
}, [addonSelected, panels, storyId]);
|
|
@@ -1591,10 +1709,10 @@ var AddonsTabs = ({ onClose, storyId }) => {
|
|
|
1591
1709
|
}),
|
|
1592
1710
|
[insets]
|
|
1593
1711
|
);
|
|
1594
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1595
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1712
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_native8.View, { style: addonsTabsContainerStyle, children: [
|
|
1713
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_native8.View, { style: addonsTabsStyle, children: [
|
|
1596
1714
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1597
|
-
|
|
1715
|
+
import_react_native8.ScrollView,
|
|
1598
1716
|
{
|
|
1599
1717
|
horizontal: true,
|
|
1600
1718
|
showsHorizontalScrollIndicator: false,
|
|
@@ -1625,7 +1743,7 @@ var AddonsTabs = ({ onClose, storyId }) => {
|
|
|
1625
1743
|
)
|
|
1626
1744
|
] }),
|
|
1627
1745
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1628
|
-
|
|
1746
|
+
import_react_native8.ScrollView,
|
|
1629
1747
|
{
|
|
1630
1748
|
style: addonsScrollStyle,
|
|
1631
1749
|
contentContainerStyle: scrollContentContainerStyle,
|
|
@@ -1655,51 +1773,64 @@ var TabText = import_react_native_theming8.styled.Text(({ theme, active }) => ({
|
|
|
1655
1773
|
}));
|
|
1656
1774
|
|
|
1657
1775
|
// src/MobileMenuDrawer.tsx
|
|
1776
|
+
var import_portal = require("@gorhom/portal");
|
|
1658
1777
|
var import_react_native_theming9 = require("@storybook/react-native-theming");
|
|
1659
1778
|
var import_react14 = require("react");
|
|
1660
|
-
var
|
|
1779
|
+
var import_react_native9 = require("react-native");
|
|
1661
1780
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1781
|
+
var flexStyle5 = { flex: 1 };
|
|
1782
|
+
var portalContainerStyle = {
|
|
1783
|
+
flex: 1,
|
|
1784
|
+
position: "absolute",
|
|
1785
|
+
top: 0,
|
|
1786
|
+
left: 0,
|
|
1787
|
+
right: 0,
|
|
1788
|
+
bottom: 0,
|
|
1789
|
+
zIndex: 1e3
|
|
1790
|
+
};
|
|
1662
1791
|
var useAnimatedModalHeight = () => {
|
|
1663
|
-
const { height } = (0,
|
|
1792
|
+
const { height } = (0, import_react_native9.useWindowDimensions)();
|
|
1664
1793
|
const animatedHeight = useAnimatedValue(0.65 * height);
|
|
1665
1794
|
(0, import_react14.useEffect)(() => {
|
|
1666
1795
|
const modalHeight = 0.65 * height;
|
|
1667
1796
|
const maxModalHeight = 0.85 * height;
|
|
1668
|
-
const expand = (duration = 250) =>
|
|
1797
|
+
const expand = (duration = 250) => import_react_native9.Animated.timing(animatedHeight, {
|
|
1669
1798
|
toValue: maxModalHeight,
|
|
1670
1799
|
duration,
|
|
1800
|
+
easing: import_react_native9.Easing.out(import_react_native9.Easing.quad),
|
|
1671
1801
|
useNativeDriver: false
|
|
1672
1802
|
}).start();
|
|
1673
|
-
const collapse = (duration = 250) =>
|
|
1803
|
+
const collapse = (duration = 250) => import_react_native9.Animated.timing(animatedHeight, {
|
|
1674
1804
|
toValue: modalHeight,
|
|
1675
1805
|
duration,
|
|
1806
|
+
easing: import_react_native9.Easing.out(import_react_native9.Easing.quad),
|
|
1676
1807
|
useNativeDriver: false
|
|
1677
1808
|
}).start();
|
|
1678
1809
|
const handleKeyboardWillShow = (e) => {
|
|
1679
|
-
if (
|
|
1810
|
+
if (import_react_native9.Platform.OS === "ios") {
|
|
1680
1811
|
expand(e.duration);
|
|
1681
1812
|
}
|
|
1682
1813
|
};
|
|
1683
1814
|
const handleKeyboardDidShow = (e) => {
|
|
1684
|
-
if (
|
|
1815
|
+
if (import_react_native9.Platform.OS === "android") {
|
|
1685
1816
|
expand();
|
|
1686
1817
|
}
|
|
1687
1818
|
};
|
|
1688
1819
|
const handleKeyboardWillHide = (e) => {
|
|
1689
|
-
if (
|
|
1820
|
+
if (import_react_native9.Platform.OS === "ios") {
|
|
1690
1821
|
collapse(e.duration);
|
|
1691
1822
|
}
|
|
1692
1823
|
};
|
|
1693
1824
|
const handleKeyboardDidHide = (e) => {
|
|
1694
|
-
if (
|
|
1825
|
+
if (import_react_native9.Platform.OS === "android") {
|
|
1695
1826
|
collapse();
|
|
1696
1827
|
}
|
|
1697
1828
|
};
|
|
1698
1829
|
const subscriptions = [
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1830
|
+
import_react_native9.Keyboard.addListener("keyboardWillShow", handleKeyboardWillShow),
|
|
1831
|
+
import_react_native9.Keyboard.addListener("keyboardDidShow", handleKeyboardDidShow),
|
|
1832
|
+
import_react_native9.Keyboard.addListener("keyboardWillHide", handleKeyboardWillHide),
|
|
1833
|
+
import_react_native9.Keyboard.addListener("keyboardDidHide", handleKeyboardDidHide)
|
|
1703
1834
|
];
|
|
1704
1835
|
return () => {
|
|
1705
1836
|
subscriptions.forEach((subscription) => subscription.remove());
|
|
@@ -1709,13 +1840,43 @@ var useAnimatedModalHeight = () => {
|
|
|
1709
1840
|
};
|
|
1710
1841
|
var MobileMenuDrawer = (0, import_react14.memo)(
|
|
1711
1842
|
(0, import_react14.forwardRef)(({ children }, ref) => {
|
|
1712
|
-
const [
|
|
1713
|
-
const {
|
|
1843
|
+
const [isVisible, setIsVisible] = (0, import_react14.useState)(false);
|
|
1844
|
+
const { scrollCallback } = useSelectedNode();
|
|
1714
1845
|
const theme = (0, import_react_native_theming9.useTheme)();
|
|
1846
|
+
const { height } = (0, import_react_native9.useWindowDimensions)();
|
|
1715
1847
|
const animatedHeight = useAnimatedModalHeight();
|
|
1848
|
+
const slideAnim = useAnimatedValue(height);
|
|
1716
1849
|
const dragY = useAnimatedValue(0);
|
|
1717
|
-
const
|
|
1718
|
-
|
|
1850
|
+
const openDrawer = (0, import_react14.useCallback)(() => {
|
|
1851
|
+
dragY.setValue(0);
|
|
1852
|
+
slideAnim.setValue(height);
|
|
1853
|
+
setIsVisible(true);
|
|
1854
|
+
import_react_native9.Animated.timing(slideAnim, {
|
|
1855
|
+
toValue: 0,
|
|
1856
|
+
duration: 300,
|
|
1857
|
+
easing: import_react_native9.Easing.out(import_react_native9.Easing.quad),
|
|
1858
|
+
useNativeDriver: true
|
|
1859
|
+
}).start(({ finished }) => {
|
|
1860
|
+
if (finished) {
|
|
1861
|
+
scrollCallback({ animated: false, id: void 0 });
|
|
1862
|
+
}
|
|
1863
|
+
});
|
|
1864
|
+
}, [dragY, height, scrollCallback, slideAnim]);
|
|
1865
|
+
const closeDrawer = (0, import_react14.useCallback)(() => {
|
|
1866
|
+
import_react_native9.Keyboard.dismiss();
|
|
1867
|
+
import_react_native9.Animated.timing(slideAnim, {
|
|
1868
|
+
toValue: height,
|
|
1869
|
+
duration: 300,
|
|
1870
|
+
easing: import_react_native9.Easing.in(import_react_native9.Easing.quad),
|
|
1871
|
+
useNativeDriver: true
|
|
1872
|
+
}).start(({ finished }) => {
|
|
1873
|
+
if (finished) {
|
|
1874
|
+
setIsVisible(false);
|
|
1875
|
+
}
|
|
1876
|
+
});
|
|
1877
|
+
}, [height, slideAnim]);
|
|
1878
|
+
const panResponder = (0, import_react14.useMemo)(
|
|
1879
|
+
() => import_react_native9.PanResponder.create({
|
|
1719
1880
|
onStartShouldSetPanResponder: () => true,
|
|
1720
1881
|
onMoveShouldSetPanResponder: (_, gestureState) => {
|
|
1721
1882
|
return gestureState.dy > 0;
|
|
@@ -1727,26 +1888,25 @@ var MobileMenuDrawer = (0, import_react14.memo)(
|
|
|
1727
1888
|
},
|
|
1728
1889
|
onPanResponderRelease: (_, gestureState) => {
|
|
1729
1890
|
if (gestureState.dy > 50) {
|
|
1730
|
-
|
|
1731
|
-
|
|
1891
|
+
closeDrawer();
|
|
1892
|
+
} else {
|
|
1893
|
+
import_react_native9.Animated.timing(dragY, {
|
|
1894
|
+
toValue: 0,
|
|
1895
|
+
duration: 300,
|
|
1896
|
+
easing: import_react_native9.Easing.out(import_react_native9.Easing.quad),
|
|
1897
|
+
useNativeDriver: true
|
|
1898
|
+
}).start();
|
|
1732
1899
|
}
|
|
1733
|
-
import_react_native8.Animated.timing(dragY, {
|
|
1734
|
-
toValue: 0,
|
|
1735
|
-
duration: 300,
|
|
1736
|
-
useNativeDriver: true
|
|
1737
|
-
}).start();
|
|
1738
1900
|
}
|
|
1739
|
-
})
|
|
1740
|
-
|
|
1901
|
+
}),
|
|
1902
|
+
[closeDrawer, dragY]
|
|
1903
|
+
);
|
|
1741
1904
|
(0, import_react14.useImperativeHandle)(ref, () => ({
|
|
1742
1905
|
setMobileMenuOpen: (open) => {
|
|
1743
1906
|
if (open) {
|
|
1744
|
-
|
|
1745
|
-
scrollToSelectedNode();
|
|
1746
|
-
setMobileMenuOpen(true);
|
|
1907
|
+
openDrawer();
|
|
1747
1908
|
} else {
|
|
1748
|
-
|
|
1749
|
-
setMobileMenuOpen(false);
|
|
1909
|
+
closeDrawer();
|
|
1750
1910
|
}
|
|
1751
1911
|
}
|
|
1752
1912
|
}));
|
|
@@ -1756,76 +1916,67 @@ var MobileMenuDrawer = (0, import_react14.memo)(
|
|
|
1756
1916
|
height: 5,
|
|
1757
1917
|
backgroundColor: theme.color.mediumdark,
|
|
1758
1918
|
borderRadius: 2.5,
|
|
1759
|
-
alignSelf: "center"
|
|
1760
|
-
// TypeScript needs this to recognize 'center' as a valid FlexAlignType
|
|
1761
|
-
marginVertical: 8
|
|
1919
|
+
alignSelf: "center"
|
|
1762
1920
|
}),
|
|
1763
1921
|
[theme.color.mediumdark]
|
|
1764
1922
|
);
|
|
1765
|
-
|
|
1766
|
-
|
|
1923
|
+
const drawerContainerStyle = (0, import_react14.useMemo)(
|
|
1924
|
+
() => ({
|
|
1925
|
+
flex: 1,
|
|
1926
|
+
borderTopColor: theme.appBorderColor,
|
|
1927
|
+
borderTopWidth: 1,
|
|
1928
|
+
borderStyle: "solid",
|
|
1929
|
+
backgroundColor: theme.background.content,
|
|
1930
|
+
elevation: 8,
|
|
1931
|
+
boxShadow: `0 16px 32px 0 ${theme.color.border}`
|
|
1932
|
+
}),
|
|
1933
|
+
[theme.appBorderColor, theme.background.content, theme.color.border]
|
|
1934
|
+
);
|
|
1935
|
+
const dragHandleWrapperStyle = (0, import_react14.useMemo)(
|
|
1936
|
+
() => ({
|
|
1937
|
+
alignItems: "center",
|
|
1938
|
+
justifyContent: "center",
|
|
1939
|
+
paddingBottom: 16,
|
|
1940
|
+
paddingTop: 10,
|
|
1941
|
+
backgroundColor: theme.background.content
|
|
1942
|
+
}),
|
|
1943
|
+
[theme.background.content]
|
|
1944
|
+
);
|
|
1945
|
+
const childrenWrapperStyle = (0, import_react14.useMemo)(
|
|
1946
|
+
() => ({
|
|
1947
|
+
flex: 1,
|
|
1948
|
+
backgroundColor: theme.background.content
|
|
1949
|
+
}),
|
|
1950
|
+
[theme.background.content]
|
|
1951
|
+
);
|
|
1952
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_portal.Portal, { hostName: "storybook-lite-ui-root", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1953
|
+
import_react_native9.Animated.View,
|
|
1767
1954
|
{
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native8.View, { style: { flex: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native8.Pressable, { style: { flex: 1 }, onPress: () => setMobileMenuOpen(false) }) }),
|
|
1775
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native8.Animated.View, { style: { height: animatedHeight }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1776
|
-
import_react_native8.Animated.View,
|
|
1955
|
+
style: [portalContainerStyle, { transform: [{ translateY: slideAnim }] }],
|
|
1956
|
+
pointerEvents: isVisible ? "auto" : "none",
|
|
1957
|
+
children: [
|
|
1958
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native9.View, { style: flexStyle5, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native9.Pressable, { style: flexStyle5, onPress: closeDrawer }) }),
|
|
1959
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1960
|
+
import_react_native9.Animated.View,
|
|
1777
1961
|
{
|
|
1778
|
-
style:
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
elevation: 8
|
|
1786
|
-
},
|
|
1787
|
-
{ transform: [{ translateY: dragY }] }
|
|
1788
|
-
],
|
|
1789
|
-
children: [
|
|
1790
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1791
|
-
import_react_native8.View,
|
|
1792
|
-
{
|
|
1793
|
-
...panResponder.panHandlers,
|
|
1794
|
-
style: {
|
|
1795
|
-
alignItems: "center",
|
|
1796
|
-
justifyContent: "center",
|
|
1797
|
-
backgroundColor: theme.background.content
|
|
1798
|
-
},
|
|
1799
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native8.View, { style: handleStyle })
|
|
1800
|
-
}
|
|
1801
|
-
),
|
|
1802
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1803
|
-
import_react_native8.ScrollView,
|
|
1804
|
-
{
|
|
1805
|
-
ref: scrollRef,
|
|
1806
|
-
keyboardShouldPersistTaps: "handled",
|
|
1807
|
-
style: {
|
|
1808
|
-
flex: 1,
|
|
1809
|
-
paddingBottom: 150,
|
|
1810
|
-
alignSelf: "flex-end",
|
|
1811
|
-
width: "100%",
|
|
1812
|
-
backgroundColor: theme.background.content
|
|
1813
|
-
},
|
|
1814
|
-
children
|
|
1815
|
-
}
|
|
1816
|
-
)
|
|
1817
|
-
]
|
|
1962
|
+
style: {
|
|
1963
|
+
height: animatedHeight
|
|
1964
|
+
},
|
|
1965
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react_native9.Animated.View, { style: [drawerContainerStyle, { transform: [{ translateY: dragY }] }], children: [
|
|
1966
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native9.View, { ...panResponder.panHandlers, style: dragHandleWrapperStyle, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native9.View, { style: handleStyle }) }),
|
|
1967
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native9.View, { style: childrenWrapperStyle, children })
|
|
1968
|
+
] })
|
|
1818
1969
|
}
|
|
1819
|
-
)
|
|
1820
|
-
]
|
|
1970
|
+
)
|
|
1971
|
+
]
|
|
1821
1972
|
}
|
|
1822
|
-
);
|
|
1973
|
+
) });
|
|
1823
1974
|
})
|
|
1824
1975
|
);
|
|
1825
1976
|
|
|
1826
1977
|
// src/StorybookLogo.tsx
|
|
1827
1978
|
var import_react15 = require("react");
|
|
1828
|
-
var
|
|
1979
|
+
var import_react_native10 = require("react-native");
|
|
1829
1980
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1830
1981
|
var WIDTH = 125;
|
|
1831
1982
|
var HEIGHT = 25;
|
|
@@ -1849,7 +2000,7 @@ var BrandLogo = ({ theme }) => {
|
|
|
1849
2000
|
return theme.brand.image;
|
|
1850
2001
|
}
|
|
1851
2002
|
const image = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1852
|
-
|
|
2003
|
+
import_react_native10.Image,
|
|
1853
2004
|
{
|
|
1854
2005
|
source: theme.brand.image,
|
|
1855
2006
|
resizeMode: theme.brand.resizeMode ?? "contain",
|
|
@@ -1858,10 +2009,10 @@ var BrandLogo = ({ theme }) => {
|
|
|
1858
2009
|
);
|
|
1859
2010
|
if (theme.brand.url) {
|
|
1860
2011
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1861
|
-
|
|
2012
|
+
import_react_native10.TouchableOpacity,
|
|
1862
2013
|
{
|
|
1863
2014
|
onPress: () => {
|
|
1864
|
-
if (theme.brand.url)
|
|
2015
|
+
if (theme.brand.url) import_react_native10.Linking.openURL(theme.brand.url);
|
|
1865
2016
|
},
|
|
1866
2017
|
children: image
|
|
1867
2018
|
}
|
|
@@ -1879,13 +2030,13 @@ var BrandTitle = ({ theme }) => {
|
|
|
1879
2030
|
fontSize: theme.typography.size.m1
|
|
1880
2031
|
};
|
|
1881
2032
|
}, [theme]);
|
|
1882
|
-
const title = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2033
|
+
const title = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native10.Text, { style: brandTitleStyle, numberOfLines: 1, ellipsizeMode: "tail", children: theme.brand.title });
|
|
1883
2034
|
if (theme.brand.url) {
|
|
1884
2035
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1885
|
-
|
|
2036
|
+
import_react_native10.TouchableOpacity,
|
|
1886
2037
|
{
|
|
1887
2038
|
onPress: () => {
|
|
1888
|
-
if (theme.brand.url)
|
|
2039
|
+
if (theme.brand.url) import_react_native10.Linking.openURL(theme.brand.url);
|
|
1889
2040
|
},
|
|
1890
2041
|
children: title
|
|
1891
2042
|
}
|
|
@@ -1921,17 +2072,18 @@ var contentContainerStyle = { flex: 1, overflow: "hidden" };
|
|
|
1921
2072
|
var mobileContentStyle = { flex: 1, overflow: "hidden" };
|
|
1922
2073
|
var placeholderObject = {};
|
|
1923
2074
|
var iconFloatRightStyle = { marginLeft: "auto" };
|
|
1924
|
-
var navButtonStyle = {
|
|
1925
|
-
var navButtonHitSlop = { bottom: 10, left: 10,
|
|
2075
|
+
var navButtonStyle = { flex: 1 };
|
|
2076
|
+
var navButtonHitSlop = { bottom: 10, left: 10, top: 10 };
|
|
2077
|
+
var addonButtonHitSlop = { bottom: 10, left: 10, right: 10, top: 10 };
|
|
1926
2078
|
var mobileMenuDrawerContentStyle = {
|
|
1927
2079
|
paddingLeft: 16,
|
|
1928
|
-
paddingTop: 4,
|
|
1929
2080
|
paddingBottom: 4
|
|
1930
2081
|
};
|
|
1931
|
-
var
|
|
2082
|
+
var flexStyle6 = { flex: 1 };
|
|
2083
|
+
var LiteUI = ({ storage, theme, storyHash, story, children }) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native_safe_area_context4.SafeAreaProvider, { style: flexStyle6, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SelectedNodeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native_theming10.ThemeProvider, { theme, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native_ui_common7.StorageProvider, { storage, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native_ui_common7.LayoutProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_portal2.PortalProvider, { shouldAddRootHost: false, children: [
|
|
1932
2084
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Layout, { storyHash, story, children }),
|
|
1933
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1934
|
-
] }) }) }) }) });
|
|
2085
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_portal2.PortalHost, { name: "storybook-lite-ui-root" })
|
|
2086
|
+
] }) }) }) }) }) });
|
|
1935
2087
|
var Layout = ({
|
|
1936
2088
|
storyHash,
|
|
1937
2089
|
story,
|
|
@@ -1939,7 +2091,7 @@ var Layout = ({
|
|
|
1939
2091
|
}) => {
|
|
1940
2092
|
const theme = (0, import_react_native_theming10.useTheme)();
|
|
1941
2093
|
const { isDesktop } = (0, import_react_native_ui_common7.useLayout)();
|
|
1942
|
-
const insets = (0,
|
|
2094
|
+
const insets = (0, import_react_native_safe_area_context4.useSafeAreaInsets)();
|
|
1943
2095
|
const [desktopSidebarOpen, setDesktopSidebarOpen] = (0, import_react_native_ui_common7.useStoreBooleanState)(
|
|
1944
2096
|
"desktopSidebarState",
|
|
1945
2097
|
true
|
|
@@ -1971,7 +2123,7 @@ var Layout = ({
|
|
|
1971
2123
|
}),
|
|
1972
2124
|
[desktopAddonsPanelOpen, theme.appBorderColor]
|
|
1973
2125
|
);
|
|
1974
|
-
const
|
|
2126
|
+
const containerStyle2 = (0, import_react_native_ui_common7.useStyle)(() => {
|
|
1975
2127
|
if (isDesktop) {
|
|
1976
2128
|
return {
|
|
1977
2129
|
flex: 1,
|
|
@@ -2017,13 +2169,13 @@ var Layout = ({
|
|
|
2017
2169
|
const channel = import_manager_api2.addons.getChannel();
|
|
2018
2170
|
channel.emit(import_core_events.SET_CURRENT_STORY, { storyId: newStoryId });
|
|
2019
2171
|
}, []);
|
|
2020
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2021
|
-
isDesktop ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2022
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2172
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native11.View, { style: containerStyle2, children: [
|
|
2173
|
+
isDesktop ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native11.View, { style: desktopSidebarStyle, children: desktopSidebarOpen ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
2174
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native11.View, { style: desktopLogoContainer, children: [
|
|
2023
2175
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(StorybookLogo, { theme }),
|
|
2024
2176
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native_ui_common7.IconButton, { onPress: () => setDesktopSidebarOpen(false), Icon: MenuIcon })
|
|
2025
2177
|
] }),
|
|
2026
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2178
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native11.View, { style: flexStyle6, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2027
2179
|
Sidebar,
|
|
2028
2180
|
{
|
|
2029
2181
|
previewInitialized: true,
|
|
@@ -2035,19 +2187,20 @@ var Layout = ({
|
|
|
2035
2187
|
storyId: story?.id,
|
|
2036
2188
|
refId: DEFAULT_REF_ID
|
|
2037
2189
|
}
|
|
2038
|
-
)
|
|
2190
|
+
) })
|
|
2039
2191
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native_ui_common7.IconButton, { onPress: () => setDesktopSidebarOpen(true), Icon: MenuIcon }) }) : null,
|
|
2040
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2041
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2192
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native11.View, { style: mobileContentStyle, children: [
|
|
2193
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native11.View, { style: contentContainerStyle, children }),
|
|
2042
2194
|
story?.parameters?.hideFullScreenButton || isDesktop ? null : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2043
|
-
|
|
2195
|
+
import_react_native11.TouchableOpacity,
|
|
2044
2196
|
{
|
|
2045
2197
|
style: fullScreenButtonStyle,
|
|
2198
|
+
hitSlop: { top: 10, bottom: 10, left: 10, right: 10 },
|
|
2046
2199
|
onPress: () => setUiHidden((prev) => !prev),
|
|
2047
2200
|
children: uiHidden ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CloseFullscreenIcon, { color: theme.color.mediumdark }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(FullscreenIcon, { color: theme.color.mediumdark })
|
|
2048
2201
|
}
|
|
2049
2202
|
),
|
|
2050
|
-
isDesktop ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2203
|
+
isDesktop ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native11.View, { style: desktopAddonsPanelStyle, children: desktopAddonsPanelOpen ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(AddonsTabs, { storyId: story?.id, onClose: () => setDesktopAddonsPanelOpen(false) }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2051
2204
|
import_react_native_ui_common7.IconButton,
|
|
2052
2205
|
{
|
|
2053
2206
|
style: iconFloatRightStyle,
|
|
@@ -2056,7 +2209,7 @@ var Layout = ({
|
|
|
2056
2209
|
}
|
|
2057
2210
|
) }) : null
|
|
2058
2211
|
] }),
|
|
2059
|
-
!uiHidden && !isDesktop ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2212
|
+
!uiHidden && !isDesktop ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Container2, { style: navContainerStyle, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Nav, { children: [
|
|
2060
2213
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2061
2214
|
Button2,
|
|
2062
2215
|
{
|
|
@@ -2066,7 +2219,7 @@ var Layout = ({
|
|
|
2066
2219
|
onPress: () => mobileMenuDrawerRef.current?.setMobileMenuOpen(true),
|
|
2067
2220
|
children: [
|
|
2068
2221
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(MenuIcon, { color: theme.color.mediumdark }),
|
|
2069
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2222
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native11.Text, { style: navButtonTextStyle, numberOfLines: 1, children: [
|
|
2070
2223
|
story?.title,
|
|
2071
2224
|
"/",
|
|
2072
2225
|
story?.name
|
|
@@ -2078,13 +2231,14 @@ var Layout = ({
|
|
|
2078
2231
|
import_react_native_ui_common7.IconButton,
|
|
2079
2232
|
{
|
|
2080
2233
|
testID: "mobile-addons-button",
|
|
2234
|
+
hitSlop: addonButtonHitSlop,
|
|
2081
2235
|
onPress: () => addonPanelRef.current.setAddonsPanelOpen(true),
|
|
2082
2236
|
Icon: BottomBarToggleIcon
|
|
2083
2237
|
}
|
|
2084
2238
|
)
|
|
2085
2239
|
] }) }) : null,
|
|
2086
|
-
isDesktop ? null : /* @__PURE__ */ (0, import_jsx_runtime13.
|
|
2087
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2240
|
+
isDesktop ? null : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(MobileMenuDrawer, { ref: mobileMenuDrawerRef, children: [
|
|
2241
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native11.View, { style: mobileMenuDrawerContentStyle, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(StorybookLogo, { theme }) }),
|
|
2088
2242
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2089
2243
|
Sidebar,
|
|
2090
2244
|
{
|
|
@@ -2098,7 +2252,7 @@ var Layout = ({
|
|
|
2098
2252
|
refId: DEFAULT_REF_ID
|
|
2099
2253
|
}
|
|
2100
2254
|
)
|
|
2101
|
-
] })
|
|
2255
|
+
] }),
|
|
2102
2256
|
isDesktop ? null : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(MobileAddonsPanel, { ref: addonPanelRef, storyId: story?.id })
|
|
2103
2257
|
] });
|
|
2104
2258
|
};
|
|
@@ -2111,7 +2265,7 @@ var Nav = import_react_native_theming10.styled.View({
|
|
|
2111
2265
|
height: 40,
|
|
2112
2266
|
paddingHorizontal: 6
|
|
2113
2267
|
});
|
|
2114
|
-
var
|
|
2268
|
+
var Container2 = import_react_native_theming10.styled.View(({ theme }) => ({
|
|
2115
2269
|
alignSelf: "flex-end",
|
|
2116
2270
|
width: "100%",
|
|
2117
2271
|
backgroundColor: theme.barBg,
|