@tamagui/sheet 1.26.0 → 1.27.0-1684163004699
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/cjs/Sheet.js +24 -427
- package/dist/cjs/Sheet.js.map +2 -2
- package/dist/cjs/SheetContext.js.map +1 -1
- package/dist/cjs/SheetImplementationCustom.js +340 -0
- package/dist/cjs/SheetImplementationCustom.js.map +6 -0
- package/dist/cjs/constants.js +13 -0
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/{useSheetContoller.js → contexts.js} +12 -21
- package/dist/cjs/contexts.js.map +6 -0
- package/dist/cjs/createSheet.js +167 -0
- package/dist/cjs/createSheet.js.map +6 -0
- package/dist/cjs/helpers.js +38 -0
- package/dist/cjs/helpers.js.map +6 -0
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/nativeSheet.js +3 -5
- package/dist/cjs/nativeSheet.js.map +1 -1
- package/dist/cjs/{getNativeSheet.js → useSheet.js} +8 -17
- package/dist/cjs/useSheet.js.map +6 -0
- package/dist/cjs/useSheetController.js +2 -1
- package/dist/cjs/useSheetController.js.map +1 -1
- package/dist/cjs/useSheetProviderProps.js +30 -3
- package/dist/cjs/useSheetProviderProps.js.map +1 -1
- package/dist/esm/Sheet.js +21 -449
- package/dist/esm/Sheet.js.map +2 -2
- package/dist/esm/SheetContext.js.map +1 -1
- package/dist/esm/{Sheet.mjs → SheetImplementationCustom.js} +88 -279
- package/dist/esm/SheetImplementationCustom.js.map +6 -0
- package/dist/esm/constants.js +10 -0
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/contexts.js +10 -0
- package/dist/esm/contexts.js.map +6 -0
- package/dist/esm/createSheet.js +151 -0
- package/dist/esm/createSheet.js.map +6 -0
- package/dist/esm/helpers.js +14 -0
- package/dist/esm/helpers.js.map +6 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/nativeSheet.js +3 -5
- package/dist/esm/nativeSheet.js.map +1 -1
- package/dist/esm/useSheet.js +6 -0
- package/dist/esm/useSheet.js.map +6 -0
- package/dist/esm/useSheetController.js +2 -1
- package/dist/esm/useSheetController.js.map +1 -1
- package/dist/esm/useSheetProviderProps.js +31 -4
- package/dist/esm/useSheetProviderProps.js.map +1 -1
- package/dist/jsx/Sheet.js +21 -436
- package/dist/jsx/Sheet.js.map +2 -2
- package/dist/jsx/Sheet.mjs +21 -436
- package/dist/jsx/Sheet.mjs.map +2 -2
- package/dist/jsx/SheetContext.js.map +1 -1
- package/dist/jsx/SheetContext.mjs.map +1 -1
- package/dist/jsx/SheetImplementationCustom.js +330 -0
- package/dist/jsx/SheetImplementationCustom.js.map +6 -0
- package/dist/jsx/SheetImplementationCustom.mjs +330 -0
- package/dist/jsx/SheetImplementationCustom.mjs.map +6 -0
- package/dist/jsx/constants.js +10 -0
- package/dist/jsx/constants.js.map +1 -1
- package/dist/jsx/constants.mjs +10 -0
- package/dist/jsx/constants.mjs.map +1 -1
- package/dist/jsx/contexts.js +10 -0
- package/dist/jsx/contexts.js.map +6 -0
- package/dist/jsx/contexts.mjs +10 -0
- package/dist/jsx/contexts.mjs.map +6 -0
- package/dist/jsx/createSheet.js +139 -0
- package/dist/jsx/createSheet.js.map +6 -0
- package/dist/jsx/createSheet.mjs +139 -0
- package/dist/jsx/createSheet.mjs.map +6 -0
- package/dist/jsx/helpers.js +14 -0
- package/dist/jsx/helpers.js.map +6 -0
- package/dist/jsx/helpers.mjs +14 -0
- package/dist/jsx/helpers.mjs.map +6 -0
- package/dist/jsx/index.js +2 -0
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +2 -0
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/nativeSheet.js +3 -5
- package/dist/jsx/nativeSheet.js.map +1 -1
- package/dist/jsx/nativeSheet.mjs +3 -5
- package/dist/jsx/nativeSheet.mjs.map +1 -1
- package/dist/jsx/useSheet.js +6 -0
- package/dist/jsx/useSheet.js.map +6 -0
- package/dist/jsx/useSheet.mjs +6 -0
- package/dist/jsx/useSheet.mjs.map +6 -0
- package/dist/jsx/useSheetController.js +2 -1
- package/dist/jsx/useSheetController.js.map +1 -1
- package/dist/jsx/useSheetController.mjs +2 -1
- package/dist/jsx/useSheetController.mjs.map +1 -1
- package/dist/jsx/useSheetProviderProps.js +31 -4
- package/dist/jsx/useSheetProviderProps.js.map +1 -1
- package/dist/jsx/useSheetProviderProps.mjs +31 -4
- package/dist/jsx/useSheetProviderProps.mjs.map +1 -1
- package/package.json +14 -13
- package/src/Sheet.tsx +20 -544
- package/src/SheetContext.tsx +1 -16
- package/src/SheetImplementationCustom.tsx +404 -0
- package/src/constants.tsx +11 -0
- package/src/contexts.ts +9 -0
- package/src/createSheet.tsx +215 -0
- package/src/helpers.tsx +10 -0
- package/src/index.ts +2 -0
- package/src/nativeSheet.tsx +3 -5
- package/src/useSheet.tsx +3 -0
- package/src/useSheetController.tsx +1 -0
- package/src/useSheetProviderProps.tsx +48 -7
- package/types/Sheet.d.ts +163 -80
- package/types/Sheet.d.ts.map +1 -1
- package/types/SheetContext.d.ts +100 -27
- package/types/SheetContext.d.ts.map +1 -1
- package/types/SheetImplementationCustom.d.ts +27 -0
- package/types/SheetImplementationCustom.d.ts.map +1 -0
- package/types/constants.d.ts +3 -0
- package/types/constants.d.ts.map +1 -1
- package/types/contexts.d.ts +6 -0
- package/types/contexts.d.ts.map +1 -0
- package/types/createSheet.d.ts +70 -0
- package/types/createSheet.d.ts.map +1 -0
- package/types/helpers.d.ts +2 -0
- package/types/helpers.d.ts.map +1 -0
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -1
- package/types/nativeSheet.d.ts.map +1 -1
- package/types/useSheet.d.ts +22 -0
- package/types/useSheet.d.ts.map +1 -0
- package/types/useSheetController.d.ts +1 -0
- package/types/useSheetController.d.ts.map +1 -1
- package/types/useSheetProviderProps.d.ts +8 -3
- package/types/useSheetProviderProps.d.ts.map +1 -1
- package/dist/cjs/getNativeSheet.js.map +0 -6
- package/dist/cjs/native-ios.js +0 -5
- package/dist/cjs/native-ios.js.map +0 -6
- package/dist/cjs/useSheetChildren.js +0 -80
- package/dist/cjs/useSheetChildren.js.map +0 -6
- package/dist/cjs/useSheetContoller.js.map +0 -6
- package/dist/cjs/useSheetSnapPoints.js +0 -77
- package/dist/cjs/useSheetSnapPoints.js.map +0 -6
- package/dist/esm/Sheet.mjs.map +0 -6
- package/dist/esm/SheetContext.mjs +0 -14
- package/dist/esm/SheetContext.mjs.map +0 -6
- package/dist/esm/SheetController.mjs +0 -25
- package/dist/esm/SheetController.mjs.map +0 -6
- package/dist/esm/SheetScrollView.mjs +0 -81
- package/dist/esm/SheetScrollView.mjs.map +0 -6
- package/dist/esm/constants.mjs +0 -9
- package/dist/esm/constants.mjs.map +0 -6
- package/dist/esm/getNativeSheet.js +0 -14
- package/dist/esm/getNativeSheet.js.map +0 -6
- package/dist/esm/getNativeSheet.mjs +0 -14
- package/dist/esm/getNativeSheet.mjs.map +0 -6
- package/dist/esm/index.mjs +0 -8
- package/dist/esm/index.mjs.map +0 -6
- package/dist/esm/native-ios.js +0 -4
- package/dist/esm/native-ios.js.map +0 -6
- package/dist/esm/native-ios.mjs +0 -4
- package/dist/esm/native-ios.mjs.map +0 -6
- package/dist/esm/nativeSheet.mjs +0 -47
- package/dist/esm/nativeSheet.mjs.map +0 -6
- package/dist/esm/types.mjs +0 -1
- package/dist/esm/types.mjs.map +0 -6
- package/dist/esm/useSheetChildren.js +0 -46
- package/dist/esm/useSheetChildren.js.map +0 -6
- package/dist/esm/useSheetChildren.mjs +0 -46
- package/dist/esm/useSheetChildren.mjs.map +0 -6
- package/dist/esm/useSheetContoller.js +0 -19
- package/dist/esm/useSheetContoller.js.map +0 -6
- package/dist/esm/useSheetContoller.mjs +0 -19
- package/dist/esm/useSheetContoller.mjs.map +0 -6
- package/dist/esm/useSheetController.mjs +0 -19
- package/dist/esm/useSheetController.mjs.map +0 -6
- package/dist/esm/useSheetOpenState.mjs +0 -27
- package/dist/esm/useSheetOpenState.mjs.map +0 -6
- package/dist/esm/useSheetProviderProps.mjs +0 -64
- package/dist/esm/useSheetProviderProps.mjs.map +0 -6
- package/dist/esm/useSheetSnapPoints.js +0 -53
- package/dist/esm/useSheetSnapPoints.js.map +0 -6
- package/dist/esm/useSheetSnapPoints.mjs +0 -53
- package/dist/esm/useSheetSnapPoints.mjs.map +0 -6
- package/dist/jsx/getNativeSheet.js +0 -14
- package/dist/jsx/getNativeSheet.js.map +0 -6
- package/dist/jsx/getNativeSheet.mjs +0 -14
- package/dist/jsx/getNativeSheet.mjs.map +0 -6
- package/dist/jsx/native-ios.js +0 -4
- package/dist/jsx/native-ios.js.map +0 -6
- package/dist/jsx/native-ios.mjs +0 -4
- package/dist/jsx/native-ios.mjs.map +0 -6
- package/dist/jsx/useSheetChildren.js +0 -45
- package/dist/jsx/useSheetChildren.js.map +0 -6
- package/dist/jsx/useSheetChildren.mjs +0 -45
- package/dist/jsx/useSheetChildren.mjs.map +0 -6
- package/dist/jsx/useSheetContoller.js +0 -19
- package/dist/jsx/useSheetContoller.js.map +0 -6
- package/dist/jsx/useSheetContoller.mjs +0 -19
- package/dist/jsx/useSheetContoller.mjs.map +0 -6
- package/dist/jsx/useSheetSnapPoints.js +0 -53
- package/dist/jsx/useSheetSnapPoints.js.map +0 -6
- package/dist/jsx/useSheetSnapPoints.mjs +0 -53
- package/dist/jsx/useSheetSnapPoints.mjs.map +0 -6
- package/src/useSheetChildren.tsx +0 -47
- package/src/useSheetSnapPoints.tsx +0 -60
- package/types/SHEET_HANDLE_NAME.d.ts +0 -4
- package/types/getNativeSheet.d.ts +0 -3
- package/types/getNativeSheet.d.ts.map +0 -1
- package/types/native-ios.d.ts +0 -2
- package/types/native-ios.d.ts.map +0 -1
- package/types/useAnimated.d.ts +0 -19
- package/types/useAnimation.d.ts +0 -1
- package/types/useSheetChildren.d.ts +0 -7
- package/types/useSheetChildren.d.ts.map +0 -1
- package/types/useSheetContoller.d.ts +0 -14
- package/types/useSheetContoller.d.ts.map +0 -1
- package/types/useSheetSnapPoints.d.ts +0 -7
- package/types/useSheetSnapPoints.d.ts.map +0 -1
package/dist/cjs/Sheet.js
CHANGED
|
@@ -19,39 +19,22 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
20
|
var Sheet_exports = {};
|
|
21
21
|
__export(Sheet_exports, {
|
|
22
|
-
|
|
22
|
+
Frame: () => Frame,
|
|
23
|
+
Handle: () => Handle,
|
|
24
|
+
Overlay: () => Overlay,
|
|
23
25
|
Sheet: () => Sheet,
|
|
24
|
-
SheetFrame: () => SheetFrame,
|
|
25
|
-
SheetFrameFrame: () => SheetFrameFrame,
|
|
26
|
-
SheetHandle: () => SheetHandle,
|
|
27
26
|
SheetHandleFrame: () => SheetHandleFrame,
|
|
28
|
-
SheetOverlay: () => SheetOverlay,
|
|
29
27
|
SheetOverlayFrame: () => SheetOverlayFrame,
|
|
30
|
-
createSheetScope: () =>
|
|
28
|
+
createSheetScope: () => import_SheetContext.createSheetScope
|
|
31
29
|
});
|
|
32
30
|
module.exports = __toCommonJS(Sheet_exports);
|
|
33
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
-
var import_adapt = require("@tamagui/adapt");
|
|
35
|
-
var import_compose_refs = require("@tamagui/compose-refs");
|
|
36
31
|
var import_core = require("@tamagui/core");
|
|
37
|
-
var import_portal = require("@tamagui/portal");
|
|
38
|
-
var import_remove_scroll = require("@tamagui/remove-scroll");
|
|
39
32
|
var import_stacks = require("@tamagui/stacks");
|
|
40
|
-
var import_use_keyboard_visible = require("@tamagui/use-keyboard-visible");
|
|
41
|
-
var import_react = require("react");
|
|
42
|
-
var import_react_native = require("react-native");
|
|
43
33
|
var import_constants = require("./constants");
|
|
44
|
-
var
|
|
34
|
+
var import_createSheet = require("./createSheet");
|
|
45
35
|
var import_SheetContext = require("./SheetContext");
|
|
46
|
-
var import_SheetScrollView = require("./SheetScrollView");
|
|
47
|
-
var import_useSheetChildren = require("./useSheetChildren");
|
|
48
|
-
var import_useSheetController = require("./useSheetController");
|
|
49
|
-
var import_useSheetOpenState = require("./useSheetOpenState");
|
|
50
|
-
var import_useSheetProviderProps = require("./useSheetProviderProps");
|
|
51
|
-
var import_useSheetSnapPoints = require("./useSheetSnapPoints");
|
|
52
|
-
var import_SheetContext2 = require("./SheetContext");
|
|
53
36
|
__reExport(Sheet_exports, require("./types"), module.exports);
|
|
54
|
-
const
|
|
37
|
+
const Handle = (0, import_core.styled)(import_stacks.XStack, {
|
|
55
38
|
name: import_constants.SHEET_HANDLE_NAME,
|
|
56
39
|
variants: {
|
|
57
40
|
open: {
|
|
@@ -82,34 +65,17 @@ const SheetHandleFrame = (0, import_core.styled)(import_stacks.XStack, {
|
|
|
82
65
|
unstyled: false
|
|
83
66
|
}
|
|
84
67
|
});
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
const context = (0, import_SheetContext.useSheetContext)(import_constants.SHEET_HANDLE_NAME, __scopeSheet);
|
|
88
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
89
|
-
SheetHandleFrame,
|
|
90
|
-
{
|
|
91
|
-
onPress: () => {
|
|
92
|
-
const max = context.snapPoints.length + (context.dismissOnSnapToBottom ? -1 : 0);
|
|
93
|
-
const nextPos = (context.position + 1) % max;
|
|
94
|
-
context.setPosition(nextPos);
|
|
95
|
-
},
|
|
96
|
-
open: context.open,
|
|
97
|
-
...props
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
);
|
|
102
|
-
const SHEET_OVERLAY_NAME = "SheetOverlay";
|
|
103
|
-
const SheetOverlayFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
104
|
-
name: SHEET_OVERLAY_NAME,
|
|
68
|
+
const Overlay = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
69
|
+
name: import_constants.SHEET_OVERLAY_NAME,
|
|
105
70
|
variants: {
|
|
106
|
-
|
|
71
|
+
open: {
|
|
107
72
|
true: {
|
|
108
|
-
opacity:
|
|
109
|
-
pointerEvents: "
|
|
73
|
+
opacity: 1,
|
|
74
|
+
pointerEvents: "auto"
|
|
110
75
|
},
|
|
111
76
|
false: {
|
|
112
|
-
|
|
77
|
+
opacity: 0,
|
|
78
|
+
pointerEvents: "none"
|
|
113
79
|
}
|
|
114
80
|
},
|
|
115
81
|
unstyled: {
|
|
@@ -125,29 +91,7 @@ const SheetOverlayFrame = (0, import_core.styled)(import_stacks.ThemeableStack,
|
|
|
125
91
|
unstyled: false
|
|
126
92
|
}
|
|
127
93
|
});
|
|
128
|
-
const
|
|
129
|
-
({ __scopeSheet, ...props }) => {
|
|
130
|
-
const context = (0, import_SheetContext.useSheetContext)(SHEET_OVERLAY_NAME, __scopeSheet);
|
|
131
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
132
|
-
SheetOverlayFrame,
|
|
133
|
-
{
|
|
134
|
-
closed: !context.open || context.hidden,
|
|
135
|
-
...props,
|
|
136
|
-
onPress: (0, import_core.mergeEvent)(
|
|
137
|
-
props.onPress,
|
|
138
|
-
context.dismissOnOverlayPress ? () => {
|
|
139
|
-
context.setOpen(false);
|
|
140
|
-
} : void 0
|
|
141
|
-
)
|
|
142
|
-
}
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
);
|
|
146
|
-
const selectionStyleSheet = import_core.isClient ? document.createElement("style") : null;
|
|
147
|
-
if (selectionStyleSheet) {
|
|
148
|
-
document.head.appendChild(selectionStyleSheet);
|
|
149
|
-
}
|
|
150
|
-
const SheetFrameFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
94
|
+
const Frame = (0, import_core.styled)(import_stacks.YStack, {
|
|
151
95
|
name: import_constants.SHEET_NAME,
|
|
152
96
|
variants: {
|
|
153
97
|
unstyled: {
|
|
@@ -158,8 +102,7 @@ const SheetFrameFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
|
158
102
|
borderTopRightRadius: "$true",
|
|
159
103
|
width: "100%",
|
|
160
104
|
maxHeight: "100%",
|
|
161
|
-
overflow: "hidden"
|
|
162
|
-
pointerEvents: "auto"
|
|
105
|
+
overflow: "hidden"
|
|
163
106
|
}
|
|
164
107
|
}
|
|
165
108
|
},
|
|
@@ -167,366 +110,20 @@ const SheetFrameFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
|
167
110
|
unstyled: false
|
|
168
111
|
}
|
|
169
112
|
});
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const composedContentRef = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.contentRef);
|
|
175
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SheetFrameFrame, { ref: composedContentRef, ...props });
|
|
176
|
-
}
|
|
177
|
-
)
|
|
178
|
-
);
|
|
179
|
-
const HIDDEN_SIZE = 1e4;
|
|
180
|
-
const sheetComponents = {
|
|
181
|
-
Handle: SheetHandle,
|
|
182
|
-
Frame: SheetFrame,
|
|
183
|
-
Overlay: SheetOverlay,
|
|
184
|
-
ScrollView: import_SheetScrollView.SheetScrollView
|
|
185
|
-
};
|
|
186
|
-
const ParentSheetContext = (0, import_react.createContext)({
|
|
187
|
-
zIndex: 1e5
|
|
113
|
+
const Sheet = (0, import_createSheet.createSheet)({
|
|
114
|
+
Frame,
|
|
115
|
+
Handle,
|
|
116
|
+
Overlay
|
|
188
117
|
});
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
const hydrated = (0, import_core.useDidFinishSSR)();
|
|
192
|
-
const { isShowingNonSheet } = (0, import_useSheetController.useSheetController)();
|
|
193
|
-
let SheetImplementation = SheetImplementationCustom;
|
|
194
|
-
if (props.native && import_react_native.Platform.OS === "ios") {
|
|
195
|
-
if (process.env.TAMAGUI_TARGET === "native") {
|
|
196
|
-
const impl = (0, import_nativeSheet.getNativeSheet)("ios");
|
|
197
|
-
if (impl) {
|
|
198
|
-
SheetImplementation = impl;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
if (isShowingNonSheet || !hydrated) {
|
|
203
|
-
return null;
|
|
204
|
-
}
|
|
205
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SheetImplementation, { ref, ...props });
|
|
206
|
-
}),
|
|
207
|
-
sheetComponents
|
|
208
|
-
);
|
|
209
|
-
const SheetImplementationCustom = (0, import_core.themeable)(
|
|
210
|
-
(0, import_react.forwardRef)(function SheetImplementationCustom2(props, forwardedRef) {
|
|
211
|
-
const parentSheet = (0, import_react.useContext)(ParentSheetContext);
|
|
212
|
-
const {
|
|
213
|
-
animationConfig,
|
|
214
|
-
forceRemoveScrollEnabled = null,
|
|
215
|
-
disableDrag: disableDragProp,
|
|
216
|
-
modal = false,
|
|
217
|
-
zIndex = parentSheet.zIndex + 1,
|
|
218
|
-
moveOnKeyboardChange = false,
|
|
219
|
-
portalProps
|
|
220
|
-
} = props;
|
|
221
|
-
const state = (0, import_useSheetOpenState.useSheetOpenState)(props);
|
|
222
|
-
const providerProps = (0, import_useSheetProviderProps.useSheetProviderProps)(props, state);
|
|
223
|
-
const { positions, maxSnapPoint, screenSize } = (0, import_useSheetSnapPoints.useSheetSnapPoints)(providerProps);
|
|
224
|
-
const { position, contentRef, setPosition, scrollBridge, frameSize, setFrameSize } = providerProps;
|
|
225
|
-
const { open, isHidden, controller } = state;
|
|
226
|
-
const { frameComponent, handleComponent, bottomCoverComponent, overlayComponent } = (0, import_useSheetChildren.useSheetChildren)(props.children);
|
|
227
|
-
const sheetRef = (0, import_react.useRef)(null);
|
|
228
|
-
const ref = (0, import_compose_refs.useComposedRefs)(forwardedRef, sheetRef);
|
|
229
|
-
const driver = (0, import_core.useAnimationDriver)();
|
|
230
|
-
if (!driver) {
|
|
231
|
-
throw new Error("Must set animations in tamagui.config.ts");
|
|
232
|
-
}
|
|
233
|
-
const disableDrag = disableDragProp ?? (controller == null ? void 0 : controller.disableDrag);
|
|
234
|
-
const keyboardIsVisible = (0, import_use_keyboard_visible.useKeyboardVisible)();
|
|
235
|
-
const themeName = (0, import_core.useThemeName)();
|
|
236
|
-
const { useAnimatedNumber, useAnimatedNumberReaction, useAnimatedNumberStyle } = driver;
|
|
237
|
-
const animatedNumber = useAnimatedNumber(HIDDEN_SIZE);
|
|
238
|
-
const at = (0, import_react.useRef)(0);
|
|
239
|
-
useAnimatedNumberReaction(
|
|
240
|
-
{
|
|
241
|
-
value: animatedNumber,
|
|
242
|
-
hostRef: sheetRef
|
|
243
|
-
},
|
|
244
|
-
(value) => {
|
|
245
|
-
if (!driver.isReactNative)
|
|
246
|
-
return;
|
|
247
|
-
at.current = value;
|
|
248
|
-
scrollBridge.paneY = value;
|
|
249
|
-
}
|
|
250
|
-
);
|
|
251
|
-
function stopSpring() {
|
|
252
|
-
animatedNumber.stop();
|
|
253
|
-
if (scrollBridge.onFinishAnimate) {
|
|
254
|
-
scrollBridge.onFinishAnimate();
|
|
255
|
-
scrollBridge.onFinishAnimate = void 0;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
const [opacity, setOpacity] = (0, import_react.useState)(open ? 1 : 0);
|
|
259
|
-
if (open && opacity === 0) {
|
|
260
|
-
setOpacity(1);
|
|
261
|
-
}
|
|
262
|
-
(0, import_react.useEffect)(() => {
|
|
263
|
-
if (!open) {
|
|
264
|
-
const tm = setTimeout(() => {
|
|
265
|
-
setOpacity(0);
|
|
266
|
-
}, 400);
|
|
267
|
-
return () => {
|
|
268
|
-
clearTimeout(tm);
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
}, [open]);
|
|
272
|
-
const animateTo = (0, import_core.useEvent)((position2) => {
|
|
273
|
-
const current = animatedNumber.getValue();
|
|
274
|
-
if (isHidden && open)
|
|
275
|
-
return;
|
|
276
|
-
if (!current)
|
|
277
|
-
return;
|
|
278
|
-
if (frameSize === 0)
|
|
279
|
-
return;
|
|
280
|
-
const hiddenValue = frameSize === 0 ? HIDDEN_SIZE : screenSize;
|
|
281
|
-
const toValue = isHidden || position2 === -1 ? hiddenValue : positions[position2];
|
|
282
|
-
if (at.current === toValue)
|
|
283
|
-
return;
|
|
284
|
-
stopSpring();
|
|
285
|
-
if (isHidden) {
|
|
286
|
-
animatedNumber.setValue(toValue, {
|
|
287
|
-
type: "timing",
|
|
288
|
-
duration: 0
|
|
289
|
-
});
|
|
290
|
-
at.current = toValue;
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
const overshootClamping = at.current === HIDDEN_SIZE;
|
|
294
|
-
animatedNumber.setValue(toValue, {
|
|
295
|
-
...animationConfig,
|
|
296
|
-
type: "spring",
|
|
297
|
-
overshootClamping
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
301
|
-
animateTo(position);
|
|
302
|
-
}, [isHidden, frameSize, position, animateTo]);
|
|
303
|
-
const [isShowingInnerSheet, setIsShowingInnerSheet] = (0, import_react.useState)(false);
|
|
304
|
-
const shouldHideParentSheet = !import_core.isWeb && modal && isShowingInnerSheet;
|
|
305
|
-
const parentSheetContext = (0, import_react.useContext)(SheetInsideSheetContext);
|
|
306
|
-
const onInnerSheet = (0, import_react.useCallback)((hasChild) => {
|
|
307
|
-
setIsShowingInnerSheet(hasChild);
|
|
308
|
-
}, []);
|
|
309
|
-
const panResponder = (0, import_react.useMemo)(
|
|
310
|
-
() => {
|
|
311
|
-
if (disableDrag)
|
|
312
|
-
return;
|
|
313
|
-
if (!frameSize)
|
|
314
|
-
return;
|
|
315
|
-
if (isShowingInnerSheet)
|
|
316
|
-
return;
|
|
317
|
-
const minY = positions[0];
|
|
318
|
-
scrollBridge.paneMinY = minY;
|
|
319
|
-
let startY = at.current;
|
|
320
|
-
function makeUnselectable(val) {
|
|
321
|
-
if (!selectionStyleSheet)
|
|
322
|
-
return;
|
|
323
|
-
if (!val) {
|
|
324
|
-
selectionStyleSheet.innerText = "";
|
|
325
|
-
} else {
|
|
326
|
-
selectionStyleSheet.innerText = ":root * { user-select: none !important; -webkit-user-select: none !important; }";
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
const release = ({ vy, dragAt }) => {
|
|
330
|
-
isExternalDrag = false;
|
|
331
|
-
previouslyScrolling = false;
|
|
332
|
-
makeUnselectable(false);
|
|
333
|
-
const at2 = dragAt + startY;
|
|
334
|
-
const end = at2 + frameSize * vy * 0.2;
|
|
335
|
-
let closestPoint = 0;
|
|
336
|
-
let dist = Infinity;
|
|
337
|
-
for (let i = 0; i < positions.length; i++) {
|
|
338
|
-
const position2 = positions[i];
|
|
339
|
-
const curDist = end > position2 ? end - position2 : position2 - end;
|
|
340
|
-
if (curDist < dist) {
|
|
341
|
-
dist = curDist;
|
|
342
|
-
closestPoint = i;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
setPosition(closestPoint);
|
|
346
|
-
animateTo(closestPoint);
|
|
347
|
-
};
|
|
348
|
-
const finish = (_e, state2) => {
|
|
349
|
-
release({
|
|
350
|
-
vy: state2.vy,
|
|
351
|
-
dragAt: state2.dy
|
|
352
|
-
});
|
|
353
|
-
};
|
|
354
|
-
let previouslyScrolling = false;
|
|
355
|
-
const onMoveShouldSet = (_e, { dy }) => {
|
|
356
|
-
const isScrolled = scrollBridge.y !== 0;
|
|
357
|
-
const isDraggingUp = dy < 0;
|
|
358
|
-
const isNearTop = scrollBridge.paneY - 5 <= scrollBridge.paneMinY;
|
|
359
|
-
if (isScrolled) {
|
|
360
|
-
previouslyScrolling = true;
|
|
361
|
-
return false;
|
|
362
|
-
}
|
|
363
|
-
if (isNearTop) {
|
|
364
|
-
if (!isScrolled && isDraggingUp) {
|
|
365
|
-
return false;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
return Math.abs(dy) > 5;
|
|
369
|
-
};
|
|
370
|
-
const grant = () => {
|
|
371
|
-
makeUnselectable(true);
|
|
372
|
-
stopSpring();
|
|
373
|
-
startY = at.current;
|
|
374
|
-
};
|
|
375
|
-
let isExternalDrag = false;
|
|
376
|
-
scrollBridge.drag = (dy) => {
|
|
377
|
-
if (!isExternalDrag) {
|
|
378
|
-
isExternalDrag = true;
|
|
379
|
-
grant();
|
|
380
|
-
}
|
|
381
|
-
const to = dy + startY;
|
|
382
|
-
animatedNumber.setValue(resisted(to, minY), { type: "direct" });
|
|
383
|
-
};
|
|
384
|
-
scrollBridge.release = release;
|
|
385
|
-
return import_react_native.PanResponder.create({
|
|
386
|
-
onMoveShouldSetPanResponder: onMoveShouldSet,
|
|
387
|
-
onPanResponderGrant: grant,
|
|
388
|
-
onPanResponderMove: (_e, { dy }) => {
|
|
389
|
-
const toFull = dy + startY;
|
|
390
|
-
const to = resisted(toFull, minY);
|
|
391
|
-
animatedNumber.setValue(to, { type: "direct" });
|
|
392
|
-
},
|
|
393
|
-
onPanResponderEnd: finish,
|
|
394
|
-
onPanResponderTerminate: finish,
|
|
395
|
-
onPanResponderRelease: finish
|
|
396
|
-
});
|
|
397
|
-
},
|
|
398
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
399
|
-
[disableDrag, isShowingInnerSheet, animateTo, frameSize, positions, setPosition]
|
|
400
|
-
);
|
|
401
|
-
const animatedStyle = useAnimatedNumberStyle(animatedNumber, (val) => {
|
|
402
|
-
"worklet";
|
|
403
|
-
const translateY = frameSize === 0 ? HIDDEN_SIZE : val;
|
|
404
|
-
return {
|
|
405
|
-
transform: [{ translateY }]
|
|
406
|
-
};
|
|
407
|
-
});
|
|
408
|
-
const sizeBeforeKeyboard = (0, import_react.useRef)(null);
|
|
409
|
-
(0, import_react.useEffect)(() => {
|
|
410
|
-
if (import_core.isWeb || !moveOnKeyboardChange)
|
|
411
|
-
return;
|
|
412
|
-
const keyboardDidShowListener = import_react_native.Keyboard.addListener("keyboardDidShow", (e) => {
|
|
413
|
-
if (sizeBeforeKeyboard.current !== null)
|
|
414
|
-
return;
|
|
415
|
-
sizeBeforeKeyboard.current = animatedNumber.getValue();
|
|
416
|
-
animatedNumber.setValue(
|
|
417
|
-
Math.max(animatedNumber.getValue() - e.endCoordinates.height, 0)
|
|
418
|
-
);
|
|
419
|
-
});
|
|
420
|
-
const keyboardDidHideListener = import_react_native.Keyboard.addListener("keyboardDidHide", () => {
|
|
421
|
-
if (sizeBeforeKeyboard.current === null)
|
|
422
|
-
return;
|
|
423
|
-
animatedNumber.setValue(sizeBeforeKeyboard.current);
|
|
424
|
-
sizeBeforeKeyboard.current = null;
|
|
425
|
-
});
|
|
426
|
-
return () => {
|
|
427
|
-
keyboardDidHideListener.remove();
|
|
428
|
-
keyboardDidShowListener.remove();
|
|
429
|
-
};
|
|
430
|
-
}, []);
|
|
431
|
-
const AnimatedView = driver["NumberView"] ?? driver.View;
|
|
432
|
-
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
433
|
-
if (!(parentSheetContext && open))
|
|
434
|
-
return;
|
|
435
|
-
parentSheetContext(true);
|
|
436
|
-
return () => {
|
|
437
|
-
parentSheetContext(false);
|
|
438
|
-
};
|
|
439
|
-
}, [parentSheetContext, open]);
|
|
440
|
-
const nextParentContext = (0, import_react.useMemo)(
|
|
441
|
-
() => ({
|
|
442
|
-
zIndex
|
|
443
|
-
}),
|
|
444
|
-
[zIndex]
|
|
445
|
-
);
|
|
446
|
-
const handleLayout = (0, import_react.useCallback)(
|
|
447
|
-
(e) => {
|
|
448
|
-
var _a;
|
|
449
|
-
let next = (_a = e.nativeEvent) == null ? void 0 : _a.layout.height;
|
|
450
|
-
if (import_core.isWeb && import_core.isTouchable && !open) {
|
|
451
|
-
next += 100;
|
|
452
|
-
}
|
|
453
|
-
if (!next)
|
|
454
|
-
return;
|
|
455
|
-
setFrameSize(() => next);
|
|
456
|
-
},
|
|
457
|
-
[keyboardIsVisible]
|
|
458
|
-
);
|
|
459
|
-
const removeScrollEnabled = forceRemoveScrollEnabled ?? (open && modal);
|
|
460
|
-
const contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ParentSheetContext.Provider, { value: nextParentContext, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_SheetContext.SheetProvider, { ...providerProps, children: [
|
|
461
|
-
shouldHideParentSheet ? null : overlayComponent,
|
|
462
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
463
|
-
AnimatedView,
|
|
464
|
-
{
|
|
465
|
-
ref,
|
|
466
|
-
...panResponder == null ? void 0 : panResponder.panHandlers,
|
|
467
|
-
onLayout: handleLayout,
|
|
468
|
-
pointerEvents: open && !shouldHideParentSheet ? "auto" : "none",
|
|
469
|
-
animation: props.animation,
|
|
470
|
-
style: [
|
|
471
|
-
{
|
|
472
|
-
position: "absolute",
|
|
473
|
-
zIndex,
|
|
474
|
-
width: "100%",
|
|
475
|
-
height: `${maxSnapPoint}%`,
|
|
476
|
-
opacity
|
|
477
|
-
},
|
|
478
|
-
animatedStyle
|
|
479
|
-
],
|
|
480
|
-
children: [
|
|
481
|
-
handleComponent,
|
|
482
|
-
bottomCoverComponent,
|
|
483
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
484
|
-
import_remove_scroll.RemoveScroll,
|
|
485
|
-
{
|
|
486
|
-
forwardProps: true,
|
|
487
|
-
enabled: removeScrollEnabled,
|
|
488
|
-
allowPinchZoom: true,
|
|
489
|
-
shards: [contentRef],
|
|
490
|
-
removeScrollBar: false,
|
|
491
|
-
children: frameComponent
|
|
492
|
-
}
|
|
493
|
-
)
|
|
494
|
-
]
|
|
495
|
-
}
|
|
496
|
-
)
|
|
497
|
-
] }) });
|
|
498
|
-
const adaptContext = (0, import_react.useContext)(import_adapt.AdaptParentContext);
|
|
499
|
-
if (modal) {
|
|
500
|
-
const modalContents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.Portal, { zIndex, ...portalProps, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Theme, { forceClassName: true, name: themeName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_adapt.AdaptParentContext.Provider, { value: adaptContext, children: contents }) }) });
|
|
501
|
-
if (import_core.isWeb) {
|
|
502
|
-
return modalContents;
|
|
503
|
-
}
|
|
504
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SheetInsideSheetContext.Provider, { value: onInnerSheet, children: modalContents });
|
|
505
|
-
}
|
|
506
|
-
return contents;
|
|
507
|
-
})
|
|
508
|
-
);
|
|
509
|
-
const SheetInsideSheetContext = (0, import_react.createContext)(null);
|
|
510
|
-
const ControlledSheet = Sheet;
|
|
511
|
-
function resisted(y, minY, maxOverflow = 25) {
|
|
512
|
-
if (y < minY) {
|
|
513
|
-
const past = minY - y;
|
|
514
|
-
const pctPast = Math.min(maxOverflow, past) / maxOverflow;
|
|
515
|
-
const diminishBy = 1.1 - Math.pow(0.1, pctPast);
|
|
516
|
-
const extra = -diminishBy * maxOverflow;
|
|
517
|
-
return minY + extra;
|
|
518
|
-
}
|
|
519
|
-
return y;
|
|
520
|
-
}
|
|
118
|
+
const SheetOverlayFrame = Overlay;
|
|
119
|
+
const SheetHandleFrame = Handle;
|
|
521
120
|
// Annotate the CommonJS export names for ESM import in node:
|
|
522
121
|
0 && (module.exports = {
|
|
523
|
-
|
|
122
|
+
Frame,
|
|
123
|
+
Handle,
|
|
124
|
+
Overlay,
|
|
524
125
|
Sheet,
|
|
525
|
-
SheetFrame,
|
|
526
|
-
SheetFrameFrame,
|
|
527
|
-
SheetHandle,
|
|
528
126
|
SheetHandleFrame,
|
|
529
|
-
SheetOverlay,
|
|
530
127
|
SheetOverlayFrame,
|
|
531
128
|
createSheetScope,
|
|
532
129
|
...require("./types")
|
package/dist/cjs/Sheet.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Sheet.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA
|
|
5
|
-
"names": [
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAuB;AACvB,oBAA+C;AAE/C,uBAAkE;AAClE,yBAA4B;AAE5B,0BAAiC;AACjC,0BAAc,oBAPd;AAaO,MAAM,aAAS,oBAAO,sBAAQ;AAAA,EACnC,MAAM;AAAA,EAEN,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,MAAM;AAAA,QACJ,eAAe;AAAA,MACjB;AAAA,MACA,OAAO;AAAA,QACL,SAAS;AAAA,QACT,eAAe;AAAA,MACjB;AAAA,IACF;AAAA,IAEA,UAAU;AAAA,MACR,OAAO;AAAA,QACL,QAAQ;AAAA,QACR,cAAc;AAAA,QACd,iBAAiB;AAAA,QACjB,QAAQ;AAAA,QACR,kBAAkB;AAAA,QAClB,cAAc;AAAA,QACd,SAAS;AAAA,QAET,YAAY;AAAA,UACV,SAAS;AAAA,QACX;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB;AAAA,IACf,UAAU;AAAA,EACZ;AACF,CAAC;AAMM,MAAM,cAAU,oBAAO,8BAAgB;AAAA,EAC5C,MAAM;AAAA,EAEN,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,MAAM;AAAA,QACJ,SAAS;AAAA,QACT,eAAe;AAAA,MACjB;AAAA,MACA,OAAO;AAAA,QACL,SAAS;AAAA,QACT,eAAe;AAAA,MACjB;AAAA,IACF;AAAA,IAEA,UAAU;AAAA,MACR,OAAO;AAAA,QACL,YAAY;AAAA,QACZ,UAAU;AAAA,QACV,cAAc;AAAA,QACd,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB;AAAA,IACf,UAAU;AAAA,EACZ;AACF,CAAC;AAMM,MAAM,YAAQ,oBAAO,sBAAQ;AAAA,EAClC,MAAM;AAAA,EAEN,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,MAAM;AAAA,QACN,iBAAiB;AAAA,QACjB,qBAAqB;AAAA,QACrB,sBAAsB;AAAA,QACtB,OAAO;AAAA,QACP,WAAW;AAAA,QACX,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB;AAAA,IACf,UAAU;AAAA,EACZ;AACF,CAAC;AAEM,MAAM,YAAQ,gCAAY;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,MAAM,oBAAoB;AAG1B,MAAM,mBAAmB;",
|
|
5
|
+
"names": []
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/SheetContext.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAmC;AAEnC,uBAA2B;AAGpB,MAAM,CAAC,oBAAoB,gBAAgB,QAAI,0CAAmB,2BAAU;AAE5E,MAAM,CAAC,eAAe,eAAe,IAAI;AAAA,EAC9C;AAAA,EACA,CAAC;AACH;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|