@studio-piot/native-ui 0.2.3 → 0.2.5
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 +2 -1
- package/dist/components/ErrorBanner/ErrorBanner.d.ts +8 -0
- package/dist/components/ErrorBanner/ErrorBanner.d.ts.map +1 -0
- package/dist/components/ErrorBanner/ErrorBanner.js +136 -0
- package/dist/components/ErrorBanner/ErrorBanner.js.map +1 -0
- package/dist/components/ErrorBanner/errorBannerContext.d.ts +36 -0
- package/dist/components/ErrorBanner/errorBannerContext.d.ts.map +1 -0
- package/dist/components/ErrorBanner/errorBannerContext.js +78 -0
- package/dist/components/ErrorBanner/errorBannerContext.js.map +1 -0
- package/dist/components/ErrorBanner/errorBannerCopy.d.ts +7 -0
- package/dist/components/ErrorBanner/errorBannerCopy.d.ts.map +1 -0
- package/dist/components/ErrorBanner/errorBannerCopy.js +22 -0
- package/dist/components/ErrorBanner/errorBannerCopy.js.map +1 -0
- package/dist/components/ErrorBanner/errorBannerThemeRoles.d.ts +9 -0
- package/dist/components/ErrorBanner/errorBannerThemeRoles.d.ts.map +1 -0
- package/dist/components/ErrorBanner/errorBannerThemeRoles.js +11 -0
- package/dist/components/ErrorBanner/errorBannerThemeRoles.js.map +1 -0
- package/dist/components/ErrorBanner/icons.d.ts +7 -0
- package/dist/components/ErrorBanner/icons.d.ts.map +1 -0
- package/dist/components/ErrorBanner/icons.js +46 -0
- package/dist/components/ErrorBanner/icons.js.map +1 -0
- package/dist/components/ErrorBanner/index.d.ts +6 -0
- package/dist/components/ErrorBanner/index.d.ts.map +1 -0
- package/dist/components/ErrorBanner/index.js +16 -0
- package/dist/components/ErrorBanner/index.js.map +1 -0
- package/dist/components/ErrorBanner/types.d.ts +31 -0
- package/dist/components/ErrorBanner/types.d.ts.map +1 -0
- package/dist/components/ErrorBanner/types.js +3 -0
- package/dist/components/ErrorBanner/types.js.map +1 -0
- package/dist/components/ErrorBanner/useErrorBanner.d.ts +13 -0
- package/dist/components/ErrorBanner/useErrorBanner.d.ts.map +1 -0
- package/dist/components/ErrorBanner/useErrorBanner.js +31 -0
- package/dist/components/ErrorBanner/useErrorBanner.js.map +1 -0
- package/dist/components/Field/fieldChrome.d.ts +1 -1
- package/dist/components/Field/fieldChrome.d.ts.map +1 -1
- package/dist/components/Field/fieldChrome.js +20 -4
- package/dist/components/Field/fieldChrome.js.map +1 -1
- package/dist/components/Field/types.d.ts +2 -0
- package/dist/components/Field/types.d.ts.map +1 -1
- package/dist/components/Form/Form.d.ts +1 -1
- package/dist/components/Form/Form.d.ts.map +1 -1
- package/dist/components/Form/Form.js +36 -23
- package/dist/components/Form/Form.js.map +1 -1
- package/dist/components/Form/types.d.ts +7 -0
- package/dist/components/Form/types.d.ts.map +1 -1
- package/dist/components/RadioField/RadioField.d.ts.map +1 -1
- package/dist/components/RadioField/RadioField.js +6 -1
- package/dist/components/RadioField/RadioField.js.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.js +8 -8
- package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/components/SegmentedControl/segmentThemeRoles.d.ts +5 -6
- package/dist/components/SegmentedControl/segmentThemeRoles.d.ts.map +1 -1
- package/dist/components/SegmentedControl/segmentThemeRoles.js +5 -6
- package/dist/components/SegmentedControl/segmentThemeRoles.js.map +1 -1
- package/dist/components/SegmentedControl/types.d.ts +0 -1
- package/dist/components/SegmentedControl/types.d.ts.map +1 -1
- package/dist/components/Select/Select.d.ts +1 -1
- package/dist/components/Select/Select.d.ts.map +1 -1
- package/dist/components/Select/Select.js +11 -4
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Select/types.d.ts +2 -0
- package/dist/components/Select/types.d.ts.map +1 -1
- package/dist/components/Slider/Slider.d.ts.map +1 -1
- package/dist/components/Slider/Slider.js +6 -1
- package/dist/components/Slider/Slider.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +10 -1
- package/dist/components/index.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/docs/components/error-banner.md +85 -0
- package/docs/components/form.md +2 -1
- package/docs/components/segmented-control.md +23 -13
- package/package.json +4 -2
- package/src/components/ErrorBanner/ErrorBanner.tsx +232 -0
- package/src/components/ErrorBanner/errorBannerContext.tsx +140 -0
- package/src/components/ErrorBanner/errorBannerCopy.test.ts +41 -0
- package/src/components/ErrorBanner/errorBannerCopy.ts +22 -0
- package/src/components/ErrorBanner/errorBannerThemeRoles.test.ts +19 -0
- package/src/components/ErrorBanner/errorBannerThemeRoles.ts +9 -0
- package/src/components/ErrorBanner/icons.tsx +38 -0
- package/src/components/ErrorBanner/index.ts +14 -0
- package/src/components/ErrorBanner/types.ts +31 -0
- package/src/components/ErrorBanner/useErrorBanner.ts +33 -0
- package/src/components/Field/fieldChrome.tsx +33 -7
- package/src/components/Field/types.ts +2 -0
- package/src/components/Form/Form.tsx +56 -2
- package/src/components/Form/types.ts +7 -0
- package/src/components/RadioField/RadioField.tsx +6 -1
- package/src/components/SegmentedControl/SegmentedControl.tsx +7 -11
- package/src/components/SegmentedControl/segmentThemeRoles.test.ts +9 -7
- package/src/components/SegmentedControl/segmentThemeRoles.ts +5 -6
- package/src/components/SegmentedControl/types.ts +0 -1
- package/src/components/Select/Select.tsx +20 -5
- package/src/components/Select/types.ts +2 -0
- package/src/components/Slider/Slider.tsx +6 -1
- package/src/components/index.ts +13 -0
- package/src/index.ts +14 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ The package is the native counterpart of `@studio-piot/ui`. Apps own their palet
|
|
|
10
10
|
npm install @studio-piot/native-ui
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
`Select` peers `@gorhom/bottom-sheet`, `react-native-reanimated`, `react-native-gesture-handler`, and `react-native-screens` (iOS `FullWindowOverlay` so the sheet appears above React Navigation modals). `SegmentedControl` uses that same `react-native-reanimated` peer to slide the selection fill. `Slider` peers `@react-native-community/slider`.
|
|
13
|
+
`Select` peers `@gorhom/bottom-sheet`, `react-native-reanimated`, `react-native-gesture-handler`, and `react-native-screens` (iOS `FullWindowOverlay` so the sheet appears above React Navigation modals). `SegmentedControl` uses that same `react-native-reanimated` peer to slide the selection fill. `Slider` peers `@react-native-community/slider`. `ErrorBanner` peers `react-native-svg` for the megaphone and row arrow.
|
|
14
14
|
|
|
15
15
|
## Docs
|
|
16
16
|
|
|
@@ -18,6 +18,7 @@ npm install @studio-piot/native-ui
|
|
|
18
18
|
- [LinkBlocks usage](./docs/components/link-blocks.md)
|
|
19
19
|
- [Field usage](./docs/components/field.md)
|
|
20
20
|
- [Form usage](./docs/components/form.md)
|
|
21
|
+
- [ErrorBanner usage](./docs/components/error-banner.md)
|
|
21
22
|
- [RadioField usage](./docs/components/radio-field.md)
|
|
22
23
|
- [Select usage](./docs/components/select.md)
|
|
23
24
|
- [SegmentedControl usage](./docs/components/segmented-control.md)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ErrorBannerProps } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Screen-wide field-error banner. Mount it once and drive `open` so the
|
|
4
|
+
* exit animation can play. It is not tied to a form shell: pass `errors`,
|
|
5
|
+
* `onJump`, and `onDismiss`. `Form` does that by default.
|
|
6
|
+
*/
|
|
7
|
+
export declare function ErrorBanner({ open, errors, onJump, onDismiss, onHeightChange, safeAreaTop, paddingHorizontal, backgroundColor: backgroundColorProp, textColor: textColorProp, secondaryColor: secondaryColorProp, dividerColor: dividerColorProp, accentColor: accentColorProp, }: ErrorBannerProps): import("react").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=ErrorBanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorBanner.d.ts","sourceRoot":"","sources":["../../../src/components/ErrorBanner/ErrorBanner.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAIhD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,MAAM,EACN,MAAM,EACN,SAAS,EACT,cAAc,EACd,WAAW,EACX,iBAA2C,EAC3C,eAAe,EAAE,mBAAmB,EACpC,SAAS,EAAE,aAAa,EACxB,cAAc,EAAE,kBAAkB,EAClC,YAAY,EAAE,gBAAgB,EAC9B,WAAW,EAAE,eAAe,GAC7B,EAAE,gBAAgB,+BAuIlB"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorBanner = ErrorBanner;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const react_native_1 = require("react-native");
|
|
7
|
+
const react_native_safe_area_context_1 = require("react-native-safe-area-context");
|
|
8
|
+
const buttonRadius_1 = require("../Button/buttonRadius");
|
|
9
|
+
const useResolvedFieldColor_1 = require("../Field/useResolvedFieldColor");
|
|
10
|
+
const screenPadding_1 = require("../../layout/screenPadding");
|
|
11
|
+
const errorBannerCopy_1 = require("./errorBannerCopy");
|
|
12
|
+
const errorBannerThemeRoles_1 = require("./errorBannerThemeRoles");
|
|
13
|
+
const icons_1 = require("./icons");
|
|
14
|
+
const BOTTOM_RADIUS = (0, buttonRadius_1.buttonRadiusValue)("xl");
|
|
15
|
+
/**
|
|
16
|
+
* Screen-wide field-error banner. Mount it once and drive `open` so the
|
|
17
|
+
* exit animation can play. It is not tied to a form shell: pass `errors`,
|
|
18
|
+
* `onJump`, and `onDismiss`. `Form` does that by default.
|
|
19
|
+
*/
|
|
20
|
+
function ErrorBanner({ open, errors, onJump, onDismiss, onHeightChange, safeAreaTop, paddingHorizontal = screenPadding_1.screenPaddingHorizontal, backgroundColor: backgroundColorProp, textColor: textColorProp, secondaryColor: secondaryColorProp, dividerColor: dividerColorProp, accentColor: accentColorProp, }) {
|
|
21
|
+
const insets = (0, react_native_safe_area_context_1.useSafeAreaInsets)();
|
|
22
|
+
const topInset = safeAreaTop ?? insets.top;
|
|
23
|
+
const backgroundColor = (0, useResolvedFieldColor_1.useResolvedFieldColor)(backgroundColorProp, errorBannerThemeRoles_1.ERROR_BANNER_THEME_ROLES.backgroundColor);
|
|
24
|
+
const textColor = (0, useResolvedFieldColor_1.useResolvedFieldColor)(textColorProp, errorBannerThemeRoles_1.ERROR_BANNER_THEME_ROLES.textColor);
|
|
25
|
+
const secondaryColor = (0, useResolvedFieldColor_1.useResolvedFieldColor)(secondaryColorProp, errorBannerThemeRoles_1.ERROR_BANNER_THEME_ROLES.secondaryColor);
|
|
26
|
+
const dividerColor = (0, useResolvedFieldColor_1.useResolvedFieldColor)(dividerColorProp, errorBannerThemeRoles_1.ERROR_BANNER_THEME_ROLES.dividerColor);
|
|
27
|
+
const accentColor = (0, useResolvedFieldColor_1.useResolvedFieldColor)(accentColorProp, errorBannerThemeRoles_1.ERROR_BANNER_THEME_ROLES.accentColor);
|
|
28
|
+
const [height, setHeight] = (0, react_1.useState)(400);
|
|
29
|
+
const [reduceMotion, setReduceMotion] = (0, react_1.useState)(false);
|
|
30
|
+
const progress = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
|
|
31
|
+
const count = errors.length;
|
|
32
|
+
const title = (0, errorBannerCopy_1.errorBannerTitle)(count);
|
|
33
|
+
const titleRef = (0, react_1.useRef)(title);
|
|
34
|
+
titleRef.current = title;
|
|
35
|
+
(0, react_1.useEffect)(() => {
|
|
36
|
+
react_native_1.AccessibilityInfo.isReduceMotionEnabled().then(setReduceMotion);
|
|
37
|
+
}, []);
|
|
38
|
+
(0, react_1.useEffect)(() => {
|
|
39
|
+
react_native_1.Animated.timing(progress, {
|
|
40
|
+
toValue: open ? 1 : 0,
|
|
41
|
+
duration: reduceMotion ? 120 : open ? 260 : 200,
|
|
42
|
+
easing: react_native_1.Easing.bezier(0.16, 1, 0.3, 1),
|
|
43
|
+
useNativeDriver: true,
|
|
44
|
+
}).start();
|
|
45
|
+
if (open) {
|
|
46
|
+
react_native_1.AccessibilityInfo.announceForAccessibility(titleRef.current);
|
|
47
|
+
}
|
|
48
|
+
}, [open, progress, reduceMotion]);
|
|
49
|
+
const motion = reduceMotion
|
|
50
|
+
? { opacity: progress }
|
|
51
|
+
: {
|
|
52
|
+
transform: [
|
|
53
|
+
{
|
|
54
|
+
translateY: progress.interpolate({
|
|
55
|
+
inputRange: [0, 1],
|
|
56
|
+
outputRange: [-(height + 24), 0],
|
|
57
|
+
}),
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
};
|
|
61
|
+
const onLayout = (event) => {
|
|
62
|
+
const next = Math.round(event.nativeEvent.layout.height);
|
|
63
|
+
setHeight((current) => (current === next ? current : next));
|
|
64
|
+
onHeightChange?.(next);
|
|
65
|
+
};
|
|
66
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [open ? (0, jsx_runtime_1.jsx)(react_native_1.StatusBar, { animated: true, barStyle: "light-content" }) : null, (0, jsx_runtime_1.jsxs)(react_native_1.Animated.View, { accessibilityRole: "alert", accessibilityElementsHidden: !open, importantForAccessibility: open ? "auto" : "no-hide-descendants", onLayout: onLayout, pointerEvents: open ? "auto" : "none", style: [
|
|
67
|
+
styles.banner,
|
|
68
|
+
{
|
|
69
|
+
backgroundColor,
|
|
70
|
+
paddingTop: topInset + 8,
|
|
71
|
+
paddingHorizontal,
|
|
72
|
+
borderBottomLeftRadius: BOTTOM_RADIUS,
|
|
73
|
+
borderBottomRightRadius: BOTTOM_RADIUS,
|
|
74
|
+
},
|
|
75
|
+
motion,
|
|
76
|
+
], children: [(0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.header, children: [(0, jsx_runtime_1.jsx)(react_native_1.View, { accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", style: [styles.iconDisc, { backgroundColor: accentColor }], children: (0, jsx_runtime_1.jsx)(icons_1.Megaphone, { color: backgroundColor }) }), (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: [styles.title, { color: textColor }], children: title }), (0, jsx_runtime_1.jsx)(react_native_1.Pressable, { accessibilityLabel: "Dismiss", accessibilityRole: "button", hitSlop: 12, onPress: onDismiss, children: (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: [styles.dismiss, { color: secondaryColor }], children: "\u2715" }) })] }), (0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.rows, children: errors.map((error) => ((0, jsx_runtime_1.jsxs)(react_native_1.Pressable, { accessibilityLabel: `${error.short}. Go to field.`, accessibilityRole: "button", hitSlop: { top: 4, bottom: 4 }, onPress: () => onJump(error.field), style: ({ pressed }) => [
|
|
77
|
+
styles.row,
|
|
78
|
+
{ borderTopColor: dividerColor },
|
|
79
|
+
pressed && styles.pressed,
|
|
80
|
+
], children: [(0, jsx_runtime_1.jsx)(react_native_1.Text, { style: [styles.rowLabel, { color: textColor }], children: error.short }), (0, jsx_runtime_1.jsx)(react_native_1.View, { accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", children: (0, jsx_runtime_1.jsx)(icons_1.ArrowRight, { color: secondaryColor }) })] }, error.field))) })] })] }));
|
|
81
|
+
}
|
|
82
|
+
const styles = react_native_1.StyleSheet.create({
|
|
83
|
+
banner: {
|
|
84
|
+
position: "absolute",
|
|
85
|
+
top: 0,
|
|
86
|
+
left: 0,
|
|
87
|
+
right: 0,
|
|
88
|
+
zIndex: 100,
|
|
89
|
+
paddingBottom: 10,
|
|
90
|
+
shadowColor: "#22201D",
|
|
91
|
+
shadowOpacity: 0.25,
|
|
92
|
+
shadowRadius: 12,
|
|
93
|
+
shadowOffset: { width: 0, height: 8 },
|
|
94
|
+
elevation: 12,
|
|
95
|
+
},
|
|
96
|
+
header: {
|
|
97
|
+
flexDirection: "row",
|
|
98
|
+
alignItems: "center",
|
|
99
|
+
gap: 10,
|
|
100
|
+
},
|
|
101
|
+
iconDisc: {
|
|
102
|
+
width: 28,
|
|
103
|
+
height: 28,
|
|
104
|
+
borderRadius: 14,
|
|
105
|
+
alignItems: "center",
|
|
106
|
+
justifyContent: "center",
|
|
107
|
+
},
|
|
108
|
+
title: {
|
|
109
|
+
flex: 1,
|
|
110
|
+
fontSize: 15,
|
|
111
|
+
lineHeight: 20,
|
|
112
|
+
fontWeight: "600",
|
|
113
|
+
},
|
|
114
|
+
dismiss: {
|
|
115
|
+
fontSize: 15,
|
|
116
|
+
},
|
|
117
|
+
rows: {
|
|
118
|
+
marginTop: 6,
|
|
119
|
+
},
|
|
120
|
+
row: {
|
|
121
|
+
flexDirection: "row",
|
|
122
|
+
alignItems: "center",
|
|
123
|
+
minHeight: 36,
|
|
124
|
+
marginLeft: 38,
|
|
125
|
+
borderTopWidth: 1,
|
|
126
|
+
},
|
|
127
|
+
pressed: {
|
|
128
|
+
opacity: 0.6,
|
|
129
|
+
},
|
|
130
|
+
rowLabel: {
|
|
131
|
+
flex: 1,
|
|
132
|
+
fontSize: 15,
|
|
133
|
+
lineHeight: 20,
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
//# sourceMappingURL=ErrorBanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorBanner.js","sourceRoot":"","sources":["../../../src/components/ErrorBanner/ErrorBanner.tsx"],"names":[],"mappings":";;AA4BA,kCAoJC;;AAhLD,iCAAoD;AACpD,+CAUsB;AACtB,mFAAmE;AACnE,yDAA2D;AAC3D,0EAAuE;AACvE,8DAAqE;AACrE,uDAAqD;AACrD,mEAAmE;AACnE,mCAAgD;AAGhD,MAAM,aAAa,GAAG,IAAA,gCAAiB,EAAC,IAAI,CAAC,CAAC;AAE9C;;;;GAIG;AACH,SAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,MAAM,EACN,MAAM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,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,GAAG;QACX,aAAa,EAAE,EAAE;QACjB,WAAW,EAAE,SAAS;QACtB,aAAa,EAAE,IAAI;QACnB,YAAY,EAAE,EAAE;QAChB,YAAY,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;QACrC,SAAS,EAAE,EAAE;KACd;IACD,MAAM,EAAE;QACN,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,QAAQ;QACpB,GAAG,EAAE,EAAE;KACR;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,YAAY,EAAE,EAAE;QAChB,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;KACzB;IACD,KAAK,EAAE;QACL,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,KAAK;KAClB;IACD,OAAO,EAAE;QACP,QAAQ,EAAE,EAAE;KACb;IACD,IAAI,EAAE;QACJ,SAAS,EAAE,CAAC;KACb;IACD,GAAG,EAAE;QACH,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,QAAQ;QACpB,SAAS,EAAE,EAAE;QACb,UAAU,EAAE,EAAE;QACd,cAAc,EAAE,CAAC;KAClB;IACD,OAAO,EAAE;QACP,OAAO,EAAE,GAAG;KACb;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,EAAE;KACf;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type ReactNode, type RefObject } from "react";
|
|
2
|
+
import { View, type ScrollView } from "react-native";
|
|
3
|
+
import type { FieldError } from "./types";
|
|
4
|
+
export type ErrorBannerAnchor = {
|
|
5
|
+
view: View;
|
|
6
|
+
focus?: () => void;
|
|
7
|
+
};
|
|
8
|
+
type ErrorBannerContextValue = {
|
|
9
|
+
errors: readonly FieldError[];
|
|
10
|
+
register: (field: string, anchor: ErrorBannerAnchor | null) => void;
|
|
11
|
+
dismiss: () => void;
|
|
12
|
+
jump: (field: string) => void;
|
|
13
|
+
};
|
|
14
|
+
export declare function useErrorBannerContext(): ErrorBannerContextValue | null;
|
|
15
|
+
export declare function useErrorBannerDismiss(): () => void;
|
|
16
|
+
/**
|
|
17
|
+
* Registers a field so a banner row can scroll it into view.
|
|
18
|
+
* No-ops outside `ErrorBannerProvider` (and `Form`, which provides one).
|
|
19
|
+
*/
|
|
20
|
+
export declare function useErrorBannerField(name: string | undefined, focus?: () => void): {
|
|
21
|
+
viewRef: RefObject<View | null>;
|
|
22
|
+
listed: FieldError | undefined;
|
|
23
|
+
};
|
|
24
|
+
export declare function ErrorBannerProvider({ children, scrollRef, errors, onDismiss, bannerHeightRef, }: {
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
scrollRef: RefObject<ScrollView | null>;
|
|
27
|
+
errors: readonly FieldError[];
|
|
28
|
+
onDismiss: () => void;
|
|
29
|
+
bannerHeightRef: RefObject<number>;
|
|
30
|
+
}): import("react").JSX.Element;
|
|
31
|
+
export declare function ErrorBannerField({ name, children, }: {
|
|
32
|
+
name: string;
|
|
33
|
+
children: ReactNode;
|
|
34
|
+
}): import("react").JSX.Element;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=errorBannerContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorBannerContext.d.ts","sourceRoot":"","sources":["../../../src/components/ErrorBanner/errorBannerContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,IAAI,EAA2B,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAE9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAC7B,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC;IAC9B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,IAAI,KAAK,IAAI,CAAC;IACpE,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/B,CAAC;AAIF,wBAAgB,qBAAqB,IAAI,uBAAuB,GAAG,IAAI,CAEtE;AAED,wBAAgB,qBAAqB,IAAI,MAAM,IAAI,CAGlD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,KAAK,CAAC,EAAE,MAAM,IAAI;;;EA2BnB;AAED,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,SAAS,EACT,MAAM,EACN,SAAS,EACT,eAAe,GAChB,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,EAAE,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACxC,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC;IAC9B,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,eAAe,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;CACpC,+BAwCA;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,IAAI,EACJ,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,SAAS,CAAC;CACrB,+BAOA"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useErrorBannerContext = useErrorBannerContext;
|
|
4
|
+
exports.useErrorBannerDismiss = useErrorBannerDismiss;
|
|
5
|
+
exports.useErrorBannerField = useErrorBannerField;
|
|
6
|
+
exports.ErrorBannerProvider = ErrorBannerProvider;
|
|
7
|
+
exports.ErrorBannerField = ErrorBannerField;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const react_native_1 = require("react-native");
|
|
11
|
+
const errorBannerCopy_1 = require("./errorBannerCopy");
|
|
12
|
+
const ErrorBannerContext = (0, react_1.createContext)(null);
|
|
13
|
+
function useErrorBannerContext() {
|
|
14
|
+
return (0, react_1.useContext)(ErrorBannerContext);
|
|
15
|
+
}
|
|
16
|
+
function useErrorBannerDismiss() {
|
|
17
|
+
const ctx = (0, react_1.useContext)(ErrorBannerContext);
|
|
18
|
+
return ctx?.dismiss ?? (() => undefined);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Registers a field so a banner row can scroll it into view.
|
|
22
|
+
* No-ops outside `ErrorBannerProvider` (and `Form`, which provides one).
|
|
23
|
+
*/
|
|
24
|
+
function useErrorBannerField(name, focus) {
|
|
25
|
+
const ctx = (0, react_1.useContext)(ErrorBannerContext);
|
|
26
|
+
const viewRef = (0, react_1.useRef)(null);
|
|
27
|
+
const focusRef = (0, react_1.useRef)(focus);
|
|
28
|
+
focusRef.current = focus;
|
|
29
|
+
(0, react_1.useEffect)(() => {
|
|
30
|
+
if (!name || !ctx) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const view = viewRef.current;
|
|
34
|
+
if (!view) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
ctx.register(name, {
|
|
38
|
+
view,
|
|
39
|
+
focus: () => focusRef.current?.(),
|
|
40
|
+
});
|
|
41
|
+
return () => ctx.register(name, null);
|
|
42
|
+
}, [ctx, name]);
|
|
43
|
+
const listed = name
|
|
44
|
+
? ctx?.errors.find((error) => error.field === name)
|
|
45
|
+
: undefined;
|
|
46
|
+
return { viewRef, listed };
|
|
47
|
+
}
|
|
48
|
+
function ErrorBannerProvider({ children, scrollRef, errors, onDismiss, bannerHeightRef, }) {
|
|
49
|
+
const anchors = (0, react_1.useRef)(new Map());
|
|
50
|
+
const register = (0, react_1.useCallback)((field, anchor) => {
|
|
51
|
+
if (!anchor) {
|
|
52
|
+
anchors.current.delete(field);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
anchors.current.set(field, anchor);
|
|
56
|
+
}, []);
|
|
57
|
+
const jump = (0, react_1.useCallback)((field) => {
|
|
58
|
+
const anchor = anchors.current.get(field);
|
|
59
|
+
const scroll = scrollRef.current;
|
|
60
|
+
if (!anchor || !scroll) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
anchor.view.measureLayout(scroll, (_x, y) => {
|
|
64
|
+
scroll.scrollTo({
|
|
65
|
+
y: (0, errorBannerCopy_1.fieldScrollY)(y, bannerHeightRef.current ?? 0),
|
|
66
|
+
animated: true,
|
|
67
|
+
});
|
|
68
|
+
anchor.focus?.();
|
|
69
|
+
}, () => undefined);
|
|
70
|
+
}, [bannerHeightRef, scrollRef]);
|
|
71
|
+
const value = (0, react_1.useMemo)(() => ({ errors, register, dismiss: onDismiss, jump }), [errors, jump, onDismiss, register]);
|
|
72
|
+
return ((0, jsx_runtime_1.jsx)(ErrorBannerContext.Provider, { value: value, children: children }));
|
|
73
|
+
}
|
|
74
|
+
function ErrorBannerField({ name, children, }) {
|
|
75
|
+
const { viewRef } = useErrorBannerField(name);
|
|
76
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.View, { ref: viewRef, collapsable: false, children: children }));
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=errorBannerContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorBannerContext.js","sourceRoot":"","sources":["../../../src/components/ErrorBanner/errorBannerContext.tsx"],"names":[],"mappings":";;AA4BA,sDAEC;AAED,sDAGC;AAMD,kDA6BC;AAED,kDAoDC;AAED,4CAaC;;AA3ID,iCASe;AACf,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AS,CAChB,CAAC;IACJ,CAAC,EAAE,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC,CAAC;IAEjC,MAAM,KAAK,GAAG,IAAA,eAAO,EACnB,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EACtD,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAC,CACpC,CAAC;IAEF,OAAO,CACL,uBAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACtC,QAAQ,GACmB,CAC/B,CAAC;AACJ,CAAC;AAED,SAAgB,gBAAgB,CAAC,EAC/B,IAAI,EACJ,QAAQ,GAIT;IACC,MAAM,EAAE,OAAO,EAAE,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC9C,OAAO,CACL,uBAAC,mBAAI,IAAC,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,YACnC,QAAQ,GACJ,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Gap kept between the banner and a field scrolled into view. */
|
|
2
|
+
export declare const ERROR_BANNER_SCROLL_GAP = 16;
|
|
3
|
+
export declare function errorBannerTitle(count: number): string;
|
|
4
|
+
export declare function errorBannerOpen(errorCount: number, dismissed: boolean): boolean;
|
|
5
|
+
/** Content y that places the field just below the banner. */
|
|
6
|
+
export declare function fieldScrollY(fieldY: number, bannerHeight: number, gap?: number): number;
|
|
7
|
+
//# sourceMappingURL=errorBannerCopy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorBannerCopy.d.ts","sourceRoot":"","sources":["../../../src/components/ErrorBanner/errorBannerCopy.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKtD;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAE/E;AAED,6DAA6D;AAC7D,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,GAAG,SAA0B,GAC5B,MAAM,CAER"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ERROR_BANNER_SCROLL_GAP = void 0;
|
|
4
|
+
exports.errorBannerTitle = errorBannerTitle;
|
|
5
|
+
exports.errorBannerOpen = errorBannerOpen;
|
|
6
|
+
exports.fieldScrollY = fieldScrollY;
|
|
7
|
+
/** Gap kept between the banner and a field scrolled into view. */
|
|
8
|
+
exports.ERROR_BANNER_SCROLL_GAP = 16;
|
|
9
|
+
function errorBannerTitle(count) {
|
|
10
|
+
if (count === 1) {
|
|
11
|
+
return "Nearly there. One thing to review";
|
|
12
|
+
}
|
|
13
|
+
return `Nearly there. ${count} things to review`;
|
|
14
|
+
}
|
|
15
|
+
function errorBannerOpen(errorCount, dismissed) {
|
|
16
|
+
return errorCount > 0 && !dismissed;
|
|
17
|
+
}
|
|
18
|
+
/** Content y that places the field just below the banner. */
|
|
19
|
+
function fieldScrollY(fieldY, bannerHeight, gap = exports.ERROR_BANNER_SCROLL_GAP) {
|
|
20
|
+
return Math.max(0, fieldY - bannerHeight - gap);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=errorBannerCopy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorBannerCopy.js","sourceRoot":"","sources":["../../../src/components/ErrorBanner/errorBannerCopy.ts"],"names":[],"mappings":";;;AAGA,4CAKC;AAED,0CAEC;AAGD,oCAMC;AArBD,kEAAkE;AACrD,QAAA,uBAAuB,GAAG,EAAE,CAAC;AAE1C,SAAgB,gBAAgB,CAAC,KAAa;IAC5C,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QAChB,OAAO,mCAAmC,CAAC;IAC7C,CAAC;IACD,OAAO,iBAAiB,KAAK,mBAAmB,CAAC;AACnD,CAAC;AAED,SAAgB,eAAe,CAAC,UAAkB,EAAE,SAAkB;IACpE,OAAO,UAAU,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC;AACtC,CAAC;AAED,6DAA6D;AAC7D,SAAgB,YAAY,CAC1B,MAAc,EACd,YAAoB,EACpB,GAAG,GAAG,+BAAuB;IAE7B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,GAAG,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const ERROR_BANNER_THEME_ROLES: {
|
|
2
|
+
readonly backgroundColor: "errorBannerBackground";
|
|
3
|
+
readonly textColor: "errorBannerText";
|
|
4
|
+
readonly secondaryColor: "errorBannerSecondary";
|
|
5
|
+
readonly dividerColor: "errorBannerDivider";
|
|
6
|
+
readonly accentColor: "errorBannerAccent";
|
|
7
|
+
};
|
|
8
|
+
export type ErrorBannerThemeColorProp = keyof typeof ERROR_BANNER_THEME_ROLES;
|
|
9
|
+
//# sourceMappingURL=errorBannerThemeRoles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorBannerThemeRoles.d.ts","sourceRoot":"","sources":["../../../src/components/ErrorBanner/errorBannerThemeRoles.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB;;;;;;CAM3B,CAAC;AAEX,MAAM,MAAM,yBAAyB,GAAG,MAAM,OAAO,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ERROR_BANNER_THEME_ROLES = void 0;
|
|
4
|
+
exports.ERROR_BANNER_THEME_ROLES = {
|
|
5
|
+
backgroundColor: "errorBannerBackground",
|
|
6
|
+
textColor: "errorBannerText",
|
|
7
|
+
secondaryColor: "errorBannerSecondary",
|
|
8
|
+
dividerColor: "errorBannerDivider",
|
|
9
|
+
accentColor: "errorBannerAccent",
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=errorBannerThemeRoles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorBannerThemeRoles.js","sourceRoot":"","sources":["../../../src/components/ErrorBanner/errorBannerThemeRoles.ts"],"names":[],"mappings":";;;AAAa,QAAA,wBAAwB,GAAG;IACtC,eAAe,EAAE,uBAAuB;IACxC,SAAS,EAAE,iBAAiB;IAC5B,cAAc,EAAE,sBAAsB;IACtC,YAAY,EAAE,oBAAoB;IAClC,WAAW,EAAE,mBAAmB;CACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../../src/components/ErrorBanner/icons.tsx"],"names":[],"mappings":"AAEA,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,+BAiBrD;AAED,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,+BAgBtD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Megaphone = Megaphone;
|
|
37
|
+
exports.ArrowRight = ArrowRight;
|
|
38
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
39
|
+
const react_native_svg_1 = __importStar(require("react-native-svg"));
|
|
40
|
+
function Megaphone({ color }) {
|
|
41
|
+
return ((0, jsx_runtime_1.jsx)(react_native_svg_1.default, { width: 16, height: 16, viewBox: "0 0 24 24", fill: "none", stroke: color, strokeWidth: 1.8, children: (0, jsx_runtime_1.jsx)(react_native_svg_1.Path, { strokeLinecap: "round", strokeLinejoin: "round", d: "M10.34 15.84c-.688-.06-1.386-.09-2.09-.09H7.5a4.5 4.5 0 1 1 0-9h.75c.704 0 1.402-.03 2.09-.09m0 9.18c.253.962.584 1.892.985 2.783.247.55.06 1.21-.463 1.511l-.657.38c-.551.318-1.26.117-1.527-.461a20.845 20.845 0 0 1-1.44-4.282m3.102.069a18.03 18.03 0 0 1-.59-4.59c0-1.586.205-3.124.59-4.59m0 9.18a23.848 23.848 0 0 1 8.835 2.535M10.34 6.66a23.847 23.847 0 0 0 8.835-2.535m0 0A23.74 23.74 0 0 0 18.795 3m.38 1.125a23.91 23.91 0 0 1 1.014 5.395m-1.014 8.855c-.118.38-.245.754-.38 1.125m.38-1.125a23.91 23.91 0 0 0 1.014-5.395m0-3.46c.495.413.811 1.035.811 1.73 0 .695-.316 1.317-.811 1.73m0-3.46a24.347 24.347 0 0 1 0 3.46" }) }));
|
|
42
|
+
}
|
|
43
|
+
function ArrowRight({ color }) {
|
|
44
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_svg_1.default, { width: 18, height: 18, viewBox: "0 0 24 24", fill: "none", stroke: color, strokeWidth: 2.25, strokeLinecap: "round", strokeLinejoin: "round", children: [(0, jsx_runtime_1.jsx)(react_native_svg_1.Line, { x1: 5, y1: 12, x2: 19, y2: 12 }), (0, jsx_runtime_1.jsx)(react_native_svg_1.Polyline, { points: "13 6 19 12 13 18" })] }));
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=icons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icons.js","sourceRoot":"","sources":["../../../src/components/ErrorBanner/icons.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,8BAiBC;AAED,gCAgBC;;AArCD,qEAA6D;AAE7D,SAAgB,SAAS,CAAC,EAAE,KAAK,EAAqB;IACpD,OAAO,CACL,uBAAC,0BAAG,IACF,KAAK,EAAE,EAAE,EACT,MAAM,EAAE,EAAE,EACV,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAE,KAAK,EACb,WAAW,EAAE,GAAG,YAEhB,uBAAC,uBAAI,IACH,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EACtB,CAAC,EAAC,6mBAA6mB,GAC/mB,GACE,CACP,CAAC;AACJ,CAAC;AAED,SAAgB,UAAU,CAAC,EAAE,KAAK,EAAqB;IACrD,OAAO,CACL,wBAAC,0BAAG,IACF,KAAK,EAAE,EAAE,EACT,MAAM,EAAE,EAAE,EACV,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAE,KAAK,EACb,WAAW,EAAE,IAAI,EACjB,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,aAEtB,uBAAC,uBAAI,IAAC,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAI,EACvC,uBAAC,2BAAQ,IAAC,MAAM,EAAC,kBAAkB,GAAG,IAClC,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ErrorBanner } from "./ErrorBanner";
|
|
2
|
+
export { ErrorBannerField, ErrorBannerProvider, useErrorBannerContext, useErrorBannerDismiss, useErrorBannerField, } from "./errorBannerContext";
|
|
3
|
+
export { ERROR_BANNER_THEME_ROLES, type ErrorBannerThemeColorProp, } from "./errorBannerThemeRoles";
|
|
4
|
+
export { useErrorBanner } from "./useErrorBanner";
|
|
5
|
+
export type { ErrorBannerProps, FieldError } from "./types";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ErrorBanner/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,wBAAwB,EACxB,KAAK,yBAAyB,GAC/B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useErrorBanner = exports.ERROR_BANNER_THEME_ROLES = exports.useErrorBannerField = exports.useErrorBannerDismiss = exports.useErrorBannerContext = exports.ErrorBannerProvider = exports.ErrorBannerField = exports.ErrorBanner = void 0;
|
|
4
|
+
var ErrorBanner_1 = require("./ErrorBanner");
|
|
5
|
+
Object.defineProperty(exports, "ErrorBanner", { enumerable: true, get: function () { return ErrorBanner_1.ErrorBanner; } });
|
|
6
|
+
var errorBannerContext_1 = require("./errorBannerContext");
|
|
7
|
+
Object.defineProperty(exports, "ErrorBannerField", { enumerable: true, get: function () { return errorBannerContext_1.ErrorBannerField; } });
|
|
8
|
+
Object.defineProperty(exports, "ErrorBannerProvider", { enumerable: true, get: function () { return errorBannerContext_1.ErrorBannerProvider; } });
|
|
9
|
+
Object.defineProperty(exports, "useErrorBannerContext", { enumerable: true, get: function () { return errorBannerContext_1.useErrorBannerContext; } });
|
|
10
|
+
Object.defineProperty(exports, "useErrorBannerDismiss", { enumerable: true, get: function () { return errorBannerContext_1.useErrorBannerDismiss; } });
|
|
11
|
+
Object.defineProperty(exports, "useErrorBannerField", { enumerable: true, get: function () { return errorBannerContext_1.useErrorBannerField; } });
|
|
12
|
+
var errorBannerThemeRoles_1 = require("./errorBannerThemeRoles");
|
|
13
|
+
Object.defineProperty(exports, "ERROR_BANNER_THEME_ROLES", { enumerable: true, get: function () { return errorBannerThemeRoles_1.ERROR_BANNER_THEME_ROLES; } });
|
|
14
|
+
var useErrorBanner_1 = require("./useErrorBanner");
|
|
15
|
+
Object.defineProperty(exports, "useErrorBanner", { enumerable: true, get: function () { return useErrorBanner_1.useErrorBanner; } });
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ErrorBanner/index.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,2DAM8B;AAL5B,sHAAA,gBAAgB,OAAA;AAChB,yHAAA,mBAAmB,OAAA;AACnB,2HAAA,qBAAqB,OAAA;AACrB,2HAAA,qBAAqB,OAAA;AACrB,yHAAA,mBAAmB,OAAA;AAErB,iEAGiC;AAF/B,iIAAA,wBAAwB,OAAA;AAG1B,mDAAkD;AAAzC,gHAAA,cAAc,OAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type FieldError = {
|
|
2
|
+
/** Matches the field `name`. */
|
|
3
|
+
field: string;
|
|
4
|
+
/** Banner row, about 40 characters. */
|
|
5
|
+
short: string;
|
|
6
|
+
/** Fuller sentence for the field's accessibility hint. */
|
|
7
|
+
message: string;
|
|
8
|
+
};
|
|
9
|
+
export type ErrorBannerProps = {
|
|
10
|
+
open: boolean;
|
|
11
|
+
errors: readonly FieldError[];
|
|
12
|
+
/** Scroll the field into view. The banner stays open until dismiss or an edit. */
|
|
13
|
+
onJump: (field: string) => void;
|
|
14
|
+
onDismiss: () => void;
|
|
15
|
+
/** Reported so the host can scroll the field clear of the banner. */
|
|
16
|
+
onHeightChange?: (height: number) => void;
|
|
17
|
+
/** Override `useSafeAreaInsets().top`. */
|
|
18
|
+
safeAreaTop?: number;
|
|
19
|
+
paddingHorizontal?: number;
|
|
20
|
+
/** Defaults to theme role `errorBannerBackground`. */
|
|
21
|
+
backgroundColor?: string;
|
|
22
|
+
/** Defaults to theme role `errorBannerText`. */
|
|
23
|
+
textColor?: string;
|
|
24
|
+
/** Defaults to theme role `errorBannerSecondary`. Dismiss and arrows. */
|
|
25
|
+
secondaryColor?: string;
|
|
26
|
+
/** Defaults to theme role `errorBannerDivider`. */
|
|
27
|
+
dividerColor?: string;
|
|
28
|
+
/** Defaults to theme role `errorBannerAccent`. Megaphone disc. */
|
|
29
|
+
accentColor?: string;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/ErrorBanner/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC;IAC9B,kFAAkF;IAClF,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,qEAAqE;IACrE,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,sDAAsD;IACtD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mDAAmD;IACnD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/ErrorBanner/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FieldError } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Open / dismiss state for a field-error banner.
|
|
4
|
+
* Call `present` when the runner submits. Call `dismiss` when they close it
|
|
5
|
+
* or edit the form. A cleared error list resets dismiss so the next failure
|
|
6
|
+
* can show the banner again.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useErrorBanner(errors: readonly FieldError[]): {
|
|
9
|
+
open: boolean;
|
|
10
|
+
dismiss: () => void;
|
|
11
|
+
present: () => void;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=useErrorBanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useErrorBanner.d.ts","sourceRoot":"","sources":["../../../src/components/ErrorBanner/useErrorBanner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE;;;;EAsB3D"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useErrorBanner = useErrorBanner;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const errorBannerCopy_1 = require("./errorBannerCopy");
|
|
6
|
+
/**
|
|
7
|
+
* Open / dismiss state for a field-error banner.
|
|
8
|
+
* Call `present` when the runner submits. Call `dismiss` when they close it
|
|
9
|
+
* or edit the form. A cleared error list resets dismiss so the next failure
|
|
10
|
+
* can show the banner again.
|
|
11
|
+
*/
|
|
12
|
+
function useErrorBanner(errors) {
|
|
13
|
+
const [dismissed, setDismissed] = (0, react_1.useState)(false);
|
|
14
|
+
(0, react_1.useEffect)(() => {
|
|
15
|
+
if (errors.length === 0) {
|
|
16
|
+
setDismissed(false);
|
|
17
|
+
}
|
|
18
|
+
}, [errors.length]);
|
|
19
|
+
const dismiss = (0, react_1.useCallback)(() => {
|
|
20
|
+
setDismissed(true);
|
|
21
|
+
}, []);
|
|
22
|
+
const present = (0, react_1.useCallback)(() => {
|
|
23
|
+
setDismissed(false);
|
|
24
|
+
}, []);
|
|
25
|
+
return {
|
|
26
|
+
open: (0, errorBannerCopy_1.errorBannerOpen)(errors.length, dismissed),
|
|
27
|
+
dismiss,
|
|
28
|
+
present,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=useErrorBanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useErrorBanner.js","sourceRoot":"","sources":["../../../src/components/ErrorBanner/useErrorBanner.ts"],"names":[],"mappings":";;AAUA,wCAsBC;AAhCD,iCAAyD;AACzD,uDAAoD;AAGpD;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,MAA6B;IAC1D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAElD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAEpB,MAAM,OAAO,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAC/B,YAAY,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,OAAO,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAC/B,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,IAAI,EAAE,IAAA,iCAAe,EAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;QAC/C,OAAO;QACP,OAAO;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -6,5 +6,5 @@ export type FieldChromeProps = FieldSharedProps & {
|
|
|
6
6
|
minHeight?: number;
|
|
7
7
|
textAlignVertical?: TextInputProps["textAlignVertical"];
|
|
8
8
|
};
|
|
9
|
-
export declare function FieldChrome({ value, onChangeText, borderColor: borderColorProp, focusedBorderColor: focusedBorderColorProp, errorColor: errorColorProp, textColor: textColorProp, labelColor: labelColorProp, placeholderColor: placeholderColorProp, backgroundColor: backgroundColorProp, label, description, error, placeholder, radius, editable, clearIcon, onClear, style, inputStyle, multiline, numberOfLines, minHeight, textAlignVertical, secureTextEntry, keyboardType, autoCapitalize, autoComplete, textContentType, onFocus, onBlur, ref, }: FieldChromeProps): import("react").JSX.Element;
|
|
9
|
+
export declare function FieldChrome({ name, value, onChangeText, borderColor: borderColorProp, focusedBorderColor: focusedBorderColorProp, errorColor: errorColorProp, textColor: textColorProp, labelColor: labelColorProp, placeholderColor: placeholderColorProp, backgroundColor: backgroundColorProp, label, description, error, placeholder, radius, editable, clearIcon, onClear, style, inputStyle, multiline, numberOfLines, minHeight, textAlignVertical, secureTextEntry, keyboardType, autoCapitalize, autoComplete, textContentType, onFocus, onBlur, ref, }: FieldChromeProps): import("react").JSX.Element;
|
|
10
10
|
//# sourceMappingURL=fieldChrome.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fieldChrome.d.ts","sourceRoot":"","sources":["../../../src/components/Field/fieldChrome.tsx"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"fieldChrome.d.ts","sourceRoot":"","sources":["../../../src/components/Field/fieldChrome.tsx"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,cAAc,CAAC;AAWtB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGhD,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,GAAG;IAChD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,cAAc,CAAC,mBAAmB,CAAC,CAAC;CACzD,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,KAAK,EACL,YAAY,EACZ,WAAW,EAAE,eAAe,EAC5B,kBAAkB,EAAE,sBAAsB,EAC1C,UAAU,EAAE,cAAc,EAC1B,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,cAAc,EAC1B,gBAAgB,EAAE,oBAAoB,EACtC,eAAe,EAAE,mBAAmB,EACpC,KAAK,EACL,WAAW,EACX,KAAK,EACL,WAAW,EACX,MAAa,EACb,QAAe,EACf,SAAS,EACT,OAAO,EACP,KAAK,EACL,UAAU,EACV,SAAiB,EACjB,aAAa,EACb,SAAc,EACd,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,eAAe,EACf,OAAO,EACP,MAAM,EACN,GAAG,GACJ,EAAE,gBAAgB,+BA8IlB"}
|