@expressive-ui/native 0.1.1 → 0.2.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 (57) hide show
  1. package/README.md +10 -0
  2. package/dist/AppBar.d.ts +18 -0
  3. package/dist/AppBar.d.ts.map +1 -0
  4. package/dist/AppBar.js +15 -0
  5. package/dist/AppBar.js.map +1 -0
  6. package/dist/Divider.d.ts +10 -0
  7. package/dist/Divider.d.ts.map +1 -0
  8. package/dist/Divider.js +10 -0
  9. package/dist/Divider.js.map +1 -0
  10. package/dist/Feedback.d.ts +42 -0
  11. package/dist/Feedback.d.ts.map +1 -0
  12. package/dist/Feedback.js +26 -0
  13. package/dist/Feedback.js.map +1 -0
  14. package/dist/FileUpload.d.ts +13 -0
  15. package/dist/FileUpload.d.ts.map +1 -0
  16. package/dist/FileUpload.js +29 -0
  17. package/dist/FileUpload.js.map +1 -0
  18. package/dist/NumberField.d.ts +18 -0
  19. package/dist/NumberField.d.ts.map +1 -0
  20. package/dist/NumberField.js +20 -0
  21. package/dist/NumberField.js.map +1 -0
  22. package/dist/Pickers.d.ts +2 -0
  23. package/dist/Pickers.d.ts.map +1 -1
  24. package/dist/Pickers.js +19 -16
  25. package/dist/Pickers.js.map +1 -1
  26. package/dist/RangeSlider.d.ts +11 -0
  27. package/dist/RangeSlider.d.ts.map +1 -0
  28. package/dist/RangeSlider.js +63 -0
  29. package/dist/RangeSlider.js.map +1 -0
  30. package/dist/Select.d.ts +31 -0
  31. package/dist/Select.d.ts.map +1 -0
  32. package/dist/Select.js +22 -0
  33. package/dist/Select.js.map +1 -0
  34. package/dist/Snackbar.d.ts +17 -0
  35. package/dist/Snackbar.d.ts.map +1 -0
  36. package/dist/Snackbar.js +36 -0
  37. package/dist/Snackbar.js.map +1 -0
  38. package/dist/Toolbar.d.ts +5 -2
  39. package/dist/Toolbar.d.ts.map +1 -1
  40. package/dist/Toolbar.js +10 -6
  41. package/dist/Toolbar.js.map +1 -1
  42. package/dist/index.d.ts +8 -0
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +8 -0
  45. package/dist/index.js.map +1 -1
  46. package/package.json +4 -4
  47. package/src/AppBar.tsx +30 -0
  48. package/src/Divider.tsx +9 -0
  49. package/src/Feedback.tsx +23 -0
  50. package/src/FileUpload.tsx +16 -0
  51. package/src/NumberField.tsx +13 -0
  52. package/src/Pickers.tsx +10 -9
  53. package/src/RangeSlider.tsx +65 -0
  54. package/src/Select.tsx +36 -0
  55. package/src/Snackbar.tsx +35 -0
  56. package/src/Toolbar.tsx +16 -9
  57. package/src/index.ts +10 -0
@@ -0,0 +1,63 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import { PanResponder, View } from 'react-native';
4
+ import { moveSliderThumb, resolveSlider, sliderStops, useRangeSlider, valueRatio } from '@expressive-ui/core';
5
+ import { T, withAlpha } from './primitives.js';
6
+ import { useExpressiveTheme } from './theme.js';
7
+ export function RangeSlider({ value, min = 0, max = 100, step = 1, onChange, onPreview, label, thumbLabels, size = 'sm', stops = false, format = String, showValue = true, disabled = false, style }) {
8
+ const { colors, locale } = useExpressiveTheme();
9
+ const labels = thumbLabels ?? (locale.startsWith('pt') ? ['Mínimo', 'Máximo'] : ['Minimum', 'Maximum']);
10
+ const [width, setWidth] = useState(0);
11
+ const state = useRangeSlider({ value, min, max, step, onChange, onPreview });
12
+ const surface = useRef(null);
13
+ const start = useRef({ page: 0, local: 0 });
14
+ const gesture = useRef({ id: 0, ready: false, ended: false, cancelled: false, page: 0 });
15
+ const latest = useRef({ state, width, min, max, disabled });
16
+ latest.current = { state, width, min, max, disabled };
17
+ const spec = resolveSlider({ size, disabled });
18
+ const at = (pageX) => { const p = latest.current; return p.min + Math.max(0, Math.min(1, (start.current.local + pageX - start.current.page) / Math.max(1, p.width))) * (p.max - p.min); };
19
+ const responder = useRef(PanResponder.create({
20
+ onStartShouldSetPanResponder: () => !latest.current.disabled,
21
+ onMoveShouldSetPanResponder: () => !latest.current.disabled,
22
+ onPanResponderTerminationRequest: () => false,
23
+ onPanResponderGrant: event => {
24
+ // measure() yields page coordinates even when the touch lands on a child handle.
25
+ const page = event.nativeEvent.pageX;
26
+ const session = { id: gesture.current.id + 1, ready: false, ended: false, cancelled: false, page };
27
+ gesture.current = session;
28
+ surface.current?.measure((_x, _y, _w, _h, pageX) => {
29
+ if (latest.current.disabled || session.cancelled || gesture.current !== session)
30
+ return;
31
+ start.current = { page, local: page - pageX };
32
+ const next = at(page), p = latest.current;
33
+ const thumb = Math.abs(next - p.state.shown[0]) < Math.abs(next - p.state.shown[1]) ? 0 : 1;
34
+ p.state.begin(thumb);
35
+ session.ready = true;
36
+ p.state.move(at(session.page));
37
+ if (session.ended)
38
+ p.state.commit();
39
+ });
40
+ },
41
+ onPanResponderMove: event => { gesture.current.page = event.nativeEvent.pageX; if (gesture.current.ready)
42
+ latest.current.state.move(at(event.nativeEvent.pageX)); },
43
+ onPanResponderRelease: event => { gesture.current.ended = true; gesture.current.page = event.nativeEvent.pageX; if (gesture.current.ready) {
44
+ latest.current.state.move(at(event.nativeEvent.pageX));
45
+ latest.current.state.commit();
46
+ } },
47
+ onPanResponderTerminate: () => { gesture.current.cancelled = true; latest.current.state.cancel(); },
48
+ })).current;
49
+ useEffect(() => { if (disabled) {
50
+ gesture.current.cancelled = true;
51
+ latest.current.state.cancel();
52
+ } }, [disabled]);
53
+ const positions = [valueRatio(state.shown[0], min, max), valueRatio(state.shown[1], min, max)];
54
+ return _jsx(View, { accessibilityLabel: label, style: [{ height: Math.max(48, spec.handleHeight), opacity: spec.disabledOpacity }, style], children: _jsxs(View, { ref: surface, collapsable: false, onLayout: event => setWidth(event.nativeEvent.layout.width), ...responder.panHandlers, style: { flex: 1 }, children: [_jsxs(View, { pointerEvents: "none", style: { position: 'absolute', left: 0, right: 0, top: (spec.handleHeight - spec.track) / 2, height: spec.track, borderRadius: spec.radius.outer, backgroundColor: withAlpha(colors[spec.inactive], disabled ? .12 : 1) }, children: [_jsx(View, { style: { position: 'absolute', left: positions[0] * width, width: Math.max(0, (positions[1] - positions[0]) * width), height: spec.track, borderRadius: spec.radius.inner, backgroundColor: colors[spec.active] } }), stops ? sliderStops(min, max, step).map(s => _jsx(View, { style: { position: 'absolute', left: s * width - 2, top: spec.track / 2 - 2, width: 4, height: 4, borderRadius: 2, backgroundColor: colors[s >= positions[0] && s <= positions[1] ? spec.stopOnActive : spec.stopOnInactive] } }, s)) : null] }), [0, 1].map(thumb => _jsxs(View, { accessible: true, accessibilityRole: "adjustable", accessibilityLabel: `${label}: ${labels[thumb]}`, accessibilityState: { disabled }, accessibilityValue: { min: thumb === 0 ? min : state.shown[0], max: thumb === 0 ? state.shown[1] : max, now: state.shown[thumb], text: format(state.shown[thumb]) }, accessibilityActions: [{ name: 'increment' }, { name: 'decrement' }], onAccessibilityAction: event => {
55
+ if (disabled)
56
+ return;
57
+ const action = event.nativeEvent.actionName;
58
+ if (action !== 'increment' && action !== 'decrement')
59
+ return;
60
+ onChange?.(moveSliderThumb(state.shown, thumb, state.shown[thumb] + (action === 'increment' ? step : -step), min, max, step));
61
+ }, style: { position: 'absolute', left: Math.max(0, Math.min(Math.max(0, width - 48), positions[thumb] * width - 24)), width: 48, height: spec.handleHeight, alignItems: 'center' }, children: [_jsx(View, { pointerEvents: "none", style: { position: 'absolute', left: positions[thumb] * width - spec.gap - Math.max(0, Math.min(Math.max(0, width - 48), positions[thumb] * width - 24)) - 2, width: 4, height: spec.handleHeight, borderRadius: 2, backgroundColor: colors[spec.active], borderWidth: spec.gap, borderColor: colors.surface, boxSizing: 'content-box' } }), showValue && state.dragging ? _jsx(View, { pointerEvents: "none", style: { position: 'absolute', bottom: spec.handleHeight + 4, paddingHorizontal: 12, paddingVertical: 8, borderRadius: 24, backgroundColor: colors.inverseSurface }, children: _jsx(T, { variant: "labelLarge", color: "inverseOnSurface", children: format(state.shown[thumb]) }) }) : null] }, thumb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"}
@@ -0,0 +1,31 @@
1
+ import { type StyleProp, type ViewStyle } from 'react-native';
2
+ import { type SelectOption, type OptionLoader } from '@expressive-ui/core';
3
+ export type { SelectOption, OptionLoader } from '@expressive-ui/core';
4
+ export type SelectProps = {
5
+ label: string;
6
+ options: readonly SelectOption[];
7
+ value?: string;
8
+ defaultValue?: string;
9
+ onChange?: (value: string, option: SelectOption) => void;
10
+ variant?: 'filled' | 'outlined';
11
+ placeholder?: string;
12
+ supportingText?: string;
13
+ error?: string | boolean;
14
+ required?: boolean;
15
+ disabled?: boolean;
16
+ leadingIcon?: string;
17
+ maxHeight?: number;
18
+ style?: StyleProp<ViewStyle>;
19
+ };
20
+ export type AutocompleteProps = SelectProps & {
21
+ loadOptions?: OptionLoader;
22
+ onQueryChange?: (query: string) => void;
23
+ debounce?: number;
24
+ emptyText?: string;
25
+ loadingText?: string;
26
+ loadErrorText?: string;
27
+ };
28
+ export declare function Select(props: SelectProps): import("react").JSX.Element;
29
+ export declare function Autocomplete(props: AutocompleteProps): import("react").JSX.Element;
30
+ export declare const Combobox: typeof Autocomplete;
31
+ //# sourceMappingURL=Select.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../src/Select.tsx"],"names":[],"mappings":"AACA,OAAO,EAA+B,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAmB,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAM5F,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACtE,MAAM,MAAM,WAAW,GAAG;IAAE,KAAK,EAAC,MAAM,CAAC;IAAC,OAAO,EAAC,SAAS,YAAY,EAAE,CAAC;IAAC,KAAK,CAAC,EAAC,MAAM,CAAC;IAAC,YAAY,CAAC,EAAC,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAC,CAAC,KAAK,EAAC,MAAM,EAAC,MAAM,EAAC,YAAY,KAAG,IAAI,CAAC;IAAC,OAAO,CAAC,EAAC,QAAQ,GAAC,UAAU,CAAC;IAAC,WAAW,CAAC,EAAC,MAAM,CAAC;IAAC,cAAc,CAAC,EAAC,MAAM,CAAC;IAAC,KAAK,CAAC,EAAC,MAAM,GAAC,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAC,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAC,OAAO,CAAC;IAAC,WAAW,CAAC,EAAC,MAAM,CAAC;IAAC,SAAS,CAAC,EAAC,MAAM,CAAC;IAAC,KAAK,CAAC,EAAC,SAAS,CAAC,SAAS,CAAC,CAAA;CAAE,CAAC;AAClX,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG;IAAE,WAAW,CAAC,EAAC,YAAY,CAAC;IAAC,aAAa,CAAC,EAAC,CAAC,KAAK,EAAC,MAAM,KAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAC,MAAM,CAAC;IAAC,SAAS,CAAC,EAAC,MAAM,CAAC;IAAC,WAAW,CAAC,EAAC,MAAM,CAAC;IAAC,aAAa,CAAC,EAAC,MAAM,CAAA;CAAE,CAAC;AAClM,wBAAgB,MAAM,CAAC,KAAK,EAAC,WAAW,+BAAwD;AAChG,wBAAgB,YAAY,CAAC,KAAK,EAAC,iBAAiB,+BAAgD;AACpG,eAAO,MAAM,QAAQ,qBAAa,CAAC"}
package/dist/Select.js ADDED
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import { Pressable, ScrollView, View } from 'react-native';
4
+ import { useOptionSearch } from '@expressive-ui/core';
5
+ import { Dialog } from './Dialogs.js';
6
+ import { TextField } from './Fields.js';
7
+ import { Button } from './Button.js';
8
+ import { Icon, T } from './primitives.js';
9
+ import { useExpressiveTheme } from './theme.js';
10
+ export function Select(props) { return _jsx(SelectionField, { ...props, editable: false }); }
11
+ export function Autocomplete(props) { return _jsx(SelectionField, { ...props, editable: true }); }
12
+ export const Combobox = Autocomplete;
13
+ function SelectionField({ label, options, value: controlled, defaultValue = '', onChange, variant = 'outlined', placeholder, supportingText, error, required, disabled, leadingIcon, maxHeight = 320, style, editable, loadOptions, onQueryChange, debounce, emptyText, loadingText, loadErrorText }) {
14
+ const { colors, locale, labels } = useExpressiveTheme(), pt = locale.startsWith('pt');
15
+ const [inner, setInner] = useState(defaultValue), value = controlled ?? inner, [open, setOpen] = useState(false), [query, setQuery] = useState('');
16
+ const cached = useRef(undefined), selected = options.find(option => option.value === value) ?? (cached.current?.value === value ? cached.current : undefined);
17
+ const result = useOptionSearch(editable && open ? query : '', options, editable ? loadOptions : undefined, debounce), shown = editable ? result.options : options;
18
+ useEffect(() => { if (disabled)
19
+ setOpen(false); }, [disabled]);
20
+ return _jsxs(View, { style: [{ gap: 6, opacity: disabled ? .38 : 1 }, style], children: [_jsxs(T, { variant: "labelMedium", children: [label, required ? ' *' : ''] }), _jsxs(Pressable, { accessibilityRole: "combobox", accessibilityLabel: `${label}${required ? (pt ? ', obrigatório' : ', required') : ''}`, accessibilityValue: { text: selected?.label ?? '' }, accessibilityState: { expanded: open, disabled: !!disabled }, accessibilityHint: typeof error === 'string' ? error : supportingText, disabled: disabled, onPress: () => { setQuery(''); setOpen(true); }, style: { minHeight: 56, padding: 14, borderWidth: variant === 'outlined' ? 1 : 0, borderBottomWidth: 1, borderColor: error ? colors.error : colors.outline, borderRadius: 12, backgroundColor: variant === 'filled' ? colors.surfaceContainerHighest : colors.surface, flexDirection: 'row', alignItems: 'center', gap: 12 }, children: [leadingIcon ? _jsx(Icon, { name: leadingIcon }) : null, _jsx(T, { style: { flex: 1 }, children: selected?.label ?? placeholder ?? (pt ? 'Selecione' : 'Select') }), _jsx(Icon, { name: "arrow_drop_down" })] }), error || supportingText ? _jsx(T, { variant: "bodySmall", color: error ? 'error' : 'onSurfaceVariant', children: typeof error === 'string' ? error : supportingText }) : null, _jsxs(Dialog, { open: open, onClose: () => setOpen(false), headline: label, actions: [{ label: labels.close, onPress: () => setOpen(false) }], children: [editable ? _jsx(TextField, { label: label, value: query, onChange: next => { setQuery(next); onQueryChange?.(next); }, placeholder: placeholder }) : null, _jsx(ScrollView, { style: { maxHeight }, keyboardShouldPersistTaps: "handled", children: result.loading ? _jsx(T, { accessibilityLiveRegion: "polite", children: loadingText ?? (pt ? 'Carregando…' : 'Loading…') }) : result.error ? _jsxs(View, { children: [_jsx(T, { accessibilityRole: "alert", children: loadErrorText ?? (pt ? 'Não foi possível carregar.' : 'Could not load options.') }), _jsx(Button, { variant: "text", action: { id: 'select.retry', label: pt ? 'Tentar novamente' : 'Retry' }, onPress: result.retry })] }) : !shown.length ? _jsx(T, { accessibilityLiveRegion: "polite", children: emptyText ?? (pt ? 'Nenhum resultado.' : 'No results.') }) : shown.map(option => _jsxs(Pressable, { accessibilityRole: "button", accessibilityState: { selected: option.value === value, disabled: !!option.disabled }, disabled: option.disabled, onPress: () => { cached.current = option; setInner(option.value); onChange?.(option.value, option); setOpen(false); }, style: { minHeight: 48, padding: 14, marginVertical: 2, borderRadius: 12, flexDirection: 'row', alignItems: 'center', gap: 12, opacity: option.disabled ? .38 : 1, backgroundColor: option.value === value ? colors.secondaryContainer : colors.surface }, children: [option.icon ? _jsx(Icon, { name: option.icon }) : null, _jsxs(View, { style: { flex: 1 }, children: [_jsx(T, { children: option.label }), option.supportingText ? _jsx(T, { variant: "bodySmall", color: "onSurfaceVariant", children: option.supportingText }) : null] }), option.value === value ? _jsx(Icon, { name: "check" }) : null] }, option.value)) })] })] });
21
+ }
22
+ //# sourceMappingURL=Select.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Select.js","sourceRoot":"","sources":["../src/Select.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAkC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,QAAQ,CAAA,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA,CAAC,EAAC,eAAe,EAAC,MAAM,CAAC,KAAK,KAAG,KAAK,CAAA,CAAC,CAAA,MAAM,CAAC,kBAAkB,CAAA,CAAC,CAAA,MAAM,CAAC,OAAO,EAAC,aACr8B,MAAM,CAAC,IAAI,CAAA,CAAC,CAAA,KAAC,IAAI,IAAC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG,CAAA,CAAC,CAAA,IAAI,EAAC,MAAC,IAAI,IAAC,KAAK,EAAE,EAAC,IAAI,EAAC,CAAC,EAAC,aAAE,KAAC,CAAC,cAAE,MAAM,CAAC,KAAK,GAAK,EAAC,MAAM,CAAC,cAAc,CAAA,CAAC,CAAA,KAAC,CAAC,IAAC,OAAO,EAAC,WAAW,EAAC,KAAK,EAAC,kBAAkB,YAAE,MAAM,CAAC,cAAc,GAAK,CAAA,CAAC,CAAA,IAAI,IAAQ,EAAC,MAAM,CAAC,KAAK,KAAG,KAAK,CAAA,CAAC,CAAA,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAE,CAAA,CAAC,CAAA,IAAI,KADgP,MAAM,CAAC,KAAK,CAEze,CAAC,GACF,IACN,IACJ,CAAC;AACV,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type StyleProp, type ViewStyle } from 'react-native';
3
+ import { type SnackbarMessage } from '@expressive-ui/core';
4
+ export { useSnackbar } from '@expressive-ui/core';
5
+ export type { SnackbarMessage, SnackbarCloseReason } from '@expressive-ui/core';
6
+ export type SnackbarProps = SnackbarMessage & {
7
+ open: boolean;
8
+ style?: StyleProp<ViewStyle>;
9
+ };
10
+ export declare function Snackbar({ open, message, action, duration, dismissible, onClose, style }: SnackbarProps): import("react").JSX.Element | null;
11
+ export type SnackbarProviderProps = {
12
+ children: ReactNode;
13
+ bottomInset?: number;
14
+ style?: StyleProp<ViewStyle>;
15
+ };
16
+ export declare function SnackbarProvider({ children, bottomInset, style }: SnackbarProviderProps): import("react").JSX.Element;
17
+ //# sourceMappingURL=Snackbar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Snackbar.d.ts","sourceRoot":"","sources":["../src/Snackbar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,EAA0D,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AACtH,OAAO,EAAuD,KAAK,eAAe,EAA4B,MAAM,qBAAqB,CAAC;AAG1I,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAChF,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAAE,CAAC;AAC9F,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,QAA4B,EAAE,WAAkB,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,aAAa,sCAmBlI;AACD,MAAM,MAAM,qBAAqB,GAAG;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAAE,CAAC;AAChH,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,WAAe,EAAE,KAAK,EAAE,EAAE,qBAAqB,+BAK3F"}
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import { AccessibilityInfo, AppState, Platform, Pressable, View } from 'react-native';
4
+ import { SnackbarContext, useSnackbarQueue, useSnackbarTimer } from '@expressive-ui/core';
5
+ import { T } from './primitives.js';
6
+ import { useExpressiveTheme } from './theme.js';
7
+ export { useSnackbar } from '@expressive-ui/core';
8
+ export function Snackbar({ open, message, action, duration = action ? 0 : 5000, dismissible = true, onClose, style }) {
9
+ const { colors, labels } = useExpressiveTheme();
10
+ const [background, setBackground] = useState(AppState.currentState !== 'active');
11
+ const [screenReader, setScreenReader] = useState(true);
12
+ useEffect(() => {
13
+ let active = true;
14
+ AccessibilityInfo.isScreenReaderEnabled().then(value => { if (active)
15
+ setScreenReader(value); }).catch(() => { });
16
+ const reader = AccessibilityInfo.addEventListener('screenReaderChanged', setScreenReader);
17
+ const app = AppState.addEventListener('change', state => setBackground(state !== 'active'));
18
+ return () => { active = false; reader.remove(); app.remove(); };
19
+ }, []);
20
+ useEffect(() => { if (open && Platform.OS === 'ios')
21
+ AccessibilityInfo.announceForAccessibility(message); }, [open, message]);
22
+ useSnackbarTimer(open, duration, background || screenReader, onClose);
23
+ if (!open)
24
+ return null;
25
+ return _jsxs(View, { style: [{ minHeight: 48, borderRadius: 4, paddingHorizontal: 16, paddingVertical: 8, backgroundColor: colors.inverseSurface, flexDirection: 'row', alignItems: 'center', gap: 8 }, style], children: [_jsx(T, { variant: "bodyMedium", color: "inverseOnSurface", accessibilityLiveRegion: "polite", style: { flex: 1 }, children: message }), action ? _jsx(Pressable, { accessibilityRole: "button", onPress: () => { try {
26
+ action.onPress();
27
+ }
28
+ finally {
29
+ onClose?.('action');
30
+ } }, style: { minHeight: 48, paddingHorizontal: 8, justifyContent: 'center' }, children: _jsx(T, { variant: "labelLarge", color: "inversePrimary", children: action.label }) }) : null, dismissible ? _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: labels.close, onPress: () => onClose?.('dismiss'), style: { minWidth: 48, minHeight: 48, alignItems: 'center', justifyContent: 'center' }, children: _jsx(T, { variant: "titleLarge", color: "inverseOnSurface", children: "\u00D7" }) }) : null] });
31
+ }
32
+ export function SnackbarProvider({ children, bottomInset = 0, style }) {
33
+ const { controller, entry, close } = useSnackbarQueue();
34
+ return _jsxs(SnackbarContext.Provider, { value: controller, children: [children, _jsx(View, { pointerEvents: "box-none", style: [{ position: 'absolute', bottom: 16 + bottomInset, left: 16, right: 16, zIndex: 1000, maxWidth: 560, alignSelf: 'center' }, style], children: entry ? _jsx(Snackbar, { ...entry, open: true, onClose: (reason) => close(entry.id, reason) }, entry.id) : null })] });
35
+ }
36
+ //# sourceMappingURL=Snackbar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Snackbar.js","sourceRoot":"","sources":["../src/Snackbar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAkC,MAAM,cAAc,CAAC;AACtH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAkD,MAAM,qBAAqB,CAAC;AAC1I,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD,MAAM,UAAU,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,EAAiB;IACjI,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,kBAAkB,EAAE,CAAC;IAChD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,YAAY,KAAK,QAAQ,CAAC,CAAC;IACjF,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IACvD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI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gBAAgB,EAAE,CAAC;IACxD,OAAO,MAAC,eAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,UAAU,aAAG,QAAQ,EAAC,KAAC,IAAI,IAAC,aAAa,EAAC,UAAU,EAAC,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,GAAG,WAAW,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,YACnO,KAAK,CAAC,CAAC,CAAC,KAAC,QAAQ,OAAoB,KAAK,EAAE,IAAI,QAAC,OAAO,EAAE,CAAC,MAA2B,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,CAAC,IAA3F,KAAK,CAAC,EAAE,CAAuF,CAAC,CAAC,CAAC,IAAI,GACzH,IAA2B,CAAC;AACrC,CAAC"}
package/dist/Toolbar.d.ts CHANGED
@@ -1,13 +1,16 @@
1
1
  import { type StyleProp, type ViewStyle } from 'react-native';
2
- import { type RuntimeProps } from '@expressive-ui/core';
2
+ import { type ScrollBehavior, type RuntimeProps } from '@expressive-ui/core';
3
3
  import type { ToolbarData } from '@expressive-ui/schema';
4
4
  export type ToolbarProps = ToolbarData & RuntimeProps & {
5
5
  /** Item selecionado: fica em pílula e mostra o rótulo, como o Dock do mobile-app-rhosse. */
6
6
  value?: string;
7
+ scrollBehavior?: ScrollBehavior;
8
+ scrollOffset?: number;
9
+ scrollThreshold?: number;
7
10
  /** Área segura inferior da toolbar docked. */
8
11
  bottomInset?: number;
9
12
  style?: StyleProp<ViewStyle>;
10
13
  };
11
14
  /** Toolbar do M3 Expressive: floating (o Dock do mobile-app-rhosse, com FAB opcional) ou docked. */
12
- export declare function Toolbar({ items, fab, type, color, orientation, value, bottomInset, onAction, index: _, children: __, style }: ToolbarProps): import("react").JSX.Element;
15
+ export declare function Toolbar({ items, fab, type, color, orientation, value, scrollBehavior, scrollOffset, scrollThreshold, bottomInset, onAction, index: _, children: __, style }: ToolbarProps): import("react").JSX.Element;
13
16
  //# sourceMappingURL=Toolbar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../src/Toolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAMrE,MAAM,MAAM,YAAY,GAAG,WAAW,GACpC,YAAY,GAAG;IACb,4FAA4F;IAC5F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AAEJ,oGAAoG;AACpG,wBAAgB,OAAO,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,WAAe,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,YAAY,+BAoC9I"}
1
+ {"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../src/Toolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyC,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AACrG,OAAO,EAAsC,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACjH,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAMrE,MAAM,MAAM,YAAY,GAAG,WAAW,GACpC,YAAY,GAAG;IACb,4FAA4F;IAC5F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AAEJ,oGAAoG;AACpG,wBAAgB,OAAO,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,cAAuB,EAAE,YAAgB,EAAE,eAAoB,EAAE,WAAe,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,YAAY,+BAwC/M"}
package/dist/Toolbar.js CHANGED
@@ -1,16 +1,20 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Pressable, StyleSheet, View } from 'react-native';
3
- import { resolveToolbar } from '@expressive-ui/core';
2
+ import { Animated, Pressable, StyleSheet, View } from 'react-native';
3
+ import { resolveToolbar, useScrollCollapsed } from '@expressive-ui/core';
4
4
  import { tokens } from '@expressive-ui/tokens';
5
5
  import { Fab } from './Fab.js';
6
6
  import { Icon, T, withAlpha } from './primitives.js';
7
- import { useExpressiveTheme } from './theme.js';
7
+ import { useExpressiveTheme, useSpringValue } from './theme.js';
8
8
  /** Toolbar do M3 Expressive: floating (o Dock do mobile-app-rhosse, com FAB opcional) ou docked. */
9
- export function Toolbar({ items, fab, type, color, orientation, value, bottomInset = 0, onAction, index: _, children: __, style }) {
10
- const { colors, mode } = useExpressiveTheme();
9
+ export function Toolbar({ items, fab, type, color, orientation, value, scrollBehavior = 'none', scrollOffset = 0, scrollThreshold = 24, bottomInset = 0, onAction, index: _, children: __, style }) {
10
+ const { colors, mode, locale } = useExpressiveTheme();
11
11
  const spec = resolveToolbar({ type, color, orientation });
12
+ const { collapsed, setCollapsed } = useScrollCollapsed(scrollOffset, scrollBehavior !== 'none', scrollThreshold);
13
+ const compact = collapsed && scrollBehavior === 'collapse';
14
+ const hidden = collapsed && scrollBehavior === 'hide';
15
+ const visibility = useSpringValue(hidden ? 0 : 1, 'effectsFast');
12
16
  const floating = spec.type === 'floating';
13
- return (_jsxs(View, { style: [styles.wrap, spec.vertical && styles.wrapVertical, !floating && { alignSelf: 'stretch' }, style], children: [_jsx(View, { accessibilityRole: "toolbar", style: [
17
+ return (_jsxs(Animated.View, { accessibilityElementsHidden: hidden, importantForAccessibility: hidden ? 'no-hide-descendants' : 'auto', pointerEvents: hidden ? 'none' : 'auto', style: [styles.wrap, { opacity: visibility }, spec.vertical && styles.wrapVertical, !floating && { alignSelf: 'stretch' }, style], children: [compact ? _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: locale.startsWith('pt') ? 'Expandir ações' : 'Expand actions', accessibilityState: { expanded: false }, onPress: () => setCollapsed(false), style: { width: 56, height: 56, borderRadius: 28, alignItems: 'center', justifyContent: 'center', backgroundColor: colors[spec.container] }, children: _jsx(Icon, { name: "more_horiz", color: spec.content }) }) : _jsx(View, { accessibilityRole: "toolbar", style: [
14
18
  styles.bar,
15
19
  spec.vertical ? { flexDirection: 'column', width: spec.height, paddingVertical: spec.padding } : { height: floating ? spec.height : undefined, paddingHorizontal: spec.padding },
16
20
  !floating && { flex: 1, justifyContent: 'space-around', minHeight: spec.height, paddingTop: 8, paddingBottom: Math.max(8, bottomInset) },
@@ -1 +1 @@
1
- {"version":3,"file":"Toolbar.js","sourceRoot":"","sources":["../src/Toolbar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAkC,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAqB,MAAM,qBAAqB,CAAC;AAExE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EA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ED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE;IAC5D,YAAY,EAAE,EAAE,aAAa,EAAE,QAAQ,EAAE;IACzC,GAAG,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE;IACnD,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,iBAAiB,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE;IACzJ,YAAY,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE;CACpD,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -18,4 +18,12 @@ export * from './Transition.js';
18
18
  export * from './Search.js';
19
19
  export * from './Toolbar.js';
20
20
  export * from './Pickers.js';
21
+ export * from './AppBar.js';
22
+ export * from './Divider.js';
23
+ export * from './Snackbar.js';
24
+ export * from './RangeSlider.js';
25
+ export * from './Select.js';
26
+ export * from './Feedback.js';
27
+ export * from './NumberField.js';
28
+ export * from './FileUpload.js';
21
29
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAE7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -18,4 +18,12 @@ export * from './Transition.js';
18
18
  export * from './Search.js';
19
19
  export * from './Toolbar.js';
20
20
  export * from './Pickers.js';
21
+ export * from './AppBar.js';
22
+ export * from './Divider.js';
23
+ export * from './Snackbar.js';
24
+ export * from './RangeSlider.js';
25
+ export * from './Select.js';
26
+ export * from './Feedback.js';
27
+ export * from './NumberField.js';
28
+ export * from './FileUpload.js';
21
29
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAE7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expressive-ui/native",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "homepage": "https://expressive-ui.com",
5
5
  "description": "Componentes React Native (Expo) do ExpressiveUI em Material 3 Expressive.",
6
6
  "keywords": [
@@ -34,9 +34,9 @@
34
34
  "build": "tsc -b"
35
35
  },
36
36
  "dependencies": {
37
- "@expressive-ui/core": "0.1.1",
38
- "@expressive-ui/schema": "0.1.1",
39
- "@expressive-ui/tokens": "0.1.1"
37
+ "@expressive-ui/core": "0.2.0",
38
+ "@expressive-ui/schema": "0.2.0",
39
+ "@expressive-ui/tokens": "0.2.0"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "react": ">=19",
package/src/AppBar.tsx ADDED
@@ -0,0 +1,30 @@
1
+ import type { ReactNode } from 'react';
2
+ import { Animated, View, type StyleProp, type ViewStyle } from 'react-native';
3
+ import { resolveAppBar, useScrollCollapsed, type AppBarVariant, type AppBarScrollBehavior } from '@expressive-ui/core';
4
+ import { T } from './primitives.js';
5
+ import { useExpressiveTheme, useSpringValue } from './theme.js';
6
+ export type AppBarProps = {
7
+ title: string; subtitle?: string; navigation?: ReactNode; actions?: ReactNode;
8
+ variant?: AppBarVariant; scrollBehavior?: AppBarScrollBehavior;
9
+ /** Feed contentOffset.y from the screen's onScroll. */
10
+ scrollOffset?: number; topInset?: number; style?: StyleProp<ViewStyle>;
11
+ };
12
+ export function AppBar({ title, subtitle, navigation, actions, variant = 'small', scrollBehavior = 'pinned', scrollOffset = 0, topInset = 0, style }: AppBarProps) {
13
+ const { colors } = useExpressiveTheme();
14
+ const spec = resolveAppBar(variant, scrollOffset, scrollBehavior);
15
+ const { collapsed: hidden } = useScrollCollapsed(scrollOffset, scrollBehavior === 'enterAlways');
16
+ const translateY = useSpringValue(hidden ? -(spec.height + topInset) : 0, 'spatialFast');
17
+ const expanded = spec.height > 64;
18
+ return <Animated.View pointerEvents={hidden ? 'none' : 'auto'} accessibilityElementsHidden={hidden} importantForAccessibility={hidden ? 'no-hide-descendants' : 'auto'}
19
+ style={[{ minHeight: spec.height + topInset, paddingTop: topInset, backgroundColor: colors[spec.scrolled ? 'surfaceContainer' : 'surface'], transform: [{ translateY }] }, style]}>
20
+ <View style={{ minHeight: 64, flexDirection: 'row', alignItems: 'center', paddingHorizontal: 4, gap: 4 }}>
21
+ {navigation}
22
+ <View style={{ flex: 1, paddingHorizontal: 12 }}>
23
+ {!expanded ? <><T accessibilityRole="header" variant="titleLarge" numberOfLines={1} style={{ textAlign: spec.centered ? 'center' : 'left' }}>{title}</T>{subtitle ? <T variant="bodyMedium" color="onSurfaceVariant">{subtitle}</T> : null}</> : null}
24
+ </View>
25
+ {actions ? <View style={{ flexDirection: 'row', alignItems: 'center' }}>{actions}</View> : null}
26
+ </View>
27
+ {expanded ? <View style={{ flex: 1, justifyContent: 'flex-end', paddingHorizontal: 16, paddingBottom: 12 }}><T variant={variant === 'large' ? 'headlineMedium' : 'headlineSmall'} accessibilityRole="header">{title}</T>{subtitle ? <T variant="bodyMedium" color="onSurfaceVariant">{subtitle}</T> : null}</View> : null}
28
+ </Animated.View>;
29
+ }
30
+ export const TopAppBar = AppBar;
@@ -0,0 +1,9 @@
1
+ import { View, type StyleProp, type ViewStyle } from 'react-native';
2
+ import { useExpressiveTheme } from './theme.js';
3
+ export type DividerProps = { orientation?: 'horizontal' | 'vertical'; insetStart?: number; insetEnd?: number; decorative?: boolean; style?: StyleProp<ViewStyle> };
4
+ export function Divider({ orientation = 'horizontal', insetStart = 0, insetEnd = 0, decorative = false, style }: DividerProps) {
5
+ const { colors } = useExpressiveTheme();
6
+ return <View accessible={!decorative} role={decorative ? undefined : 'separator'} style={[{ flexShrink: 0, backgroundColor: colors.outlineVariant }, orientation === 'vertical'
7
+ ? { width: 1, alignSelf: 'stretch', marginTop: insetStart, marginBottom: insetEnd }
8
+ : { height: 1, alignSelf: 'stretch', marginStart: insetStart, marginEnd: insetEnd }, style]} />;
9
+ }
@@ -0,0 +1,23 @@
1
+ import { useEffect, useRef, useState, type ReactNode } from 'react';
2
+ import { AccessibilityInfo, Animated, Pressable, View, type DimensionValue, type StyleProp, type ViewStyle } from 'react-native';
3
+ import { alertIcons, type AlertSeverity } from '@expressive-ui/core';
4
+ import { Button } from './Button.js';
5
+ import { Icon, T } from './primitives.js';
6
+ import { useExpressiveTheme } from './theme.js';
7
+ export type SkeletonProps={variant?:'text'|'rectangular'|'circular';width?:DimensionValue;height?:number;lines?:number;animation?:boolean;label?:string;style?:StyleProp<ViewStyle>};
8
+ export function Skeleton({variant='text',width='100%',height,lines=1,animation=true,label,style}:SkeletonProps){
9
+ const {colors}=useExpressiveTheme(),opacity=useRef(new Animated.Value(1)).current,[reduced,setReduced]=useState(true);
10
+ useEffect(()=>{let active=true;AccessibilityInfo.isReduceMotionEnabled().then(value=>{if(active)setReduced(value);});const listener=AccessibilityInfo.addEventListener('reduceMotionChanged',setReduced);return()=>{active=false;listener.remove();};},[]);
11
+ useEffect(()=>{if(!animation||reduced){opacity.setValue(1);return;}const loop=Animated.loop(Animated.sequence([Animated.timing(opacity,{toValue:.45,duration:750,useNativeDriver:true}),Animated.timing(opacity,{toValue:1,duration:750,useNativeDriver:true})]));loop.start();return()=>loop.stop();},[animation,reduced,opacity]);
12
+ return <View accessible={!!label} accessibilityLabel={label} accessibilityLiveRegion={label?'polite':undefined} accessibilityElementsHidden={!label} importantForAccessibility={label?'yes':'no-hide-descendants'} style={[{width,gap:10},style]}>{Array.from({length:Math.max(1,Math.floor(lines))},(_,index)=><Animated.View key={index} style={{height:height??(variant==='text'?16:48),width:variant==='circular'?height??48:index===Math.floor(lines)-1&&lines>1?'72%':'100%',borderRadius:variant==='circular'?999:8,backgroundColor:colors.surfaceContainerHighest,opacity}}/>)}</View>;
13
+ }
14
+ export type AlertProps={severity?:AlertSeverity;title?:string;children:ReactNode;icon?:string|false;action?:{label:string;onPress:()=>void};onClose?:()=>void;live?:boolean;style?:StyleProp<ViewStyle>};
15
+ export function Alert({severity='info',title,children,icon,action,onClose,live=true,style}:AlertProps){
16
+ const {colors,labels}=useExpressiveTheme();
17
+ const background=severity==='error'?colors.errorContainer:severity==='success'?colors.tertiaryContainer:severity==='warning'?colors.primaryContainer:colors.secondaryContainer;
18
+ const content=severity==='error'?'onErrorContainer':severity==='success'?'onTertiaryContainer':severity==='warning'?'onPrimaryContainer':'onSecondaryContainer';
19
+ return <View accessibilityLiveRegion={live?severity==='error'?'assertive':'polite':'none'} style={[{flexDirection:'row',gap:14,padding:18,borderRadius:16,backgroundColor:background},style]}>{icon!==false?<Icon name={icon??alertIcons[severity]} color={content}/>:null}<View style={{flex:1,gap:6}}>{title?<T variant="titleSmall" color={content}>{title}</T>:null}{typeof children==='string'?<T color={content}>{children}</T>:children}{action?<Button variant="text" action={{id:'alert.action',label:action.label}} onPress={action.onPress}/>:null}</View>{onClose?<Pressable accessibilityRole="button" accessibilityLabel={labels.close} onPress={onClose} style={{minWidth:40,minHeight:40,alignItems:'center',justifyContent:'center'}}><Icon name="close" color={content}/></Pressable>:null}</View>;
20
+ }
21
+ export const InlineMessage=Alert;
22
+ export type EmptyStateProps={title:string;description?:string;icon?:string;illustration?:ReactNode;action?:{label:string;onPress:()=>void};children?:ReactNode;style?:StyleProp<ViewStyle>};
23
+ export function EmptyState({title,description,icon='inbox',illustration,action,children,style}:EmptyStateProps){const {colors}=useExpressiveTheme();return <View style={[{alignItems:'center',gap:16,padding:24},style]}><View style={{width:96,height:96,borderRadius:32,backgroundColor:colors.secondaryContainer,alignItems:'center',justifyContent:'center'}}>{illustration??<Icon name={icon} size={48} color="onSecondaryContainer"/>}</View><T variant="titleLarge" accessibilityRole="header" style={{textAlign:'center'}}>{title}</T>{description?<T color="onSurfaceVariant" style={{textAlign:'center'}}>{description}</T>:null}{action?<Button action={{id:'empty.action',label:action.label}} onPress={action.onPress}/>:null}{children}</View>;}
@@ -0,0 +1,16 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+ import { Image, View, type StyleProp, type ViewStyle } from 'react-native';
3
+ import { useFileUpload, type FileUploadOptions, type NativeUploadFile } from '@expressive-ui/core';
4
+ import { Button } from './Button.js';
5
+ import { Icon, T } from './primitives.js';
6
+ import { useExpressiveTheme } from './theme.js';
7
+ export type { NativeUploadFile } from '@expressive-ui/core';
8
+ /** Inject an Expo DocumentPicker or platform picker adapter; this package does not install a picker dependency. */
9
+ export type FileUploadProps=FileUploadOptions<NativeUploadFile>&{label:string;pickFiles:()=>Promise<readonly NativeUploadFile[]>;supportingText?:string;disabled?:boolean;style?:StyleProp<ViewStyle>};
10
+ export function FileUpload({label,pickFiles,supportingText,disabled,style,...options}:FileUploadProps){
11
+ const {colors,locale}=useExpressiveTheme(),pt=locale.startsWith('pt'),[picking,setPicking]=useState(false),[error,setError]=useState(''),mounted=useRef(true),inflight=useRef(false);
12
+ useEffect(()=>{mounted.current=true;return()=>{mounted.current=false;};},[]);
13
+ const queue=useFileUpload({...options,onReject:rejected=>{setError(rejected.map(item=>`${item.file.name}: ${item.reason}`).join(', '));options.onReject?.(rejected);}});
14
+ const choose=async()=>{if(inflight.current||disabled)return;inflight.current=true;setPicking(true);setError('');try{const files=await pickFiles();if(mounted.current)queue.add(files);}catch(error){if(mounted.current)setError(error instanceof Error?error.message:String(error));}finally{inflight.current=false;if(mounted.current)setPicking(false);}};
15
+ return <View style={[{gap:14},style]}><T variant="titleSmall">{label}</T>{supportingText?<T color="onSurfaceVariant">{supportingText}</T>:null}<View style={{padding:24,borderWidth:2,borderStyle:'dashed',borderColor:colors.outlineVariant,borderRadius:20,alignItems:'center',gap:12}}><Icon name="upload" size={32}/><Button action={{id:'upload.choose',label:pt?'Escolher arquivos':'Choose files'}} loading={picking} disabled={disabled||picking} onPress={choose}/></View>{error?<T accessibilityRole="alert" color="error">{error}</T>:null}{queue.entries.map(entry=><View key={entry.id} style={{padding:12,borderRadius:16,backgroundColor:colors.surfaceContainer,gap:8}}><View style={{flexDirection:'row',alignItems:'center',gap:12}}>{entry.file.type.startsWith('image/')?<Image source={{uri:entry.file.uri}} accessibilityIgnoresInvertColors style={{width:48,height:48,borderRadius:8}}/>:<Icon name="description"/>}<View style={{flex:1}}><T>{entry.file.name}</T><T variant="bodySmall" color="onSurfaceVariant">{Math.ceil(entry.file.size/1024)} KB · {entry.status}</T></View></View>{entry.status==='uploading'?<View accessibilityRole="progressbar" accessibilityLabel={entry.file.name} accessibilityValue={{min:0,max:100,now:entry.progress}} style={{height:4,borderRadius:2,backgroundColor:colors.outlineVariant}}><View style={{height:4,width:`${entry.progress}%`,backgroundColor:colors.primary}}/></View>:null}{entry.error?<T accessibilityRole="alert" color="error">{entry.error}</T>:null}<View style={{flexDirection:'row',flexWrap:'wrap',gap:8}}>{entry.status==='uploading'?<Button variant="text" action={{id:'upload.cancel',label:pt?'Cancelar':'Cancel'}} onPress={()=>queue.cancel(entry.id)}/>:null}{options.onUpload&&['error','cancelled'].includes(entry.status)?<Button variant="text" disabled={disabled} action={{id:'upload.retry',label:pt?'Tentar novamente':'Retry'}} onPress={()=>queue.retry(entry.id)}/>:null}<Button variant="text" disabled={disabled} action={{id:'upload.remove',label:pt?'Remover':'Remove'}} onPress={()=>queue.remove(entry.id)}/></View></View>)}</View>;
16
+ }
@@ -0,0 +1,13 @@
1
+ import { useId, useState } from 'react';
2
+ import { Pressable, TextInput, View, type StyleProp, type ViewStyle } from 'react-native';
3
+ import { useNumberField, type NumberFieldOptions } from '@expressive-ui/core';
4
+ import { Icon, T } from './primitives.js';
5
+ import { useExpressiveTheme } from './theme.js';
6
+ export type NumberFieldProps=NumberFieldOptions&{label:string;disabled?:boolean;required?:boolean;readOnly?:boolean;variant?:'filled'|'outlined';controlsPosition?:'split'|'end';controlsOrientation?:'horizontal'|'vertical';prefix?:string;suffix?:string;supportingText?:string;error?:string|boolean;style?:StyleProp<ViewStyle>};
7
+ export function NumberField({label,disabled,required,readOnly,variant='outlined',controlsPosition='split',controlsOrientation='horizontal',prefix,suffix,supportingText,error,style,...options}:NumberFieldProps){
8
+ const {colors,locale}=useExpressiveTheme(),state=useNumberField({locale,...options}),pt=locale.startsWith('pt'),id=useId();
9
+ const [selection,setSelection]=useState<{start:number;end:number}|undefined>();
10
+ const vertical=controlsPosition==='end'&&controlsOrientation==='vertical';
11
+ const stepButton=(direction:1|-1)=><Pressable accessibilityRole="button" accessibilityLabel={`${direction===1?(pt?'Aumentar':'Increase'):(pt?'Diminuir':'Decrease')} ${label}`} disabled={disabled||readOnly||options.value!==null&&(direction===1?options.value>=(options.max??Infinity):options.value<=(options.min??-Infinity))} onPress={()=>state.increment(direction)} style={({pressed})=>({width:vertical?48:44,height:vertical?48:44,borderRadius:vertical?0:22,borderTopWidth:vertical&&direction===-1?1:0,borderTopColor:colors.outlineVariant,alignItems:'center',justifyContent:'center',backgroundColor:vertical?'transparent':colors.secondaryContainer,opacity:disabled||readOnly? .38 :pressed? .7 :1})}><Icon name={direction===1?'add':'remove'}/></Pressable>;
12
+ return <View style={[{gap:6,opacity:disabled? .38 :1},style]}><T variant="labelMedium" nativeID={`${id}-label`}>{label}{required?' *':''}</T><View style={{flexDirection:'row',alignItems:'center',gap:8,minHeight:56,padding:6,borderWidth:variant==='outlined'?1:0,borderBottomWidth:1,borderColor:error?colors.error:colors.outline,borderRadius:12,backgroundColor:variant==='filled'?colors.surfaceContainerHighest:colors.surface}}>{controlsPosition==='split'?stepButton(-1):null}{prefix??state.currencySymbol?<T>{prefix??state.currencySymbol}</T>:null}<TextInput accessibilityLabel={label} accessibilityRole="adjustable" accessibilityValue={{...(options.min!==undefined?{min:options.min}:{}),...(options.max!==undefined?{max:options.max}:{}),...(options.value!==null?{now:options.value}:{}),text:state.text}} accessibilityState={{disabled:!!disabled}} accessibilityActions={[{name:'increment'},{name:'decrement'}]} onAccessibilityAction={event=>{if(!disabled&&!readOnly)state.increment(event.nativeEvent.actionName==='increment'?1:-1);}} editable={!disabled&&!readOnly} value={state.text} selection={options.format==='currency'?selection:undefined} onSelectionChange={event=>{if(options.format==='currency')setSelection(event.nativeEvent.selection);}} onFocus={()=>{if(options.format==='currency'&&(options.value===null||options.value===0)){const point=state.text.indexOf(state.decimalSeparator);setSelection({start:0,end:point<0?state.text.length:point});}}} onChangeText={text=>{const result=state.editText(text);if(options.format==='currency')setSelection({start:result.caret,end:result.caret});}} onEndEditing={state.commit} keyboardType="numbers-and-punctuation" style={{flex:1,minWidth:0,padding:10,textAlign:controlsPosition==='end'?'auto':'center',color:colors.onSurface,fontSize:16}}/>{suffix?<T>{suffix}</T>:null}{controlsPosition==='end'?<View style={{flexDirection:vertical?'column':'row',flexShrink:0,gap:vertical?0:6,borderWidth:vertical?1:0,borderColor:colors.outlineVariant,borderRadius:vertical?16:0,overflow:'hidden',backgroundColor:vertical?colors.secondaryContainer:undefined}}>{vertical?<>{stepButton(1)}{stepButton(-1)}</>:<>{stepButton(-1)}{stepButton(1)}</>}</View>:stepButton(1)}</View>{error||supportingText?<T variant="bodySmall" color={error?'error':'onSurfaceVariant'}>{typeof error==='string'?error:supportingText}</T>:null}</View>;
13
+ }
package/src/Pickers.tsx CHANGED
@@ -28,8 +28,8 @@ function TimeModeToggle({ input, label, onPress }: { input: boolean; label: stri
28
28
  </Pressable>;
29
29
  }
30
30
 
31
- export type DatePickerProps = DatePickerOptions & { style?: StyleProp<ViewStyle> };
32
- export type DateRangePickerProps = DateRangePickerOptions & { style?: StyleProp<ViewStyle> };
31
+ export type DatePickerProps = DatePickerOptions & { variant?: 'modal' | 'docked'; style?: StyleProp<ViewStyle> };
32
+ export type DateRangePickerProps = DateRangePickerOptions & { variant?: 'modal' | 'docked'; style?: StyleProp<ViewStyle> };
33
33
  export type { DateRange } from '@expressive-ui/core';
34
34
  export function DatePicker(props: DatePickerProps) {
35
35
  const { locale: themeLocale } = useExpressiveTheme();
@@ -52,7 +52,7 @@ type DatePickerSurfaceProps = Omit<DatePickerProps, 'value' | 'onConfirm'> & {
52
52
  };
53
53
  function DatePickerSurface(props: DatePickerSurfaceProps) {
54
54
  const { colors } = useExpressiveTheme();
55
- const { open, onClose, title, fieldLabel, cancelLabel, confirmLabel, min, max, style, locale, state, range, startLabel, endLabel } = props;
55
+ const { open, onClose, title, fieldLabel, cancelLabel, confirmLabel, min, max, style, locale, state, range, startLabel, endLabel, variant = 'modal' } = props;
56
56
  const labels = pickerLabels(locale);
57
57
  const rangeEnd = range?.range.end ?? '';
58
58
  const shortDate = (date: string) => parseDate(date)?.toLocaleDateString(locale, { month: 'short', day: 'numeric' });
@@ -64,11 +64,11 @@ function DatePickerSurface(props: DatePickerSurfaceProps) {
64
64
  }, [state.view]);
65
65
  const monthName = (m: number, long = false) => new Date(2024, m, 1).toLocaleDateString(locale, { month: long ? 'long' : 'short' });
66
66
  const menu = (view: 'months' | 'years', label: string, text: string) => <Pressable accessibilityRole="button" accessibilityLabel={label} accessibilityState={{ expanded: state.view === view, disabled: state.view !== 'days' && state.view !== view }} disabled={state.view !== 'days' && state.view !== view} onPress={() => state.setView(state.view === view ? 'days' : view)} style={[styles.menuTrigger, { opacity: state.view !== 'days' && state.view !== view ? .38 : 1 }]}><T variant="labelLarge" color={state.view === view ? 'primary' : 'onSurfaceVariant'}>{text}</T><Icon name="arrow_drop_down" size={18} /></Pressable>;
67
- return <Dialog open={open} onClose={onClose} style={[{ maxWidth: 360, borderRadius: 28 }, style]}>
68
- <View style={{ gap: 16 }}>
67
+ const content = <View style={{ gap: 16 }}>
69
68
  <T variant="labelLarge" color="onSurfaceVariant">{title ?? (range ? labels.range : labels.date)}</T>
70
69
  <View style={[styles.headline, { borderBottomColor: colors.outlineVariant, borderBottomWidth: 1, paddingBottom: 12 }]}><T variant={range ? "headlineSmall" : "headlineLarge"} style={{ flex: 1 }}>{range ? `${shortDate(range.range.start) ?? labels.start} – ${shortDate(range.range.end) ?? labels.end}` : parseDate(state.draft)?.toLocaleDateString(locale, { weekday: 'short', month: 'short', day: 'numeric' }) ?? '—'}</T><PickerIcon name={state.mode === 'calendar' ? 'edit' : 'calendar_today'} label={state.mode === 'calendar' ? labels.input : labels.calendar} onPress={() => { state.setMode(state.mode === 'calendar' ? 'input' : 'calendar'); state.setView('days'); }} /></View>
71
- {state.mode === 'input' ? range ? <View style={{ gap: 16 }}>{(['start', 'end'] as const).map(part => <TextField key={part} variant="outlined" label={part === 'start' ? startLabel ?? labels.start : endLabel ?? labels.end} value={part === 'start' ? range.startText : range.endText} onChange={text => range.editPart(text, part)} keyboardType="numbers-and-punctuation" placeholder={dateInputPattern(locale)} supportingText={dateInputPattern(locale)} error={(part === 'start' ? range.startText : range.endText) && (!range.available(range.range[part]) || !!(range.range.start && range.range.end && !range.valid)) ? labels.rangeInvalid : undefined} />)}</View> : <TextField variant="outlined" label={fieldLabel ?? labels.dateField} value={state.text} onChange={state.edit} keyboardType="numbers-and-punctuation" placeholder={dateInputPattern(locale)} supportingText={dateInputPattern(locale)} error={state.text && !state.valid ? labels.invalid : undefined} /> : <View>
70
+ {state.mode === 'input' || variant === 'docked' ? range ? <View style={{ gap: 16 }}>{(['start', 'end'] as const).map(part => <TextField key={part} variant="outlined" label={part === 'start' ? startLabel ?? labels.start : endLabel ?? labels.end} value={part === 'start' ? range.startText : range.endText} onChange={text => range.editPart(text, part)} keyboardType="numbers-and-punctuation" placeholder={dateInputPattern(locale)} supportingText={dateInputPattern(locale)} error={(part === 'start' ? range.startText : range.endText) && (!range.available(range.range[part]) || !!(range.range.start && range.range.end && !range.valid)) ? labels.rangeInvalid : undefined} />)}</View> : <TextField variant="outlined" label={fieldLabel ?? labels.dateField} value={state.text} onChange={state.edit} keyboardType="numbers-and-punctuation" placeholder={dateInputPattern(locale)} supportingText={dateInputPattern(locale)} error={state.text && !state.valid ? labels.invalid : undefined} /> : null}
71
+ {state.mode === 'calendar' || variant === 'docked' ? <View>
72
72
  <View style={styles.navigation}>
73
73
  <View style={styles.navGroup}><PickerIcon name="chevron_left" label={labels.previous} disabled={state.view === 'years' || !state.canNavigate(-1)} onPress={() => state.navigate(-1)} />{menu('months', labels.month, monthName(state.month.getMonth()))}<PickerIcon name="chevron_right" label={labels.next} disabled={state.view === 'years' || !state.canNavigate(1)} onPress={() => state.navigate(1)} /></View>
74
74
  <View style={styles.navGroup}><PickerIcon name="chevron_left" label={labels.previousYear} disabled={state.view === 'months' || !state.canNavigate(-12)} onPress={() => state.navigate(-12)} />{menu('years', labels.year, String(state.month.getFullYear()))}<PickerIcon name="chevron_right" label={labels.nextYear} disabled={state.view === 'months' || !state.canNavigate(12)} onPress={() => state.navigate(12)} /></View>
@@ -91,11 +91,12 @@ function DatePickerSurface(props: DatePickerSurfaceProps) {
91
91
  return <Pressable key={n} accessibilityRole="button" accessibilityState={{ selected, disabled }} disabled={disabled} onPress={() => state.view === 'months' ? state.chooseMonth(n) : state.chooseYear(n)} style={{ minHeight: 48, paddingHorizontal: 16, flexDirection: 'row', alignItems: 'center', gap: 16, opacity: disabled ? .38 : 1, backgroundColor: selected ? colors.secondaryContainer : undefined }}><View style={{ width: 20 }}>{selected ? <Icon name="check" size={20} color="onSecondaryContainer" /> : null}</View><T color={selected ? 'onSecondaryContainer' : 'onSurface'}>{state.view === 'months' ? monthName(n, true) : n}</T></Pressable>;
92
92
  })}
93
93
  </ScrollView>}
94
- </View>}
94
+ </View> : null}
95
95
  {range ? <T variant="bodySmall" color="onSurfaceVariant" accessibilityLiveRegion="polite">{range.range.start && !range.range.end ? labels.end : range.range.end && !range.valid ? labels.rangeInvalid : labels.rangeHelp}</T> : null}
96
96
  <PickerActions cancel={cancelLabel ?? labels.cancel} confirm={confirmLabel ?? labels.confirm} onClose={onClose} onConfirm={state.confirm} valid={state.valid} />
97
- </View>
98
- </Dialog>;
97
+ </View>;
98
+ if (variant === 'docked') return open ? <View style={[{ maxWidth: 360, alignSelf: 'stretch', borderRadius: 16, padding: 16, backgroundColor: colors.surfaceContainerHigh }, style]}>{content}</View> : null;
99
+ return <Dialog open={open} onClose={onClose} style={[{ maxWidth: 360, borderRadius: 28 }, style]}>{content}</Dialog>;
99
100
  }
100
101
 
101
102
  export type TimePickerProps = TimePickerOptions & { style?: StyleProp<ViewStyle> };