@storybook/react-native-ui-lite 11.0.0-next.1 → 11.0.0-next.3
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.d.ts +39 -54
- package/dist/index.js +70 -80
- package/package.json +9 -9
- package/src/Explorer.tsx +1 -1
- package/src/Layout.tsx +13 -1
- package/src/MobileMenuDrawer.tsx +3 -3
- package/src/Search.tsx +2 -2
- package/src/SearchResults.tsx +0 -1
- package/src/SelectedNodeProvider.tsx +7 -10
- package/src/Tree.tsx +3 -4
- package/src/TreeNode.tsx +78 -68
- package/src/useKeyboard.ts +12 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,44 +1,30 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import { View } from "react-native";
|
|
1
|
+
import React, { FC, ReactNode } from "react";
|
|
2
|
+
import { TouchableOpacityProps, View } from "react-native";
|
|
3
3
|
import { CombinedDataset, ExpandAction, Item, SBUI, Selection } from "@storybook/react-native-ui-common";
|
|
4
|
-
import {
|
|
4
|
+
import { IndexHash, State } from "storybook/manager-api";
|
|
5
5
|
import { API_IndexHash, API_LoadedRefData } from "storybook/internal/types";
|
|
6
6
|
import { ReactRenderer } from "@storybook/react";
|
|
7
7
|
import { Args, StoryContext } from "storybook/internal/csf";
|
|
8
|
-
|
|
9
|
-
interface
|
|
10
|
-
children: React.ReactNode | React.ReactNode[];
|
|
11
|
-
isExpandable?: boolean;
|
|
12
|
-
isExpanded?: boolean;
|
|
13
|
-
}
|
|
14
|
-
declare const BranchNode: import("@storybook/react-native-theming").StyledComponent<import("react-native").TouchableOpacityProps & React.RefAttributes<View> & {
|
|
15
|
-
theme?: import("@storybook/react-native-theming").Theme;
|
|
16
|
-
as?: React.ElementType;
|
|
17
|
-
} & {
|
|
8
|
+
export interface StoryNodeRef extends React.ComponentRef<typeof View> {}
|
|
9
|
+
export interface BranchNodeProps extends TouchableOpacityProps {
|
|
18
10
|
depth?: number;
|
|
19
11
|
isExpandable?: boolean;
|
|
20
12
|
isExpanded?: boolean;
|
|
21
13
|
isComponent?: boolean;
|
|
22
14
|
isSelected?: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
}>;
|
|
26
|
-
declare const GroupNode: FC<ComponentProps<typeof BranchNode> & {
|
|
27
|
-
isExpanded?: boolean;
|
|
28
|
-
isExpandable?: boolean;
|
|
29
|
-
}>;
|
|
30
|
-
declare const ComponentNode: FC<ComponentProps<typeof BranchNode>>;
|
|
31
|
-
declare const StoryNode: React.NamedExoticComponent<Omit<import("react-native").TouchableOpacityProps & React.RefAttributes<View> & {
|
|
32
|
-
theme?: import("@storybook/react-native-theming").Theme;
|
|
33
|
-
as?: React.ElementType;
|
|
34
|
-
} & {
|
|
15
|
+
}
|
|
16
|
+
export interface LeafNodeProps extends TouchableOpacityProps {
|
|
35
17
|
depth?: number;
|
|
36
18
|
selected?: boolean;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
19
|
+
}
|
|
20
|
+
export interface NodeProps {
|
|
21
|
+
children: React.ReactNode | React.ReactNode[];
|
|
22
|
+
isExpandable?: boolean;
|
|
23
|
+
isExpanded?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare const GroupNode: FC<BranchNodeProps>;
|
|
26
|
+
export declare const ComponentNode: FC<BranchNodeProps>;
|
|
27
|
+
export declare const StoryNode: React.NamedExoticComponent<LeafNodeProps & React.RefAttributes<StoryNodeRef>>;
|
|
42
28
|
interface NodeProps$1 {
|
|
43
29
|
item: Item;
|
|
44
30
|
refId: string;
|
|
@@ -54,49 +40,51 @@ interface NodeProps$1 {
|
|
|
54
40
|
onSelectStoryId: (itemId: string) => void;
|
|
55
41
|
status: State['status'][keyof State['status']];
|
|
56
42
|
}
|
|
57
|
-
declare const Node: React.NamedExoticComponent<NodeProps$1>;
|
|
58
|
-
declare const LeafNodeStyleWrapper: import("@storybook/react-native-theming").StyledComponent<import("react-native").ViewProps & {
|
|
43
|
+
export declare const Node: React.NamedExoticComponent<NodeProps$1>;
|
|
44
|
+
export declare const LeafNodeStyleWrapper: import("@storybook/react-native-theming").StyledComponent<Omit<import("react-native").ViewProps, "ref"> & {
|
|
45
|
+
ref?: React.Ref<import("react-native").ViewInstance> | undefined;
|
|
46
|
+
} & {
|
|
59
47
|
theme?: import("@storybook/react-native-theming").Theme;
|
|
60
48
|
as?: React.ElementType;
|
|
61
49
|
}, {}, {
|
|
62
|
-
ref?: React.Ref<
|
|
50
|
+
ref?: React.Ref<any>;
|
|
63
51
|
}>;
|
|
64
|
-
declare const RootNode: import("@storybook/react-native-theming").StyledComponent<import("react-native").ViewProps & {
|
|
52
|
+
export declare const RootNode: import("@storybook/react-native-theming").StyledComponent<Omit<import("react-native").ViewProps, "ref"> & {
|
|
53
|
+
ref?: React.Ref<import("react-native").ViewInstance> | undefined;
|
|
54
|
+
} & {
|
|
65
55
|
theme?: import("@storybook/react-native-theming").Theme;
|
|
66
56
|
as?: React.ElementType;
|
|
67
57
|
}, {}, {
|
|
68
|
-
ref?: React.Ref<
|
|
58
|
+
ref?: React.Ref<any>;
|
|
69
59
|
}>;
|
|
70
|
-
declare const RootNodeText: import("@storybook/react-native-theming").StyledComponent<import("react-native").TextProps & {
|
|
60
|
+
export declare const RootNodeText: import("@storybook/react-native-theming").StyledComponent<Omit<import("react-native").TextProps, "ref"> & {
|
|
61
|
+
ref?: React.Ref<import("react-native").TextInstance> | undefined;
|
|
62
|
+
} & {
|
|
71
63
|
theme?: import("@storybook/react-native-theming").Theme;
|
|
72
64
|
as?: React.ElementType;
|
|
73
65
|
}, {}, {
|
|
74
|
-
ref?: React.Ref<
|
|
66
|
+
ref?: React.Ref<any>;
|
|
75
67
|
}>;
|
|
76
|
-
declare const Tree: React.NamedExoticComponent<{
|
|
68
|
+
export declare const Tree: React.NamedExoticComponent<{
|
|
77
69
|
isBrowsing: boolean;
|
|
78
70
|
isMain: boolean;
|
|
79
71
|
status?: State["status"];
|
|
80
72
|
refId: string;
|
|
81
|
-
data:
|
|
73
|
+
data: IndexHash;
|
|
82
74
|
docsMode: boolean;
|
|
83
75
|
selectedStoryId: string | null;
|
|
84
76
|
onSelectStoryId: (storyId: string) => void;
|
|
85
77
|
}>;
|
|
86
|
-
|
|
87
|
-
//#region src/Explorer.d.ts
|
|
88
|
-
interface ExplorerProps {
|
|
78
|
+
export interface ExplorerProps {
|
|
89
79
|
isLoading: boolean;
|
|
90
80
|
isBrowsing: boolean;
|
|
91
81
|
dataset: CombinedDataset;
|
|
92
82
|
selected: Selection;
|
|
93
83
|
setSelection: (selection: Selection) => void;
|
|
94
84
|
}
|
|
95
|
-
declare const Explorer: FC<ExplorerProps>;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
declare const useCombination: (index: SidebarProps["index"], indexError: SidebarProps["indexError"], previewInitialized: SidebarProps["previewInitialized"], status: SidebarProps["status"], refs: SidebarProps["refs"]) => CombinedDataset;
|
|
99
|
-
interface SidebarProps extends API_LoadedRefData {
|
|
85
|
+
export declare const Explorer: FC<ExplorerProps>;
|
|
86
|
+
export declare const useCombination: (index: SidebarProps["index"], indexError: SidebarProps["indexError"], previewInitialized: SidebarProps["previewInitialized"], status: SidebarProps["status"], refs: SidebarProps["refs"]) => CombinedDataset;
|
|
87
|
+
export interface SidebarProps extends API_LoadedRefData {
|
|
100
88
|
refs: State['refs'];
|
|
101
89
|
status: State['status'];
|
|
102
90
|
storyId?: string;
|
|
@@ -105,15 +93,12 @@ interface SidebarProps extends API_LoadedRefData {
|
|
|
105
93
|
setSelection: (selection: Selection) => void;
|
|
106
94
|
onSearchActiveChange?: (active: boolean) => void;
|
|
107
95
|
}
|
|
108
|
-
declare const Sidebar: React.MemoExoticComponent<({ storyId, refId, index, indexError, status, previewInitialized, refs, setSelection, onSearchActiveChange }: SidebarProps) => React.JSX.Element>;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
declare const LiteUI: SBUI;
|
|
112
|
-
declare const Layout: ({ storyHash, story, storyBackgroundColor, children }: {
|
|
96
|
+
export declare const Sidebar: React.MemoExoticComponent<({ storyId, refId, index, indexError, status, previewInitialized, refs, setSelection, onSearchActiveChange }: SidebarProps) => React.JSX.Element>;
|
|
97
|
+
export declare const LiteUI: SBUI;
|
|
98
|
+
export declare const Layout: ({ storyHash, story, storyBackgroundColor, children }: {
|
|
113
99
|
storyHash: API_IndexHash | undefined;
|
|
114
100
|
story?: StoryContext<ReactRenderer, Args>;
|
|
115
101
|
storyBackgroundColor?: string;
|
|
116
102
|
children: ReactNode | ReactNode[];
|
|
117
103
|
}) => import("react").JSX.Element;
|
|
118
|
-
|
|
119
|
-
export { ComponentNode, Explorer, ExplorerProps, GroupNode, Layout, LeafNodeStyleWrapper, LiteUI, Node, NodeProps, RootNode, RootNodeText, Sidebar, SidebarProps, StoryNode, Tree, useCombination };
|
|
104
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
// \0rolldown/runtime.js
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -16,11 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
20
20
|
value: mod,
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
|
-
//#endregion
|
|
24
23
|
let _storybook_react_native_theming = require("@storybook/react-native-theming");
|
|
25
24
|
let react = require("react");
|
|
26
25
|
react = __toESM(react);
|
|
@@ -30,12 +29,12 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
30
29
|
let _storybook_react_native_ui_common = require("@storybook/react-native-ui-common");
|
|
31
30
|
let _legendapp_list_react_native = require("@legendapp/list/react-native");
|
|
32
31
|
let react_native_safe_area_context = require("react-native-safe-area-context");
|
|
33
|
-
let
|
|
32
|
+
let _nozbe_microfuzz_react = require("@nozbe/microfuzz/react");
|
|
34
33
|
let _gorhom_portal = require("@gorhom/portal");
|
|
35
34
|
let storybook_internal_core_events = require("storybook/internal/core-events");
|
|
36
35
|
let storybook_internal_types = require("storybook/internal/types");
|
|
37
36
|
let storybook_manager_api = require("storybook/manager-api");
|
|
38
|
-
|
|
37
|
+
// src/icon/iconDataUris.tsx
|
|
39
38
|
/**
|
|
40
39
|
* Auto-generated file with icon data URIs
|
|
41
40
|
* Generated on: 2025-05-17T12:14:23.666Z
|
|
@@ -245,8 +244,7 @@ function StoryIcon({ color, width = 12, height = 12, size }) {
|
|
|
245
244
|
}
|
|
246
245
|
});
|
|
247
246
|
}
|
|
248
|
-
|
|
249
|
-
//#region src/TreeNode.tsx
|
|
247
|
+
// src/TreeNode.tsx
|
|
250
248
|
const BranchNodeText = _storybook_react_native_theming.styled.Text(({ theme }) => ({
|
|
251
249
|
textAlign: "left",
|
|
252
250
|
fontSize: theme.typography.size.s2 + 1,
|
|
@@ -256,7 +254,6 @@ const BranchNodeText = _storybook_react_native_theming.styled.Text(({ theme }) =
|
|
|
256
254
|
const BranchNode = _storybook_react_native_theming.styled.TouchableOpacity(({ depth = 0, isExpandable = false, theme }) => ({
|
|
257
255
|
width: "100%",
|
|
258
256
|
border: "none",
|
|
259
|
-
cursor: "pointer",
|
|
260
257
|
display: "flex",
|
|
261
258
|
flexDirection: "row",
|
|
262
259
|
alignItems: "center",
|
|
@@ -273,7 +270,6 @@ const BranchNode = _storybook_react_native_theming.styled.TouchableOpacity(({ de
|
|
|
273
270
|
}
|
|
274
271
|
}));
|
|
275
272
|
const LeafNode = _storybook_react_native_theming.styled.TouchableOpacity(({ depth = 0, selected, theme }) => ({
|
|
276
|
-
cursor: "pointer",
|
|
277
273
|
color: "inherit",
|
|
278
274
|
display: "flex",
|
|
279
275
|
gap: 6,
|
|
@@ -367,8 +363,7 @@ const StoryNode = react.default.memo((0, react.forwardRef)(function StoryNode({
|
|
|
367
363
|
});
|
|
368
364
|
}));
|
|
369
365
|
StoryNode.displayName = "StoryNode";
|
|
370
|
-
|
|
371
|
-
//#region src/SelectedNodeProvider.tsx
|
|
366
|
+
// src/SelectedNodeProvider.tsx
|
|
372
367
|
const SelectedNodeContext = (0, react.createContext)({
|
|
373
368
|
registerCallback: () => {},
|
|
374
369
|
scrollCallback: () => {}
|
|
@@ -381,21 +376,20 @@ const SelectedNodeProvider = ({ children }) => {
|
|
|
381
376
|
const scrollCallback = (0, react.useCallback)((options) => {
|
|
382
377
|
scrollCallbackValue?.(options);
|
|
383
378
|
}, [scrollCallbackValue]);
|
|
379
|
+
const value = (0, react.useMemo)(() => ({
|
|
380
|
+
scrollCallback,
|
|
381
|
+
registerCallback
|
|
382
|
+
}), [scrollCallback, registerCallback]);
|
|
384
383
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectedNodeContext.Provider, {
|
|
385
|
-
value
|
|
386
|
-
scrollCallback,
|
|
387
|
-
registerCallback
|
|
388
|
-
},
|
|
384
|
+
value,
|
|
389
385
|
children
|
|
390
386
|
});
|
|
391
387
|
};
|
|
392
388
|
const useSelectedNode = () => (0, react.useContext)(SelectedNodeContext);
|
|
393
|
-
|
|
394
|
-
//#region src/DrawerKeyboardInsetContext.tsx
|
|
389
|
+
// src/DrawerKeyboardInsetContext.tsx
|
|
395
390
|
const DrawerKeyboardInsetContext = (0, react.createContext)(0);
|
|
396
391
|
const useDrawerKeyboardInset = () => (0, react.useContext)(DrawerKeyboardInsetContext);
|
|
397
|
-
|
|
398
|
-
//#region src/Tree.tsx
|
|
392
|
+
// src/Tree.tsx
|
|
399
393
|
const Node = react.default.memo(function Node({ item, refId, isOrphan: _isOrphan, isDisplayed: _isDisplayed, isSelected, isFullyExpanded, color: _2, setFullyExpanded, isExpanded, setExpanded, onSelectStoryId }) {
|
|
400
394
|
const id = (0, _storybook_react_native_ui_common.createId)(item.id, refId);
|
|
401
395
|
if (item.type === "story") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LeafNodeStyleWrapper, {
|
|
@@ -431,7 +425,7 @@ const Node = react.default.memo(function Node({ item, refId, isOrphan: _isOrphan
|
|
|
431
425
|
"aria-expanded": isExpanded,
|
|
432
426
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CollapseIcon, { isExpanded }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RootNodeText, { children: (0, _storybook_react_native_ui_common.startCase)(item.name) })]
|
|
433
427
|
}), isExpanded && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_storybook_react_native_ui_common.IconButton, {
|
|
434
|
-
"aria-label": isFullyExpanded ? "
|
|
428
|
+
"aria-label": isFullyExpanded ? "Collapse all" : "Expand all",
|
|
435
429
|
"data-action": "expand-all",
|
|
436
430
|
"data-expanded": isFullyExpanded,
|
|
437
431
|
hitSlop: {
|
|
@@ -447,23 +441,26 @@ const Node = react.default.memo(function Node({ item, refId, isOrphan: _isOrphan
|
|
|
447
441
|
children: isFullyExpanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CollapseAllIcon, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ExpandAllIcon, {})
|
|
448
442
|
})]
|
|
449
443
|
}, id);
|
|
450
|
-
if (item.type === "component" || item.type === "group")
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
444
|
+
if (item.type === "component" || item.type === "group") {
|
|
445
|
+
const BranchNode = item.type === "component" ? ComponentNode : GroupNode;
|
|
446
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BranchNode, {
|
|
447
|
+
id,
|
|
448
|
+
"aria-controls": item.children && item.children[0],
|
|
449
|
+
"aria-expanded": isExpanded,
|
|
450
|
+
depth: item.depth,
|
|
451
|
+
isComponent: item.type === "component",
|
|
452
|
+
isExpandable: item.children && item.children.length > 0,
|
|
453
|
+
isExpanded,
|
|
454
|
+
onPress: (event) => {
|
|
455
|
+
event.preventDefault();
|
|
456
|
+
setExpanded({
|
|
457
|
+
ids: [item.id],
|
|
458
|
+
value: !isExpanded
|
|
459
|
+
});
|
|
460
|
+
},
|
|
461
|
+
children: (0, _storybook_react_native_ui_common.startCase)(item.name)
|
|
462
|
+
}, id);
|
|
463
|
+
}
|
|
467
464
|
return null;
|
|
468
465
|
});
|
|
469
466
|
const LeafNodeStyleWrapper = _storybook_react_native_theming.styled.View(({ theme }) => ({
|
|
@@ -505,7 +502,6 @@ const CollapseButton = _storybook_react_native_theming.styled.TouchableOpacity((
|
|
|
505
502
|
borderRadius: 4,
|
|
506
503
|
gap: 6,
|
|
507
504
|
alignItems: "center",
|
|
508
|
-
cursor: "pointer",
|
|
509
505
|
minHeight: 34
|
|
510
506
|
}));
|
|
511
507
|
const flexStyle$5 = { flex: 1 };
|
|
@@ -757,8 +753,7 @@ const Root = react.default.memo(function Root({ setExpanded, isFullyExpanded, ex
|
|
|
757
753
|
setFullyExpanded
|
|
758
754
|
});
|
|
759
755
|
});
|
|
760
|
-
|
|
761
|
-
//#region src/Refs.tsx
|
|
756
|
+
// src/Refs.tsx
|
|
762
757
|
const Wrapper = _storybook_react_native_theming.styled.View(() => ({ flex: 1 }));
|
|
763
758
|
const Ref = react.default.memo(function Ref(props) {
|
|
764
759
|
const { index, id: refId, title = refId, isLoading: isLoadingMain, isBrowsing, selectedStoryId, loginUrl, type, expanded = true, indexError, previewInitialized, setSelection } = props;
|
|
@@ -794,12 +789,12 @@ const Ref = react.default.memo(function Ref(props) {
|
|
|
794
789
|
})
|
|
795
790
|
}) });
|
|
796
791
|
});
|
|
797
|
-
|
|
798
|
-
//#region src/Explorer.tsx
|
|
792
|
+
// src/Explorer.tsx
|
|
799
793
|
const containerStyle = { flex: 1 };
|
|
800
794
|
const Explorer = react.default.memo(function Explorer({ isLoading, isBrowsing, dataset, selected, setSelection }) {
|
|
795
|
+
const containerRef = (0, react.useRef)(null);
|
|
801
796
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
802
|
-
ref:
|
|
797
|
+
ref: containerRef,
|
|
803
798
|
style: containerStyle,
|
|
804
799
|
id: "storybook-explorer-tree",
|
|
805
800
|
testID: "storybook-explorer-tree",
|
|
@@ -813,9 +808,9 @@ const Explorer = react.default.memo(function Explorer({ isLoading, isBrowsing, d
|
|
|
813
808
|
}))
|
|
814
809
|
});
|
|
815
810
|
});
|
|
811
|
+
// src/constants.ts
|
|
816
812
|
const DEFAULT_REF_ID = "storybook_internal";
|
|
817
|
-
|
|
818
|
-
//#region src/Search.tsx
|
|
813
|
+
// src/Search.tsx
|
|
819
814
|
const DEFAULT_MAX_SEARCH_RESULTS = 50;
|
|
820
815
|
const SearchIconWrapper = _storybook_react_native_theming.styled.View({
|
|
821
816
|
position: "absolute",
|
|
@@ -856,7 +851,6 @@ const ClearIcon = _storybook_react_native_theming.styled.TouchableOpacity(({ the
|
|
|
856
851
|
right: 0,
|
|
857
852
|
zIndex: 1,
|
|
858
853
|
color: theme.textMutedColor,
|
|
859
|
-
cursor: "pointer",
|
|
860
854
|
display: "flex",
|
|
861
855
|
alignItems: "center",
|
|
862
856
|
justifyContent: "center",
|
|
@@ -917,15 +911,17 @@ const Search = react.default.memo(function Search({ children, dataset, setSelect
|
|
|
917
911
|
(0, react.useEffect)(() => {
|
|
918
912
|
onSearchActiveChange?.(!isBrowsing);
|
|
919
913
|
}, [isBrowsing, onSearchActiveChange]);
|
|
920
|
-
const
|
|
914
|
+
const getText = (0, react.useCallback)((item) => [item.name, item.path?.join(" ") ?? ""], []);
|
|
915
|
+
const mapResultItem = (0, react.useCallback)(({ item, score, matches }) => ({
|
|
916
|
+
item,
|
|
917
|
+
score,
|
|
918
|
+
matches: matches ?? []
|
|
919
|
+
}), []);
|
|
920
|
+
const fuzzyResults = (0, _nozbe_microfuzz_react.useFuzzySearchList)({
|
|
921
921
|
list: searchList,
|
|
922
922
|
queryText,
|
|
923
|
-
getText
|
|
924
|
-
mapResultItem
|
|
925
|
-
item,
|
|
926
|
-
score,
|
|
927
|
-
matches: matches ?? []
|
|
928
|
-
}), [])
|
|
923
|
+
getText,
|
|
924
|
+
mapResultItem
|
|
929
925
|
});
|
|
930
926
|
const results = (0, react.useMemo)(() => {
|
|
931
927
|
if (!queryText) return [];
|
|
@@ -962,7 +958,8 @@ const Search = react.default.memo(function Search({ children, dataset, setSelect
|
|
|
962
958
|
ref: inputRef,
|
|
963
959
|
onChangeText: setInputValue,
|
|
964
960
|
onFocus: () => setIsOpen(true),
|
|
965
|
-
returnKeyType: "search"
|
|
961
|
+
returnKeyType: "search",
|
|
962
|
+
accessibilityLabel: "Find components"
|
|
966
963
|
}),
|
|
967
964
|
isOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ClearIcon, {
|
|
968
965
|
accessibilityRole: "button",
|
|
@@ -987,14 +984,12 @@ const Search = react.default.memo(function Search({ children, dataset, setSelect
|
|
|
987
984
|
})]
|
|
988
985
|
});
|
|
989
986
|
});
|
|
990
|
-
|
|
991
|
-
//#region src/SearchResults.tsx
|
|
987
|
+
// src/SearchResults.tsx
|
|
992
988
|
const noResultsFirstLineStyle = { marginBottom: 4 };
|
|
993
989
|
const flexStyle$3 = { flex: 1 };
|
|
994
990
|
const ResultRow = _storybook_react_native_theming.styled.TouchableOpacity(({ theme, isHighlighted }) => ({
|
|
995
991
|
width: "100%",
|
|
996
992
|
border: "none",
|
|
997
|
-
cursor: "pointer",
|
|
998
993
|
display: "flex",
|
|
999
994
|
flexDirection: "row",
|
|
1000
995
|
alignItems: "flex-start",
|
|
@@ -1214,8 +1209,7 @@ const SearchResults = react.default.memo(function SearchResults({ query, results
|
|
|
1214
1209
|
})
|
|
1215
1210
|
});
|
|
1216
1211
|
});
|
|
1217
|
-
|
|
1218
|
-
//#region src/Sidebar.tsx
|
|
1212
|
+
// src/Sidebar.tsx
|
|
1219
1213
|
const Container$1 = _storybook_react_native_theming.styled.View(({ theme }) => ({
|
|
1220
1214
|
flex: 1,
|
|
1221
1215
|
flexDirection: "column",
|
|
@@ -1303,14 +1297,12 @@ const Sidebar = react.default.memo(function Sidebar({ storyId = null, refId = DE
|
|
|
1303
1297
|
})
|
|
1304
1298
|
}) }) });
|
|
1305
1299
|
});
|
|
1306
|
-
|
|
1307
|
-
//#region src/useAnimatedValue.ts
|
|
1300
|
+
// src/useAnimatedValue.ts
|
|
1308
1301
|
function useAnimatedValue(initialValue, config) {
|
|
1309
1302
|
const [value] = (0, react.useState)(new react_native.Animated.Value(initialValue, config));
|
|
1310
1303
|
return value;
|
|
1311
1304
|
}
|
|
1312
|
-
|
|
1313
|
-
//#region src/MobileAddonsPanel.tsx
|
|
1305
|
+
// src/MobileAddonsPanel.tsx
|
|
1314
1306
|
const MobileAddonsPanel = (0, react.forwardRef)(({ storyId, parameters }, ref) => {
|
|
1315
1307
|
const theme = (0, _storybook_react_native_theming.useTheme)();
|
|
1316
1308
|
const { height } = (0, react_native.useWindowDimensions)();
|
|
@@ -1518,8 +1510,7 @@ const TabText = _storybook_react_native_theming.styled.Text(({ theme, active })
|
|
|
1518
1510
|
fontSize: 12,
|
|
1519
1511
|
lineHeight: 12
|
|
1520
1512
|
}));
|
|
1521
|
-
|
|
1522
|
-
//#region src/MobileMenuDrawer.tsx
|
|
1513
|
+
// src/MobileMenuDrawer.tsx
|
|
1523
1514
|
const flexStyle$1 = { flex: 1 };
|
|
1524
1515
|
const portalContainerStyle = {
|
|
1525
1516
|
flex: 1,
|
|
@@ -1742,8 +1733,7 @@ const MobileMenuDrawer = (0, react.memo)((0, react.forwardRef)(({ children, onVi
|
|
|
1742
1733
|
})
|
|
1743
1734
|
});
|
|
1744
1735
|
}));
|
|
1745
|
-
|
|
1746
|
-
//#region src/ResizeHandle.tsx
|
|
1736
|
+
// src/ResizeHandle.tsx
|
|
1747
1737
|
const ResizeHandle = (0, react.memo)(function ResizeHandle({ direction, onResize, onResizeStart, onResizeEnd }) {
|
|
1748
1738
|
const theme = (0, _storybook_react_native_theming.useTheme)();
|
|
1749
1739
|
const [active, setActive] = (0, react.useState)(false);
|
|
@@ -1810,8 +1800,7 @@ const ResizeHandle = (0, react.memo)(function ResizeHandle({ direction, onResize
|
|
|
1810
1800
|
style
|
|
1811
1801
|
});
|
|
1812
1802
|
});
|
|
1813
|
-
|
|
1814
|
-
//#region src/StorybookLogo.tsx
|
|
1803
|
+
// src/StorybookLogo.tsx
|
|
1815
1804
|
const WIDTH = 125;
|
|
1816
1805
|
const HEIGHT = 25;
|
|
1817
1806
|
const NoBrandLogo = ({ theme }) => theme.base === "light" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Logo, {
|
|
@@ -1850,15 +1839,16 @@ const BrandLogo = ({ theme }) => {
|
|
|
1850
1839
|
else return image;
|
|
1851
1840
|
};
|
|
1852
1841
|
const BrandTitle = ({ theme }) => {
|
|
1842
|
+
const brandTitleStyle = (0, react.useMemo)(() => {
|
|
1843
|
+
return {
|
|
1844
|
+
width: WIDTH,
|
|
1845
|
+
height: HEIGHT,
|
|
1846
|
+
color: theme.color.defaultText,
|
|
1847
|
+
fontSize: theme.typography.size.m1
|
|
1848
|
+
};
|
|
1849
|
+
}, [theme]);
|
|
1853
1850
|
const title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
1854
|
-
style:
|
|
1855
|
-
return {
|
|
1856
|
-
width: WIDTH,
|
|
1857
|
-
height: HEIGHT,
|
|
1858
|
-
color: theme.color.defaultText,
|
|
1859
|
-
fontSize: theme.typography.size.m1
|
|
1860
|
-
};
|
|
1861
|
-
}, [theme]),
|
|
1851
|
+
style: brandTitleStyle,
|
|
1862
1852
|
numberOfLines: 1,
|
|
1863
1853
|
ellipsizeMode: "tail",
|
|
1864
1854
|
children: theme.brand.title
|
|
@@ -1880,8 +1870,7 @@ const StorybookLogo = ({ theme }) => {
|
|
|
1880
1870
|
else if (title) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BrandTitle, { theme });
|
|
1881
1871
|
else return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NoBrandLogo, { theme });
|
|
1882
1872
|
};
|
|
1883
|
-
|
|
1884
|
-
//#region src/Layout.tsx
|
|
1873
|
+
// src/Layout.tsx
|
|
1885
1874
|
const desktopLogoContainer = {
|
|
1886
1875
|
flexDirection: "row",
|
|
1887
1876
|
alignItems: "center",
|
|
@@ -2031,6 +2020,7 @@ const Layout = ({ storyHash, story, storyBackgroundColor, children }) => {
|
|
|
2031
2020
|
const setSelection = (0, react.useCallback)(({ storyId: newStoryId }) => {
|
|
2032
2021
|
storybook_manager_api.addons.getChannel().emit(storybook_internal_core_events.SET_CURRENT_STORY, { storyId: newStoryId });
|
|
2033
2022
|
}, []);
|
|
2023
|
+
const storyPath = react_native.Platform.OS === "ios" && story ? `${story.title}/${story.name}` : void 0;
|
|
2034
2024
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
|
|
2035
2025
|
style: containerStyle,
|
|
2036
2026
|
accessibilityElementsHidden: isDrawerOpen,
|
|
@@ -2117,6 +2107,7 @@ const Layout = ({ storyHash, story, storyBackgroundColor, children }) => {
|
|
|
2117
2107
|
onPress: () => mobileMenuDrawerRef.current?.setMobileMenuOpen(true),
|
|
2118
2108
|
accessibilityRole: "button",
|
|
2119
2109
|
accessibilityLabel: "Open story list",
|
|
2110
|
+
accessibilityValue: storyPath ? { text: storyPath } : void 0,
|
|
2120
2111
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MenuIcon, { color: theme.color.mediumdark }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.Text, {
|
|
2121
2112
|
style: navButtonTextStyle,
|
|
2122
2113
|
numberOfLines: 1,
|
|
@@ -2187,7 +2178,6 @@ const Button = _storybook_react_native_theming.styled.TouchableOpacity(({ theme
|
|
|
2187
2178
|
paddingHorizontal: 7,
|
|
2188
2179
|
fontWeight: theme.typography.weight.bold
|
|
2189
2180
|
}));
|
|
2190
|
-
//#endregion
|
|
2191
2181
|
exports.ComponentNode = ComponentNode;
|
|
2192
2182
|
exports.Explorer = Explorer;
|
|
2193
2183
|
exports.GroupNode = GroupNode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react-native-ui-lite",
|
|
3
|
-
"version": "11.0.0-next.
|
|
3
|
+
"version": "11.0.0-next.3",
|
|
4
4
|
"description": "lightweight ui components for react native storybook",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -29,25 +29,25 @@
|
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@gorhom/portal": "^1.0.14",
|
|
32
|
-
"@legendapp/list": "^3.
|
|
32
|
+
"@legendapp/list": "^3.7.2",
|
|
33
33
|
"@nozbe/microfuzz": "^1.0.0",
|
|
34
|
-
"@storybook/react": "^11.0.0-
|
|
35
|
-
"@storybook/react-native-theming": "^11.0.0-next.
|
|
36
|
-
"@storybook/react-native-ui-common": "^11.0.0-next.
|
|
34
|
+
"@storybook/react": "^11.0.0-rc.1",
|
|
35
|
+
"@storybook/react-native-theming": "^11.0.0-next.3",
|
|
36
|
+
"@storybook/react-native-ui-common": "^11.0.0-next.3",
|
|
37
37
|
"polished": "^4.3.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@types/react": "~19.
|
|
41
|
-
"storybook": "^11.0.0-
|
|
40
|
+
"@types/react": "~19.3.0",
|
|
41
|
+
"storybook": "^11.0.0-rc.1",
|
|
42
42
|
"ts-dedent": "^2.3.0",
|
|
43
|
-
"tsdown": "^0.
|
|
43
|
+
"tsdown": "^0.23.7",
|
|
44
44
|
"typescript": "~6.0.3"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "*",
|
|
48
48
|
"react-native": ">=0.57.0",
|
|
49
49
|
"react-native-safe-area-context": "*",
|
|
50
|
-
"storybook": "^11.0.0-
|
|
50
|
+
"storybook": "^11.0.0-beta.1"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
53
53
|
"node": ">=20.0.0"
|
package/src/Explorer.tsx
CHANGED
package/src/Layout.tsx
CHANGED
|
@@ -20,7 +20,14 @@ import {
|
|
|
20
20
|
useRef,
|
|
21
21
|
useState,
|
|
22
22
|
} from 'react';
|
|
23
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
Platform,
|
|
25
|
+
Text,
|
|
26
|
+
TouchableOpacity,
|
|
27
|
+
useWindowDimensions,
|
|
28
|
+
View,
|
|
29
|
+
ViewStyle,
|
|
30
|
+
} from 'react-native';
|
|
24
31
|
import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
25
32
|
import { SET_CURRENT_STORY } from 'storybook/internal/core-events';
|
|
26
33
|
import type { Args, StoryContext } from 'storybook/internal/csf';
|
|
@@ -262,6 +269,10 @@ export const Layout = ({
|
|
|
262
269
|
channel.emit(SET_CURRENT_STORY, { storyId: newStoryId });
|
|
263
270
|
}, []);
|
|
264
271
|
|
|
272
|
+
// The story list button's label replaces its text on iOS, so expose the open story as its value
|
|
273
|
+
// there. Android still reads the text, and would append a value to the label.
|
|
274
|
+
const storyPath = Platform.OS === 'ios' && story ? `${story.title}/${story.name}` : undefined;
|
|
275
|
+
|
|
265
276
|
return (
|
|
266
277
|
<View
|
|
267
278
|
style={containerStyle}
|
|
@@ -383,6 +394,7 @@ export const Layout = ({
|
|
|
383
394
|
onPress={() => mobileMenuDrawerRef.current?.setMobileMenuOpen(true)}
|
|
384
395
|
accessibilityRole="button"
|
|
385
396
|
accessibilityLabel="Open story list"
|
|
397
|
+
accessibilityValue={storyPath ? { text: storyPath } : undefined}
|
|
386
398
|
>
|
|
387
399
|
<MenuIcon color={theme.color.mediumdark} />
|
|
388
400
|
<Text style={navButtonTextStyle} numberOfLines={1}>
|
package/src/MobileMenuDrawer.tsx
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
Pressable,
|
|
21
21
|
View,
|
|
22
22
|
ViewStyle,
|
|
23
|
-
|
|
23
|
+
KeyboardEvent,
|
|
24
24
|
Platform,
|
|
25
25
|
} from 'react-native';
|
|
26
26
|
import { useSelectedNode } from './SelectedNodeProvider';
|
|
@@ -71,11 +71,11 @@ export const useAnimatedModalHeight = () => {
|
|
|
71
71
|
setKeyboardHeight(0);
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
-
const handleKeyboardShow
|
|
74
|
+
const handleKeyboardShow = (e: KeyboardEvent) => {
|
|
75
75
|
expand(e.endCoordinates.height);
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
const handleKeyboardHide
|
|
78
|
+
const handleKeyboardHide = () => {
|
|
79
79
|
collapse();
|
|
80
80
|
};
|
|
81
81
|
|
package/src/Search.tsx
CHANGED
|
@@ -70,7 +70,6 @@ const ClearIcon = styled.TouchableOpacity(({ theme }) => ({
|
|
|
70
70
|
right: 0,
|
|
71
71
|
zIndex: 1,
|
|
72
72
|
color: theme.textMutedColor,
|
|
73
|
-
cursor: 'pointer',
|
|
74
73
|
display: 'flex',
|
|
75
74
|
alignItems: 'center',
|
|
76
75
|
justifyContent: 'center',
|
|
@@ -97,7 +96,7 @@ export const Search = React.memo<{
|
|
|
97
96
|
onSearchActiveChange,
|
|
98
97
|
}) {
|
|
99
98
|
const theme = useTheme();
|
|
100
|
-
const inputRef = useRef<TextInput
|
|
99
|
+
const inputRef = useRef<React.ComponentRef<typeof TextInput>>(null);
|
|
101
100
|
const [inputValue, setInputValue] = useState(initialQuery);
|
|
102
101
|
const [isOpen, setIsOpen] = useState(false);
|
|
103
102
|
const [allComponents, showAllComponents] = useState(false);
|
|
@@ -257,6 +256,7 @@ export const Search = React.memo<{
|
|
|
257
256
|
onChangeText={setInputValue}
|
|
258
257
|
onFocus={() => setIsOpen(true)}
|
|
259
258
|
returnKeyType="search"
|
|
259
|
+
accessibilityLabel="Find components"
|
|
260
260
|
/>
|
|
261
261
|
|
|
262
262
|
{isOpen && (
|
package/src/SearchResults.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FC, PropsWithChildren } from 'react';
|
|
2
|
-
import { createContext, useCallback, useContext, useState } from 'react';
|
|
2
|
+
import { createContext, useCallback, useContext, useMemo, useState } from 'react';
|
|
3
3
|
type CallbackOptions = { id?: string; animated?: boolean };
|
|
4
4
|
|
|
5
5
|
type SelectedNodeContextType = {
|
|
@@ -28,16 +28,13 @@ export const SelectedNodeProvider: FC<PropsWithChildren> = ({ children }) => {
|
|
|
28
28
|
[scrollCallbackValue]
|
|
29
29
|
);
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
registerCallback,
|
|
36
|
-
}}
|
|
37
|
-
>
|
|
38
|
-
{children}
|
|
39
|
-
</SelectedNodeContext.Provider>
|
|
31
|
+
// Keep the value stable between renders, so its consumers re-render only when it changes.
|
|
32
|
+
const value = useMemo(
|
|
33
|
+
() => ({ scrollCallback, registerCallback }),
|
|
34
|
+
[scrollCallback, registerCallback]
|
|
40
35
|
);
|
|
36
|
+
|
|
37
|
+
return <SelectedNodeContext.Provider value={value}>{children}</SelectedNodeContext.Provider>;
|
|
41
38
|
};
|
|
42
39
|
|
|
43
40
|
export const useSelectedNode = () => useContext(SelectedNodeContext);
|
package/src/Tree.tsx
CHANGED
|
@@ -20,7 +20,7 @@ import type {
|
|
|
20
20
|
ComponentEntry,
|
|
21
21
|
GroupEntry,
|
|
22
22
|
State,
|
|
23
|
-
|
|
23
|
+
IndexHash,
|
|
24
24
|
StoryEntry,
|
|
25
25
|
} from 'storybook/manager-api';
|
|
26
26
|
import { ComponentNode, GroupNode, StoryNode } from './TreeNode';
|
|
@@ -93,7 +93,7 @@ export const Node = React.memo<NodeProps>(function Node({
|
|
|
93
93
|
</CollapseButton>
|
|
94
94
|
{isExpanded && (
|
|
95
95
|
<IconButton
|
|
96
|
-
aria-label={isFullyExpanded ? '
|
|
96
|
+
aria-label={isFullyExpanded ? 'Collapse all' : 'Expand all'}
|
|
97
97
|
data-action="expand-all"
|
|
98
98
|
data-expanded={isFullyExpanded}
|
|
99
99
|
hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
|
|
@@ -176,7 +176,6 @@ const CollapseButton = styled.TouchableOpacity(() => ({
|
|
|
176
176
|
borderRadius: 4,
|
|
177
177
|
gap: 6,
|
|
178
178
|
alignItems: 'center',
|
|
179
|
-
cursor: 'pointer',
|
|
180
179
|
minHeight: 34,
|
|
181
180
|
}));
|
|
182
181
|
|
|
@@ -217,7 +216,7 @@ export const Tree = React.memo<{
|
|
|
217
216
|
isMain: boolean;
|
|
218
217
|
status?: State['status'];
|
|
219
218
|
refId: string;
|
|
220
|
-
data:
|
|
219
|
+
data: IndexHash;
|
|
221
220
|
docsMode: boolean;
|
|
222
221
|
selectedStoryId: string | null;
|
|
223
222
|
onSelectStoryId: (storyId: string) => void;
|
package/src/TreeNode.tsx
CHANGED
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
import { styled, useTheme } from '@storybook/react-native-theming';
|
|
2
2
|
|
|
3
|
-
import React, {
|
|
3
|
+
import React, { FC, forwardRef, useMemo } from 'react';
|
|
4
4
|
import { transparentize } from 'polished';
|
|
5
|
-
import { View } from 'react-native';
|
|
5
|
+
import { TouchableOpacityProps, View } from 'react-native';
|
|
6
6
|
import { CollapseIcon, ComponentIcon, GroupIcon, StoryIcon } from './icon/iconDataUris';
|
|
7
7
|
|
|
8
|
+
// Declared here rather than inferred from the styled components. Since react-native 0.88 its default types are the
|
|
9
|
+
// generated ones, where TouchableOpacityProps and View's ref expand into types react-native doesn't export
|
|
10
|
+
// (WithAnimatedValue, ____ViewStyleProp_Internal, ReactNativeElement), so TypeScript can't name them in our emitted
|
|
11
|
+
// declarations. An interface keeps its own name, so these don't expand.
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
13
|
+
export interface StoryNodeRef extends React.ComponentRef<typeof View> {}
|
|
14
|
+
|
|
15
|
+
export interface BranchNodeProps extends TouchableOpacityProps {
|
|
16
|
+
depth?: number;
|
|
17
|
+
isExpandable?: boolean;
|
|
18
|
+
isExpanded?: boolean;
|
|
19
|
+
isComponent?: boolean;
|
|
20
|
+
isSelected?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface LeafNodeProps extends TouchableOpacityProps {
|
|
24
|
+
depth?: number;
|
|
25
|
+
selected?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
8
28
|
export interface NodeProps {
|
|
9
29
|
children: React.ReactNode | React.ReactNode[];
|
|
10
30
|
isExpandable?: boolean;
|
|
@@ -18,55 +38,47 @@ const BranchNodeText = styled.Text<{ isSelected?: boolean }>(({ theme }) => ({
|
|
|
18
38
|
color: theme.color.defaultText,
|
|
19
39
|
}));
|
|
20
40
|
|
|
21
|
-
const BranchNode = styled.TouchableOpacity<
|
|
22
|
-
depth
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
isComponent?: boolean;
|
|
26
|
-
isSelected?: boolean;
|
|
27
|
-
}>(({ depth = 0, isExpandable = false, theme }) => ({
|
|
28
|
-
width: '100%',
|
|
29
|
-
border: 'none',
|
|
30
|
-
cursor: 'pointer',
|
|
31
|
-
display: 'flex',
|
|
32
|
-
flexDirection: 'row',
|
|
33
|
-
alignItems: 'center',
|
|
34
|
-
paddingLeft: (isExpandable ? 8 : 22) + depth * 18,
|
|
35
|
-
|
|
36
|
-
backgroundColor: 'transparent',
|
|
37
|
-
minHeight: 34,
|
|
38
|
-
borderRadius: 4,
|
|
39
|
-
gap: 6,
|
|
40
|
-
paddingTop: 8,
|
|
41
|
-
paddingBottom: 7,
|
|
42
|
-
|
|
43
|
-
// will this actually do anything?
|
|
44
|
-
'&:hover, &:focus': {
|
|
45
|
-
backgroundColor: transparentize(0.93, theme.color.secondary),
|
|
46
|
-
outline: 'none',
|
|
47
|
-
},
|
|
48
|
-
}));
|
|
49
|
-
|
|
50
|
-
const LeafNode = styled.TouchableOpacity<{ depth?: number; selected?: boolean }>(
|
|
51
|
-
({ depth = 0, selected, theme }) => ({
|
|
52
|
-
cursor: 'pointer',
|
|
53
|
-
color: 'inherit',
|
|
41
|
+
const BranchNode = styled.TouchableOpacity<BranchNodeProps>(
|
|
42
|
+
({ depth = 0, isExpandable = false, theme }) => ({
|
|
43
|
+
width: '100%',
|
|
44
|
+
border: 'none',
|
|
54
45
|
display: 'flex',
|
|
55
|
-
gap: 6,
|
|
56
46
|
flexDirection: 'row',
|
|
57
47
|
alignItems: 'center',
|
|
58
|
-
paddingLeft: 22 + depth * 18,
|
|
48
|
+
paddingLeft: (isExpandable ? 8 : 22) + depth * 18,
|
|
49
|
+
|
|
50
|
+
backgroundColor: 'transparent',
|
|
51
|
+
minHeight: 34,
|
|
52
|
+
borderRadius: 4,
|
|
53
|
+
gap: 6,
|
|
59
54
|
paddingTop: 8,
|
|
60
55
|
paddingBottom: 7,
|
|
61
|
-
|
|
62
|
-
//
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
|
|
57
|
+
// will this actually do anything?
|
|
58
|
+
'&:hover, &:focus': {
|
|
59
|
+
backgroundColor: transparentize(0.93, theme.color.secondary),
|
|
60
|
+
outline: 'none',
|
|
61
|
+
},
|
|
67
62
|
})
|
|
68
63
|
);
|
|
69
64
|
|
|
65
|
+
const LeafNode = styled.TouchableOpacity<LeafNodeProps>(({ depth = 0, selected, theme }) => ({
|
|
66
|
+
color: 'inherit',
|
|
67
|
+
display: 'flex',
|
|
68
|
+
gap: 6,
|
|
69
|
+
flexDirection: 'row',
|
|
70
|
+
alignItems: 'center',
|
|
71
|
+
paddingLeft: 22 + depth * 18,
|
|
72
|
+
paddingTop: 8,
|
|
73
|
+
paddingBottom: 7,
|
|
74
|
+
backgroundColor: selected ? theme.color.secondary : undefined,
|
|
75
|
+
// not sure 👇
|
|
76
|
+
width: '100%',
|
|
77
|
+
borderRadius: 4,
|
|
78
|
+
paddingRight: 20,
|
|
79
|
+
minHeight: 34,
|
|
80
|
+
}));
|
|
81
|
+
|
|
70
82
|
const LeafNodeText = styled.Text<{ depth?: number; selected?: boolean }>(({ theme, selected }) => ({
|
|
71
83
|
fontSize: theme.typography.size.s2 + 1,
|
|
72
84
|
flexShrink: 1,
|
|
@@ -81,9 +93,7 @@ const Wrapper = styled.View({
|
|
|
81
93
|
gap: 6,
|
|
82
94
|
});
|
|
83
95
|
|
|
84
|
-
export const GroupNode: FC<
|
|
85
|
-
ComponentProps<typeof BranchNode> & { isExpanded?: boolean; isExpandable?: boolean }
|
|
86
|
-
> = React.memo(function GroupNode({
|
|
96
|
+
export const GroupNode: FC<BranchNodeProps> = React.memo(function GroupNode({
|
|
87
97
|
children,
|
|
88
98
|
isExpanded = false,
|
|
89
99
|
isExpandable = false,
|
|
@@ -106,32 +116,32 @@ export const GroupNode: FC<
|
|
|
106
116
|
);
|
|
107
117
|
});
|
|
108
118
|
|
|
109
|
-
export const ComponentNode: FC<
|
|
110
|
-
|
|
111
|
-
|
|
119
|
+
export const ComponentNode: FC<BranchNodeProps> = React.memo(function ComponentNode({
|
|
120
|
+
children,
|
|
121
|
+
isExpanded,
|
|
122
|
+
isExpandable,
|
|
123
|
+
...props
|
|
124
|
+
}) {
|
|
125
|
+
const theme = useTheme();
|
|
112
126
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
127
|
+
const color = useMemo(() => {
|
|
128
|
+
return theme.color.secondary;
|
|
129
|
+
}, [theme.color.secondary]);
|
|
116
130
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
);
|
|
131
|
+
return (
|
|
132
|
+
<BranchNode isExpandable={isExpandable} accessibilityRole="button" {...props}>
|
|
133
|
+
{/* workaround for macos icon color bug */}
|
|
134
|
+
<Wrapper key={`component-${props.id}-${color}`}>
|
|
135
|
+
{isExpandable && <CollapseIcon isExpanded={isExpanded} />}
|
|
136
|
+
<ComponentIcon width={12} height={12} color={color} />
|
|
137
|
+
</Wrapper>
|
|
138
|
+
<BranchNodeText numberOfLines={1}>{children}</BranchNodeText>
|
|
139
|
+
</BranchNode>
|
|
140
|
+
);
|
|
141
|
+
});
|
|
129
142
|
|
|
130
143
|
export const StoryNode = React.memo(
|
|
131
|
-
forwardRef<
|
|
132
|
-
{ children, ...props },
|
|
133
|
-
ref
|
|
134
|
-
) {
|
|
144
|
+
forwardRef<StoryNodeRef, LeafNodeProps>(function StoryNode({ children, ...props }, ref) {
|
|
135
145
|
const theme = useTheme();
|
|
136
146
|
|
|
137
147
|
const color = useMemo(() => {
|
package/src/useKeyboard.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
// taken from https://github.com/react-native-community/hooks/blob/main/src/useKeyboard.ts
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
|
-
import { Keyboard,
|
|
3
|
+
import { Keyboard, KeyboardEvent, KeyboardMetrics } from 'react-native';
|
|
4
|
+
|
|
5
|
+
// react-native 0.88 no longer exports KeyboardEventListener
|
|
6
|
+
type KeyboardEventListener = (event: KeyboardEvent) => void;
|
|
7
|
+
|
|
8
|
+
// Only iOS keyboard events have startCoordinates
|
|
9
|
+
const startCoordinates = (e: KeyboardEvent): KeyboardMetrics | undefined =>
|
|
10
|
+
'startCoordinates' in e ? e.startCoordinates : undefined;
|
|
4
11
|
|
|
5
12
|
const emptyCoordinates = Object.freeze({
|
|
6
13
|
screenX: 0,
|
|
@@ -22,20 +29,20 @@ export function useKeyboard() {
|
|
|
22
29
|
const [keyboardHeight, setKeyboardHeight] = useState<number>(0);
|
|
23
30
|
|
|
24
31
|
const handleKeyboardWillShow: KeyboardEventListener = (e) => {
|
|
25
|
-
setCoordinates({ start: e
|
|
32
|
+
setCoordinates({ start: startCoordinates(e), end: e.endCoordinates });
|
|
26
33
|
};
|
|
27
34
|
const handleKeyboardDidShow: KeyboardEventListener = (e) => {
|
|
28
35
|
setShown(true);
|
|
29
|
-
setCoordinates({ start: e
|
|
36
|
+
setCoordinates({ start: startCoordinates(e), end: e.endCoordinates });
|
|
30
37
|
setKeyboardHeight(e.endCoordinates.height);
|
|
31
38
|
};
|
|
32
39
|
const handleKeyboardWillHide: KeyboardEventListener = (e) => {
|
|
33
|
-
setCoordinates({ start: e
|
|
40
|
+
setCoordinates({ start: startCoordinates(e), end: e.endCoordinates });
|
|
34
41
|
};
|
|
35
42
|
const handleKeyboardDidHide: KeyboardEventListener = (e) => {
|
|
36
43
|
setShown(false);
|
|
37
44
|
if (e) {
|
|
38
|
-
setCoordinates({ start: e
|
|
45
|
+
setCoordinates({ start: startCoordinates(e), end: e.endCoordinates });
|
|
39
46
|
} else {
|
|
40
47
|
setCoordinates(initialValue);
|
|
41
48
|
setKeyboardHeight(0);
|