@startupjs-ui/modal 0.1.13 → 0.1.16
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 +8 -0
- package/README.mdx +54 -7
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.1.16](https://github.com/startupjs/startupjs-ui/compare/v0.1.15...v0.1.16) (2026-02-10)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @startupjs-ui/modal
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [0.1.13](https://github.com/startupjs/startupjs-ui/compare/v0.1.12...v0.1.13) (2026-02-03)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @startupjs-ui/modal
|
package/README.mdx
CHANGED
|
@@ -16,7 +16,7 @@ import './index.mdx.cssx.styl'
|
|
|
16
16
|
|
|
17
17
|
Inherits [React Native Modal](https://reactnative.dev/docs/modal).
|
|
18
18
|
|
|
19
|
-
Modal
|
|
19
|
+
Modal displays critical information, asks for user decisions, or presents a complex sub-task without navigating away from the current page or interrupting the workflow.
|
|
20
20
|
|
|
21
21
|
```js
|
|
22
22
|
import { Modal } from 'startupjs-ui'
|
|
@@ -24,6 +24,8 @@ import { Modal } from 'startupjs-ui'
|
|
|
24
24
|
|
|
25
25
|
## Simple example
|
|
26
26
|
|
|
27
|
+
The simplest way to use a Modal is to pass `visible` to control its visibility, a `title` for the header, and an `onRequestClose` callback to handle closing.
|
|
28
|
+
|
|
27
29
|
```jsx example
|
|
28
30
|
const [visible, setVisible] = useState(false)
|
|
29
31
|
|
|
@@ -45,9 +47,11 @@ return (
|
|
|
45
47
|
|
|
46
48
|
## Managing visibility
|
|
47
49
|
|
|
48
|
-
There are three
|
|
50
|
+
There are three ways to control the visibility of a modal:
|
|
51
|
+
|
|
52
|
+
### 1. Using a scoped model (`$visible`)
|
|
49
53
|
|
|
50
|
-
|
|
54
|
+
Pass a scoped model to `$visible` for two-way data binding. The modal reads and writes its visibility state through the model automatically.
|
|
51
55
|
|
|
52
56
|
```jsx example
|
|
53
57
|
const $visible = $()
|
|
@@ -67,7 +71,9 @@ return (
|
|
|
67
71
|
)
|
|
68
72
|
```
|
|
69
73
|
|
|
70
|
-
2.
|
|
74
|
+
### 2. Using a controlled `visible` prop
|
|
75
|
+
|
|
76
|
+
Pass the `visible` boolean prop along with an `onRequestClose` callback to manage visibility through React state.
|
|
71
77
|
|
|
72
78
|
```jsx example
|
|
73
79
|
const [visible, setVisible] = useState(false)
|
|
@@ -88,7 +94,9 @@ return (
|
|
|
88
94
|
)
|
|
89
95
|
```
|
|
90
96
|
|
|
91
|
-
3.
|
|
97
|
+
### 3. Using a ref
|
|
98
|
+
|
|
99
|
+
Pass a `ref` to the Modal to get access to imperative `open()` and `close()` methods for controlling visibility.
|
|
92
100
|
|
|
93
101
|
```jsx example
|
|
94
102
|
const modalRef = useRef()
|
|
@@ -110,7 +118,7 @@ return (
|
|
|
110
118
|
|
|
111
119
|
## Fullscreen modal
|
|
112
120
|
|
|
113
|
-
By default the modal
|
|
121
|
+
By default, the modal appears as a centered window. To make it fill the entire screen, set the `variant` prop to `'fullscreen'`.
|
|
114
122
|
|
|
115
123
|
```jsx example
|
|
116
124
|
const $visible = $(false)
|
|
@@ -133,9 +141,48 @@ return (
|
|
|
133
141
|
)
|
|
134
142
|
```
|
|
135
143
|
|
|
144
|
+
## Action buttons
|
|
145
|
+
|
|
146
|
+
The modal can automatically display action buttons at the bottom:
|
|
147
|
+
|
|
148
|
+
- Pass `onCancel` alone to show a single action button (labeled "OK" by default, customizable via `cancelLabel`).
|
|
149
|
+
- Pass both `onCancel` and `onConfirm` to show two buttons: "Cancel" and "Confirm" (customizable via `cancelLabel` and `confirmLabel`).
|
|
150
|
+
|
|
151
|
+
## Props reference
|
|
152
|
+
|
|
153
|
+
| Prop | Type | Default | Description |
|
|
154
|
+
|---|---|---|---|
|
|
155
|
+
| `style` | `StyleProp<ViewStyle>` | | Custom styles for the root view |
|
|
156
|
+
| `modalStyle` | `StyleProp<ViewStyle>` | | Custom styles for the modal content container |
|
|
157
|
+
| `children` | `ReactNode` | | Content rendered inside the modal |
|
|
158
|
+
| `variant` | `'window' \| 'fullscreen'` | `'window'` | Layout variant |
|
|
159
|
+
| `visible` | `boolean` | | Controlled visibility flag |
|
|
160
|
+
| `$visible` | `any` | | Scoped model for two-way visibility binding |
|
|
161
|
+
| `ref` | `RefObject` | | Imperative ref exposing `open()` and `close()` |
|
|
162
|
+
| `title` | `string` | | Header title text |
|
|
163
|
+
| `cancelLabel` | `string` | `'Cancel'` | Label for the cancel button |
|
|
164
|
+
| `confirmLabel` | `string` | `'Confirm'` | Label for the confirm button |
|
|
165
|
+
| `showCross` | `boolean` | `true` | Whether to show a close icon in the header |
|
|
166
|
+
| `enableBackdropPress` | `boolean` | `true` | Whether tapping the backdrop closes the modal |
|
|
167
|
+
| `ModalElement` | `ComponentType` | `SafeAreaView` | Component used as the modal container |
|
|
168
|
+
| `animationType` | `'slide' \| 'fade' \| 'none'` | `'fade'` | Animation used when showing/hiding the modal |
|
|
169
|
+
| `transparent` | `boolean` | `true` | Whether the modal has a transparent background |
|
|
170
|
+
| `statusBarTranslucent` | `boolean` | | Controls status bar translucency on Android |
|
|
171
|
+
| `supportedOrientations` | `SupportedOrientation[]` | all orientations | Allowed screen orientations while the modal is displayed |
|
|
172
|
+
| `onShow` | `() => void` | | Called after the modal becomes visible |
|
|
173
|
+
| `onCrossPress` | `(event) => void` | | Called when the close icon is pressed |
|
|
174
|
+
| `onCancel` | `(event) => void` | | Provides a cancel action button; called when it is pressed |
|
|
175
|
+
| `onConfirm` | `(event) => void` | | Provides a confirm action button; called when it is pressed |
|
|
176
|
+
| `onBackdropPress` | `(event) => void` | | Called when the backdrop is pressed (requires `enableBackdropPress`) |
|
|
177
|
+
| `onOrientationChange` | `(event) => void` | | Called when the device orientation changes while the modal is open |
|
|
178
|
+
| `onRequestClose` | `(value?) => void` | | Called when the user requests to close (hardware back, Esc, etc.) |
|
|
179
|
+
| `onDismiss` | `() => void` | | Called after the modal has been fully dismissed |
|
|
180
|
+
|
|
136
181
|
## Advanced usage
|
|
137
182
|
|
|
138
|
-
Modal
|
|
183
|
+
Modal is composed of three sub-components: `Modal.Header`, `Modal.Content`, and `Modal.Actions`. Use these to fully customize the modal layout. `Modal.Header` replaces the `title` prop, `Modal.Content` replaces `children`, and `Modal.Actions` replaces the `onCancel`/`onConfirm` buttons.
|
|
184
|
+
|
|
185
|
+
Each sub-component can be used independently or in combination.
|
|
139
186
|
|
|
140
187
|
```jsx example
|
|
141
188
|
const $visible = $(false)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startupjs-ui/modal",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -8,18 +8,18 @@
|
|
|
8
8
|
"types": "index.d.ts",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@startupjs-ui/button": "^0.1.
|
|
11
|
+
"@startupjs-ui/button": "^0.1.16",
|
|
12
12
|
"@startupjs-ui/core": "^0.1.11",
|
|
13
|
-
"@startupjs-ui/div": "^0.1.
|
|
14
|
-
"@startupjs-ui/icon": "^0.1.
|
|
15
|
-
"@startupjs-ui/portal": "^0.1.
|
|
16
|
-
"@startupjs-ui/scroll-view": "^0.1.
|
|
17
|
-
"@startupjs-ui/span": "^0.1.
|
|
13
|
+
"@startupjs-ui/div": "^0.1.16",
|
|
14
|
+
"@startupjs-ui/icon": "^0.1.16",
|
|
15
|
+
"@startupjs-ui/portal": "^0.1.16",
|
|
16
|
+
"@startupjs-ui/scroll-view": "^0.1.16",
|
|
17
|
+
"@startupjs-ui/span": "^0.1.16"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"react": "*",
|
|
21
21
|
"react-native": "*",
|
|
22
22
|
"startupjs": "*"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "9943aa3566d5d80f5b404473906eb3c0611f9ee5"
|
|
25
25
|
}
|