react-native-terra-ui 0.11.17 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/lib/module/components/accordion/Accordion.js +109 -0
- package/lib/module/components/accordion/Accordion.js.map +1 -0
- package/lib/module/components/accordion/context.js +34 -0
- package/lib/module/components/accordion/context.js.map +1 -0
- package/lib/module/components/accordion/hooks/use-accordion-core.js +46 -0
- package/lib/module/components/accordion/hooks/use-accordion-core.js.map +1 -0
- package/lib/module/components/accordion/index.js +5 -0
- package/lib/module/components/accordion/index.js.map +1 -0
- package/lib/module/components/accordion/parts/AccordionContent.js +98 -0
- package/lib/module/components/accordion/parts/AccordionContent.js.map +1 -0
- package/lib/module/components/accordion/parts/AccordionIndicator.js +60 -0
- package/lib/module/components/accordion/parts/AccordionIndicator.js.map +1 -0
- package/lib/module/components/accordion/parts/AccordionItem.js +53 -0
- package/lib/module/components/accordion/parts/AccordionItem.js.map +1 -0
- package/lib/module/components/accordion/parts/AccordionTrigger.js +85 -0
- package/lib/module/components/accordion/parts/AccordionTrigger.js.map +1 -0
- package/lib/module/components/accordion/types.js +4 -0
- package/lib/module/components/accordion/types.js.map +1 -0
- package/lib/module/components/accordion/utils.js +15 -0
- package/lib/module/components/accordion/utils.js.map +1 -0
- package/lib/module/components/badge/Badge.js +219 -64
- package/lib/module/components/badge/Badge.js.map +1 -1
- package/lib/module/components/badge/WithBadge.js +94 -0
- package/lib/module/components/badge/WithBadge.js.map +1 -0
- package/lib/module/components/badge/index.js +1 -0
- package/lib/module/components/badge/index.js.map +1 -1
- package/lib/module/components/badge/utils.js +3 -3
- package/lib/module/components/header/parts/HeaderBar.js +34 -7
- package/lib/module/components/header/parts/HeaderBar.js.map +1 -1
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/typescript/src/components/accordion/Accordion.d.ts +33 -0
- package/lib/typescript/src/components/accordion/Accordion.d.ts.map +1 -0
- package/lib/typescript/src/components/accordion/context.d.ts +25 -0
- package/lib/typescript/src/components/accordion/context.d.ts.map +1 -0
- package/lib/typescript/src/components/accordion/hooks/use-accordion-core.d.ts +11 -0
- package/lib/typescript/src/components/accordion/hooks/use-accordion-core.d.ts.map +1 -0
- package/lib/typescript/src/components/accordion/index.d.ts +8 -0
- package/lib/typescript/src/components/accordion/index.d.ts.map +1 -0
- package/lib/typescript/src/components/accordion/parts/AccordionContent.d.ts +8 -0
- package/lib/typescript/src/components/accordion/parts/AccordionContent.d.ts.map +1 -0
- package/lib/typescript/src/components/accordion/parts/AccordionIndicator.d.ts +16 -0
- package/lib/typescript/src/components/accordion/parts/AccordionIndicator.d.ts.map +1 -0
- package/lib/typescript/src/components/accordion/parts/AccordionItem.d.ts +16 -0
- package/lib/typescript/src/components/accordion/parts/AccordionItem.d.ts.map +1 -0
- package/lib/typescript/src/components/accordion/parts/AccordionTrigger.d.ts +11 -0
- package/lib/typescript/src/components/accordion/parts/AccordionTrigger.d.ts.map +1 -0
- package/lib/typescript/src/components/accordion/types.d.ts +65 -0
- package/lib/typescript/src/components/accordion/types.d.ts.map +1 -0
- package/lib/typescript/src/components/accordion/utils.d.ts +8 -0
- package/lib/typescript/src/components/accordion/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/badge/Badge.d.ts +13 -9
- package/lib/typescript/src/components/badge/Badge.d.ts.map +1 -1
- package/lib/typescript/src/components/badge/WithBadge.d.ts +18 -0
- package/lib/typescript/src/components/badge/WithBadge.d.ts.map +1 -0
- package/lib/typescript/src/components/badge/index.d.ts +2 -1
- package/lib/typescript/src/components/badge/index.d.ts.map +1 -1
- package/lib/typescript/src/components/badge/types.d.ts +35 -12
- package/lib/typescript/src/components/badge/types.d.ts.map +1 -1
- package/lib/typescript/src/components/badge/utils.d.ts +3 -3
- package/lib/typescript/src/components/badge/utils.d.ts.map +1 -1
- package/lib/typescript/src/components/header/parts/HeaderBar.d.ts.map +1 -1
- package/lib/typescript/src/components/index.d.ts +1 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/accordion/Accordion.tsx +116 -0
- package/src/components/accordion/context.ts +45 -0
- package/src/components/accordion/hooks/use-accordion-core.ts +51 -0
- package/src/components/accordion/index.ts +14 -0
- package/src/components/accordion/parts/AccordionContent.tsx +96 -0
- package/src/components/accordion/parts/AccordionIndicator.tsx +67 -0
- package/src/components/accordion/parts/AccordionItem.tsx +55 -0
- package/src/components/accordion/parts/AccordionTrigger.tsx +88 -0
- package/src/components/accordion/types.ts +71 -0
- package/src/components/accordion/utils.ts +12 -0
- package/src/components/badge/Badge.tsx +177 -59
- package/src/components/badge/WithBadge.tsx +79 -0
- package/src/components/badge/index.ts +2 -1
- package/src/components/badge/types.ts +36 -12
- package/src/components/badge/utils.ts +3 -3
- package/src/components/header/parts/HeaderBar.tsx +41 -8
- package/src/components/index.ts +1 -0
- package/lib/module/components/badge/parts/BadgeIndicator.js +0 -212
- package/lib/module/components/badge/parts/BadgeIndicator.js.map +0 -1
- package/lib/typescript/src/components/badge/parts/BadgeIndicator.d.ts +0 -19
- package/lib/typescript/src/components/badge/parts/BadgeIndicator.d.ts.map +0 -1
- package/src/components/badge/parts/BadgeIndicator.tsx +0 -178
|
@@ -1,92 +1,247 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { View } from "react-native-unistyles/components/native/View";
|
|
4
|
-
import {
|
|
5
|
-
import { StyleSheet } from "react-native-unistyles";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { Text as RNText } from "react-native-unistyles/components/native/Text";
|
|
5
|
+
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
|
6
|
+
import { resolveThemeColor } from "../../utils/resolve-theme-color.js";
|
|
7
|
+
import { FONT_WEIGHT_VALUE, SYSTEM_FONT } from "../../utils/typography.js";
|
|
8
|
+
import { getCustomBadgeColors, hasLabel } from "./utils.js";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
const SCHEME_NAMES = new Set(["primary", "secondary", "success", "warning", "danger"]);
|
|
11
|
+
/** Label foreground per scheme — mirrors the spec's token table. */
|
|
12
|
+
const FG_TOKEN = {
|
|
13
|
+
primary: "accent.solid.fg",
|
|
14
|
+
secondary: "neutral.solid.fg",
|
|
15
|
+
success: "success.solid.fg",
|
|
16
|
+
warning: "warning.solid.fg",
|
|
17
|
+
danger: "danger.solid.fg"
|
|
18
|
+
};
|
|
19
|
+
const LABEL_VARIANT = {
|
|
20
|
+
sm: "label-sm",
|
|
21
|
+
md: "label-md",
|
|
22
|
+
lg: "label-lg"
|
|
23
|
+
};
|
|
8
24
|
|
|
9
25
|
/**
|
|
10
|
-
*
|
|
26
|
+
* A dot, or a pill carrying a count or short label.
|
|
11
27
|
*
|
|
12
28
|
* ```tsx
|
|
13
|
-
* <
|
|
14
|
-
*
|
|
15
|
-
* </Badge>
|
|
29
|
+
* <Text>Appearing</Text>
|
|
30
|
+
* <Badge color="secondary" size="sm" label={56} />
|
|
16
31
|
* ```
|
|
17
32
|
*
|
|
18
|
-
*
|
|
19
|
-
* the
|
|
20
|
-
*
|
|
33
|
+
* Stands on its own, inline in a row beside the text it counts. To pin one to
|
|
34
|
+
* the corner of an icon or button, wrap that element in `WithBadge`, which
|
|
35
|
+
* renders this and owns only the position.
|
|
36
|
+
*
|
|
37
|
+
* `useUnistyles` is called unconditionally, which is what subscribes this
|
|
38
|
+
* component to theme changes. The background below comes from a variant, which
|
|
39
|
+
* unistyles applies straight to the native node on a theme switch; without a
|
|
40
|
+
* re-render React would go on believing the node holds the previous theme's
|
|
41
|
+
* value. `Chip` documents the same hazard on its root.
|
|
21
42
|
*/
|
|
22
|
-
|
|
23
|
-
const Badge = /*#__PURE__*/forwardRef(function Badge({
|
|
24
|
-
children,
|
|
25
|
-
placement = "top-right",
|
|
43
|
+
export const Badge = ({
|
|
26
44
|
label,
|
|
27
45
|
color = "danger",
|
|
28
46
|
size = "md",
|
|
29
|
-
|
|
30
|
-
isVisible = true,
|
|
31
|
-
fullWidth = false,
|
|
47
|
+
ring = false,
|
|
32
48
|
accessibilityLabel,
|
|
33
49
|
style,
|
|
34
50
|
...rest
|
|
35
|
-
}
|
|
51
|
+
}) => {
|
|
52
|
+
const {
|
|
53
|
+
theme
|
|
54
|
+
} = useUnistyles();
|
|
55
|
+
// A literal never matches one of the five variant options, so it's cast to
|
|
56
|
+
// satisfy `useVariants`'s literal-union type while still being compared
|
|
57
|
+
// against the real value below.
|
|
36
58
|
const _styles = styles;
|
|
37
59
|
{
|
|
38
60
|
const styles = _styles.useVariants({
|
|
39
|
-
|
|
61
|
+
color: color,
|
|
62
|
+
size,
|
|
63
|
+
ring
|
|
64
|
+
});
|
|
65
|
+
const custom = SCHEME_NAMES.has(color) ? null : getCustomBadgeColors(color);
|
|
66
|
+
const labelled = hasLabel(label);
|
|
67
|
+
const foreground = custom ? custom.fg : FG_TOKEN[color];
|
|
68
|
+
|
|
69
|
+
// An explicit label wins even on a dot; a dot with nothing to announce is
|
|
70
|
+
// decorative and hidden rather than read out as an unlabelled element.
|
|
71
|
+
const announced = accessibilityLabel ?? (labelled ? String(label) : undefined);
|
|
72
|
+
const accessibility = announced ? {
|
|
73
|
+
accessible: true,
|
|
74
|
+
accessibilityLabel: announced
|
|
75
|
+
} : {
|
|
76
|
+
accessibilityElementsHidden: true,
|
|
77
|
+
importantForAccessibility: "no-hide-descendants",
|
|
78
|
+
"aria-hidden": true
|
|
79
|
+
};
|
|
80
|
+
return /*#__PURE__*/_jsx(View, {
|
|
81
|
+
style: [styles.indicator, labelled ? styles.pill : styles.dot, custom ? {
|
|
82
|
+
backgroundColor: custom.bg
|
|
83
|
+
} : null, style],
|
|
84
|
+
...rest,
|
|
85
|
+
...accessibility,
|
|
86
|
+
children: labelled ? /*#__PURE__*/_jsx(RNText, {
|
|
87
|
+
style: [styles.label, {
|
|
88
|
+
color: resolveThemeColor(foreground, theme)
|
|
89
|
+
}],
|
|
90
|
+
maxFontSizeMultiplier: theme.typography.variants[LABEL_VARIANT[size]].maxFontSizeMultiplier,
|
|
91
|
+
numberOfLines: 1,
|
|
92
|
+
children: label
|
|
93
|
+
}) : null
|
|
40
94
|
});
|
|
41
|
-
return (
|
|
42
|
-
/*#__PURE__*/
|
|
43
|
-
// `style` last so an explicit `alignSelf` beats `fullWidth`.
|
|
44
|
-
_jsxs(View, {
|
|
45
|
-
ref: ref,
|
|
46
|
-
style: [styles.wrapper, style],
|
|
47
|
-
...rest,
|
|
48
|
-
children: [children, isVisible ? /*#__PURE__*/_jsx(View, {
|
|
49
|
-
pointerEvents: "box-none",
|
|
50
|
-
style: [styles.anchor, getAnchorPosition(placement, size, offset)],
|
|
51
|
-
children: /*#__PURE__*/_jsx(BadgeIndicator, {
|
|
52
|
-
label: label,
|
|
53
|
-
color: color,
|
|
54
|
-
size: size,
|
|
55
|
-
accessibilityLabel: accessibilityLabel
|
|
56
|
-
})
|
|
57
|
-
}) : null]
|
|
58
|
-
})
|
|
59
|
-
);
|
|
60
95
|
}
|
|
61
|
-
}
|
|
62
|
-
export { Badge };
|
|
96
|
+
};
|
|
63
97
|
|
|
64
98
|
// ─── Styles ───────────────────────────────────────────────────────────────────
|
|
65
99
|
//
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
100
|
+
// `color` is a plain variant rather than a compound one: `Badge` renders solid
|
|
101
|
+
// only, so there is no second paint axis for it to interact with.
|
|
102
|
+
//
|
|
103
|
+
// React Native's box model is border-box, so the ring below eats into the
|
|
104
|
+
// badge rather than growing it — the dot's outer diameter stays exactly what
|
|
105
|
+
// `size` declares, with no compensation arithmetic, ring or not.
|
|
106
|
+
const styles = StyleSheet.create(theme => {
|
|
107
|
+
const c = theme.color;
|
|
108
|
+
// A custom font encodes its weight in the family name, so only the system
|
|
109
|
+
// font takes a numeric `fontWeight` — the same branch `Chip` makes. Inlined
|
|
110
|
+
// rather than extracted: the unistyles Babel plugin rewrites this factory,
|
|
111
|
+
// and an imported function called from inside it is not in scope at runtime.
|
|
112
|
+
const labelFont = theme.typography.fonts.semibold;
|
|
113
|
+
const isSystemLabelFont = labelFont === SYSTEM_FONT;
|
|
114
|
+
return {
|
|
115
|
+
indicator: {
|
|
116
|
+
alignItems: "center",
|
|
117
|
+
justifyContent: "center",
|
|
118
|
+
borderRadius: theme.radius.full,
|
|
119
|
+
borderColor: c["surface.canvas"],
|
|
120
|
+
variants: {
|
|
121
|
+
// No styles of its own; it only has to exist for the compound rows
|
|
122
|
+
// below to match on. The ring's width depends on size as well.
|
|
123
|
+
size: {
|
|
124
|
+
sm: {},
|
|
125
|
+
md: {},
|
|
126
|
+
lg: {}
|
|
127
|
+
},
|
|
128
|
+
ring: {
|
|
129
|
+
true: {},
|
|
130
|
+
false: {
|
|
131
|
+
borderWidth: 0
|
|
132
|
+
}
|
|
80
133
|
},
|
|
81
|
-
|
|
82
|
-
|
|
134
|
+
color: {
|
|
135
|
+
primary: {
|
|
136
|
+
backgroundColor: c["accent.solid.bg"]
|
|
137
|
+
},
|
|
138
|
+
secondary: {
|
|
139
|
+
backgroundColor: c["neutral.solid.bg"]
|
|
140
|
+
},
|
|
141
|
+
success: {
|
|
142
|
+
backgroundColor: c["success.solid.bg"]
|
|
143
|
+
},
|
|
144
|
+
warning: {
|
|
145
|
+
backgroundColor: c["warning.solid.bg"]
|
|
146
|
+
},
|
|
147
|
+
danger: {
|
|
148
|
+
backgroundColor: c["danger.solid.bg"]
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
compoundVariants: [{
|
|
153
|
+
ring: true,
|
|
154
|
+
size: "sm",
|
|
155
|
+
styles: {
|
|
156
|
+
borderWidth: 1.5
|
|
157
|
+
}
|
|
158
|
+
}, {
|
|
159
|
+
ring: true,
|
|
160
|
+
size: "md",
|
|
161
|
+
styles: {
|
|
162
|
+
borderWidth: 2
|
|
83
163
|
}
|
|
84
|
-
}
|
|
164
|
+
}, {
|
|
165
|
+
ring: true,
|
|
166
|
+
size: "lg",
|
|
167
|
+
styles: {
|
|
168
|
+
borderWidth: 2
|
|
169
|
+
}
|
|
170
|
+
}],
|
|
171
|
+
uni__dependencies: [0, 4]
|
|
85
172
|
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
173
|
+
// These diameters are mirrored by `DOT_SIZE` in `./utils.ts`, which the
|
|
174
|
+
// anchor arithmetic reads. The Babel plugin needs them literal here, so a
|
|
175
|
+
// test asserts the two stay equal.
|
|
176
|
+
dot: {
|
|
177
|
+
variants: {
|
|
178
|
+
size: {
|
|
179
|
+
sm: {
|
|
180
|
+
width: 12,
|
|
181
|
+
height: 12
|
|
182
|
+
},
|
|
183
|
+
md: {
|
|
184
|
+
width: 16,
|
|
185
|
+
height: 16
|
|
186
|
+
},
|
|
187
|
+
lg: {
|
|
188
|
+
width: 20,
|
|
189
|
+
height: 20
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
uni__dependencies: [4]
|
|
194
|
+
},
|
|
195
|
+
pill: {
|
|
196
|
+
variants: {
|
|
197
|
+
size: {
|
|
198
|
+
sm: {
|
|
199
|
+
height: 18,
|
|
200
|
+
minWidth: 18,
|
|
201
|
+
paddingHorizontal: 5
|
|
202
|
+
},
|
|
203
|
+
md: {
|
|
204
|
+
height: 22,
|
|
205
|
+
minWidth: 22,
|
|
206
|
+
paddingHorizontal: 6
|
|
207
|
+
},
|
|
208
|
+
lg: {
|
|
209
|
+
height: 26,
|
|
210
|
+
minWidth: 26,
|
|
211
|
+
paddingHorizontal: 8
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
uni__dependencies: [4]
|
|
216
|
+
},
|
|
217
|
+
// Spelled out rather than derived from `LABEL_VARIANT`: the unistyles Babel
|
|
218
|
+
// plugin reads this object statically, so computed variant keys are not
|
|
219
|
+
// safe here even though they would resolve correctly under test.
|
|
220
|
+
label: {
|
|
221
|
+
textAlign: "center",
|
|
222
|
+
fontFamily: isSystemLabelFont ? undefined : labelFont,
|
|
223
|
+
fontWeight: isSystemLabelFont ? FONT_WEIGHT_VALUE.semibold : undefined,
|
|
224
|
+
variants: {
|
|
225
|
+
size: {
|
|
226
|
+
sm: {
|
|
227
|
+
fontSize: theme.typography.variants["label-sm"].fontSize,
|
|
228
|
+
lineHeight: theme.typography.variants["label-sm"].lineHeight,
|
|
229
|
+
letterSpacing: theme.typography.variants["label-sm"].letterSpacing
|
|
230
|
+
},
|
|
231
|
+
md: {
|
|
232
|
+
fontSize: theme.typography.variants["label-md"].fontSize,
|
|
233
|
+
lineHeight: theme.typography.variants["label-md"].lineHeight,
|
|
234
|
+
letterSpacing: theme.typography.variants["label-md"].letterSpacing
|
|
235
|
+
},
|
|
236
|
+
lg: {
|
|
237
|
+
fontSize: theme.typography.variants["label-lg"].fontSize,
|
|
238
|
+
lineHeight: theme.typography.variants["label-lg"].lineHeight,
|
|
239
|
+
letterSpacing: theme.typography.variants["label-lg"].letterSpacing
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
uni__dependencies: [0, 4]
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
});
|
|
92
247
|
//# sourceMappingURL=Badge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["StyleSheet","useUnistyles","resolveThemeColor","FONT_WEIGHT_VALUE","SYSTEM_FONT","getCustomBadgeColors","hasLabel","jsx","_jsx","SCHEME_NAMES","Set","FG_TOKEN","primary","secondary","success","warning","danger","LABEL_VARIANT","sm","md","lg","Badge","label","color","size","ring","accessibilityLabel","style","rest","theme","_styles","styles","useVariants","custom","has","labelled","foreground","fg","announced","String","undefined","accessibility","accessible","accessibilityElementsHidden","importantForAccessibility","View","indicator","pill","dot","backgroundColor","bg","children","RNText","maxFontSizeMultiplier","typography","variants","numberOfLines","create","c","labelFont","fonts","semibold","isSystemLabelFont","alignItems","justifyContent","borderRadius","radius","full","borderColor","true","false","borderWidth","compoundVariants","uni__dependencies","width","height","minWidth","paddingHorizontal","textAlign","fontFamily","fontWeight","fontSize","lineHeight","letterSpacing"],"sourceRoot":"../../../../src","sources":["components/badge/Badge.tsx"],"mappings":";;;;AAEA,SAASA,UAAU,EAAEC,YAAY,QAAQ,wBAAwB;AAGjE,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB,EAAEC,WAAW;AAEvC,SAASC,oBAAoB,EAAEC,QAAQ;AAAkB,SAAAC,GAAA,IAAAC,IAAA;AAEzD,MAAMC,YAAY,GAAG,IAAIC,GAAG,CAAC,CAAC,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AAItF;AACA,MAAMC,QAAyC,GAAG;EAChDC,OAAO,EAAE,iBAAiB;EAC1BC,SAAS,EAAE,kBAAkB;EAC7BC,OAAO,EAAE,kBAAkB;EAC3BC,OAAO,EAAE,kBAAkB;EAC3BC,MAAM,EAAE;AACV,CAAC;AAED,MAAMC,aAAiD,GAAG;EACxDC,EAAE,EAAE,UAAU;EACdC,EAAE,EAAE,UAAU;EACdC,EAAE,EAAE;AACN,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,KAAK,GAAGA,CAAC;EACpBC,KAAK;EACLC,KAAK,GAAG,QAAQ;EAChBC,IAAI,GAAG,IAAI;EACXC,IAAI,GAAG,KAAK;EACZC,kBAAkB;EAClBC,KAAK;EACL,GAAGC;AACO,CAAC,KAAK;EAChB,MAAM;IAAEC;EAAM,CAAC,GAAG5B,YAAY,CAAC,CAA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
2
|
+
|
|
3
|
+
import { View } from "react-native-unistyles/components/native/View";
|
|
4
|
+
import { forwardRef } from "react";
|
|
5
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
6
|
+
import { Badge } from "./Badge.js";
|
|
7
|
+
import { getAnchorPosition } from "./utils.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Pins a `Badge` to one corner of the element it wraps.
|
|
11
|
+
*
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <WithBadge placement="top-right" color="danger" label={3}>
|
|
14
|
+
* <Toolbar.Button icon="bell" accessibilityLabel="Notifications" />
|
|
15
|
+
* </WithBadge>
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* The child renders untouched — `WithBadge` contributes the positioning context
|
|
19
|
+
* and the overlay, nothing else. A round child usually wants a negative
|
|
20
|
+
* `offset`, since the corner being anchored to is the bounding box's, not the
|
|
21
|
+
* circle's. For a badge that sits inline beside text, use `Badge` on its own.
|
|
22
|
+
*/
|
|
23
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
+
const WithBadge = /*#__PURE__*/forwardRef(function WithBadge({
|
|
25
|
+
children,
|
|
26
|
+
placement = "top-right",
|
|
27
|
+
label,
|
|
28
|
+
color = "danger",
|
|
29
|
+
size = "md",
|
|
30
|
+
offset = 0,
|
|
31
|
+
isVisible = true,
|
|
32
|
+
fullWidth = false,
|
|
33
|
+
accessibilityLabel,
|
|
34
|
+
style,
|
|
35
|
+
...rest
|
|
36
|
+
}, ref) {
|
|
37
|
+
const _styles = styles;
|
|
38
|
+
{
|
|
39
|
+
const styles = _styles.useVariants({
|
|
40
|
+
fullWidth
|
|
41
|
+
});
|
|
42
|
+
return (
|
|
43
|
+
/*#__PURE__*/
|
|
44
|
+
// `style` last so an explicit `alignSelf` beats `fullWidth`.
|
|
45
|
+
_jsxs(View, {
|
|
46
|
+
ref: ref,
|
|
47
|
+
style: [styles.wrapper, style],
|
|
48
|
+
...rest,
|
|
49
|
+
children: [children, isVisible ? /*#__PURE__*/_jsx(View, {
|
|
50
|
+
pointerEvents: "box-none",
|
|
51
|
+
style: [styles.anchor, getAnchorPosition(placement, size, offset)],
|
|
52
|
+
children: /*#__PURE__*/_jsx(Badge, {
|
|
53
|
+
label: label,
|
|
54
|
+
color: color,
|
|
55
|
+
size: size,
|
|
56
|
+
ring: true,
|
|
57
|
+
accessibilityLabel: accessibilityLabel
|
|
58
|
+
})
|
|
59
|
+
}) : null]
|
|
60
|
+
})
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
export { WithBadge };
|
|
65
|
+
|
|
66
|
+
// ─── Styles ───────────────────────────────────────────────────────────────────
|
|
67
|
+
//
|
|
68
|
+
// The badge's insets are computed in `getAnchorPosition`, not declared here:
|
|
69
|
+
// `offset` is an open-ended number, so it could never be a variant condition,
|
|
70
|
+
// and the position involves no theme tokens at all. That leaves this stylesheet
|
|
71
|
+
// with only what genuinely varies declaratively.
|
|
72
|
+
const styles = StyleSheet.create(() => ({
|
|
73
|
+
wrapper: {
|
|
74
|
+
position: "relative",
|
|
75
|
+
variants: {
|
|
76
|
+
// `alignSelf: 'flex-start'` hugs the child, so the indicator anchors to
|
|
77
|
+
// the child's bounds rather than the surrounding container's. A child
|
|
78
|
+
// that was stretching needs `fullWidth` to go on doing so.
|
|
79
|
+
fullWidth: {
|
|
80
|
+
true: {
|
|
81
|
+
alignSelf: "stretch"
|
|
82
|
+
},
|
|
83
|
+
false: {
|
|
84
|
+
alignSelf: "flex-start"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
uni__dependencies: [4]
|
|
89
|
+
},
|
|
90
|
+
anchor: {
|
|
91
|
+
position: "absolute"
|
|
92
|
+
}
|
|
93
|
+
}));
|
|
94
|
+
//# sourceMappingURL=WithBadge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","StyleSheet","Badge","getAnchorPosition","jsx","_jsx","jsxs","_jsxs","WithBadge","children","placement","label","color","size","offset","isVisible","fullWidth","accessibilityLabel","style","rest","ref","_styles","styles","useVariants","View","wrapper","pointerEvents","anchor","ring","create","position","variants","true","alignSelf","false","uni__dependencies"],"sourceRoot":"../../../../src","sources":["components/badge/WithBadge.tsx"],"mappings":";;;AAAA,SAA4BA,UAAU,QAAQ,OAAO;AAGrD,SAASC,UAAU,QAAQ,wBAAwB;AAEnD,SAASC,KAAK;AAEd,SAASC,iBAAiB;;AAE1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAbA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAcA,MAAMC,SAAS,gBAAGR,UAAU,CAA4C,SAASQ,SAASA,CACxF;EACEC,QAAQ;EACRC,SAAS,GAAG,WAAW;EACvBC,KAAK;EACLC,KAAK,GAAG,QAAQ;EAChBC,IAAI,GAAG,IAAI;EACXC,MAAM,GAAG,CAAC;EACVC,SAAS,GAAG,IAAI;EAChBC,SAAS,GAAG,KAAK;EACjBC,kBAAkB;EAClBC,KAAK;EACL,GAAGC;AACL,CAAC,EACDC,GAAG,EACH;EAAA,MAAAC,OAAA,GAAAC,MAAA;EAAA;IAAA,MAAAA,MAAA,GAAAD,OAAA,CAAAE,WAAA,CACmB;MAAEP;IAAU,CAAC;IAEhC;MAAA;MACE;MACAT,KAAA,CAACiB,IAAI;QAACJ,GAAG,EAAEA,GAAI;QAACF,KAAK,EAAE,CAACI,MAAM,CAACG,OAAO,EAAEP,KAAK,CAAE;QAAA,GAAKC,IAAI;QAAAV,QAAA,GACrDA,QAAQ,EACRM,SAAS,gBACRV,IAAA,CAACmB,IAAI;UAACE,aAAa,EAAC,UAAU;UAACR,KAAK,EAAE,CAACI,MAAM,CAACK,MAAM,EAAExB,iBAAiB,CAACO,SAAS,EAAEG,IAAI,EAAEC,MAAM,CAAC,CAAE;UAAAL,QAAA,eAChGJ,IAAA,CAACH,KAAK;YAACS,KAAK,EAAEA,KAAM;YAACC,KAAK,EAAEA,KAAM;YAACC,IAAI,EAAEA,IAAK;YAACe,IAAI;YAACX,kBAAkB,EAAEA;UAAmB,CAAE;QAAC,CAC1F,CAAC,GACL,IAAI;MAAA,CACJ;IAAC;EACP;AACJ,CAAC,CAAC;AAEF,SAAST,SAAS;;AAElB;AACA;AACA;AACA;AACA;AACA;AACA,MAAMc,MAAM,GAAGrB,UAAU,CAAC4B,MAAM,CAAC,OAAO;EACtCJ,OAAO,EAAE;IACPK,QAAQ,EAAE,UAAU;IACpBC,QAAQ,EAAE;MACR;MACA;MACA;MACAf,SAAS,EAAE;QACTgB,IAAI,EAAE;UAAEC,SAAS,EAAE;QAAU,CAAC;QAC9BC,KAAK,EAAE;UAAED,SAAS,EAAE;QAAa;MACnC;IACF,CAAC;IAAAE,iBAAA;EACH,CAAC;EACDR,MAAM,EAAE;IACNG,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Badge"],"sourceRoot":"../../../../src","sources":["components/badge/index.ts"],"mappings":";;AAAA,SAASA,KAAK","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Badge","WithBadge"],"sourceRoot":"../../../../src","sources":["components/badge/index.ts"],"mappings":";;AAAA,SAASA,KAAK;AAEd,SAASC,SAAS","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ import { readableOn } from "../../utils/color-utils.js";
|
|
|
6
6
|
// can't be a unistyles variant condition — it's derived here instead, the same
|
|
7
7
|
// way `chip/utils.ts` handles the equivalent case on `Chip`.
|
|
8
8
|
|
|
9
|
-
/** The
|
|
9
|
+
/** The badge's paint for a raw literal: the literal itself, plus a readable label. */
|
|
10
10
|
export function getCustomBadgeColors(literal) {
|
|
11
11
|
return {
|
|
12
12
|
bg: literal,
|
|
@@ -24,7 +24,7 @@ export function hasLabel(label) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* Outer diameter of the dot per size. The
|
|
27
|
+
* Outer diameter of the dot per size. The badge's own stylesheet repeats
|
|
28
28
|
* these as literals — the unistyles Babel plugin reads that object statically,
|
|
29
29
|
* so it cannot reference this table — and `anchorOffsetsMatchDotRadius` in the
|
|
30
30
|
* test suite is what keeps the two in step.
|
|
@@ -35,7 +35,7 @@ export const DOT_SIZE = {
|
|
|
35
35
|
lg: 20
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
38
|
-
* Absolute insets for
|
|
38
|
+
* Absolute insets for a `WithBadge`'s badge, in pure arithmetic rather than one
|
|
39
39
|
* compound variant per (placement, size) cell: `offset` is an open-ended number
|
|
40
40
|
* and could never be a variant condition, and nothing here touches the theme.
|
|
41
41
|
*
|
|
@@ -34,6 +34,13 @@ export function HeaderBar({
|
|
|
34
34
|
left: 0,
|
|
35
35
|
right: 0
|
|
36
36
|
});
|
|
37
|
+
// Toolbar widths, so a centered title can stay clear of both sides.
|
|
38
|
+
const [leadingWidth, setLeadingWidth] = useState(0);
|
|
39
|
+
const [trailingWidth, setTrailingWidth] = useState(0);
|
|
40
|
+
const onLeadingLayout = event => setLeadingWidth(event.nativeEvent.layout.width);
|
|
41
|
+
const onTrailingLayout = event => setTrailingWidth(event.nativeEvent.layout.width);
|
|
42
|
+
const hasLeading = leading != null || dismissAction === "back";
|
|
43
|
+
const hasTrailing = trailing != null || dismissAction === "close";
|
|
37
44
|
const _styles = styles;
|
|
38
45
|
{
|
|
39
46
|
const styles = _styles.useVariants({
|
|
@@ -67,18 +74,21 @@ export function HeaderBar({
|
|
|
67
74
|
animatedStyle: surfaceStyle
|
|
68
75
|
}), /*#__PURE__*/_jsx(HeaderWindowInsets, {
|
|
69
76
|
onInsetsChange: setWindowInsets
|
|
70
|
-
}),
|
|
77
|
+
}), hasLeading && /*#__PURE__*/_jsxs(Toolbar, {
|
|
78
|
+
onLayout: onLeadingLayout,
|
|
71
79
|
children: [dismissAction === "back" && dismiss, leading]
|
|
72
80
|
}), /*#__PURE__*/_jsx(Animated.View, {
|
|
73
|
-
style: [styles.titleContainer, styles.titleInsets(windowInsets.left, windowInsets.right, titleAlignment), titleStyle],
|
|
81
|
+
style: [styles.titleContainer, styles.titleInsets(windowInsets.left, windowInsets.right, hasLeading ? leadingWidth : 0, hasTrailing ? trailingWidth : 0, titleAlignment), titleStyle],
|
|
74
82
|
pointerEvents: isCustomTitle(title) ? "box-none" : "none",
|
|
75
83
|
children: isTextTitle(title) ? String(title).trim().length > 0 && /*#__PURE__*/_jsx(Text, {
|
|
76
84
|
style: styles.title,
|
|
85
|
+
numberOfLines: 1,
|
|
77
86
|
maxFontSizeMultiplier: theme.typography.variants["title-md"].maxFontSizeMultiplier,
|
|
78
87
|
children: title
|
|
79
88
|
}) : title
|
|
80
|
-
}),
|
|
89
|
+
}), hasTrailing && /*#__PURE__*/_jsxs(Toolbar, {
|
|
81
90
|
style: styles.trailing,
|
|
91
|
+
onLayout: onTrailingLayout,
|
|
82
92
|
children: [dismissAction === "close" && dismiss, trailing]
|
|
83
93
|
})]
|
|
84
94
|
})
|
|
@@ -92,10 +102,27 @@ const styles = StyleSheet.create((theme, runtime) => ({
|
|
|
92
102
|
paddingRight: Math.max(resolveScreenPadding(theme, runtime.breakpoint).x, right),
|
|
93
103
|
uni__dependencies: [0, 3]
|
|
94
104
|
}),
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
105
|
+
// A centered title spans the region between the window controls and is inset
|
|
106
|
+
// by the same amount from both of its edges, so it stays centered in that
|
|
107
|
+
// region. The inset is whichever side reaches further in — bar padding plus
|
|
108
|
+
// that side's toolbar — so a long title truncates before either toolbar
|
|
109
|
+
// instead of running underneath it. A left-aligned title is in the flex row
|
|
110
|
+
// already and needs none of this.
|
|
111
|
+
titleInsets: (left, right, leadingWidth, trailingWidth, alignment) => {
|
|
112
|
+
if (alignment !== "center") return {
|
|
113
|
+
uni__dependencies: [0, 3]
|
|
114
|
+
};
|
|
115
|
+
const padding = resolveScreenPadding(theme, runtime.breakpoint).x;
|
|
116
|
+
const gap = theme.spacing["3"];
|
|
117
|
+
const reachLeft = Math.max(padding, left) + (leadingWidth > 0 ? leadingWidth + gap : 0) - left;
|
|
118
|
+
const reachRight = Math.max(padding, right) + (trailingWidth > 0 ? trailingWidth + gap : 0) - right;
|
|
119
|
+
const inset = Math.max(reachLeft, reachRight);
|
|
120
|
+
return {
|
|
121
|
+
left: left + inset,
|
|
122
|
+
right: right + inset,
|
|
123
|
+
uni__dependencies: [0, 3]
|
|
124
|
+
};
|
|
125
|
+
},
|
|
99
126
|
bar: {
|
|
100
127
|
height: theme.layout.header.height,
|
|
101
128
|
flexDirection: "row",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useState","Animated","ScrollToTopGuard","StyleSheet","useUnistyles","FONT_WEIGHT_VALUE","resolveScreenPadding","Toolbar","HeaderDismissButton","isCustomTitle","isTextTitle","HeaderSurface","HeaderWindowInsets","jsx","_jsx","jsxs","_jsxs","HeaderBar","title","leading","trailing","titleAlignment","color","surfaceStyle","titleStyle","dismissAction","navigation","onDismiss","theme","windowInsets","setWindowInsets","left","right","_styles","styles","useVariants","dismiss","children","View","style","bar","animatedStyle","onInsetsChange","titleContainer","titleInsets","pointerEvents","String","trim","length","Text","maxFontSizeMultiplier","typography","variants","create","runtime","paddingLeft","Math","max","breakpoint","x","paddingRight","uni__dependencies","alignment","
|
|
1
|
+
{"version":3,"names":["useState","Animated","ScrollToTopGuard","StyleSheet","useUnistyles","FONT_WEIGHT_VALUE","resolveScreenPadding","Toolbar","HeaderDismissButton","isCustomTitle","isTextTitle","HeaderSurface","HeaderWindowInsets","jsx","_jsx","jsxs","_jsxs","HeaderBar","title","leading","trailing","titleAlignment","color","surfaceStyle","titleStyle","dismissAction","navigation","onDismiss","theme","windowInsets","setWindowInsets","left","right","leadingWidth","setLeadingWidth","trailingWidth","setTrailingWidth","onLeadingLayout","event","nativeEvent","layout","width","onTrailingLayout","hasLeading","hasTrailing","_styles","styles","useVariants","dismiss","children","View","style","bar","animatedStyle","onInsetsChange","onLayout","titleContainer","titleInsets","pointerEvents","String","trim","length","Text","numberOfLines","maxFontSizeMultiplier","typography","variants","create","runtime","paddingLeft","Math","max","breakpoint","x","paddingRight","uni__dependencies","alignment","padding","gap","spacing","reachLeft","reachRight","inset","height","header","flexDirection","alignItems","paddingHorizontal","screen","justifyContent","center","marginLeft","position","flex","fontSize","lineHeight","letterSpacing","fontWeight","textAlign"],"sourceRoot":"../../../../../src","sources":["components/header/parts/HeaderBar.tsx"],"mappings":";;;;AAAA,SAA8CA,QAAQ,QAAQ,OAAO;AAGrE,OAAOC,QAAQ,MAAM,yBAAyB;AAC9C,SAASC,gBAAgB,QAAQ,mCAAmC;AACpE,SAASC,UAAU,EAAEC,YAAY,QAAQ,wBAAwB;AAEjE,SAASC,iBAAiB;AAC1B,SAASC,oBAAoB;AAC7B,SAASC,OAAO;AAChB,SAASC,mBAAmB;AAC5B,SAASC,aAAa,EAAEC,WAAW;AACnC,SAASC,aAAa;AACtB,SAASC,kBAAkB;AAA+B,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAY1D;AACA,OAAO,SAASC,SAASA,CAAC;EACxBC,KAAK;EACLC,OAAO;EACPC,QAAQ;EACRC,cAAc;EACdC,KAAK;EACLC,YAAY;EACZC,UAAU;EACVC,aAAa,GAAG,MAAM;EACtBC,UAAU;EACVC;AACc,CAAC,EAAE;EACjB,MAAM;IAAEC;EAAM,CAAC,GAAGxB,YAAY,CAAC,CAAC;EAChC,MAAM,CAACyB,YAAY,EAAEC,eAAe,CAAC,GAAG9B,QAAQ,CAAC;IAAE+B,IAAI,EAAE,CAAC;IAAEC,KAAK,EAAE;EAAE,CAAC,CAAC;EACvE;EACA,MAAM,CAACC,YAAY,EAAEC,eAAe,CAAC,GAAGlC,QAAQ,CAAC,CAAC,CAAC;EACnD,MAAM,CAACmC,aA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;UAAEQ,SAAS,EAAE;QAAS,CAAC;QAC/BnE,IAAI,EAAE;UAAEmE,SAAS,EAAE;QAAO;MAC5B;IACF,CAAC;IAAAvB,iBAAA;EACH;AACF,CAAC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["components/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["components/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AccordionContent } from "./parts/AccordionContent.js";
|
|
2
|
+
import { AccordionIndicator } from "./parts/AccordionIndicator.js";
|
|
3
|
+
import { AccordionItem } from "./parts/AccordionItem.js";
|
|
4
|
+
import { AccordionTrigger } from "./parts/AccordionTrigger.js";
|
|
5
|
+
import type { AccordionProps } from "./types.js";
|
|
6
|
+
/**
|
|
7
|
+
* A vertical stack of headers that each open a panel of content.
|
|
8
|
+
*
|
|
9
|
+
* `'single'` mode (the default) keeps one item open at a time; `'multiple'`
|
|
10
|
+
* lets any number be open. Uncontrolled through `defaultValue`, or controlled
|
|
11
|
+
* through `value` + `onValueChange`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <Accordion defaultValue="shipping">
|
|
15
|
+
* <Accordion.Item value="shipping">
|
|
16
|
+
* <Accordion.Trigger>
|
|
17
|
+
* How long does shipping take?
|
|
18
|
+
* <Accordion.Indicator />
|
|
19
|
+
* </Accordion.Trigger>
|
|
20
|
+
* <Accordion.Content>3–5 business days.</Accordion.Content>
|
|
21
|
+
* </Accordion.Item>
|
|
22
|
+
* </Accordion>
|
|
23
|
+
*/
|
|
24
|
+
declare const AccordionRoot: import("react").ForwardRefExoticComponent<AccordionProps & import("react").RefAttributes<import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default>>;
|
|
25
|
+
type AccordionComponent = typeof AccordionRoot & {
|
|
26
|
+
Item: typeof AccordionItem;
|
|
27
|
+
Trigger: typeof AccordionTrigger;
|
|
28
|
+
Indicator: typeof AccordionIndicator;
|
|
29
|
+
Content: typeof AccordionContent;
|
|
30
|
+
};
|
|
31
|
+
export declare const Accordion: AccordionComponent;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=Accordion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Accordion.d.ts","sourceRoot":"","sources":["../../../../../src/components/accordion/Accordion.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA0B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA4B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAAuB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAS,CAAC;AAiB9C;;;;;;;;;;;;;;;;;GAiBG;AACH,QAAA,MAAM,aAAa,4LA2BjB,CAAC;AAEH,KAAK,kBAAkB,GAAG,OAAO,aAAa,GAAG;IAC/C,IAAI,EAAE,OAAO,aAAa,CAAC;IAC3B,OAAO,EAAE,OAAO,gBAAgB,CAAC;IACjC,SAAS,EAAE,OAAO,kBAAkB,CAAC;IACrC,OAAO,EAAE,OAAO,gBAAgB,CAAC;CAClC,CAAC;AAEF,eAAO,MAAM,SAAS,EAAoB,kBAAkB,CAAC"}
|