@sincpro/mobile-ui 3.0.1 → 3.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.
- package/dist/Actions/Actions.Button.d.ts +6 -6
- package/dist/Actions/Actions.Button.js +650 -180
- package/dist/Actions/Actions.Dock.d.ts +1 -1
- package/dist/Actions/Actions.Dock.js +297 -18
- package/dist/Actions/Actions.FAB.js +100 -12
- package/dist/Actions/Actions.FilterButton.d.ts +17 -0
- package/dist/Actions/Actions.FilterButton.js +263 -33
- package/dist/Actions/Actions.IconButton.d.ts +1 -0
- package/dist/Actions/Actions.IconButton.js +196 -33
- package/dist/Actions/index.js +13 -13
- package/dist/Dialog/Confirmation.context.js +82 -16
- package/dist/Dialog/Dialog.ActionSheet.js +200 -41
- package/dist/Dialog/Dialog.Confirmation.js +168 -31
- package/dist/Dialog/Dialog.EditValue.js +437 -62
- package/dist/Dialog/Dialog.Sheet.d.ts +7 -3
- package/dist/Dialog/Dialog.Sheet.js +267 -15
- package/dist/Dialog/OverlayHost.d.ts +24 -0
- package/dist/Dialog/OverlayHost.js +230 -0
- package/dist/Dialog/SheetSurface.d.ts +43 -0
- package/dist/Dialog/SheetSurface.js +495 -0
- package/dist/Dialog/dialog-actions.d.ts +17 -0
- package/dist/Dialog/dialog-actions.js +59 -0
- package/dist/Dialog/index.d.ts +4 -1
- package/dist/Dialog/index.js +8 -7
- package/dist/Dialog/overlay.store.d.ts +24 -0
- package/dist/Dialog/overlay.store.js +59 -0
- package/dist/Dialog/requestConfirmation.js +20 -10
- package/dist/Display/Display.Accordion.js +185 -13
- package/dist/Display/Display.AmountSummary.js +206 -15
- package/dist/Display/Display.Avatar.js +93 -31
- package/dist/Display/Display.AvatarGroup.js +132 -17
- package/dist/Display/Display.Badge.d.ts +18 -2
- package/dist/Display/Display.Badge.js +117 -49
- package/dist/Display/Display.Card.js +163 -26
- package/dist/Display/Display.Carousel.js +459 -105
- package/dist/Display/Display.Chip.d.ts +4 -1
- package/dist/Display/Display.Chip.js +165 -31
- package/dist/Display/Display.CircleButton.d.ts +1 -0
- package/dist/Display/Display.CircleButton.js +86 -27
- package/dist/Display/Display.CopyableText.js +289 -66
- package/dist/Display/Display.CountRecords.js +60 -3
- package/dist/Display/Display.DataTable.js +123 -13
- package/dist/Display/Display.Date.js +243 -33
- package/dist/Display/Display.Divider.d.ts +10 -10
- package/dist/Display/Display.Divider.js +67 -20
- package/dist/Display/Display.ExpoImage.js +97 -8
- package/dist/Display/Display.GradientSurface.d.ts +9 -4
- package/dist/Display/Display.GradientSurface.js +196 -46
- package/dist/Display/Display.Icon.js +129 -15
- package/dist/Display/Display.IconBadge.js +95 -25
- package/dist/Display/Display.Image.d.ts +7 -1
- package/dist/Display/Display.Image.js +344 -39
- package/dist/Display/Display.KeyValue.js +90 -5
- package/dist/Display/Display.ListGroup.js +181 -9
- package/dist/Display/Display.ListItem.js +324 -28
- package/dist/Display/Display.Logo.js +84 -29
- package/dist/Display/Display.MediaCard.js +125 -4
- package/dist/Display/Display.MediaEmbed.d.ts +0 -5
- package/dist/Display/Display.MediaEmbed.js +170 -26
- package/dist/Display/Display.MenuButton.d.ts +2 -2
- package/dist/Display/Display.MenuButton.js +380 -94
- package/dist/Display/Display.MenuCard.js +122 -18
- package/dist/Display/Display.MenuGrid.js +43 -3
- package/dist/Display/Display.Monetary.js +90 -5
- package/dist/Display/Display.Pattern.js +306 -47
- package/dist/Display/Display.PriceTag.js +117 -14
- package/dist/Display/Display.ProductCard.js +154 -4
- package/dist/Display/Display.Rating.js +92 -11
- package/dist/Display/Display.SearchHistory.js +132 -6
- package/dist/Display/Display.SectionHeader.d.ts +5 -1
- package/dist/Display/Display.SectionHeader.js +125 -12
- package/dist/Display/Display.Stat.js +62 -3
- package/dist/Display/Display.StatCard.js +131 -7
- package/dist/Display/Display.StatusBadge.d.ts +29 -0
- package/dist/Display/Display.StatusBadge.js +68 -0
- package/dist/Display/Display.StatusDot.js +93 -18
- package/dist/Display/Display.Story.js +285 -35
- package/dist/Display/Display.StoryTray.js +354 -34
- package/dist/Display/Display.StoryViewer.js +571 -72
- package/dist/Display/Display.SwipeableRow.js +148 -20
- package/dist/Display/Display.Tag.d.ts +4 -1
- package/dist/Display/Display.Tag.js +66 -4
- package/dist/Display/Display.Timeline.js +102 -13
- package/dist/Display/Display.Tooltip.js +122 -26
- package/dist/Display/chevron.d.ts +6 -0
- package/dist/Display/chevron.js +32 -0
- package/dist/Display/count-badge.d.ts +21 -0
- package/dist/Display/count-badge.js +124 -0
- package/dist/Display/group-title.d.ts +10 -0
- package/dist/Display/group-title.js +53 -0
- package/dist/Display/icon-font.d.ts +3 -0
- package/dist/Display/icon-font.ios.d.ts +3 -0
- package/dist/Display/icon-font.ios.js +4 -0
- package/dist/Display/icon-font.js +7 -0
- package/dist/Display/icon-glyphs.d.ts +2 -0
- package/dist/Display/icon-glyphs.js +87 -0
- package/dist/Display/icon-map.d.ts +15 -11
- package/dist/Display/icon-map.js +344 -84
- package/dist/Display/icon-registry.d.ts +21 -0
- package/dist/Display/icon-registry.js +21 -0
- package/dist/Display/index.d.ts +6 -1
- package/dist/Display/index.js +53 -48
- package/dist/Display/pill.d.ts +16 -0
- package/dist/Display/pill.js +47 -0
- package/dist/Feedback/ErrorBoundary.js +35 -23
- package/dist/Feedback/Feedback.Banner.js +202 -24
- package/dist/Feedback/Feedback.DomainSplashScreen.js +246 -70
- package/dist/Feedback/Feedback.Empty.js +54 -3
- package/dist/Feedback/Feedback.EmptyState.js +114 -5
- package/dist/Feedback/Feedback.Error.d.ts +1 -1
- package/dist/Feedback/Feedback.Error.js +130 -5
- package/dist/Feedback/Feedback.Loading.d.ts +1 -1
- package/dist/Feedback/Feedback.Loading.js +70 -3
- package/dist/Feedback/Feedback.PermissionCard.js +161 -5
- package/dist/Feedback/Feedback.Progress.js +199 -41
- package/dist/Feedback/Feedback.ProgressCircle.js +184 -12
- package/dist/Feedback/Feedback.Skeleton.js +149 -36
- package/dist/Feedback/Feedback.Spinner.js +407 -79
- package/dist/Feedback/Feedback.Splash.js +240 -33
- package/dist/Feedback/Feedback.State.d.ts +17 -0
- package/dist/Feedback/Feedback.State.js +104 -0
- package/dist/Feedback/Toast.context.js +883 -167
- package/dist/Feedback/index.d.ts +3 -0
- package/dist/Feedback/index.js +15 -13
- package/dist/Form/Form.Checkbox.js +212 -22
- package/dist/Form/Form.ControlledCheckbox.d.ts +1 -1
- package/dist/Form/Form.ControlledCheckbox.js +46 -4
- package/dist/Form/Form.ControlledDropdown.d.ts +1 -1
- package/dist/Form/Form.ControlledDropdown.js +62 -4
- package/dist/Form/Form.ControlledInput.d.ts +4 -3
- package/dist/Form/Form.ControlledInput.js +72 -4
- package/dist/Form/Form.ControlledMonetaryInput.d.ts +6 -3
- package/dist/Form/Form.ControlledMonetaryInput.js +50 -4
- package/dist/Form/Form.ControlledRadioButton.d.ts +2 -2
- package/dist/Form/Form.ControlledRadioButton.js +45 -4
- package/dist/Form/Form.DatePicker.js +507 -107
- package/dist/Form/Form.Dropdown.js +303 -52
- package/dist/Form/Form.ErrorSummary.js +236 -44
- package/dist/Form/Form.Field.d.ts +24 -0
- package/dist/Form/Form.Field.js +55 -0
- package/dist/Form/Form.FractionalQuantityInput.js +508 -96
- package/dist/Form/Form.Input.d.ts +17 -3
- package/dist/Form/Form.Input.js +497 -29
- package/dist/Form/Form.KeyboardForm.d.ts +22 -8
- package/dist/Form/Form.KeyboardForm.js +83 -8
- package/dist/Form/Form.KeyboardToolbarHost.d.ts +14 -0
- package/dist/Form/Form.KeyboardToolbarHost.js +223 -0
- package/dist/Form/Form.MonetaryInput.js +164 -17
- package/dist/Form/Form.PickerField.d.ts +31 -0
- package/dist/Form/Form.PickerField.js +539 -0
- package/dist/Form/Form.PinInput.js +150 -15
- package/dist/Form/Form.QuantitySelector.js +229 -25
- package/dist/Form/Form.RadioButton.d.ts +1 -0
- package/dist/Form/Form.RadioButton.js +26 -29
- package/dist/Form/Form.Select.d.ts +2 -1
- package/dist/Form/Form.Select.js +388 -60
- package/dist/Form/Form.Slider.js +133 -10
- package/dist/Form/Form.Switch.js +99 -4
- package/dist/Form/choice-row.d.ts +15 -0
- package/dist/Form/choice-row.js +236 -0
- package/dist/Form/index.d.ts +11 -6
- package/dist/Form/index.js +26 -27
- package/dist/Form/input-text.d.ts +7 -0
- package/dist/Form/input-text.js +18 -0
- package/dist/Navigation/Navigation.AppBar.d.ts +3 -4
- package/dist/Navigation/Navigation.AppBar.js +535 -99
- package/dist/Navigation/Navigation.BottomNav.js +363 -98
- package/dist/Navigation/Navigation.CollapsingHeader.d.ts +28 -13
- package/dist/Navigation/Navigation.CollapsingHeader.js +369 -36
- package/dist/Navigation/Navigation.FloatingBar.js +71 -11
- package/dist/Navigation/Navigation.Menu.js +309 -95
- package/dist/Navigation/Navigation.MenuSection.js +80 -11
- package/dist/Navigation/Navigation.RowItem.d.ts +4 -2
- package/dist/Navigation/Navigation.RowItem.js +93 -8
- package/dist/Navigation/Navigation.Search.js +241 -27
- package/dist/Navigation/Navigation.SearchBar.d.ts +7 -1
- package/dist/Navigation/Navigation.SearchBar.js +218 -29
- package/dist/Navigation/Navigation.SearchSuggestions.js +77 -3
- package/dist/Navigation/Navigation.SegmentedControl.js +152 -14
- package/dist/Navigation/Navigation.Steps.js +105 -11
- package/dist/Navigation/Navigation.Tabs.js +449 -41
- package/dist/Navigation/index.d.ts +9 -4
- package/dist/Navigation/index.js +13 -13
- package/dist/Typography/Typography.Heading.js +33 -3
- package/dist/Typography/Typography.SelectableText.js +95 -7
- package/dist/Typography/Typography.Text.d.ts +4 -2
- package/dist/Typography/Typography.Text.js +217 -7
- package/dist/Typography/index.js +3 -3
- package/dist/branding.js +29 -13
- package/dist/icons/AddItemIcon.js +76 -2
- package/dist/icons/ArrangeCircle.js +82 -2
- package/dist/icons/ArrowDownIcon.js +63 -3
- package/dist/icons/ArrowUpIcon.js +63 -3
- package/dist/icons/BoxIcon.js +64 -2
- package/dist/icons/BoxTimeIcon.js +63 -2
- package/dist/icons/CalendarIcon.js +145 -2
- package/dist/icons/CardIcon.js +80 -2
- package/dist/icons/CashierIcon.js +39 -2
- package/dist/icons/CreditIcon.js +76 -3
- package/dist/icons/DuoIcon.js +75 -2
- package/dist/icons/HomeIcon.js +39 -2
- package/dist/icons/HomeIconOutlined.js +53 -2
- package/dist/icons/LogoIcon.js +87 -2
- package/dist/icons/MoneyReceiveIcon.js +86 -2
- package/dist/icons/PinIcon.js +39 -2
- package/dist/icons/ProfileIcon.js +47 -2
- package/dist/icons/SettingsIcon.js +114 -2
- package/dist/icons/SinpeIcon.js +60 -2
- package/dist/icons/ToggleOffIcon.js +53 -2
- package/dist/icons/WalletMoneyIcon.js +81 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +8 -2
- package/dist/layouts/AuthContainer.d.ts +4 -5
- package/dist/layouts/AuthContainer.js +231 -7
- package/dist/layouts/BottomInset.js +4 -1
- package/dist/layouts/Container.d.ts +2 -2
- package/dist/layouts/Container.js +45 -3
- package/dist/layouts/GradientContainer.js +37 -5
- package/dist/layouts/PlainLayout.js +19 -3
- package/dist/layouts/ScrollContainer.d.ts +14 -9
- package/dist/layouts/ScrollContainer.js +125 -4
- package/dist/layouts/edges.d.ts +2 -0
- package/dist/layouts/edges.js +1 -0
- package/dist/primitives/AspectRatio.js +75 -3
- package/dist/primitives/Box.js +45 -3
- package/dist/primitives/Pressable.js +95 -5
- package/dist/primitives/Row.js +84 -13
- package/dist/primitives/Spacer.js +42 -5
- package/dist/primitives/Stack.js +66 -7
- package/dist/primitives/index.js +1 -1
- package/dist/theme/active.d.ts +2 -0
- package/dist/theme/active.js +33 -18
- package/dist/theme/build.js +118 -87
- package/dist/theme/color.js +87 -87
- package/dist/theme/components/ThemedActivityIndicator.d.ts +2 -15
- package/dist/theme/components/ThemedActivityIndicator.js +35 -3
- package/dist/theme/components/index.js +1 -0
- package/dist/theme/contrast.js +32 -33
- package/dist/theme/css-vars.js +71 -75
- package/dist/theme/dark.js +116 -97
- package/dist/theme/default.js +116 -97
- package/dist/theme/define.js +16 -12
- package/dist/theme/index.d.ts +1 -0
- package/dist/theme/index.js +7 -6
- package/dist/theme/on-dark-surface.d.ts +12 -0
- package/dist/theme/on-dark-surface.js +13 -0
- package/dist/theme/theme.js +1 -0
- package/dist/theme/tw.js +3 -1
- package/dist/theme/types.js +0 -18
- package/dist/theme/typography.d.ts +1 -1
- package/dist/theme/typography.js +337 -303
- package/dist/theme/useTheme.d.ts +4 -0
- package/dist/theme/useTheme.js +7 -3
- package/dist/theme/useThemeVars.d.ts +9 -0
- package/dist/theme/useThemeVars.js +23 -0
- package/dist/theme/validate.js +175 -166
- package/dist/tokens/index.js +1 -1
- package/dist/tokens/motion.js +30 -13
- package/dist/utils/async.d.ts +14 -0
- package/dist/utils/async.js +22 -0
- package/dist/utils/criteria.js +66 -85
- package/dist/utils/date.d.ts +8 -2
- package/dist/utils/date.js +63 -50
- package/dist/utils/image.js +8 -8
- package/dist/utils/intl.d.ts +1 -0
- package/dist/utils/intl.js +13 -0
- package/dist/utils/keys.js +3 -5
- package/dist/utils/monetary.d.ts +1 -0
- package/dist/utils/monetary.js +28 -24
- package/dist/utils/progress.js +2 -3
- package/dist/utils/quantity.js +25 -26
- package/dist/utils/reorder.js +11 -20
- package/dist/utils/search.d.ts +4 -0
- package/dist/utils/search.js +12 -0
- package/dist/utils/serializer.js +38 -38
- package/dist/utils/useReducedMotion.js +32 -30
- package/dist/views/AppSplashView.js +117 -3
- package/dist/views/AuthFormView.d.ts +4 -5
- package/dist/views/AuthFormView.js +119 -11
- package/dist/views/FormViewV2.context.js +75 -23
- package/dist/views/FormViewV2.d.ts +4 -5
- package/dist/views/FormViewV2.js +658 -92
- package/dist/views/ListViewV2.context.js +91 -47
- package/dist/views/ListViewV2.d.ts +84 -43
- package/dist/views/ListViewV2.js +1350 -200
- package/dist/views/Wizard/Wizard.context.js +248 -84
- package/dist/views/Wizard/Wizard.js +260 -67
- package/dist/views/types/IListView.js +34 -31
- package/dist/widgets/CollectionOptions.js +557 -138
- package/dist/widgets/FilterBar.js +159 -7
- package/dist/widgets/FilterBuilder.js +375 -102
- package/dist/widgets/JSONViewer.js +275 -129
- package/dist/widgets/PromoBanner.js +336 -42
- package/dist/widgets/PromoModal.d.ts +2 -2
- package/dist/widgets/PromoModal.js +389 -62
- package/dist/widgets/QueryChoice.js +150 -8
- package/dist/widgets/QuickActions.js +120 -31
- package/dist/widgets/ReorderableList.js +399 -128
- package/dist/widgets/TimeZoneSelectorModal.js +458 -51
- package/dist/widgets/index.js +3 -3
- package/package.json +6 -1
- package/tailwind.preset.js +7 -5
- package/dist/Form/Form.InputField.d.ts +0 -10
- package/dist/Form/Form.InputField.js +0 -38
- package/dist/Form/Form.KeyboardToolbar.d.ts +0 -22
- package/dist/Form/Form.KeyboardToolbar.js +0 -66
- package/dist/Form/Form.PasswordInput.d.ts +0 -9
- package/dist/Form/Form.PasswordInput.js +0 -17
- package/dist/Form/Form.TextInput.d.ts +0 -8
- package/dist/Form/Form.TextInput.js +0 -8
- package/dist/primitives/BaseButton.d.ts +0 -150
- package/dist/primitives/BaseButton.js +0 -229
- package/dist/utils/useSheetTranslation.d.ts +0 -5
- package/dist/utils/useSheetTranslation.js +0 -23
|
@@ -1,64 +1,315 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import Sheet from "../Dialog/Dialog.Sheet.js";
|
|
3
3
|
import Icon from "../Display/Display.Icon.js";
|
|
4
4
|
import Pressable from "../primitives/Pressable.js";
|
|
5
5
|
import { useTheme } from "../theme/index.js";
|
|
6
6
|
import { cn } from "../theme/tw.js";
|
|
7
7
|
import { Typography } from "../Typography/index.js";
|
|
8
|
+
import { attempt, errorMessage } from "../utils/async.js";
|
|
8
9
|
import { useRef, useState } from "react";
|
|
9
10
|
import { ActivityIndicator, View } from "react-native";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "nativewind/jsx-runtime";
|
|
12
|
+
function Dropdown(t0) {
|
|
13
|
+
const $ = _c(67);
|
|
14
|
+
const {
|
|
15
|
+
title,
|
|
16
|
+
options,
|
|
17
|
+
variant: t1,
|
|
18
|
+
size: t2,
|
|
19
|
+
disabled: t3,
|
|
20
|
+
readOnly: t4,
|
|
21
|
+
buttonProps,
|
|
22
|
+
renderOption,
|
|
23
|
+
testID
|
|
24
|
+
} = t0;
|
|
25
|
+
const variant = t1 === undefined ? "secondary" : t1;
|
|
26
|
+
const size = t2 === undefined ? "small" : t2;
|
|
27
|
+
const disabled = t3 === undefined ? false : t3;
|
|
28
|
+
const readOnly = t4 === undefined ? false : t4;
|
|
29
|
+
const theme = useTheme();
|
|
30
|
+
const saving = useRef(false);
|
|
31
|
+
const [open, setOpen] = useState(false);
|
|
32
|
+
const [pending, setPending] = useState();
|
|
33
|
+
const [error, setError] = useState();
|
|
34
|
+
const blocked = disabled || readOnly || pending !== undefined;
|
|
35
|
+
let t5;
|
|
36
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
37
|
+
t5 = () => {
|
|
38
|
+
if (!saving.current) {
|
|
39
|
+
setOpen(false);
|
|
40
|
+
}
|
|
20
41
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
$[0] = t5;
|
|
43
|
+
} else {
|
|
44
|
+
t5 = $[0];
|
|
45
|
+
}
|
|
46
|
+
const close = t5;
|
|
47
|
+
let T0;
|
|
48
|
+
let t10;
|
|
49
|
+
let t11;
|
|
50
|
+
let t6;
|
|
51
|
+
let t7;
|
|
52
|
+
let t8;
|
|
53
|
+
let t9;
|
|
54
|
+
if ($[1] !== blocked || $[2] !== buttonProps || $[3] !== open || $[4] !== options || $[5] !== pending || $[6] !== renderOption || $[7] !== size || $[8] !== testID || $[9] !== theme.primary || $[10] !== theme.text.accent || $[11] !== theme.text.onPrimary || $[12] !== title || $[13] !== variant) {
|
|
55
|
+
const choose = async option => {
|
|
56
|
+
if (blocked || option.disabled || saving.current) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
saving.current = true;
|
|
60
|
+
setPending(option.id);
|
|
61
|
+
setError(undefined);
|
|
62
|
+
const result = await attempt(async () => {
|
|
63
|
+
await option.onPress();
|
|
64
|
+
setOpen(false);
|
|
65
|
+
});
|
|
66
|
+
saving.current = false;
|
|
67
|
+
setPending(undefined);
|
|
68
|
+
if (!result.ok) {
|
|
69
|
+
setError(errorMessage(result.error, "No se pudo completar la acci\xF3n. Vuelve a intentarlo."));
|
|
70
|
+
}
|
|
40
71
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
72
|
+
const t12 = buttonProps?.accessibilityLabel ?? title;
|
|
73
|
+
const t13 = buttonProps?.accessibilityState;
|
|
74
|
+
let t14;
|
|
75
|
+
if ($[21] !== blocked || $[22] !== open || $[23] !== t13) {
|
|
76
|
+
t14 = {
|
|
77
|
+
...t13,
|
|
78
|
+
disabled: blocked,
|
|
79
|
+
expanded: open
|
|
80
|
+
};
|
|
81
|
+
$[21] = blocked;
|
|
82
|
+
$[22] = open;
|
|
83
|
+
$[23] = t13;
|
|
84
|
+
$[24] = t14;
|
|
85
|
+
} else {
|
|
86
|
+
t14 = $[24];
|
|
87
|
+
}
|
|
88
|
+
const t15 = variant === "primary" ? "bg-primary" : variant === "secondary" ? "bg-bg-card border border-primary" : "bg-transparent border border-primary";
|
|
89
|
+
const t16 = buttonProps?.className;
|
|
90
|
+
let t17;
|
|
91
|
+
if ($[25] !== t15 || $[26] !== t16) {
|
|
92
|
+
t17 = cn("flex-row items-center justify-between gap-3 rounded-lg px-3", t15, t16);
|
|
93
|
+
$[25] = t15;
|
|
94
|
+
$[26] = t16;
|
|
95
|
+
$[27] = t17;
|
|
96
|
+
} else {
|
|
97
|
+
t17 = $[27];
|
|
98
|
+
}
|
|
99
|
+
let t18;
|
|
100
|
+
if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
|
|
101
|
+
t18 = () => {
|
|
102
|
+
setError(undefined);
|
|
103
|
+
setOpen(true);
|
|
104
|
+
};
|
|
105
|
+
$[28] = t18;
|
|
106
|
+
} else {
|
|
107
|
+
t18 = $[28];
|
|
108
|
+
}
|
|
109
|
+
let t19;
|
|
110
|
+
if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
|
|
111
|
+
t19 = {
|
|
112
|
+
xs: 6,
|
|
113
|
+
small: 8,
|
|
114
|
+
medium: 10,
|
|
115
|
+
large: 12
|
|
116
|
+
};
|
|
117
|
+
$[29] = t19;
|
|
118
|
+
} else {
|
|
119
|
+
t19 = $[29];
|
|
120
|
+
}
|
|
121
|
+
const t20 = t19[size];
|
|
122
|
+
let t21;
|
|
123
|
+
if ($[30] !== t20) {
|
|
124
|
+
t21 = {
|
|
125
|
+
minHeight: 48,
|
|
126
|
+
minWidth: 48,
|
|
127
|
+
paddingVertical: t20
|
|
128
|
+
};
|
|
129
|
+
$[30] = t20;
|
|
130
|
+
$[31] = t21;
|
|
131
|
+
} else {
|
|
132
|
+
t21 = $[31];
|
|
133
|
+
}
|
|
134
|
+
const t22 = buttonProps?.style;
|
|
135
|
+
let t23;
|
|
136
|
+
if ($[32] !== t21 || $[33] !== t22) {
|
|
137
|
+
t23 = [t21, t22];
|
|
138
|
+
$[32] = t21;
|
|
139
|
+
$[33] = t22;
|
|
140
|
+
$[34] = t23;
|
|
141
|
+
} else {
|
|
142
|
+
t23 = $[34];
|
|
143
|
+
}
|
|
144
|
+
const t24 = variant === "primary" ? "text-text-on-primary" : "text-text-accent";
|
|
145
|
+
const t25 = size === "large" || size === "medium" ? "body" : "bodySmall";
|
|
146
|
+
let t26;
|
|
147
|
+
if ($[35] !== t24 || $[36] !== t25 || $[37] !== title) {
|
|
148
|
+
t26 = _jsx(Typography.Text, {
|
|
149
|
+
className: t24,
|
|
150
|
+
variant: t25,
|
|
151
|
+
children: title
|
|
152
|
+
});
|
|
153
|
+
$[35] = t24;
|
|
154
|
+
$[36] = t25;
|
|
155
|
+
$[37] = title;
|
|
156
|
+
$[38] = t26;
|
|
157
|
+
} else {
|
|
158
|
+
t26 = $[38];
|
|
159
|
+
}
|
|
160
|
+
const t27 = variant === "primary" ? theme.text.onPrimary : theme.text.accent;
|
|
161
|
+
let t28;
|
|
162
|
+
if ($[39] !== t27) {
|
|
163
|
+
t28 = _jsx(Icon, {
|
|
164
|
+
color: t27,
|
|
165
|
+
name: "expand",
|
|
166
|
+
size: 16
|
|
167
|
+
});
|
|
168
|
+
$[39] = t27;
|
|
169
|
+
$[40] = t28;
|
|
170
|
+
} else {
|
|
171
|
+
t28 = $[40];
|
|
172
|
+
}
|
|
173
|
+
if ($[41] !== blocked || $[42] !== buttonProps || $[43] !== t12 || $[44] !== t14 || $[45] !== t17 || $[46] !== t23 || $[47] !== t26 || $[48] !== t28 || $[49] !== testID) {
|
|
174
|
+
t11 = _jsxs(Pressable, {
|
|
175
|
+
...buttonProps,
|
|
176
|
+
accessibilityLabel: t12,
|
|
177
|
+
accessibilityRole: "button",
|
|
178
|
+
accessibilityState: t14,
|
|
179
|
+
className: t17,
|
|
180
|
+
disabled: blocked,
|
|
181
|
+
onPress: t18,
|
|
182
|
+
style: t23,
|
|
183
|
+
testID: testID,
|
|
184
|
+
children: [t26, t28]
|
|
185
|
+
});
|
|
186
|
+
$[41] = blocked;
|
|
187
|
+
$[42] = buttonProps;
|
|
188
|
+
$[43] = t12;
|
|
189
|
+
$[44] = t14;
|
|
190
|
+
$[45] = t17;
|
|
191
|
+
$[46] = t23;
|
|
192
|
+
$[47] = t26;
|
|
193
|
+
$[48] = t28;
|
|
194
|
+
$[49] = testID;
|
|
195
|
+
$[50] = t11;
|
|
196
|
+
} else {
|
|
197
|
+
t11 = $[50];
|
|
198
|
+
}
|
|
199
|
+
T0 = Sheet;
|
|
200
|
+
t6 = pending === undefined;
|
|
201
|
+
t7 = close;
|
|
202
|
+
t8 = title;
|
|
203
|
+
t9 = open;
|
|
204
|
+
t10 = options.map(option_0 => _jsxs(Pressable, {
|
|
205
|
+
accessibilityLabel: option_0.title,
|
|
206
|
+
accessibilityRole: "button",
|
|
207
|
+
accessibilityState: {
|
|
208
|
+
disabled: blocked || !!option_0.disabled,
|
|
209
|
+
busy: pending === option_0.id
|
|
210
|
+
},
|
|
211
|
+
className: "flex-row items-center gap-3 border-b border-border-light py-3",
|
|
212
|
+
disabled: blocked || option_0.disabled,
|
|
213
|
+
onPress: () => void choose(option_0),
|
|
214
|
+
style: {
|
|
215
|
+
minHeight: 48,
|
|
216
|
+
minWidth: 48
|
|
217
|
+
},
|
|
218
|
+
children: [_jsx(View, {
|
|
219
|
+
className: "flex-1",
|
|
220
|
+
children: renderOption ? renderOption(option_0) : _jsx(Typography.Text, {
|
|
221
|
+
className: option_0.disabled ? "text-text-disabled" : "text-text-primary",
|
|
222
|
+
children: option_0.title
|
|
223
|
+
})
|
|
224
|
+
}), pending === option_0.id ? _jsx(ActivityIndicator, {
|
|
225
|
+
color: theme.primary
|
|
226
|
+
}) : null]
|
|
227
|
+
}, option_0.id));
|
|
228
|
+
$[1] = blocked;
|
|
229
|
+
$[2] = buttonProps;
|
|
230
|
+
$[3] = open;
|
|
231
|
+
$[4] = options;
|
|
232
|
+
$[5] = pending;
|
|
233
|
+
$[6] = renderOption;
|
|
234
|
+
$[7] = size;
|
|
235
|
+
$[8] = testID;
|
|
236
|
+
$[9] = theme.primary;
|
|
237
|
+
$[10] = theme.text.accent;
|
|
238
|
+
$[11] = theme.text.onPrimary;
|
|
239
|
+
$[12] = title;
|
|
240
|
+
$[13] = variant;
|
|
241
|
+
$[14] = T0;
|
|
242
|
+
$[15] = t10;
|
|
243
|
+
$[16] = t11;
|
|
244
|
+
$[17] = t6;
|
|
245
|
+
$[18] = t7;
|
|
246
|
+
$[19] = t8;
|
|
247
|
+
$[20] = t9;
|
|
248
|
+
} else {
|
|
249
|
+
T0 = $[14];
|
|
250
|
+
t10 = $[15];
|
|
251
|
+
t11 = $[16];
|
|
252
|
+
t6 = $[17];
|
|
253
|
+
t7 = $[18];
|
|
254
|
+
t8 = $[19];
|
|
255
|
+
t9 = $[20];
|
|
256
|
+
}
|
|
257
|
+
let t12;
|
|
258
|
+
if ($[51] !== options.length) {
|
|
259
|
+
t12 = !options.length ? _jsx(Typography.Text, {
|
|
260
|
+
children: "No hay opciones disponibles."
|
|
261
|
+
}) : null;
|
|
262
|
+
$[51] = options.length;
|
|
263
|
+
$[52] = t12;
|
|
264
|
+
} else {
|
|
265
|
+
t12 = $[52];
|
|
266
|
+
}
|
|
267
|
+
let t13;
|
|
268
|
+
if ($[53] !== error) {
|
|
269
|
+
t13 = error ? _jsx(Typography.Text, {
|
|
270
|
+
accessibilityLiveRegion: "polite",
|
|
271
|
+
accessibilityRole: "alert",
|
|
272
|
+
className: "pt-3 text-danger",
|
|
273
|
+
selectable: true,
|
|
274
|
+
children: error
|
|
275
|
+
}) : null;
|
|
276
|
+
$[53] = error;
|
|
277
|
+
$[54] = t13;
|
|
278
|
+
} else {
|
|
279
|
+
t13 = $[54];
|
|
280
|
+
}
|
|
281
|
+
let t14;
|
|
282
|
+
if ($[55] !== T0 || $[56] !== t10 || $[57] !== t12 || $[58] !== t13 || $[59] !== t6 || $[60] !== t7 || $[61] !== t8 || $[62] !== t9) {
|
|
283
|
+
t14 = _jsxs(T0, {
|
|
284
|
+
dismissible: t6,
|
|
285
|
+
onClose: t7,
|
|
286
|
+
title: t8,
|
|
287
|
+
visible: t9,
|
|
288
|
+
children: [t10, t12, t13]
|
|
289
|
+
});
|
|
290
|
+
$[55] = T0;
|
|
291
|
+
$[56] = t10;
|
|
292
|
+
$[57] = t12;
|
|
293
|
+
$[58] = t13;
|
|
294
|
+
$[59] = t6;
|
|
295
|
+
$[60] = t7;
|
|
296
|
+
$[61] = t8;
|
|
297
|
+
$[62] = t9;
|
|
298
|
+
$[63] = t14;
|
|
299
|
+
} else {
|
|
300
|
+
t14 = $[63];
|
|
301
|
+
}
|
|
302
|
+
let t15;
|
|
303
|
+
if ($[64] !== t11 || $[65] !== t14) {
|
|
304
|
+
t15 = _jsxs(_Fragment, {
|
|
305
|
+
children: [t11, t14]
|
|
306
|
+
});
|
|
307
|
+
$[64] = t11;
|
|
308
|
+
$[65] = t14;
|
|
309
|
+
$[66] = t15;
|
|
310
|
+
} else {
|
|
311
|
+
t15 = $[66];
|
|
312
|
+
}
|
|
313
|
+
return t15;
|
|
63
314
|
}
|
|
64
315
|
export default Dropdown;
|
|
@@ -1,53 +1,245 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import Pressable from "../primitives/Pressable.js";
|
|
3
3
|
import { useTheme } from "../theme/index.js";
|
|
4
4
|
import { Typography } from "../Typography/index.js";
|
|
5
5
|
import { uniqueKeys } from "../utils/keys.js";
|
|
6
6
|
import { useEffect, useRef } from "react";
|
|
7
|
-
import { AccessibilityInfo, StyleSheet, View
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
import { AccessibilityInfo, StyleSheet, View } from "react-native";
|
|
8
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "nativewind/jsx-runtime";
|
|
9
|
+
export default function ErrorSummary(t0) {
|
|
10
|
+
const $ = _c(45);
|
|
11
|
+
let className;
|
|
12
|
+
let errors;
|
|
13
|
+
let itemStyle;
|
|
14
|
+
let itemTextProps;
|
|
15
|
+
let onSelectError;
|
|
16
|
+
let props;
|
|
17
|
+
let renderErrorContent;
|
|
18
|
+
let renderHeader;
|
|
19
|
+
let style;
|
|
20
|
+
let t1;
|
|
21
|
+
let t2;
|
|
22
|
+
let titleTextProps;
|
|
23
|
+
if ($[0] !== t0) {
|
|
24
|
+
({
|
|
25
|
+
errors,
|
|
26
|
+
onSelectError,
|
|
27
|
+
title: t1,
|
|
28
|
+
announce: t2,
|
|
29
|
+
className,
|
|
30
|
+
style,
|
|
31
|
+
itemStyle,
|
|
32
|
+
renderErrorContent,
|
|
33
|
+
renderHeader,
|
|
34
|
+
itemTextProps,
|
|
35
|
+
titleTextProps,
|
|
36
|
+
...props
|
|
37
|
+
} = t0);
|
|
38
|
+
$[0] = t0;
|
|
39
|
+
$[1] = className;
|
|
40
|
+
$[2] = errors;
|
|
41
|
+
$[3] = itemStyle;
|
|
42
|
+
$[4] = itemTextProps;
|
|
43
|
+
$[5] = onSelectError;
|
|
44
|
+
$[6] = props;
|
|
45
|
+
$[7] = renderErrorContent;
|
|
46
|
+
$[8] = renderHeader;
|
|
47
|
+
$[9] = style;
|
|
48
|
+
$[10] = t1;
|
|
49
|
+
$[11] = t2;
|
|
50
|
+
$[12] = titleTextProps;
|
|
51
|
+
} else {
|
|
52
|
+
className = $[1];
|
|
53
|
+
errors = $[2];
|
|
54
|
+
itemStyle = $[3];
|
|
55
|
+
itemTextProps = $[4];
|
|
56
|
+
onSelectError = $[5];
|
|
57
|
+
props = $[6];
|
|
58
|
+
renderErrorContent = $[7];
|
|
59
|
+
renderHeader = $[8];
|
|
60
|
+
style = $[9];
|
|
61
|
+
t1 = $[10];
|
|
62
|
+
t2 = $[11];
|
|
63
|
+
titleTextProps = $[12];
|
|
64
|
+
}
|
|
65
|
+
const title = t1 === undefined ? "Revisa los siguientes errores" : t1;
|
|
66
|
+
const announce = t2 === undefined ? true : t2;
|
|
67
|
+
const theme = useTheme();
|
|
68
|
+
const nonemptyEpisode = useRef(false);
|
|
69
|
+
uniqueKeys(errors, _temp, "ErrorSummary");
|
|
70
|
+
for (const {
|
|
71
|
+
label,
|
|
72
|
+
message
|
|
73
|
+
} of errors) {
|
|
74
|
+
if (typeof label !== "string" || !label.trim()) {
|
|
75
|
+
throw new Error("Form.ErrorSummary requires non-empty error labels.");
|
|
76
|
+
}
|
|
77
|
+
if (typeof message !== "string" || !message.trim()) {
|
|
78
|
+
throw new Error("Form.ErrorSummary requires non-empty error messages.");
|
|
17
79
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
80
|
+
}
|
|
81
|
+
let t3;
|
|
82
|
+
let t4;
|
|
83
|
+
if ($[13] !== announce || $[14] !== errors || $[15] !== title) {
|
|
84
|
+
t3 = () => {
|
|
85
|
+
if (errors.length === 0) {
|
|
86
|
+
nonemptyEpisode.current = false;
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (nonemptyEpisode.current) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
nonemptyEpisode.current = true;
|
|
93
|
+
if (announce) {
|
|
94
|
+
AccessibilityInfo.announceForAccessibility([title, ...errors.map(_temp2)].join("\n"));
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
t4 = [announce, errors, title];
|
|
98
|
+
$[13] = announce;
|
|
99
|
+
$[14] = errors;
|
|
100
|
+
$[15] = title;
|
|
101
|
+
$[16] = t3;
|
|
102
|
+
$[17] = t4;
|
|
103
|
+
} else {
|
|
104
|
+
t3 = $[16];
|
|
105
|
+
t4 = $[17];
|
|
106
|
+
}
|
|
107
|
+
useEffect(t3, t4);
|
|
108
|
+
if (errors.length === 0) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
let t5;
|
|
112
|
+
if ($[18] !== theme.bg.card || $[19] !== theme.danger) {
|
|
113
|
+
t5 = {
|
|
114
|
+
backgroundColor: theme.bg.card,
|
|
115
|
+
borderColor: theme.danger,
|
|
116
|
+
borderWidth: 2,
|
|
117
|
+
borderRadius: 8,
|
|
118
|
+
padding: 16,
|
|
119
|
+
gap: 8
|
|
120
|
+
};
|
|
121
|
+
$[18] = theme.bg.card;
|
|
122
|
+
$[19] = theme.danger;
|
|
123
|
+
$[20] = t5;
|
|
124
|
+
} else {
|
|
125
|
+
t5 = $[20];
|
|
126
|
+
}
|
|
127
|
+
let t6;
|
|
128
|
+
if ($[21] !== style || $[22] !== t5) {
|
|
129
|
+
t6 = [t5, style];
|
|
130
|
+
$[21] = style;
|
|
131
|
+
$[22] = t5;
|
|
132
|
+
$[23] = t6;
|
|
133
|
+
} else {
|
|
134
|
+
t6 = $[23];
|
|
135
|
+
}
|
|
136
|
+
let t7;
|
|
137
|
+
if ($[24] !== renderHeader || $[25] !== title || $[26] !== titleTextProps) {
|
|
138
|
+
t7 = renderHeader ? _jsx(View, {
|
|
139
|
+
accessibilityLabel: title,
|
|
140
|
+
accessibilityRole: "header",
|
|
141
|
+
accessible: true,
|
|
142
|
+
children: renderHeader(title)
|
|
143
|
+
}) : _jsx(Typography.Text, {
|
|
144
|
+
semibold: true,
|
|
145
|
+
variant: "body",
|
|
146
|
+
...titleTextProps,
|
|
147
|
+
accessibilityRole: "header",
|
|
148
|
+
allowFontScaling: true,
|
|
149
|
+
numberOfLines: 0,
|
|
150
|
+
children: title
|
|
151
|
+
});
|
|
152
|
+
$[24] = renderHeader;
|
|
153
|
+
$[25] = title;
|
|
154
|
+
$[26] = titleTextProps;
|
|
155
|
+
$[27] = t7;
|
|
156
|
+
} else {
|
|
157
|
+
t7 = $[27];
|
|
158
|
+
}
|
|
159
|
+
let t8;
|
|
160
|
+
if ($[28] !== errors || $[29] !== itemStyle || $[30] !== itemTextProps || $[31] !== onSelectError || $[32] !== renderErrorContent) {
|
|
161
|
+
let t9;
|
|
162
|
+
if ($[34] !== itemStyle || $[35] !== itemTextProps || $[36] !== onSelectError || $[37] !== renderErrorContent) {
|
|
163
|
+
t9 = (error_0, index) => _jsx(Pressable, {
|
|
164
|
+
accessibilityLabel: `${error_0.label}: ${error_0.message}`,
|
|
165
|
+
accessibilityRole: "button",
|
|
166
|
+
accessible: true,
|
|
167
|
+
hitSlop: 0,
|
|
168
|
+
onPress: () => onSelectError(error_0.id),
|
|
169
|
+
style: [styles.item, itemStyle, styles.target],
|
|
170
|
+
children: renderErrorContent ? renderErrorContent(error_0, index) : _jsxs(_Fragment, {
|
|
171
|
+
children: [_jsx(Typography.Text, {
|
|
172
|
+
semibold: true,
|
|
173
|
+
variant: "bodySmall",
|
|
174
|
+
...itemTextProps,
|
|
175
|
+
allowFontScaling: true,
|
|
176
|
+
numberOfLines: 0,
|
|
177
|
+
children: error_0.label
|
|
178
|
+
}), _jsx(Typography.Text, {
|
|
179
|
+
className: "text-text-accent",
|
|
180
|
+
underline: true,
|
|
181
|
+
...itemTextProps,
|
|
182
|
+
allowFontScaling: true,
|
|
183
|
+
numberOfLines: 0,
|
|
184
|
+
children: error_0.message
|
|
185
|
+
})]
|
|
186
|
+
})
|
|
187
|
+
}, error_0.id);
|
|
188
|
+
$[34] = itemStyle;
|
|
189
|
+
$[35] = itemTextProps;
|
|
190
|
+
$[36] = onSelectError;
|
|
191
|
+
$[37] = renderErrorContent;
|
|
192
|
+
$[38] = t9;
|
|
193
|
+
} else {
|
|
194
|
+
t9 = $[38];
|
|
195
|
+
}
|
|
196
|
+
t8 = errors.map(t9);
|
|
197
|
+
$[28] = errors;
|
|
198
|
+
$[29] = itemStyle;
|
|
199
|
+
$[30] = itemTextProps;
|
|
200
|
+
$[31] = onSelectError;
|
|
201
|
+
$[32] = renderErrorContent;
|
|
202
|
+
$[33] = t8;
|
|
203
|
+
} else {
|
|
204
|
+
t8 = $[33];
|
|
205
|
+
}
|
|
206
|
+
let t9;
|
|
207
|
+
if ($[39] !== className || $[40] !== props || $[41] !== t6 || $[42] !== t7 || $[43] !== t8) {
|
|
208
|
+
t9 = _jsxs(View, {
|
|
209
|
+
className: className,
|
|
210
|
+
style: t6,
|
|
211
|
+
...props,
|
|
212
|
+
children: [t7, t8]
|
|
213
|
+
});
|
|
214
|
+
$[39] = className;
|
|
215
|
+
$[40] = props;
|
|
216
|
+
$[41] = t6;
|
|
217
|
+
$[42] = t7;
|
|
218
|
+
$[43] = t8;
|
|
219
|
+
$[44] = t9;
|
|
220
|
+
} else {
|
|
221
|
+
t9 = $[44];
|
|
222
|
+
}
|
|
223
|
+
return t9;
|
|
224
|
+
}
|
|
225
|
+
function _temp2(t0) {
|
|
226
|
+
const {
|
|
227
|
+
label: label_0,
|
|
228
|
+
message: message_0
|
|
229
|
+
} = t0;
|
|
230
|
+
return `${label_0}: ${message_0}`;
|
|
231
|
+
}
|
|
232
|
+
function _temp(error) {
|
|
233
|
+
return error.id;
|
|
42
234
|
}
|
|
43
235
|
const styles = StyleSheet.create({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
236
|
+
item: {
|
|
237
|
+
justifyContent: "center",
|
|
238
|
+
paddingVertical: 8,
|
|
239
|
+
gap: 4
|
|
240
|
+
},
|
|
241
|
+
target: {
|
|
242
|
+
minHeight: 48,
|
|
243
|
+
minWidth: 48
|
|
244
|
+
}
|
|
53
245
|
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import { type Control, type FieldValues, type Path, type PathValue, type RegisterOptions } from "react-hook-form";
|
|
3
|
+
export interface FieldRenderProps<V> {
|
|
4
|
+
value: V;
|
|
5
|
+
onChange: (value: V) => void;
|
|
6
|
+
onBlur: () => void;
|
|
7
|
+
/** The explicit `error` prop, otherwise the validation message. */
|
|
8
|
+
error?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export type FieldRules<T extends FieldValues, N extends Path<T>> = Omit<RegisterOptions<T, N>, "valueAsNumber" | "valueAsDate" | "setValueAs" | "disabled">;
|
|
12
|
+
export interface FieldProps<T extends FieldValues, N extends Path<T>> {
|
|
13
|
+
control: Control<T>;
|
|
14
|
+
name: N;
|
|
15
|
+
rules?: FieldRules<T, N>;
|
|
16
|
+
/** Wins over the validation message, e.g. a server-side error. */
|
|
17
|
+
error?: string;
|
|
18
|
+
render: (field: FieldRenderProps<PathValue<T, N>>) => ReactElement;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The one react-hook-form adapter of the DS. Any control (DS or app) becomes a
|
|
22
|
+
* form field with typed value, blur, validation message and disabled state.
|
|
23
|
+
*/
|
|
24
|
+
export default function Field<T extends FieldValues, N extends Path<T>>({ control, name, rules, error, render, }: FieldProps<T, N>): import("react").JSX.Element;
|