@xaui/native 0.9.1-alpha.32 → 0.9.1-alpha.34
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/chunk-DUQUCOUY.cjs +198 -0
- package/dist/chunk-I66VMLHE.cjs +410 -0
- package/dist/chunk-LZK77LFX.js +198 -0
- package/dist/chunk-ZA6RT3XQ.js +381 -0
- package/dist/components/alert/index.cjs +1 -1
- package/dist/components/alert/index.js +1 -1
- package/dist/components/avatar/index.cjs +17 -0
- package/dist/components/avatar/index.d.cts +131 -0
- package/dist/components/avatar/index.d.ts +131 -0
- package/dist/components/avatar/index.js +17 -0
- package/dist/components/badge/index.cjs +16 -0
- package/dist/components/badge/index.d.cts +157 -0
- package/dist/components/badge/index.d.ts +157 -0
- package/dist/components/badge/index.js +16 -0
- package/dist/components/button/index.cjs +3 -3
- package/dist/components/button/index.js +2 -2
- package/dist/components/chip/index.cjs +3 -3
- package/dist/components/chip/index.js +2 -2
- package/dist/index.cjs +40 -24
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +56 -40
- package/dist/system/index.cjs +4 -4
- package/dist/system/index.js +5 -5
- package/package.json +21 -1
- package/dist/{chunk-Y2B4XM3Y.js → chunk-2IWL6R3D.js} +3 -3
- package/dist/{chunk-4MPSXDAB.cjs → chunk-DBXFFJTC.cjs} +3 -3
- package/dist/{chunk-4YJLNYUS.js → chunk-M2BGCN77.js} +3 -3
- package/dist/{chunk-ETSYP3NH.cjs → chunk-QY4MN7X3.cjs} +3 -3
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import * as react_native from 'react-native';
|
|
4
|
+
import { StyleProp, ViewStyle, TextStyle, ViewProps, ImageProps, ImageStyle, TextProps } from 'react-native';
|
|
5
|
+
import { V as ViewStyleProps, I as ImageStyleProps, T as TextStyleProps } from '../../style-props.type-CfnoGEP7.cjs';
|
|
6
|
+
import { S as Size, R as RadiusKey, X as XAUITheme } from '../../theme.type-C2gNHpEx.cjs';
|
|
7
|
+
import { I as IconContextValue } from '../../icon.type-d_i9ma-i.cjs';
|
|
8
|
+
import { R as Recipe, S as SlotStyles, a as StyleFn } from '../../create-recipe-dC7wMfnj.cjs';
|
|
9
|
+
|
|
10
|
+
type AvatarSlot = 'root' | 'fallback' | 'initials' | 'icon';
|
|
11
|
+
/**
|
|
12
|
+
* The full vocabulary (§1 bis), and the `Chip`'s eleven names exactly — an avatar is a
|
|
13
|
+
* token *about* a person or a thing, which is the category the `Chip` established, so a
|
|
14
|
+
* name means here what it means there.
|
|
15
|
+
*
|
|
16
|
+
* They colour the **frame**, which is all that shows when there is no image: `primary` is
|
|
17
|
+
* the accent fill with its contrasted initials, `secondary` the soft slice, `tertiary` a
|
|
18
|
+
* border and nothing else. The three status families are here because an avatar reports as
|
|
19
|
+
* often as it identifies — a red frame for the account that failed to sync, a green one for
|
|
20
|
+
* the person who is online.
|
|
21
|
+
*
|
|
22
|
+
* It is HeroUI's `variant × color` matrix said once: their `default` is this `default`, and
|
|
23
|
+
* their `soft` crossed with five colours is `secondary` plus the five `-soft` names.
|
|
24
|
+
*/
|
|
25
|
+
type AvatarVariant = 'primary' | 'secondary' | 'default' | 'tertiary' | 'ghost' | 'success' | 'success-soft' | 'warning' | 'warning-soft' | 'danger' | 'danger-soft';
|
|
26
|
+
type AvatarSize = Size;
|
|
27
|
+
/**
|
|
28
|
+
* What the `Avatar` itself understands. R14 — a name in here is the component's, so the
|
|
29
|
+
* style prop that shares it is not exposed: `size` is the avatar's diameter and never
|
|
30
|
+
* `ViewStyle`'s, and `color` is R7's tint.
|
|
31
|
+
*/
|
|
32
|
+
type AvatarOwnProps = {
|
|
33
|
+
variant?: AvatarVariant;
|
|
34
|
+
/** The diameter, and the type inside it. It sets both sides, never a width alone. */
|
|
35
|
+
size?: AvatarSize;
|
|
36
|
+
/**
|
|
37
|
+
* Overrides the circle. An avatar is round at every size — that is the shape the name
|
|
38
|
+
* means — so this is the prop for the logo or the cover that wants a square.
|
|
39
|
+
*/
|
|
40
|
+
radius?: RadiusKey;
|
|
41
|
+
/**
|
|
42
|
+
* A raw tint (`'#7c3aed'`), never a token (R7). Where it lands follows the variant: the
|
|
43
|
+
* fill of a `primary`, the border of a `tertiary`, the initials of a `ghost`. Its
|
|
44
|
+
* contrasted and soft slices are derived in OKLab, so it behaves exactly like `accent` —
|
|
45
|
+
* which is also why it must be a hex value.
|
|
46
|
+
*/
|
|
47
|
+
color?: string;
|
|
48
|
+
/** R12 — the child element becomes the frame and keeps this variant's style. */
|
|
49
|
+
asChild?: boolean;
|
|
50
|
+
style?: StyleProp<ViewStyle>;
|
|
51
|
+
children?: ReactNode;
|
|
52
|
+
};
|
|
53
|
+
type AvatarProps = Omit<ViewProps, 'style'> & AvatarOwnProps & Omit<ViewStyleProps, keyof AvatarOwnProps | keyof ViewProps>;
|
|
54
|
+
type AvatarImageOwnProps = {
|
|
55
|
+
/**
|
|
56
|
+
* `false` shows the image the moment it decodes, with no fade. The frame does not change
|
|
57
|
+
* either way, so a list switched off with this does not reflow.
|
|
58
|
+
*/
|
|
59
|
+
animation?: boolean;
|
|
60
|
+
style?: StyleProp<ImageStyle>;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* `Image`'s own props win over the `ImageStyle` keys of the same name (R14). `source`
|
|
64
|
+
* stays required, as `Image` declares it: an `Avatar.Image` with nothing to show is an
|
|
65
|
+
* `Avatar.Fallback`.
|
|
66
|
+
*/
|
|
67
|
+
type AvatarImageProps = Omit<ImageProps, 'style'> & AvatarImageOwnProps & Omit<ImageStyleProps, keyof AvatarImageOwnProps | keyof ImageProps>;
|
|
68
|
+
type AvatarFallbackOwnProps = {
|
|
69
|
+
/**
|
|
70
|
+
* Initials, an `Icon`, anything. A stringifiable tree becomes `Avatar.Initials` (R3); an
|
|
71
|
+
* element is centred and left alone — and an `Icon` among them needs no props, because
|
|
72
|
+
* the fallback publishes the frame's size and colour to it.
|
|
73
|
+
*/
|
|
74
|
+
children?: ReactNode;
|
|
75
|
+
style?: StyleProp<ViewStyle>;
|
|
76
|
+
};
|
|
77
|
+
type AvatarFallbackProps = Omit<ViewProps, 'style'> & AvatarFallbackOwnProps & Omit<ViewStyleProps, keyof AvatarFallbackOwnProps | keyof ViewProps>;
|
|
78
|
+
/** `Text`'s own props win over the `TextStyle` keys of the same name (R14). */
|
|
79
|
+
type AvatarInitialsProps = TextProps & Omit<TextStyleProps, keyof TextProps> & {
|
|
80
|
+
children?: ReactNode;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* R5 — resolved styles, not props for a slot to resolve a second time. Each entry is the
|
|
84
|
+
* cached `StyleSheet` reference with the uncached tint pass layered over it, so a slot
|
|
85
|
+
* merges its own `style` on top and does no work of its own.
|
|
86
|
+
*/
|
|
87
|
+
type AvatarContextValue = {
|
|
88
|
+
fallbackStyle: StyleProp<ViewStyle>;
|
|
89
|
+
initialsStyle: StyleProp<TextStyle>;
|
|
90
|
+
/**
|
|
91
|
+
* Values, not a style: `Icon` hands `size` and `color` to a third-party component, so
|
|
92
|
+
* the root flattens its icon slot once here rather than in every icon it contains.
|
|
93
|
+
*/
|
|
94
|
+
icon: IconContextValue;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
declare const useAvatar: () => AvatarContextValue;
|
|
98
|
+
|
|
99
|
+
declare const avatarRecipe: Recipe<"root" | "icon" | "fallback" | "initials", AvatarVariant, {
|
|
100
|
+
readonly size: {
|
|
101
|
+
readonly xs: (theme: XAUITheme) => SlotStyles<AvatarSlot>;
|
|
102
|
+
readonly sm: (theme: XAUITheme) => SlotStyles<AvatarSlot>;
|
|
103
|
+
readonly md: (theme: XAUITheme) => SlotStyles<AvatarSlot>;
|
|
104
|
+
readonly lg: (theme: XAUITheme) => SlotStyles<AvatarSlot>;
|
|
105
|
+
};
|
|
106
|
+
readonly radius: Record<RadiusKey, StyleFn<AvatarSlot>>;
|
|
107
|
+
}>;
|
|
108
|
+
|
|
109
|
+
declare const Avatar: react.ForwardRefExoticComponent<Omit<react_native.ViewProps, "style"> & {
|
|
110
|
+
variant?: AvatarVariant;
|
|
111
|
+
size?: AvatarSize;
|
|
112
|
+
radius?: RadiusKey;
|
|
113
|
+
color?: string;
|
|
114
|
+
asChild?: boolean;
|
|
115
|
+
style?: react_native.StyleProp<react_native.ViewStyle>;
|
|
116
|
+
children?: react.ReactNode;
|
|
117
|
+
} & Omit<ViewStyleProps, "color" | "pointerEvents" | "style" | "children" | "hitSlop" | "id" | "needsOffscreenAlphaCompositing" | "onLayout" | "removeClippedSubviews" | "testID" | "nativeID" | "collapsable" | "collapsableChildren" | "onBlur" | "onFocus" | "renderToHardwareTextureAndroid" | "focusable" | "tabIndex" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerUp" | "onPointerUpCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "aria-label" | "accessibilityRole" | "accessibilityState" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-selected" | "accessibilityHint" | "accessibilityValue" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "onAccessibilityAction" | "importantForAccessibility" | "aria-hidden" | "aria-modal" | "role" | "accessibilityLabelledBy" | "aria-labelledby" | "accessibilityLiveRegion" | "aria-live" | "screenReaderFocusable" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "accessibilityLanguage" | "accessibilityShowsLargeContentViewer" | "accessibilityLargeContentTitle" | "accessibilityRespondsToUserInteraction" | "asChild" | "radius" | "size" | "variant"> & react.RefAttributes<react_native.View>> & {
|
|
118
|
+
Image: react.ForwardRefExoticComponent<Omit<react_native.ImageProps, "style"> & {
|
|
119
|
+
animation?: boolean;
|
|
120
|
+
style?: react_native.StyleProp<react_native.ImageStyle>;
|
|
121
|
+
} & Omit<ImageStyleProps, "height" | "width" | "borderRadius" | "resizeMode" | "tintColor" | "borderTopLeftRadius" | "borderTopRightRadius" | "borderBottomLeftRadius" | "borderBottomRightRadius" | "style" | "id" | "onLayout" | "testID" | "nativeID" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "aria-label" | "accessibilityRole" | "accessibilityState" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-selected" | "accessibilityHint" | "accessibilityValue" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "onAccessibilityAction" | "importantForAccessibility" | "aria-hidden" | "aria-modal" | "role" | "accessibilityLabelledBy" | "aria-labelledby" | "accessibilityLiveRegion" | "aria-live" | "screenReaderFocusable" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "accessibilityLanguage" | "accessibilityShowsLargeContentViewer" | "accessibilityLargeContentTitle" | "accessibilityRespondsToUserInteraction" | "source" | "animation" | "onError" | "onLoad" | "onLoadEnd" | "onLoadStart" | "progressiveRenderingEnabled" | "src" | "srcSet" | "loadingIndicatorSource" | "defaultSource" | "alt" | "crossOrigin" | "referrerPolicy" | "blurRadius" | "capInsets" | "onProgress" | "onPartialLoad" | "resizeMethod" | "fadeDuration"> & react.RefAttributes<react_native.Image>>;
|
|
122
|
+
Fallback: react.ForwardRefExoticComponent<Omit<react_native.ViewProps, "style"> & {
|
|
123
|
+
children?: react.ReactNode;
|
|
124
|
+
style?: react_native.StyleProp<react_native.ViewStyle>;
|
|
125
|
+
} & Omit<ViewStyleProps, "pointerEvents" | "style" | "children" | "hitSlop" | "id" | "needsOffscreenAlphaCompositing" | "onLayout" | "removeClippedSubviews" | "testID" | "nativeID" | "collapsable" | "collapsableChildren" | "onBlur" | "onFocus" | "renderToHardwareTextureAndroid" | "focusable" | "tabIndex" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerUp" | "onPointerUpCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "aria-label" | "accessibilityRole" | "accessibilityState" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-selected" | "accessibilityHint" | "accessibilityValue" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "onAccessibilityAction" | "importantForAccessibility" | "aria-hidden" | "aria-modal" | "role" | "accessibilityLabelledBy" | "aria-labelledby" | "accessibilityLiveRegion" | "aria-live" | "screenReaderFocusable" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "accessibilityLanguage" | "accessibilityShowsLargeContentViewer" | "accessibilityLargeContentTitle" | "accessibilityRespondsToUserInteraction"> & react.RefAttributes<react_native.View>>;
|
|
126
|
+
Initials: react.ForwardRefExoticComponent<react_native.TextProps & Omit<TextStyleProps, keyof react_native.TextProps> & {
|
|
127
|
+
children?: react.ReactNode;
|
|
128
|
+
} & react.RefAttributes<react_native.Text>>;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export { Avatar, type AvatarContextValue, type AvatarFallbackProps, type AvatarImageProps, type AvatarInitialsProps, type AvatarProps, type AvatarSize, type AvatarSlot, type AvatarVariant, avatarRecipe, useAvatar };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import * as react_native from 'react-native';
|
|
4
|
+
import { StyleProp, ViewStyle, TextStyle, ViewProps, ImageProps, ImageStyle, TextProps } from 'react-native';
|
|
5
|
+
import { V as ViewStyleProps, I as ImageStyleProps, T as TextStyleProps } from '../../style-props.type-CfnoGEP7.js';
|
|
6
|
+
import { S as Size, R as RadiusKey, X as XAUITheme } from '../../theme.type-C2gNHpEx.js';
|
|
7
|
+
import { I as IconContextValue } from '../../icon.type-Kml72iSz.js';
|
|
8
|
+
import { R as Recipe, S as SlotStyles, a as StyleFn } from '../../create-recipe-BdVd2ffi.js';
|
|
9
|
+
|
|
10
|
+
type AvatarSlot = 'root' | 'fallback' | 'initials' | 'icon';
|
|
11
|
+
/**
|
|
12
|
+
* The full vocabulary (§1 bis), and the `Chip`'s eleven names exactly — an avatar is a
|
|
13
|
+
* token *about* a person or a thing, which is the category the `Chip` established, so a
|
|
14
|
+
* name means here what it means there.
|
|
15
|
+
*
|
|
16
|
+
* They colour the **frame**, which is all that shows when there is no image: `primary` is
|
|
17
|
+
* the accent fill with its contrasted initials, `secondary` the soft slice, `tertiary` a
|
|
18
|
+
* border and nothing else. The three status families are here because an avatar reports as
|
|
19
|
+
* often as it identifies — a red frame for the account that failed to sync, a green one for
|
|
20
|
+
* the person who is online.
|
|
21
|
+
*
|
|
22
|
+
* It is HeroUI's `variant × color` matrix said once: their `default` is this `default`, and
|
|
23
|
+
* their `soft` crossed with five colours is `secondary` plus the five `-soft` names.
|
|
24
|
+
*/
|
|
25
|
+
type AvatarVariant = 'primary' | 'secondary' | 'default' | 'tertiary' | 'ghost' | 'success' | 'success-soft' | 'warning' | 'warning-soft' | 'danger' | 'danger-soft';
|
|
26
|
+
type AvatarSize = Size;
|
|
27
|
+
/**
|
|
28
|
+
* What the `Avatar` itself understands. R14 — a name in here is the component's, so the
|
|
29
|
+
* style prop that shares it is not exposed: `size` is the avatar's diameter and never
|
|
30
|
+
* `ViewStyle`'s, and `color` is R7's tint.
|
|
31
|
+
*/
|
|
32
|
+
type AvatarOwnProps = {
|
|
33
|
+
variant?: AvatarVariant;
|
|
34
|
+
/** The diameter, and the type inside it. It sets both sides, never a width alone. */
|
|
35
|
+
size?: AvatarSize;
|
|
36
|
+
/**
|
|
37
|
+
* Overrides the circle. An avatar is round at every size — that is the shape the name
|
|
38
|
+
* means — so this is the prop for the logo or the cover that wants a square.
|
|
39
|
+
*/
|
|
40
|
+
radius?: RadiusKey;
|
|
41
|
+
/**
|
|
42
|
+
* A raw tint (`'#7c3aed'`), never a token (R7). Where it lands follows the variant: the
|
|
43
|
+
* fill of a `primary`, the border of a `tertiary`, the initials of a `ghost`. Its
|
|
44
|
+
* contrasted and soft slices are derived in OKLab, so it behaves exactly like `accent` —
|
|
45
|
+
* which is also why it must be a hex value.
|
|
46
|
+
*/
|
|
47
|
+
color?: string;
|
|
48
|
+
/** R12 — the child element becomes the frame and keeps this variant's style. */
|
|
49
|
+
asChild?: boolean;
|
|
50
|
+
style?: StyleProp<ViewStyle>;
|
|
51
|
+
children?: ReactNode;
|
|
52
|
+
};
|
|
53
|
+
type AvatarProps = Omit<ViewProps, 'style'> & AvatarOwnProps & Omit<ViewStyleProps, keyof AvatarOwnProps | keyof ViewProps>;
|
|
54
|
+
type AvatarImageOwnProps = {
|
|
55
|
+
/**
|
|
56
|
+
* `false` shows the image the moment it decodes, with no fade. The frame does not change
|
|
57
|
+
* either way, so a list switched off with this does not reflow.
|
|
58
|
+
*/
|
|
59
|
+
animation?: boolean;
|
|
60
|
+
style?: StyleProp<ImageStyle>;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* `Image`'s own props win over the `ImageStyle` keys of the same name (R14). `source`
|
|
64
|
+
* stays required, as `Image` declares it: an `Avatar.Image` with nothing to show is an
|
|
65
|
+
* `Avatar.Fallback`.
|
|
66
|
+
*/
|
|
67
|
+
type AvatarImageProps = Omit<ImageProps, 'style'> & AvatarImageOwnProps & Omit<ImageStyleProps, keyof AvatarImageOwnProps | keyof ImageProps>;
|
|
68
|
+
type AvatarFallbackOwnProps = {
|
|
69
|
+
/**
|
|
70
|
+
* Initials, an `Icon`, anything. A stringifiable tree becomes `Avatar.Initials` (R3); an
|
|
71
|
+
* element is centred and left alone — and an `Icon` among them needs no props, because
|
|
72
|
+
* the fallback publishes the frame's size and colour to it.
|
|
73
|
+
*/
|
|
74
|
+
children?: ReactNode;
|
|
75
|
+
style?: StyleProp<ViewStyle>;
|
|
76
|
+
};
|
|
77
|
+
type AvatarFallbackProps = Omit<ViewProps, 'style'> & AvatarFallbackOwnProps & Omit<ViewStyleProps, keyof AvatarFallbackOwnProps | keyof ViewProps>;
|
|
78
|
+
/** `Text`'s own props win over the `TextStyle` keys of the same name (R14). */
|
|
79
|
+
type AvatarInitialsProps = TextProps & Omit<TextStyleProps, keyof TextProps> & {
|
|
80
|
+
children?: ReactNode;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* R5 — resolved styles, not props for a slot to resolve a second time. Each entry is the
|
|
84
|
+
* cached `StyleSheet` reference with the uncached tint pass layered over it, so a slot
|
|
85
|
+
* merges its own `style` on top and does no work of its own.
|
|
86
|
+
*/
|
|
87
|
+
type AvatarContextValue = {
|
|
88
|
+
fallbackStyle: StyleProp<ViewStyle>;
|
|
89
|
+
initialsStyle: StyleProp<TextStyle>;
|
|
90
|
+
/**
|
|
91
|
+
* Values, not a style: `Icon` hands `size` and `color` to a third-party component, so
|
|
92
|
+
* the root flattens its icon slot once here rather than in every icon it contains.
|
|
93
|
+
*/
|
|
94
|
+
icon: IconContextValue;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
declare const useAvatar: () => AvatarContextValue;
|
|
98
|
+
|
|
99
|
+
declare const avatarRecipe: Recipe<"root" | "icon" | "fallback" | "initials", AvatarVariant, {
|
|
100
|
+
readonly size: {
|
|
101
|
+
readonly xs: (theme: XAUITheme) => SlotStyles<AvatarSlot>;
|
|
102
|
+
readonly sm: (theme: XAUITheme) => SlotStyles<AvatarSlot>;
|
|
103
|
+
readonly md: (theme: XAUITheme) => SlotStyles<AvatarSlot>;
|
|
104
|
+
readonly lg: (theme: XAUITheme) => SlotStyles<AvatarSlot>;
|
|
105
|
+
};
|
|
106
|
+
readonly radius: Record<RadiusKey, StyleFn<AvatarSlot>>;
|
|
107
|
+
}>;
|
|
108
|
+
|
|
109
|
+
declare const Avatar: react.ForwardRefExoticComponent<Omit<react_native.ViewProps, "style"> & {
|
|
110
|
+
variant?: AvatarVariant;
|
|
111
|
+
size?: AvatarSize;
|
|
112
|
+
radius?: RadiusKey;
|
|
113
|
+
color?: string;
|
|
114
|
+
asChild?: boolean;
|
|
115
|
+
style?: react_native.StyleProp<react_native.ViewStyle>;
|
|
116
|
+
children?: react.ReactNode;
|
|
117
|
+
} & Omit<ViewStyleProps, "color" | "pointerEvents" | "style" | "children" | "hitSlop" | "id" | "needsOffscreenAlphaCompositing" | "onLayout" | "removeClippedSubviews" | "testID" | "nativeID" | "collapsable" | "collapsableChildren" | "onBlur" | "onFocus" | "renderToHardwareTextureAndroid" | "focusable" | "tabIndex" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerUp" | "onPointerUpCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "aria-label" | "accessibilityRole" | "accessibilityState" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-selected" | "accessibilityHint" | "accessibilityValue" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "onAccessibilityAction" | "importantForAccessibility" | "aria-hidden" | "aria-modal" | "role" | "accessibilityLabelledBy" | "aria-labelledby" | "accessibilityLiveRegion" | "aria-live" | "screenReaderFocusable" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "accessibilityLanguage" | "accessibilityShowsLargeContentViewer" | "accessibilityLargeContentTitle" | "accessibilityRespondsToUserInteraction" | "asChild" | "radius" | "size" | "variant"> & react.RefAttributes<react_native.View>> & {
|
|
118
|
+
Image: react.ForwardRefExoticComponent<Omit<react_native.ImageProps, "style"> & {
|
|
119
|
+
animation?: boolean;
|
|
120
|
+
style?: react_native.StyleProp<react_native.ImageStyle>;
|
|
121
|
+
} & Omit<ImageStyleProps, "height" | "width" | "borderRadius" | "resizeMode" | "tintColor" | "borderTopLeftRadius" | "borderTopRightRadius" | "borderBottomLeftRadius" | "borderBottomRightRadius" | "style" | "id" | "onLayout" | "testID" | "nativeID" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "aria-label" | "accessibilityRole" | "accessibilityState" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-selected" | "accessibilityHint" | "accessibilityValue" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "onAccessibilityAction" | "importantForAccessibility" | "aria-hidden" | "aria-modal" | "role" | "accessibilityLabelledBy" | "aria-labelledby" | "accessibilityLiveRegion" | "aria-live" | "screenReaderFocusable" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "accessibilityLanguage" | "accessibilityShowsLargeContentViewer" | "accessibilityLargeContentTitle" | "accessibilityRespondsToUserInteraction" | "source" | "animation" | "onError" | "onLoad" | "onLoadEnd" | "onLoadStart" | "progressiveRenderingEnabled" | "src" | "srcSet" | "loadingIndicatorSource" | "defaultSource" | "alt" | "crossOrigin" | "referrerPolicy" | "blurRadius" | "capInsets" | "onProgress" | "onPartialLoad" | "resizeMethod" | "fadeDuration"> & react.RefAttributes<react_native.Image>>;
|
|
122
|
+
Fallback: react.ForwardRefExoticComponent<Omit<react_native.ViewProps, "style"> & {
|
|
123
|
+
children?: react.ReactNode;
|
|
124
|
+
style?: react_native.StyleProp<react_native.ViewStyle>;
|
|
125
|
+
} & Omit<ViewStyleProps, "pointerEvents" | "style" | "children" | "hitSlop" | "id" | "needsOffscreenAlphaCompositing" | "onLayout" | "removeClippedSubviews" | "testID" | "nativeID" | "collapsable" | "collapsableChildren" | "onBlur" | "onFocus" | "renderToHardwareTextureAndroid" | "focusable" | "tabIndex" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerUp" | "onPointerUpCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "aria-label" | "accessibilityRole" | "accessibilityState" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-selected" | "accessibilityHint" | "accessibilityValue" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "onAccessibilityAction" | "importantForAccessibility" | "aria-hidden" | "aria-modal" | "role" | "accessibilityLabelledBy" | "aria-labelledby" | "accessibilityLiveRegion" | "aria-live" | "screenReaderFocusable" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "accessibilityLanguage" | "accessibilityShowsLargeContentViewer" | "accessibilityLargeContentTitle" | "accessibilityRespondsToUserInteraction"> & react.RefAttributes<react_native.View>>;
|
|
126
|
+
Initials: react.ForwardRefExoticComponent<react_native.TextProps & Omit<TextStyleProps, keyof react_native.TextProps> & {
|
|
127
|
+
children?: react.ReactNode;
|
|
128
|
+
} & react.RefAttributes<react_native.Text>>;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export { Avatar, type AvatarContextValue, type AvatarFallbackProps, type AvatarImageProps, type AvatarInitialsProps, type AvatarProps, type AvatarSize, type AvatarSlot, type AvatarVariant, avatarRecipe, useAvatar };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Avatar,
|
|
3
|
+
avatarRecipe,
|
|
4
|
+
useAvatar
|
|
5
|
+
} from "../../chunk-ZA6RT3XQ.js";
|
|
6
|
+
import "../../chunk-WJPQARJ5.js";
|
|
7
|
+
import "../../chunk-YXPYOOHU.js";
|
|
8
|
+
import "../../chunk-36PRYGAM.js";
|
|
9
|
+
import "../../chunk-4GTAZM2C.js";
|
|
10
|
+
import "../../chunk-MEYCZS32.js";
|
|
11
|
+
import "../../chunk-A3EGFI6T.js";
|
|
12
|
+
import "../../chunk-GGW42MY4.js";
|
|
13
|
+
export {
|
|
14
|
+
Avatar,
|
|
15
|
+
avatarRecipe,
|
|
16
|
+
useAvatar
|
|
17
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkDUQUCOUYcjs = require('../../chunk-DUQUCOUY.cjs');
|
|
6
|
+
require('../../chunk-54FJOKAN.cjs');
|
|
7
|
+
require('../../chunk-H4E4HDEP.cjs');
|
|
8
|
+
require('../../chunk-FNEUOBCV.cjs');
|
|
9
|
+
require('../../chunk-I6ZB3FZI.cjs');
|
|
10
|
+
require('../../chunk-57SJ4LJF.cjs');
|
|
11
|
+
require('../../chunk-MC7SY2QH.cjs');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
exports.Badge = _chunkDUQUCOUYcjs.Badge; exports.badgeRecipe = _chunkDUQUCOUYcjs.badgeRecipe; exports.placementInsets = _chunkDUQUCOUYcjs.placementInsets;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import * as react_native from 'react-native';
|
|
4
|
+
import { ViewProps, StyleProp, ViewStyle, View } from 'react-native';
|
|
5
|
+
import { V as ViewStyleProps } from '../../style-props.type-CfnoGEP7.cjs';
|
|
6
|
+
import { S as Size, R as RadiusKey, X as XAUITheme } from '../../theme.type-C2gNHpEx.cjs';
|
|
7
|
+
import { R as Recipe, S as SlotStyles, a as StyleFn } from '../../create-recipe-dC7wMfnj.cjs';
|
|
8
|
+
|
|
9
|
+
type BadgeSlot = 'root' | 'label';
|
|
10
|
+
/**
|
|
11
|
+
* The full vocabulary (§1 bis), and the `Chip`'s eleven — a badge is what a chip is when
|
|
12
|
+
* it is too small to hold a word: something a component **reports** about itself. So the
|
|
13
|
+
* three status families are here for the same reason they are there, and a name means the
|
|
14
|
+
* same thing in both.
|
|
15
|
+
*
|
|
16
|
+
* `danger` is the default rather than `primary`, and it is the only component in the
|
|
17
|
+
* library whose default is not the first name in the ladder. A badge is overwhelmingly the
|
|
18
|
+
* count of something that wants attention — unread, failed, overdue — and a red one is what
|
|
19
|
+
* a caller writing `<Badge>3</Badge>` means. The accent count is a `variant` away.
|
|
20
|
+
*/
|
|
21
|
+
type BadgeVariant = 'primary' | 'secondary' | 'default' | 'tertiary' | 'ghost' | 'success' | 'success-soft' | 'warning' | 'warning-soft' | 'danger' | 'danger-soft';
|
|
22
|
+
type BadgeSize = Size;
|
|
23
|
+
/**
|
|
24
|
+
* Which corner it hangs off, when it hangs off something.
|
|
25
|
+
*
|
|
26
|
+
* Unset, the badge is in flow and the parent lays it out like any other node — which is the
|
|
27
|
+
* right thing for a badge at the end of a list row. Set, it is absolutely positioned in
|
|
28
|
+
* that corner of the **parent**, so the parent is whatever the badge decorates:
|
|
29
|
+
*
|
|
30
|
+
* ```tsx
|
|
31
|
+
* <View>
|
|
32
|
+
* <Icon as={BellIcon} size={24} />
|
|
33
|
+
* <Badge placement="top-end">3</Badge>
|
|
34
|
+
* </View>
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* It is a prop rather than four style keys the caller writes because the offset is derived
|
|
38
|
+
* from the badge's own `size` — it is pulled out by half its height on each axis, so its
|
|
39
|
+
* centre sits on the corner it marks, and that arithmetic belongs with the measurements
|
|
40
|
+
* rather than at every call site. R13 is the other half: the keys are `start` and `end`, so
|
|
41
|
+
* a badge on the trailing corner mirrors in RTL instead of staying put.
|
|
42
|
+
*/
|
|
43
|
+
type BadgePlacement = 'top-end' | 'top-start' | 'bottom-end' | 'bottom-start';
|
|
44
|
+
/**
|
|
45
|
+
* What the `Badge` itself understands. R14 — a name in here is the component's, so the
|
|
46
|
+
* style prop that shares it is not exposed: `size` is the badge's scale and never
|
|
47
|
+
* `ViewStyle`'s, and `color` is R7's tint.
|
|
48
|
+
*/
|
|
49
|
+
type BadgeOwnProps = {
|
|
50
|
+
variant?: BadgeVariant;
|
|
51
|
+
/** Height, horizontal padding and type. The width follows the count inside it. */
|
|
52
|
+
size?: BadgeSize;
|
|
53
|
+
/**
|
|
54
|
+
* Overrides the capsule. A badge is a pill at every size — that is what makes a
|
|
55
|
+
* two-digit count read as one object — so this is the prop for the square marker.
|
|
56
|
+
*/
|
|
57
|
+
radius?: RadiusKey;
|
|
58
|
+
/**
|
|
59
|
+
* A raw tint (`'#7c3aed'`), never a token (R7). Where it lands follows the variant: the
|
|
60
|
+
* fill of a `primary`, the border and label of a `tertiary`, the label of a `ghost`.
|
|
61
|
+
*/
|
|
62
|
+
color?: string;
|
|
63
|
+
/**
|
|
64
|
+
* The bare circle — no label, no padding, a fixed diameter. It is what a badge is when
|
|
65
|
+
* the fact that there is *something* is the whole message: a dot on a tab, an unsaved
|
|
66
|
+
* marker on a row.
|
|
67
|
+
*
|
|
68
|
+
* Children are not rendered while it is set: a dot is the absence of a label, so there
|
|
69
|
+
* is nothing for one to sit in.
|
|
70
|
+
*/
|
|
71
|
+
isDot?: boolean;
|
|
72
|
+
placement?: BadgePlacement;
|
|
73
|
+
/** R12 — the child element becomes the badge and keeps this variant's style. */
|
|
74
|
+
asChild?: boolean;
|
|
75
|
+
style?: StyleProp<ViewStyle>;
|
|
76
|
+
children?: ReactNode;
|
|
77
|
+
};
|
|
78
|
+
type BadgeProps = Omit<ViewProps, 'style'> & BadgeOwnProps & Omit<ViewStyleProps, keyof BadgeOwnProps | keyof ViewProps>;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* A count, or the fact that there is one.
|
|
82
|
+
*
|
|
83
|
+
* ```tsx
|
|
84
|
+
* <Badge>3</Badge>
|
|
85
|
+
* <Badge variant="success-soft" size="sm">Payé</Badge>
|
|
86
|
+
* <Badge isDot variant="warning" />
|
|
87
|
+
*
|
|
88
|
+
* <View>
|
|
89
|
+
* <Icon as={BellIcon} size={24} />
|
|
90
|
+
* <Badge placement="top-end">12</Badge>
|
|
91
|
+
* </View>
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* **One node and no slots**, per the plan. A badge is a mark: whatever is inside it is one
|
|
95
|
+
* line of two or three characters, and a slot would be a name for a `Text` this component
|
|
96
|
+
* can just as well insert itself (R3).
|
|
97
|
+
*
|
|
98
|
+
* **It is not a small `Chip`.** A chip holds a word and hugs it; a badge holds a count and
|
|
99
|
+
* is round unless the count is too wide to be. That is the `minWidth` equal to the height —
|
|
100
|
+
* one digit is a circle, two are a capsule — and it is why the label stays at 12pt through
|
|
101
|
+
* three of the four sizes, because a count that grows with its badge stops being a count.
|
|
102
|
+
*
|
|
103
|
+
* **`placement` makes the parent whatever the badge decorates.** Unset, the badge is in
|
|
104
|
+
* flow and laid out like any other node, which is what a badge at the end of a list row
|
|
105
|
+
* wants. Set, it is pulled half its own height out of that corner of the parent, so its
|
|
106
|
+
* centre lands on the corner it marks.
|
|
107
|
+
*/
|
|
108
|
+
declare const Badge: react.ForwardRefExoticComponent<Omit<react_native.ViewProps, "style"> & {
|
|
109
|
+
variant?: BadgeVariant;
|
|
110
|
+
size?: BadgeSize;
|
|
111
|
+
radius?: RadiusKey;
|
|
112
|
+
color?: string;
|
|
113
|
+
isDot?: boolean;
|
|
114
|
+
placement?: BadgePlacement;
|
|
115
|
+
asChild?: boolean;
|
|
116
|
+
style?: react_native.StyleProp<react_native.ViewStyle>;
|
|
117
|
+
children?: react.ReactNode;
|
|
118
|
+
} & Omit<ViewStyleProps, "color" | "pointerEvents" | "style" | "children" | "hitSlop" | "id" | "needsOffscreenAlphaCompositing" | "onLayout" | "removeClippedSubviews" | "testID" | "nativeID" | "collapsable" | "collapsableChildren" | "onBlur" | "onFocus" | "renderToHardwareTextureAndroid" | "focusable" | "tabIndex" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerUp" | "onPointerUpCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "aria-label" | "accessibilityRole" | "accessibilityState" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-selected" | "accessibilityHint" | "accessibilityValue" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "onAccessibilityAction" | "importantForAccessibility" | "aria-hidden" | "aria-modal" | "role" | "accessibilityLabelledBy" | "aria-labelledby" | "accessibilityLiveRegion" | "aria-live" | "screenReaderFocusable" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "accessibilityLanguage" | "accessibilityShowsLargeContentViewer" | "accessibilityLargeContentTitle" | "accessibilityRespondsToUserInteraction" | "asChild" | "radius" | "size" | "variant" | "isDot" | "placement"> & react.RefAttributes<View>>;
|
|
119
|
+
|
|
120
|
+
declare const badgeRecipe: Recipe<"label" | "root", BadgeVariant, {
|
|
121
|
+
readonly size: {
|
|
122
|
+
readonly xs: (theme: XAUITheme) => SlotStyles<BadgeSlot>;
|
|
123
|
+
readonly sm: (theme: XAUITheme) => SlotStyles<BadgeSlot>;
|
|
124
|
+
readonly md: (theme: XAUITheme) => SlotStyles<BadgeSlot>;
|
|
125
|
+
readonly lg: (theme: XAUITheme) => SlotStyles<BadgeSlot>;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* The same four keys as `size`, and the root selects it with the resolved size when
|
|
129
|
+
* `isDot` is set and with nothing when it is not — an axis left unselected contributes
|
|
130
|
+
* nothing, which is exactly "this badge has a label". A `{ true, false }` axis would
|
|
131
|
+
* have needed a `false` branch with nothing to say, and a `size × isDot` compound
|
|
132
|
+
* would have been sixteen entries for four measurements.
|
|
133
|
+
*/
|
|
134
|
+
readonly dot: {
|
|
135
|
+
readonly xs: (theme: XAUITheme) => SlotStyles<BadgeSlot>;
|
|
136
|
+
readonly sm: (theme: XAUITheme) => SlotStyles<BadgeSlot>;
|
|
137
|
+
readonly md: (theme: XAUITheme) => SlotStyles<BadgeSlot>;
|
|
138
|
+
readonly lg: (theme: XAUITheme) => SlotStyles<BadgeSlot>;
|
|
139
|
+
};
|
|
140
|
+
readonly radius: Record<RadiusKey, StyleFn<BadgeSlot>>;
|
|
141
|
+
}>;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* `placement` turned into the four keys React Native understands, given how far the badge
|
|
145
|
+
* has to be pulled out of the corner it marks.
|
|
146
|
+
*
|
|
147
|
+
* A pure function rather than a lookup in the recipe, because the insets must **not** exist
|
|
148
|
+
* when there is no placement: in flow the node is `position: 'relative'`, where an inset is
|
|
149
|
+
* a nudge rather than a placement, and a cached style carrying `top: -10` would shift every
|
|
150
|
+
* badge that is simply sitting at the end of a row.
|
|
151
|
+
*
|
|
152
|
+
* R13 — `start` and `end`, never `left` and `right`, so a badge on the trailing corner
|
|
153
|
+
* mirrors with the layout instead of staying put.
|
|
154
|
+
*/
|
|
155
|
+
declare function placementInsets(placement: BadgePlacement | undefined, offset: number): ViewStyle | undefined;
|
|
156
|
+
|
|
157
|
+
export { Badge, type BadgePlacement, type BadgeProps, type BadgeSize, type BadgeSlot, type BadgeVariant, badgeRecipe, placementInsets };
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import * as react_native from 'react-native';
|
|
4
|
+
import { ViewProps, StyleProp, ViewStyle, View } from 'react-native';
|
|
5
|
+
import { V as ViewStyleProps } from '../../style-props.type-CfnoGEP7.js';
|
|
6
|
+
import { S as Size, R as RadiusKey, X as XAUITheme } from '../../theme.type-C2gNHpEx.js';
|
|
7
|
+
import { R as Recipe, S as SlotStyles, a as StyleFn } from '../../create-recipe-BdVd2ffi.js';
|
|
8
|
+
|
|
9
|
+
type BadgeSlot = 'root' | 'label';
|
|
10
|
+
/**
|
|
11
|
+
* The full vocabulary (§1 bis), and the `Chip`'s eleven — a badge is what a chip is when
|
|
12
|
+
* it is too small to hold a word: something a component **reports** about itself. So the
|
|
13
|
+
* three status families are here for the same reason they are there, and a name means the
|
|
14
|
+
* same thing in both.
|
|
15
|
+
*
|
|
16
|
+
* `danger` is the default rather than `primary`, and it is the only component in the
|
|
17
|
+
* library whose default is not the first name in the ladder. A badge is overwhelmingly the
|
|
18
|
+
* count of something that wants attention — unread, failed, overdue — and a red one is what
|
|
19
|
+
* a caller writing `<Badge>3</Badge>` means. The accent count is a `variant` away.
|
|
20
|
+
*/
|
|
21
|
+
type BadgeVariant = 'primary' | 'secondary' | 'default' | 'tertiary' | 'ghost' | 'success' | 'success-soft' | 'warning' | 'warning-soft' | 'danger' | 'danger-soft';
|
|
22
|
+
type BadgeSize = Size;
|
|
23
|
+
/**
|
|
24
|
+
* Which corner it hangs off, when it hangs off something.
|
|
25
|
+
*
|
|
26
|
+
* Unset, the badge is in flow and the parent lays it out like any other node — which is the
|
|
27
|
+
* right thing for a badge at the end of a list row. Set, it is absolutely positioned in
|
|
28
|
+
* that corner of the **parent**, so the parent is whatever the badge decorates:
|
|
29
|
+
*
|
|
30
|
+
* ```tsx
|
|
31
|
+
* <View>
|
|
32
|
+
* <Icon as={BellIcon} size={24} />
|
|
33
|
+
* <Badge placement="top-end">3</Badge>
|
|
34
|
+
* </View>
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* It is a prop rather than four style keys the caller writes because the offset is derived
|
|
38
|
+
* from the badge's own `size` — it is pulled out by half its height on each axis, so its
|
|
39
|
+
* centre sits on the corner it marks, and that arithmetic belongs with the measurements
|
|
40
|
+
* rather than at every call site. R13 is the other half: the keys are `start` and `end`, so
|
|
41
|
+
* a badge on the trailing corner mirrors in RTL instead of staying put.
|
|
42
|
+
*/
|
|
43
|
+
type BadgePlacement = 'top-end' | 'top-start' | 'bottom-end' | 'bottom-start';
|
|
44
|
+
/**
|
|
45
|
+
* What the `Badge` itself understands. R14 — a name in here is the component's, so the
|
|
46
|
+
* style prop that shares it is not exposed: `size` is the badge's scale and never
|
|
47
|
+
* `ViewStyle`'s, and `color` is R7's tint.
|
|
48
|
+
*/
|
|
49
|
+
type BadgeOwnProps = {
|
|
50
|
+
variant?: BadgeVariant;
|
|
51
|
+
/** Height, horizontal padding and type. The width follows the count inside it. */
|
|
52
|
+
size?: BadgeSize;
|
|
53
|
+
/**
|
|
54
|
+
* Overrides the capsule. A badge is a pill at every size — that is what makes a
|
|
55
|
+
* two-digit count read as one object — so this is the prop for the square marker.
|
|
56
|
+
*/
|
|
57
|
+
radius?: RadiusKey;
|
|
58
|
+
/**
|
|
59
|
+
* A raw tint (`'#7c3aed'`), never a token (R7). Where it lands follows the variant: the
|
|
60
|
+
* fill of a `primary`, the border and label of a `tertiary`, the label of a `ghost`.
|
|
61
|
+
*/
|
|
62
|
+
color?: string;
|
|
63
|
+
/**
|
|
64
|
+
* The bare circle — no label, no padding, a fixed diameter. It is what a badge is when
|
|
65
|
+
* the fact that there is *something* is the whole message: a dot on a tab, an unsaved
|
|
66
|
+
* marker on a row.
|
|
67
|
+
*
|
|
68
|
+
* Children are not rendered while it is set: a dot is the absence of a label, so there
|
|
69
|
+
* is nothing for one to sit in.
|
|
70
|
+
*/
|
|
71
|
+
isDot?: boolean;
|
|
72
|
+
placement?: BadgePlacement;
|
|
73
|
+
/** R12 — the child element becomes the badge and keeps this variant's style. */
|
|
74
|
+
asChild?: boolean;
|
|
75
|
+
style?: StyleProp<ViewStyle>;
|
|
76
|
+
children?: ReactNode;
|
|
77
|
+
};
|
|
78
|
+
type BadgeProps = Omit<ViewProps, 'style'> & BadgeOwnProps & Omit<ViewStyleProps, keyof BadgeOwnProps | keyof ViewProps>;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* A count, or the fact that there is one.
|
|
82
|
+
*
|
|
83
|
+
* ```tsx
|
|
84
|
+
* <Badge>3</Badge>
|
|
85
|
+
* <Badge variant="success-soft" size="sm">Payé</Badge>
|
|
86
|
+
* <Badge isDot variant="warning" />
|
|
87
|
+
*
|
|
88
|
+
* <View>
|
|
89
|
+
* <Icon as={BellIcon} size={24} />
|
|
90
|
+
* <Badge placement="top-end">12</Badge>
|
|
91
|
+
* </View>
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* **One node and no slots**, per the plan. A badge is a mark: whatever is inside it is one
|
|
95
|
+
* line of two or three characters, and a slot would be a name for a `Text` this component
|
|
96
|
+
* can just as well insert itself (R3).
|
|
97
|
+
*
|
|
98
|
+
* **It is not a small `Chip`.** A chip holds a word and hugs it; a badge holds a count and
|
|
99
|
+
* is round unless the count is too wide to be. That is the `minWidth` equal to the height —
|
|
100
|
+
* one digit is a circle, two are a capsule — and it is why the label stays at 12pt through
|
|
101
|
+
* three of the four sizes, because a count that grows with its badge stops being a count.
|
|
102
|
+
*
|
|
103
|
+
* **`placement` makes the parent whatever the badge decorates.** Unset, the badge is in
|
|
104
|
+
* flow and laid out like any other node, which is what a badge at the end of a list row
|
|
105
|
+
* wants. Set, it is pulled half its own height out of that corner of the parent, so its
|
|
106
|
+
* centre lands on the corner it marks.
|
|
107
|
+
*/
|
|
108
|
+
declare const Badge: react.ForwardRefExoticComponent<Omit<react_native.ViewProps, "style"> & {
|
|
109
|
+
variant?: BadgeVariant;
|
|
110
|
+
size?: BadgeSize;
|
|
111
|
+
radius?: RadiusKey;
|
|
112
|
+
color?: string;
|
|
113
|
+
isDot?: boolean;
|
|
114
|
+
placement?: BadgePlacement;
|
|
115
|
+
asChild?: boolean;
|
|
116
|
+
style?: react_native.StyleProp<react_native.ViewStyle>;
|
|
117
|
+
children?: react.ReactNode;
|
|
118
|
+
} & Omit<ViewStyleProps, "color" | "pointerEvents" | "style" | "children" | "hitSlop" | "id" | "needsOffscreenAlphaCompositing" | "onLayout" | "removeClippedSubviews" | "testID" | "nativeID" | "collapsable" | "collapsableChildren" | "onBlur" | "onFocus" | "renderToHardwareTextureAndroid" | "focusable" | "tabIndex" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerUp" | "onPointerUpCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "aria-label" | "accessibilityRole" | "accessibilityState" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-selected" | "accessibilityHint" | "accessibilityValue" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "onAccessibilityAction" | "importantForAccessibility" | "aria-hidden" | "aria-modal" | "role" | "accessibilityLabelledBy" | "aria-labelledby" | "accessibilityLiveRegion" | "aria-live" | "screenReaderFocusable" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "accessibilityLanguage" | "accessibilityShowsLargeContentViewer" | "accessibilityLargeContentTitle" | "accessibilityRespondsToUserInteraction" | "asChild" | "radius" | "size" | "variant" | "isDot" | "placement"> & react.RefAttributes<View>>;
|
|
119
|
+
|
|
120
|
+
declare const badgeRecipe: Recipe<"label" | "root", BadgeVariant, {
|
|
121
|
+
readonly size: {
|
|
122
|
+
readonly xs: (theme: XAUITheme) => SlotStyles<BadgeSlot>;
|
|
123
|
+
readonly sm: (theme: XAUITheme) => SlotStyles<BadgeSlot>;
|
|
124
|
+
readonly md: (theme: XAUITheme) => SlotStyles<BadgeSlot>;
|
|
125
|
+
readonly lg: (theme: XAUITheme) => SlotStyles<BadgeSlot>;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* The same four keys as `size`, and the root selects it with the resolved size when
|
|
129
|
+
* `isDot` is set and with nothing when it is not — an axis left unselected contributes
|
|
130
|
+
* nothing, which is exactly "this badge has a label". A `{ true, false }` axis would
|
|
131
|
+
* have needed a `false` branch with nothing to say, and a `size × isDot` compound
|
|
132
|
+
* would have been sixteen entries for four measurements.
|
|
133
|
+
*/
|
|
134
|
+
readonly dot: {
|
|
135
|
+
readonly xs: (theme: XAUITheme) => SlotStyles<BadgeSlot>;
|
|
136
|
+
readonly sm: (theme: XAUITheme) => SlotStyles<BadgeSlot>;
|
|
137
|
+
readonly md: (theme: XAUITheme) => SlotStyles<BadgeSlot>;
|
|
138
|
+
readonly lg: (theme: XAUITheme) => SlotStyles<BadgeSlot>;
|
|
139
|
+
};
|
|
140
|
+
readonly radius: Record<RadiusKey, StyleFn<BadgeSlot>>;
|
|
141
|
+
}>;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* `placement` turned into the four keys React Native understands, given how far the badge
|
|
145
|
+
* has to be pulled out of the corner it marks.
|
|
146
|
+
*
|
|
147
|
+
* A pure function rather than a lookup in the recipe, because the insets must **not** exist
|
|
148
|
+
* when there is no placement: in flow the node is `position: 'relative'`, where an inset is
|
|
149
|
+
* a nudge rather than a placement, and a cached style carrying `top: -10` would shift every
|
|
150
|
+
* badge that is simply sitting at the end of a row.
|
|
151
|
+
*
|
|
152
|
+
* R13 — `start` and `end`, never `left` and `right`, so a badge on the trailing corner
|
|
153
|
+
* mirrors with the layout instead of staying put.
|
|
154
|
+
*/
|
|
155
|
+
declare function placementInsets(placement: BadgePlacement | undefined, offset: number): ViewStyle | undefined;
|
|
156
|
+
|
|
157
|
+
export { Badge, type BadgePlacement, type BadgeProps, type BadgeSize, type BadgeSlot, type BadgeVariant, badgeRecipe, placementInsets };
|