@storybook/react-native-ui 8.3.1-alpha.0 → 8.3.1-alpha.2
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 +126 -99
- package/package.json +3 -3
- package/src/Layout.tsx +60 -25
- package/src/Tree.tsx +0 -4
package/dist/index.js
CHANGED
|
@@ -3132,7 +3132,7 @@ var StoryNode = import_react.default.memo(function StoryNode2({
|
|
|
3132
3132
|
|
|
3133
3133
|
// src/Tree.tsx
|
|
3134
3134
|
var import_react_native_theming7 = require("@storybook/react-native-theming");
|
|
3135
|
-
var
|
|
3135
|
+
var import_react5 = __toESM(require("react"));
|
|
3136
3136
|
|
|
3137
3137
|
// src/Button.tsx
|
|
3138
3138
|
var import_react_native_theming3 = require("@storybook/react-native-theming");
|
|
@@ -3289,40 +3289,10 @@ var IconButton = (0, import_react3.forwardRef)(
|
|
|
3289
3289
|
);
|
|
3290
3290
|
IconButton.displayName = "IconButton";
|
|
3291
3291
|
|
|
3292
|
-
// src/LayoutProvider.tsx
|
|
3293
|
-
var import_react4 = require("react");
|
|
3294
|
-
var import_react_native = require("react-native");
|
|
3295
|
-
|
|
3296
|
-
// src/constants.ts
|
|
3297
|
-
var BREAKPOINT = 1e3;
|
|
3298
|
-
var MEDIA_DESKTOP_BREAKPOINT = `@media (min-width: ${BREAKPOINT}px)`;
|
|
3299
|
-
var DEFAULT_REF_ID = "storybook_internal";
|
|
3300
|
-
|
|
3301
|
-
// src/LayoutProvider.tsx
|
|
3302
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
3303
|
-
var LayoutContext = (0, import_react4.createContext)({
|
|
3304
|
-
isDesktop: false,
|
|
3305
|
-
isMobile: true
|
|
3306
|
-
});
|
|
3307
|
-
var LayoutProvider = ({ children }) => {
|
|
3308
|
-
const { width } = (0, import_react_native.useWindowDimensions)();
|
|
3309
|
-
const isDesktop = width >= BREAKPOINT;
|
|
3310
|
-
const isMobile = !isDesktop;
|
|
3311
|
-
const contextValue = (0, import_react4.useMemo)(
|
|
3312
|
-
() => ({
|
|
3313
|
-
isDesktop,
|
|
3314
|
-
isMobile
|
|
3315
|
-
}),
|
|
3316
|
-
[isDesktop, isMobile]
|
|
3317
|
-
);
|
|
3318
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(LayoutContext.Provider, { value: contextValue, children });
|
|
3319
|
-
};
|
|
3320
|
-
var useLayout = () => (0, import_react4.useContext)(LayoutContext);
|
|
3321
|
-
|
|
3322
3292
|
// src/icon/CollapseAllIcon.tsx
|
|
3323
3293
|
var import_react_native_svg5 = require("react-native-svg");
|
|
3324
3294
|
var import_react_native_theming4 = require("@storybook/react-native-theming");
|
|
3325
|
-
var
|
|
3295
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
3326
3296
|
var CollapseAllIcon = ({
|
|
3327
3297
|
color,
|
|
3328
3298
|
//= '#2E3438',
|
|
@@ -3331,7 +3301,7 @@ var CollapseAllIcon = ({
|
|
|
3331
3301
|
...props
|
|
3332
3302
|
}) => {
|
|
3333
3303
|
const theme = (0, import_react_native_theming4.useTheme)();
|
|
3334
|
-
return /* @__PURE__ */ (0,
|
|
3304
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native_svg5.Svg, { width, height, viewBox: "0 0 14 14", fill: "none", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3335
3305
|
import_react_native_svg5.Path,
|
|
3336
3306
|
{
|
|
3337
3307
|
d: "M3.354.146a.5.5 0 10-.708.708l4 4a.5.5 0 00.708 0l4-4a.5.5 0 00-.708-.708L7 3.793 3.354.146zM6.646 9.146a.5.5 0 01.708 0l4 4a.5.5 0 01-.708.708L7 10.207l-3.646 3.647a.5.5 0 01-.708-.708l4-4z",
|
|
@@ -3343,7 +3313,7 @@ var CollapseAllIcon = ({
|
|
|
3343
3313
|
// src/icon/ExpandAllIcon.tsx
|
|
3344
3314
|
var import_react_native_svg6 = require("react-native-svg");
|
|
3345
3315
|
var import_react_native_theming5 = require("@storybook/react-native-theming");
|
|
3346
|
-
var
|
|
3316
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
3347
3317
|
var ExpandAllIcon = ({
|
|
3348
3318
|
color,
|
|
3349
3319
|
//= '#2E3438',
|
|
@@ -3352,7 +3322,7 @@ var ExpandAllIcon = ({
|
|
|
3352
3322
|
...props
|
|
3353
3323
|
}) => {
|
|
3354
3324
|
const theme = (0, import_react_native_theming5.useTheme)();
|
|
3355
|
-
return /* @__PURE__ */ (0,
|
|
3325
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native_svg6.Svg, { width, height, viewBox: "0 0 14 14", fill: "none", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
3356
3326
|
import_react_native_svg6.Path,
|
|
3357
3327
|
{
|
|
3358
3328
|
d: "M7.354.146l4 4a.5.5 0 01-.708.708L7 1.207 3.354 4.854a.5.5 0 11-.708-.708l4-4a.5.5 0 01.708 0zM11.354 9.146a.5.5 0 010 .708l-4 4a.5.5 0 01-.708 0l-4-4a.5.5 0 11.708-.708L7 12.793l3.646-3.647a.5.5 0 01.708 0z",
|
|
@@ -3362,10 +3332,17 @@ var ExpandAllIcon = ({
|
|
|
3362
3332
|
};
|
|
3363
3333
|
|
|
3364
3334
|
// src/useExpanded.ts
|
|
3365
|
-
var
|
|
3335
|
+
var import_react4 = require("react");
|
|
3366
3336
|
|
|
3367
3337
|
// src/util/tree.ts
|
|
3368
3338
|
var import_memoizerific = __toESM(require("memoizerific"));
|
|
3339
|
+
|
|
3340
|
+
// src/constants.ts
|
|
3341
|
+
var BREAKPOINT = 1e3;
|
|
3342
|
+
var MEDIA_DESKTOP_BREAKPOINT = `@media (min-width: ${BREAKPOINT}px)`;
|
|
3343
|
+
var DEFAULT_REF_ID = "storybook_internal";
|
|
3344
|
+
|
|
3345
|
+
// src/util/tree.ts
|
|
3369
3346
|
var createId = (itemId, refId) => !refId || refId === DEFAULT_REF_ID ? itemId : `${refId}_${itemId}`;
|
|
3370
3347
|
var get = (0, import_memoizerific.default)(1e3)((id, dataset) => dataset[id]);
|
|
3371
3348
|
var getParent = (0, import_memoizerific.default)(1e3)((id, dataset) => {
|
|
@@ -3436,15 +3413,15 @@ var useExpanded = ({
|
|
|
3436
3413
|
rootIds,
|
|
3437
3414
|
selectedStoryId
|
|
3438
3415
|
}) => {
|
|
3439
|
-
const [expanded, setExpanded] = (0,
|
|
3416
|
+
const [expanded, setExpanded] = (0, import_react4.useReducer)(
|
|
3440
3417
|
(state, { ids, value }) => ids.reduce((acc, id) => Object.assign(acc, { [id]: value }), { ...state }),
|
|
3441
3418
|
{ refId, data, rootIds, initialExpanded },
|
|
3442
3419
|
initializeExpanded
|
|
3443
3420
|
);
|
|
3444
|
-
const updateExpanded = (0,
|
|
3421
|
+
const updateExpanded = (0, import_react4.useCallback)(({ ids, value }) => {
|
|
3445
3422
|
setExpanded({ ids, value });
|
|
3446
3423
|
}, []);
|
|
3447
|
-
(0,
|
|
3424
|
+
(0, import_react4.useEffect)(() => {
|
|
3448
3425
|
setExpanded({ ids: getAncestorIds(data, selectedStoryId), value: true });
|
|
3449
3426
|
}, [data, selectedStoryId]);
|
|
3450
3427
|
return [expanded, updateExpanded];
|
|
@@ -3453,16 +3430,16 @@ var useExpanded = ({
|
|
|
3453
3430
|
// src/util/status.tsx
|
|
3454
3431
|
var import_react_native_theming6 = require("@storybook/react-native-theming");
|
|
3455
3432
|
var import_react_native_svg7 = __toESM(require("react-native-svg"));
|
|
3456
|
-
var
|
|
3433
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
3457
3434
|
function CircleIcon({ height = 14, width = 14, color, ...props }) {
|
|
3458
|
-
return /* @__PURE__ */ (0,
|
|
3435
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native_svg7.default, { width, height, viewBox: "0 0 14 14", fill: "none", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native_svg7.Path, { d: "M14 7A7 7 0 110 7a7 7 0 0114 0z", fill: color }) });
|
|
3459
3436
|
}
|
|
3460
3437
|
function SmallIcons(props) {
|
|
3461
|
-
return /* @__PURE__ */ (0,
|
|
3438
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CircleIcon, { width: 6, height: 6, ...props });
|
|
3462
3439
|
}
|
|
3463
3440
|
function LoadingIcons(props) {
|
|
3464
3441
|
const theme = (0, import_react_native_theming6.useTheme)();
|
|
3465
|
-
return /* @__PURE__ */ (0,
|
|
3442
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3466
3443
|
SmallIcons,
|
|
3467
3444
|
{
|
|
3468
3445
|
color: theme.base === "light" ? theme.color.mediumdark : theme.color.darker,
|
|
@@ -3473,10 +3450,10 @@ function LoadingIcons(props) {
|
|
|
3473
3450
|
var statusPriority = ["unknown", "pending", "success", "warn", "error"];
|
|
3474
3451
|
var statusMapping = {
|
|
3475
3452
|
unknown: [null, null],
|
|
3476
|
-
pending: [/* @__PURE__ */ (0,
|
|
3477
|
-
success: [/* @__PURE__ */ (0,
|
|
3478
|
-
warn: [/* @__PURE__ */ (0,
|
|
3479
|
-
error: [/* @__PURE__ */ (0,
|
|
3453
|
+
pending: [/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(LoadingIcons, {}, "icon"), "currentColor"],
|
|
3454
|
+
success: [/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SmallIcons, { color: "green" }, "icon"), "currentColor"],
|
|
3455
|
+
warn: [/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SmallIcons, { color: "orange" }, "icon"), "#A15C20"],
|
|
3456
|
+
error: [/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SmallIcons, { color: "red" }, "icon"), "brown"]
|
|
3480
3457
|
};
|
|
3481
3458
|
var getHighestStatus = (statuses) => {
|
|
3482
3459
|
return statusPriority.reduce(
|
|
@@ -3500,11 +3477,11 @@ function getGroupStatus(collapsedData, status) {
|
|
|
3500
3477
|
}
|
|
3501
3478
|
|
|
3502
3479
|
// src/Tree.tsx
|
|
3503
|
-
var
|
|
3480
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
3504
3481
|
var TextItem = import_react_native_theming7.styled.Text(({ theme }) => ({
|
|
3505
3482
|
color: theme.color.defaultText
|
|
3506
3483
|
}));
|
|
3507
|
-
var Node =
|
|
3484
|
+
var Node = import_react5.default.memo(function Node2({
|
|
3508
3485
|
item,
|
|
3509
3486
|
refId,
|
|
3510
3487
|
isOrphan,
|
|
@@ -3517,14 +3494,13 @@ var Node = import_react6.default.memo(function Node2({
|
|
|
3517
3494
|
setExpanded,
|
|
3518
3495
|
onSelectStoryId
|
|
3519
3496
|
}) {
|
|
3520
|
-
const { isDesktop } = useLayout();
|
|
3521
3497
|
if (!isDisplayed) {
|
|
3522
3498
|
return null;
|
|
3523
3499
|
}
|
|
3524
3500
|
const id = createId(item.id, refId);
|
|
3525
3501
|
if (item.type === "story") {
|
|
3526
3502
|
const LeafNode2 = StoryNode;
|
|
3527
|
-
return /* @__PURE__ */ (0,
|
|
3503
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(LeafNodeStyleWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3528
3504
|
LeafNode2,
|
|
3529
3505
|
{
|
|
3530
3506
|
selected: isSelected,
|
|
@@ -3539,8 +3515,8 @@ var Node = import_react6.default.memo(function Node2({
|
|
|
3539
3515
|
) });
|
|
3540
3516
|
}
|
|
3541
3517
|
if (item.type === "root") {
|
|
3542
|
-
return /* @__PURE__ */ (0,
|
|
3543
|
-
/* @__PURE__ */ (0,
|
|
3518
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(RootNode, { id, children: [
|
|
3519
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
3544
3520
|
CollapseButton,
|
|
3545
3521
|
{
|
|
3546
3522
|
"data-action": "collapse-root",
|
|
@@ -3550,12 +3526,12 @@ var Node = import_react6.default.memo(function Node2({
|
|
|
3550
3526
|
},
|
|
3551
3527
|
"aria-expanded": isExpanded,
|
|
3552
3528
|
children: [
|
|
3553
|
-
/* @__PURE__ */ (0,
|
|
3554
|
-
/* @__PURE__ */ (0,
|
|
3529
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CollapseIcon, { isExpanded }),
|
|
3530
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TextItem, { children: item.renderLabel?.(item, {}) || item.name })
|
|
3555
3531
|
]
|
|
3556
3532
|
}
|
|
3557
3533
|
),
|
|
3558
|
-
isExpanded && /* @__PURE__ */ (0,
|
|
3534
|
+
isExpanded && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3559
3535
|
IconButton,
|
|
3560
3536
|
{
|
|
3561
3537
|
"aria-label": isFullyExpanded ? "Expand" : "Collapse",
|
|
@@ -3565,14 +3541,14 @@ var Node = import_react6.default.memo(function Node2({
|
|
|
3565
3541
|
event.preventDefault();
|
|
3566
3542
|
setFullyExpanded();
|
|
3567
3543
|
},
|
|
3568
|
-
children: isFullyExpanded ? /* @__PURE__ */ (0,
|
|
3544
|
+
children: isFullyExpanded ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CollapseAllIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ExpandAllIcon, {})
|
|
3569
3545
|
}
|
|
3570
3546
|
)
|
|
3571
3547
|
] }, id);
|
|
3572
3548
|
}
|
|
3573
3549
|
if (item.type === "component" || item.type === "group") {
|
|
3574
3550
|
const BranchNode2 = item.type === "component" ? ComponentNode : GroupNode;
|
|
3575
|
-
return /* @__PURE__ */ (0,
|
|
3551
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3576
3552
|
BranchNode2,
|
|
3577
3553
|
{
|
|
3578
3554
|
id,
|
|
@@ -3585,8 +3561,6 @@ var Node = import_react6.default.memo(function Node2({
|
|
|
3585
3561
|
onPress: (event) => {
|
|
3586
3562
|
event.preventDefault();
|
|
3587
3563
|
setExpanded({ ids: [item.id], value: !isExpanded });
|
|
3588
|
-
if (item.type === "component" && !isExpanded && isDesktop)
|
|
3589
|
-
onSelectStoryId(item.id);
|
|
3590
3564
|
},
|
|
3591
3565
|
children: item.renderLabel?.(item) || item.name
|
|
3592
3566
|
},
|
|
@@ -3635,9 +3609,9 @@ var CollapseButton = import_react_native_theming7.styled.TouchableOpacity(({}) =
|
|
|
3635
3609
|
cursor: "pointer",
|
|
3636
3610
|
height: 28
|
|
3637
3611
|
}));
|
|
3638
|
-
var Tree =
|
|
3639
|
-
const containerRef = (0,
|
|
3640
|
-
const [rootIds, orphanIds, initialExpanded] = (0,
|
|
3612
|
+
var Tree = import_react5.default.memo(function Tree2({ isMain, refId, data, status, docsMode, selectedStoryId, onSelectStoryId }) {
|
|
3613
|
+
const containerRef = (0, import_react5.useRef)(null);
|
|
3614
|
+
const [rootIds, orphanIds, initialExpanded] = (0, import_react5.useMemo)(
|
|
3641
3615
|
() => Object.keys(data).reduce(
|
|
3642
3616
|
(acc, id) => {
|
|
3643
3617
|
const item = data[id];
|
|
@@ -3653,7 +3627,7 @@ var Tree = import_react6.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
3653
3627
|
),
|
|
3654
3628
|
[data]
|
|
3655
3629
|
);
|
|
3656
|
-
const { expandableDescendants } = (0,
|
|
3630
|
+
const { expandableDescendants } = (0, import_react5.useMemo)(() => {
|
|
3657
3631
|
return [...orphanIds, ...rootIds].reduce(
|
|
3658
3632
|
(acc, nodeId) => {
|
|
3659
3633
|
acc.expandableDescendants[nodeId] = getDescendantIds(data, nodeId, false).filter(
|
|
@@ -3664,7 +3638,7 @@ var Tree = import_react6.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
3664
3638
|
{ orphansFirst: [], expandableDescendants: {} }
|
|
3665
3639
|
);
|
|
3666
3640
|
}, [data, rootIds, orphanIds]);
|
|
3667
|
-
const singleStoryComponentIds = (0,
|
|
3641
|
+
const singleStoryComponentIds = (0, import_react5.useMemo)(() => {
|
|
3668
3642
|
return Object.keys(data).filter((id) => {
|
|
3669
3643
|
const entry = data[id];
|
|
3670
3644
|
if (entry.type !== "component")
|
|
@@ -3680,12 +3654,12 @@ var Tree = import_react6.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
3680
3654
|
return false;
|
|
3681
3655
|
});
|
|
3682
3656
|
}, [data]);
|
|
3683
|
-
const collapsedItems = (0,
|
|
3657
|
+
const collapsedItems = (0, import_react5.useMemo)(
|
|
3684
3658
|
() => Object.keys(data).filter((id) => !singleStoryComponentIds.includes(id)),
|
|
3685
3659
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3686
3660
|
[singleStoryComponentIds]
|
|
3687
3661
|
);
|
|
3688
|
-
const collapsedData = (0,
|
|
3662
|
+
const collapsedData = (0, import_react5.useMemo)(() => {
|
|
3689
3663
|
return singleStoryComponentIds.reduce(
|
|
3690
3664
|
(acc, id) => {
|
|
3691
3665
|
const { children, parent, name } = data[id];
|
|
@@ -3706,7 +3680,7 @@ var Tree = import_react6.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
3706
3680
|
{ ...data }
|
|
3707
3681
|
);
|
|
3708
3682
|
}, [data]);
|
|
3709
|
-
const ancestry = (0,
|
|
3683
|
+
const ancestry = (0, import_react5.useMemo)(() => {
|
|
3710
3684
|
return collapsedItems.reduce(
|
|
3711
3685
|
(acc, id) => Object.assign(acc, { [id]: getAncestorIds(collapsedData, id) }),
|
|
3712
3686
|
{}
|
|
@@ -3720,15 +3694,15 @@ var Tree = import_react6.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
3720
3694
|
selectedStoryId,
|
|
3721
3695
|
onSelectStoryId
|
|
3722
3696
|
});
|
|
3723
|
-
const groupStatus = (0,
|
|
3724
|
-
const treeItems = (0,
|
|
3697
|
+
const groupStatus = (0, import_react5.useMemo)(() => getGroupStatus(collapsedData, status), [collapsedData, status]);
|
|
3698
|
+
const treeItems = (0, import_react5.useMemo)(() => {
|
|
3725
3699
|
return collapsedItems.map((itemId) => {
|
|
3726
3700
|
const item = collapsedData[itemId];
|
|
3727
3701
|
const id = createId(itemId, refId);
|
|
3728
3702
|
if (item.type === "root") {
|
|
3729
3703
|
const descendants = expandableDescendants[item.id];
|
|
3730
3704
|
const isFullyExpanded = descendants.every((d) => expanded[d]);
|
|
3731
|
-
return /* @__PURE__ */ (0,
|
|
3705
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3732
3706
|
Root,
|
|
3733
3707
|
{
|
|
3734
3708
|
item,
|
|
@@ -3750,7 +3724,7 @@ var Tree = import_react6.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
3750
3724
|
}
|
|
3751
3725
|
const isDisplayed = !item.parent || ancestry[itemId].every((a) => expanded[a]);
|
|
3752
3726
|
const color = groupStatus[itemId] ? statusMapping[groupStatus[itemId]][1] : null;
|
|
3753
|
-
return /* @__PURE__ */ (0,
|
|
3727
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3754
3728
|
Node,
|
|
3755
3729
|
{
|
|
3756
3730
|
item,
|
|
@@ -3783,23 +3757,23 @@ var Tree = import_react6.default.memo(function Tree2({ isMain, refId, data, stat
|
|
|
3783
3757
|
setExpanded,
|
|
3784
3758
|
status
|
|
3785
3759
|
]);
|
|
3786
|
-
return /* @__PURE__ */ (0,
|
|
3760
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Container, { ref: containerRef, hasOrphans: isMain && orphanIds.length > 0, children: treeItems });
|
|
3787
3761
|
});
|
|
3788
3762
|
var Container = import_react_native_theming7.styled.View((props) => ({
|
|
3789
3763
|
marginTop: props.hasOrphans ? 20 : 0,
|
|
3790
3764
|
marginBottom: 20
|
|
3791
3765
|
}));
|
|
3792
|
-
var Root =
|
|
3766
|
+
var Root = import_react5.default.memo(function Root2({
|
|
3793
3767
|
setExpanded,
|
|
3794
3768
|
isFullyExpanded,
|
|
3795
3769
|
expandableDescendants,
|
|
3796
3770
|
...props
|
|
3797
3771
|
}) {
|
|
3798
|
-
const setFullyExpanded = (0,
|
|
3772
|
+
const setFullyExpanded = (0, import_react5.useCallback)(
|
|
3799
3773
|
() => setExpanded({ ids: expandableDescendants, value: !isFullyExpanded }),
|
|
3800
3774
|
[setExpanded, isFullyExpanded, expandableDescendants]
|
|
3801
3775
|
);
|
|
3802
|
-
return /* @__PURE__ */ (0,
|
|
3776
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3803
3777
|
Node,
|
|
3804
3778
|
{
|
|
3805
3779
|
...props,
|
|
@@ -3810,6 +3784,29 @@ var Root = import_react6.default.memo(function Root2({
|
|
|
3810
3784
|
);
|
|
3811
3785
|
});
|
|
3812
3786
|
|
|
3787
|
+
// src/LayoutProvider.tsx
|
|
3788
|
+
var import_react6 = require("react");
|
|
3789
|
+
var import_react_native = require("react-native");
|
|
3790
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
3791
|
+
var LayoutContext = (0, import_react6.createContext)({
|
|
3792
|
+
isDesktop: false,
|
|
3793
|
+
isMobile: true
|
|
3794
|
+
});
|
|
3795
|
+
var LayoutProvider = ({ children }) => {
|
|
3796
|
+
const { width } = (0, import_react_native.useWindowDimensions)();
|
|
3797
|
+
const isDesktop = width >= BREAKPOINT;
|
|
3798
|
+
const isMobile = !isDesktop;
|
|
3799
|
+
const contextValue = (0, import_react6.useMemo)(
|
|
3800
|
+
() => ({
|
|
3801
|
+
isDesktop,
|
|
3802
|
+
isMobile
|
|
3803
|
+
}),
|
|
3804
|
+
[isDesktop, isMobile]
|
|
3805
|
+
);
|
|
3806
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(LayoutContext.Provider, { value: contextValue, children });
|
|
3807
|
+
};
|
|
3808
|
+
var useLayout = () => (0, import_react6.useContext)(LayoutContext);
|
|
3809
|
+
|
|
3813
3810
|
// src/Explorer.tsx
|
|
3814
3811
|
var import_react8 = __toESM(require("react"));
|
|
3815
3812
|
|
|
@@ -4785,6 +4782,8 @@ var Layout = ({
|
|
|
4785
4782
|
const addonPanelRef = (0, import_react17.useRef)(null);
|
|
4786
4783
|
const insets = (0, import_react_native_safe_area_context3.useSafeAreaInsets)();
|
|
4787
4784
|
const { isDesktop } = useLayout();
|
|
4785
|
+
const [desktopSidebarOpen, setDesktopSidebarOpen] = (0, import_react17.useState)(true);
|
|
4786
|
+
const [desktopAddonsPanelOpen, setDesktopAddonsPanelOpen] = (0, import_react17.useState)(true);
|
|
4788
4787
|
if (isDesktop) {
|
|
4789
4788
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
4790
4789
|
import_react_native8.View,
|
|
@@ -4800,36 +4799,56 @@ var Layout = ({
|
|
|
4800
4799
|
import_react_native8.View,
|
|
4801
4800
|
{
|
|
4802
4801
|
style: {
|
|
4803
|
-
width: 240,
|
|
4802
|
+
width: desktopSidebarOpen ? 240 : void 0,
|
|
4803
|
+
padding: desktopSidebarOpen ? 0 : 10,
|
|
4804
4804
|
borderColor: theme.appBorderColor,
|
|
4805
4805
|
borderRightWidth: 1
|
|
4806
4806
|
},
|
|
4807
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime24.
|
|
4807
|
+
children: desktopSidebarOpen ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
4808
4808
|
import_react_native8.ScrollView,
|
|
4809
4809
|
{
|
|
4810
4810
|
keyboardShouldPersistTaps: "handled",
|
|
4811
4811
|
contentContainerStyle: {
|
|
4812
4812
|
paddingBottom: insets.bottom
|
|
4813
4813
|
},
|
|
4814
|
-
children:
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4814
|
+
children: [
|
|
4815
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
4816
|
+
import_react_native8.View,
|
|
4817
|
+
{
|
|
4818
|
+
style: {
|
|
4819
|
+
flexDirection: "row",
|
|
4820
|
+
alignItems: "center",
|
|
4821
|
+
paddingVertical: 10,
|
|
4822
|
+
paddingLeft: 16,
|
|
4823
|
+
paddingRight: 10,
|
|
4824
|
+
justifyContent: "space-between"
|
|
4825
|
+
},
|
|
4826
|
+
children: [
|
|
4827
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react_native8.Text, { style: { fontSize: 20, fontWeight: "bold", color: theme.color.defaultText }, children: "Storybook" }),
|
|
4828
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(IconButton, { onPress: () => setDesktopSidebarOpen(false), Icon: MenuIcon })
|
|
4829
|
+
]
|
|
4830
|
+
}
|
|
4831
|
+
),
|
|
4832
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4833
|
+
Sidebar,
|
|
4834
|
+
{
|
|
4835
|
+
extra: [],
|
|
4836
|
+
previewInitialized: true,
|
|
4837
|
+
indexError: void 0,
|
|
4838
|
+
refs: {},
|
|
4839
|
+
setSelection: ({ storyId: newStoryId }) => {
|
|
4840
|
+
const channel = import_manager_api2.addons.getChannel();
|
|
4841
|
+
channel.emit(import_core_events.SET_CURRENT_STORY, { storyId: newStoryId });
|
|
4842
|
+
},
|
|
4843
|
+
status: {},
|
|
4844
|
+
index: storyHash,
|
|
4845
|
+
storyId: story?.id,
|
|
4846
|
+
refId: DEFAULT_REF_ID
|
|
4847
|
+
}
|
|
4848
|
+
)
|
|
4849
|
+
]
|
|
4831
4850
|
}
|
|
4832
|
-
)
|
|
4851
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(IconButton, { onPress: () => setDesktopSidebarOpen(true), Icon: MenuIcon })
|
|
4833
4852
|
}
|
|
4834
4853
|
),
|
|
4835
4854
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_react_native8.View, { style: { flex: 1 }, children: [
|
|
@@ -4838,12 +4857,20 @@ var Layout = ({
|
|
|
4838
4857
|
import_react_native8.View,
|
|
4839
4858
|
{
|
|
4840
4859
|
style: {
|
|
4841
|
-
height: 300,
|
|
4860
|
+
height: desktopAddonsPanelOpen ? 300 : void 0,
|
|
4842
4861
|
borderTopWidth: 1,
|
|
4843
4862
|
borderColor: theme.appBorderColor,
|
|
4844
|
-
paddingTop: 4
|
|
4863
|
+
paddingTop: desktopAddonsPanelOpen ? 4 : 0,
|
|
4864
|
+
padding: desktopAddonsPanelOpen ? 0 : 10
|
|
4845
4865
|
},
|
|
4846
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(AddonsTabs, { storyId: story?.id })
|
|
4866
|
+
children: desktopAddonsPanelOpen ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(AddonsTabs, { storyId: story?.id, onClose: () => setDesktopAddonsPanelOpen(false) }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4867
|
+
IconButton,
|
|
4868
|
+
{
|
|
4869
|
+
style: { marginLeft: "auto" },
|
|
4870
|
+
onPress: () => setDesktopAddonsPanelOpen(true),
|
|
4871
|
+
Icon: BottomBarToggleIcon
|
|
4872
|
+
}
|
|
4873
|
+
)
|
|
4847
4874
|
}
|
|
4848
4875
|
)
|
|
4849
4876
|
] })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react-native-ui",
|
|
3
|
-
"version": "8.3.1-alpha.
|
|
3
|
+
"version": "8.3.1-alpha.2",
|
|
4
4
|
"description": "ui components for react native storybook",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@storybook/core": "^8.3.1",
|
|
61
61
|
"@storybook/react": "^8.3.1",
|
|
62
|
-
"@storybook/react-native-theming": "^8.3.1-alpha.
|
|
62
|
+
"@storybook/react-native-theming": "^8.3.1-alpha.2",
|
|
63
63
|
"fuse.js": "^7.0.0",
|
|
64
64
|
"memoizerific": "^1.11.3",
|
|
65
65
|
"polished": "^4.3.1",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"publishConfig": {
|
|
81
81
|
"access": "public"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "2db7054f47b2addecdb947cba539544be40379e3"
|
|
84
84
|
}
|
package/src/Layout.tsx
CHANGED
|
@@ -33,6 +33,10 @@ export const Layout = ({
|
|
|
33
33
|
const insets = useSafeAreaInsets();
|
|
34
34
|
const { isDesktop } = useLayout();
|
|
35
35
|
|
|
36
|
+
const [desktopSidebarOpen, setDesktopSidebarOpen] = useState(true);
|
|
37
|
+
|
|
38
|
+
const [desktopAddonsPanelOpen, setDesktopAddonsPanelOpen] = useState(true);
|
|
39
|
+
|
|
36
40
|
if (isDesktop) {
|
|
37
41
|
return (
|
|
38
42
|
<View
|
|
@@ -45,33 +49,55 @@ export const Layout = ({
|
|
|
45
49
|
>
|
|
46
50
|
<View
|
|
47
51
|
style={{
|
|
48
|
-
width: 240,
|
|
52
|
+
width: desktopSidebarOpen ? 240 : undefined,
|
|
53
|
+
padding: desktopSidebarOpen ? 0 : 10,
|
|
49
54
|
borderColor: theme.appBorderColor,
|
|
50
55
|
borderRightWidth: 1,
|
|
51
56
|
}}
|
|
52
57
|
>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
>
|
|
59
|
-
<Sidebar
|
|
60
|
-
extra={[]}
|
|
61
|
-
previewInitialized
|
|
62
|
-
indexError={undefined}
|
|
63
|
-
refs={{}}
|
|
64
|
-
setSelection={({ storyId: newStoryId }) => {
|
|
65
|
-
const channel = addons.getChannel();
|
|
66
|
-
|
|
67
|
-
channel.emit(SET_CURRENT_STORY, { storyId: newStoryId });
|
|
58
|
+
{desktopSidebarOpen ? (
|
|
59
|
+
<ScrollView
|
|
60
|
+
keyboardShouldPersistTaps="handled"
|
|
61
|
+
contentContainerStyle={{
|
|
62
|
+
paddingBottom: insets.bottom,
|
|
68
63
|
}}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
>
|
|
65
|
+
<View
|
|
66
|
+
style={{
|
|
67
|
+
flexDirection: 'row',
|
|
68
|
+
alignItems: 'center',
|
|
69
|
+
paddingVertical: 10,
|
|
70
|
+
paddingLeft: 16,
|
|
71
|
+
paddingRight: 10,
|
|
72
|
+
justifyContent: 'space-between',
|
|
73
|
+
}}
|
|
74
|
+
>
|
|
75
|
+
<Text style={{ fontSize: 20, fontWeight: 'bold', color: theme.color.defaultText }}>
|
|
76
|
+
Storybook
|
|
77
|
+
</Text>
|
|
78
|
+
|
|
79
|
+
<IconButton onPress={() => setDesktopSidebarOpen(false)} Icon={MenuIcon} />
|
|
80
|
+
</View>
|
|
81
|
+
|
|
82
|
+
<Sidebar
|
|
83
|
+
extra={[]}
|
|
84
|
+
previewInitialized
|
|
85
|
+
indexError={undefined}
|
|
86
|
+
refs={{}}
|
|
87
|
+
setSelection={({ storyId: newStoryId }) => {
|
|
88
|
+
const channel = addons.getChannel();
|
|
89
|
+
|
|
90
|
+
channel.emit(SET_CURRENT_STORY, { storyId: newStoryId });
|
|
91
|
+
}}
|
|
92
|
+
status={{}}
|
|
93
|
+
index={storyHash}
|
|
94
|
+
storyId={story?.id}
|
|
95
|
+
refId={DEFAULT_REF_ID}
|
|
96
|
+
/>
|
|
97
|
+
</ScrollView>
|
|
98
|
+
) : (
|
|
99
|
+
<IconButton onPress={() => setDesktopSidebarOpen(true)} Icon={MenuIcon} />
|
|
100
|
+
)}
|
|
75
101
|
</View>
|
|
76
102
|
|
|
77
103
|
<View style={{ flex: 1 }}>
|
|
@@ -79,13 +105,22 @@ export const Layout = ({
|
|
|
79
105
|
|
|
80
106
|
<View
|
|
81
107
|
style={{
|
|
82
|
-
height: 300,
|
|
108
|
+
height: desktopAddonsPanelOpen ? 300 : undefined,
|
|
83
109
|
borderTopWidth: 1,
|
|
84
110
|
borderColor: theme.appBorderColor,
|
|
85
|
-
paddingTop: 4,
|
|
111
|
+
paddingTop: desktopAddonsPanelOpen ? 4 : 0,
|
|
112
|
+
padding: desktopAddonsPanelOpen ? 0 : 10,
|
|
86
113
|
}}
|
|
87
114
|
>
|
|
88
|
-
|
|
115
|
+
{desktopAddonsPanelOpen ? (
|
|
116
|
+
<AddonsTabs storyId={story?.id} onClose={() => setDesktopAddonsPanelOpen(false)} />
|
|
117
|
+
) : (
|
|
118
|
+
<IconButton
|
|
119
|
+
style={{ marginLeft: 'auto' }}
|
|
120
|
+
onPress={() => setDesktopAddonsPanelOpen(true)}
|
|
121
|
+
Icon={BottomBarToggleIcon}
|
|
122
|
+
/>
|
|
123
|
+
)}
|
|
89
124
|
</View>
|
|
90
125
|
</View>
|
|
91
126
|
</View>
|
package/src/Tree.tsx
CHANGED
|
@@ -9,7 +9,6 @@ import { styled } from '@storybook/react-native-theming';
|
|
|
9
9
|
import React, { useCallback, useMemo, useRef } from 'react';
|
|
10
10
|
import { View } from 'react-native';
|
|
11
11
|
import { IconButton } from './IconButton';
|
|
12
|
-
import { useLayout } from './LayoutProvider';
|
|
13
12
|
import { ComponentNode, GroupNode, StoryNode } from './TreeNode';
|
|
14
13
|
import { CollapseAllIcon } from './icon/CollapseAllIcon';
|
|
15
14
|
import { CollapseIcon } from './icon/CollapseIcon';
|
|
@@ -53,8 +52,6 @@ export const Node = React.memo<NodeProps>(function Node({
|
|
|
53
52
|
setExpanded,
|
|
54
53
|
onSelectStoryId,
|
|
55
54
|
}) {
|
|
56
|
-
const { isDesktop } = useLayout();
|
|
57
|
-
|
|
58
55
|
if (!isDisplayed) {
|
|
59
56
|
return null;
|
|
60
57
|
}
|
|
@@ -127,7 +124,6 @@ export const Node = React.memo<NodeProps>(function Node({
|
|
|
127
124
|
onPress={(event) => {
|
|
128
125
|
event.preventDefault();
|
|
129
126
|
setExpanded({ ids: [item.id], value: !isExpanded });
|
|
130
|
-
if (item.type === 'component' && !isExpanded && isDesktop) onSelectStoryId(item.id);
|
|
131
127
|
}}
|
|
132
128
|
>
|
|
133
129
|
{(item.renderLabel as (i: typeof item) => React.ReactNode)?.(item) || item.name}
|