@lodev09/react-native-true-sheet 0.11.3 → 0.12.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.
Files changed (42) hide show
  1. package/README.md +1 -1
  2. package/android/src/main/java/com/lodev09/truesheet/TrueSheetDialog.kt +26 -15
  3. package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +56 -16
  4. package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +26 -3
  5. package/android/src/main/java/com/lodev09/truesheet/core/KeyboardManager.kt +2 -2
  6. package/android/src/main/java/com/lodev09/truesheet/core/RootSheetView.kt +26 -15
  7. package/android/src/main/java/com/lodev09/truesheet/events/DismissEvent.kt +16 -0
  8. package/android/src/main/java/com/lodev09/truesheet/events/MountEvent.kt +16 -0
  9. package/android/src/main/java/com/lodev09/truesheet/events/PresentEvent.kt +23 -0
  10. package/android/src/main/java/com/lodev09/truesheet/events/SizeChangeEvent.kt +23 -0
  11. package/ios/TrueSheetView.swift +71 -19
  12. package/ios/TrueSheetViewManager.m +3 -0
  13. package/lib/commonjs/TrueSheet.js +12 -0
  14. package/lib/commonjs/TrueSheet.js.map +1 -1
  15. package/lib/commonjs/{types.js → TrueSheet.types.js} +1 -1
  16. package/lib/commonjs/TrueSheet.types.js.map +1 -0
  17. package/lib/commonjs/index.js +8 -8
  18. package/lib/commonjs/index.js.map +1 -1
  19. package/lib/module/TrueSheet.js +12 -0
  20. package/lib/module/TrueSheet.js.map +1 -1
  21. package/lib/module/TrueSheet.types.js +2 -0
  22. package/lib/module/TrueSheet.types.js.map +1 -0
  23. package/lib/module/index.js +1 -1
  24. package/lib/module/index.js.map +1 -1
  25. package/lib/typescript/src/TrueSheet.d.ts +2 -1
  26. package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
  27. package/lib/typescript/src/{types.d.ts → TrueSheet.types.d.ts} +27 -1
  28. package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -0
  29. package/lib/typescript/src/TrueSheetFooter.d.ts +1 -1
  30. package/lib/typescript/src/TrueSheetFooter.d.ts.map +1 -1
  31. package/lib/typescript/src/index.d.ts +1 -1
  32. package/lib/typescript/src/index.d.ts.map +1 -1
  33. package/package.json +2 -2
  34. package/src/TrueSheet.tsx +14 -1
  35. package/src/{types.ts → TrueSheet.types.ts} +30 -0
  36. package/src/TrueSheetFooter.tsx +1 -1
  37. package/src/index.ts +1 -1
  38. package/android/src/main/java/com/lodev09/truesheet/core/Events.kt +0 -51
  39. package/lib/commonjs/types.js.map +0 -1
  40. package/lib/module/types.js +0 -2
  41. package/lib/module/types.js.map +0 -1
  42. package/lib/typescript/src/types.d.ts.map +0 -1
package/src/TrueSheet.tsx CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  type LayoutChangeEvent,
11
11
  } from 'react-native'
12
12
 
13
- import type { TrueSheetProps, SizeInfo } from './types'
13
+ import type { TrueSheetProps, SizeInfo } from './TrueSheet.types'
14
14
  import { TrueSheetModule } from './TrueSheetModule'
15
15
  import { TrueSheetGrabber } from './TrueSheetGrabber'
16
16
  import { TrueSheetFooter } from './TrueSheetFooter'
@@ -59,6 +59,7 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
59
59
 
60
60
  this.ref = createRef<NativeRef>()
61
61
 
62
+ this.onMount = this.onMount.bind(this)
62
63
  this.onDismiss = this.onDismiss.bind(this)
63
64
  this.onPresent = this.onPresent.bind(this)
64
65
  this.onSizeChange = this.onSizeChange.bind(this)
@@ -159,6 +160,10 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
159
160
  this.props.onDismiss?.()
160
161
  }
161
162
 
163
+ private onMount(): void {
164
+ this.props.onMount?.()
165
+ }
166
+
162
167
  /**
163
168
  * Present the sheet. Optionally accepts a size `index`.
164
169
  * See `sizes` prop
@@ -203,6 +208,9 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
203
208
  dismissible = true,
204
209
  grabber = true,
205
210
  dimmed = true,
211
+ initialIndexAnimated = true,
212
+ keyboardMode = 'resize',
213
+ initialIndex,
206
214
  dimmedIndex,
207
215
  grabberProps,
208
216
  blurTint,
@@ -228,8 +236,12 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
228
236
  grabber={grabber}
229
237
  dimmed={dimmed}
230
238
  dimmedIndex={dimmedIndex}
239
+ initialIndex={initialIndex}
240
+ initialIndexAnimated={initialIndexAnimated}
241
+ keyboardMode={keyboardMode}
231
242
  dismissible={dismissible}
232
243
  maxHeight={maxHeight}
244
+ onMount={this.onMount}
233
245
  onPresent={this.onPresent}
234
246
  onDismiss={this.onDismiss}
235
247
  onSizeChange={this.onSizeChange}
@@ -267,6 +279,7 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
267
279
 
268
280
  const $nativeSheet: ViewStyle = {
269
281
  position: 'absolute',
282
+ width: '100%',
270
283
  left: -9999,
271
284
  zIndex: -9999,
272
285
  }
@@ -130,6 +130,22 @@ export interface TrueSheetProps extends ViewProps {
130
130
  */
131
131
  dimmed?: boolean
132
132
 
133
+ /**
134
+ * Initially present the sheet, after mounting, at a given size index.
135
+ *
136
+ * @note This property is only used during the initial mount.
137
+ * @default -1
138
+ */
139
+ initialIndex?: number
140
+
141
+ /**
142
+ * Specify whether the sheet should animate after mounting.
143
+ * Used with `initialIndex`.
144
+ *
145
+ * @default true
146
+ */
147
+ initialIndexAnimated?: boolean
148
+
133
149
  /**
134
150
  * The size index that the sheet should start to dim the background.
135
151
  * This is ignored if `dimmed` is set to `false`.
@@ -205,6 +221,20 @@ export interface TrueSheetProps extends ViewProps {
205
221
  */
206
222
  FooterComponent?: ComponentType<unknown> | ReactElement
207
223
 
224
+ /**
225
+ * Determines how the software keyboard will impact the layout of the sheet.
226
+ * Set to `pan` if you're working with `FlatList` with a `TextInput`.
227
+ *
228
+ * @platform android
229
+ * @default resize
230
+ */
231
+ keyboardMode?: 'resize' | 'pan'
232
+
233
+ /**
234
+ * This is called when the sheet is ready to present.
235
+ */
236
+ onMount?: () => void
237
+
208
238
  /**
209
239
  * Called when the Sheet has been presented.
210
240
  * Comes with the size info.
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import type { TrueSheetProps } from './types'
2
+ import type { TrueSheetProps } from './TrueSheet.types'
3
3
 
4
4
  interface TrueSheetFooterProps {
5
5
  Component?: TrueSheetProps['FooterComponent']
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './types'
2
1
  export * from './TrueSheet'
2
+ export * from './TrueSheet.types'
3
3
  export * from './TrueSheetGrabber'
@@ -1,51 +0,0 @@
1
- package com.lodev09.truesheet.core
2
-
3
- import com.facebook.react.bridge.Arguments
4
- import com.facebook.react.bridge.WritableMap
5
- import com.facebook.react.uimanager.events.Event
6
- import com.lodev09.truesheet.SizeInfo
7
-
8
- // onPresent
9
- class PresentEvent(surfaceId: Int, viewId: Int, private val sizeInfo: SizeInfo) : Event<PresentEvent>(surfaceId, viewId) {
10
- override fun getEventName() = EVENT_NAME
11
-
12
- override fun getEventData(): WritableMap {
13
- val data = Arguments.createMap()
14
- data.putInt("index", sizeInfo.index)
15
- data.putDouble("value", sizeInfo.value.toDouble())
16
-
17
- return data
18
- }
19
-
20
- companion object {
21
- const val EVENT_NAME = "present"
22
- }
23
- }
24
-
25
- // onDismiss
26
- class DismissEvent(surfaceId: Int, viewId: Int) : Event<PresentEvent>(surfaceId, viewId) {
27
- override fun getEventName() = EVENT_NAME
28
-
29
- override fun getEventData(): WritableMap = Arguments.createMap()
30
-
31
- companion object {
32
- const val EVENT_NAME = "dismiss"
33
- }
34
- }
35
-
36
- // onSizeChange
37
- class SizeChangeEvent(surfaceId: Int, viewId: Int, private val sizeInfo: SizeInfo) : Event<SizeChangeEvent>(surfaceId, viewId) {
38
- override fun getEventName() = EVENT_NAME
39
-
40
- override fun getEventData(): WritableMap {
41
- val data = Arguments.createMap()
42
- data.putInt("index", sizeInfo.index)
43
- data.putDouble("value", sizeInfo.value.toDouble())
44
-
45
- return data
46
- }
47
-
48
- companion object {
49
- const val EVENT_NAME = "sizeChange"
50
- }
51
- }
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAE/D,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAChB,OAAO,GACP,MAAM,GACN,SAAS,GACT,YAAY,GACZ,SAAS,GACT,WAAW,GACX,yBAAyB,GACzB,oBAAoB,GACpB,gBAAgB,GAChB,qBAAqB,GACrB,sBAAsB,GACtB,8BAA8B,GAC9B,yBAAyB,GACzB,qBAAqB,GACrB,0BAA0B,GAC1B,2BAA2B,GAC3B,6BAA6B,GAC7B,wBAAwB,GACxB,oBAAoB,GACpB,yBAAyB,GACzB,0BAA0B,CAAA;AAE9B;;;;;GAKG;AACH,MAAM,MAAM,SAAS;AACnB;;;;;GAKG;AACD,MAAM;AAER;;;;;GAKG;GACD,MAAM;AAER;;;;;GAKG;GACD,GAAG,MAAM,GAAG;AAEd;;;;;GAKG;GACD,OAAO;AAET;;;;;GAKG;GACD,QAAQ;AAEV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