panelui-native 0.2.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +258 -0
- package/lib/module/components/accordion/index.js +312 -0
- package/lib/module/components/accordion/index.js.map +1 -0
- package/lib/module/components/alert/index.js +106 -13
- package/lib/module/components/alert/index.js.map +1 -1
- package/lib/module/components/avatar/index.js +58 -17
- package/lib/module/components/avatar/index.js.map +1 -1
- package/lib/module/components/badge/index.js +29 -8
- package/lib/module/components/badge/index.js.map +1 -1
- package/lib/module/components/button/index.js +87 -26
- package/lib/module/components/button/index.js.map +1 -1
- package/lib/module/components/checkbox/index.js +59 -18
- package/lib/module/components/checkbox/index.js.map +1 -1
- package/lib/module/components/empty-state/index.js +178 -0
- package/lib/module/components/empty-state/index.js.map +1 -0
- package/lib/module/components/frame/index.js +64 -13
- package/lib/module/components/frame/index.js.map +1 -1
- package/lib/module/components/input-group/index.js +132 -0
- package/lib/module/components/input-group/index.js.map +1 -0
- package/lib/module/components/label/index.js +117 -0
- package/lib/module/components/label/index.js.map +1 -0
- package/lib/module/components/progress/index.js +138 -0
- package/lib/module/components/progress/index.js.map +1 -0
- package/lib/module/components/steps/index.js +354 -0
- package/lib/module/components/steps/index.js.map +1 -0
- package/lib/module/components/tabs/index.js +9 -3
- package/lib/module/components/tabs/index.js.map +1 -1
- package/lib/module/components/timeline/index.js +633 -0
- package/lib/module/components/timeline/index.js.map +1 -0
- package/lib/module/components/toast/index.js +569 -0
- package/lib/module/components/toast/index.js.map +1 -0
- package/lib/module/components/toast/toast-store.js +81 -0
- package/lib/module/components/toast/toast-store.js.map +1 -0
- package/lib/module/components/typography/index.js +126 -0
- package/lib/module/components/typography/index.js.map +1 -0
- package/lib/module/icons/index.js +590 -8
- package/lib/module/icons/index.js.map +1 -1
- package/lib/module/index.js +11 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/providers/panel-ui-provider.js +2 -1
- package/lib/module/providers/panel-ui-provider.js.map +1 -1
- package/lib/module/theme/use-theme.js +90 -3
- package/lib/module/theme/use-theme.js.map +1 -1
- package/lib/typescript/src/components/accordion/index.d.ts +56 -0
- package/lib/typescript/src/components/accordion/index.d.ts.map +1 -0
- package/lib/typescript/src/components/alert/index.d.ts +56 -4
- package/lib/typescript/src/components/alert/index.d.ts.map +1 -1
- package/lib/typescript/src/components/avatar/index.d.ts +8 -1
- package/lib/typescript/src/components/avatar/index.d.ts.map +1 -1
- package/lib/typescript/src/components/badge/index.d.ts +38 -0
- package/lib/typescript/src/components/badge/index.d.ts.map +1 -1
- package/lib/typescript/src/components/button/index.d.ts +57 -0
- package/lib/typescript/src/components/button/index.d.ts.map +1 -1
- package/lib/typescript/src/components/checkbox/index.d.ts +50 -0
- package/lib/typescript/src/components/checkbox/index.d.ts.map +1 -1
- package/lib/typescript/src/components/empty-state/index.d.ts +73 -0
- package/lib/typescript/src/components/empty-state/index.d.ts.map +1 -0
- package/lib/typescript/src/components/frame/index.d.ts +39 -5
- package/lib/typescript/src/components/frame/index.d.ts.map +1 -1
- package/lib/typescript/src/components/input-group/index.d.ts +34 -0
- package/lib/typescript/src/components/input-group/index.d.ts.map +1 -0
- package/lib/typescript/src/components/label/index.d.ts +28 -0
- package/lib/typescript/src/components/label/index.d.ts.map +1 -0
- package/lib/typescript/src/components/progress/index.d.ts +132 -0
- package/lib/typescript/src/components/progress/index.d.ts.map +1 -0
- package/lib/typescript/src/components/steps/index.d.ts +62 -0
- package/lib/typescript/src/components/steps/index.d.ts.map +1 -0
- package/lib/typescript/src/components/tabs/index.d.ts.map +1 -1
- package/lib/typescript/src/components/timeline/index.d.ts +96 -0
- package/lib/typescript/src/components/timeline/index.d.ts.map +1 -0
- package/lib/typescript/src/components/toast/index.d.ts +176 -0
- package/lib/typescript/src/components/toast/index.d.ts.map +1 -0
- package/lib/typescript/src/components/toast/toast-store.d.ts +65 -0
- package/lib/typescript/src/components/toast/toast-store.d.ts.map +1 -0
- package/lib/typescript/src/components/typography/index.d.ts +77 -0
- package/lib/typescript/src/components/typography/index.d.ts.map +1 -0
- package/lib/typescript/src/icons/index.d.ts +60 -0
- package/lib/typescript/src/icons/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +13 -4
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/providers/panel-ui-provider.d.ts.map +1 -1
- package/lib/typescript/src/theme/use-theme.d.ts +64 -4
- package/lib/typescript/src/theme/use-theme.d.ts.map +1 -1
- package/package.json +22 -4
- package/src/components/accordion/index.tsx +344 -0
- package/src/components/alert/index.tsx +102 -16
- package/src/components/avatar/index.tsx +68 -20
- package/src/components/badge/index.tsx +38 -9
- package/src/components/button/index.tsx +102 -19
- package/src/components/checkbox/index.tsx +64 -12
- package/src/components/empty-state/index.tsx +136 -0
- package/src/components/frame/index.tsx +101 -31
- package/src/components/input-group/index.tsx +164 -0
- package/src/components/label/index.tsx +128 -0
- package/src/components/progress/index.tsx +147 -0
- package/src/components/steps/index.tsx +343 -0
- package/src/components/tabs/index.tsx +10 -2
- package/src/components/timeline/index.tsx +456 -0
- package/src/components/toast/index.tsx +568 -0
- package/src/components/toast/toast-store.ts +120 -0
- package/src/components/typography/index.tsx +121 -0
- package/src/icons/index.tsx +423 -7
- package/src/index.ts +114 -4
- package/src/providers/panel-ui-provider.tsx +3 -0
- package/src/theme/use-theme.ts +119 -4
- package/theme.css +330 -7
|
@@ -1,33 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Alert — a status message with an optional leading status icon.
|
|
5
|
+
*
|
|
6
|
+
* Adapted from: heroui-inc/heroui-native src/components/alert/alert.tsx
|
|
7
|
+
* (Indicator / Content / Title / Description anatomy, status-driven icon and
|
|
8
|
+
* title colour), restyled with Coss UI tokens.
|
|
9
|
+
*
|
|
10
|
+
* The `variant` prop name is kept from PanelUI v0.2 rather than renamed to
|
|
11
|
+
* HeroUI's `status`, so existing code keeps working.
|
|
12
|
+
*/
|
|
3
13
|
import { createContext, forwardRef, useContext } from 'react';
|
|
4
14
|
import { View } from 'react-native';
|
|
5
15
|
import { tv } from 'tailwind-variants';
|
|
16
|
+
import { useCSSVariable } from 'uniwind';
|
|
6
17
|
import { cn } from "../../utils/cn.js";
|
|
7
18
|
import { Text } from "../../primitives/text.js";
|
|
8
|
-
import {
|
|
19
|
+
import { AlertTriangleIcon, CheckCircleIcon, InfoIcon } from "../../icons/index.js";
|
|
20
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
21
|
const alertVariants = tv({
|
|
10
22
|
slots: {
|
|
11
|
-
root: 'w-full gap-
|
|
12
|
-
|
|
23
|
+
root: 'w-full flex-row gap-3 rounded-xl border px-3.5 py-3',
|
|
24
|
+
indicator: 'pt-px',
|
|
25
|
+
content: 'flex-1 gap-0.5',
|
|
26
|
+
title: 'text-sm font-medium',
|
|
13
27
|
description: 'text-sm text-muted-foreground'
|
|
14
28
|
},
|
|
15
29
|
variants: {
|
|
16
30
|
variant: {
|
|
17
31
|
default: {
|
|
18
|
-
root: 'border-border bg-surface'
|
|
32
|
+
root: 'border-border bg-surface',
|
|
33
|
+
title: 'text-card-foreground'
|
|
19
34
|
},
|
|
20
35
|
info: {
|
|
21
|
-
root: 'border-info/32 bg-info
|
|
36
|
+
root: 'border-info/32 bg-info-soft',
|
|
37
|
+
title: 'text-info-foreground'
|
|
22
38
|
},
|
|
23
39
|
success: {
|
|
24
|
-
root: 'border-success/32 bg-success
|
|
40
|
+
root: 'border-success/32 bg-success-soft',
|
|
41
|
+
title: 'text-success-foreground'
|
|
25
42
|
},
|
|
26
43
|
warning: {
|
|
27
|
-
root: 'border-warning/32 bg-warning
|
|
44
|
+
root: 'border-warning/32 bg-warning-soft',
|
|
45
|
+
title: 'text-warning-foreground'
|
|
28
46
|
},
|
|
29
47
|
destructive: {
|
|
30
|
-
root: 'border-destructive/32 bg-destructive
|
|
48
|
+
root: 'border-destructive/32 bg-destructive-soft',
|
|
49
|
+
title: 'text-destructive-foreground'
|
|
31
50
|
}
|
|
32
51
|
}
|
|
33
52
|
},
|
|
@@ -36,6 +55,22 @@ const alertVariants = tv({
|
|
|
36
55
|
}
|
|
37
56
|
});
|
|
38
57
|
const AlertContext = /*#__PURE__*/createContext('default');
|
|
58
|
+
|
|
59
|
+
/** CSS variable each variant's indicator icon takes its colour from. */
|
|
60
|
+
const INDICATOR_COLOR_VAR = {
|
|
61
|
+
default: '--color-muted-foreground',
|
|
62
|
+
info: '--color-info-foreground',
|
|
63
|
+
success: '--color-success-foreground',
|
|
64
|
+
warning: '--color-warning-foreground',
|
|
65
|
+
destructive: '--color-destructive-foreground'
|
|
66
|
+
};
|
|
67
|
+
const INDICATOR_ICON = {
|
|
68
|
+
default: InfoIcon,
|
|
69
|
+
info: InfoIcon,
|
|
70
|
+
success: CheckCircleIcon,
|
|
71
|
+
warning: AlertTriangleIcon,
|
|
72
|
+
destructive: AlertTriangleIcon
|
|
73
|
+
};
|
|
39
74
|
const AlertRoot = /*#__PURE__*/forwardRef(({
|
|
40
75
|
className,
|
|
41
76
|
variant = 'default',
|
|
@@ -44,7 +79,9 @@ const AlertRoot = /*#__PURE__*/forwardRef(({
|
|
|
44
79
|
...props
|
|
45
80
|
}, ref) => {
|
|
46
81
|
const {
|
|
47
|
-
root
|
|
82
|
+
root,
|
|
83
|
+
indicator,
|
|
84
|
+
content
|
|
48
85
|
} = alertVariants({
|
|
49
86
|
variant
|
|
50
87
|
});
|
|
@@ -57,13 +94,12 @@ const AlertRoot = /*#__PURE__*/forwardRef(({
|
|
|
57
94
|
className
|
|
58
95
|
}),
|
|
59
96
|
...props,
|
|
60
|
-
children: icon ? /*#__PURE__*/_jsxs(
|
|
61
|
-
className: "flex-row items-start gap-3",
|
|
97
|
+
children: icon ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
62
98
|
children: [/*#__PURE__*/_jsx(View, {
|
|
63
|
-
className:
|
|
99
|
+
className: indicator(),
|
|
64
100
|
children: icon
|
|
65
101
|
}), /*#__PURE__*/_jsx(View, {
|
|
66
|
-
className:
|
|
102
|
+
className: content(),
|
|
67
103
|
children: children
|
|
68
104
|
})]
|
|
69
105
|
}) : children
|
|
@@ -71,6 +107,59 @@ const AlertRoot = /*#__PURE__*/forwardRef(({
|
|
|
71
107
|
});
|
|
72
108
|
});
|
|
73
109
|
AlertRoot.displayName = 'Alert';
|
|
110
|
+
/**
|
|
111
|
+
* Leading status icon. Resolves both the icon and its colour from the parent
|
|
112
|
+
* Alert's variant, so it follows the active theme.
|
|
113
|
+
*/
|
|
114
|
+
const AlertIndicator = /*#__PURE__*/forwardRef(({
|
|
115
|
+
className,
|
|
116
|
+
iconProps,
|
|
117
|
+
children,
|
|
118
|
+
...props
|
|
119
|
+
}, ref) => {
|
|
120
|
+
const variant = useContext(AlertContext);
|
|
121
|
+
const {
|
|
122
|
+
indicator
|
|
123
|
+
} = alertVariants({
|
|
124
|
+
variant
|
|
125
|
+
});
|
|
126
|
+
const themeColor = useCSSVariable(INDICATOR_COLOR_VAR[variant]);
|
|
127
|
+
const Icon = INDICATOR_ICON[variant];
|
|
128
|
+
const color = iconProps?.color ?? (typeof themeColor === 'string' ? themeColor : undefined);
|
|
129
|
+
return /*#__PURE__*/_jsx(View, {
|
|
130
|
+
ref: ref,
|
|
131
|
+
className: indicator({
|
|
132
|
+
className
|
|
133
|
+
}),
|
|
134
|
+
...props,
|
|
135
|
+
children: children ?? /*#__PURE__*/_jsx(Icon, {
|
|
136
|
+
size: iconProps?.size ?? 18,
|
|
137
|
+
color: color
|
|
138
|
+
})
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
AlertIndicator.displayName = 'Alert.Indicator';
|
|
142
|
+
|
|
143
|
+
/** Flex-1 wrapper for Alert.Title and Alert.Description. */
|
|
144
|
+
const AlertContent = /*#__PURE__*/forwardRef(({
|
|
145
|
+
className,
|
|
146
|
+
...props
|
|
147
|
+
}, ref) => {
|
|
148
|
+
const variant = useContext(AlertContext);
|
|
149
|
+
const {
|
|
150
|
+
content
|
|
151
|
+
} = alertVariants({
|
|
152
|
+
variant
|
|
153
|
+
});
|
|
154
|
+
return /*#__PURE__*/_jsx(View, {
|
|
155
|
+
ref: ref,
|
|
156
|
+
className: content({
|
|
157
|
+
className
|
|
158
|
+
}),
|
|
159
|
+
...props
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
AlertContent.displayName = 'Alert.Content';
|
|
74
163
|
const AlertTitle = /*#__PURE__*/forwardRef(({
|
|
75
164
|
className,
|
|
76
165
|
...props
|
|
@@ -106,6 +195,10 @@ const AlertDescription = /*#__PURE__*/forwardRef(({
|
|
|
106
195
|
});
|
|
107
196
|
AlertDescription.displayName = 'Alert.Description';
|
|
108
197
|
export const Alert = Object.assign(AlertRoot, {
|
|
198
|
+
/** @optional Status icon rendered as the leading visual element. */
|
|
199
|
+
Indicator: AlertIndicator,
|
|
200
|
+
/** @optional Wrapper for title and description. */
|
|
201
|
+
Content: AlertContent,
|
|
109
202
|
Title: AlertTitle,
|
|
110
203
|
Description: AlertDescription
|
|
111
204
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createContext","forwardRef","useContext","View","tv","cn","Text","jsx","_jsx","jsxs","_jsxs","alertVariants","slots","root","title","description","variants","variant","default","info","success","warning","destructive","defaultVariants","AlertContext","AlertRoot","className","icon","children","props","ref","Provider","value","accessibilityRole","displayName","AlertTitle","AlertDescription","Alert","Object","assign","Title","Description"],"sourceRoot":"../../../../src","sources":["components/alert/index.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,UAAU,EAAEC,UAAU,QAAwB,OAAO;AAC7E,SAASC,IAAI,
|
|
1
|
+
{"version":3,"names":["createContext","forwardRef","useContext","View","tv","useCSSVariable","cn","Text","AlertTriangleIcon","CheckCircleIcon","InfoIcon","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","alertVariants","slots","root","indicator","content","title","description","variants","variant","default","info","success","warning","destructive","defaultVariants","AlertContext","INDICATOR_COLOR_VAR","INDICATOR_ICON","AlertRoot","className","icon","children","props","ref","Provider","value","accessibilityRole","displayName","AlertIndicator","iconProps","themeColor","Icon","color","undefined","size","AlertContent","AlertTitle","AlertDescription","Alert","Object","assign","Indicator","Content","Title","Description"],"sourceRoot":"../../../../src","sources":["components/alert/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,UAAU,EAAEC,UAAU,QAAwB,OAAO;AAC7E,SAASC,IAAI,QAA6C,cAAc;AACxE,SAASC,EAAE,QAA2B,mBAAmB;AACzD,SAASC,cAAc,QAAQ,SAAS;AACxC,SAASC,EAAE,QAAQ,mBAAgB;AACnC,SAASC,IAAI,QAAwB,0BAAuB;AAC5D,SAASC,iBAAiB,EAAEC,eAAe,EAAEC,QAAQ,QAAQ,sBAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAE3E,MAAMC,aAAa,GAAGb,EAAE,CAAC;EACvBc,KAAK,EAAE;IACLC,IAAI,EAAE,qDAAqD;IAC3DC,SAAS,EAAE,OAAO;IAClBC,OAAO,EAAE,gBAAgB;IACzBC,KAAK,EAAE,qBAAqB;IAC5BC,WAAW,EAAE;EACf,CAAC;EACDC,QAAQ,EAAE;IACRC,OAAO,EAAE;MACPC,OAAO,EAAE;QACPP,IAAI,EAAE,0BAA0B;QAChCG,KAAK,EAAE;MACT,CAAC;MACDK,IAAI,EAAE;QACJR,IAAI,EAAE,6BAA6B;QACnCG,KAAK,EAAE;MACT,CAAC;MACDM,OAAO,EAAE;QACPT,IAAI,EAAE,mCAAmC;QACzCG,KAAK,EAAE;MACT,CAAC;MACDO,OAAO,EAAE;QACPV,IAAI,EAAE,mCAAmC;QACzCG,KAAK,EAAE;MACT,CAAC;MACDQ,WAAW,EAAE;QACXX,IAAI,EAAE,2C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AAGC,MAAM,CAACC,MAAM,CAACtB,SAAS,EAAE;EAC5C;EACAuB,SAAS,EAAEb,cAAc;EACzB;EACAc,OAAO,EAAEP,YAAY;EACrBQ,KAAK,EAAEP,UAAU;EACjBQ,WAAW,EAAEP;AACf,CAAC,CAAC","ignoreList":[]}
|
|
@@ -4,7 +4,8 @@ import { forwardRef, useState } from 'react';
|
|
|
4
4
|
import { Image, View } from 'react-native';
|
|
5
5
|
import { tv } from 'tailwind-variants';
|
|
6
6
|
import { Text } from "../../primitives/text.js";
|
|
7
|
-
import {
|
|
7
|
+
import { cn } from "../../utils/cn.js";
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
9
|
const avatarVariants = tv({
|
|
9
10
|
slots: {
|
|
10
11
|
root: 'items-center justify-center overflow-hidden rounded-full border border-border bg-muted',
|
|
@@ -35,12 +36,13 @@ const avatarVariants = tv({
|
|
|
35
36
|
size: 'md'
|
|
36
37
|
}
|
|
37
38
|
});
|
|
38
|
-
|
|
39
|
+
const AvatarRoot = /*#__PURE__*/forwardRef(({
|
|
39
40
|
className,
|
|
40
41
|
size,
|
|
41
42
|
source,
|
|
42
43
|
fallback,
|
|
43
44
|
imageProps,
|
|
45
|
+
children,
|
|
44
46
|
...props
|
|
45
47
|
}, ref) => {
|
|
46
48
|
const [errored, setErrored] = useState(false);
|
|
@@ -52,23 +54,62 @@ export const Avatar = /*#__PURE__*/forwardRef(({
|
|
|
52
54
|
size
|
|
53
55
|
});
|
|
54
56
|
const showImage = !!source && !errored;
|
|
55
|
-
|
|
57
|
+
const face = showImage ? /*#__PURE__*/_jsx(Image, {
|
|
58
|
+
source: source,
|
|
59
|
+
onError: () => setErrored(true),
|
|
60
|
+
className: image(),
|
|
61
|
+
...imageProps
|
|
62
|
+
}) : /*#__PURE__*/_jsx(Text, {
|
|
63
|
+
className: fallbackSlot(),
|
|
64
|
+
children: fallback ?? '?'
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// The plain avatar is a single clipped node.
|
|
68
|
+
if (!children) {
|
|
69
|
+
return /*#__PURE__*/_jsx(View, {
|
|
70
|
+
ref: ref,
|
|
71
|
+
accessibilityRole: "image",
|
|
72
|
+
className: root({
|
|
73
|
+
className
|
|
74
|
+
}),
|
|
75
|
+
...props,
|
|
76
|
+
children: face
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// With an overlay it needs two: the face keeps overflow-hidden to round
|
|
81
|
+
// the image, which would otherwise cut a corner badge in half, so the
|
|
82
|
+
// overlay hangs off an unclipped wrapper around it.
|
|
83
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
56
84
|
ref: ref,
|
|
57
|
-
|
|
58
|
-
className: root({
|
|
59
|
-
className
|
|
60
|
-
}),
|
|
85
|
+
className: cn('self-start', className),
|
|
61
86
|
...props,
|
|
62
|
-
children:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}) : /*#__PURE__*/_jsx(Text, {
|
|
68
|
-
className: fallbackSlot(),
|
|
69
|
-
children: fallback ?? '?'
|
|
70
|
-
})
|
|
87
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
88
|
+
accessibilityRole: "image",
|
|
89
|
+
className: root(),
|
|
90
|
+
children: face
|
|
91
|
+
}), children]
|
|
71
92
|
});
|
|
72
93
|
});
|
|
73
|
-
|
|
94
|
+
AvatarRoot.displayName = 'Avatar';
|
|
95
|
+
/**
|
|
96
|
+
* Overlay pinned to the avatar's top-right — an unread count, a presence dot.
|
|
97
|
+
*
|
|
98
|
+
* The ring is `border-background` so the badge separates from the image
|
|
99
|
+
* whatever surface the avatar sits on.
|
|
100
|
+
*/
|
|
101
|
+
const AvatarBadge = /*#__PURE__*/forwardRef(({
|
|
102
|
+
className,
|
|
103
|
+
children,
|
|
104
|
+
...props
|
|
105
|
+
}, ref) => /*#__PURE__*/_jsx(View, {
|
|
106
|
+
ref: ref,
|
|
107
|
+
className: cn('absolute -right-1 -top-1 rounded-full border-2 border-background', className),
|
|
108
|
+
...props,
|
|
109
|
+
children: children
|
|
110
|
+
}));
|
|
111
|
+
AvatarBadge.displayName = 'Avatar.Badge';
|
|
112
|
+
export const Avatar = Object.assign(AvatarRoot, {
|
|
113
|
+
Badge: AvatarBadge
|
|
114
|
+
});
|
|
74
115
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","useState","Image","View","tv","Text","jsx","_jsx","avatarVariants","slots","root","image","fallback","variants","size","sm","md","lg","xl","defaultVariants","
|
|
1
|
+
{"version":3,"names":["forwardRef","useState","Image","View","tv","Text","cn","jsx","_jsx","jsxs","_jsxs","avatarVariants","slots","root","image","fallback","variants","size","sm","md","lg","xl","defaultVariants","AvatarRoot","className","source","imageProps","children","props","ref","errored","setErrored","fallbackSlot","showImage","face","onError","accessibilityRole","displayName","AvatarBadge","Avatar","Object","assign","Badge"],"sourceRoot":"../../../../src","sources":["components/avatar/index.tsx"],"mappings":";;AAAA,SAASA,UAAU,EAAEC,QAAQ,QAAwB,OAAO;AAC5D,SACEC,KAAK,EACLC,IAAI,QAIC,cAAc;AACrB,SAASC,EAAE,QAA2B,mBAAmB;AACzD,SAASC,IAAI,QAAQ,0BAAuB;AAC5C,SAASC,EAAE,QAAQ,mBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAEpC,MAAMC,cAAc,GAAGP,EAAE,CAAC;EACxBQ,KAAK,EAAE;IACLC,IAAI,EAAE,wFAAwF;IAC9FC,KAAK,EAAE,gCAAgC;IACvCC,QAAQ,EAAE;EACZ,CAAC;EACDC,QAAQ,EAAE;IACRC,IAAI,EAAE;MACJC,EAAE,EAAE;QAAEL,IAAI,EAAE,SAAS;QAAEE,QAAQ,EAAE;MAAU,CAAC;MAC5CI,EAAE,EAAE;QAAEN,IAAI,EAAE,WAAW;QAAEE,QAAQ,EAAE;MAAU,CAAC;MA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X;;EAEA;EACA;EACA;EACA,oBACExB,KAAA,CAACP,IAAI;IAAC0B,GAAG,EAAEA,GAAI;IAACL,SAAS,EAAElB,EAAE,CAAC,YAAY,EAAEkB,SAAS,CAAE;IAAA,GAAKI,KAAK;IAAAD,QAAA,gBAC/DnB,IAAA,CAACL,IAAI;MAACiC,iBAAiB,EAAC,OAAO;MAACZ,SAAS,EAAEX,IAAI,CAAC,CAAE;MAAAc,QAAA,EAC/CO;IAAI,CACD,CAAC,EACNP,QAAQ;EAAA,CACL,CAAC;AAEX,CACF,CAAC;AACDJ,UAAU,CAACc,WAAW,GAAG,QAAQ;AAOjC;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAW,gBAAGtC,UAAU,CAC5B,CAAC;EAAEwB,SAAS;EAAEG,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,kBACrCrB,IAAA,CAACL,IAAI;EACH0B,GAAG,EAAEA,GAAI;EACTL,SAAS,EAAElB,EAAE,CACX,kEAAkE,EAClEkB,SACF,CAAE;EAAA,GACEI,KAAK;EAAAD,QAAA,EAERA;AAAQ,CACL,CAEV,CAAC;AACDW,WAAW,CAACD,WAAW,GAAG,cAAc;AAExC,OAAO,MAAME,MAAM,GAAGC,MAAM,CAACC,MAAM,CAAClB,UAAU,EAAE;EAC9CmB,KAAK,EAAEJ;AACT,CAAC,CAAC","ignoreList":[]}
|
|
@@ -11,6 +11,17 @@ const badgeVariants = tv({
|
|
|
11
11
|
label: 'text-xs font-medium'
|
|
12
12
|
},
|
|
13
13
|
variants: {
|
|
14
|
+
shape: {
|
|
15
|
+
default: {},
|
|
16
|
+
/** A bare status dot, no label. */
|
|
17
|
+
dot: {
|
|
18
|
+
root: 'h-2 w-2 rounded-full px-0 py-0'
|
|
19
|
+
},
|
|
20
|
+
/** Circular, for a count sitting over an avatar or an icon. */
|
|
21
|
+
count: {
|
|
22
|
+
root: 'h-5 min-w-5 rounded-full px-1.5 py-0'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
14
25
|
variant: {
|
|
15
26
|
default: {
|
|
16
27
|
root: 'bg-primary',
|
|
@@ -29,48 +40,58 @@ const badgeVariants = tv({
|
|
|
29
40
|
label: 'text-white'
|
|
30
41
|
},
|
|
31
42
|
success: {
|
|
32
|
-
root: 'bg-success
|
|
43
|
+
root: 'bg-success-subtle',
|
|
33
44
|
label: 'text-success-foreground'
|
|
34
45
|
},
|
|
35
46
|
warning: {
|
|
36
|
-
root: 'bg-warning
|
|
47
|
+
root: 'bg-warning-subtle',
|
|
37
48
|
label: 'text-warning-foreground'
|
|
38
49
|
},
|
|
39
50
|
info: {
|
|
40
|
-
root: 'bg-info
|
|
51
|
+
root: 'bg-info-subtle',
|
|
41
52
|
label: 'text-info-foreground'
|
|
42
53
|
}
|
|
43
54
|
}
|
|
44
55
|
},
|
|
45
56
|
defaultVariants: {
|
|
46
|
-
variant: 'default'
|
|
57
|
+
variant: 'default',
|
|
58
|
+
shape: 'default'
|
|
47
59
|
}
|
|
48
60
|
});
|
|
61
|
+
|
|
62
|
+
/** Counts past this render as "99+" so the badge keeps its shape. */
|
|
63
|
+
const MAX_COUNT = 99;
|
|
49
64
|
export const Badge = /*#__PURE__*/forwardRef(({
|
|
50
65
|
children,
|
|
51
66
|
className,
|
|
52
67
|
labelClassName,
|
|
53
68
|
variant,
|
|
69
|
+
shape,
|
|
70
|
+
count,
|
|
54
71
|
...props
|
|
55
72
|
}, ref) => {
|
|
73
|
+
const resolvedShape = shape ?? (count !== undefined ? 'count' : 'default');
|
|
56
74
|
const {
|
|
57
75
|
root,
|
|
58
76
|
label
|
|
59
77
|
} = badgeVariants({
|
|
60
|
-
variant
|
|
78
|
+
variant,
|
|
79
|
+
shape: resolvedShape
|
|
61
80
|
});
|
|
81
|
+
const content = count !== undefined ? `${Math.min(count, MAX_COUNT)}${count > MAX_COUNT ? '+' : ''}` : children;
|
|
62
82
|
return /*#__PURE__*/_jsx(View, {
|
|
63
83
|
ref: ref,
|
|
84
|
+
accessibilityLabel: count !== undefined ? `${count} unread` : undefined,
|
|
64
85
|
className: root({
|
|
65
86
|
className
|
|
66
87
|
}),
|
|
67
88
|
...props,
|
|
68
|
-
children: typeof
|
|
89
|
+
children: resolvedShape === 'dot' ? null : typeof content === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
69
90
|
className: label({
|
|
70
91
|
className: labelClassName
|
|
71
92
|
}),
|
|
72
|
-
children:
|
|
73
|
-
}) :
|
|
93
|
+
children: content
|
|
94
|
+
}) : content
|
|
74
95
|
});
|
|
75
96
|
});
|
|
76
97
|
Badge.displayName = 'Badge';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","View","tv","Text","jsx","_jsx","badgeVariants","slots","root","label","variants","
|
|
1
|
+
{"version":3,"names":["forwardRef","View","tv","Text","jsx","_jsx","badgeVariants","slots","root","label","variants","shape","default","dot","count","variant","secondary","outline","destructive","success","warning","info","defaultVariants","MAX_COUNT","Badge","children","className","labelClassName","props","ref","resolvedShape","undefined","content","Math","min","accessibilityLabel","displayName"],"sourceRoot":"../../../../src","sources":["components/badge/index.tsx"],"mappings":";;AAAA,SAASA,UAAU,QAAwB,OAAO;AAClD,SAASC,IAAI,QAAwB,cAAc;AACnD,SAASC,EAAE,QAA2B,mBAAmB;AACzD,SAASC,IAAI,QAAQ,0BAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE7C,MAAMC,aAAa,GAAGJ,EAAE,CAAC;EACvBK,KAAK,EAAE;IACLC,IAAI,EAAE,wGAAwG;IAC9GC,KAAK,EAAE;EACT,CAAC;EACDC,QAAQ,EAAE;IACRC,KAAK,EAAE;MACLC,OAAO,EAAE,CAAC,CAAC;MACX;MACAC,GAAG,EAAE;QAAEL,IAAI,EAAE;MAAiC,CAAC;MAC/C;MACAM,KAAK,EAAE;QAAEN,IAAI,EAAE;MAAuC;IACxD,CAAC;IACDO,OAAO,EAAE;MACPH,OAAO,EAAE;QAAEJ,IAAI,EAAE,YAAY;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,CAACJ,IAAI;IACH4B,GAAG,EAAEA,GAAI;IACTM,kBAAkB,EAChBrB,KAAK,KAAKiB,SAAS,GAAG,GAAGjB,KAAK,SAAS,GAAGiB,SAC3C;IACDL,SAAS,EAAElB,IAAI,CAAC;MAAEkB;IAAU,CAAC,CAAE;IAAA,GAC3BE,KAAK;IAAAH,QAAA,EAERK,aAAa,KAAK,KAAK,GAAG,IAAI,GAAG,OAAOE,OAAO,KAAK,QAAQ,gBAC3D3B,IAAA,CAACF,IAAI;MAACuB,SAAS,EAAEjB,KAAK,CAAC;QAAEiB,SAAS,EAAEC;MAAe,CAAC,CAAE;MAAAF,QAAA,EAAEO;IAAO,CAAO,CAAC,GAEvEA;EACD,CACG,CAAC;AAEX,CACF,CAAC;AAEDR,KAAK,CAACY,WAAW,GAAG,OAAO","ignoreList":[]}
|
|
@@ -1,36 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { forwardRef
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
4
|
import { tv } from 'tailwind-variants';
|
|
5
|
+
import { useCSSVariable } from 'uniwind';
|
|
5
6
|
import { AnimatedPressable } from "../../primitives/animated-pressable.js";
|
|
6
7
|
import { Text } from "../../primitives/text.js";
|
|
7
|
-
import {
|
|
8
|
+
import { IconColorProvider } from "../../icons/index.js";
|
|
9
|
+
import { Spinner } from "../spinner/index.js";
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
11
|
const buttonVariants = tv({
|
|
9
12
|
slots: {
|
|
10
13
|
root: 'flex-row items-center justify-center gap-2 rounded-lg border border-transparent',
|
|
11
|
-
label: 'font-medium'
|
|
14
|
+
label: 'font-medium',
|
|
15
|
+
spinner: ''
|
|
12
16
|
},
|
|
13
17
|
variants: {
|
|
14
18
|
variant: {
|
|
15
19
|
primary: {
|
|
16
20
|
root: 'border-primary bg-primary shadow-sm',
|
|
17
|
-
label: 'text-primary-foreground'
|
|
21
|
+
label: 'text-primary-foreground',
|
|
22
|
+
spinner: 'border-primary-foreground/32 border-t-primary-foreground'
|
|
18
23
|
},
|
|
19
24
|
secondary: {
|
|
20
25
|
root: 'bg-secondary',
|
|
21
|
-
label: 'text-secondary-foreground'
|
|
26
|
+
label: 'text-secondary-foreground',
|
|
27
|
+
spinner: 'border-secondary-foreground/24 border-t-secondary-foreground'
|
|
22
28
|
},
|
|
23
29
|
outline: {
|
|
24
30
|
root: 'border-input bg-popover shadow-sm',
|
|
25
|
-
label: 'text-foreground'
|
|
31
|
+
label: 'text-foreground',
|
|
32
|
+
spinner: 'border-muted border-t-foreground'
|
|
26
33
|
},
|
|
27
34
|
ghost: {
|
|
28
35
|
root: 'bg-transparent',
|
|
29
|
-
label: 'text-foreground'
|
|
36
|
+
label: 'text-foreground',
|
|
37
|
+
spinner: 'border-muted border-t-foreground'
|
|
30
38
|
},
|
|
31
39
|
destructive: {
|
|
32
40
|
root: 'border-destructive bg-destructive shadow-sm',
|
|
33
|
-
label: 'text-white'
|
|
41
|
+
label: 'text-white',
|
|
42
|
+
spinner: 'border-white/32 border-t-white'
|
|
43
|
+
},
|
|
44
|
+
/** Neutral surface for third-party sign-in, sized for a full-width stack. */
|
|
45
|
+
social: {
|
|
46
|
+
root: 'border-input bg-card shadow-sm',
|
|
47
|
+
label: 'text-foreground',
|
|
48
|
+
spinner: 'border-muted border-t-foreground'
|
|
34
49
|
}
|
|
35
50
|
},
|
|
36
51
|
size: {
|
|
@@ -50,6 +65,11 @@ const buttonVariants = tv({
|
|
|
50
65
|
root: 'h-11 w-11 px-0'
|
|
51
66
|
}
|
|
52
67
|
},
|
|
68
|
+
fullWidth: {
|
|
69
|
+
true: {
|
|
70
|
+
root: 'w-full'
|
|
71
|
+
}
|
|
72
|
+
},
|
|
53
73
|
disabled: {
|
|
54
74
|
true: {
|
|
55
75
|
root: 'opacity-[0.64]'
|
|
@@ -61,40 +81,81 @@ const buttonVariants = tv({
|
|
|
61
81
|
size: 'md'
|
|
62
82
|
}
|
|
63
83
|
});
|
|
84
|
+
const SPINNER_SIZE = {
|
|
85
|
+
sm: 'sm',
|
|
86
|
+
md: 'sm',
|
|
87
|
+
lg: 'md',
|
|
88
|
+
icon: 'sm'
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The theme token each variant's content reads against. Icons in the content
|
|
93
|
+
* slots inherit the resolved value, so they follow the theme automatically.
|
|
94
|
+
*
|
|
95
|
+
* `destructive` is absent on purpose: its background is a saturated red in
|
|
96
|
+
* every theme, so its content is always white rather than a themed token.
|
|
97
|
+
*/
|
|
98
|
+
const CONTENT_COLOR_VAR = {
|
|
99
|
+
primary: '--color-primary-foreground',
|
|
100
|
+
secondary: '--color-secondary-foreground',
|
|
101
|
+
outline: '--color-foreground',
|
|
102
|
+
ghost: '--color-foreground',
|
|
103
|
+
social: '--color-foreground'
|
|
104
|
+
};
|
|
64
105
|
export const Button = /*#__PURE__*/forwardRef(({
|
|
65
106
|
children,
|
|
66
107
|
className,
|
|
67
108
|
labelClassName,
|
|
68
109
|
variant,
|
|
69
110
|
size,
|
|
111
|
+
fullWidth,
|
|
70
112
|
disabled,
|
|
113
|
+
loading = false,
|
|
114
|
+
startContent,
|
|
115
|
+
endContent,
|
|
71
116
|
...props
|
|
72
117
|
}, ref) => {
|
|
118
|
+
const isDisabled = disabled || loading;
|
|
73
119
|
const {
|
|
74
120
|
root,
|
|
75
|
-
label
|
|
121
|
+
label,
|
|
122
|
+
spinner
|
|
76
123
|
} = buttonVariants({
|
|
77
124
|
variant,
|
|
78
125
|
size,
|
|
79
|
-
|
|
126
|
+
fullWidth,
|
|
127
|
+
disabled: isDisabled
|
|
80
128
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
129
|
+
|
|
130
|
+
// Icons in the content slots inherit this, so they stay legible when the
|
|
131
|
+
// theme inverts the button's background. Without it every caller has to
|
|
132
|
+
// hardcode a hex that is wrong in one theme or the other.
|
|
133
|
+
const themedColor = useCSSVariable(CONTENT_COLOR_VAR[variant === 'destructive' ? 'primary' : variant ?? 'primary']);
|
|
134
|
+
const contentColor = variant === 'destructive' ? '#ffffff' : typeof themedColor === 'string' ? themedColor : undefined;
|
|
135
|
+
return /*#__PURE__*/_jsx(IconColorProvider, {
|
|
136
|
+
color: contentColor,
|
|
137
|
+
children: /*#__PURE__*/_jsxs(AnimatedPressable, {
|
|
138
|
+
ref: ref,
|
|
139
|
+
accessibilityRole: "button",
|
|
140
|
+
accessibilityState: {
|
|
141
|
+
disabled: isDisabled,
|
|
142
|
+
busy: loading
|
|
143
|
+
},
|
|
144
|
+
disabled: isDisabled,
|
|
145
|
+
className: root({
|
|
146
|
+
className
|
|
95
147
|
}),
|
|
96
|
-
|
|
97
|
-
|
|
148
|
+
...props,
|
|
149
|
+
children: [loading ? /*#__PURE__*/_jsx(Spinner, {
|
|
150
|
+
size: SPINNER_SIZE[size ?? 'md'],
|
|
151
|
+
className: spinner()
|
|
152
|
+
}) : startContent, typeof children === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
153
|
+
className: label({
|
|
154
|
+
className: labelClassName
|
|
155
|
+
}),
|
|
156
|
+
children: children
|
|
157
|
+
}) : children, endContent]
|
|
158
|
+
})
|
|
98
159
|
});
|
|
99
160
|
});
|
|
100
161
|
Button.displayName = 'Button';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","
|
|
1
|
+
{"version":3,"names":["forwardRef","tv","useCSSVariable","AnimatedPressable","Text","IconColorProvider","Spinner","jsx","_jsx","jsxs","_jsxs","buttonVariants","slots","root","label","spinner","variants","variant","primary","secondary","outline","ghost","destructive","social","size","sm","md","lg","icon","fullWidth","true","disabled","defaultVariants","SPINNER_SIZE","CONTENT_COLOR_VAR","Button","children","className","labelClassName","loading","startContent","endContent","props","ref","isDisabled","themedColor","contentColor","undefined","color","accessibilityRole","accessibilityState","busy","displayName"],"sourceRoot":"../../../../src","sources":["components/button/index.tsx"],"mappings":";;AAAA,SAASA,UAAU,QAAwB,OAAO;AAElD,SAASC,EAAE,QAA2B,mBAAmB;AACzD,SAASC,cAAc,QAAQ,SAAS;AACxC,SACEC,iBAAiB,QAEZ,wCAAqC;AAC5C,SAASC,IAAI,QAAQ,0BAAuB;AAC5C,SAASC,iBAAiB,QAAQ,sBAAa;AAC/C,SAASC,OAAO,QAAQ,qBAAY;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAErC,MAAMC,cAAc,GAAGV,EAAE,CAAC;EACxBW,KAAK,EAAE;IACLC,IAAI,EAAE,iFAAiF;IACvFC,KAAK,EAAE,aAAa;IACpBC,OAAO,EAAE;EACX,CAAC;EACDC,QAAQ,EAAE;IACRC,OAAO,EAAE;MACPC,OAAO,EAAE;QACPL,IAAI,EAAE,qCAAqC;QAC3CC,KAAK,EAAE,yBAAyB;QAChCC,OAAO,EAAE;MACX,CAAC;MACDI,SAAS,EAAE;QACTN,IAAI,EAAE,cAAc;QACpBC,KAAK,EAAE,2BAA2B;QAClCC,OAAO,EAAE;MACX,CAAC;MACDK,OAAO,EAAE;QACPP,IAAI,EAAE,mCAAmC;QACzCC,KAAK,EAAE,iBAAiB;QACxBC,OAAO,EAAE;MACX,CAAC;MACDM,KAAK,EAAE;QACLR,IAAI,EAAE,gBAAgB;QACtBC,KAAK,EAAE,iBAAiB;QACxBC,OAAO,EAAE;MACX,CAAC;MACDO,WAAW,EAAE;QACXT,IAAI,EAAE,6CAA6C;QACnDC,KAAK,EAAE,YAAY;QACnBC,OAAO,EAAE;MACX,CAAC;MACD;MACAQ,MAAM,EAAE;QACNV,IAAI,EAAE,gCAAgC;QACtCC,KAAK,EAAE,iBAAiB;QACxBC,OAAO,EAAE;MACX;IACF,CAAC;IACDS,IAAI,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