@dcs-tech/ui-native 0.18.0 → 0.20.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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @dcs-tech/ui-native
2
2
 
3
+ ## 0.20.0
4
+
5
+ ### Patch Changes
6
+
7
+ - @dcs-tech/tokens@0.20.0
8
+ - @dcs-tech/core@0.20.0
9
+
10
+ ## 0.19.0
11
+
12
+ ### Minor Changes
13
+
14
+ - 0d8cc3f: Toast: the web toast's new look and options on React Native. The type now shows as its icon in a tinted disc on a plain, rounder card with a softer shadow (the coloured rail is gone), and a toast comes in from the edge it sits at. New options `description` (a quieter second line; the message reads as its title) and `action` (one button such as Undo or Retry; pressing it closes the toast unless `keepOpen`), a new type `loading` (a spinner that stays until updated) and two calls, `loading(message)` and `promise(promise, { loading, success, error })`, which takes one toast through a promise and is not brought back if dismissed while it runs. A screen reader reads the title and description together. New types `ToastAction` and `ToastPromiseMessages`.
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [0d8cc3f]
19
+ - Updated dependencies [47d120f]
20
+ - @dcs-tech/core@0.19.0
21
+ - @dcs-tech/tokens@0.19.0
22
+
3
23
  ## 0.18.0
4
24
 
5
25
  ### Patch Changes
package/README.md CHANGED
@@ -55,7 +55,7 @@ import { Button, IconAdd, UIProvider } from '@dcs-tech/ui-native';
55
55
  | `Dialog` | A dialog, or a sheet from any edge, over a dimmed screen: title, subtitle, a scrolling body, a footer of actions. |
56
56
  | `useDialog()`, `DialogHost` | Ask and wait: `confirm`, `choose`, `alert`, as on the web. UIProvider hosts them. |
57
57
  | `useDialogOpen()` | Whether a library dialog is open, for an app's own overlay to step aside. |
58
- | `useToast()`, `ToastHost`, `ToastItem` | Toasts: `toast`, `success`, `error`, `warning`, `info`, `update`, `dismiss`, as on the web. UIProvider hosts them; while a Dialog is open they are drawn in it. |
58
+ | `useToast()`, `ToastHost`, `ToastItem` | Toasts: `toast`, `success`, `error`, `warning`, `info`, `loading`, `promise`, `update`, `dismiss`, as on the web. UIProvider hosts them; while a Dialog is open they are drawn in it. |
59
59
  | `DataTableScrollView` | A ScrollView for the screen a DataTable sits in: a drag to select holds it still and scrolls it at its edges. |
60
60
  | `DataTable` | The web DataTable's `views` / `columns` config on a phone: the views as tabs, a search, a sort, the rows as cards or a split list, a pager, and a row opening in a sheet (beside the list in a wide split view); from `data`, or from a `dataSource` with the web's query. |
61
61
 
@@ -150,10 +150,10 @@ A prop marked **same** takes the same values and does the same thing as on `@dcs
150
150
 
151
151
  | | Props |
152
152
  |---|---|
153
- | Same | `useToast()` and its calls; the options `type`, `autoClose` (or `false`), `position`, `hideProgressBar`, `closeOnClick`, `pauseOnFocusLoss` (the app in the background), `draggable` (swipe sideways), `closeButton`, `icon`, `id` (updates in place), `onClose`; UIProvider's `toast` defaults with `newestOnTop` and `limit` |
154
- | Adapted | A finger on a toast pauses it, where the web pauses on hover (`pauseOnHover`). `style` is a view style; `testID` as well. Below 600 wide a toast takes the width. The toasts are drawn over the view UIProvider sits in, clear of the system bars (those an app's `SafeAreaProvider` measured, else the window's at start); while a library Dialog is open, in the topmost one, as the web draws them in the topmost modal. An update (`update`, or the same `id`) starts its time again; moving into or out of a dialog does not. Letting go after holding a toast is not a tap. |
155
- | Not yet | Over Select's sheet (its own window): a toast fired while it is open shows when it closes |
156
- | Web only | `pauseOnHover`, `className` |
153
+ | Same | `useToast()` and its calls, `loading` and `promise` included (a result after the toast was dismissed does not bring it back); the options `type` (`loading` a spinner, sticky until updated), `description` (a quieter second line under the message, which reads as its title), `action` (one button; a press runs it and closes the toast unless `keepOpen`), `autoClose` (or `false`), `position`, `hideProgressBar`, `closeOnClick`, `pauseOnFocusLoss` (the app in the background), `draggable` (swipe sideways), `closeButton`, `icon`, `id` (updates in place), `onClose`; UIProvider's `toast` defaults with `newestOnTop` and `limit` |
154
+ | Adapted | A finger on a toast pauses it, where the web pauses on hover (`pauseOnHover`). `style` is a view style; `testID` as well. Below 600 wide a toast takes the width. The toasts are drawn over the view UIProvider sits in, clear of the system bars (those an app's `SafeAreaProvider` measured, else the window's at start); while a library Dialog is open, in the topmost one, as the web draws them in the topmost modal. An update (`update`, or the same `id`) starts its time again; moving into or out of a dialog does not. Letting go after holding a toast is not a tap. The action's `onClick` gets the press event. A screen reader reads the title and description together. |
155
+ | Not yet | Over Select's sheet (its own window): a toast fired while it is open shows when it closes. The toasts after a leaving one slide into its place on the web; here they move up at once. The web's deck (`stack`): here the toasts are always a list |
156
+ | Web only | `pauseOnHover`, `className`, Escape closing the toast in focus |
157
157
 
158
158
  **DataTable**
159
159
 
@@ -31,7 +31,7 @@ export function ToastHost({ defaults = {}, children }) {
31
31
  setToasts(prev => (id === undefined ? [] : prev.filter(x => x.id !== id)));
32
32
  }, [memory]);
33
33
  const restKey = JSON.stringify(restDefaults);
34
- const push = useCallback((message, opts = {}) => {
34
+ const push = useCallback((message, opts = {}, onlyIfActive = false) => {
35
35
  const id = opts.id ?? nextId();
36
36
  const record = {
37
37
  position: defaultPosition,
@@ -44,7 +44,7 @@ export function ToastHost({ defaults = {}, children }) {
44
44
  setToasts(prev => {
45
45
  const at = prev.findIndex(x => x.id === id);
46
46
  if (at < 0)
47
- return [...prev, record];
47
+ return onlyIfActive ? prev : [...prev, record];
48
48
  const next = [...prev];
49
49
  next[at] = record;
50
50
  return next;
@@ -57,6 +57,14 @@ export function ToastHost({ defaults = {}, children }) {
57
57
  error: (m, o) => push(m, { ...o, type: 'error' }),
58
58
  warning: (m, o) => push(m, { ...o, type: 'warning' }),
59
59
  info: (m, o) => push(m, { ...o, type: 'info' }),
60
+ loading: (m, o) => push(m, { autoClose: false, closeOnClick: false, ...o, type: 'loading' }),
61
+ promise: (p, messages, o) => {
62
+ const id = push(messages.loading, { autoClose: false, closeOnClick: false, ...o, type: 'loading' });
63
+ const run = typeof p === 'function' ? p() : p;
64
+ const say = (m, v) => (typeof m === 'function' ? m(v) : m);
65
+ run.then(value => { push(say(messages.success, value), { ...o, id, type: 'success' }, true); }, error => { push(say(messages.error, error), { ...o, id, type: 'error' }, true); });
66
+ return run;
67
+ },
60
68
  update: (id, m, o) => { push(m, { ...o, id }); },
61
69
  dismiss,
62
70
  isActive: id => toasts.some(x => x.id === id),
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
- import { AccessibilityInfo, Animated, Easing, PanResponder, Pressable, Text, View } from 'react-native';
3
+ import { AccessibilityInfo, ActivityIndicator, Animated, Easing, PanResponder, Pressable, Text, View } from 'react-native';
4
4
  import { useTokens, useUILabels } from '../UIProvider/context';
5
5
  import { IconSlotContext } from '../Icon/IconContext';
6
6
  import { IconClose, IconError, IconInfo, IconSuccess, IconWarning } from '../Icon/icons';
@@ -18,7 +18,7 @@ const ease = Easing.bezier(CSS_EASE.x1, CSS_EASE.y1, CSS_EASE.x2, CSS_EASE.y2);
18
18
  export function ToastItem({ toast, active, onDismiss, narrow, memory }) {
19
19
  const t = useTokens();
20
20
  const words = useUILabels();
21
- const { id, type = 'default', message, autoClose = 5000, hideProgressBar = false, closeOnClick = true, pauseOnFocusLoss = true, draggable = true, closeButton = true, icon, style, testID, } = toast;
21
+ const { id, type = 'default', message, autoClose = 5000, hideProgressBar = false, closeOnClick = true, pauseOnFocusLoss = true, draggable = true, closeButton = true, icon, style, testID, description, action, position, } = toast;
22
22
  const look = toastLook(t, type, narrow);
23
23
  const reduced = t.motionScale === 0;
24
24
  const [held, setHeld] = useState(false);
@@ -35,6 +35,8 @@ export function ToastItem({ toast, active, onDismiss, narrow, memory }) {
35
35
  const startedAt = useRef(0);
36
36
  const keep = (since = null) => memory?.set(id, { left: remaining.current, since });
37
37
  const paused = held || dragging || (pauseOnFocusLoss && !active);
38
+ const said = (n) => (typeof n === 'string' || typeof n === 'number' ? String(n) : '');
39
+ const spoken = [said(message), said(description)].filter(Boolean).join('. ');
38
40
  const close = useCallback(() => {
39
41
  if (leaving)
40
42
  return;
@@ -48,8 +50,8 @@ export function ToastItem({ toast, active, onDismiss, narrow, memory }) {
48
50
  if (kept !== undefined)
49
51
  return;
50
52
  Animated.timing(enter, { toValue: 1, duration: t.transitionBase * t.motionScale, easing: ease, useNativeDriver: true }).start();
51
- if (typeof message === 'string')
52
- AccessibilityInfo.announceForAccessibility(message);
53
+ if (spoken)
54
+ AccessibilityInfo.announceForAccessibility(spoken);
53
55
  }, []);
54
56
  const shownAs = useRef({ message, autoClose });
55
57
  useEffect(() => {
@@ -59,6 +61,8 @@ export function ToastItem({ toast, active, onDismiss, narrow, memory }) {
59
61
  remaining.current = full;
60
62
  bar.setValue(1);
61
63
  keep();
64
+ if (spoken)
65
+ AccessibilityInfo.announceForAccessibility(spoken);
62
66
  }, [message, autoClose]);
63
67
  useEffect(() => {
64
68
  if (autoClose === false || leaving || paused)
@@ -96,7 +100,13 @@ export function ToastItem({ toast, active, onDismiss, narrow, memory }) {
96
100
  }), [draggable, drag, close]);
97
101
  const urgent = type === 'error' || type === 'warning';
98
102
  const Glyph = ICONS[type];
99
- const shownIcon = icon === false ? null : icon ?? (Glyph ? _jsx(Glyph, {}) : null);
103
+ const shownIcon = icon === false
104
+ ? null
105
+ : icon ?? (type === 'loading'
106
+ ? _jsx(ActivityIndicator, { size: "small", color: look.accent, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants" })
107
+ : Glyph ? _jsx(Glyph, {}) : null);
108
+ const asText = (n, st) => (typeof n === 'string' || typeof n === 'number' ? _jsx(Text, { style: st, children: n }) : n);
109
+ const fromBottom = position?.startsWith('bottom') ?? false;
100
110
  const fade = drag.interpolate({ inputRange: [-TOAST_SWIPE_FADE, 0, TOAST_SWIPE_FADE], outputRange: [0, 1, 0], extrapolate: 'clamp' });
101
111
  return (_jsxs(Animated.View, { testID: testID, role: urgent ? 'alert' : 'status', accessibilityLiveRegion: urgent ? 'assertive' : 'polite', style: [
102
112
  look.toast,
@@ -105,11 +115,15 @@ export function ToastItem({ toast, active, onDismiss, narrow, memory }) {
105
115
  opacity: Animated.multiply(Animated.multiply(enter, exit), fade),
106
116
  transform: [
107
117
  { translateX: drag },
108
- { translateY: enter.interpolate({ inputRange: [0, 1], outputRange: [-TOAST_ENTER_OFFSET, 0] }) },
118
+ { translateY: enter.interpolate({ inputRange: [0, 1], outputRange: [fromBottom ? TOAST_ENTER_OFFSET : -TOAST_ENTER_OFFSET, 0] }) },
109
119
  { scale: enter.interpolate({ inputRange: [0, 1], outputRange: [TOAST_MOTION_SCALE, 1] }) },
110
120
  { scale: exit.interpolate({ inputRange: [0, 1], outputRange: [TOAST_MOTION_SCALE, 1] }) },
111
121
  ],
112
122
  },
113
- ], ...pan.panHandlers, children: [_jsx(View, { style: look.rail }), _jsxs(Pressable, { accessible: false, style: { flex: 1, flexDirection: 'row', alignItems: 'flex-start', gap: t.spacingMd }, onPress: closeOnClick ? close : undefined, onLongPress: () => { }, onPressIn: () => setHeld(true), onPressOut: () => setHeld(false), children: [shownIcon && (_jsx(View, { style: look.icon, children: _jsx(IconSlotContext.Provider, { value: { size: look.iconSize, color: look.accent }, children: shownIcon }) })), _jsx(View, { style: look.body, children: typeof message === 'string' || typeof message === 'number' ? _jsx(Text, { style: look.text, children: message }) : message })] }), closeButton !== false && (_jsx(Pressable, { role: "button", "aria-label": words.toast.dismiss, onPress: close, onPressIn: () => setHeld(true), onPressOut: () => setHeld(false), style: ({ pressed }) => [look.close, pressed && look.closePressed], children: ({ pressed }) => (_jsx(IconSlotContext.Provider, { value: { size: look.closeIconSize, color: pressed ? look.closePressedColor : look.closeColor }, children: closeButton === true ? _jsx(IconClose, {}) : closeButton })) })), !hideProgressBar && typeof autoClose === 'number' && !leaving && (_jsx(Animated.View, { testID: testID ? `${testID}-progress` : undefined, style: [look.progress, { transform: [{ scaleX: bar }] }] }))] }));
123
+ ], ...pan.panHandlers, children: [_jsxs(Pressable, { accessible: false, style: { flex: 1, flexDirection: 'row', alignItems: 'flex-start', gap: t.spacingLg }, onPress: closeOnClick ? close : undefined, onLongPress: () => { }, onPressIn: () => setHeld(true), onPressOut: () => setHeld(false), children: [shownIcon && (_jsx(View, { style: look.icon, children: _jsx(IconSlotContext.Provider, { value: { size: look.iconSize, color: look.accent }, children: shownIcon }) })), _jsxs(View, { style: look.body, accessible: spoken ? true : undefined, accessibilityLabel: spoken || undefined, children: [asText(message, description ? look.title : look.text), description ? asText(description, look.description) : null] })] }), action && (_jsx(Pressable, { role: "button", "aria-label": typeof action.label === 'string' ? action.label : undefined, onPress: e => {
124
+ action.onClick(e);
125
+ if (!action.keepOpen)
126
+ close();
127
+ }, onPressIn: () => setHeld(true), onPressOut: () => setHeld(false), style: ({ pressed }) => [look.action, pressed && look.actionPressed], children: asText(action.label, look.actionText) })), closeButton !== false && (_jsx(Pressable, { role: "button", "aria-label": words.toast.dismiss, onPress: close, onPressIn: () => setHeld(true), onPressOut: () => setHeld(false), style: ({ pressed }) => [look.close, pressed && look.closePressed], children: ({ pressed }) => (_jsx(IconSlotContext.Provider, { value: { size: look.closeIconSize, color: pressed ? look.closePressedColor : look.closeColor }, children: closeButton === true ? _jsx(IconClose, {}) : closeButton })) })), !hideProgressBar && typeof autoClose === 'number' && !leaving && (_jsx(Animated.View, { testID: testID ? `${testID}-progress` : undefined, style: [look.progress, { transform: [{ scaleX: bar }] }] }))] }));
114
128
  }
115
129
  ToastItem.displayName = 'ToastItem';
@@ -1,36 +1,77 @@
1
1
  import { boxShadow } from '../Button/buttonStyle';
2
- import { TOAST_ICON_NUDGE, TOAST_LINE_HEIGHT, TOAST_PROGRESS_HEIGHT, TOAST_PROGRESS_OPACITY, TOAST_RAIL_WIDTH, TOAST_WIDTH, } from '../styles/webValues';
2
+ import { TOAST_LINE_HEIGHT, TOAST_PROGRESS_HEIGHT, TOAST_PROGRESS_OPACITY, TOAST_WIDTH, } from '../styles/webValues';
3
+ const fw = (w) => String(w);
3
4
  export function toastAccent(t, type) {
4
5
  switch (type) {
5
- case 'success': return t.success;
6
- case 'error': return t.error;
7
- case 'warning': return t.warning;
8
- case 'info': return t.info;
6
+ case 'success': return t.success11;
7
+ case 'error': return t.error11;
8
+ case 'warning': return t.warning11;
9
+ case 'info': return t.info11;
9
10
  default: return t.textSecondary;
10
11
  }
11
12
  }
13
+ export function toastTint(t, type) {
14
+ switch (type) {
15
+ case 'success': return t.success3;
16
+ case 'error': return t.error3;
17
+ case 'warning': return t.warning3;
18
+ case 'info': return t.info3;
19
+ default: return t.neutral3;
20
+ }
21
+ }
12
22
  export function toastLook(t, type, narrow) {
13
23
  const accent = toastAccent(t, type);
24
+ const lineHeight = Math.round(t.fontSizeMd * TOAST_LINE_HEIGHT);
14
25
  return {
15
26
  toast: {
16
27
  flexDirection: 'row',
17
28
  alignItems: 'flex-start',
18
- gap: t.spacingMd,
29
+ gap: t.spacingLg,
19
30
  ...(narrow ? { alignSelf: 'stretch' } : { width: TOAST_WIDTH, maxWidth: '100%' }),
20
- padding: t.spacingLg,
21
- borderRadius: t.borderRadiusSm,
31
+ paddingTop: t.spacingLg,
32
+ paddingBottom: t.spacingLg,
33
+ paddingStart: t.spacingLg,
34
+ paddingEnd: t.spacingMd,
35
+ borderRadius: t.borderRadius,
22
36
  borderWidth: 1,
23
37
  borderColor: t.cardBorder,
24
38
  backgroundColor: t.cardBg,
25
- boxShadow: boxShadow(t.shadowLg),
39
+ boxShadow: boxShadow(t.shadowPopover),
26
40
  overflow: 'hidden',
27
41
  },
28
- rail: { position: 'absolute', top: 0, bottom: 0, left: 0, width: TOAST_RAIL_WIDTH, backgroundColor: accent },
29
- icon: { flexShrink: 0, alignItems: 'center', justifyContent: 'center', marginTop: TOAST_ICON_NUDGE },
42
+ icon: {
43
+ flexShrink: 0,
44
+ alignItems: 'center',
45
+ justifyContent: 'center',
46
+ width: t.fieldHeightXxs,
47
+ height: t.fieldHeightXxs,
48
+ borderRadius: t.borderRadiusFull,
49
+ backgroundColor: toastTint(t, type),
50
+ },
30
51
  iconSize: t.iconSlotDefault,
31
52
  accent,
32
- body: { flex: 1, minWidth: 0 },
33
- text: { color: t.textPrimary, fontSize: t.fontSizeMd, lineHeight: Math.round(t.fontSizeMd * TOAST_LINE_HEIGHT) },
53
+ body: { flex: 1, minWidth: 0, paddingVertical: Math.max(0, (t.fieldHeightXxs - lineHeight) / 2) },
54
+ text: { color: t.textPrimary, fontSize: t.fontSizeMd, lineHeight },
55
+ title: { color: t.textPrimary, fontSize: t.fontSizeMd, lineHeight, fontWeight: fw(t.fontWeightSemibold) },
56
+ description: {
57
+ marginTop: t.spacingXs,
58
+ color: t.textSecondary,
59
+ fontSize: t.fontSizeSm,
60
+ lineHeight: Math.round(t.fontSizeSm * TOAST_LINE_HEIGHT),
61
+ },
62
+ action: {
63
+ flexShrink: 0,
64
+ alignSelf: 'center',
65
+ minHeight: t.fieldHeightXxs,
66
+ paddingHorizontal: t.spacingMd,
67
+ borderWidth: 1,
68
+ borderColor: t.borderColor,
69
+ borderRadius: t.borderRadiusSm,
70
+ alignItems: 'center',
71
+ justifyContent: 'center',
72
+ },
73
+ actionPressed: { backgroundColor: t.bgTertiary },
74
+ actionText: { color: t.textPrimary, fontSize: t.fontSizeSm, fontWeight: fw(t.fontWeightSemibold) },
34
75
  close: {
35
76
  flexShrink: 0,
36
77
  width: t.fieldHeightXxs,
@@ -62,19 +62,17 @@ export const DT_ACTIVE_EDGE_MIX = 30;
62
62
  export const MENU_RAIL_ITEM_MIN_WIDTH = 64;
63
63
  export const MENU_RAIL_DISABLED_OPACITY = 0.4;
64
64
  export const DT_SPLIT_ACTIONS_TUCK = 6;
65
- export const TOAST_WIDTH = 340;
65
+ export const TOAST_WIDTH = 360;
66
66
  export const TOAST_NARROW_BELOW = 600;
67
- export const TOAST_RAIL_WIDTH = 3;
68
67
  export const TOAST_LINE_HEIGHT = 1.45;
69
68
  export const TOAST_PROGRESS_HEIGHT = 2;
70
- export const TOAST_PROGRESS_OPACITY = 0.55;
69
+ export const TOAST_PROGRESS_OPACITY = 0.4;
71
70
  export const TOAST_ENTER_OFFSET = 8;
72
- export const TOAST_MOTION_SCALE = 0.98;
71
+ export const TOAST_MOTION_SCALE = 0.96;
73
72
  export const CSS_EASE = { x1: 0.25, y1: 0.1, x2: 0.25, y2: 1 };
74
73
  export const TOAST_EXIT_MS = 200;
75
74
  export const TOAST_SWIPE_DISMISS = 110;
76
75
  export const TOAST_SWIPE_FADE = 220;
77
- export const TOAST_ICON_NUDGE = 1;
78
76
  export const DT_CARD_CHECK_BOX = 32;
79
77
  export const DT_CARD_CHECK_TOP = 12;
80
78
  export const DT_CARD_CHECK_LEFT = 8;
@@ -2,4 +2,4 @@ export { ToastHost, useToast } from './ToastHost';
2
2
  export type { ToastHostProps } from './ToastHost';
3
3
  export { ToastItem } from './ToastItem';
4
4
  export type { ToastItemProps } from './ToastItem';
5
- export type { ToastApi, ToastDefaults, ToastOptions, ToastPosition, ToastRecord, ToastType, } from './toast.types';
5
+ export type { ToastAction, ToastApi, ToastDefaults, ToastOptions, ToastPosition, ToastPromiseMessages, ToastRecord, ToastType, } from './toast.types';
@@ -1,9 +1,16 @@
1
1
  import type React from 'react';
2
- import type { StyleProp, ViewStyle } from 'react-native';
3
- export type ToastType = 'default' | 'success' | 'error' | 'warning' | 'info';
2
+ import type { GestureResponderEvent, StyleProp, ViewStyle } from 'react-native';
3
+ export type ToastType = 'default' | 'success' | 'error' | 'warning' | 'info' | 'loading';
4
+ export interface ToastAction {
5
+ label: React.ReactNode;
6
+ onClick: (event: GestureResponderEvent) => void;
7
+ keepOpen?: boolean;
8
+ }
4
9
  export type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
5
10
  export interface ToastOptions {
6
11
  type?: ToastType;
12
+ description?: React.ReactNode;
13
+ action?: ToastAction;
7
14
  autoClose?: number | false;
8
15
  position?: ToastPosition;
9
16
  hideProgressBar?: boolean;
@@ -31,7 +38,14 @@ export interface ToastApi {
31
38
  error: (message: React.ReactNode, opts?: ToastOptions) => string;
32
39
  warning: (message: React.ReactNode, opts?: ToastOptions) => string;
33
40
  info: (message: React.ReactNode, opts?: ToastOptions) => string;
41
+ loading: (message: React.ReactNode, opts?: ToastOptions) => string;
42
+ promise: <T>(promise: Promise<T> | (() => Promise<T>), messages: ToastPromiseMessages<T>, opts?: ToastOptions) => Promise<T>;
34
43
  update: (id: string, message: React.ReactNode, opts?: ToastOptions) => void;
35
44
  dismiss: (id?: string) => void;
36
45
  isActive: (id: string) => boolean;
37
46
  }
47
+ export interface ToastPromiseMessages<T> {
48
+ loading: React.ReactNode;
49
+ success: React.ReactNode | ((value: T) => React.ReactNode);
50
+ error: React.ReactNode | ((error: unknown) => React.ReactNode);
51
+ }
@@ -3,14 +3,19 @@ import type { Tokens } from '@dcs-tech/tokens';
3
3
  import type { EdgeInsets } from '../Dialog/dialogStyle';
4
4
  import type { ToastPosition, ToastType } from './toast.types';
5
5
  export declare function toastAccent(t: Tokens, type: ToastType): string;
6
+ export declare function toastTint(t: Tokens, type: ToastType): string;
6
7
  export interface ToastLook {
7
8
  toast: ViewStyle;
8
- rail: ViewStyle;
9
9
  icon: ViewStyle;
10
10
  iconSize: number;
11
11
  accent: string;
12
12
  body: ViewStyle;
13
13
  text: TextStyle;
14
+ title: TextStyle;
15
+ description: TextStyle;
16
+ action: ViewStyle;
17
+ actionPressed: ViewStyle;
18
+ actionText: TextStyle;
14
19
  close: ViewStyle;
15
20
  closePressed: ViewStyle;
16
21
  closeIconSize: number;
@@ -67,14 +67,13 @@ export declare const DT_ACTIVE_EDGE_MIX = 30;
67
67
  export declare const MENU_RAIL_ITEM_MIN_WIDTH = 64;
68
68
  export declare const MENU_RAIL_DISABLED_OPACITY = 0.4;
69
69
  export declare const DT_SPLIT_ACTIONS_TUCK = 6;
70
- export declare const TOAST_WIDTH = 340;
70
+ export declare const TOAST_WIDTH = 360;
71
71
  export declare const TOAST_NARROW_BELOW = 600;
72
- export declare const TOAST_RAIL_WIDTH = 3;
73
72
  export declare const TOAST_LINE_HEIGHT = 1.45;
74
73
  export declare const TOAST_PROGRESS_HEIGHT = 2;
75
- export declare const TOAST_PROGRESS_OPACITY = 0.55;
74
+ export declare const TOAST_PROGRESS_OPACITY = 0.4;
76
75
  export declare const TOAST_ENTER_OFFSET = 8;
77
- export declare const TOAST_MOTION_SCALE = 0.98;
76
+ export declare const TOAST_MOTION_SCALE = 0.96;
78
77
  export declare const CSS_EASE: {
79
78
  readonly x1: 0.25;
80
79
  readonly y1: 0.1;
@@ -84,7 +83,6 @@ export declare const CSS_EASE: {
84
83
  export declare const TOAST_EXIT_MS = 200;
85
84
  export declare const TOAST_SWIPE_DISMISS = 110;
86
85
  export declare const TOAST_SWIPE_FADE = 220;
87
- export declare const TOAST_ICON_NUDGE = 1;
88
86
  export declare const DT_CARD_CHECK_BOX = 32;
89
87
  export declare const DT_CARD_CHECK_TOP = 12;
90
88
  export declare const DT_CARD_CHECK_LEFT = 8;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcs-tech/ui-native",
3
- "version": "0.18.0",
3
+ "version": "0.20.0",
4
4
  "description": "React Native components of the DCS Tech UI library, on the same logic, icons and design tokens as @dcs-tech/ui.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -38,8 +38,8 @@
38
38
  "clean": "rm -rf dist"
39
39
  },
40
40
  "dependencies": {
41
- "@dcs-tech/core": "0.18.0",
42
- "@dcs-tech/tokens": "0.18.0"
41
+ "@dcs-tech/core": "0.20.0",
42
+ "@dcs-tech/tokens": "0.20.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "react": ">=19.3",