@mrmeg/expo-ui 0.7.3 → 0.8.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.
- package/LLM_USAGE.md +21 -11
- package/README.md +8 -10
- package/dist/components/Accordion.d.ts +4 -4
- package/dist/components/AnimatedView.d.ts +1 -1
- package/dist/components/Badge.d.ts +1 -1
- package/dist/components/BottomSheet.d.ts +7 -7
- package/dist/components/Button.d.ts +3 -3
- package/dist/components/Button.js +17 -1
- package/dist/components/Card.d.ts +6 -6
- package/dist/components/Checkbox.d.ts +2 -1
- package/dist/components/Collapsible.d.ts +4 -3
- package/dist/components/Dialog.d.ts +10 -10
- package/dist/components/DismissKeyboard.d.ts +1 -1
- package/dist/components/Drawer.d.ts +7 -7
- package/dist/components/DropdownMenu.d.ts +10 -10
- package/dist/components/EmptyState.d.ts +1 -1
- package/dist/components/ErrorBoundary.d.ts +1 -1
- package/dist/components/Icon.d.ts +1 -1
- package/dist/components/InputOTP.d.ts +2 -1
- package/dist/components/Label.d.ts +1 -1
- package/dist/components/MaxWidthContainer.d.ts +1 -1
- package/dist/components/Notification.d.ts +4 -10
- package/dist/components/Notification.js +12 -13
- package/dist/components/Popover.d.ts +4 -4
- package/dist/components/Progress.d.ts +2 -1
- package/dist/components/RadioGroup.d.ts +3 -2
- package/dist/components/SegmentedControl.d.ts +2 -1
- package/dist/components/Select.d.ts +7 -7
- package/dist/components/Separator.d.ts +2 -1
- package/dist/components/Skeleton.d.ts +5 -4
- package/dist/components/Slider.d.ts +2 -1
- package/dist/components/StatusBar.d.ts +1 -1
- package/dist/components/StyledText.d.ts +12 -12
- package/dist/components/Switch.d.ts +2 -1
- package/dist/components/Tabs.d.ts +5 -5
- package/dist/components/TextInput.d.ts +1 -1
- package/dist/components/TextInput.js +9 -1
- package/dist/components/Toggle.d.ts +3 -2
- package/dist/components/ToggleGroup.d.ts +4 -3
- package/dist/components/Tooltip.d.ts +3 -3
- package/dist/components/UIProvider.d.ts +1 -1
- package/dist/state/globalUIStore.d.ts +9 -1
- package/dist/state/globalUIStore.js +9 -1
- package/dist/state/index.d.ts +1 -0
- package/dist/state/index.js +1 -0
- package/dist/state/notify.d.ts +50 -0
- package/dist/state/notify.js +31 -0
- package/dist/state/themeColorScope.d.ts +1 -1
- package/llms-full.md +34 -3
- package/package.json +2 -2
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { globalUIStore } from "./globalUIStore.js";
|
|
2
|
+
const show = (alert) => globalUIStore.getState().show(alert);
|
|
3
|
+
const showType = (type) => (title, options) => show({ type, title, ...options });
|
|
4
|
+
export const notify = Object.assign(show, {
|
|
5
|
+
success: showType("success"),
|
|
6
|
+
error: showType("error"),
|
|
7
|
+
info: showType("info"),
|
|
8
|
+
warning: showType("warning"),
|
|
9
|
+
/** Persistent spinner notification; stays visible until replaced or hidden. */
|
|
10
|
+
loading: (title, options) => show({ type: "info", title, loading: true, ...options }),
|
|
11
|
+
/**
|
|
12
|
+
* Shows a loading notification while the promise is pending, then a
|
|
13
|
+
* success or error notification. Rethrows on rejection and returns the
|
|
14
|
+
* resolved value so it can wrap existing async flows transparently.
|
|
15
|
+
*/
|
|
16
|
+
promise: async (promise, messages) => {
|
|
17
|
+
notify.loading(messages.loading);
|
|
18
|
+
try {
|
|
19
|
+
const value = await promise;
|
|
20
|
+
const title = typeof messages.success === "function" ? messages.success(value) : messages.success;
|
|
21
|
+
notify.success(title);
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
const title = typeof messages.error === "function" ? messages.error(error) : messages.error;
|
|
26
|
+
notify.error(title);
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
hide: () => globalUIStore.getState().hide(),
|
|
31
|
+
});
|
package/llms-full.md
CHANGED
|
@@ -34,7 +34,7 @@ the root when the app uses package feedback or overlay components.
|
|
|
34
34
|
`UIProvider` owns the package `Notification`, `StatusBar`, and default
|
|
35
35
|
`@rn-primitives` portal host. Mount it before using `Dialog`, `AlertDialog`,
|
|
36
36
|
`BottomSheet`, `Drawer`, `DropdownMenu`, `Popover`, `SelectContent`,
|
|
37
|
-
`Tooltip`, or `globalUIStore` notifications.
|
|
37
|
+
`Tooltip`, or `notify` / `globalUIStore` notifications.
|
|
38
38
|
|
|
39
39
|
On native, `BottomSheet.Content` composes its sheet transform with React Native
|
|
40
40
|
keyboard event values. Pass `avoidKeyboard={false}` for sheets that should not
|
|
@@ -66,7 +66,7 @@ import { Button, StyledText, UIProvider } from "@mrmeg/expo-ui/components";
|
|
|
66
66
|
import { Button as ButtonDirect } from "@mrmeg/expo-ui/components/Button";
|
|
67
67
|
import { colors, spacing, typography } from "@mrmeg/expo-ui/constants";
|
|
68
68
|
import { useResources, useTheme } from "@mrmeg/expo-ui/hooks";
|
|
69
|
-
import { globalUIStore, useThemeStore } from "@mrmeg/expo-ui/state";
|
|
69
|
+
import { globalUIStore, notify, useThemeStore } from "@mrmeg/expo-ui/state";
|
|
70
70
|
import { configureExpoUiI18n, hapticLight } from "@mrmeg/expo-ui/lib";
|
|
71
71
|
```
|
|
72
72
|
|
|
@@ -101,7 +101,7 @@ Use this catalog before creating a new app-local primitive.
|
|
|
101
101
|
| `InputOTP` | `@mrmeg/expo-ui/components` | Verification code entry | Prefer over manually managed text input groups. |
|
|
102
102
|
| `Label` | `@mrmeg/expo-ui/components` | Accessible form labels | Use with package form controls. |
|
|
103
103
|
| `MaxWidthContainer` | `@mrmeg/expo-ui/components` | Centered responsive width | Use for web and tablet constrained layouts. |
|
|
104
|
-
| `Notification` | `@mrmeg/expo-ui/components` | Global toast surface | Trigger through `globalUIStore` with root `UIProvider`; optional actions dismiss after press. |
|
|
104
|
+
| `Notification` | `@mrmeg/expo-ui/components` | Global toast surface | Trigger through `notify` (or `globalUIStore` for subscriptions/tests) with root `UIProvider`; optional actions dismiss after press. |
|
|
105
105
|
| `Popover` | `@mrmeg/expo-ui/components` | Anchored contextual content | Requires root `UIProvider` portal setup. |
|
|
106
106
|
| `Progress` | `@mrmeg/expo-ui/components` | Determinate or indeterminate progress | Prefer over layout-shifting spinners for progress regions. |
|
|
107
107
|
| `RadioGroup` | `@mrmeg/expo-ui/components` | Small mutually exclusive choices | Use `Select` for longer option sets. |
|
|
@@ -134,6 +134,37 @@ full page sections. Use `EmptyState` for no-data or recoverable error regions,
|
|
|
134
134
|
`Skeleton` for loading content with stable layout, and `Progress` for real
|
|
135
135
|
progress or indeterminate long-running work.
|
|
136
136
|
|
|
137
|
+
## Notifications
|
|
138
|
+
|
|
139
|
+
`notify` is the primary imperative API for triggering the `Notification` component. Import from `@mrmeg/expo-ui/state` (also re-exported from the package root).
|
|
140
|
+
|
|
141
|
+
Notifications auto-dismiss after 4s (`DEFAULT_NOTIFICATION_DURATION`) unless a `duration` is given; pass `duration: 0` to keep one up until dismissed. `notify.loading` never auto-dismisses.
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
import { notify } from "@mrmeg/expo-ui/state";
|
|
145
|
+
|
|
146
|
+
notify.success("Saved", { messages: ["Your changes were saved."] });
|
|
147
|
+
notify.error("Upload failed");
|
|
148
|
+
notify.warning("Connection slow");
|
|
149
|
+
notify.info("Copied to clipboard");
|
|
150
|
+
|
|
151
|
+
// Loading spinner — persists until replaced or hidden (no auto-dismiss)
|
|
152
|
+
notify.loading("Uploading…");
|
|
153
|
+
notify.hide();
|
|
154
|
+
|
|
155
|
+
// Full control (same payload as globalUIStore show())
|
|
156
|
+
notify({ type: "success", title: "Saved", duration: 3000, position: "bottom" });
|
|
157
|
+
|
|
158
|
+
// Loading → success/error around a promise; rethrows on rejection
|
|
159
|
+
await notify.promise(saveProfile(), {
|
|
160
|
+
loading: "Saving…",
|
|
161
|
+
success: "Profile saved", // or (value) => `Saved ${value.name}`
|
|
162
|
+
error: "Could not save profile", // or (err) => err.message
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
`globalUIStore` (the underlying zustand store) remains available for reactive selectors and tests. Use `notify` for all imperative triggers in app code.
|
|
167
|
+
|
|
137
168
|
## Validation
|
|
138
169
|
|
|
139
170
|
Run the UI package gates when changing package code or shipped docs:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrmeg/expo-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Reusable Expo and React Native UI primitives for MrMeg projects.",
|
|
6
6
|
"keywords": [
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"zustand": ">=5.0.0 <6.0.0"
|
|
123
123
|
},
|
|
124
124
|
"devDependencies": {
|
|
125
|
-
"@types/react": "~19.2.
|
|
125
|
+
"@types/react": "~19.2.17",
|
|
126
126
|
"typescript": "~6.0.3"
|
|
127
127
|
}
|
|
128
128
|
}
|