@lodev09/react-native-true-sheet 0.11.2 → 0.12.0

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 (44) hide show
  1. package/README.md +2 -2
  2. package/android/src/main/java/com/lodev09/truesheet/TrueSheetDialog.kt +27 -11
  3. package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +50 -16
  4. package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +15 -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/core/Utils.kt +34 -15
  8. package/android/src/main/java/com/lodev09/truesheet/events/DismissEvent.kt +16 -0
  9. package/android/src/main/java/com/lodev09/truesheet/events/MountEvent.kt +16 -0
  10. package/android/src/main/java/com/lodev09/truesheet/events/PresentEvent.kt +23 -0
  11. package/android/src/main/java/com/lodev09/truesheet/events/SizeChangeEvent.kt +23 -0
  12. package/ios/TrueSheetView.swift +71 -19
  13. package/ios/TrueSheetViewManager.m +3 -0
  14. package/ios/Utils/Logger.swift +5 -9
  15. package/lib/commonjs/TrueSheet.js +11 -1
  16. package/lib/commonjs/TrueSheet.js.map +1 -1
  17. package/lib/commonjs/{types.js → TrueSheet.types.js} +1 -1
  18. package/lib/commonjs/TrueSheet.types.js.map +1 -0
  19. package/lib/commonjs/index.js +8 -8
  20. package/lib/commonjs/index.js.map +1 -1
  21. package/lib/module/TrueSheet.js +10 -0
  22. package/lib/module/TrueSheet.js.map +1 -1
  23. package/lib/module/TrueSheet.types.js +2 -0
  24. package/lib/module/TrueSheet.types.js.map +1 -0
  25. package/lib/module/index.js +1 -1
  26. package/lib/module/index.js.map +1 -1
  27. package/lib/typescript/src/TrueSheet.d.ts +2 -1
  28. package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
  29. package/lib/typescript/src/{types.d.ts → TrueSheet.types.d.ts} +19 -1
  30. package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -0
  31. package/lib/typescript/src/TrueSheetFooter.d.ts +1 -1
  32. package/lib/typescript/src/TrueSheetFooter.d.ts.map +1 -1
  33. package/lib/typescript/src/index.d.ts +1 -1
  34. package/lib/typescript/src/index.d.ts.map +1 -1
  35. package/package.json +4 -7
  36. package/src/TrueSheet.tsx +12 -1
  37. package/src/{types.ts → TrueSheet.types.ts} +21 -0
  38. package/src/TrueSheetFooter.tsx +1 -1
  39. package/src/index.ts +1 -1
  40. package/android/src/main/java/com/lodev09/truesheet/core/Events.kt +0 -51
  41. package/lib/commonjs/types.js.map +0 -1
  42. package/lib/module/types.js +0 -2
  43. package/lib/module/types.js.map +0 -1
  44. package/lib/typescript/src/types.d.ts.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lodev09/react-native-true-sheet",
3
- "version": "0.11.2",
3
+ "version": "0.12.0",
4
4
  "description": "The true native bottom sheet experience for your React Native Apps.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -60,7 +60,7 @@
60
60
  "devDependencies": {
61
61
  "@commitlint/config-conventional": "^19.0.3",
62
62
  "@evilmartians/lefthook": "^1.6.5",
63
- "@react-native/eslint-config": "^0.73.2",
63
+ "@react-native/eslint-config": "^0.74.83",
64
64
  "@release-it/conventional-changelog": "^8.0.1",
65
65
  "@types/jest": "^29.5.12",
66
66
  "@types/react": "^18.2.64",
@@ -78,14 +78,11 @@
78
78
  "jest": "^29.7.0",
79
79
  "prettier": "^3.2.5",
80
80
  "react": "^18.2.0",
81
- "react-native": "^0.73.5",
81
+ "react-native": "^0.74.1",
82
82
  "react-native-builder-bob": "^0.23.2",
83
83
  "release-it": "^17.1.1",
84
84
  "typescript": "~5.3.3"
85
85
  },
86
- "resolutions": {
87
- "@types/react": "^18.2.44"
88
- },
89
86
  "peerDependencies": {
90
87
  "react": "*",
91
88
  "react-native": "*"
@@ -94,7 +91,7 @@
94
91
  "example",
95
92
  "docs"
96
93
  ],
97
- "packageManager": "yarn@4.1.1",
94
+ "packageManager": "yarn@4.2.2",
98
95
  "jest": {
99
96
  "preset": "react-native",
100
97
  "modulePathIgnorePatterns": [
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,8 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
203
208
  dismissible = true,
204
209
  grabber = true,
205
210
  dimmed = true,
211
+ initialIndexAnimated = true,
212
+ initialIndex,
206
213
  dimmedIndex,
207
214
  grabberProps,
208
215
  blurTint,
@@ -228,8 +235,11 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
228
235
  grabber={grabber}
229
236
  dimmed={dimmed}
230
237
  dimmedIndex={dimmedIndex}
238
+ initialIndex={initialIndex}
239
+ initialIndexAnimated={initialIndexAnimated}
231
240
  dismissible={dismissible}
232
241
  maxHeight={maxHeight}
242
+ onMount={this.onMount}
233
243
  onPresent={this.onPresent}
234
244
  onDismiss={this.onDismiss}
235
245
  onSizeChange={this.onSizeChange}
@@ -267,6 +277,7 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
267
277
 
268
278
  const $nativeSheet: ViewStyle = {
269
279
  position: 'absolute',
280
+ width: '100%',
270
281
  left: -9999,
271
282
  zIndex: -9999,
272
283
  }
@@ -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,11 @@ export interface TrueSheetProps extends ViewProps {
205
221
  */
206
222
  FooterComponent?: ComponentType<unknown> | ReactElement
207
223
 
224
+ /**
225
+ * This is called when the sheet is ready to present.
226
+ */
227
+ onMount?: () => void
228
+
208
229
  /**
209
230
  * Called when the Sheet has been presented.
210
231
  * 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,CA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