@xaui/native 0.0.30 → 0.0.32
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/README.md +4 -0
- package/dist/app-bar/index.cjs +10 -5
- package/dist/app-bar/index.d.cts +8 -1
- package/dist/app-bar/index.d.ts +8 -1
- package/dist/app-bar/index.js +10 -5
- package/dist/dialog/index.cjs +381 -0
- package/dist/dialog/index.d.cts +151 -0
- package/dist/dialog/index.d.ts +151 -0
- package/dist/dialog/index.js +381 -0
- package/dist/index-DyU3sW3_.d.cts +4 -0
- package/dist/index-DyU3sW3_.d.ts +4 -0
- package/dist/snackbar/index.d.cts +1 -2
- package/dist/snackbar/index.d.ts +1 -2
- package/dist/snippet/index.cjs +282 -0
- package/dist/snippet/index.d.cts +90 -0
- package/dist/snippet/index.d.ts +90 -0
- package/dist/snippet/index.js +282 -0
- package/dist/toolbar/index.cjs +24 -17
- package/dist/toolbar/index.js +25 -18
- package/package.json +13 -3
package/README.md
CHANGED
|
@@ -76,6 +76,10 @@ This table lists all public components exported by `@xaui/native` and their impo
|
|
|
76
76
|
| `Slider` | Draggable value selector slider. | `import { Slider } from '@xaui/native/slider'` |
|
|
77
77
|
| `Select` | Select input with trigger and list behavior. | `import { Select } from '@xaui/native/select'` |
|
|
78
78
|
| `SelectItem` | Select option item for `Select`. | `import { SelectItem } from '@xaui/native/select'` |
|
|
79
|
+
| `Dialog` | Modal dialog container component. | `import { Dialog } from '@xaui/native/dialog'` |
|
|
80
|
+
| `DialogHeader` | Header section for `Dialog`. | `import { DialogHeader } from '@xaui/native/dialog'` |
|
|
81
|
+
| `DialogBody` | Body/content section for `Dialog`. | `import { DialogBody } from '@xaui/native/dialog'` |
|
|
82
|
+
| `DialogFooter` | Footer/actions section for `Dialog`. | `import { DialogFooter } from '@xaui/native/dialog'` |
|
|
79
83
|
| `Divider` | Horizontal or vertical separator line. | `import { Divider } from '@xaui/native/divider'` |
|
|
80
84
|
| `Drawer` | Side sheet / drawer container. | `import { Drawer } from '@xaui/native/drawer'` |
|
|
81
85
|
| `Skeleton` | Placeholder loading block. | `import { Skeleton } from '@xaui/native/skeleton'` |
|
package/dist/app-bar/index.cjs
CHANGED
|
@@ -39,10 +39,11 @@ var useAppBarElevationStyles = (elevation = 0) => {
|
|
|
39
39
|
|
|
40
40
|
var styles = _reactnative.StyleSheet.create({
|
|
41
41
|
container: {
|
|
42
|
+
flexShrink: 1,
|
|
43
|
+
flexBasis: "auto",
|
|
42
44
|
width: "100%"
|
|
43
45
|
},
|
|
44
46
|
floatingContainer: {
|
|
45
|
-
paddingHorizontal: 16,
|
|
46
47
|
paddingVertical: 8
|
|
47
48
|
},
|
|
48
49
|
appBar: {
|
|
@@ -56,7 +57,9 @@ var styles = _reactnative.StyleSheet.create({
|
|
|
56
57
|
borderRadius: 0
|
|
57
58
|
},
|
|
58
59
|
floating: {
|
|
59
|
-
|
|
60
|
+
flexShrink: 1,
|
|
61
|
+
flexBasis: "auto",
|
|
62
|
+
maxWidth: "97%",
|
|
60
63
|
borderRadius: 9999,
|
|
61
64
|
alignSelf: "center"
|
|
62
65
|
},
|
|
@@ -71,7 +74,7 @@ var styles = _reactnative.StyleSheet.create({
|
|
|
71
74
|
flex: 1,
|
|
72
75
|
alignItems: "center",
|
|
73
76
|
justifyContent: "center",
|
|
74
|
-
paddingHorizontal:
|
|
77
|
+
paddingHorizontal: 10
|
|
75
78
|
},
|
|
76
79
|
endContent: {
|
|
77
80
|
flexShrink: 0,
|
|
@@ -97,7 +100,7 @@ var AppBar = ({
|
|
|
97
100
|
const safeThemeColor = _core.getSafeThemeColor.call(void 0, themeColor);
|
|
98
101
|
const colorScheme = theme.colors[safeThemeColor];
|
|
99
102
|
const isDefaultThemeColor = safeThemeColor === "default";
|
|
100
|
-
const backgroundColor = isDefaultThemeColor ? theme.mode === "dark" ? theme.colors.default.background : "#FFFFFF" : colorScheme.background;
|
|
103
|
+
const backgroundColor = isDefaultThemeColor ? theme.mode === "dark" ? theme.colors.default.background : isFloating ? theme.palette.gray[200] : "#FFFFFF" : colorScheme.background;
|
|
101
104
|
const borderBottomColor = isDefaultThemeColor ? theme.mode === "dark" ? "rgba(255, 255, 255, 0.06)" : "rgba(0, 0, 0, 0.08)" : colorScheme.main;
|
|
102
105
|
return /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: [styles.container, isFloating && styles.floatingContainer] }, /* @__PURE__ */ _react2.default.createElement(
|
|
103
106
|
_reactnative.View,
|
|
@@ -125,9 +128,11 @@ var AppBarStartContent = ({
|
|
|
125
128
|
};
|
|
126
129
|
var AppBarContent = ({
|
|
127
130
|
children,
|
|
131
|
+
alignment = "center",
|
|
128
132
|
style
|
|
129
133
|
}) => {
|
|
130
|
-
|
|
134
|
+
const alignItems = alignment === "start" ? "flex-start" : alignment === "center" ? "center" : "flex-end";
|
|
135
|
+
return /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: [styles.content, { alignItems }, style] }, children);
|
|
131
136
|
};
|
|
132
137
|
var AppBarEndContent = ({
|
|
133
138
|
children,
|
package/dist/app-bar/index.d.cts
CHANGED
|
@@ -40,8 +40,15 @@ type AppBarSlotProps = {
|
|
|
40
40
|
*/
|
|
41
41
|
style?: StyleProp<ViewStyle>;
|
|
42
42
|
};
|
|
43
|
+
type AppBarSlotContentAlignment = 'start' | 'center' | 'end';
|
|
43
44
|
type AppBarStartContentProps = AppBarSlotProps;
|
|
44
|
-
type AppBarContentProps = AppBarSlotProps
|
|
45
|
+
type AppBarContentProps = AppBarSlotProps & {
|
|
46
|
+
/**
|
|
47
|
+
* Horizontal alignment for content slot content.
|
|
48
|
+
* @default 'center'
|
|
49
|
+
*/
|
|
50
|
+
alignment?: AppBarSlotContentAlignment;
|
|
51
|
+
};
|
|
45
52
|
type AppBarEndContentProps = AppBarSlotProps;
|
|
46
53
|
|
|
47
54
|
declare const AppBar: React.FC<AppBarProps>;
|
package/dist/app-bar/index.d.ts
CHANGED
|
@@ -40,8 +40,15 @@ type AppBarSlotProps = {
|
|
|
40
40
|
*/
|
|
41
41
|
style?: StyleProp<ViewStyle>;
|
|
42
42
|
};
|
|
43
|
+
type AppBarSlotContentAlignment = 'start' | 'center' | 'end';
|
|
43
44
|
type AppBarStartContentProps = AppBarSlotProps;
|
|
44
|
-
type AppBarContentProps = AppBarSlotProps
|
|
45
|
+
type AppBarContentProps = AppBarSlotProps & {
|
|
46
|
+
/**
|
|
47
|
+
* Horizontal alignment for content slot content.
|
|
48
|
+
* @default 'center'
|
|
49
|
+
*/
|
|
50
|
+
alignment?: AppBarSlotContentAlignment;
|
|
51
|
+
};
|
|
45
52
|
type AppBarEndContentProps = AppBarSlotProps;
|
|
46
53
|
|
|
47
54
|
declare const AppBar: React.FC<AppBarProps>;
|
package/dist/app-bar/index.js
CHANGED
|
@@ -39,10 +39,11 @@ var useAppBarElevationStyles = (elevation = 0) => {
|
|
|
39
39
|
import { StyleSheet } from "react-native";
|
|
40
40
|
var styles = StyleSheet.create({
|
|
41
41
|
container: {
|
|
42
|
+
flexShrink: 1,
|
|
43
|
+
flexBasis: "auto",
|
|
42
44
|
width: "100%"
|
|
43
45
|
},
|
|
44
46
|
floatingContainer: {
|
|
45
|
-
paddingHorizontal: 16,
|
|
46
47
|
paddingVertical: 8
|
|
47
48
|
},
|
|
48
49
|
appBar: {
|
|
@@ -56,7 +57,9 @@ var styles = StyleSheet.create({
|
|
|
56
57
|
borderRadius: 0
|
|
57
58
|
},
|
|
58
59
|
floating: {
|
|
59
|
-
|
|
60
|
+
flexShrink: 1,
|
|
61
|
+
flexBasis: "auto",
|
|
62
|
+
maxWidth: "97%",
|
|
60
63
|
borderRadius: 9999,
|
|
61
64
|
alignSelf: "center"
|
|
62
65
|
},
|
|
@@ -71,7 +74,7 @@ var styles = StyleSheet.create({
|
|
|
71
74
|
flex: 1,
|
|
72
75
|
alignItems: "center",
|
|
73
76
|
justifyContent: "center",
|
|
74
|
-
paddingHorizontal:
|
|
77
|
+
paddingHorizontal: 10
|
|
75
78
|
},
|
|
76
79
|
endContent: {
|
|
77
80
|
flexShrink: 0,
|
|
@@ -97,7 +100,7 @@ var AppBar = ({
|
|
|
97
100
|
const safeThemeColor = getSafeThemeColor(themeColor);
|
|
98
101
|
const colorScheme = theme.colors[safeThemeColor];
|
|
99
102
|
const isDefaultThemeColor = safeThemeColor === "default";
|
|
100
|
-
const backgroundColor = isDefaultThemeColor ? theme.mode === "dark" ? theme.colors.default.background : "#FFFFFF" : colorScheme.background;
|
|
103
|
+
const backgroundColor = isDefaultThemeColor ? theme.mode === "dark" ? theme.colors.default.background : isFloating ? theme.palette.gray[200] : "#FFFFFF" : colorScheme.background;
|
|
101
104
|
const borderBottomColor = isDefaultThemeColor ? theme.mode === "dark" ? "rgba(255, 255, 255, 0.06)" : "rgba(0, 0, 0, 0.08)" : colorScheme.main;
|
|
102
105
|
return /* @__PURE__ */ React.createElement(View, { style: [styles.container, isFloating && styles.floatingContainer] }, /* @__PURE__ */ React.createElement(
|
|
103
106
|
View,
|
|
@@ -125,9 +128,11 @@ var AppBarStartContent = ({
|
|
|
125
128
|
};
|
|
126
129
|
var AppBarContent = ({
|
|
127
130
|
children,
|
|
131
|
+
alignment = "center",
|
|
128
132
|
style
|
|
129
133
|
}) => {
|
|
130
|
-
|
|
134
|
+
const alignItems = alignment === "start" ? "flex-start" : alignment === "center" ? "center" : "flex-end";
|
|
135
|
+
return /* @__PURE__ */ React.createElement(View, { style: [styles.content, { alignItems }, style] }, children);
|
|
131
136
|
};
|
|
132
137
|
var AppBarEndContent = ({
|
|
133
138
|
children,
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkOQ2BLOOGcjs = require('../chunk-OQ2BLOOG.cjs');
|
|
5
|
+
|
|
6
|
+
// src/components/dialog/dialog.tsx
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
|
16
|
+
var _reactnative = require('react-native');
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
var _reactnativereanimated = require('react-native-reanimated'); var _reactnativereanimated2 = _interopRequireDefault(_reactnativereanimated);
|
|
24
|
+
var _core = require('@xaui/core');
|
|
25
|
+
var _icons = require('@xaui/icons');
|
|
26
|
+
|
|
27
|
+
// src/components/dialog/dialog.style.ts
|
|
28
|
+
|
|
29
|
+
var styles = _reactnative.StyleSheet.create({
|
|
30
|
+
root: {
|
|
31
|
+
flex: 1
|
|
32
|
+
},
|
|
33
|
+
backdrop: {
|
|
34
|
+
..._reactnative.StyleSheet.absoluteFillObject
|
|
35
|
+
},
|
|
36
|
+
backdropTransparent: {
|
|
37
|
+
backgroundColor: "transparent"
|
|
38
|
+
},
|
|
39
|
+
backdropBlurred: {
|
|
40
|
+
backgroundColor: "rgba(15, 23, 42, 0.35)"
|
|
41
|
+
},
|
|
42
|
+
backdropOpaque: {
|
|
43
|
+
backgroundColor: "rgba(15, 23, 42, 0.55)"
|
|
44
|
+
},
|
|
45
|
+
placementBase: {
|
|
46
|
+
flex: 1,
|
|
47
|
+
paddingHorizontal: 16
|
|
48
|
+
},
|
|
49
|
+
placementTop: {
|
|
50
|
+
justifyContent: "flex-start",
|
|
51
|
+
paddingTop: 44,
|
|
52
|
+
paddingBottom: 16
|
|
53
|
+
},
|
|
54
|
+
placementCenter: {
|
|
55
|
+
justifyContent: "center",
|
|
56
|
+
paddingVertical: 16
|
|
57
|
+
},
|
|
58
|
+
placementBottom: {
|
|
59
|
+
justifyContent: "flex-end",
|
|
60
|
+
paddingTop: 16,
|
|
61
|
+
paddingBottom: 28
|
|
62
|
+
},
|
|
63
|
+
dialog: {
|
|
64
|
+
width: "100%",
|
|
65
|
+
alignSelf: "center",
|
|
66
|
+
overflow: "hidden",
|
|
67
|
+
borderWidth: 1
|
|
68
|
+
},
|
|
69
|
+
sizeSm: {
|
|
70
|
+
maxWidth: 360
|
|
71
|
+
},
|
|
72
|
+
sizeMd: {
|
|
73
|
+
maxWidth: 520
|
|
74
|
+
},
|
|
75
|
+
sizeLg: {
|
|
76
|
+
maxWidth: 700
|
|
77
|
+
},
|
|
78
|
+
sizeFull: {
|
|
79
|
+
maxWidth: "100%",
|
|
80
|
+
flex: 1
|
|
81
|
+
},
|
|
82
|
+
header: {
|
|
83
|
+
paddingTop: 18,
|
|
84
|
+
paddingBottom: 12,
|
|
85
|
+
paddingHorizontal: 20,
|
|
86
|
+
flexDirection: "row",
|
|
87
|
+
alignItems: "flex-start",
|
|
88
|
+
justifyContent: "space-between",
|
|
89
|
+
gap: 12
|
|
90
|
+
},
|
|
91
|
+
headerContent: {
|
|
92
|
+
flex: 1
|
|
93
|
+
},
|
|
94
|
+
headerText: {
|
|
95
|
+
fontSize: 20,
|
|
96
|
+
lineHeight: 26,
|
|
97
|
+
fontWeight: "700"
|
|
98
|
+
},
|
|
99
|
+
body: {
|
|
100
|
+
paddingHorizontal: 20,
|
|
101
|
+
paddingVertical: 12,
|
|
102
|
+
gap: 10
|
|
103
|
+
},
|
|
104
|
+
bodyText: {
|
|
105
|
+
fontSize: 15,
|
|
106
|
+
lineHeight: 22
|
|
107
|
+
},
|
|
108
|
+
footer: {
|
|
109
|
+
paddingTop: 8,
|
|
110
|
+
paddingBottom: 18,
|
|
111
|
+
paddingHorizontal: 20,
|
|
112
|
+
flexDirection: "row",
|
|
113
|
+
justifyContent: "flex-end",
|
|
114
|
+
alignItems: "center",
|
|
115
|
+
gap: 8
|
|
116
|
+
},
|
|
117
|
+
closeButton: {
|
|
118
|
+
padding: 4,
|
|
119
|
+
borderRadius: 999,
|
|
120
|
+
alignItems: "center",
|
|
121
|
+
justifyContent: "center"
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// src/components/dialog/dialog.tsx
|
|
126
|
+
var DialogContext = _react.createContext.call(void 0, {});
|
|
127
|
+
var sizeStyles = {
|
|
128
|
+
sm: styles.sizeSm,
|
|
129
|
+
md: styles.sizeMd,
|
|
130
|
+
lg: styles.sizeLg,
|
|
131
|
+
full: styles.sizeFull
|
|
132
|
+
};
|
|
133
|
+
var placementStyles = {
|
|
134
|
+
top: styles.placementTop,
|
|
135
|
+
center: styles.placementCenter,
|
|
136
|
+
bottom: styles.placementBottom
|
|
137
|
+
};
|
|
138
|
+
var backdropStyles = {
|
|
139
|
+
transparent: styles.backdropTransparent,
|
|
140
|
+
blurred: styles.backdropBlurred,
|
|
141
|
+
opaque: styles.backdropOpaque
|
|
142
|
+
};
|
|
143
|
+
var ENTER_DURATION = 240;
|
|
144
|
+
var EXIT_DURATION = 180;
|
|
145
|
+
function getTranslateOffset(placement, animationType) {
|
|
146
|
+
if (animationType === "slide") {
|
|
147
|
+
if (placement === "top") return -28;
|
|
148
|
+
if (placement === "bottom") return 28;
|
|
149
|
+
return 18;
|
|
150
|
+
}
|
|
151
|
+
if (placement === "top") return -18;
|
|
152
|
+
if (placement === "bottom") return 18;
|
|
153
|
+
return 10;
|
|
154
|
+
}
|
|
155
|
+
var resolveChildrenContent = (content, textStyle) => {
|
|
156
|
+
if (content === void 0 || content === null) return null;
|
|
157
|
+
if (typeof content === "string" || typeof content === "number") {
|
|
158
|
+
return /* @__PURE__ */ _react2.default.createElement(_reactnative.Text, { style: textStyle }, content);
|
|
159
|
+
}
|
|
160
|
+
return content;
|
|
161
|
+
};
|
|
162
|
+
var Dialog = ({
|
|
163
|
+
children,
|
|
164
|
+
isOpen,
|
|
165
|
+
onClose,
|
|
166
|
+
onOpenChange,
|
|
167
|
+
size = "md",
|
|
168
|
+
placement = "center",
|
|
169
|
+
radius = "lg",
|
|
170
|
+
backdrop = "opaque",
|
|
171
|
+
closeOnBackdropPress = true,
|
|
172
|
+
hideBackdrop = false,
|
|
173
|
+
animationType = "fade",
|
|
174
|
+
disableAnimation = false,
|
|
175
|
+
style,
|
|
176
|
+
customAppearance
|
|
177
|
+
}) => {
|
|
178
|
+
const theme = _chunkOQ2BLOOGcjs.useXUITheme.call(void 0, );
|
|
179
|
+
const radiusStyles = _chunkOQ2BLOOGcjs.useBorderRadiusStyles.call(void 0, radius);
|
|
180
|
+
const [shouldRender, setShouldRender] = _react.useState.call(void 0, isOpen);
|
|
181
|
+
const openRef = _react.useRef.call(void 0, isOpen);
|
|
182
|
+
const shouldAnimate = !disableAnimation && animationType !== "none";
|
|
183
|
+
const initialOffset = getTranslateOffset(placement, animationType);
|
|
184
|
+
const backdropOpacity = _reactnativereanimated.useSharedValue.call(void 0, isOpen ? 1 : 0);
|
|
185
|
+
const dialogOpacity = _reactnativereanimated.useSharedValue.call(void 0, isOpen ? 1 : 0);
|
|
186
|
+
const dialogTranslate = _reactnativereanimated.useSharedValue.call(void 0, isOpen ? 0 : initialOffset);
|
|
187
|
+
const dialogScale = _reactnativereanimated.useSharedValue.call(void 0, isOpen ? 1 : placement === "center" ? 0.98 : 1);
|
|
188
|
+
const requestClose = _react.useCallback.call(void 0, () => {
|
|
189
|
+
_optionalChain([onOpenChange, 'optionalCall', _ => _(false)]);
|
|
190
|
+
_optionalChain([onClose, 'optionalCall', _2 => _2()]);
|
|
191
|
+
}, [onClose, onOpenChange]);
|
|
192
|
+
const handleBackdropPress = () => {
|
|
193
|
+
if (closeOnBackdropPress) {
|
|
194
|
+
requestClose();
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
const finishClosing = _react.useCallback.call(void 0, () => {
|
|
198
|
+
if (!openRef.current) {
|
|
199
|
+
setShouldRender(false);
|
|
200
|
+
}
|
|
201
|
+
}, []);
|
|
202
|
+
_react.useEffect.call(void 0, () => {
|
|
203
|
+
openRef.current = isOpen;
|
|
204
|
+
}, [isOpen]);
|
|
205
|
+
_react.useEffect.call(void 0, () => {
|
|
206
|
+
if (isOpen && !shouldRender) {
|
|
207
|
+
setShouldRender(true);
|
|
208
|
+
}
|
|
209
|
+
}, [isOpen, shouldRender]);
|
|
210
|
+
_react.useEffect.call(void 0, () => {
|
|
211
|
+
if (!shouldRender) return;
|
|
212
|
+
if (!shouldAnimate) {
|
|
213
|
+
backdropOpacity.value = isOpen ? 1 : 0;
|
|
214
|
+
dialogOpacity.value = isOpen ? 1 : 0;
|
|
215
|
+
dialogTranslate.value = 0;
|
|
216
|
+
dialogScale.value = 1;
|
|
217
|
+
if (!isOpen) {
|
|
218
|
+
setShouldRender(false);
|
|
219
|
+
}
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
const offset = getTranslateOffset(placement, animationType);
|
|
223
|
+
if (isOpen) {
|
|
224
|
+
backdropOpacity.value = 0;
|
|
225
|
+
dialogOpacity.value = 0;
|
|
226
|
+
dialogTranslate.value = offset;
|
|
227
|
+
dialogScale.value = placement === "center" ? 0.98 : 1;
|
|
228
|
+
backdropOpacity.value = _reactnativereanimated.withTiming.call(void 0, 1, {
|
|
229
|
+
duration: 210,
|
|
230
|
+
easing: _reactnativereanimated.Easing.out(_reactnativereanimated.Easing.quad)
|
|
231
|
+
});
|
|
232
|
+
dialogOpacity.value = _reactnativereanimated.withTiming.call(void 0, 1, {
|
|
233
|
+
duration: 220,
|
|
234
|
+
easing: _reactnativereanimated.Easing.out(_reactnativereanimated.Easing.quad)
|
|
235
|
+
});
|
|
236
|
+
dialogTranslate.value = _reactnativereanimated.withTiming.call(void 0, 0, {
|
|
237
|
+
duration: ENTER_DURATION,
|
|
238
|
+
easing: _reactnativereanimated.Easing.out(_reactnativereanimated.Easing.cubic)
|
|
239
|
+
});
|
|
240
|
+
dialogScale.value = _reactnativereanimated.withTiming.call(void 0, 1, {
|
|
241
|
+
duration: 220,
|
|
242
|
+
easing: _reactnativereanimated.Easing.out(_reactnativereanimated.Easing.quad)
|
|
243
|
+
});
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
backdropOpacity.value = _reactnativereanimated.withTiming.call(void 0, 0, {
|
|
247
|
+
duration: 150,
|
|
248
|
+
easing: _reactnativereanimated.Easing.in(_reactnativereanimated.Easing.quad)
|
|
249
|
+
});
|
|
250
|
+
dialogTranslate.value = _reactnativereanimated.withTiming.call(void 0, offset, {
|
|
251
|
+
duration: EXIT_DURATION,
|
|
252
|
+
easing: _reactnativereanimated.Easing.in(_reactnativereanimated.Easing.cubic)
|
|
253
|
+
});
|
|
254
|
+
dialogScale.value = _reactnativereanimated.withTiming.call(void 0, placement === "center" ? 0.98 : 1, {
|
|
255
|
+
duration: 150,
|
|
256
|
+
easing: _reactnativereanimated.Easing.in(_reactnativereanimated.Easing.quad)
|
|
257
|
+
});
|
|
258
|
+
dialogOpacity.value = _reactnativereanimated.withTiming.call(void 0,
|
|
259
|
+
0,
|
|
260
|
+
{
|
|
261
|
+
duration: EXIT_DURATION,
|
|
262
|
+
easing: _reactnativereanimated.Easing.in(_reactnativereanimated.Easing.quad)
|
|
263
|
+
},
|
|
264
|
+
(finished) => {
|
|
265
|
+
if (finished) {
|
|
266
|
+
_reactnativereanimated.runOnJS.call(void 0, finishClosing)();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
);
|
|
270
|
+
}, [
|
|
271
|
+
animationType,
|
|
272
|
+
backdropOpacity,
|
|
273
|
+
dialogOpacity,
|
|
274
|
+
dialogScale,
|
|
275
|
+
dialogTranslate,
|
|
276
|
+
finishClosing,
|
|
277
|
+
isOpen,
|
|
278
|
+
placement,
|
|
279
|
+
shouldAnimate,
|
|
280
|
+
shouldRender
|
|
281
|
+
]);
|
|
282
|
+
const backdropAnimatedStyle = _reactnativereanimated.useAnimatedStyle.call(void 0, () => ({
|
|
283
|
+
opacity: backdropOpacity.value
|
|
284
|
+
}));
|
|
285
|
+
const dialogAnimatedStyle = _reactnativereanimated.useAnimatedStyle.call(void 0, () => ({
|
|
286
|
+
opacity: dialogOpacity.value,
|
|
287
|
+
transform: [{ translateY: dialogTranslate.value }, { scale: dialogScale.value }]
|
|
288
|
+
}));
|
|
289
|
+
const dialogContextValue = _react.useMemo.call(void 0,
|
|
290
|
+
() => ({
|
|
291
|
+
onClose: requestClose,
|
|
292
|
+
customAppearance
|
|
293
|
+
}),
|
|
294
|
+
[customAppearance, requestClose]
|
|
295
|
+
);
|
|
296
|
+
if (!shouldRender) return null;
|
|
297
|
+
return /* @__PURE__ */ _react2.default.createElement(
|
|
298
|
+
_reactnative.Modal,
|
|
299
|
+
{
|
|
300
|
+
visible: true,
|
|
301
|
+
transparent: true,
|
|
302
|
+
animationType: "none",
|
|
303
|
+
onRequestClose: requestClose
|
|
304
|
+
},
|
|
305
|
+
/* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles.root }, !hideBackdrop && /* @__PURE__ */ _react2.default.createElement(
|
|
306
|
+
AnimatedPressable,
|
|
307
|
+
{
|
|
308
|
+
style: [
|
|
309
|
+
styles.backdrop,
|
|
310
|
+
backdropStyles[backdrop],
|
|
311
|
+
backdropAnimatedStyle,
|
|
312
|
+
_optionalChain([customAppearance, 'optionalAccess', _3 => _3.backdrop])
|
|
313
|
+
],
|
|
314
|
+
onPress: handleBackdropPress
|
|
315
|
+
}
|
|
316
|
+
), /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: [styles.placementBase, placementStyles[placement]] }, /* @__PURE__ */ _react2.default.createElement(DialogContext.Provider, { value: dialogContextValue }, /* @__PURE__ */ _react2.default.createElement(_reactnative.Pressable, { onPress: (event) => event.stopPropagation() }, /* @__PURE__ */ _react2.default.createElement(
|
|
317
|
+
_reactnativereanimated2.default.View,
|
|
318
|
+
{
|
|
319
|
+
style: [
|
|
320
|
+
styles.dialog,
|
|
321
|
+
sizeStyles[size],
|
|
322
|
+
radiusStyles,
|
|
323
|
+
dialogAnimatedStyle,
|
|
324
|
+
{
|
|
325
|
+
backgroundColor: theme.colors.background,
|
|
326
|
+
borderColor: _core.withOpacity.call(void 0, theme.colors.foreground, 0.14)
|
|
327
|
+
},
|
|
328
|
+
theme.shadows.lg,
|
|
329
|
+
_optionalChain([customAppearance, 'optionalAccess', _4 => _4.container]),
|
|
330
|
+
style
|
|
331
|
+
]
|
|
332
|
+
},
|
|
333
|
+
children
|
|
334
|
+
)))))
|
|
335
|
+
);
|
|
336
|
+
};
|
|
337
|
+
var AnimatedPressable = _reactnativereanimated2.default.createAnimatedComponent(_reactnative.Pressable);
|
|
338
|
+
var DialogHeader = ({
|
|
339
|
+
children,
|
|
340
|
+
isClosable = false,
|
|
341
|
+
closeButton,
|
|
342
|
+
onClose,
|
|
343
|
+
style
|
|
344
|
+
}) => {
|
|
345
|
+
const theme = _chunkOQ2BLOOGcjs.useXUITheme.call(void 0, );
|
|
346
|
+
const { onClose: contextClose, customAppearance } = _react.useContext.call(void 0, DialogContext);
|
|
347
|
+
const close = _nullishCoalesce(onClose, () => ( contextClose));
|
|
348
|
+
return /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: [styles.header, _optionalChain([customAppearance, 'optionalAccess', _5 => _5.header]), style] }, /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles.headerContent }, resolveChildrenContent(children, [
|
|
349
|
+
styles.headerText,
|
|
350
|
+
{ color: theme.colors.foreground },
|
|
351
|
+
_optionalChain([customAppearance, 'optionalAccess', _6 => _6.headerText])
|
|
352
|
+
])), isClosable && /* @__PURE__ */ _react2.default.createElement(
|
|
353
|
+
_reactnative.Pressable,
|
|
354
|
+
{
|
|
355
|
+
accessibilityRole: "button",
|
|
356
|
+
accessibilityLabel: "Close dialog",
|
|
357
|
+
onPress: close,
|
|
358
|
+
style: [styles.closeButton, _optionalChain([customAppearance, 'optionalAccess', _7 => _7.closeButton])]
|
|
359
|
+
},
|
|
360
|
+
_nullishCoalesce(closeButton, () => ( /* @__PURE__ */ _react2.default.createElement(_icons.CloseIcon, { size: 22, color: theme.colors.foreground })))
|
|
361
|
+
));
|
|
362
|
+
};
|
|
363
|
+
var DialogBody = ({ children, style }) => {
|
|
364
|
+
const theme = _chunkOQ2BLOOGcjs.useXUITheme.call(void 0, );
|
|
365
|
+
const { customAppearance } = _react.useContext.call(void 0, DialogContext);
|
|
366
|
+
return /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: [styles.body, _optionalChain([customAppearance, 'optionalAccess', _8 => _8.body]), style] }, resolveChildrenContent(children, [
|
|
367
|
+
styles.bodyText,
|
|
368
|
+
{ color: _core.withOpacity.call(void 0, theme.colors.foreground, 0.9) },
|
|
369
|
+
_optionalChain([customAppearance, 'optionalAccess', _9 => _9.bodyText])
|
|
370
|
+
]));
|
|
371
|
+
};
|
|
372
|
+
var DialogFooter = ({ children, style }) => {
|
|
373
|
+
const { customAppearance } = _react.useContext.call(void 0, DialogContext);
|
|
374
|
+
return /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: [styles.footer, _optionalChain([customAppearance, 'optionalAccess', _10 => _10.footer]), style] }, children);
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
exports.Dialog = Dialog; exports.DialogBody = DialogBody; exports.DialogFooter = DialogFooter; exports.DialogHeader = DialogHeader;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ModalProps, ViewStyle, TextStyle } from 'react-native';
|
|
3
|
+
import { R as Radius } from '../index-BOw6tbkc.cjs';
|
|
4
|
+
|
|
5
|
+
type DialogSize = 'sm' | 'md' | 'lg' | 'full';
|
|
6
|
+
type DialogPlacement = 'top' | 'center' | 'bottom';
|
|
7
|
+
type DialogBackdrop = 'transparent' | 'blurred' | 'opaque';
|
|
8
|
+
type DialogCustomAppearance = {
|
|
9
|
+
/**
|
|
10
|
+
* Custom style for the overlay backdrop.
|
|
11
|
+
*/
|
|
12
|
+
backdrop?: ViewStyle;
|
|
13
|
+
/**
|
|
14
|
+
* Custom style for the dialog container.
|
|
15
|
+
*/
|
|
16
|
+
container?: ViewStyle;
|
|
17
|
+
/**
|
|
18
|
+
* Custom style for the dialog header section.
|
|
19
|
+
*/
|
|
20
|
+
header?: ViewStyle;
|
|
21
|
+
/**
|
|
22
|
+
* Custom style for the dialog body section.
|
|
23
|
+
*/
|
|
24
|
+
body?: ViewStyle;
|
|
25
|
+
/**
|
|
26
|
+
* Custom style for the dialog footer section.
|
|
27
|
+
*/
|
|
28
|
+
footer?: ViewStyle;
|
|
29
|
+
/**
|
|
30
|
+
* Custom style for the close button.
|
|
31
|
+
*/
|
|
32
|
+
closeButton?: ViewStyle;
|
|
33
|
+
/**
|
|
34
|
+
* Custom style for default title text rendered in DialogHeader.
|
|
35
|
+
*/
|
|
36
|
+
headerText?: TextStyle;
|
|
37
|
+
/**
|
|
38
|
+
* Custom style for default body text rendered in DialogBody.
|
|
39
|
+
*/
|
|
40
|
+
bodyText?: TextStyle;
|
|
41
|
+
};
|
|
42
|
+
type DialogEvents = {
|
|
43
|
+
/**
|
|
44
|
+
* Called when the dialog requests to close.
|
|
45
|
+
*/
|
|
46
|
+
onClose?: () => void;
|
|
47
|
+
/**
|
|
48
|
+
* Called whenever open state changes.
|
|
49
|
+
*/
|
|
50
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
51
|
+
};
|
|
52
|
+
type DialogProps = {
|
|
53
|
+
/**
|
|
54
|
+
* Dialog content.
|
|
55
|
+
*/
|
|
56
|
+
children: ReactNode;
|
|
57
|
+
/**
|
|
58
|
+
* Controls visibility.
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
isOpen: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Dialog size preset.
|
|
64
|
+
* @default 'md'
|
|
65
|
+
*/
|
|
66
|
+
size?: DialogSize;
|
|
67
|
+
/**
|
|
68
|
+
* Dialog placement on screen.
|
|
69
|
+
* @default 'center'
|
|
70
|
+
*/
|
|
71
|
+
placement?: DialogPlacement;
|
|
72
|
+
/**
|
|
73
|
+
* Border radius of the dialog container.
|
|
74
|
+
* @default 'lg'
|
|
75
|
+
*/
|
|
76
|
+
radius?: Radius;
|
|
77
|
+
/**
|
|
78
|
+
* Controls backdrop intensity.
|
|
79
|
+
* @default 'opaque'
|
|
80
|
+
*/
|
|
81
|
+
backdrop?: DialogBackdrop;
|
|
82
|
+
/**
|
|
83
|
+
* If true, backdrop press closes the dialog.
|
|
84
|
+
* @default true
|
|
85
|
+
*/
|
|
86
|
+
closeOnBackdropPress?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Whether to hide the backdrop layer.
|
|
89
|
+
* @default false
|
|
90
|
+
*/
|
|
91
|
+
hideBackdrop?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Modal animation type.
|
|
94
|
+
* @default 'fade'
|
|
95
|
+
*/
|
|
96
|
+
animationType?: ModalProps['animationType'];
|
|
97
|
+
/**
|
|
98
|
+
* Disable animation by forcing `animationType="none"`.
|
|
99
|
+
* @default false
|
|
100
|
+
*/
|
|
101
|
+
disableAnimation?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Extra style for the dialog container.
|
|
104
|
+
*/
|
|
105
|
+
style?: ViewStyle;
|
|
106
|
+
/**
|
|
107
|
+
* Custom styles per section.
|
|
108
|
+
*/
|
|
109
|
+
customAppearance?: DialogCustomAppearance;
|
|
110
|
+
} & DialogEvents;
|
|
111
|
+
type DialogHeaderProps = {
|
|
112
|
+
children?: ReactNode;
|
|
113
|
+
/**
|
|
114
|
+
* Whether to show a close button in header.
|
|
115
|
+
* @default false
|
|
116
|
+
*/
|
|
117
|
+
isClosable?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Custom close button element.
|
|
120
|
+
*/
|
|
121
|
+
closeButton?: ReactNode;
|
|
122
|
+
/**
|
|
123
|
+
* Optional close callback override for this header.
|
|
124
|
+
*/
|
|
125
|
+
onClose?: () => void;
|
|
126
|
+
/**
|
|
127
|
+
* Custom style for header container.
|
|
128
|
+
*/
|
|
129
|
+
style?: ViewStyle;
|
|
130
|
+
};
|
|
131
|
+
type DialogBodyProps = {
|
|
132
|
+
children?: ReactNode;
|
|
133
|
+
/**
|
|
134
|
+
* Custom style for body container.
|
|
135
|
+
*/
|
|
136
|
+
style?: ViewStyle;
|
|
137
|
+
};
|
|
138
|
+
type DialogFooterProps = {
|
|
139
|
+
children?: ReactNode;
|
|
140
|
+
/**
|
|
141
|
+
* Custom style for footer container.
|
|
142
|
+
*/
|
|
143
|
+
style?: ViewStyle;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
declare const Dialog: React.FC<DialogProps>;
|
|
147
|
+
declare const DialogHeader: React.FC<DialogHeaderProps>;
|
|
148
|
+
declare const DialogBody: React.FC<DialogBodyProps>;
|
|
149
|
+
declare const DialogFooter: React.FC<DialogFooterProps>;
|
|
150
|
+
|
|
151
|
+
export { Dialog, type DialogBackdrop, DialogBody, type DialogBodyProps, DialogFooter, type DialogFooterProps, DialogHeader, type DialogHeaderProps, type DialogPlacement, type DialogProps, type DialogSize };
|