@manakind/ui-core 0.18.0 → 0.19.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/README.md CHANGED
@@ -58,6 +58,7 @@ separately, so an app can load only what it renders.
58
58
  |---|---|
59
59
  | `@manakind/ui-core` | Everything below, plus every prop type, the `cx` helper, and the built-in fallback glyphs (`FallbackChevronLeft`, `FallbackChevronRight`, `FallbackCheck`, `FallbackCross`) for compositions that want the same defaults |
60
60
  | `@manakind/ui-core/alert` | `Alert` |
61
+ | `@manakind/ui-core/avatar` | `Avatar` + `initialsOf` |
61
62
  | `@manakind/ui-core/badge` | `Badge` |
62
63
  | `@manakind/ui-core/button` | `Button` + `IconButton` |
63
64
  | `@manakind/ui-core/calendar` | `Calendar` |
@@ -65,7 +66,7 @@ separately, so an app can load only what it renders.
65
66
  | `@manakind/ui-core/dialog` | `Dialog` + `DialogClose` |
66
67
  | `@manakind/ui-core/icon` | `Icon` |
67
68
  | `@manakind/ui-core/illustration` | `Illustration` + `illustrationPaint` |
68
- | `@manakind/ui-core/menu` | `Menu`, `MenuTrigger` |
69
+ | `@manakind/ui-core/menu` | `Menu`, `MenuTrigger`, `ActionMenu` |
69
70
  | `@manakind/ui-core/popover` | `Popover` |
70
71
  | `@manakind/ui-core/checkbox` | `Checkbox` |
71
72
  | `@manakind/ui-core/combobox` | `Combobox` |
@@ -78,6 +79,7 @@ separately, so an app can load only what it renders.
78
79
  | `@manakind/ui-core/field` | `Field`, `Input`, `Textarea`, `useFieldControl` |
79
80
  | `@manakind/ui-core/tabs` | `Tabs`, `TabsList`, `TabsTrigger`, `TabsContent` |
80
81
  | `@manakind/ui-core/css/alert` | Alert structural CSS; its icon also needs `css/icon` |
82
+ | `@manakind/ui-core/css/avatar` | Avatar structural CSS; its fallback glyph also needs `css/icon` |
81
83
  | `@manakind/ui-core/css/badge` | Badge structural CSS |
82
84
  | `@manakind/ui-core/css/button` | Button + IconButton structural CSS |
83
85
  | `@manakind/ui-core/css/calendar` | Calendar structural CSS; its paging buttons also need `css/button` and `css/icon` |
@@ -85,7 +87,7 @@ separately, so an app can load only what it renders.
85
87
  | `@manakind/ui-core/css/dialog` | Dialog structural CSS; its close button also needs `css/button` and `css/icon` |
86
88
  | `@manakind/ui-core/css/icon` | Icon structural CSS |
87
89
  | `@manakind/ui-core/css/illustration` | Illustration structural CSS, including the paint roles |
88
- | `@manakind/ui-core/css/menu` | Menu structural CSS |
90
+ | `@manakind/ui-core/css/menu` | Menu and ActionMenu structural CSS; an ActionMenu's glyphs also need `css/icon` |
89
91
  | `@manakind/ui-core/css/popover` | Popover structural CSS |
90
92
  | `@manakind/ui-core/css/checkbox` | Checkbox structural CSS |
91
93
  | `@manakind/ui-core/css/combobox` | Combobox structural CSS |
@@ -0,0 +1,42 @@
1
+ @layer components {
2
+ .ds-avatar {
3
+ /*
4
+ * Explicit, as Badge's is: the size keys measure the whole disc, border
5
+ * included, or the border stacks on top and the disc outgrows its token.
6
+ */
7
+ box-sizing: border-box;
8
+ display: inline-flex;
9
+ align-items: center;
10
+ justify-content: center;
11
+ /*
12
+ * A disc beside a name in a flex row. It never gives: a long name wraps
13
+ * or truncates on its own terms, and the disc keeps its diameter.
14
+ */
15
+ flex-shrink: 0;
16
+ inline-size: var(--ds-avatar-size-md);
17
+ block-size: var(--ds-avatar-size-md);
18
+ border: 1px solid var(--ds-avatar-border);
19
+ border-radius: var(--ds-avatar-radius);
20
+ background-color: var(--ds-avatar-bg);
21
+ color: var(--ds-avatar-text);
22
+ font-size: var(--ds-avatar-font-size-md);
23
+ font-weight: var(--ds-avatar-font-weight);
24
+ line-height: inherit;
25
+ /* Two letters, never a word: nothing here can wrap, so the box clips instead. */
26
+ overflow: hidden;
27
+ overflow-wrap: anywhere;
28
+ user-select: none;
29
+
30
+ &.ds-avatar--sm {
31
+ inline-size: var(--ds-avatar-size-sm);
32
+ block-size: var(--ds-avatar-size-sm);
33
+ font-size: var(--ds-avatar-font-size-sm);
34
+ }
35
+
36
+ &.ds-avatar--lg {
37
+ inline-size: var(--ds-avatar-size-lg);
38
+ block-size: var(--ds-avatar-size-lg);
39
+ font-size: var(--ds-avatar-font-size-lg);
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,2 @@
1
+ /* AUTOGENERATED: types for the stylesheet beside it. */
2
+ export {};
@@ -0,0 +1,55 @@
1
+ import type { ComponentProps } from 'react';
2
+ import { type IconSource } from '../icon/icon';
3
+ import './avatar.css';
4
+ export type AvatarSize = 'sm' | 'md' | 'lg';
5
+ /**
6
+ * An avatar beside the name it stands for is decorative; one standing alone,
7
+ * such as the content of a menu trigger whose button has no name of its
8
+ * own, needs a label. The pairing is a compile error rather than a
9
+ * convention, mirroring `IconProps`.
10
+ */
11
+ type AvatarA11y = {
12
+ label: string;
13
+ decorative?: never;
14
+ } | {
15
+ decorative: true;
16
+ label?: never;
17
+ };
18
+ export type AvatarProps = Omit<ComponentProps<'span'>, 'children' | 'aria-label' | 'aria-hidden' | 'role'> & AvatarA11y & {
19
+ /**
20
+ * The person's name. The avatar shows its initials: the first letter of
21
+ * the first and last words, or the first two letters of a single word.
22
+ */
23
+ name: string;
24
+ /**
25
+ * Glyph shown when the name yields no initials, such as a person glyph for
26
+ * an account without a name. Decorative; without it the avatar is a bare
27
+ * disc.
28
+ */
29
+ icon?: IconSource;
30
+ /** `sm` fits a toolbar, `md` a row, `lg` a profile heading. */
31
+ size?: AvatarSize;
32
+ };
33
+ /**
34
+ * The letters an `Avatar` shows for a name: the first letter of the first
35
+ * and last words ("Pål Taule Brentebråten" → "PB"), the first two letters of
36
+ * a single word ("Manuia" → "MA"), nothing for an empty name. Upper-cased
37
+ * with the runtime's locale rules, so an initial that changes case by
38
+ * length comes out right.
39
+ */
40
+ export declare function initialsOf(name: string): string;
41
+ /**
42
+ * A person, as initials in a disc.
43
+ *
44
+ * Renders a `span`. Labelled, it is `role="img"` named by `label`; decorative,
45
+ * it is hidden from assistive technology and the text beside it carries the
46
+ * name. The look comes from the `--ds-avatar-*` keys.
47
+ *
48
+ * ```tsx
49
+ * <Avatar name={user.name} icon={PersonGlyph} decorative />
50
+ * <span>{user.name}</span>
51
+ * ```
52
+ */
53
+ export declare function Avatar({ name, icon, size, label, decorative, className, ...props }: AvatarProps): import("react/jsx-runtime").JSX.Element;
54
+ export {};
55
+ //# sourceMappingURL=avatar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"avatar.d.ts","sourceRoot":"","sources":["../../src/avatar/avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,cAAc,CAAC;AAEtB,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C;;;;;GAKG;AACH,KAAK,UAAU,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,UAAU,EAAE,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAE9F,MAAM,MAAM,WAAW,GAAG,IAAI,CAC5B,cAAc,CAAC,MAAM,CAAC,EACtB,UAAU,GAAG,YAAY,GAAG,aAAa,GAAG,MAAM,CACnD,GACC,UAAU,GAAG;IACX;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,CAAC;AAEJ;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAU/C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,EACrB,IAAI,EACJ,IAAI,EACJ,IAAW,EACX,KAAK,EACL,UAAU,EACV,SAAS,EACT,GAAG,KAAK,EACT,EAAE,WAAW,2CAUb"}
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cx } from '../cx';
3
+ import { Icon } from '../icon/icon';
4
+ import './avatar.css';
5
+ /**
6
+ * The letters an `Avatar` shows for a name: the first letter of the first
7
+ * and last words ("Pål Taule Brentebråten" → "PB"), the first two letters of
8
+ * a single word ("Manuia" → "MA"), nothing for an empty name. Upper-cased
9
+ * with the runtime's locale rules, so an initial that changes case by
10
+ * length comes out right.
11
+ */
12
+ export function initialsOf(name) {
13
+ const words = name.trim().split(/\s+/).filter(Boolean);
14
+ const first = words[0];
15
+ if (first === undefined)
16
+ return '';
17
+ const last = words.length > 1 ? words[words.length - 1] : undefined;
18
+ const letters = last === undefined
19
+ ? Array.from(first).slice(0, 2)
20
+ : [Array.from(first)[0], Array.from(last)[0]];
21
+ return letters.join('').toLocaleUpperCase();
22
+ }
23
+ /**
24
+ * A person, as initials in a disc.
25
+ *
26
+ * Renders a `span`. Labelled, it is `role="img"` named by `label`; decorative,
27
+ * it is hidden from assistive technology and the text beside it carries the
28
+ * name. The look comes from the `--ds-avatar-*` keys.
29
+ *
30
+ * ```tsx
31
+ * <Avatar name={user.name} icon={PersonGlyph} decorative />
32
+ * <span>{user.name}</span>
33
+ * ```
34
+ */
35
+ export function Avatar({ name, icon, size = 'md', label, decorative, className, ...props }) {
36
+ const initials = initialsOf(name);
37
+ const fallback = icon ? _jsx(Icon, { source: icon, size: size, decorative: true }) : null;
38
+ const a11y = decorative ? { 'aria-hidden': true } : { role: 'img', 'aria-label': label };
39
+ return (_jsx("span", { className: cx('ds-avatar', `ds-avatar--${size}`, className), ...a11y, ...props, children: initials || fallback }));
40
+ }
41
+ //# sourceMappingURL=avatar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"avatar.js","sourceRoot":"","sources":["../../src/avatar/avatar.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3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AI,CAAC;IAC7E,MAAM,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;IAEzF,OAAO,CACL,eAAM,SAAS,EAAE,EAAE,CAAC,WAAW,EAAE,cAAc,IAAI,EAAE,EAAE,SAAS,CAAC,KAAM,IAAI,KAAM,KAAK,YACnF,QAAQ,IAAI,QAAQ,GAChB,CACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export type { AvatarProps, AvatarSize } from './avatar';
2
+ export { Avatar, initialsOf } from './avatar';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/avatar/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { Avatar, initialsOf } from './avatar';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/avatar/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './alert';
2
+ export * from './avatar';
2
3
  export * from './badge';
3
4
  export * from './button';
4
5
  export * from './calendar';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC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c,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './alert';
2
+ export * from './avatar';
2
3
  export * from './badge';
3
4
  export * from './button';
4
5
  export * from './calendar';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,KAAK,IAAI,aAAa,EACtB,WAAW,IAAI,mBAAmB,EAClC,YAAY,IAAI,oBAAoB,EACpC,KAAK,IAAI,aAAa,GACvB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,KAAK,IAAI,aAAa,EACtB,WAAW,IAAI,mBAAmB,EAClC,YAAY,IAAI,oBAAoB,EACpC,KAAK,IAAI,aAAa,GACvB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,120 @@
1
+ import { type ElementType, type ReactElement, type ReactNode } from 'react';
2
+ import { type IconSource } from '../icon/icon';
3
+ import './menu.css';
4
+ export interface ActionMenuItem {
5
+ /** Stable value reported by `onSelect`. */
6
+ value: string;
7
+ /** Text shown in the menu. Also what typeahead matches against. */
8
+ label: string;
9
+ /** Glyph before the label. Decorative: the label says what the item does. */
10
+ icon?: IconSource;
11
+ /**
12
+ * Makes the item a link to this address, rendered through `linkComponent`.
13
+ * Choosing it follows the link, with the keyboard too; `onSelect` still
14
+ * reports its value.
15
+ */
16
+ href?: string;
17
+ /**
18
+ * Marks the link to the page the user is on: `aria-current="page"`, and
19
+ * the `itemIndicator` glyph after the label so the mark is not colour alone.
20
+ */
21
+ current?: boolean;
22
+ /** Individually disable this item without removing it. */
23
+ disabled?: boolean;
24
+ /**
25
+ * Whether choosing the item closes the menu. Defaults to `true`. Keep an
26
+ * item open when its outcome shows in the `footer`, so a failure appears
27
+ * where the click happened.
28
+ */
29
+ closeOnSelect?: boolean;
30
+ }
31
+ /**
32
+ * The props a `linkComponent` receives. A plain `'a'` and a router's link
33
+ * component both accept them; Ark adds the menu item's role, id, state
34
+ * attributes and handlers on top, so the component must pass unknown props
35
+ * and its `ref` on to the anchor it renders.
36
+ */
37
+ export interface ActionMenuLinkProps {
38
+ href: string;
39
+ className?: string;
40
+ children?: ReactNode;
41
+ 'aria-current'?: 'page';
42
+ }
43
+ export interface ActionMenuProps {
44
+ /**
45
+ * The element that opens the menu: a `<button>`, or a component that
46
+ * passes its props and `ref` on to one, such as `IconButton` or
47
+ * `MenuTrigger`. Ark renders it as the trigger, adding `aria-haspopup`,
48
+ * `aria-expanded`, `aria-controls`, the open and close handlers and
49
+ * `data-state`. Give it an accessible name that says what the menu holds,
50
+ * such as "Account menu" or "Main navigation": the menu takes its name
51
+ * from the trigger.
52
+ */
53
+ trigger: ReactElement;
54
+ /** The actions and links, in order. */
55
+ items: ActionMenuItem[];
56
+ /** Fired with the item's `value` when one is chosen, a link included. */
57
+ onSelect?: (value: string) => void;
58
+ /**
59
+ * Content above the items that says whose menu this is, such as the
60
+ * signed-in user's name and email. It names the group of items for
61
+ * assistive technology, so keep it to text and decorative elements.
62
+ */
63
+ header?: ReactNode;
64
+ /**
65
+ * A line under the items about the last action, such as "Couldn't sign
66
+ * out. Check your connection, then try again." It is announced when it
67
+ * appears, and a press on it leaves the menu open. It is not an item and
68
+ * sits beside the `menu` element, which may own only items, so keep it to
69
+ * text and a decorative glyph rather than an `Alert`.
70
+ */
71
+ footer?: ReactNode;
72
+ /**
73
+ * Renders an item with an `href`. Defaults to `'a'`; pass a router's link
74
+ * component for client-side navigation.
75
+ */
76
+ linkComponent?: ElementType<ActionMenuLinkProps>;
77
+ /**
78
+ * Glyph marking the `current` link. Defaults to a plain built-in check so
79
+ * `@manakind/ui-core` renders on its own; products pass their own icon.
80
+ */
81
+ itemIndicator?: IconSource;
82
+ /** Controlled open state. Pair with `onOpenChange`. */
83
+ open?: boolean;
84
+ /** Fired with the requested state whenever the menu asks to open or close. */
85
+ onOpenChange?: (open: boolean) => void;
86
+ /** Extra class names on the menu's popup: the frame around the items and the footer. */
87
+ className?: string;
88
+ }
89
+ /**
90
+ * A menu of actions and links, opened from a trigger, built on Ark UI's
91
+ * Menu. The counterpart of `Menu`, whose items are mutually exclusive
92
+ * choices: here every item does something or goes somewhere.
93
+ *
94
+ * Ark owns the hard parts: `menu` / `menuitem` semantics, roving highlight
95
+ * with the arrow keys, Home/End, typeahead, Escape and click outside to
96
+ * dismiss, following a link on Enter, and focus returning to the trigger on
97
+ * close. This wrapper contributes the `ds-menu` classes and `--ds-menu-*`
98
+ * bindings it shares with `Menu`, a flat `items` API, and the header and
99
+ * footer slots.
100
+ *
101
+ * ```tsx
102
+ * <ActionMenu
103
+ * trigger={<IconButton icon={MenuGlyph} variant="tertiary" aria-label="Main navigation" />}
104
+ * linkComponent={Link}
105
+ * items={[
106
+ * { value: 'dashboard', label: 'Dashboard', href: '/dashboard', current: true },
107
+ * { value: 'goals', label: 'Goals', href: '/goals' },
108
+ * ]}
109
+ * />
110
+ * ```
111
+ *
112
+ * Reach for this for an account menu, a row's overflow actions, or a
113
+ * navigation that folds into a button on a phone. A set of choices where
114
+ * exactly one is in effect is a `Menu`; a form field is a `Select`.
115
+ *
116
+ * The popup renders in a portal, at the same `z-index: 60` as Select's
117
+ * listbox, and is mounted only while open, as `Menu`'s is.
118
+ */
119
+ export declare function ActionMenu({ trigger, items, onSelect, header, footer, linkComponent, itemIndicator, open, onOpenChange, className, }: ActionMenuProps): import("react/jsx-runtime").JSX.Element;
120
+ //# sourceMappingURL=action-menu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-menu.d.ts","sourceRoot":"","sources":["../../src/menu/action-menu.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAsB,MAAM,OAAO,CAAC;AAGhG,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,YAAY,CAAC;AAEpB,MAAM,WAAW,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ACzB,OAAO,EACP,KAAK,EACL,QAAQ,EACR,MAAM,EACN,MAAM,EACN,aAAmB,EACnB,aAAqB,EACrB,IAAI,EACJ,YAAY,EACZ,SAAS,GACV,EAAE,eAAe,2CAiEjB"}
@@ -0,0 +1,80 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Menu as ArkMenu } from '@ark-ui/react/menu';
3
+ import { Portal } from '@ark-ui/react/portal';
4
+ import { useContext, useRef } from 'react';
5
+ import { cx } from '../cx';
6
+ import { Check } from '../fallback-glyphs';
7
+ import { Icon } from '../icon/icon';
8
+ import { PortalContainerContext } from '../portal-container';
9
+ import './menu.css';
10
+ function ActionMenuRow({ item, linkComponent: LinkComponent, itemIndicator }) {
11
+ const body = (_jsxs(_Fragment, { children: [_jsxs("span", { className: "ds-menu__item-body", children: [item.icon && (_jsx(Icon, { source: item.icon, size: "sm", decorative: true, className: "ds-menu__item-icon" })), _jsx(ArkMenu.ItemText, { children: item.label })] }), item.current && (_jsx("span", { className: "ds-menu__item-indicator", children: _jsx(Icon, { source: itemIndicator, size: "sm", decorative: true }) }))] }));
12
+ const itemProps = {
13
+ value: item.value,
14
+ valueText: item.label,
15
+ disabled: item.disabled,
16
+ closeOnSelect: item.closeOnSelect,
17
+ className: 'ds-menu__item',
18
+ };
19
+ if (item.href === undefined) {
20
+ return _jsx(ArkMenu.Item, { ...itemProps, children: body });
21
+ }
22
+ return (_jsx(ArkMenu.Item, { ...itemProps, asChild: true, children: _jsx(LinkComponent, { href: item.href, "aria-current": item.current ? 'page' : undefined, children: body }) }));
23
+ }
24
+ /**
25
+ * A menu of actions and links, opened from a trigger, built on Ark UI's
26
+ * Menu. The counterpart of `Menu`, whose items are mutually exclusive
27
+ * choices: here every item does something or goes somewhere.
28
+ *
29
+ * Ark owns the hard parts: `menu` / `menuitem` semantics, roving highlight
30
+ * with the arrow keys, Home/End, typeahead, Escape and click outside to
31
+ * dismiss, following a link on Enter, and focus returning to the trigger on
32
+ * close. This wrapper contributes the `ds-menu` classes and `--ds-menu-*`
33
+ * bindings it shares with `Menu`, a flat `items` API, and the header and
34
+ * footer slots.
35
+ *
36
+ * ```tsx
37
+ * <ActionMenu
38
+ * trigger={<IconButton icon={MenuGlyph} variant="tertiary" aria-label="Main navigation" />}
39
+ * linkComponent={Link}
40
+ * items={[
41
+ * { value: 'dashboard', label: 'Dashboard', href: '/dashboard', current: true },
42
+ * { value: 'goals', label: 'Goals', href: '/goals' },
43
+ * ]}
44
+ * />
45
+ * ```
46
+ *
47
+ * Reach for this for an account menu, a row's overflow actions, or a
48
+ * navigation that folds into a button on a phone. A set of choices where
49
+ * exactly one is in effect is a `Menu`; a form field is a `Select`.
50
+ *
51
+ * The popup renders in a portal, at the same `z-index: 60` as Select's
52
+ * listbox, and is mounted only while open, as `Menu`'s is.
53
+ */
54
+ export function ActionMenu({ trigger, items, onSelect, header, footer, linkComponent = 'a', itemIndicator = Check, open, onOpenChange, className, }) {
55
+ const portalContainer = useContext(PortalContainerContext);
56
+ const handleSelect = (details) => onSelect?.(details.value);
57
+ const handleOpenChange = (details) => onOpenChange?.(details.open);
58
+ /*
59
+ * Enter on a link item. Zag's default dispatches a click that does not
60
+ * bubble, which the browser follows as a document load but React never
61
+ * sees, so a router's link component could not take it over. `click()`
62
+ * bubbles, and the link navigates the way a pointer click would.
63
+ */
64
+ const navigate = (details) => queueMicrotask(() => details.node.click());
65
+ /*
66
+ * The footer sits beside the `menu` element, not in it, because a menu may
67
+ * own only items. To Zag that makes it outside, so a press on the message
68
+ * would dismiss the menu; this keeps it open.
69
+ */
70
+ const footerRef = useRef(null);
71
+ const keepOpenForFooter = (event) => {
72
+ const target = event.detail.originalEvent.target;
73
+ if (target instanceof Node && footerRef.current?.contains(target))
74
+ event.preventDefault();
75
+ };
76
+ const rows = items.map((item) => (_jsx(ActionMenuRow, { item: item, linkComponent: linkComponent, itemIndicator: itemIndicator }, item.value)));
77
+ const list = header === undefined ? (rows) : (_jsxs(ArkMenu.ItemGroup, { children: [_jsx(ArkMenu.ItemGroupLabel, { className: "ds-menu__header", children: header }), rows] }));
78
+ return (_jsxs(ArkMenu.Root, { lazyMount: true, unmountOnExit: true, open: open, onOpenChange: handleOpenChange, onSelect: handleSelect, navigate: navigate, onInteractOutside: keepOpenForFooter, children: [_jsx(ArkMenu.Trigger, { asChild: true, children: trigger }), _jsx(Portal, { container: portalContainer, children: _jsx(ArkMenu.Positioner, { children: _jsxs("div", { className: cx('ds-menu__popup', className), children: [_jsx(ArkMenu.Content, { className: "ds-menu__content", children: list }), _jsx("div", { ref: footerRef, className: "ds-menu__footer", "aria-live": "polite", children: footer })] }) }) })] }));
79
+ }
80
+ //# sourceMappingURL=action-menu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-menu.js","sourceRoot":"","sources":["../../src/menu/action-menu.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAuD,UAAU,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAChG,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,YAAY,CAAC;AAgGpB,SAAS,aAAa,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAsB;IAC9F,MAAM,IAAI,GAAG,CACX,8BACE,gBAAM,SAAS,EAAC,oBAAoB,aACjC,IAAI,CAAC,IAAI,IAAI,CACZ,KAAC,IAAI,IAAC,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAC,IAAI,EAAC,UAAU,QAAC,SAA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E,iBAAiB,aAEpC,KAAC,OAAO,CAAC,OAAO,IAAC,OAAO,kBAAE,OAAO,GAAmB,EAEpD,KAAC,MAAM,IAAC,SAAS,EAAE,eAAe,YAChC,KAAC,OAAO,CAAC,UAAU,cACjB,eAAK,SAAS,EAAE,EAAE,CAAC,gBAAgB,EAAE,SAAS,CAAC,aAC7C,KAAC,OAAO,CAAC,OAAO,IAAC,SAAS,EAAC,kBAAkB,YAAE,IAAI,GAAmB,EACtE,cAAK,GAAG,EAAE,SAAS,EAAE,SAAS,EAAC,iBAAiB,eAAW,QAAQ,YAChE,MAAM,GACH,IACF,GACa,GACd,IACI,CAChB,CAAC;AACJ,CAAC"}
@@ -1,3 +1,5 @@
1
+ export type { ActionMenuItem, ActionMenuLinkProps, ActionMenuProps } from './action-menu';
2
+ export { ActionMenu } from './action-menu';
1
3
  export type { MenuItem, MenuProps, MenuTriggerProps } from './menu';
2
4
  export { Menu, MenuTrigger } from './menu';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/menu/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/menu/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC"}
@@ -1,2 +1,3 @@
1
+ export { ActionMenu } from './action-menu';
1
2
  export { Menu, MenuTrigger } from './menu';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/menu/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/menu/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC"}
@@ -54,9 +54,12 @@
54
54
 
55
55
  /*
56
56
  * The popup renders in a portal, so it is not a descendant of the trigger
57
- * in the DOM and is styled at the top level, as Select's listbox is.
57
+ * in the DOM and is styled at the top level, as Select's listbox is. It is
58
+ * the frame around the `menu` element (`.ds-menu__content`) and, for an
59
+ * ActionMenu, the footer beside it: a menu may own only items, so anything
60
+ * else in the frame is its sibling.
58
61
  */
59
- .ds-menu__content {
62
+ .ds-menu__popup {
60
63
  padding: var(--ds-menu-content-padding);
61
64
  border: 1px solid var(--ds-menu-content-border);
62
65
  border-radius: var(--ds-menu-content-radius);
@@ -72,22 +75,28 @@
72
75
  overflow-wrap: anywhere;
73
76
  /*
74
77
  * The `popup` stacking layer (ds-config/scripts/stacking.ts), as Select's
75
- * listbox: Zag copies this onto the positioner, a sibling of the page in
76
- * `<body>`, so the menu paints above the products' overlay layer and the
77
- * page content positioned under it.
78
+ * listbox: Zag copies the positioner's first child's value onto the
79
+ * positioner, a sibling of the page in `<body>`, so the menu paints above
80
+ * the products' overlay layer and the page content positioned under it.
78
81
  */
79
82
  z-index: 60;
80
83
 
81
84
  /*
82
- * Inset like Select's listbox ring: an outer ring on a portalled popup is
83
- * cropped by anything that sizes to it and can clip against the viewport.
85
+ * Keyboard focus sits on the `menu` element inside; the ring is drawn on
86
+ * the frame, inset like Select's listbox ring: an outer ring on a
87
+ * portalled popup is cropped by anything that sizes to it and can clip
88
+ * against the viewport.
84
89
  */
85
- &:focus-visible {
90
+ &:has(> .ds-menu__content:focus-visible) {
86
91
  outline: 2px solid var(--ds-menu-focus-ring);
87
92
  outline-offset: -2px;
88
93
  }
89
94
  }
90
95
 
96
+ .ds-menu__content {
97
+ outline: none;
98
+ }
99
+
91
100
  /*
92
101
  * Names the group of choices for assistive technology only. The trigger
93
102
  * already says what the menu chooses, so showing it again would repeat it.
@@ -124,6 +133,51 @@
124
133
  opacity: var(--ds-opacity-disabled);
125
134
  cursor: not-allowed;
126
135
  }
136
+
137
+ /* An ActionMenu link is an anchor with the item's role; it reads as a row, not a link. */
138
+ &:is(a) {
139
+ text-decoration: none;
140
+ }
141
+ }
142
+
143
+ /* The glyph and label of an ActionMenu item, kept together ahead of the indicator. */
144
+ .ds-menu__item-body {
145
+ display: inline-flex;
146
+ align-items: center;
147
+ gap: var(--ds-menu-item-gap);
148
+ min-width: 0;
149
+ max-width: 100%;
150
+ }
151
+
152
+ .ds-menu__item-icon {
153
+ flex-shrink: 0;
154
+ }
155
+
156
+ /*
157
+ * An ActionMenu's header names the group of items (Ark's group label), so
158
+ * it sits in the item's inset and is ruled off from the items under it.
159
+ */
160
+ .ds-menu__header {
161
+ padding: var(--ds-menu-item-padding-block) var(--ds-menu-item-padding-inline);
162
+ margin-block-end: var(--ds-menu-content-padding);
163
+ border-block-end: 1px solid var(--ds-menu-content-border);
164
+ color: var(--ds-menu-item-text);
165
+ }
166
+
167
+ /*
168
+ * A line under the items about the last action; not an item. Always in the
169
+ * DOM so that a message arriving later is announced (a live region created
170
+ * with its content is not), and taking no room while it is empty.
171
+ */
172
+ .ds-menu__footer {
173
+ margin-block-start: var(--ds-menu-content-padding);
174
+ padding: var(--ds-menu-item-padding-block) var(--ds-menu-item-padding-inline);
175
+ border-block-start: 1px solid var(--ds-menu-content-border);
176
+ color: var(--ds-menu-item-text);
177
+
178
+ &:empty {
179
+ display: none;
180
+ }
127
181
  }
128
182
 
129
183
  /*
@@ -53,7 +53,7 @@ export interface MenuProps<V extends string = string> {
53
53
  * they do Select's `itemIndicator`.
54
54
  */
55
55
  itemIndicator?: IconSource;
56
- /** Extra class names on the menu's popup. */
56
+ /** Extra class names on the menu's popup: the frame around the items. */
57
57
  className?: string;
58
58
  }
59
59
  export interface MenuTriggerProps extends Omit<ComponentProps<'button'>, 'type'> {
@@ -1 +1 @@
1
- {"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../src/menu/menu.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAA2B,MAAM,OAAO,CAAC;AAGxF,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,YAAY,CAAC;AAEpB,MAAM,WAAW,QAAQ,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACjD,0EAA0E;IAC1E,KAAK,EAAE,CAAC,CAAC;IACT,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IAClD;;;;;;;;;;OAUG;IACH,OAAO,EAAE,YAAY,CAAC;IACtB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IACrB;;;;OAIG;IACH,KAAK,EAAE,CAAC,CAAC;IACT;;;;OAIG;IACH,aAAa,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAClC;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IA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ClC;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC9E;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,UAAU,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,EAC1B,SAAwB,EACxB,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,gBAAgB,2CAOlB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,EAC9C,OAAO,EACP,KAAK,EACL,KAAK,EACL,KAAK,EACL,aAAa,EACb,aAAqB,EACrB,SAAS,GACV,EAAE,SAAS,CAAC,CAAC,CAAC,2CA+Cd"}
package/dist/menu/menu.js CHANGED
@@ -74,6 +74,6 @@ export function Menu({ trigger, label, items, value, onValueChange, itemIndicato
74
74
  onValueChange(chosen.value);
75
75
  }, [items, value, onValueChange]);
76
76
  const portalContainer = useContext(PortalContainerContext);
77
- return (_jsxs(ArkMenu.Root, { lazyMount: true, unmountOnExit: true, children: [_jsx(ArkMenu.Trigger, { asChild: true, children: trigger }), _jsx(Portal, { container: portalContainer, children: _jsx(ArkMenu.Positioner, { children: _jsx(ArkMenu.Content, { className: cx('ds-menu__content', className), children: _jsxs(ArkMenu.RadioItemGroup, { value: value, onValueChange: handleValueChange, children: [_jsx(ArkMenu.ItemGroupLabel, { className: "ds-menu__label", children: label }), items.map((item) => (_jsxs(ArkMenu.RadioItem, { value: item.value, valueText: item.label, disabled: item.disabled, className: "ds-menu__item", children: [_jsx(ArkMenu.ItemText, { children: item.label }), _jsx(ArkMenu.ItemIndicator, { className: "ds-menu__item-indicator", children: _jsx(Icon, { source: itemIndicator, size: "sm", decorative: true }) })] }, item.value)))] }) }) }) })] }));
77
+ return (_jsxs(ArkMenu.Root, { lazyMount: true, unmountOnExit: true, children: [_jsx(ArkMenu.Trigger, { asChild: true, children: trigger }), _jsx(Portal, { container: portalContainer, children: _jsx(ArkMenu.Positioner, { children: _jsx("div", { className: cx('ds-menu__popup', className), children: _jsx(ArkMenu.Content, { className: "ds-menu__content", children: _jsxs(ArkMenu.RadioItemGroup, { value: value, onValueChange: handleValueChange, children: [_jsx(ArkMenu.ItemGroupLabel, { className: "ds-menu__label", children: label }), items.map((item) => (_jsxs(ArkMenu.RadioItem, { value: item.value, valueText: item.label, disabled: item.disabled, className: "ds-menu__item", children: [_jsx(ArkMenu.ItemText, { children: item.label }), _jsx(ArkMenu.ItemIndicator, { className: "ds-menu__item-indicator", children: _jsx(Icon, { source: itemIndicator, size: "sm", decorative: true }) })] }, item.value)))] }) }) }) }) })] }));
78
78
  }
79
79
  //# sourceMappingURL=menu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"menu.js","sourceRoot":"","sources":["../../src/menu/menu.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAA0C,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACxF,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,YAAY,CAAC;AAuEpB;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,WAAW,CAAC,EAC1B,SAAS,GAAG,YAAY,EACxB,SAAS,EACT,QAAQ,EACR,G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,kBAAkB,YAC3C,MAAC,OAAO,CAAC,cAAc,IAAC,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,iBAAiB,aACpE,KAAC,OAAO,CAAC,cAAc,IAAC,SAAS,EAAC,gBAAgB,YAAE,KAAK,GAA0B,EAClF,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACnB,MAAC,OAAO,CAAC,SAAS,IAEhB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,SAAS,EAAE,IAAI,CAAC,KAAK,EACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,SAAS,EAAC,eAAe,aAEzB,KAAC,OAAO,CAAC,QAAQ,cAAE,IAAI,CAAC,KAAK,GAAoB,EACjD,KAAC,OAAO,CAAC,aAAa,IAAC,SAAS,EAAC,yBAAyB,YACxD,KAAC,IAAI,IAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAC,IAAI,EAAC,UAAU,SAAG,GAC9B,KATnB,IAAI,CAAC,KAAK,CAUG,CACrB,CAAC,IACqB,GACT,GACd,GACa,GACd,IACI,CAChB,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manakind/ui-core",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,6 +28,10 @@
28
28
  "types": "./dist/alert/index.d.ts",
29
29
  "import": "./dist/alert/index.js"
30
30
  },
31
+ "./avatar": {
32
+ "types": "./dist/avatar/index.d.ts",
33
+ "import": "./dist/avatar/index.js"
34
+ },
31
35
  "./badge": {
32
36
  "types": "./dist/badge/index.d.ts",
33
37
  "import": "./dist/badge/index.js"
@@ -108,6 +112,10 @@
108
112
  "types": "./dist/alert/alert.css.d.ts",
109
113
  "default": "./dist/alert/alert.css"
110
114
  },
115
+ "./css/avatar": {
116
+ "types": "./dist/avatar/avatar.css.d.ts",
117
+ "default": "./dist/avatar/avatar.css"
118
+ },
111
119
  "./css/badge": {
112
120
  "types": "./dist/badge/badge.css.d.ts",
113
121
  "default": "./dist/badge/badge.css"
@@ -203,7 +211,7 @@
203
211
  },
204
212
  "devDependencies": {
205
213
  "@manakind/ds-config": "*",
206
- "@manakind/manuia-tokens": "0.17.0",
214
+ "@manakind/manuia-tokens": "0.18.0",
207
215
  "@testing-library/jest-dom": "^6.9.1",
208
216
  "@testing-library/react": "^16.3.2",
209
217
  "@testing-library/user-event": "^14.6.1",