@sincpro/mobile-ui 0.2.1 → 0.3.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/README.md +75 -20
- package/dist/Dialog/BottomSheet/BottomSheet.Root.d.ts +11 -7
- package/dist/Dialog/BottomSheet/BottomSheet.Root.js +4 -0
- package/dist/Dialog/Confirmation.context.d.ts +1 -1
- package/dist/Dialog/Dialog.ActionSheet.d.ts +17 -0
- package/dist/Dialog/Dialog.ActionSheet.js +16 -0
- package/dist/Dialog/Dialog.EditValue.d.ts +1 -1
- package/dist/Dialog/Dialog.Sheet.d.ts +26 -0
- package/dist/Dialog/Dialog.Sheet.js +55 -0
- package/dist/Dialog/index.d.ts +9 -7
- package/dist/Dialog/index.js +2 -0
- package/dist/Display/Display.Accordion.d.ts +18 -0
- package/dist/Display/Display.Accordion.js +22 -0
- package/dist/Display/Display.AvatarGroup.d.ts +12 -0
- package/dist/Display/Display.AvatarGroup.js +23 -0
- package/dist/Display/Display.Badge.d.ts +1 -1
- package/dist/Display/Display.Card.d.ts +46 -0
- package/dist/Display/Display.Card.js +36 -0
- package/dist/Display/Display.Carousel.d.ts +13 -0
- package/dist/Display/Display.Carousel.js +19 -0
- package/dist/Display/Display.Chip.d.ts +105 -0
- package/dist/Display/Display.Chip.js +45 -0
- package/dist/Display/Display.CopyableText.d.ts +1 -1
- package/dist/Display/Display.CountRecords.d.ts +1 -1
- package/dist/Display/Display.DataTable.d.ts +19 -0
- package/dist/Display/Display.DataTable.js +22 -0
- package/dist/Display/Display.Date.d.ts +15 -2
- package/dist/Display/Display.Date.js +34 -4
- package/dist/Display/Display.Divider.d.ts +1 -1
- package/dist/Display/Display.IconBadge.d.ts +13 -0
- package/dist/Display/Display.IconBadge.js +30 -0
- package/dist/Display/Display.Image.d.ts +15 -0
- package/dist/Display/Display.Image.js +17 -0
- package/dist/Display/Display.KeyValue.d.ts +10 -0
- package/dist/Display/Display.KeyValue.js +9 -0
- package/dist/Display/Display.ListItem.d.ts +13 -0
- package/dist/Display/Display.ListItem.js +14 -0
- package/dist/Display/Display.Logo.js +3 -1
- package/dist/Display/Display.MediaCard.d.ts +17 -0
- package/dist/Display/Display.MediaCard.js +12 -0
- package/dist/Display/Display.MediaEmbed.d.ts +19 -0
- package/dist/Display/Display.MediaEmbed.js +39 -0
- package/dist/Display/Display.MenuButton.d.ts +1 -1
- package/dist/Display/Display.Monetary.d.ts +1 -1
- package/dist/Display/Display.PriceTag.d.ts +10 -0
- package/dist/Display/Display.PriceTag.js +23 -0
- package/dist/Display/Display.ProductCard.d.ts +17 -0
- package/dist/Display/Display.ProductCard.js +13 -0
- package/dist/Display/Display.Rating.d.ts +11 -0
- package/dist/Display/Display.Rating.js +16 -0
- package/dist/Display/Display.SearchHistory.d.ts +12 -0
- package/dist/Display/Display.SearchHistory.js +13 -0
- package/dist/Display/Display.SectionHeader.d.ts +13 -0
- package/dist/Display/Display.SectionHeader.js +9 -0
- package/dist/Display/Display.Stat.d.ts +10 -0
- package/dist/Display/Display.Stat.js +9 -0
- package/dist/Display/Display.StatCard.d.ts +14 -0
- package/dist/Display/Display.StatCard.js +13 -0
- package/dist/Display/Display.StatusDot.d.ts +11 -0
- package/dist/Display/Display.StatusDot.js +28 -0
- package/dist/Display/Display.Story.d.ts +15 -0
- package/dist/Display/Display.Story.js +43 -0
- package/dist/Display/Display.StoryTray.d.ts +26 -0
- package/dist/Display/Display.StoryTray.js +43 -0
- package/dist/Display/Display.StoryViewer.d.ts +26 -0
- package/dist/Display/Display.StoryViewer.js +79 -0
- package/dist/Display/Display.SwipeableRow.d.ts +15 -0
- package/dist/Display/Display.SwipeableRow.js +28 -0
- package/dist/Display/Display.Tag.d.ts +11 -0
- package/dist/Display/Display.Tag.js +9 -0
- package/dist/Display/Display.Timeline.d.ts +13 -0
- package/dist/Display/Display.Timeline.js +19 -0
- package/dist/Display/Display.Tooltip.d.ts +10 -0
- package/dist/Display/Display.Tooltip.js +24 -0
- package/dist/Display/index.d.ts +66 -0
- package/dist/Display/index.js +54 -0
- package/dist/Feedback/ErrorBoundary.d.ts +1 -1
- package/dist/Feedback/Feedback.Banner.d.ts +82 -0
- package/dist/Feedback/Feedback.Banner.js +35 -0
- package/dist/Feedback/Feedback.DomainSplashScreen.d.ts +2 -1
- package/dist/Feedback/Feedback.DomainSplashScreen.js +1 -1
- package/dist/Feedback/Feedback.Empty.d.ts +1 -1
- package/dist/Feedback/Feedback.EmptyState.d.ts +15 -0
- package/dist/Feedback/Feedback.EmptyState.js +11 -0
- package/dist/Feedback/Feedback.Error.d.ts +1 -1
- package/dist/Feedback/Feedback.Loading.d.ts +2 -1
- package/dist/Feedback/Feedback.PermissionCard.d.ts +15 -0
- package/dist/Feedback/Feedback.PermissionCard.js +11 -0
- package/dist/Feedback/Feedback.Progress.d.ts +9 -0
- package/dist/Feedback/Feedback.Progress.js +35 -0
- package/dist/Feedback/Feedback.ProgressCircle.d.ts +12 -0
- package/dist/Feedback/Feedback.ProgressCircle.js +15 -0
- package/dist/Feedback/Feedback.Skeleton.d.ts +11 -0
- package/dist/Feedback/Feedback.Skeleton.js +29 -0
- package/dist/Feedback/Feedback.Splash.d.ts +1 -1
- package/dist/Feedback/Toast.context.d.ts +35 -0
- package/dist/Feedback/Toast.context.js +119 -0
- package/dist/Feedback/index.d.ts +15 -0
- package/dist/Feedback/index.js +15 -0
- package/dist/Form/Form.Button.d.ts +6 -0
- package/dist/Form/Form.Button.js +12 -1
- package/dist/Form/Form.Checkbox.d.ts +1 -1
- package/dist/Form/Form.ControlledCheckbox.d.ts +1 -1
- package/dist/Form/Form.ControlledInput.d.ts +1 -1
- package/dist/Form/Form.ControlledMonetaryInput.d.ts +1 -1
- package/dist/Form/Form.ControlledRadioButton.d.ts +1 -1
- package/dist/Form/Form.DatePicker.d.ts +20 -0
- package/dist/Form/Form.DatePicker.js +38 -0
- package/dist/Form/Form.Dropdown.d.ts +1 -1
- package/dist/Form/Form.FAB.d.ts +10 -0
- package/dist/Form/Form.FAB.js +17 -0
- package/dist/Form/Form.FilterButton.d.ts +1 -1
- package/dist/Form/Form.FractionalQuantityInput.d.ts +1 -1
- package/dist/Form/Form.IconButton.d.ts +1 -1
- package/dist/Form/Form.Input.d.ts +2 -1
- package/dist/Form/Form.MonetaryInput.d.ts +1 -1
- package/dist/Form/Form.PinInput.d.ts +12 -0
- package/dist/Form/Form.PinInput.js +23 -0
- package/dist/Form/Form.QuantitySelector.d.ts +2 -1
- package/dist/Form/Form.QuantitySelector.js +1 -1
- package/dist/Form/Form.RadioButton.d.ts +1 -1
- package/dist/Form/Form.SearchBar.d.ts +6 -1
- package/dist/Form/Form.SearchBar.js +4 -0
- package/dist/Form/Form.Select.d.ts +17 -0
- package/dist/Form/Form.Select.js +26 -0
- package/dist/Form/Form.Slider.d.ts +20 -0
- package/dist/Form/Form.Slider.js +16 -0
- package/dist/Form/Form.Switch.d.ts +10 -0
- package/dist/Form/Form.Switch.js +9 -0
- package/dist/Form/index.d.ts +12 -0
- package/dist/Form/index.js +12 -0
- package/dist/Navigation/Navigation.AppBar.d.ts +41 -0
- package/dist/Navigation/Navigation.AppBar.js +33 -0
- package/dist/Navigation/Navigation.BottomNav.d.ts +29 -0
- package/dist/Navigation/Navigation.BottomNav.js +35 -0
- package/dist/Navigation/Navigation.CollapsingHeader.d.ts +34 -0
- package/dist/Navigation/Navigation.CollapsingHeader.js +47 -0
- package/dist/Navigation/Navigation.FloatingBar.d.ts +15 -0
- package/dist/Navigation/Navigation.FloatingBar.js +21 -0
- package/dist/Navigation/Navigation.Header.d.ts +6 -2
- package/dist/Navigation/Navigation.Header.js +4 -0
- package/dist/Navigation/Navigation.HeaderToolbar.d.ts +1 -1
- package/dist/Navigation/Navigation.Menu.d.ts +21 -0
- package/dist/Navigation/Navigation.Menu.js +42 -0
- package/dist/Navigation/Navigation.RowItem.d.ts +1 -1
- package/dist/Navigation/Navigation.SearchBar.d.ts +18 -0
- package/dist/Navigation/Navigation.SearchBar.js +22 -0
- package/dist/Navigation/Navigation.SegmentedControl.d.ts +14 -0
- package/dist/Navigation/Navigation.SegmentedControl.js +13 -0
- package/dist/Navigation/Navigation.Steps.d.ts +8 -0
- package/dist/Navigation/Navigation.Steps.js +17 -0
- package/dist/Navigation/Navigation.TabIcon.d.ts +1 -1
- package/dist/Navigation/Navigation.Tabs.d.ts +28 -0
- package/dist/Navigation/Navigation.Tabs.js +45 -0
- package/dist/Navigation/index.d.ts +32 -1
- package/dist/Navigation/index.js +18 -0
- package/dist/Typography/Typography.Text.d.ts +2 -1
- package/dist/branding.d.ts +6 -0
- package/dist/branding.js +7 -0
- package/dist/icons/ArrowDownIcon.d.ts +2 -1
- package/dist/icons/ArrowUpIcon.d.ts +2 -1
- package/dist/icons/CreditIcon.d.ts +1 -1
- package/dist/icons/OdooIcon.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/layouts/AuthContainer.d.ts +1 -1
- package/dist/layouts/Container.d.ts +1 -0
- package/dist/layouts/Container.js +2 -3
- package/dist/layouts/GradientContainer.d.ts +1 -1
- package/dist/layouts/PlainLayout.d.ts +1 -1
- package/dist/layouts/ScrollContainer.d.ts +2 -2
- package/dist/layouts/ScrollContainer.js +1 -1
- package/dist/layouts/TabNavigatorLayout.d.ts +2 -2
- package/dist/layouts/TabNavigatorLayout.js +4 -0
- package/dist/primitives/AspectRatio.d.ts +10 -0
- package/dist/primitives/AspectRatio.js +8 -0
- package/dist/primitives/Box.d.ts +1 -1
- package/dist/primitives/Pressable.d.ts +10 -0
- package/dist/primitives/Pressable.js +9 -0
- package/dist/primitives/Row.d.ts +1 -1
- package/dist/primitives/Spacer.d.ts +8 -0
- package/dist/primitives/Spacer.js +9 -0
- package/dist/primitives/Stack.d.ts +1 -1
- package/dist/primitives/index.d.ts +3 -0
- package/dist/primitives/index.js +3 -0
- package/dist/theme/active.d.ts +2 -0
- package/dist/theme/active.js +13 -0
- package/dist/theme/components/ThemedActivityIndicator.d.ts +1 -1
- package/dist/theme/components/index.d.ts +1 -1
- package/dist/theme/components/index.js +1 -1
- package/dist/theme/dark.d.ts +7 -0
- package/dist/theme/dark.js +84 -0
- package/dist/theme/define.d.ts +5 -5
- package/dist/theme/define.js +5 -5
- package/dist/theme/index.d.ts +3 -1
- package/dist/theme/index.js +3 -1
- package/dist/theme/theme.d.ts +1 -1
- package/dist/theme/theme.js +1 -1
- package/dist/theme/types.d.ts +14 -14
- package/dist/theme/types.js +2 -2
- package/dist/theme/useTheme.d.ts +3 -1
- package/dist/theme/useTheme.js +6 -1
- package/dist/tokens/index.d.ts +2 -0
- package/dist/tokens/index.js +2 -0
- package/dist/tokens/motion.d.ts +71 -0
- package/dist/tokens/motion.js +25 -0
- package/dist/utils/date.d.ts +33 -33
- package/dist/utils/date.js +39 -39
- package/dist/views/AuthFormView.d.ts +1 -1
- package/dist/views/FormViewV2.context.d.ts +1 -1
- package/dist/views/FormViewV2.d.ts +10 -10
- package/dist/views/ListViewV2.context.d.ts +1 -1
- package/dist/views/ListViewV2.d.ts +20 -20
- package/dist/views/Wizard/Wizard.context.d.ts +1 -1
- package/dist/widgets/CircleButton.d.ts +6 -2
- package/dist/widgets/CircleButton.js +4 -0
- package/dist/widgets/GeoPermissionCard.d.ts +1 -1
- package/dist/widgets/HomeHeader.d.ts +4 -0
- package/dist/widgets/HomeHeader.js +4 -0
- package/dist/widgets/JSONViewer.d.ts +2 -1
- package/dist/widgets/JSONViewer.js +6 -6
- package/dist/widgets/MenuCard.d.ts +1 -1
- package/dist/widgets/ScreenHeader.d.ts +5 -1
- package/dist/widgets/ScreenHeader.js +4 -0
- package/dist/widgets/TimeZoneSelector.d.ts +1 -1
- package/dist/widgets/TimeZoneSelectorModal.d.ts +1 -1
- package/package.json +38 -25
- package/tailwind.preset.js +14 -0
- package/dist/notifications/index.d.ts +0 -1
- package/dist/notifications/index.js +0 -1
- package/dist/providers/index.d.ts +0 -1
- package/dist/providers/index.js +0 -2
package/dist/Display/index.js
CHANGED
|
@@ -1,17 +1,71 @@
|
|
|
1
|
+
import Accordion from "../Display/Display.Accordion";
|
|
1
2
|
import Avatar from "../Display/Display.Avatar";
|
|
3
|
+
import AvatarGroup from "../Display/Display.AvatarGroup";
|
|
2
4
|
import Badge, { BadgeVariants, } from "../Display/Display.Badge";
|
|
5
|
+
import Card from "../Display/Display.Card";
|
|
6
|
+
import Carousel from "../Display/Display.Carousel";
|
|
7
|
+
import Chip from "../Display/Display.Chip";
|
|
3
8
|
import CopyableText from "../Display/Display.CopyableText";
|
|
4
9
|
import CountRecords from "../Display/Display.CountRecords";
|
|
10
|
+
import DataTable from "../Display/Display.DataTable";
|
|
5
11
|
import Date from "../Display/Display.Date";
|
|
6
12
|
import Divider from "../Display/Display.Divider";
|
|
7
13
|
import Icon from "../Display/Display.Icon";
|
|
14
|
+
import IconBadge from "../Display/Display.IconBadge";
|
|
15
|
+
import DisplayImage from "../Display/Display.Image";
|
|
16
|
+
import KeyValue from "../Display/Display.KeyValue";
|
|
17
|
+
import ListItem from "../Display/Display.ListItem";
|
|
8
18
|
import Logo from "../Display/Display.Logo";
|
|
19
|
+
import MediaCard from "../Display/Display.MediaCard";
|
|
20
|
+
import MediaEmbed from "../Display/Display.MediaEmbed";
|
|
9
21
|
import MenuButton from "../Display/Display.MenuButton";
|
|
10
22
|
import Monetary from "../Display/Display.Monetary";
|
|
23
|
+
import PriceTag from "../Display/Display.PriceTag";
|
|
24
|
+
import ProductCard from "../Display/Display.ProductCard";
|
|
25
|
+
import Rating from "../Display/Display.Rating";
|
|
26
|
+
import SearchHistory from "../Display/Display.SearchHistory";
|
|
27
|
+
import SectionHeader from "../Display/Display.SectionHeader";
|
|
28
|
+
import Stat from "../Display/Display.Stat";
|
|
29
|
+
import StatCard from "../Display/Display.StatCard";
|
|
30
|
+
import StatusDot from "../Display/Display.StatusDot";
|
|
31
|
+
import Story from "../Display/Display.Story";
|
|
32
|
+
import StoryTray from "../Display/Display.StoryTray";
|
|
33
|
+
import StoryViewer from "../Display/Display.StoryViewer";
|
|
34
|
+
import SwipeableRow from "../Display/Display.SwipeableRow";
|
|
35
|
+
import Tag from "../Display/Display.Tag";
|
|
36
|
+
import Timeline from "../Display/Display.Timeline";
|
|
37
|
+
import Tooltip from "../Display/Display.Tooltip";
|
|
11
38
|
export const Display = {
|
|
12
39
|
Badge,
|
|
13
40
|
BadgeVariants,
|
|
41
|
+
Accordion,
|
|
14
42
|
Avatar,
|
|
43
|
+
AvatarGroup,
|
|
44
|
+
Card,
|
|
45
|
+
Carousel,
|
|
46
|
+
Chip,
|
|
47
|
+
Tag,
|
|
48
|
+
Image: DisplayImage,
|
|
49
|
+
MediaCard,
|
|
50
|
+
MediaEmbed,
|
|
51
|
+
Story,
|
|
52
|
+
StoryTray,
|
|
53
|
+
StoryViewer,
|
|
54
|
+
ListItem,
|
|
55
|
+
KeyValue,
|
|
56
|
+
DataTable,
|
|
57
|
+
Stat,
|
|
58
|
+
StatCard,
|
|
59
|
+
StatusDot,
|
|
60
|
+
PriceTag,
|
|
61
|
+
ProductCard,
|
|
62
|
+
Timeline,
|
|
63
|
+
SearchHistory,
|
|
64
|
+
SectionHeader,
|
|
65
|
+
Rating,
|
|
66
|
+
SwipeableRow,
|
|
67
|
+
Tooltip,
|
|
68
|
+
IconBadge,
|
|
15
69
|
CopyableText,
|
|
16
70
|
Date,
|
|
17
71
|
Divider,
|
|
@@ -13,6 +13,6 @@ export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBo
|
|
|
13
13
|
static getDerivedStateFromError(error: Error): ErrorBoundaryState;
|
|
14
14
|
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
|
|
15
15
|
handleRetry: () => void;
|
|
16
|
-
render(): string | number | bigint | boolean |
|
|
16
|
+
render(): string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
|
|
17
17
|
}
|
|
18
18
|
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type VariantProps } from "../theme/tw";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
declare const banner: import("tailwind-variants").TVReturnType<{
|
|
4
|
+
tone: {
|
|
5
|
+
info: {
|
|
6
|
+
root: string;
|
|
7
|
+
title: string;
|
|
8
|
+
};
|
|
9
|
+
success: {
|
|
10
|
+
root: string;
|
|
11
|
+
title: string;
|
|
12
|
+
};
|
|
13
|
+
warning: {
|
|
14
|
+
root: string;
|
|
15
|
+
title: string;
|
|
16
|
+
};
|
|
17
|
+
danger: {
|
|
18
|
+
root: string;
|
|
19
|
+
title: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}, {
|
|
23
|
+
root: string;
|
|
24
|
+
title: string;
|
|
25
|
+
message: string;
|
|
26
|
+
}, undefined, {
|
|
27
|
+
tone: {
|
|
28
|
+
info: {
|
|
29
|
+
root: string;
|
|
30
|
+
title: string;
|
|
31
|
+
};
|
|
32
|
+
success: {
|
|
33
|
+
root: string;
|
|
34
|
+
title: string;
|
|
35
|
+
};
|
|
36
|
+
warning: {
|
|
37
|
+
root: string;
|
|
38
|
+
title: string;
|
|
39
|
+
};
|
|
40
|
+
danger: {
|
|
41
|
+
root: string;
|
|
42
|
+
title: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
}, {
|
|
46
|
+
root: string;
|
|
47
|
+
title: string;
|
|
48
|
+
message: string;
|
|
49
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
50
|
+
tone: {
|
|
51
|
+
info: {
|
|
52
|
+
root: string;
|
|
53
|
+
title: string;
|
|
54
|
+
};
|
|
55
|
+
success: {
|
|
56
|
+
root: string;
|
|
57
|
+
title: string;
|
|
58
|
+
};
|
|
59
|
+
warning: {
|
|
60
|
+
root: string;
|
|
61
|
+
title: string;
|
|
62
|
+
};
|
|
63
|
+
danger: {
|
|
64
|
+
root: string;
|
|
65
|
+
title: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
}, {
|
|
69
|
+
root: string;
|
|
70
|
+
title: string;
|
|
71
|
+
message: string;
|
|
72
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
73
|
+
export interface BannerProps extends VariantProps<typeof banner> {
|
|
74
|
+
message: string;
|
|
75
|
+
title?: string;
|
|
76
|
+
onClose?: () => void;
|
|
77
|
+
action?: ReactNode;
|
|
78
|
+
className?: string;
|
|
79
|
+
testID?: string;
|
|
80
|
+
}
|
|
81
|
+
declare function Banner({ message, title, tone, onClose, action, className, testID, }: BannerProps): import("react").JSX.Element;
|
|
82
|
+
export default Banner;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "nativewind/jsx-runtime";
|
|
2
|
+
import Icon from "../Display/Display.Icon";
|
|
3
|
+
import Pressable from "../primitives/Pressable";
|
|
4
|
+
import { theme } from "../theme";
|
|
5
|
+
import { tv } from "../theme/tw";
|
|
6
|
+
import { Typography } from "../Typography";
|
|
7
|
+
import { View } from "react-native";
|
|
8
|
+
const banner = tv({
|
|
9
|
+
slots: {
|
|
10
|
+
root: "flex-row items-start gap-3 rounded-lg p-3 border",
|
|
11
|
+
title: "text-sm font-semibold",
|
|
12
|
+
message: "text-sm text-text-secondary",
|
|
13
|
+
},
|
|
14
|
+
variants: {
|
|
15
|
+
tone: {
|
|
16
|
+
info: { root: "bg-info-light border-info/30", title: "text-info" },
|
|
17
|
+
success: { root: "bg-success-light border-success/30", title: "text-success" },
|
|
18
|
+
warning: { root: "bg-warning-light border-warning/30", title: "text-warning" },
|
|
19
|
+
danger: { root: "bg-danger-light border-danger/30", title: "text-danger" },
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: { tone: "info" },
|
|
23
|
+
});
|
|
24
|
+
const iconByTone = {
|
|
25
|
+
info: { name: "information-circle", color: theme.info },
|
|
26
|
+
success: { name: "checkmark-circle", color: theme.success },
|
|
27
|
+
warning: { name: "warning", color: theme.warning },
|
|
28
|
+
danger: { name: "alert-circle", color: theme.danger },
|
|
29
|
+
};
|
|
30
|
+
function Banner({ message, title, tone = "info", onClose, action, className, testID, }) {
|
|
31
|
+
const styles = banner({ tone });
|
|
32
|
+
const icon = iconByTone[tone ?? "info"];
|
|
33
|
+
return (_jsxs(View, { className: styles.root({ className }), testID: testID, children: [_jsx(Icon, { color: icon.color, name: icon.name, size: 20 }), _jsxs(View, { className: "flex-1 gap-0.5", children: [title ? _jsx(Typography.Text, { className: styles.title(), children: title }) : null, _jsx(Typography.Text, { className: styles.message(), children: message }), action ? _jsx(View, { className: "mt-2", children: action }) : null] }), onClose ? (_jsx(Pressable, { accessibilityLabel: "Cerrar", hitSlop: 8, onPress: onClose, children: _jsx(Icon, { color: theme.icon.secondary, name: "close", size: 18 }) })) : null] }));
|
|
34
|
+
}
|
|
35
|
+
export default Banner;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type React from "react";
|
|
1
2
|
import { ReactNode } from "react";
|
|
2
3
|
interface DomainSplashScreenProps {
|
|
3
4
|
domainName: string;
|
|
@@ -6,5 +7,5 @@ interface DomainSplashScreenProps {
|
|
|
6
7
|
onComplete?: () => void;
|
|
7
8
|
minDuration?: number;
|
|
8
9
|
}
|
|
9
|
-
declare function DomainSplashScreen({ domainName, isLoading, children, onComplete, minDuration, }: DomainSplashScreenProps):
|
|
10
|
+
declare function DomainSplashScreen({ domainName, isLoading, children, onComplete, minDuration, }: DomainSplashScreenProps): React.JSX.Element;
|
|
10
11
|
export default DomainSplashScreen;
|
|
@@ -57,7 +57,7 @@ function DomainSplashScreen({ domainName, isLoading, children, onComplete, minDu
|
|
|
57
57
|
const splashStyle = useAnimatedStyle(() => ({
|
|
58
58
|
opacity: opacityValue.value,
|
|
59
59
|
}));
|
|
60
|
-
return (_jsxs(View, { style: styles.container, children: [children, _jsx(Animated.View, { pointerEvents: isLoading ? "auto" : "none", style: [StyleSheet.
|
|
60
|
+
return (_jsxs(View, { style: styles.container, children: [children, _jsx(Animated.View, { pointerEvents: isLoading ? "auto" : "none", style: [StyleSheet.absoluteFill, splashStyle], children: _jsx(GradientContainer, { className: "flex-1 justify-center items-center px-8", children: _jsxs(View, { className: "w-full items-center gap-6", children: [_jsx(Typography.Text, { className: "text-2xl font-bold text-white", children: isComplete ? "¡Listo!" : `Cargando ${domainName}` }), !isComplete && (_jsx(View, { className: "w-full bg-transparent border border-white/30 rounded-full h-4 overflow-hidden", children: _jsx(Animated.View, { className: "bg-white rounded-full h-4 shadow-lg", style: progressBarStyle }) })), isComplete && (_jsxs(Typography.Text, { className: "text-sm text-white/80", children: ["Ya puedes comenzar a usar ", domainName, "."] }))] }) }) })] }));
|
|
61
61
|
}
|
|
62
62
|
const styles = StyleSheet.create({
|
|
63
63
|
container: {
|
|
@@ -2,5 +2,5 @@ interface EmptyProps {
|
|
|
2
2
|
handleGoHome?: () => void;
|
|
3
3
|
className?: string;
|
|
4
4
|
}
|
|
5
|
-
declare function Empty({ handleGoHome, className }: EmptyProps): import("react
|
|
5
|
+
declare function Empty({ handleGoHome, className }: EmptyProps): import("react").JSX.Element;
|
|
6
6
|
export default Empty;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { type ImageSourcePropType } from "react-native";
|
|
3
|
+
export interface EmptyStateProps {
|
|
4
|
+
title: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
icon?: string;
|
|
7
|
+
image?: ImageSourcePropType;
|
|
8
|
+
actionLabel?: string;
|
|
9
|
+
onAction?: () => void;
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
className?: string;
|
|
12
|
+
testID?: string;
|
|
13
|
+
}
|
|
14
|
+
declare function EmptyState({ title, description, icon, image, actionLabel, onAction, children, className, testID, }: EmptyStateProps): import("react").JSX.Element;
|
|
15
|
+
export default EmptyState;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "nativewind/jsx-runtime";
|
|
2
|
+
import Icon from "../Display/Display.Icon";
|
|
3
|
+
import { BaseButton } from "../primitives/BaseButton";
|
|
4
|
+
import { theme } from "../theme";
|
|
5
|
+
import { cn } from "../theme/tw";
|
|
6
|
+
import { Typography } from "../Typography";
|
|
7
|
+
import { Image, View } from "react-native";
|
|
8
|
+
function EmptyState({ title, description, icon = "file-tray-outline", image, actionLabel, onAction, children, className, testID, }) {
|
|
9
|
+
return (_jsxs(View, { className: cn("flex-1 items-center justify-center px-8 gap-3", className), testID: testID, children: [image ? (_jsx(Image, { resizeMode: "contain", source: image, style: { width: 140, height: 140 } })) : (_jsx(View, { className: "w-20 h-20 rounded-full bg-bg-muted items-center justify-center", children: _jsx(Icon, { color: theme.icon.tertiary, name: icon, size: 40 }) })), _jsx(Typography.Text, { align: "center", className: "text-text-primary", semibold: true, variant: "subtitle", children: title }), description ? (_jsx(Typography.Text, { align: "center", className: "text-text-secondary", variant: "body", children: description })) : null, actionLabel && onAction ? (_jsx(View, { className: "mt-2", children: _jsx(BaseButton, { onPress: onAction, title: actionLabel, variant: "primary" }) })) : null, children] }));
|
|
10
|
+
}
|
|
11
|
+
export default EmptyState;
|
|
@@ -5,5 +5,5 @@ interface ErrorProps {
|
|
|
5
5
|
onHome?: () => void;
|
|
6
6
|
className?: string;
|
|
7
7
|
}
|
|
8
|
-
declare function Error({ message, onRetry, onBack, onHome, className }: ErrorProps): import("react
|
|
8
|
+
declare function Error({ message, onRetry, onBack, onHome, className }: ErrorProps): import("react").JSX.Element;
|
|
9
9
|
export default Error;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type React from "react";
|
|
1
2
|
interface LoadingStateProps {
|
|
2
3
|
message?: string;
|
|
3
4
|
size?: "small" | "large";
|
|
4
5
|
style?: object;
|
|
5
6
|
className?: string;
|
|
6
7
|
}
|
|
7
|
-
declare function LoadingState({ message, size, style, className, }: LoadingStateProps):
|
|
8
|
+
declare function LoadingState({ message, size, style, className, }: LoadingStateProps): React.JSX.Element;
|
|
8
9
|
export default LoadingState;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface PermissionCardProps {
|
|
2
|
+
title: string;
|
|
3
|
+
description?: string;
|
|
4
|
+
granted?: boolean;
|
|
5
|
+
icon?: string;
|
|
6
|
+
grantedLabel?: string;
|
|
7
|
+
deniedLabel?: string;
|
|
8
|
+
actionLabel?: string;
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
onRequest?: () => void;
|
|
11
|
+
className?: string;
|
|
12
|
+
testID?: string;
|
|
13
|
+
}
|
|
14
|
+
declare function PermissionCard({ title, description, granted, icon, grantedLabel, deniedLabel, actionLabel, loading, onRequest, className, testID, }: PermissionCardProps): import("react").JSX.Element;
|
|
15
|
+
export default PermissionCard;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "nativewind/jsx-runtime";
|
|
2
|
+
import Icon from "../Display/Display.Icon";
|
|
3
|
+
import { BaseButton } from "../primitives/BaseButton";
|
|
4
|
+
import { theme } from "../theme";
|
|
5
|
+
import { cn } from "../theme/tw";
|
|
6
|
+
import { Typography } from "../Typography";
|
|
7
|
+
import { View } from "react-native";
|
|
8
|
+
function PermissionCard({ title, description, granted = false, icon = "lock-closed", grantedLabel = "Permiso activo", deniedLabel = "Permiso inactivo", actionLabel = "Permitir", loading = false, onRequest, className, testID, }) {
|
|
9
|
+
return (_jsx(View, { className: cn("bg-bg-card rounded-xl p-4 border border-border-light", className), style: theme.shadow.sm, testID: testID, children: _jsxs(View, { className: "flex-row items-start gap-3", children: [_jsx(Icon, { color: granted ? theme.success : theme.danger, name: granted ? "checkmark-circle" : icon, size: 32 }), _jsxs(View, { className: "flex-1 gap-1", children: [_jsx(Typography.Text, { className: "text-text-primary", semibold: true, variant: "body", children: title }), description ? (_jsx(Typography.Text, { className: "text-text-secondary", variant: "bodySmall", children: description })) : null, _jsx(Typography.Text, { style: { color: granted ? theme.success : theme.danger }, variant: "bodySmall", children: granted ? grantedLabel : deniedLabel }), !granted && onRequest ? (_jsx(View, { className: "mt-2 self-start", children: _jsx(BaseButton, { loading: loading, onPress: onRequest, size: "small", title: actionLabel }) })) : null] })] }) }));
|
|
10
|
+
}
|
|
11
|
+
export default PermissionCard;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface ProgressProps {
|
|
2
|
+
value?: number;
|
|
3
|
+
indeterminate?: boolean;
|
|
4
|
+
height?: number;
|
|
5
|
+
className?: string;
|
|
6
|
+
testID?: string;
|
|
7
|
+
}
|
|
8
|
+
declare function Progress({ value, indeterminate, height, className, testID, }: ProgressProps): import("react").JSX.Element;
|
|
9
|
+
export default Progress;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "nativewind/jsx-runtime";
|
|
2
|
+
import { cn } from "../theme/tw";
|
|
3
|
+
import { motion } from "../tokens/motion";
|
|
4
|
+
import { useEffect, useRef } from "react";
|
|
5
|
+
import { Animated, Easing, View } from "react-native";
|
|
6
|
+
function clamp(n) {
|
|
7
|
+
return Math.max(0, Math.min(1, n));
|
|
8
|
+
}
|
|
9
|
+
function Progress({ value = 0, indeterminate = false, height = 6, className, testID, }) {
|
|
10
|
+
const translate = useRef(new Animated.Value(0)).current;
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!indeterminate)
|
|
13
|
+
return;
|
|
14
|
+
const loop = Animated.loop(Animated.timing(translate, {
|
|
15
|
+
toValue: 1,
|
|
16
|
+
duration: motion.duration.slower,
|
|
17
|
+
easing: Easing.inOut(Easing.ease),
|
|
18
|
+
useNativeDriver: true,
|
|
19
|
+
}));
|
|
20
|
+
loop.start();
|
|
21
|
+
return () => loop.stop();
|
|
22
|
+
}, [indeterminate, translate]);
|
|
23
|
+
return (_jsx(View, { accessibilityRole: "progressbar", accessibilityValue: indeterminate ? undefined : { now: Math.round(clamp(value) * 100), min: 0, max: 100 }, className: cn("w-full overflow-hidden rounded-full bg-bg-muted", className), style: { height }, testID: testID, children: indeterminate ? (_jsx(Animated.View, { className: "h-full rounded-full bg-primary", style: {
|
|
24
|
+
width: "40%",
|
|
25
|
+
transform: [
|
|
26
|
+
{
|
|
27
|
+
translateX: translate.interpolate({
|
|
28
|
+
inputRange: [0, 1],
|
|
29
|
+
outputRange: ["-40%", "250%"],
|
|
30
|
+
}),
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
} })) : (_jsx(View, { className: "h-full rounded-full bg-primary", style: { width: `${clamp(value) * 100}%` } })) }));
|
|
34
|
+
}
|
|
35
|
+
export default Progress;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface ProgressCircleProps {
|
|
3
|
+
value?: number;
|
|
4
|
+
size?: number;
|
|
5
|
+
strokeWidth?: number;
|
|
6
|
+
color?: string;
|
|
7
|
+
trackColor?: string;
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
testID?: string;
|
|
10
|
+
}
|
|
11
|
+
declare function ProgressCircle({ value, size, strokeWidth, color, trackColor, children, testID, }: ProgressCircleProps): import("react").JSX.Element;
|
|
12
|
+
export default ProgressCircle;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "nativewind/jsx-runtime";
|
|
2
|
+
import { theme } from "../theme";
|
|
3
|
+
import { View } from "react-native";
|
|
4
|
+
import Svg, { Circle } from "react-native-svg";
|
|
5
|
+
function clamp(n) {
|
|
6
|
+
return Math.max(0, Math.min(1, n));
|
|
7
|
+
}
|
|
8
|
+
function ProgressCircle({ value = 0, size = 64, strokeWidth = 6, color, trackColor, children, testID, }) {
|
|
9
|
+
const radius = (size - strokeWidth) / 2;
|
|
10
|
+
const circumference = 2 * Math.PI * radius;
|
|
11
|
+
const offset = circumference * (1 - clamp(value));
|
|
12
|
+
const center = size / 2;
|
|
13
|
+
return (_jsxs(View, { accessibilityRole: "progressbar", accessibilityValue: { now: Math.round(clamp(value) * 100), min: 0, max: 100 }, style: { width: size, height: size, alignItems: "center", justifyContent: "center" }, testID: testID, children: [_jsxs(Svg, { height: size, style: { position: "absolute" }, width: size, children: [_jsx(Circle, { cx: center, cy: center, fill: "none", r: radius, stroke: trackColor ?? theme.bg.muted, strokeWidth: strokeWidth }), _jsx(Circle, { cx: center, cy: center, fill: "none", r: radius, stroke: color ?? theme.primary, strokeDasharray: `${circumference} ${circumference}`, strokeDashoffset: offset, strokeLinecap: "round", strokeWidth: strokeWidth, transform: `rotate(-90 ${center} ${center})` })] }), children] }));
|
|
14
|
+
}
|
|
15
|
+
export default ProgressCircle;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type DimensionValue, type ViewStyle } from "react-native";
|
|
2
|
+
export interface SkeletonProps {
|
|
3
|
+
width?: DimensionValue;
|
|
4
|
+
height?: DimensionValue;
|
|
5
|
+
radius?: number;
|
|
6
|
+
circle?: boolean;
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: ViewStyle;
|
|
9
|
+
}
|
|
10
|
+
declare function Skeleton({ width, height, radius, circle, className, style, }: SkeletonProps): import("react").JSX.Element;
|
|
11
|
+
export default Skeleton;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "nativewind/jsx-runtime";
|
|
2
|
+
import { cn } from "../theme/tw";
|
|
3
|
+
import { motion } from "../tokens/motion";
|
|
4
|
+
import { useEffect, useRef } from "react";
|
|
5
|
+
import { Animated, Easing } from "react-native";
|
|
6
|
+
function Skeleton({ width = "100%", height = 16, radius = 8, circle = false, className, style, }) {
|
|
7
|
+
const opacity = useRef(new Animated.Value(0.5)).current;
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const pulse = Animated.loop(Animated.sequence([
|
|
10
|
+
Animated.timing(opacity, {
|
|
11
|
+
toValue: 1,
|
|
12
|
+
duration: motion.duration.slow,
|
|
13
|
+
easing: Easing.inOut(Easing.ease),
|
|
14
|
+
useNativeDriver: true,
|
|
15
|
+
}),
|
|
16
|
+
Animated.timing(opacity, {
|
|
17
|
+
toValue: 0.5,
|
|
18
|
+
duration: motion.duration.slow,
|
|
19
|
+
easing: Easing.inOut(Easing.ease),
|
|
20
|
+
useNativeDriver: true,
|
|
21
|
+
}),
|
|
22
|
+
]));
|
|
23
|
+
pulse.start();
|
|
24
|
+
return () => pulse.stop();
|
|
25
|
+
}, [opacity]);
|
|
26
|
+
const resolvedRadius = circle && typeof height === "number" ? height / 2 : radius;
|
|
27
|
+
return (_jsx(Animated.View, { accessibilityElementsHidden: true, className: cn("bg-bg-muted", className), importantForAccessibility: "no-hide-descendants", style: [{ width, height, borderRadius: resolvedRadius }, style, { opacity }] }));
|
|
28
|
+
}
|
|
29
|
+
export default Skeleton;
|
|
@@ -7,5 +7,5 @@ interface SplashScreenProps {
|
|
|
7
7
|
message?: string;
|
|
8
8
|
children?: ReactNode;
|
|
9
9
|
}
|
|
10
|
-
declare function Splash({ isReady, logo, minDuration, message, children, }: SplashScreenProps): string | number | bigint | boolean | import("react
|
|
10
|
+
declare function Splash({ isReady, logo, minDuration, message, children, }: SplashScreenProps): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
|
|
11
11
|
export default Splash;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export type ToastVariant = "info" | "success" | "warning" | "danger" | "loading";
|
|
3
|
+
export interface ToastAction {
|
|
4
|
+
label: string;
|
|
5
|
+
onPress: () => void;
|
|
6
|
+
}
|
|
7
|
+
export interface ToastOptions {
|
|
8
|
+
message: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
variant?: ToastVariant;
|
|
11
|
+
duration?: number;
|
|
12
|
+
action?: ToastAction;
|
|
13
|
+
}
|
|
14
|
+
type MessageOrFn<T> = string | ((value: T) => string);
|
|
15
|
+
export interface ToastPromiseMessages<T> {
|
|
16
|
+
loading: string;
|
|
17
|
+
success: MessageOrFn<T>;
|
|
18
|
+
error: MessageOrFn<unknown>;
|
|
19
|
+
}
|
|
20
|
+
export interface ToastContextValue {
|
|
21
|
+
show: (options: ToastOptions) => string;
|
|
22
|
+
update: (id: string, options: Partial<ToastOptions>) => void;
|
|
23
|
+
hide: (id: string) => void;
|
|
24
|
+
info: (message: string, options?: Omit<ToastOptions, "message" | "variant">) => string;
|
|
25
|
+
success: (message: string, options?: Omit<ToastOptions, "message" | "variant">) => string;
|
|
26
|
+
warning: (message: string, options?: Omit<ToastOptions, "message" | "variant">) => string;
|
|
27
|
+
danger: (message: string, options?: Omit<ToastOptions, "message" | "variant">) => string;
|
|
28
|
+
loading: (message: string, options?: Omit<ToastOptions, "message" | "variant">) => string;
|
|
29
|
+
promise: <T>(promise: Promise<T>, messages: ToastPromiseMessages<T>) => Promise<T>;
|
|
30
|
+
}
|
|
31
|
+
export declare function ToastProvider({ children }: {
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
}): import("react").JSX.Element;
|
|
34
|
+
export declare function useToast(): ToastContextValue;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "nativewind/jsx-runtime";
|
|
2
|
+
import Icon from "../Display/Display.Icon";
|
|
3
|
+
import Pressable from "../primitives/Pressable";
|
|
4
|
+
import { theme } from "../theme";
|
|
5
|
+
import { tv } from "../theme/tw";
|
|
6
|
+
import { Typography } from "../Typography";
|
|
7
|
+
import { createContext, useCallback, useContext, useMemo, useRef, useState, } from "react";
|
|
8
|
+
import { ActivityIndicator, View } from "react-native";
|
|
9
|
+
import Animated, { FadeInDown, FadeOutDown } from "react-native-reanimated";
|
|
10
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
11
|
+
const ToastContext = createContext(null);
|
|
12
|
+
const DEFAULT_DURATION = 3500;
|
|
13
|
+
const toast = tv({
|
|
14
|
+
slots: {
|
|
15
|
+
root: "flex-row items-center gap-3 rounded-lg px-4 py-3 bg-bg-card border-l-4 shadow-lg",
|
|
16
|
+
title: "text-sm font-semibold text-text-primary",
|
|
17
|
+
message: "text-sm text-text-secondary",
|
|
18
|
+
},
|
|
19
|
+
variants: {
|
|
20
|
+
variant: {
|
|
21
|
+
info: { root: "border-info" },
|
|
22
|
+
success: { root: "border-success" },
|
|
23
|
+
warning: { root: "border-warning" },
|
|
24
|
+
danger: { root: "border-danger" },
|
|
25
|
+
loading: { root: "border-primary" },
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
defaultVariants: { variant: "info" },
|
|
29
|
+
});
|
|
30
|
+
const iconByVariant = {
|
|
31
|
+
info: { name: "information-circle", color: theme.info },
|
|
32
|
+
success: { name: "checkmark-circle", color: theme.success },
|
|
33
|
+
warning: { name: "warning", color: theme.warning },
|
|
34
|
+
danger: { name: "close-circle", color: theme.danger },
|
|
35
|
+
};
|
|
36
|
+
function ToastItem({ entry, onHide }) {
|
|
37
|
+
const variant = entry.variant ?? "info";
|
|
38
|
+
const styles = toast({ variant });
|
|
39
|
+
return (_jsxs(Animated.View, { accessibilityLiveRegion: "polite", accessible: true, className: styles.root(), entering: FadeInDown.duration(220), exiting: FadeOutDown.duration(180), children: [variant === "loading" ? (_jsx(ActivityIndicator, { color: theme.primary, size: "small" })) : (_jsx(Icon, { color: iconByVariant[variant].color, name: iconByVariant[variant].name, size: 22 })), _jsxs(View, { className: "flex-1", children: [entry.title ? (_jsx(Typography.Text, { className: styles.title(), children: entry.title })) : null, _jsx(Typography.Text, { className: styles.message(), children: entry.message })] }), entry.action ? (_jsx(Pressable, { accessibilityLabel: entry.action.label, onPress: () => {
|
|
40
|
+
entry.action?.onPress();
|
|
41
|
+
onHide(entry.id);
|
|
42
|
+
}, children: _jsx(Typography.Text, { className: "text-primary text-sm font-semibold", children: entry.action.label }) })) : null] }));
|
|
43
|
+
}
|
|
44
|
+
export function ToastProvider({ children }) {
|
|
45
|
+
const insets = useSafeAreaInsets();
|
|
46
|
+
const [toasts, setToasts] = useState([]);
|
|
47
|
+
const counter = useRef(0);
|
|
48
|
+
const timers = useRef({});
|
|
49
|
+
const clearTimer = useCallback((id) => {
|
|
50
|
+
const timer = timers.current[id];
|
|
51
|
+
if (timer) {
|
|
52
|
+
clearTimeout(timer);
|
|
53
|
+
delete timers.current[id];
|
|
54
|
+
}
|
|
55
|
+
}, []);
|
|
56
|
+
const hide = useCallback((id) => {
|
|
57
|
+
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
58
|
+
clearTimer(id);
|
|
59
|
+
}, [clearTimer]);
|
|
60
|
+
const scheduleDismiss = useCallback((id, variant, duration) => {
|
|
61
|
+
clearTimer(id);
|
|
62
|
+
const resolved = duration ?? (variant === "loading" ? 0 : DEFAULT_DURATION);
|
|
63
|
+
if (resolved > 0) {
|
|
64
|
+
timers.current[id] = setTimeout(() => hide(id), resolved);
|
|
65
|
+
}
|
|
66
|
+
}, [clearTimer, hide]);
|
|
67
|
+
const show = useCallback((options) => {
|
|
68
|
+
counter.current += 1;
|
|
69
|
+
const id = `toast-${counter.current}`;
|
|
70
|
+
setToasts((prev) => [...prev, { ...options, id }]);
|
|
71
|
+
scheduleDismiss(id, options.variant, options.duration);
|
|
72
|
+
return id;
|
|
73
|
+
}, [scheduleDismiss]);
|
|
74
|
+
const update = useCallback((id, options) => {
|
|
75
|
+
setToasts((prev) => prev.map((t) => (t.id === id ? { ...t, ...options } : t)));
|
|
76
|
+
scheduleDismiss(id, options.variant, options.duration);
|
|
77
|
+
}, [scheduleDismiss]);
|
|
78
|
+
const value = useMemo(() => {
|
|
79
|
+
const promise = (p, messages) => {
|
|
80
|
+
const id = show({ message: messages.loading, variant: "loading", duration: 0 });
|
|
81
|
+
return p.then((result) => {
|
|
82
|
+
const msg = messages.success;
|
|
83
|
+
update(id, {
|
|
84
|
+
message: typeof msg === "function" ? msg(result) : msg,
|
|
85
|
+
variant: "success",
|
|
86
|
+
duration: DEFAULT_DURATION,
|
|
87
|
+
});
|
|
88
|
+
return result;
|
|
89
|
+
}, (err) => {
|
|
90
|
+
const msg = messages.error;
|
|
91
|
+
update(id, {
|
|
92
|
+
message: typeof msg === "function" ? msg(err) : msg,
|
|
93
|
+
variant: "danger",
|
|
94
|
+
duration: DEFAULT_DURATION,
|
|
95
|
+
});
|
|
96
|
+
throw err;
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
return {
|
|
100
|
+
show,
|
|
101
|
+
update,
|
|
102
|
+
hide,
|
|
103
|
+
info: (message, options) => show({ ...options, message, variant: "info" }),
|
|
104
|
+
success: (message, options) => show({ ...options, message, variant: "success" }),
|
|
105
|
+
warning: (message, options) => show({ ...options, message, variant: "warning" }),
|
|
106
|
+
danger: (message, options) => show({ ...options, message, variant: "danger" }),
|
|
107
|
+
loading: (message, options) => show({ ...options, message, variant: "loading" }),
|
|
108
|
+
promise,
|
|
109
|
+
};
|
|
110
|
+
}, [show, update, hide]);
|
|
111
|
+
return (_jsxs(ToastContext.Provider, { value: value, children: [children, _jsx(View, { className: "absolute left-0 right-0 px-4 gap-2 z-toast", pointerEvents: "box-none", style: { bottom: insets.bottom + 12 }, children: toasts.map((entry) => (_jsx(ToastItem, { entry: entry, onHide: hide }, entry.id))) })] }));
|
|
112
|
+
}
|
|
113
|
+
export function useToast() {
|
|
114
|
+
const ctx = useContext(ToastContext);
|
|
115
|
+
if (!ctx) {
|
|
116
|
+
throw new Error("useToast debe usarse dentro de <ToastProvider>");
|
|
117
|
+
}
|
|
118
|
+
return ctx;
|
|
119
|
+
}
|
package/dist/Feedback/index.d.ts
CHANGED
|
@@ -1,13 +1,28 @@
|
|
|
1
|
+
import Banner from "../Feedback/Feedback.Banner";
|
|
1
2
|
import DomainSplashScreen from "../Feedback/Feedback.DomainSplashScreen";
|
|
2
3
|
import Empty from "../Feedback/Feedback.Empty";
|
|
4
|
+
import EmptyState from "../Feedback/Feedback.EmptyState";
|
|
3
5
|
import Error from "../Feedback/Feedback.Error";
|
|
4
6
|
import Loading from "../Feedback/Feedback.Loading";
|
|
7
|
+
import PermissionCard from "../Feedback/Feedback.PermissionCard";
|
|
8
|
+
import Progress from "../Feedback/Feedback.Progress";
|
|
9
|
+
import ProgressCircle from "../Feedback/Feedback.ProgressCircle";
|
|
10
|
+
import Skeleton from "../Feedback/Feedback.Skeleton";
|
|
11
|
+
import SplashScreen from "../Feedback/Feedback.Splash";
|
|
5
12
|
export { ErrorBoundary } from "../Feedback/ErrorBoundary";
|
|
13
|
+
export { type ToastAction, type ToastContextValue, type ToastOptions, type ToastPromiseMessages, ToastProvider, type ToastVariant, useToast, } from "../Feedback/Toast.context";
|
|
6
14
|
export declare const Feedback: {
|
|
7
15
|
Loading: typeof Loading;
|
|
8
16
|
Spinner: import("react").FC<import("../Feedback/Feedback.Spinner").SpinnerProps>;
|
|
17
|
+
Skeleton: typeof Skeleton;
|
|
18
|
+
Progress: typeof Progress;
|
|
19
|
+
ProgressCircle: typeof ProgressCircle;
|
|
20
|
+
Banner: typeof Banner;
|
|
21
|
+
PermissionCard: typeof PermissionCard;
|
|
9
22
|
Empty: typeof Empty;
|
|
23
|
+
EmptyState: typeof EmptyState;
|
|
10
24
|
Error: typeof Error;
|
|
25
|
+
SplashScreen: typeof SplashScreen;
|
|
11
26
|
DomainSplashScreen: typeof DomainSplashScreen;
|
|
12
27
|
};
|
|
13
28
|
export default Feedback;
|