@ruby-native/react 0.11.2 → 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.
package/README.md CHANGED
@@ -37,6 +37,7 @@ Each component renders a hidden `data-native-*` signal element that the Ruby Nat
37
37
  - `NativeForm` - mark the current page as a form so back navigation skips it
38
38
  - `NativePresentation` - declare that this page lands as a root, with no back button
39
39
  - `NativeReview` - ask for an App Store review prompt when the page loads
40
+ - `NativeToast` - show a transient native toast above all app chrome
40
41
  - `NativeNavbar` - native navigation bar with title and buttons
41
42
  - `NativeButton` - native nav bar button (icon, title, href, or click target)
42
43
  - `NativeMenuItem` - item inside a native menu
package/index.d.ts CHANGED
@@ -16,6 +16,17 @@ export function NativeTabs({ enabled }: {
16
16
  * @returns {import("react").ReactElement}
17
17
  */
18
18
  export function NativePush(): import("react").ReactElement;
19
+ /**
20
+ * Who is signed in, as an opaque server-computed token (`native_identity_token`
21
+ * shared as an Inertia prop). Render on every page: an empty or missing token
22
+ * means signed out, and the app clears its screens when the value changes.
23
+ * @param {object} props
24
+ * @param {string | null} [props.token]
25
+ * @returns {import("react").ReactElement}
26
+ */
27
+ export function NativeIdentity({ token }: {
28
+ token?: string | null | undefined;
29
+ }): import("react").ReactElement;
19
30
  /**
20
31
  * @returns {import("react").ReactElement}
21
32
  */
@@ -40,6 +51,25 @@ export function NativePresentation({ intent }?: {
40
51
  * @returns {import("react").ReactElement}
41
52
  */
42
53
  export function NativeReview(): import("react").ReactElement;
54
+ /**
55
+ * A transient native toast shown above all app chrome. The signal is consumed
56
+ * the moment it fires, so a restored page cannot re-toast. Renders nothing
57
+ * visible on the web. The counterpart of the `native_toast_tag` Rails helper.
58
+ * @param {object} props
59
+ * @param {string} [props.message] Nothing renders when blank.
60
+ * @param {string | false} [props.icon] `false` hides the default checkmark.
61
+ * @param {NativeIcons} [props.icons]
62
+ * @param {number} [props.duration]
63
+ * @param {"inverted" | "system"} [props.appearance]
64
+ * @returns {import("react").ReactElement | null}
65
+ */
66
+ export function NativeToast({ message, icon, icons, duration, appearance }: {
67
+ message?: string | undefined;
68
+ icon?: string | false | undefined;
69
+ icons?: NativeIcons | undefined;
70
+ duration?: number | undefined;
71
+ appearance?: "inverted" | "system" | undefined;
72
+ }): import("react").ReactElement | null;
43
73
  /**
44
74
  * @param {object} props
45
75
  * @param {string} [props.title]
package/index.js CHANGED
@@ -86,6 +86,18 @@ export function NativePush() {
86
86
  return createElement("div", { "data-native-push": true, hidden: true })
87
87
  }
88
88
 
89
+ /**
90
+ * Who is signed in, as an opaque server-computed token (`native_identity_token`
91
+ * shared as an Inertia prop). Render on every page: an empty or missing token
92
+ * means signed out, and the app clears its screens when the value changes.
93
+ * @param {object} props
94
+ * @param {string | null} [props.token]
95
+ * @returns {import("react").ReactElement}
96
+ */
97
+ export function NativeIdentity({ token }) {
98
+ return createElement("div", { "data-native-identity": token ?? "", hidden: true })
99
+ }
100
+
89
101
  /**
90
102
  * @returns {import("react").ReactElement}
91
103
  */
@@ -117,6 +129,39 @@ export function NativeReview() {
117
129
  return createElement("div", { "data-native-review": true, hidden: true })
118
130
  }
119
131
 
132
+ /**
133
+ * A transient native toast shown above all app chrome. The signal is consumed
134
+ * the moment it fires, so a restored page cannot re-toast. Renders nothing
135
+ * visible on the web. The counterpart of the `native_toast_tag` Rails helper.
136
+ * @param {object} props
137
+ * @param {string} [props.message] Nothing renders when blank.
138
+ * @param {string | false} [props.icon] `false` hides the default checkmark.
139
+ * @param {NativeIcons} [props.icons]
140
+ * @param {number} [props.duration]
141
+ * @param {"inverted" | "system"} [props.appearance]
142
+ * @returns {import("react").ReactElement | null}
143
+ */
144
+ export function NativeToast({ message, icon, icons, duration = 4, appearance = "inverted" }) {
145
+ if (!message) return null
146
+ /** @type {Record<string, any>} */
147
+ const props = {
148
+ "data-native-toast": "",
149
+ "data-native-toast-message": message,
150
+ "data-native-toast-duration": duration,
151
+ "data-native-toast-appearance": appearance,
152
+ hidden: true
153
+ }
154
+ // An absent icon attribute means "use the default" to the shell (the JS API
155
+ // omits it), so `icon={false}` emits an empty value to mean "none".
156
+ if (icon === false) {
157
+ props["data-native-toast-icon"] = ""
158
+ } else {
159
+ const fallback = rubyNativePlatform() === "android" ? "check_circle" : "checkmark.circle.fill"
160
+ props["data-native-toast-icon"] = resolveIcon(icon, icons) || fallback
161
+ }
162
+ return createElement("div", props)
163
+ }
164
+
120
165
  /**
121
166
  * @param {object} props
122
167
  * @param {string} [props.title]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruby-native/react",
3
- "version": "0.11.2",
3
+ "version": "0.12.1",
4
4
  "description": "React components for Ruby Native",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",