@ankhorage/zora 2.4.8 → 2.5.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/CHANGELOG.md +12 -0
- package/README.md +3 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/metadata/bindableComponentMeta.d.ts +553 -0
- package/dist/metadata/bindableComponentMeta.d.ts.map +1 -0
- package/dist/metadata/bindableComponentMeta.js +473 -0
- package/dist/metadata/bindableComponentMeta.js.map +1 -0
- package/dist/metadata/index.d.ts +2 -0
- package/dist/metadata/index.d.ts.map +1 -1
- package/dist/metadata/index.js +1 -0
- package/dist/metadata/index.js.map +1 -1
- package/dist/patterns/responsive-panel/ResponsivePanel.d.ts.map +1 -1
- package/dist/patterns/responsive-panel/ResponsivePanel.js +60 -7
- package/dist/patterns/responsive-panel/ResponsivePanel.js.map +1 -1
- package/dist/patterns/responsive-panel/types.d.ts +4 -0
- package/dist/patterns/responsive-panel/types.d.ts.map +1 -1
- package/dist/patterns/responsive-panel/types.js.map +1 -1
- package/dist/theme/useZoraTheme.d.ts +1 -1
- package/package.json +9 -2
- package/src/index.ts +4 -1
- package/src/metadata/bindableComponentMeta.test.ts +18 -0
- package/src/metadata/bindableComponentMeta.ts +476 -0
- package/src/metadata/index.ts +2 -0
- package/src/patterns/responsive-panel/ResponsivePanel.tsx +78 -6
- package/src/patterns/responsive-panel/types.ts +4 -0
|
@@ -1,10 +1,59 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ScrollView, StyleSheet, View } from 'react-native';
|
|
2
3
|
|
|
3
4
|
import { Drawer } from '../../components/drawer';
|
|
4
5
|
import { Modal } from '../../components/modal';
|
|
6
|
+
import type { ZoraContentWidth } from '../../internal/recipes';
|
|
5
7
|
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
6
8
|
import { Panel } from '../panel';
|
|
7
|
-
import type { ResponsivePanelProps } from './types';
|
|
9
|
+
import type { ResponsivePanelProps, ResponsivePanelScroll, ResponsivePanelSize } from './types';
|
|
10
|
+
|
|
11
|
+
function resolvePanelWidth(size: ResponsivePanelSize): number {
|
|
12
|
+
switch (size) {
|
|
13
|
+
case 'compact':
|
|
14
|
+
return 300;
|
|
15
|
+
case 'wide':
|
|
16
|
+
return 420;
|
|
17
|
+
case 'extraWide':
|
|
18
|
+
return 560;
|
|
19
|
+
case 'default':
|
|
20
|
+
default:
|
|
21
|
+
return 360;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function resolveModalWidth(size: ResponsivePanelSize | undefined): ZoraContentWidth | undefined {
|
|
26
|
+
switch (size) {
|
|
27
|
+
case 'compact':
|
|
28
|
+
return 'narrow';
|
|
29
|
+
case 'wide':
|
|
30
|
+
case 'extraWide':
|
|
31
|
+
return 'wide';
|
|
32
|
+
case 'default':
|
|
33
|
+
return 'default';
|
|
34
|
+
default:
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function renderPanelBody(children: React.ReactNode, scroll: ResponsivePanelScroll) {
|
|
40
|
+
if (children == null) return null;
|
|
41
|
+
|
|
42
|
+
if (scroll === 'content') {
|
|
43
|
+
return (
|
|
44
|
+
<ScrollView
|
|
45
|
+
contentContainerStyle={styles.scrollContent}
|
|
46
|
+
keyboardShouldPersistTaps="handled"
|
|
47
|
+
showsVerticalScrollIndicator
|
|
48
|
+
style={styles.scrollBody}
|
|
49
|
+
>
|
|
50
|
+
{children}
|
|
51
|
+
</ScrollView>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return children;
|
|
56
|
+
}
|
|
8
57
|
|
|
9
58
|
function ResponsivePanelInner({
|
|
10
59
|
themeId: _themeId,
|
|
@@ -20,14 +69,20 @@ function ResponsivePanelInner({
|
|
|
20
69
|
desktopMode = 'inline',
|
|
21
70
|
mobileMode = 'drawer',
|
|
22
71
|
compact = true,
|
|
72
|
+
size,
|
|
73
|
+
scroll = 'none',
|
|
23
74
|
testID,
|
|
24
75
|
}: ResponsivePanelProps) {
|
|
25
76
|
if (!open) return null;
|
|
26
77
|
|
|
78
|
+
const body = renderPanelBody(children, scroll);
|
|
79
|
+
|
|
27
80
|
// For now, we assume desktopMode determines the rendering.
|
|
28
81
|
// In a real app, this would react to window size.
|
|
29
82
|
if (desktopMode === 'floating') {
|
|
30
83
|
if (mobileMode === 'modal') {
|
|
84
|
+
const modalWidth = resolveModalWidth(size);
|
|
85
|
+
|
|
31
86
|
return (
|
|
32
87
|
<Modal
|
|
33
88
|
description={description}
|
|
@@ -36,8 +91,9 @@ function ResponsivePanelInner({
|
|
|
36
91
|
testID={testID}
|
|
37
92
|
title={title}
|
|
38
93
|
visible={open}
|
|
94
|
+
width={modalWidth}
|
|
39
95
|
>
|
|
40
|
-
{
|
|
96
|
+
{body}
|
|
41
97
|
</Modal>
|
|
42
98
|
);
|
|
43
99
|
}
|
|
@@ -52,13 +108,12 @@ function ResponsivePanelInner({
|
|
|
52
108
|
title={title}
|
|
53
109
|
visible={open}
|
|
54
110
|
>
|
|
55
|
-
{
|
|
111
|
+
{body}
|
|
56
112
|
</Drawer>
|
|
57
113
|
);
|
|
58
114
|
}
|
|
59
115
|
|
|
60
|
-
|
|
61
|
-
return (
|
|
116
|
+
const panel = (
|
|
62
117
|
<Panel
|
|
63
118
|
actions={actions}
|
|
64
119
|
compact={compact}
|
|
@@ -67,9 +122,26 @@ function ResponsivePanelInner({
|
|
|
67
122
|
testID={testID}
|
|
68
123
|
title={title}
|
|
69
124
|
>
|
|
70
|
-
{
|
|
125
|
+
{body}
|
|
71
126
|
</Panel>
|
|
72
127
|
);
|
|
128
|
+
|
|
129
|
+
if (size === undefined) return panel;
|
|
130
|
+
|
|
131
|
+
return <View style={[styles.inlineSizedPanel, { width: resolvePanelWidth(size) }]}>{panel}</View>;
|
|
73
132
|
}
|
|
74
133
|
|
|
134
|
+
const styles = StyleSheet.create({
|
|
135
|
+
inlineSizedPanel: {
|
|
136
|
+
maxWidth: '100%',
|
|
137
|
+
},
|
|
138
|
+
scrollBody: {
|
|
139
|
+
flexGrow: 0,
|
|
140
|
+
maxHeight: '100%',
|
|
141
|
+
},
|
|
142
|
+
scrollContent: {
|
|
143
|
+
flexGrow: 1,
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
|
|
75
147
|
export const ResponsivePanel = withZoraThemeScope(ResponsivePanelInner);
|
|
@@ -5,6 +5,8 @@ import type { ZoraBaseProps } from '../../theme/ZoraBaseProps';
|
|
|
5
5
|
export type ResponsivePanelSide = 'left' | 'right';
|
|
6
6
|
export type ResponsivePanelDesktopMode = 'inline' | 'floating';
|
|
7
7
|
export type ResponsivePanelMobileMode = 'drawer' | 'modal';
|
|
8
|
+
export type ResponsivePanelSize = 'compact' | 'default' | 'wide' | 'extraWide';
|
|
9
|
+
export type ResponsivePanelScroll = 'none' | 'content';
|
|
8
10
|
|
|
9
11
|
export interface ResponsivePanelProps extends ZoraBaseProps {
|
|
10
12
|
title?: React.ReactNode;
|
|
@@ -18,4 +20,6 @@ export interface ResponsivePanelProps extends ZoraBaseProps {
|
|
|
18
20
|
desktopMode?: ResponsivePanelDesktopMode;
|
|
19
21
|
mobileMode?: ResponsivePanelMobileMode;
|
|
20
22
|
compact?: boolean;
|
|
23
|
+
size?: ResponsivePanelSize;
|
|
24
|
+
scroll?: ResponsivePanelScroll;
|
|
21
25
|
}
|