@storybook/react-native-ui-common 9.1.0 → 9.1.1-alpha.1
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 +1 -1
- package/dist/index.js +29 -55
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -189,4 +189,4 @@ declare const useLastViewed: (selection: Selection) => {
|
|
|
189
189
|
|
|
190
190
|
declare const useStoreBooleanState: (key: string, defaultValue: boolean) => ReturnType<typeof useState<boolean>>;
|
|
191
191
|
|
|
192
|
-
export { Button, ButtonIcon, ButtonProps, ButtonText, CombinedDataset, Dataset, ExpandAction, ExpandType, ExpandedProps, ExpandedState, GetSearchItemProps, Highlight, IconButton, Item, ItemRef, LayoutProvider, RefType, Refs, SBUI, SearchChildrenFn, SearchItem, SearchResult, SearchResultProps, Selection, Storage, StorageProvider, StoryRef, createId, cycle, get, getAncestorIds, getDescendantIds, getParent, getParents, getPath, getStateType, intersect, isAncestor, isExpandType, isStoryHoistable, merge, noArrayMerge, prevent, removeNoiseFromName, searchItem, transformStoryIndexToStoriesHash, transformStoryIndexV2toV3, transformStoryIndexV3toV4, transformStoryIndexV4toV5, useExpanded, useLastViewed, useLayout, useStorage, useStoreBooleanState, useStyle };
|
|
192
|
+
export { Button, ButtonIcon, type ButtonProps, ButtonText, type CombinedDataset, type Dataset, type ExpandAction, type ExpandType, type ExpandedProps, type ExpandedState, type GetSearchItemProps, type Highlight, IconButton, type Item, type ItemRef, LayoutProvider, type RefType, type Refs, type SBUI, type SearchChildrenFn, type SearchItem, type SearchResult, type SearchResultProps, type Selection, type Storage, StorageProvider, type StoryRef, createId, cycle, get, getAncestorIds, getDescendantIds, getParent, getParents, getPath, getStateType, intersect, isAncestor, isExpandType, isStoryHoistable, merge, noArrayMerge, prevent, removeNoiseFromName, searchItem, transformStoryIndexToStoriesHash, transformStoryIndexV2toV3, transformStoryIndexV3toV4, transformStoryIndexV4toV5, useExpanded, useLastViewed, useLayout, useStorage, useStoreBooleanState, useStyle };
|
package/dist/index.js
CHANGED
|
@@ -27,8 +27,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
|
|
29
29
|
// src/index.tsx
|
|
30
|
-
var
|
|
31
|
-
__export(
|
|
30
|
+
var index_exports = {};
|
|
31
|
+
__export(index_exports, {
|
|
32
32
|
Button: () => Button,
|
|
33
33
|
ButtonIcon: () => ButtonIcon,
|
|
34
34
|
ButtonText: () => ButtonText,
|
|
@@ -64,7 +64,7 @@ __export(src_exports, {
|
|
|
64
64
|
useStoreBooleanState: () => useStoreBooleanState,
|
|
65
65
|
useStyle: () => useStyle
|
|
66
66
|
});
|
|
67
|
-
module.exports = __toCommonJS(
|
|
67
|
+
module.exports = __toCommonJS(index_exports);
|
|
68
68
|
|
|
69
69
|
// src/Button.tsx
|
|
70
70
|
var import_react_native_theming = require("@storybook/react-native-theming");
|
|
@@ -86,16 +86,13 @@ var Button = (0, import_react.forwardRef)(
|
|
|
86
86
|
}, ref) => {
|
|
87
87
|
const [isAnimating, setIsAnimating] = (0, import_react.useState)(false);
|
|
88
88
|
const handleClick = (event) => {
|
|
89
|
-
if (onPress)
|
|
90
|
-
|
|
91
|
-
if (animation === "none")
|
|
92
|
-
return;
|
|
89
|
+
if (onPress) onPress(event);
|
|
90
|
+
if (animation === "none") return;
|
|
93
91
|
setIsAnimating(true);
|
|
94
92
|
};
|
|
95
93
|
(0, import_react.useEffect)(() => {
|
|
96
94
|
const timer = setTimeout(() => {
|
|
97
|
-
if (isAnimating)
|
|
98
|
-
setIsAnimating(false);
|
|
95
|
+
if (isAnimating) setIsAnimating(false);
|
|
99
96
|
}, 1e3);
|
|
100
97
|
return () => clearTimeout(timer);
|
|
101
98
|
}, [isAnimating]);
|
|
@@ -132,14 +129,10 @@ var StyledButton = import_react_native_theming.styled.TouchableOpacity(({ theme,
|
|
|
132
129
|
justifyContent: "center",
|
|
133
130
|
overflow: "hidden",
|
|
134
131
|
paddingHorizontal: (() => {
|
|
135
|
-
if (padding === "small" && size === "small")
|
|
136
|
-
|
|
137
|
-
if (
|
|
138
|
-
|
|
139
|
-
if (size === "small")
|
|
140
|
-
return 10;
|
|
141
|
-
if (size === "medium")
|
|
142
|
-
return 12;
|
|
132
|
+
if (padding === "small" && size === "small") return 7;
|
|
133
|
+
if (padding === "small" && size === "medium") return 9;
|
|
134
|
+
if (size === "small") return 10;
|
|
135
|
+
if (size === "medium") return 12;
|
|
143
136
|
return 0;
|
|
144
137
|
})(),
|
|
145
138
|
paddingVertical: 0,
|
|
@@ -153,12 +146,9 @@ var StyledButton = import_react_native_theming.styled.TouchableOpacity(({ theme,
|
|
|
153
146
|
opacity: disabled ? 0.5 : 1,
|
|
154
147
|
margin: 0,
|
|
155
148
|
backgroundColor: (() => {
|
|
156
|
-
if (variant === "solid")
|
|
157
|
-
|
|
158
|
-
if (variant === "
|
|
159
|
-
return theme.button.background;
|
|
160
|
-
if (variant === "ghost" && active)
|
|
161
|
-
return theme.background.hoverable;
|
|
149
|
+
if (variant === "solid") return theme.color.secondary;
|
|
150
|
+
if (variant === "outline") return theme.button.background;
|
|
151
|
+
if (variant === "ghost" && active) return theme.background.hoverable;
|
|
162
152
|
return "transparent";
|
|
163
153
|
})(),
|
|
164
154
|
boxShadow: variant === "outline" ? `${theme.button.border} 0 0 0 1px inset` : "none",
|
|
@@ -168,14 +158,10 @@ var StyledButton = import_react_native_theming.styled.TouchableOpacity(({ theme,
|
|
|
168
158
|
}));
|
|
169
159
|
var ButtonText = import_react_native_theming.styled.Text(({ theme, variant, active }) => ({
|
|
170
160
|
color: (() => {
|
|
171
|
-
if (variant === "solid")
|
|
172
|
-
|
|
173
|
-
if (variant === "
|
|
174
|
-
|
|
175
|
-
if (variant === "ghost" && active)
|
|
176
|
-
return theme.color.secondary;
|
|
177
|
-
if (variant === "ghost")
|
|
178
|
-
return theme.color.mediumdark;
|
|
161
|
+
if (variant === "solid") return theme.color.lightest;
|
|
162
|
+
if (variant === "outline") return theme.input.color;
|
|
163
|
+
if (variant === "ghost" && active) return theme.color.secondary;
|
|
164
|
+
if (variant === "ghost") return theme.color.mediumdark;
|
|
179
165
|
return theme.input.color;
|
|
180
166
|
})(),
|
|
181
167
|
flexDirection: "row",
|
|
@@ -191,14 +177,10 @@ var ButtonIcon = ({
|
|
|
191
177
|
}) => {
|
|
192
178
|
const theme = (0, import_react_native_theming.useTheme)();
|
|
193
179
|
const color = (0, import_react.useMemo)(() => {
|
|
194
|
-
if (variant === "solid")
|
|
195
|
-
|
|
196
|
-
if (variant === "
|
|
197
|
-
|
|
198
|
-
if (variant === "ghost" && active)
|
|
199
|
-
return theme.color.secondary;
|
|
200
|
-
if (variant === "ghost")
|
|
201
|
-
return theme.color.mediumdark;
|
|
180
|
+
if (variant === "solid") return theme.color.lightest;
|
|
181
|
+
if (variant === "outline") return theme.input.color;
|
|
182
|
+
if (variant === "ghost" && active) return theme.color.secondary;
|
|
183
|
+
if (variant === "ghost") return theme.color.mediumdark;
|
|
202
184
|
return theme.input.color;
|
|
203
185
|
}, [
|
|
204
186
|
active,
|
|
@@ -551,16 +533,14 @@ var getDescendantIds = (0, import_memoizerific.default)(1e3)((data, id, skipLeaf
|
|
|
551
533
|
const children = entry.type === "story" || entry.type === "docs" ? [] : entry.children;
|
|
552
534
|
return children.reduce((acc, childId) => {
|
|
553
535
|
const child = data[childId];
|
|
554
|
-
if (!child || skipLeafs && (child.type === "story" || child.type === "docs"))
|
|
555
|
-
return acc;
|
|
536
|
+
if (!child || skipLeafs && (child.type === "story" || child.type === "docs")) return acc;
|
|
556
537
|
acc.push(childId, ...getDescendantIds(data, childId, skipLeafs));
|
|
557
538
|
return acc;
|
|
558
539
|
}, []);
|
|
559
540
|
});
|
|
560
541
|
function getPath(item, ref) {
|
|
561
542
|
const parent = item.type !== "root" && item.parent ? ref.index[item.parent] : null;
|
|
562
|
-
if (parent)
|
|
563
|
-
return [...getPath(parent, ref), parent.name];
|
|
543
|
+
if (parent) return [...getPath(parent, ref), parent.name];
|
|
564
544
|
return ref.id === DEFAULT_REF_ID ? [] : [ref.title || ref.id];
|
|
565
545
|
}
|
|
566
546
|
var searchItem = (item, ref) => {
|
|
@@ -568,10 +548,8 @@ var searchItem = (item, ref) => {
|
|
|
568
548
|
};
|
|
569
549
|
function cycle(array, index, delta) {
|
|
570
550
|
let next = index + delta % array.length;
|
|
571
|
-
if (next < 0)
|
|
572
|
-
|
|
573
|
-
if (next >= array.length)
|
|
574
|
-
next -= array.length;
|
|
551
|
+
if (next < 0) next = array.length + next;
|
|
552
|
+
if (next >= array.length) next -= array.length;
|
|
575
553
|
return next;
|
|
576
554
|
}
|
|
577
555
|
var getStateType = (isLoading, isAuthRequired, isError, isEmpty) => {
|
|
@@ -589,10 +567,8 @@ var getStateType = (isLoading, isAuthRequired, isError, isEmpty) => {
|
|
|
589
567
|
}
|
|
590
568
|
};
|
|
591
569
|
var isAncestor = (element, maybeAncestor) => {
|
|
592
|
-
if (!element || !maybeAncestor)
|
|
593
|
-
|
|
594
|
-
if (element === maybeAncestor)
|
|
595
|
-
return true;
|
|
570
|
+
if (!element || !maybeAncestor) return false;
|
|
571
|
+
if (element === maybeAncestor) return true;
|
|
596
572
|
return isAncestor(element.parentElement, maybeAncestor);
|
|
597
573
|
};
|
|
598
574
|
var removeNoiseFromName = (storyName) => storyName.replaceAll(/(\s|-|_)/gi, "");
|
|
@@ -649,8 +625,7 @@ var useLastViewed = (selection) => {
|
|
|
649
625
|
const index = items.findIndex(
|
|
650
626
|
({ storyId, refId }) => storyId === story.storyId && refId === story.refId
|
|
651
627
|
);
|
|
652
|
-
if (index === 0)
|
|
653
|
-
return;
|
|
628
|
+
if (index === 0) return;
|
|
654
629
|
if (index === -1) {
|
|
655
630
|
lastViewedRef.current = [story, ...items];
|
|
656
631
|
} else {
|
|
@@ -660,8 +635,7 @@ var useLastViewed = (selection) => {
|
|
|
660
635
|
[lastViewedRef]
|
|
661
636
|
);
|
|
662
637
|
(0, import_react7.useEffect)(() => {
|
|
663
|
-
if (selection)
|
|
664
|
-
updateLastViewed(selection);
|
|
638
|
+
if (selection) updateLastViewed(selection);
|
|
665
639
|
}, [selection]);
|
|
666
640
|
return {
|
|
667
641
|
getLastViewed: (0, import_react7.useCallback)(() => lastViewedRef.current, [lastViewedRef]),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react-native-ui-common",
|
|
3
|
-
"version": "9.1.
|
|
3
|
+
"version": "9.1.1-alpha.1",
|
|
4
4
|
"description": "common ui components for react native storybook",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
"babel-jest": "^29.7.0",
|
|
54
54
|
"jest": "^29.7.0",
|
|
55
55
|
"react-test-renderer": "^19.1.0",
|
|
56
|
-
"tsup": "^
|
|
56
|
+
"tsup": "^8.5.0",
|
|
57
57
|
"typescript": "~5.8.3"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@storybook/react": "^9.1.
|
|
61
|
-
"@storybook/react-native-theming": "^9.1.
|
|
60
|
+
"@storybook/react": "^9.1.2",
|
|
61
|
+
"@storybook/react-native-theming": "^9.1.1-alpha.1",
|
|
62
62
|
"es-toolkit": "^1.38.0",
|
|
63
63
|
"fuse.js": "^7.0.0",
|
|
64
64
|
"memoizerific": "^1.11.3",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"publishConfig": {
|
|
78
78
|
"access": "public"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "cc38bfb53177171ffb92d228c0bcde0e4d01d767"
|
|
81
81
|
}
|