@xaui/native 0.9.1-alpha.4 → 0.9.1-alpha.40
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-2EGR4LWD.js +145 -0
- package/dist/chunk-2NRZKJG7.js +531 -0
- package/dist/chunk-2PMXMKS5.js +67 -0
- package/dist/chunk-2XPG2243.js +586 -0
- package/dist/chunk-36PRYGAM.js +13 -0
- package/dist/chunk-3E7CDKFO.cjs +696 -0
- package/dist/chunk-3GFRSZYR.js +54 -0
- package/dist/chunk-423RQBOX.js +21 -0
- package/dist/chunk-4CUZZWFW.js +92 -0
- package/dist/chunk-4GTAZM2C.js +174 -0
- package/dist/chunk-4KFKWBN5.cjs +89 -0
- package/dist/{chunk-3QBT3Q65.cjs → chunk-57SJ4LJF.cjs} +7 -2
- package/dist/chunk-5R26NM4M.cjs +402 -0
- package/dist/chunk-5VKYNBNA.js +607 -0
- package/dist/chunk-64MXEVT3.js +66 -0
- package/dist/chunk-6DOLGZVV.cjs +147 -0
- package/dist/chunk-6L2TS2R3.cjs +92 -0
- package/dist/chunk-6UEZJRVI.js +669 -0
- package/dist/chunk-734MFAX4.js +27 -0
- package/dist/chunk-73RKQC5X.js +104 -0
- package/dist/chunk-7DPL3ZDS.cjs +21 -0
- package/dist/chunk-7EIHHOHP.cjs +42 -0
- package/dist/chunk-7GHM4GKL.cjs +119 -0
- package/dist/chunk-7YF5NAHQ.cjs +74 -0
- package/dist/{chunk-X2K2FX3W.js → chunk-A3EGFI6T.js} +6 -1
- package/dist/chunk-ABAGZTXZ.cjs +736 -0
- package/dist/{chunk-AW63PTQ4.cjs → chunk-ACAPTWE3.cjs} +85 -81
- package/dist/chunk-AMCSSOJT.cjs +104 -0
- package/dist/chunk-BA2DBSAN.js +102 -0
- package/dist/chunk-BRRXFOBY.js +431 -0
- package/dist/chunk-C5YLPCFC.cjs +293 -0
- package/dist/chunk-DA3OKXHV.cjs +700 -0
- package/dist/chunk-DD4276RF.js +366 -0
- package/dist/chunk-DG2I4PJG.js +701 -0
- package/dist/chunk-DHGLGSH6.js +661 -0
- package/dist/chunk-DIBUQ46Y.js +346 -0
- package/dist/chunk-EGLLDKN6.js +9 -0
- package/dist/chunk-EJQCQPET.cjs +9 -0
- package/dist/chunk-EKS3W46M.cjs +66 -0
- package/dist/chunk-EZEYMLO3.js +402 -0
- package/dist/chunk-F6CQ6CBI.cjs +112 -0
- package/dist/chunk-F6W3JQ7K.js +42 -0
- package/dist/chunk-FHUYHV6J.js +89 -0
- package/dist/chunk-FNEUOBCV.cjs +174 -0
- package/dist/chunk-G7P3ERYF.cjs +478 -0
- package/dist/chunk-GA6PBWNT.js +147 -0
- package/dist/chunk-GFUZ3MUT.cjs +455 -0
- package/dist/chunk-GGW43Q37.cjs +1 -0
- package/dist/chunk-GTR5X65M.cjs +27 -0
- package/dist/chunk-H4E4HDEP.cjs +13 -0
- package/dist/chunk-H7DS4IO7.js +198 -0
- package/dist/chunk-HDVVZG4S.cjs +198 -0
- package/dist/chunk-IKJVLJKT.js +151 -0
- package/dist/chunk-J3MB4PI5.cjs +531 -0
- package/dist/chunk-K72UDPVN.js +119 -0
- package/dist/chunk-KCMYU7WF.js +86 -0
- package/dist/chunk-LRN3RNDO.js +940 -0
- package/dist/chunk-LTX6TB5I.js +124 -0
- package/dist/chunk-LUPCPLND.cjs +145 -0
- package/dist/chunk-M63GFNKV.js +194 -0
- package/dist/chunk-N3KTZMPG.js +293 -0
- package/dist/chunk-NCTOTTVW.js +13 -0
- package/dist/chunk-NWGLP6JX.cjs +410 -0
- package/dist/chunk-R73XQK7X.cjs +314 -0
- package/dist/chunk-RU7JCMWC.cjs +881 -0
- package/dist/chunk-SNIHUKDA.cjs +184 -0
- package/dist/chunk-T5FV5F7A.cjs +607 -0
- package/dist/chunk-TDTUAIFF.cjs +153 -0
- package/dist/chunk-TJ74XVZN.cjs +431 -0
- package/dist/chunk-TK44VBIE.cjs +194 -0
- package/dist/chunk-UAWBAD4E.cjs +346 -0
- package/dist/chunk-UFTCTTKK.js +381 -0
- package/dist/chunk-WDDXU3OH.cjs +67 -0
- package/dist/chunk-WFEMJCXO.cjs +13 -0
- package/dist/chunk-WHJTBTYM.js +0 -0
- package/dist/{chunk-2KXQATVL.js → chunk-WKCQ6VGW.js} +59 -55
- package/dist/chunk-XFPQFCEK.js +455 -0
- package/dist/chunk-XSQPVDFH.cjs +60 -0
- package/dist/chunk-XTC2SLFT.js +153 -0
- package/dist/chunk-XV735BSA.cjs +366 -0
- package/dist/chunk-XWNG2U4K.cjs +124 -0
- package/dist/chunk-YGYYJ3LQ.js +314 -0
- package/dist/chunk-YVHT2UVW.js +74 -0
- package/dist/chunk-ZFOOJK37.cjs +86 -0
- package/dist/close-button.type-BUYuoSt2.d.ts +36 -0
- package/dist/close-button.type-CHsgZ3wO.d.cts +36 -0
- package/dist/components/accordion/index.cjs +35 -0
- package/dist/components/accordion/index.d.cts +299 -0
- package/dist/components/accordion/index.d.ts +299 -0
- package/dist/components/accordion/index.js +35 -0
- package/dist/components/alert/index.cjs +20 -0
- package/dist/components/alert/index.d.cts +169 -0
- package/dist/components/alert/index.d.ts +169 -0
- package/dist/components/alert/index.js +20 -0
- package/dist/components/avatar/index.cjs +16 -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 +16 -0
- package/dist/components/badge/index.cjs +15 -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 +15 -0
- package/dist/components/button/index.cjs +22 -0
- package/dist/components/button/index.d.cts +613 -0
- package/dist/components/button/index.d.ts +613 -0
- package/dist/components/button/index.js +22 -0
- package/dist/components/card/index.cjs +22 -0
- package/dist/components/card/index.d.cts +620 -0
- package/dist/components/card/index.d.ts +620 -0
- package/dist/components/card/index.js +22 -0
- package/dist/components/checkbox/index.cjs +26 -0
- package/dist/components/checkbox/index.d.cts +1136 -0
- package/dist/components/checkbox/index.d.ts +1136 -0
- package/dist/components/checkbox/index.js +26 -0
- package/dist/components/chip/index.cjs +20 -0
- package/dist/components/chip/index.d.cts +608 -0
- package/dist/components/chip/index.d.ts +608 -0
- package/dist/components/chip/index.js +20 -0
- package/dist/components/divider/index.cjs +13 -0
- package/dist/components/divider/index.d.cts +117 -0
- package/dist/components/divider/index.d.ts +117 -0
- package/dist/components/divider/index.js +13 -0
- package/dist/components/field-group/index.cjs +27 -0
- package/dist/components/field-group/index.d.cts +270 -0
- package/dist/components/field-group/index.d.ts +270 -0
- package/dist/components/field-group/index.js +27 -0
- package/dist/components/input-otp/index.cjs +29 -0
- package/dist/components/input-otp/index.d.cts +325 -0
- package/dist/components/input-otp/index.d.ts +325 -0
- package/dist/components/input-otp/index.js +29 -0
- package/dist/components/menu/index.cjs +49 -0
- package/dist/components/menu/index.d.cts +351 -0
- package/dist/components/menu/index.d.ts +351 -0
- package/dist/components/menu/index.js +49 -0
- package/dist/components/popover/index.cjs +38 -0
- package/dist/components/popover/index.d.cts +254 -0
- package/dist/components/popover/index.d.ts +254 -0
- package/dist/components/popover/index.js +38 -0
- package/dist/components/radio/index.cjs +26 -0
- package/dist/components/radio/index.d.cts +1102 -0
- package/dist/components/radio/index.d.ts +1102 -0
- package/dist/components/radio/index.js +26 -0
- package/dist/components/select/index.cjs +50 -0
- package/dist/components/select/index.d.cts +498 -0
- package/dist/components/select/index.d.ts +498 -0
- package/dist/components/select/index.js +50 -0
- package/dist/components/skeleton/index.cjs +11 -0
- package/dist/components/skeleton/index.d.cts +111 -0
- package/dist/components/skeleton/index.d.ts +111 -0
- package/dist/components/skeleton/index.js +11 -0
- package/dist/components/spinner/index.cjs +17 -0
- package/dist/components/spinner/index.d.cts +104 -0
- package/dist/components/spinner/index.d.ts +104 -0
- package/dist/components/spinner/index.js +17 -0
- package/dist/components/switch/index.cjs +27 -0
- package/dist/components/switch/index.d.cts +1154 -0
- package/dist/components/switch/index.d.ts +1154 -0
- package/dist/components/switch/index.js +27 -0
- package/dist/components/text-area/index.cjs +14 -0
- package/dist/components/text-area/index.d.cts +73 -0
- package/dist/components/text-area/index.d.ts +73 -0
- package/dist/components/text-area/index.js +14 -0
- package/dist/components/text-field/index.cjs +25 -0
- package/dist/components/text-field/index.d.cts +205 -0
- package/dist/components/text-field/index.d.ts +205 -0
- package/dist/components/text-field/index.js +25 -0
- package/dist/components/typography/index.cjs +15 -0
- package/dist/components/typography/index.d.cts +116 -0
- package/dist/components/typography/index.d.ts +116 -0
- package/dist/components/typography/index.js +15 -0
- package/dist/components/view/index.cjs +17 -0
- package/dist/components/view/index.d.cts +152 -0
- package/dist/components/view/index.d.ts +152 -0
- package/dist/components/view/index.js +17 -0
- package/dist/create-recipe-BdVd2ffi.d.ts +114 -0
- package/dist/create-recipe-dC7wMfnj.d.cts +114 -0
- package/dist/icon.type-Kml72iSz.d.ts +73 -0
- package/dist/icon.type-d_i9ma-i.d.cts +73 -0
- package/dist/index.cjs +400 -4
- package/dist/index.d.cts +118 -4
- package/dist/index.d.ts +118 -4
- package/dist/index.js +423 -27
- package/dist/placement-DHa0Rrh1.d.cts +38 -0
- package/dist/placement-DHa0Rrh1.d.ts +38 -0
- package/dist/pressable-feedback.type-BA2C9sSz.d.cts +127 -0
- package/dist/pressable-feedback.type-Bs4dQlGj.d.ts +127 -0
- package/dist/style-props.type-CfnoGEP7.d.cts +31 -0
- package/dist/style-props.type-CfnoGEP7.d.ts +31 -0
- package/dist/system/index.cjs +73 -4
- package/dist/system/index.d.cts +379 -193
- package/dist/system/index.d.ts +379 -193
- package/dist/system/index.js +87 -18
- package/dist/text-field.type-0l73acce.d.ts +167 -0
- package/dist/text-field.type-DBh06DU5.d.cts +167 -0
- package/dist/theme/index.cjs +5 -3
- package/dist/theme/index.d.cts +55 -24
- package/dist/theme/index.d.ts +55 -24
- package/dist/theme/index.js +4 -2
- package/dist/{theme.type-C9bFJKFm.d.cts → theme.type-C2gNHpEx.d.cts} +1 -1
- package/dist/{theme.type-C9bFJKFm.d.ts → theme.type-C2gNHpEx.d.ts} +1 -1
- package/package.json +254 -18
- package/dist/chunk-ECDWSSHJ.js +0 -688
- package/dist/chunk-IYFGO523.cjs +0 -688
|
@@ -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" | "size" | "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" | "variant" | "radius" | "asChild" | "placement" | "isDot"> & 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" | "size" | "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" | "variant" | "radius" | "asChild" | "placement" | "isDot"> & 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,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Badge,
|
|
3
|
+
badgeRecipe,
|
|
4
|
+
placementInsets
|
|
5
|
+
} from "../../chunk-H7DS4IO7.js";
|
|
6
|
+
import "../../chunk-4GTAZM2C.js";
|
|
7
|
+
import "../../chunk-A3EGFI6T.js";
|
|
8
|
+
import "../../chunk-K72UDPVN.js";
|
|
9
|
+
import "../../chunk-36PRYGAM.js";
|
|
10
|
+
import "../../chunk-M63GFNKV.js";
|
|
11
|
+
export {
|
|
12
|
+
Badge,
|
|
13
|
+
badgeRecipe,
|
|
14
|
+
placementInsets
|
|
15
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkR73XQK7Xcjs = require('../../chunk-R73XQK7X.cjs');
|
|
6
|
+
require('../../chunk-XSQPVDFH.cjs');
|
|
7
|
+
require('../../chunk-WFEMJCXO.cjs');
|
|
8
|
+
require('../../chunk-4KFKWBN5.cjs');
|
|
9
|
+
require('../../chunk-7EIHHOHP.cjs');
|
|
10
|
+
require('../../chunk-3E7CDKFO.cjs');
|
|
11
|
+
require('../../chunk-7DPL3ZDS.cjs');
|
|
12
|
+
require('../../chunk-EJQCQPET.cjs');
|
|
13
|
+
require('../../chunk-FNEUOBCV.cjs');
|
|
14
|
+
require('../../chunk-57SJ4LJF.cjs');
|
|
15
|
+
require('../../chunk-7GHM4GKL.cjs');
|
|
16
|
+
require('../../chunk-H4E4HDEP.cjs');
|
|
17
|
+
require('../../chunk-TK44VBIE.cjs');
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
exports.Button = _chunkR73XQK7Xcjs.Button; exports.buttonRecipe = _chunkR73XQK7Xcjs.buttonRecipe; exports.useButton = _chunkR73XQK7Xcjs.useButton;
|