asheeui 0.7.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AsheeUIProvider.d.ts.map +1 -1
- package/dist/AsheeUIProvider.js +22 -15
- package/dist/components/accordion/Accordion.d.ts.map +1 -1
- package/dist/components/accordion/Accordion.js +9 -7
- package/dist/components/alert/Alert.d.ts +88 -0
- package/dist/components/alert/Alert.d.ts.map +1 -0
- package/dist/components/alert/Alert.js +61 -0
- package/dist/components/alert/alert-config.d.ts +56 -0
- package/dist/components/alert/alert-config.d.ts.map +1 -0
- package/dist/components/alert/alert-config.js +14 -0
- package/dist/components/alert/alert-styles.d.ts +32 -0
- package/dist/components/alert/alert-styles.d.ts.map +1 -0
- package/dist/components/alert/alert-styles.js +20 -0
- package/dist/components/alert/index.d.ts +3 -0
- package/dist/components/alert/index.d.ts.map +1 -0
- package/dist/components/alert/index.js +3 -0
- package/dist/components/autocomplete/Autocomplete.d.ts +6 -6
- package/dist/components/autocomplete/Autocomplete.d.ts.map +1 -1
- package/dist/components/autocomplete/Autocomplete.js +94 -58
- package/dist/components/autocomplete/autocomplete-config.d.ts +1 -1
- package/dist/components/autocomplete/autocomplete-config.d.ts.map +1 -1
- package/dist/components/avatar/Avatar.d.ts +87 -0
- package/dist/components/avatar/Avatar.d.ts.map +1 -0
- package/dist/components/avatar/Avatar.js +43 -0
- package/dist/components/avatar/avatar-config.d.ts +48 -0
- package/dist/components/avatar/avatar-config.d.ts.map +1 -0
- package/dist/components/avatar/avatar-config.js +14 -0
- package/dist/components/avatar/avatar-styles.d.ts +21 -0
- package/dist/components/avatar/avatar-styles.d.ts.map +1 -0
- package/dist/components/avatar/avatar-styles.js +13 -0
- package/dist/components/avatar/avatar.helpers.d.ts +19 -0
- package/dist/components/avatar/avatar.helpers.d.ts.map +1 -0
- package/dist/components/avatar/avatar.helpers.js +11 -0
- package/dist/components/avatar/index.d.ts +3 -0
- package/dist/components/avatar/index.d.ts.map +1 -0
- package/dist/components/avatar/index.js +4 -0
- package/dist/components/badge/Badge.d.ts +69 -0
- package/dist/components/badge/Badge.d.ts.map +1 -0
- package/dist/components/badge/Badge.js +39 -0
- package/dist/components/badge/badge-config.d.ts +63 -0
- package/dist/components/badge/badge-config.d.ts.map +1 -0
- package/dist/components/badge/badge-config.js +15 -0
- package/dist/components/badge/badge-styles.d.ts +27 -0
- package/dist/components/badge/badge-styles.d.ts.map +1 -0
- package/dist/components/badge/badge-styles.js +25 -0
- package/dist/components/badge/index.d.ts +3 -0
- package/dist/components/badge/index.d.ts.map +1 -0
- package/dist/components/badge/index.js +3 -0
- package/dist/components/breadcrumb/Breadcrumb.d.ts +106 -0
- package/dist/components/breadcrumb/Breadcrumb.d.ts.map +1 -0
- package/dist/components/breadcrumb/Breadcrumb.js +52 -0
- package/dist/components/breadcrumb/breadcrumb-config.d.ts +41 -0
- package/dist/components/breadcrumb/breadcrumb-config.d.ts.map +1 -0
- package/dist/components/breadcrumb/breadcrumb-config.js +10 -0
- package/dist/components/breadcrumb/breadcrumb-styles.d.ts +28 -0
- package/dist/components/breadcrumb/breadcrumb-styles.d.ts.map +1 -0
- package/dist/components/breadcrumb/breadcrumb-styles.js +17 -0
- package/dist/components/breadcrumb/index.d.ts +3 -0
- package/dist/components/breadcrumb/index.d.ts.map +1 -0
- package/dist/components/breadcrumb/index.js +3 -0
- package/dist/components/button/Button.d.ts.map +1 -1
- package/dist/components/button/Button.js +10 -7
- package/dist/components/{date-picker/DatePicker.d.ts → calendar/Calendar.d.ts} +21 -21
- package/dist/components/calendar/Calendar.d.ts.map +1 -0
- package/dist/components/{date-picker/DatePicker.js → calendar/Calendar.js} +11 -11
- package/dist/components/{date-picker/Calendar.d.ts → calendar/DateGrid.d.ts} +7 -7
- package/dist/components/calendar/DateGrid.d.ts.map +1 -0
- package/dist/components/calendar/DateGrid.js +194 -0
- package/dist/components/calendar/TimeSpinner.d.ts.map +1 -0
- package/dist/components/{date-picker → calendar}/TimeSpinner.js +3 -3
- package/dist/components/{date-picker/date-picker-config.d.ts → calendar/calendar-config.d.ts} +17 -17
- package/dist/components/calendar/calendar-config.d.ts.map +1 -0
- package/dist/components/{date-picker/date-picker-config.js → calendar/calendar-config.js} +3 -3
- package/dist/components/{date-picker/date-picker-styles.d.ts → calendar/calendar-styles.d.ts} +1 -1
- package/dist/components/calendar/calendar-styles.d.ts.map +1 -0
- package/dist/components/{date-picker/date-picker-styles.js → calendar/calendar-styles.js} +1 -1
- package/dist/components/{date-picker/date-picker.helpers.d.ts → calendar/calendar.helpers.d.ts} +9 -9
- package/dist/components/calendar/calendar.helpers.d.ts.map +1 -0
- package/dist/components/{date-picker/date-picker.helpers.js → calendar/calendar.helpers.js} +4 -4
- package/dist/components/calendar/index.d.ts +3 -0
- package/dist/components/calendar/index.d.ts.map +1 -0
- package/dist/components/calendar/index.js +6 -0
- package/dist/components/card/Card.d.ts +6 -6
- package/dist/components/card/Card.d.ts.map +1 -1
- package/dist/components/card/Card.js +8 -8
- package/dist/components/carousel/Carousel.d.ts.map +1 -1
- package/dist/components/carousel/Carousel.js +85 -83
- package/dist/components/carousel/carousel-styles.d.ts +1 -20
- package/dist/components/carousel/carousel-styles.d.ts.map +1 -1
- package/dist/components/chip/Chip.js +5 -5
- package/dist/components/drawer/Drawer.d.ts +8 -4
- package/dist/components/drawer/Drawer.d.ts.map +1 -1
- package/dist/components/drawer/Drawer.js +54 -38
- package/dist/components/{select/Select.d.ts → dropmenu/Dropmenu.d.ts} +21 -21
- package/dist/components/{select/Select.d.ts.map → dropmenu/Dropmenu.d.ts.map} +1 -1
- package/dist/components/dropmenu/Dropmenu.js +102 -0
- package/dist/components/{select/select-config.d.ts → dropmenu/dropmenu-config.d.ts} +8 -8
- package/dist/components/dropmenu/dropmenu-config.d.ts.map +1 -0
- package/dist/components/{select/select-config.js → dropmenu/dropmenu-config.js} +3 -3
- package/dist/components/{select/select-styles.d.ts → dropmenu/dropmenu-styles.d.ts} +1 -1
- package/dist/components/dropmenu/dropmenu-styles.d.ts.map +1 -0
- package/dist/components/{select/select-styles.js → dropmenu/dropmenu-styles.js} +1 -1
- package/dist/components/dropmenu/index.d.ts +3 -0
- package/dist/components/dropmenu/index.d.ts.map +1 -0
- package/dist/components/dropmenu/index.js +3 -0
- package/dist/components/field/FieldShell.d.ts +13 -1
- package/dist/components/field/FieldShell.d.ts.map +1 -1
- package/dist/components/field/FieldShell.js +16 -15
- package/dist/components/form/Form.d.ts +109 -0
- package/dist/components/form/Form.d.ts.map +1 -0
- package/dist/components/form/Form.js +42 -0
- package/dist/components/form/form-config.d.ts +57 -0
- package/dist/components/form/form-config.d.ts.map +1 -0
- package/dist/components/form/form-config.js +12 -0
- package/dist/components/form/form-styles.d.ts +27 -0
- package/dist/components/form/form-styles.d.ts.map +1 -0
- package/dist/components/form/form-styles.js +5 -0
- package/dist/components/form/index.d.ts +3 -0
- package/dist/components/form/index.d.ts.map +1 -0
- package/dist/components/form/index.js +3 -0
- package/dist/components/image/Image.d.ts +4 -5
- package/dist/components/image/Image.d.ts.map +1 -1
- package/dist/components/image/Image.js +5 -5
- package/dist/components/input/Input.js +5 -5
- package/dist/components/link/Link.d.ts +12 -10
- package/dist/components/link/Link.d.ts.map +1 -1
- package/dist/components/link/Link.js +1 -1
- package/dist/components/marquee/Marquee.d.ts.map +1 -1
- package/dist/components/marquee/Marquee.js +36 -33
- package/dist/components/{select-menu/SelectMenu.d.ts → menu/Menu.d.ts} +52 -19
- package/dist/components/menu/Menu.d.ts.map +1 -0
- package/dist/components/menu/Menu.js +161 -0
- package/dist/components/menu/index.d.ts +5 -0
- package/dist/components/menu/index.d.ts.map +1 -0
- package/dist/components/menu/index.js +4 -0
- package/dist/components/{select-menu/select-menu-config.d.ts → menu/menu-config.d.ts} +5 -5
- package/dist/components/menu/menu-config.d.ts.map +1 -0
- package/dist/components/{select-menu/select-menu-config.js → menu/menu-config.js} +2 -2
- package/dist/components/menu/menu-navigation.d.ts +38 -0
- package/dist/components/menu/menu-navigation.d.ts.map +1 -0
- package/dist/components/menu/menu-navigation.js +20 -0
- package/dist/components/{select-menu/use-select-floating.d.ts → menu/use-menu-floating.d.ts} +10 -10
- package/dist/components/menu/use-menu-floating.d.ts.map +1 -0
- package/dist/components/{select-menu/use-select-floating.js → menu/use-menu-floating.js} +2 -2
- package/dist/components/modal/Modal.d.ts +6 -1
- package/dist/components/modal/Modal.d.ts.map +1 -1
- package/dist/components/modal/Modal.js +62 -45
- package/dist/components/multi-select/MultiSelect.d.ts +11 -10
- package/dist/components/multi-select/MultiSelect.d.ts.map +1 -1
- package/dist/components/multi-select/MultiSelect.js +99 -86
- package/dist/components/multi-select/multi-select-config.d.ts +1 -1
- package/dist/components/multi-select/multi-select-config.d.ts.map +1 -1
- package/dist/components/pagination/Pagination.d.ts +91 -0
- package/dist/components/pagination/Pagination.d.ts.map +1 -0
- package/dist/components/pagination/Pagination.js +66 -0
- package/dist/components/pagination/index.d.ts +3 -0
- package/dist/components/pagination/index.d.ts.map +1 -0
- package/dist/components/pagination/index.js +4 -0
- package/dist/components/pagination/pagination-config.d.ts +66 -0
- package/dist/components/pagination/pagination-config.d.ts.map +1 -0
- package/dist/components/pagination/pagination-config.js +19 -0
- package/dist/components/pagination/pagination-styles.d.ts +19 -0
- package/dist/components/pagination/pagination-styles.d.ts.map +1 -0
- package/dist/components/pagination/pagination-styles.js +5 -0
- package/dist/components/pagination/pagination.helpers.d.ts +26 -0
- package/dist/components/pagination/pagination.helpers.d.ts.map +1 -0
- package/dist/components/pagination/pagination.helpers.js +12 -0
- package/dist/components/radio/Radio.d.ts +53 -107
- package/dist/components/radio/Radio.d.ts.map +1 -1
- package/dist/components/radio/Radio.js +50 -36
- package/dist/components/radio/RadioGroup.d.ts +107 -53
- package/dist/components/radio/RadioGroup.d.ts.map +1 -1
- package/dist/components/radio/RadioGroup.js +43 -49
- package/dist/components/radio/index.d.ts +0 -1
- package/dist/components/radio/index.d.ts.map +1 -1
- package/dist/components/resizable-screen/ResizableScreen.d.ts +4 -4
- package/dist/components/scrollbar/index.js +1 -0
- package/dist/components/scrollbar/scrollbar-config.js +13 -0
- package/dist/components/sidebar/Sidebar.d.ts.map +1 -1
- package/dist/components/sidebar/Sidebar.js +92 -90
- package/dist/components/skeleton/Skeleton.d.ts +65 -0
- package/dist/components/skeleton/Skeleton.d.ts.map +1 -0
- package/dist/components/skeleton/Skeleton.js +29 -0
- package/dist/components/skeleton/index.d.ts +3 -0
- package/dist/components/skeleton/index.d.ts.map +1 -0
- package/dist/components/skeleton/index.js +3 -0
- package/dist/components/skeleton/skeleton-config.d.ts +40 -0
- package/dist/components/skeleton/skeleton-config.d.ts.map +1 -0
- package/dist/components/skeleton/skeleton-config.js +13 -0
- package/dist/components/skeleton/skeleton-styles.d.ts +19 -0
- package/dist/components/skeleton/skeleton-styles.d.ts.map +1 -0
- package/dist/components/skeleton/skeleton-styles.js +5 -0
- package/dist/components/switch/Switch.d.ts.map +1 -1
- package/dist/components/switch/Switch.js +7 -5
- package/dist/components/table/Table.js +3 -3
- package/dist/components/tabs/Tabs.js +3 -3
- package/dist/components/textarea/Textarea.d.ts +10 -10
- package/dist/components/textarea/Textarea.js +7 -7
- package/dist/components/textarea/textarea-config.d.ts +2 -2
- package/dist/components/toast/ToastItem.d.ts.map +1 -1
- package/dist/components/toast/ToastItem.js +8 -7
- package/dist/components/tooltip/Tooltip.js +5 -5
- package/dist/components/typography/Typography.d.ts +60 -0
- package/dist/components/typography/Typography.d.ts.map +1 -0
- package/dist/components/typography/Typography.js +28 -0
- package/dist/components/typography/index.d.ts +3 -0
- package/dist/components/typography/index.d.ts.map +1 -0
- package/dist/components/typography/index.js +3 -0
- package/dist/components/typography/typography-config.d.ts +54 -0
- package/dist/components/typography/typography-config.d.ts.map +1 -0
- package/dist/components/typography/typography-config.js +12 -0
- package/dist/components/typography/typography-styles.d.ts +21 -0
- package/dist/components/typography/typography-styles.d.ts.map +1 -0
- package/dist/components/typography/typography-styles.js +19 -0
- package/dist/config/default-config.d.ts.map +1 -1
- package/dist/config/default-config.js +2 -2
- package/dist/config/index.js +1 -0
- package/dist/config/validate-config.d.ts +34 -0
- package/dist/config/validate-config.d.ts.map +1 -0
- package/dist/config/validate-config.js +190 -0
- package/dist/index.d.ts +15 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +61 -47
- package/dist/libs/index.js +3 -0
- package/dist/libs/use-body-scroll-lock.d.ts +21 -0
- package/dist/libs/use-body-scroll-lock.d.ts.map +1 -0
- package/dist/libs/use-body-scroll-lock.js +27 -0
- package/dist/libs/use-dialog-overlay.d.ts +21 -0
- package/dist/libs/use-dialog-overlay.d.ts.map +1 -0
- package/dist/libs/use-dialog-overlay.js +21 -0
- package/dist/libs/use-prefers-reduced-motion.d.ts +23 -0
- package/dist/libs/use-prefers-reduced-motion.d.ts.map +1 -0
- package/dist/libs/use-prefers-reduced-motion.js +19 -0
- package/dist/scripts/AsheeThemeScript.js +43 -8
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/typography.d.ts +81 -0
- package/dist/shared/typography.d.ts.map +1 -0
- package/dist/shared/typography.js +137 -0
- package/dist/utils/stacking.d.ts +2 -2
- package/dist/utils/stacking.d.ts.map +1 -1
- package/package.json +13 -6
- package/dist/components/date-picker/Calendar.d.ts.map +0 -1
- package/dist/components/date-picker/Calendar.js +0 -143
- package/dist/components/date-picker/DatePicker.d.ts.map +0 -1
- package/dist/components/date-picker/TimeSpinner.d.ts.map +0 -1
- package/dist/components/date-picker/date-picker-config.d.ts.map +0 -1
- package/dist/components/date-picker/date-picker-styles.d.ts.map +0 -1
- package/dist/components/date-picker/date-picker.helpers.d.ts.map +0 -1
- package/dist/components/date-picker/index.d.ts +0 -3
- package/dist/components/date-picker/index.d.ts.map +0 -1
- package/dist/components/date-picker/index.js +0 -6
- package/dist/components/select/Select.js +0 -98
- package/dist/components/select/index.d.ts +0 -3
- package/dist/components/select/index.d.ts.map +0 -1
- package/dist/components/select/index.js +0 -3
- package/dist/components/select/select-config.d.ts.map +0 -1
- package/dist/components/select/select-styles.d.ts.map +0 -1
- package/dist/components/select-menu/SelectMenu.d.ts.map +0 -1
- package/dist/components/select-menu/SelectMenu.js +0 -104
- package/dist/components/select-menu/index.d.ts +0 -4
- package/dist/components/select-menu/index.d.ts.map +0 -1
- package/dist/components/select-menu/index.js +0 -3
- package/dist/components/select-menu/select-menu-config.d.ts.map +0 -1
- package/dist/components/select-menu/use-select-floating.d.ts.map +0 -1
- /package/dist/components/{date-picker → calendar}/TimeSpinner.d.ts +0 -0
|
@@ -3,77 +3,113 @@
|
|
|
3
3
|
import { useAsheeConfig as e } from "../../libs/context.js";
|
|
4
4
|
import { resolveCascade as t, resolveRadiusKey as n } from "../../utils/resolve-token.js";
|
|
5
5
|
import { Input as r } from "../input/Input.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
6
|
+
import { edgeOptionIndex as i, nextOptionIndex as a } from "../menu/menu-navigation.js";
|
|
7
|
+
import { Menu as o, menuOptionId as s } from "../menu/Menu.js";
|
|
8
|
+
import { useMenuFloating as c } from "../menu/use-menu-floating.js";
|
|
9
|
+
import { FALLBACK_AUTOCOMPLETE_CONFIG as l } from "./autocomplete-config.js";
|
|
10
|
+
import { forwardRef as u, useCallback as d, useEffect as f, useMemo as p, useState as m } from "react";
|
|
11
|
+
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
12
|
+
import { useDismiss as _, useFocus as ee, useInteractions as v, useRole as y } from "@floating-ui/react";
|
|
12
13
|
//#region src/components/autocomplete/Autocomplete.tsx
|
|
13
|
-
var
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}, [
|
|
18
|
-
let { refs:
|
|
19
|
-
isOpen:
|
|
20
|
-
onOpenChange:
|
|
21
|
-
disabled:
|
|
22
|
-
}),
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
]),
|
|
14
|
+
var b = u(({ options: u = [], value: b, onValueChange: x, onInputChange: S, allowCustomValue: C = !1, belowList: w, menu: T, variant: te, color: ne, radius: E, size: D, endContent: O, onClick: k, onKeyDown: A, disabled: j, placeholder: M = "Type to search...", className: N, ...P }, F) => {
|
|
15
|
+
let I = e(), L = I.components?.autocomplete, R = t(te, L?.variant, I.defaultVariant, l.variant), z = t(ne, L?.color, I.defaultColor, l.color), B = n(E, L?.radius, I.defaultRadius, l.radius), V = t(D, L?.size, void 0, l.size), H = p(() => u.find((e) => e.value === b), [u, b]), [U, W] = m(!1), [G, K] = m(() => H ? H.label : String(b ?? "")), [q, J] = m(null);
|
|
16
|
+
f(() => {
|
|
17
|
+
H ? K(H.label) : b != null && K(String(b));
|
|
18
|
+
}, [H, b]);
|
|
19
|
+
let { refs: Y, context: X, isPositioned: Z, floatingStyles: re } = c({
|
|
20
|
+
isOpen: U,
|
|
21
|
+
onOpenChange: W,
|
|
22
|
+
disabled: j
|
|
23
|
+
}), ie = ee(X), ae = _(X), oe = y(X, { role: "combobox" }), { getReferenceProps: se, getFloatingProps: ce } = v([
|
|
24
|
+
ie,
|
|
25
|
+
ae,
|
|
26
|
+
oe
|
|
27
|
+
]), Q = p(() => G.trim() ? u.filter((e) => e.label.toLowerCase().includes(G.toLowerCase())) : u, [u, G]), le = d((e) => {
|
|
27
28
|
let t = e.target.value;
|
|
28
|
-
|
|
29
|
+
K(t), S?.(t), W(!0), J(null), C && x?.(t);
|
|
29
30
|
}, [
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
]),
|
|
34
|
-
|
|
35
|
-
}, [
|
|
36
|
-
|
|
31
|
+
C,
|
|
32
|
+
S,
|
|
33
|
+
x
|
|
34
|
+
]), $ = d((e) => {
|
|
35
|
+
K(e.label), x?.(e.value, e), W(!1), J(null);
|
|
36
|
+
}, [x]), ue = d((e) => {
|
|
37
|
+
if (A?.(e), e.defaultPrevented || j) return;
|
|
38
|
+
let t = e.key === "ArrowDown" ? 1 : e.key === "ArrowUp" ? -1 : 0;
|
|
39
|
+
if (t !== 0) {
|
|
40
|
+
if (e.preventDefault(), !U) {
|
|
41
|
+
W(!0);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
J((e) => a(Q, e, t));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (e.key === "Home" || e.key === "End") {
|
|
48
|
+
if (!U) return;
|
|
49
|
+
e.preventDefault(), J(i(Q, e.key === "Home" ? "first" : "last"));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (e.key === "Enter" && U) {
|
|
53
|
+
let t = q === null ? void 0 : Q[q];
|
|
54
|
+
t && !t.disabled && (e.preventDefault(), $(t));
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
e.key === "Escape" && U && (W(!1), J(null));
|
|
58
|
+
}, [
|
|
59
|
+
q,
|
|
60
|
+
A,
|
|
61
|
+
j,
|
|
62
|
+
Q,
|
|
63
|
+
$,
|
|
64
|
+
U
|
|
65
|
+
]), de = q === null ? void 0 : s(X.floatingId, q), fe = se({
|
|
66
|
+
...P,
|
|
67
|
+
onKeyDown: ue
|
|
68
|
+
}), pe = p(() => b == null ? [] : [b], [b]);
|
|
69
|
+
return /* @__PURE__ */ g("div", {
|
|
37
70
|
className: "w-full relative inline-block",
|
|
38
|
-
children: [/* @__PURE__ */
|
|
71
|
+
children: [/* @__PURE__ */ h(r, {
|
|
39
72
|
ref: (e) => {
|
|
40
|
-
|
|
73
|
+
Y.setReference(e), typeof F == "function" ? F(e) : F && (F.current = e);
|
|
41
74
|
},
|
|
42
|
-
variant:
|
|
43
|
-
radius:
|
|
44
|
-
color:
|
|
45
|
-
size:
|
|
46
|
-
disabled:
|
|
47
|
-
placeholder:
|
|
48
|
-
value:
|
|
49
|
-
onChange:
|
|
75
|
+
variant: R,
|
|
76
|
+
radius: B,
|
|
77
|
+
color: z,
|
|
78
|
+
size: V,
|
|
79
|
+
disabled: j,
|
|
80
|
+
placeholder: M,
|
|
81
|
+
value: G,
|
|
82
|
+
onChange: le,
|
|
50
83
|
onClick: (e) => {
|
|
51
|
-
|
|
84
|
+
j || W(!0), k?.(e);
|
|
52
85
|
},
|
|
53
|
-
"aria-expanded":
|
|
54
|
-
"aria-autocomplete": "
|
|
86
|
+
"aria-expanded": U,
|
|
87
|
+
"aria-autocomplete": "list",
|
|
88
|
+
"aria-activedescendant": de,
|
|
55
89
|
endContent: O,
|
|
56
|
-
className:
|
|
57
|
-
...
|
|
58
|
-
}), /* @__PURE__ */
|
|
59
|
-
isOpen:
|
|
60
|
-
floatingStyles:
|
|
61
|
-
context:
|
|
62
|
-
getFloatingProps:
|
|
63
|
-
setFloatingRef:
|
|
64
|
-
isPositioned:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
90
|
+
className: N,
|
|
91
|
+
...fe
|
|
92
|
+
}), /* @__PURE__ */ h(o, {
|
|
93
|
+
isOpen: U,
|
|
94
|
+
floatingStyles: re,
|
|
95
|
+
context: X,
|
|
96
|
+
getFloatingProps: ce,
|
|
97
|
+
setFloatingRef: Y.setFloating,
|
|
98
|
+
isPositioned: Z,
|
|
99
|
+
activeIndex: q,
|
|
100
|
+
onActiveIndexChange: J,
|
|
101
|
+
options: Q,
|
|
102
|
+
selectedValues: pe,
|
|
103
|
+
onOptionSelect: $,
|
|
68
104
|
isSearch: !1,
|
|
69
|
-
belowList:
|
|
70
|
-
menuProps:
|
|
71
|
-
menuConfig:
|
|
105
|
+
belowList: w,
|
|
106
|
+
menuProps: T,
|
|
107
|
+
menuConfig: L?.menu,
|
|
72
108
|
initialFocus: -1,
|
|
73
109
|
returnFocus: !1
|
|
74
110
|
})]
|
|
75
111
|
});
|
|
76
112
|
});
|
|
77
|
-
|
|
113
|
+
b.displayName = "Autocomplete";
|
|
78
114
|
//#endregion
|
|
79
|
-
export {
|
|
115
|
+
export { b as Autocomplete };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete-config.d.ts","sourceRoot":"","sources":["../../../src/components/autocomplete/autocomplete-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"autocomplete-config.d.ts","sourceRoot":"","sources":["../../../src/components/autocomplete/autocomplete-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,WAAW,kBAAmB,SAAQ,WAAW;IACrD;;;OAGG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,EAAE,kBAEvC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;CAE/B,CAAC;AAEX,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,2BAA2B;QACnC,YAAY,EAAE,kBAAkB,CAAC;KAClC;CACF"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { ElementType, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { AvatarConfig } from './avatar-config';
|
|
3
|
+
type BaseAvatarProps = AvatarConfig & Omit<HTMLAttributes<HTMLDivElement>, "color" | "children">;
|
|
4
|
+
/**
|
|
5
|
+
* Configuration options for the Avatar component.
|
|
6
|
+
*/
|
|
7
|
+
export interface AvatarProps extends BaseAvatarProps {
|
|
8
|
+
/**
|
|
9
|
+
* Name of the represented entity.
|
|
10
|
+
* Supplies the initials the avatar falls back to and, unless `alt` overrides
|
|
11
|
+
* it, the name assistive technology reads.
|
|
12
|
+
*/
|
|
13
|
+
name?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Picture of the represented entity.
|
|
16
|
+
* When it is missing or fails to load, the avatar shows its fallback.
|
|
17
|
+
*/
|
|
18
|
+
src?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Name assistive technology reads, instead of `name`.
|
|
21
|
+
* Use it when the entity's name is not the wording the avatar should carry.
|
|
22
|
+
*/
|
|
23
|
+
alt?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Component that replaces the picture inside the avatar, passed to
|
|
26
|
+
* {@link Image}. This is how a consumer keeps a framework image working
|
|
27
|
+
* inside an avatar.
|
|
28
|
+
*/
|
|
29
|
+
component?: ElementType;
|
|
30
|
+
/**
|
|
31
|
+
* Additional props for that component, passed to {@link Image}.
|
|
32
|
+
*/
|
|
33
|
+
componentProps?: Record<string, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Content shown in place of the initials when there is no picture.
|
|
36
|
+
*/
|
|
37
|
+
fallback?: ReactNode;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* An entity representation with an initials fallback.
|
|
41
|
+
*
|
|
42
|
+
* Avatar shows the picture of a person or an entity, and falls back to that
|
|
43
|
+
* entity's initials when there is no picture or the picture fails to load. The
|
|
44
|
+
* fallback sits on the accent surface of the resolved colour, and the picture
|
|
45
|
+
* is rendered through the framework's {@link Image} primitive, so a consumer
|
|
46
|
+
* keeps its own image component by passing `component`.
|
|
47
|
+
*
|
|
48
|
+
* The avatar carries the entity's name as a single image role with a label, so
|
|
49
|
+
* assistive technology reads one name instead of the initials and the picture
|
|
50
|
+
* separately. With neither a name nor an alternative given, the avatar is
|
|
51
|
+
* decoration and is hidden from assistive technology: that is the right
|
|
52
|
+
* behaviour for a purely decorative picture beside text that already names the
|
|
53
|
+
* entity.
|
|
54
|
+
*
|
|
55
|
+
* Diameter, radius and colour resolve through the standard AsheeUI cascade:
|
|
56
|
+
* prop, component config, global theme defaults, and the built-in fallback.
|
|
57
|
+
*
|
|
58
|
+
* @param props - Avatar configuration options and div attributes.
|
|
59
|
+
* @param props.name - The represented entity's name.
|
|
60
|
+
* @param props.src - The picture's source.
|
|
61
|
+
* @param props.alt - Name for assistive technology, instead of `name`.
|
|
62
|
+
* @param props.component - Custom image component, passed to `Image`.
|
|
63
|
+
* @param props.componentProps - Additional props for that component.
|
|
64
|
+
* @param props.fallback - Content shown when there is no picture.
|
|
65
|
+
* @param props.size - Diameter scale. Defaults to "md".
|
|
66
|
+
* @param props.radius - Corner rounding. Defaults to "full".
|
|
67
|
+
* @param props.color - Accent colour of the fallback surface.
|
|
68
|
+
* @param props.className - Extra classes applied last, which is where a
|
|
69
|
+
* consumer overrides the diameter.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```tsx
|
|
73
|
+
* <Avatar name="Ada Lovelace" src="/ada.png" />
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```tsx
|
|
78
|
+
* // No picture: the initials carry the identity.
|
|
79
|
+
* <Avatar name="Ada Lovelace" size="lg" />
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @see AvatarConfig - The configuration type for component defaults.
|
|
83
|
+
* @see Image - The framework's image primitive.
|
|
84
|
+
*/
|
|
85
|
+
export declare const Avatar: import('react').ForwardRefExoticComponent<AvatarProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
86
|
+
export {};
|
|
87
|
+
//# sourceMappingURL=Avatar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../../src/components/avatar/Avatar.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,cAAc,EACnB,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AAOf,OAAO,EACL,KAAK,YAAY,EAElB,MAAM,iBAAiB,CAAC;AASzB,KAAK,eAAe,GAAG,YAAY,GACjC,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,SAAS,CAAC,EAAE,WAAW,CAAC;IAExB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEzC;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,MAAM,wGAsGlB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn as e } from "../../utils/cn.js";
|
|
4
|
+
import { RADIUS_CLASS as t } from "../../shared/radius.js";
|
|
5
|
+
import { resolveVariantClass as n } from "../../shared/variant.js";
|
|
6
|
+
import { useAsheeConfig as r } from "../../libs/context.js";
|
|
7
|
+
import { resolveCascade as i, resolveClassKey as a } from "../../utils/resolve-token.js";
|
|
8
|
+
import { Image as o } from "../image/Image.js";
|
|
9
|
+
import { FALLBACK_AVATAR_CONFIG as s } from "./avatar-config.js";
|
|
10
|
+
import { AVATAR_BASE_CLASS as c, AVATAR_FALLBACK_VARIANT as l, AVATAR_FONT_CLASS as u, AVATAR_SIZE_CLASS as d } from "./avatar-styles.js";
|
|
11
|
+
import { getInitials as f } from "./avatar.helpers.js";
|
|
12
|
+
import { forwardRef as p, useState as m } from "react";
|
|
13
|
+
import { jsx as h } from "react/jsx-runtime";
|
|
14
|
+
//#region src/components/avatar/Avatar.tsx
|
|
15
|
+
var g = p(({ name: p, src: g, alt: _, component: v, componentProps: y, fallback: b, size: x, radius: S, color: C, className: w, ...T }, E) => {
|
|
16
|
+
let D = r(), O = D.components?.avatar, [k, A] = m(!1), j = i(x, O?.size, void 0, s.size), M = i(S, O?.radius, D.defaultRadius, s.radius), N = i(C, O?.color, D.defaultColor, s.color), P = a(j, d, s.size), F = a(j, u, s.size), I = a(M, t, s.radius), L = _ ?? p, R = !!g && !k;
|
|
17
|
+
return /* @__PURE__ */ h("div", {
|
|
18
|
+
ref: E,
|
|
19
|
+
role: "img",
|
|
20
|
+
"aria-label": L,
|
|
21
|
+
"aria-hidden": !L || void 0,
|
|
22
|
+
className: e(c, P, I, w),
|
|
23
|
+
...T,
|
|
24
|
+
children: R ? /* @__PURE__ */ h(o, {
|
|
25
|
+
src: g,
|
|
26
|
+
alt: "",
|
|
27
|
+
component: v,
|
|
28
|
+
componentProps: y,
|
|
29
|
+
fit: "cover",
|
|
30
|
+
radius: M,
|
|
31
|
+
showSkeleton: !1,
|
|
32
|
+
onError: () => A(!0),
|
|
33
|
+
className: "size-full"
|
|
34
|
+
}) : /* @__PURE__ */ h("span", {
|
|
35
|
+
"aria-hidden": "true",
|
|
36
|
+
className: e("inline-flex items-center justify-center size-full", F, n(l, N)),
|
|
37
|
+
children: b ?? f(p ?? "")
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
g.displayName = "Avatar";
|
|
42
|
+
//#endregion
|
|
43
|
+
export { g as Avatar };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Color, Radius, Size } from '../../shared';
|
|
2
|
+
/**
|
|
3
|
+
* Theme configuration options for the Avatar component.
|
|
4
|
+
*
|
|
5
|
+
* Set under `components.avatar` in the AsheeUI config. Values feed the
|
|
6
|
+
* component-level fallback tier of the theme cascade.
|
|
7
|
+
*/
|
|
8
|
+
export interface AvatarConfig {
|
|
9
|
+
/**
|
|
10
|
+
* Diameter scale of the avatar.
|
|
11
|
+
*
|
|
12
|
+
* @default "md"
|
|
13
|
+
*/
|
|
14
|
+
size?: Size;
|
|
15
|
+
/**
|
|
16
|
+
* Corner rounding.
|
|
17
|
+
* The default makes a circular avatar; a smaller radius makes it square.
|
|
18
|
+
*
|
|
19
|
+
* @default "full"
|
|
20
|
+
*/
|
|
21
|
+
radius?: Radius;
|
|
22
|
+
/**
|
|
23
|
+
* Theme accent colour.
|
|
24
|
+
* Colours the surface the initials fall back to. It does not tint the image.
|
|
25
|
+
*
|
|
26
|
+
* @default "primary"
|
|
27
|
+
*/
|
|
28
|
+
color?: Color;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Default config values registered for the Avatar component.
|
|
32
|
+
*
|
|
33
|
+
* `color` is intentionally absent so it inherits from the global
|
|
34
|
+
* `defaultColor`.
|
|
35
|
+
*/
|
|
36
|
+
export declare const defaultAvatarConfig: AvatarConfig;
|
|
37
|
+
/**
|
|
38
|
+
* Hard fallback values used when no config tier provides a value.
|
|
39
|
+
* These values are used when instance props, component config,
|
|
40
|
+
* and global defaults are all undefined.
|
|
41
|
+
*/
|
|
42
|
+
export declare const FALLBACK_AVATAR_CONFIG: Required<AvatarConfig>;
|
|
43
|
+
declare module "../../libs/registry" {
|
|
44
|
+
interface ComponentTypeConfigRegistry {
|
|
45
|
+
avatar: AvatarConfig;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=avatar-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avatar-config.d.ts","sourceRoot":"","sources":["../../../src/components/avatar/avatar-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAExD;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,IAAI,CAAC,EAAE,IAAI,CAAC;IAEZ;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,YAGjC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,YAAY,CAIhD,CAAC;AAEX,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,2BAA2B;QACnC,MAAM,EAAE,YAAY,CAAC;KACtB;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { registerComponentDefaults as e } from "../../libs/registry.js";
|
|
3
|
+
//#region src/components/avatar/avatar-config.ts
|
|
4
|
+
var t = {
|
|
5
|
+
size: "md",
|
|
6
|
+
radius: "full"
|
|
7
|
+
}, n = {
|
|
8
|
+
size: "md",
|
|
9
|
+
radius: "full",
|
|
10
|
+
color: "primary"
|
|
11
|
+
};
|
|
12
|
+
e("avatar", t);
|
|
13
|
+
//#endregion
|
|
14
|
+
export { n as FALLBACK_AVATAR_CONFIG, t as defaultAvatarConfig };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Size, Variant } from '../../shared';
|
|
2
|
+
/**
|
|
3
|
+
* CSS classes for the avatar's diameter based on size.
|
|
4
|
+
*/
|
|
5
|
+
export declare const AVATAR_SIZE_CLASS: Record<Size, string>;
|
|
6
|
+
/**
|
|
7
|
+
* CSS classes for the initials' font size based on size.
|
|
8
|
+
*/
|
|
9
|
+
export declare const AVATAR_FONT_CLASS: Record<Size, string>;
|
|
10
|
+
/**
|
|
11
|
+
* Base classes for the avatar frame.
|
|
12
|
+
* The frame clips the picture to the resolved radius and centres a fallback.
|
|
13
|
+
*/
|
|
14
|
+
export declare const AVATAR_BASE_CLASS = "relative inline-flex items-center justify-center shrink-0 overflow-hidden select-none font-medium uppercase";
|
|
15
|
+
/**
|
|
16
|
+
* The variant the initials fall back to.
|
|
17
|
+
* An avatar shows an entity, so its fallback is a filled accent surface rather
|
|
18
|
+
* than an outline or a tint.
|
|
19
|
+
*/
|
|
20
|
+
export declare const AVATAR_FALLBACK_VARIANT: Variant;
|
|
21
|
+
//# sourceMappingURL=avatar-styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avatar-styles.d.ts","sourceRoot":"","sources":["../../../src/components/avatar/avatar-styles.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAIlD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAIlD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,gHACiF,CAAC;AAEhH;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,OAAiB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
//#region src/components/avatar/avatar-styles.ts
|
|
3
|
+
var e = {
|
|
4
|
+
sm: "size-8",
|
|
5
|
+
md: "size-10",
|
|
6
|
+
lg: "size-12"
|
|
7
|
+
}, t = {
|
|
8
|
+
sm: "text-xs",
|
|
9
|
+
md: "text-sm",
|
|
10
|
+
lg: "text-base"
|
|
11
|
+
}, n = "relative inline-flex items-center justify-center shrink-0 overflow-hidden select-none font-medium uppercase", r = "solid";
|
|
12
|
+
//#endregion
|
|
13
|
+
export { n as AVATAR_BASE_CLASS, r as AVATAR_FALLBACK_VARIANT, t as AVATAR_FONT_CLASS, e as AVATAR_SIZE_CLASS };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Avatar helpers for AsheeUI.
|
|
3
|
+
* This file provides the small pure helpers the Avatar component needs, kept
|
|
4
|
+
* apart from the component so they can be reasoned about and tested on their
|
|
5
|
+
* own.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Derives the initials shown when an avatar has no picture.
|
|
9
|
+
*
|
|
10
|
+
* A single word contributes its first two characters, and a longer name
|
|
11
|
+
* contributes the first character of its first and last word, which is what
|
|
12
|
+
* identifies a person in most name orders.
|
|
13
|
+
*
|
|
14
|
+
* @param name - The represented entity's name.
|
|
15
|
+
* @returns One or two uppercase characters, or an empty string when there is
|
|
16
|
+
* nothing to derive them from.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getInitials(name: string): string;
|
|
19
|
+
//# sourceMappingURL=avatar.helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avatar.helpers.d.ts","sourceRoot":"","sources":["../../../src/components/avatar/avatar.helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAUhD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
//#region src/components/avatar/avatar.helpers.ts
|
|
3
|
+
function e(e) {
|
|
4
|
+
let t = e.trim().split(/\s+/).filter(Boolean);
|
|
5
|
+
if (t.length === 0) return "";
|
|
6
|
+
if (t.length === 1) return t[0].slice(0, 2).toUpperCase();
|
|
7
|
+
let n = t[0], r = t[t.length - 1];
|
|
8
|
+
return `${n[0]}${r[0]}`.toUpperCase();
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { e as getInitials };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/avatar/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { BadgeConfig } from './badge-config';
|
|
3
|
+
type BaseBadgeProps = BadgeConfig & Omit<HTMLAttributes<HTMLSpanElement>, "color" | "content">;
|
|
4
|
+
/**
|
|
5
|
+
* Configuration options for the Badge component.
|
|
6
|
+
*/
|
|
7
|
+
export interface BadgeProps extends BaseBadgeProps {
|
|
8
|
+
/**
|
|
9
|
+
* Badge content.
|
|
10
|
+
* Typically a short piece of text. Omit it when the badge shows only an icon
|
|
11
|
+
* and pass `label` instead so the badge still has an accessible name.
|
|
12
|
+
*/
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* Text that stands in for the badge's content.
|
|
16
|
+
* Use it when the badge shows only an icon: the text is rendered for
|
|
17
|
+
* assistive technology and the visible content is treated as decoration. A
|
|
18
|
+
* badge with visible text does not need it, because its text is its content.
|
|
19
|
+
*/
|
|
20
|
+
label?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Content rendered before the badge text, typically an icon.
|
|
23
|
+
*/
|
|
24
|
+
startContent?: ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Content rendered after the badge text, typically an icon.
|
|
27
|
+
*/
|
|
28
|
+
endContent?: ReactNode;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A compact status or label indicator.
|
|
32
|
+
*
|
|
33
|
+
* Badge renders an inline, non-interactive element for short pieces of status
|
|
34
|
+
* or category information. Its colour, variant, size, and radius resolve
|
|
35
|
+
* through the standard AsheeUI cascade: prop, component config, global theme
|
|
36
|
+
* defaults, and the built-in fallback. It is decorative in the sense that it
|
|
37
|
+
* carries no interaction of its own: pointer events, focus, and keyboard
|
|
38
|
+
* behaviour belong to whatever it is placed inside.
|
|
39
|
+
*
|
|
40
|
+
* Consumer `className` is appended last, so it can restyle or reposition the
|
|
41
|
+
* badge without fighting the framework's classes.
|
|
42
|
+
*
|
|
43
|
+
* @param props - Badge configuration options and span attributes.
|
|
44
|
+
* @param props.children - Badge text or content.
|
|
45
|
+
* @param props.label - Text that stands in for the content of an icon-only badge.
|
|
46
|
+
* @param props.variant - Visual style variant. Defaults to the configured value.
|
|
47
|
+
* @param props.color - Theme accent colour. Defaults to the configured value.
|
|
48
|
+
* @param props.size - Density scale. Defaults to "md".
|
|
49
|
+
* @param props.radius - Corner rounding. Defaults to "full".
|
|
50
|
+
* @param props.startContent - Content rendered before the badge text.
|
|
51
|
+
* @param props.endContent - Content rendered after the badge text.
|
|
52
|
+
* @param props.className - Extra classes applied last.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```tsx
|
|
56
|
+
* <Badge color="success">Active</Badge>
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* // Icon only: the label is the badge's accessible name.
|
|
62
|
+
* <Badge label="Active" startContent={<CheckIcon />} />
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @see BadgeConfig - The configuration type for component defaults.
|
|
66
|
+
*/
|
|
67
|
+
export declare const Badge: import('react').ForwardRefExoticComponent<BadgeProps & import('react').RefAttributes<HTMLSpanElement>>;
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=Badge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../../src/components/badge/Badge.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAiBf,OAAO,EACL,KAAK,WAAW,EAGjB,MAAM,gBAAgB,CAAC;AAExB,KAAK,cAAc,GAAG,WAAW,GAC/B,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,UAAW,SAAQ,cAAc;IAChD;;;;OAIG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC;IAEzB;;OAEG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,KAAK,wGA+HjB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn as e } from "../../utils/cn.js";
|
|
4
|
+
import { RADIUS_CLASS as t } from "../../shared/radius.js";
|
|
5
|
+
import { resolveVariantClass as n } from "../../shared/variant.js";
|
|
6
|
+
import { useAsheeConfig as r } from "../../libs/context.js";
|
|
7
|
+
import { resolveCascade as i, resolveClassKey as a, resolveRadiusKey as o } from "../../utils/resolve-token.js";
|
|
8
|
+
import { BADGE_FONT_CLASS as s, BADGE_GAP_CLASS as c, BADGE_HEIGHT_CLASS as l, BADGE_ICON_SIZE_CLASS as u, BADGE_PADDING_CLASS as d } from "./badge-styles.js";
|
|
9
|
+
import { FALLBACK_BADGE_CONFIG as f } from "./badge-config.js";
|
|
10
|
+
import { forwardRef as p } from "react";
|
|
11
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
12
|
+
//#region src/components/badge/Badge.tsx
|
|
13
|
+
var _ = p(({ variant: p, color: _, size: v, radius: y, label: b, children: x, startContent: S, endContent: C, className: w, ...T }, E) => {
|
|
14
|
+
let D = r(), O = D.components?.badge, k = i(p, O?.variant, D.defaultVariant, f.variant), A = k === "underlined" ? "bordered" : k, j = i(_, O?.color, D.defaultColor, f.color), M = i(v, O?.size, void 0, f.size), N = o(y, O?.radius, D.defaultRadius, f.radius), P = a(M, l, f.size), F = a(M, d, f.size), I = a(M, s, f.size), L = a(M, c, f.size), R = a(M, u, f.size), z = a(N, t, f.radius);
|
|
15
|
+
return /* @__PURE__ */ h("span", {
|
|
16
|
+
ref: E,
|
|
17
|
+
className: e("inline-flex items-center justify-center shrink-0 whitespace-nowrap font-medium select-none", P, F, I, L, R, z, n(A, j), w),
|
|
18
|
+
...T,
|
|
19
|
+
children: b ? /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("span", {
|
|
20
|
+
className: "sr-only",
|
|
21
|
+
children: b
|
|
22
|
+
}), /* @__PURE__ */ g("span", {
|
|
23
|
+
"aria-hidden": "true",
|
|
24
|
+
className: e("inline-flex items-center", L),
|
|
25
|
+
children: [
|
|
26
|
+
S,
|
|
27
|
+
x,
|
|
28
|
+
C
|
|
29
|
+
]
|
|
30
|
+
})] }) : /* @__PURE__ */ g(m, { children: [
|
|
31
|
+
S,
|
|
32
|
+
x,
|
|
33
|
+
C
|
|
34
|
+
] })
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
_.displayName = "Badge";
|
|
38
|
+
//#endregion
|
|
39
|
+
export { _ as Badge };
|