@manakind/ui-core 0.28.1 → 0.30.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 +7 -3
- package/dist/accordion/accordion.css +89 -0
- package/dist/accordion/accordion.css.d.ts +2 -0
- package/dist/accordion/accordion.d.ts +79 -0
- package/dist/accordion/accordion.d.ts.map +1 -0
- package/dist/accordion/accordion.js +44 -0
- package/dist/accordion/accordion.js.map +1 -0
- package/dist/accordion/index.d.ts +2 -0
- package/dist/accordion/index.d.ts.map +1 -0
- package/dist/accordion/index.js +2 -0
- package/dist/accordion/index.js.map +1 -0
- package/dist/button/button.css +7 -1
- package/dist/button/button.d.ts +5 -3
- package/dist/button/button.d.ts.map +1 -1
- package/dist/button/button.js +7 -4
- package/dist/button/button.js.map +1 -1
- package/dist/button/icon-button.d.ts +4 -2
- package/dist/button/icon-button.d.ts.map +1 -1
- package/dist/button/icon-button.js +5 -2
- package/dist/button/icon-button.js.map +1 -1
- package/dist/button/loading-interaction.d.ts +6 -0
- package/dist/button/loading-interaction.d.ts.map +1 -0
- package/dist/button/loading-interaction.js +26 -0
- package/dist/button/loading-interaction.js.map +1 -0
- package/dist/calendar/calendar.d.ts +3 -4
- package/dist/calendar/calendar.d.ts.map +1 -1
- package/dist/calendar/calendar.js +5 -2
- package/dist/calendar/calendar.js.map +1 -1
- package/dist/checkbox/checkbox.d.ts +2 -4
- package/dist/checkbox/checkbox.d.ts.map +1 -1
- package/dist/checkbox/checkbox.js +4 -2
- package/dist/checkbox/checkbox.js.map +1 -1
- package/dist/combobox/combobox.d.ts +3 -3
- package/dist/combobox/combobox.d.ts.map +1 -1
- package/dist/combobox/combobox.js +5 -2
- package/dist/combobox/combobox.js.map +1 -1
- package/dist/dialog/dialog.d.ts +3 -4
- package/dist/dialog/dialog.d.ts.map +1 -1
- package/dist/dialog/dialog.js +4 -2
- package/dist/dialog/dialog.js.map +1 -1
- package/dist/fallback-glyphs.js +3 -3
- package/dist/fallback-glyphs.js.map +1 -1
- package/dist/icon-defaults.d.ts +45 -0
- package/dist/icon-defaults.d.ts.map +1 -0
- package/dist/icon-defaults.js +43 -0
- package/dist/icon-defaults.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/menu/action-menu.d.ts +3 -3
- package/dist/menu/action-menu.d.ts.map +1 -1
- package/dist/menu/action-menu.js +4 -2
- package/dist/menu/action-menu.js.map +1 -1
- package/dist/menu/menu.d.ts +5 -7
- package/dist/menu/menu.d.ts.map +1 -1
- package/dist/menu/menu.js +7 -3
- package/dist/menu/menu.js.map +1 -1
- package/dist/radio-group/index.d.ts +2 -0
- package/dist/radio-group/index.d.ts.map +1 -0
- package/dist/radio-group/index.js +2 -0
- package/dist/radio-group/index.js.map +1 -0
- package/dist/radio-group/radio-group.css +70 -0
- package/dist/radio-group/radio-group.css.d.ts +2 -0
- package/dist/radio-group/radio-group.d.ts +74 -0
- package/dist/radio-group/radio-group.d.ts.map +1 -0
- package/dist/radio-group/radio-group.js +57 -0
- package/dist/radio-group/radio-group.js.map +1 -0
- package/dist/select/select.d.ts +3 -3
- package/dist/select/select.d.ts.map +1 -1
- package/dist/select/select.js +5 -2
- package/dist/select/select.js.map +1 -1
- package/dist/sticky/sticky.css +13 -1
- package/dist/sticky/sticky.d.ts +8 -2
- package/dist/sticky/sticky.d.ts.map +1 -1
- package/dist/sticky/sticky.js +3 -3
- package/dist/sticky/sticky.js.map +1 -1
- package/package.json +18 -2
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ import '@manakind/ui-core/css/button';
|
|
|
41
41
|
import { Button } from '@manakind/ui-core';
|
|
42
42
|
|
|
43
43
|
export function Save() {
|
|
44
|
-
return <Button variant="
|
|
44
|
+
return <Button variant="primary">Save</Button>;
|
|
45
45
|
}
|
|
46
46
|
```
|
|
47
47
|
|
|
@@ -57,12 +57,13 @@ separately, so an app can load only what it renders.
|
|
|
57
57
|
|
|
58
58
|
| Entry | Contents |
|
|
59
59
|
|---|---|
|
|
60
|
-
| `@manakind/ui-core` | Everything below, plus every prop type, the `cx` helper, and the built-in fallback glyphs (`FallbackChevronLeft`, `FallbackChevronRight`, `FallbackCheck`, `FallbackCross`, `FallbackPin`) for compositions that want the same defaults |
|
|
60
|
+
| `@manakind/ui-core` | Everything below, plus every prop type, the `cx` helper, `IconDefaultsProvider` + `useIconDefaults` (a product's glyphs for every icon slot left out), and the built-in fallback glyphs (`FallbackChevronLeft`, `FallbackChevronRight`, `FallbackCheck`, `FallbackCross`, `FallbackPin`) for compositions that want the same defaults |
|
|
61
|
+
| `@manakind/ui-core/accordion` | `Accordion` + `AccordionItem`; a title, a muted summary of what the section holds, and its content |
|
|
61
62
|
| `@manakind/ui-core/alert` | `Alert` |
|
|
62
63
|
| `@manakind/ui-core/avatar` | `Avatar` + `initialsOf` |
|
|
63
64
|
| `@manakind/ui-core/badge` | `Badge` |
|
|
64
65
|
| `@manakind/ui-core/breadcrumb` | `Breadcrumb` |
|
|
65
|
-
| `@manakind/ui-core/button` | `Button` + `IconButton
|
|
66
|
+
| `@manakind/ui-core/button` | `Button` + `IconButton`; loading retains keyboard focus and blocks activation/form submission |
|
|
66
67
|
| `@manakind/ui-core/calendar` | `Calendar` |
|
|
67
68
|
| `@manakind/ui-core/card` | `Card`, `CardHeader`, `CardTitle`, `CardLink`, `CardDescription`, `CardContent`, `CardFooter` |
|
|
68
69
|
| `@manakind/ui-core/dialog` | `Dialog` + `DialogClose` |
|
|
@@ -89,6 +90,7 @@ separately, so an app can load only what it renders.
|
|
|
89
90
|
| `@manakind/ui-core/visually-hidden` | `VisuallyHidden` |
|
|
90
91
|
| `@manakind/ui-core/skeleton` | `Skeleton` |
|
|
91
92
|
| `@manakind/ui-core/spinner` | `Spinner` |
|
|
93
|
+
| `@manakind/ui-core/radio-group` | `RadioGroup` |
|
|
92
94
|
| `@manakind/ui-core/scroll-area` | `ScrollArea` |
|
|
93
95
|
| `@manakind/ui-core/sticky` | `Sticky` |
|
|
94
96
|
| `@manakind/ui-core/empty-state` | `EmptyState` |
|
|
@@ -101,6 +103,7 @@ separately, so an app can load only what it renders.
|
|
|
101
103
|
| `@manakind/ui-core/form-layout` | `FormLayout`, `FormActions` |
|
|
102
104
|
| `@manakind/ui-core/wizard-layout` | `WizardLayout`, `WizardHeader`, `WizardContent`, `WizardFooter` |
|
|
103
105
|
| `@manakind/ui-core/centered-layout` | `CenteredLayout` |
|
|
106
|
+
| `@manakind/ui-core/css/accordion` | Accordion structural CSS; its indicator also needs `css/icon` |
|
|
104
107
|
| `@manakind/ui-core/css/alert` | Alert structural CSS; its icon also needs `css/icon` |
|
|
105
108
|
| `@manakind/ui-core/css/avatar` | Avatar structural CSS; its fallback glyph also needs `css/icon` |
|
|
106
109
|
| `@manakind/ui-core/css/badge` | Badge structural CSS |
|
|
@@ -132,6 +135,7 @@ separately, so an app can load only what it renders.
|
|
|
132
135
|
| `@manakind/ui-core/css/visually-hidden` | VisuallyHidden structural CSS |
|
|
133
136
|
| `@manakind/ui-core/css/skeleton` | Skeleton structural CSS |
|
|
134
137
|
| `@manakind/ui-core/css/spinner` | Spinner structural CSS; its label also needs `css/visually-hidden` |
|
|
138
|
+
| `@manakind/ui-core/css/radio-group` | RadioGroup structural CSS |
|
|
135
139
|
| `@manakind/ui-core/css/scroll-area` | ScrollArea structural CSS |
|
|
136
140
|
| `@manakind/ui-core/css/sticky` | Sticky structural CSS |
|
|
137
141
|
| `@manakind/ui-core/css/empty-state` | EmptyState structural CSS; its glyph also needs `css/icon` |
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
@layer components {
|
|
2
|
+
.ds-accordion {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
min-inline-size: 0;
|
|
6
|
+
overflow-wrap: anywhere;
|
|
7
|
+
|
|
8
|
+
& .ds-accordion__item + .ds-accordion__item {
|
|
9
|
+
border-block-start: 1px solid var(--ds-accordion-item-border);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
& .ds-accordion__heading {
|
|
13
|
+
margin: 0;
|
|
14
|
+
font: inherit;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* The title and its summary share a wrapping run of text, and the
|
|
19
|
+
* indicator keeps a column of its own: a long summary takes the next
|
|
20
|
+
* line under the title instead of pushing the chevron out of line.
|
|
21
|
+
*/
|
|
22
|
+
& .ds-accordion__trigger {
|
|
23
|
+
display: grid;
|
|
24
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
25
|
+
align-items: center;
|
|
26
|
+
gap: var(--ds-accordion-trigger-gap);
|
|
27
|
+
inline-size: 100%;
|
|
28
|
+
padding: var(--ds-accordion-trigger-padding);
|
|
29
|
+
border: 0;
|
|
30
|
+
border-radius: var(--ds-accordion-trigger-radius);
|
|
31
|
+
background-color: transparent;
|
|
32
|
+
color: var(--ds-accordion-trigger-text);
|
|
33
|
+
font-family: inherit;
|
|
34
|
+
font-size: var(--ds-accordion-trigger-font-size);
|
|
35
|
+
line-height: inherit;
|
|
36
|
+
text-align: start;
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
|
|
39
|
+
@media (hover: hover) {
|
|
40
|
+
&:hover:not(:disabled) {
|
|
41
|
+
background-color: var(--ds-accordion-trigger-bg-hover);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/*
|
|
46
|
+
* Drawn inside the button, not 3px out as on other controls: a section
|
|
47
|
+
* spans its container edge to edge, and a container that scrolls (a
|
|
48
|
+
* pinned sidebar) would clip a ring drawn outside it.
|
|
49
|
+
*/
|
|
50
|
+
&:focus-visible {
|
|
51
|
+
outline: 2px solid var(--ds-accordion-focus-ring);
|
|
52
|
+
outline-offset: -2px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* Zag disables the button itself and puts `data-disabled` on the item, not here. */
|
|
56
|
+
&:disabled {
|
|
57
|
+
cursor: not-allowed;
|
|
58
|
+
opacity: var(--ds-opacity-disabled);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
& .ds-accordion__title {
|
|
63
|
+
font-weight: var(--ds-accordion-trigger-font-weight);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
& .ds-accordion__summary {
|
|
67
|
+
color: var(--ds-accordion-summary-text);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* The glyph points right and turns down while its section is open. */
|
|
71
|
+
& .ds-accordion__indicator {
|
|
72
|
+
display: inline-flex;
|
|
73
|
+
color: var(--ds-accordion-indicator-color);
|
|
74
|
+
transition: transform 150ms cubic-bezier(0, 0, 0.2, 1);
|
|
75
|
+
|
|
76
|
+
&[data-state="open"] {
|
|
77
|
+
transform: rotate(90deg);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
& .ds-accordion__content {
|
|
82
|
+
padding: 0 var(--ds-accordion-content-padding) var(--ds-accordion-content-padding);
|
|
83
|
+
|
|
84
|
+
&[hidden] {
|
|
85
|
+
display: none;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import './accordion.css';
|
|
3
|
+
import type { CardHeadingTag } from '../card/card';
|
|
4
|
+
import { type IconSource } from '../icon/icon';
|
|
5
|
+
export type AccordionHeadingTag = Exclude<CardHeadingTag, 'h1'>;
|
|
6
|
+
export interface AccordionProps {
|
|
7
|
+
/** The sections: `AccordionItem`s. */
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/** Controlled open sections, by `value`. */
|
|
10
|
+
value?: string[];
|
|
11
|
+
/** Sections open at first when uncontrolled. */
|
|
12
|
+
defaultValue?: string[];
|
|
13
|
+
/** Fired with every open section's value whenever one opens or closes. */
|
|
14
|
+
onValueChange?: (value: string[]) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Let several sections be open at once: a sidebar of filters. Off by
|
|
17
|
+
* default, so opening one closes the other, and the open one can still be
|
|
18
|
+
* closed.
|
|
19
|
+
*/
|
|
20
|
+
multiple?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The heading element each section's title sits in, so the sections take
|
|
23
|
+
* their place in the page's outline. Defaults to `h3`.
|
|
24
|
+
*/
|
|
25
|
+
headingLevel?: AccordionHeadingTag;
|
|
26
|
+
/** Extra class names appended after `ds-accordion`. */
|
|
27
|
+
className?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Stacked sections whose titles show and hide what sits under them, built on
|
|
31
|
+
* Ark UI's Accordion: the filters of a list in a sidebar, the questions of
|
|
32
|
+
* an FAQ.
|
|
33
|
+
*
|
|
34
|
+
* Ark owns the behaviour: each title is a button in a heading that says
|
|
35
|
+
* whether its section is expanded and which region it controls, and the
|
|
36
|
+
* arrow keys, Home and End move between the titles. This wrapper contributes
|
|
37
|
+
* the `ds-` classes, the `--ds-accordion-*` bindings and a flat item API.
|
|
38
|
+
*
|
|
39
|
+
* ```tsx
|
|
40
|
+
* <Accordion multiple defaultValue={['state']} headingLevel="h2">
|
|
41
|
+
* <AccordionItem value="state" title="State" summary="Open">
|
|
42
|
+
* …
|
|
43
|
+
* </AccordionItem>
|
|
44
|
+
* <AccordionItem value="category" title="Category" summary="Any">
|
|
45
|
+
* …
|
|
46
|
+
* </AccordionItem>
|
|
47
|
+
* </Accordion>
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* A closed section's content stays mounted, hidden, so state held in it
|
|
51
|
+
* survives closing it.
|
|
52
|
+
*/
|
|
53
|
+
export declare function Accordion({ children, value, defaultValue, onValueChange, multiple, headingLevel, className, }: AccordionProps): import("react/jsx-runtime").JSX.Element;
|
|
54
|
+
export interface AccordionItemProps {
|
|
55
|
+
/** Stable id of the section, reported by `onValueChange`. */
|
|
56
|
+
value: string;
|
|
57
|
+
/** The section's title: what its content is about. */
|
|
58
|
+
title: ReactNode;
|
|
59
|
+
/**
|
|
60
|
+
* What the section holds right now, beside the title and muted: a filter's
|
|
61
|
+
* choice ("Open", "High, Low"), so a closed section still says what it does.
|
|
62
|
+
* Part of the title button's name.
|
|
63
|
+
*/
|
|
64
|
+
summary?: ReactNode;
|
|
65
|
+
/** The section's content, shown while it is open. */
|
|
66
|
+
children: ReactNode;
|
|
67
|
+
/** Keep the section closed and its title out of reach. */
|
|
68
|
+
disabled?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Glyph after the title. Must point RIGHT: it turns down while the section
|
|
71
|
+
* is open. Defaults to the `IconDefaultsProvider`'s `chevronRight`.
|
|
72
|
+
*/
|
|
73
|
+
indicator?: IconSource;
|
|
74
|
+
/** Extra class names appended after `ds-accordion__item`. */
|
|
75
|
+
className?: string;
|
|
76
|
+
}
|
|
77
|
+
/** One section of an `Accordion`: a title that opens and closes its content. */
|
|
78
|
+
export declare function AccordionItem({ value, title, summary, children, disabled, indicator: indicatorProp, className, }: AccordionItemProps): import("react/jsx-runtime").JSX.Element;
|
|
79
|
+
//# sourceMappingURL=accordion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accordion.d.ts","sourceRoot":"","sources":["../../src/accordion/accordion.tsx"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,SAAS,EAAc,MAAM,OAAO,CAAC;AAClE,OAAO,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAGrD,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;AAIhE,MAAM,WAAW,cAAc;IAC7B,sCAAsC;IACtC,QAAQ,EAAE,SAAS,CAAC;IACpB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,gDAAgD;IAChD,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,0EAA0E;IAC1E,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC1C;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,SAAS,CAAC,EACxB,QAAQ,EACR,KAAK,EACL,YAAY,EACZ,aAAa,EACb,QAAgB,EAChB,YAAmB,EACnB,SAAS,GACV,EAAE,cAAc,2CAgBhB;AAED,MAAM,WAAW,kBAAkB;IACjC,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,KAAK,EAAE,SAAS,CAAC;IACjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,qDAAqD;IACrD,QAAQ,EAAE,SAAS,CAAC;IACpB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,SAAS,EAAE,aAAa,EACxB,SAAS,GACV,EAAE,kBAAkB,2CA+BpB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Accordion as ArkAccordion } from '@ark-ui/react/accordion';
|
|
3
|
+
import { createContext, useContext } from 'react';
|
|
4
|
+
import './accordion.css';
|
|
5
|
+
import { cx } from '../cx';
|
|
6
|
+
import { Icon } from '../icon/icon';
|
|
7
|
+
import { useIconDefaults } from '../icon-defaults';
|
|
8
|
+
const HeadingContext = createContext('h3');
|
|
9
|
+
/**
|
|
10
|
+
* Stacked sections whose titles show and hide what sits under them, built on
|
|
11
|
+
* Ark UI's Accordion: the filters of a list in a sidebar, the questions of
|
|
12
|
+
* an FAQ.
|
|
13
|
+
*
|
|
14
|
+
* Ark owns the behaviour: each title is a button in a heading that says
|
|
15
|
+
* whether its section is expanded and which region it controls, and the
|
|
16
|
+
* arrow keys, Home and End move between the titles. This wrapper contributes
|
|
17
|
+
* the `ds-` classes, the `--ds-accordion-*` bindings and a flat item API.
|
|
18
|
+
*
|
|
19
|
+
* ```tsx
|
|
20
|
+
* <Accordion multiple defaultValue={['state']} headingLevel="h2">
|
|
21
|
+
* <AccordionItem value="state" title="State" summary="Open">
|
|
22
|
+
* …
|
|
23
|
+
* </AccordionItem>
|
|
24
|
+
* <AccordionItem value="category" title="Category" summary="Any">
|
|
25
|
+
* …
|
|
26
|
+
* </AccordionItem>
|
|
27
|
+
* </Accordion>
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* A closed section's content stays mounted, hidden, so state held in it
|
|
31
|
+
* survives closing it.
|
|
32
|
+
*/
|
|
33
|
+
export function Accordion({ children, value, defaultValue, onValueChange, multiple = false, headingLevel = 'h3', className, }) {
|
|
34
|
+
const handleValueChange = (details) => onValueChange?.(details.value);
|
|
35
|
+
return (_jsx(HeadingContext.Provider, { value: headingLevel, children: _jsx(ArkAccordion.Root, { className: cx('ds-accordion', className), value: value, defaultValue: defaultValue, onValueChange: handleValueChange, multiple: multiple, collapsible: true, children: children }) }));
|
|
36
|
+
}
|
|
37
|
+
/** One section of an `Accordion`: a title that opens and closes its content. */
|
|
38
|
+
export function AccordionItem({ value, title, summary, children, disabled, indicator: indicatorProp, className, }) {
|
|
39
|
+
const Heading = useContext(HeadingContext);
|
|
40
|
+
const icons = useIconDefaults();
|
|
41
|
+
const indicator = indicatorProp ?? icons.chevronRight;
|
|
42
|
+
return (_jsxs(ArkAccordion.Item, { value: value, disabled: disabled, className: cx('ds-accordion__item', className), children: [_jsx(Heading, { className: "ds-accordion__heading", children: _jsxs(ArkAccordion.ItemTrigger, { className: "ds-accordion__trigger", children: [_jsxs("span", { className: "ds-accordion__label", children: [_jsx("span", { className: "ds-accordion__title", children: title }), summary !== undefined && (_jsxs(_Fragment, { children: [' ', _jsx("span", { className: "ds-accordion__summary", children: summary })] }))] }), _jsx(ArkAccordion.ItemIndicator, { className: "ds-accordion__indicator", children: _jsx(Icon, { source: indicator, size: "sm", decorative: true }) })] }) }), _jsx(ArkAccordion.ItemContent, { className: "ds-accordion__content", children: children })] }));
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=accordion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accordion.js","sourceRoot":"","sources":["../../src/accordion/accordion.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAkB,UAAU,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,iBAAiB,CAAC;AAEzB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAInD,MAAM,cAAc,GAAG,aAAa,CAAsB,IAAI,CAAC,CAAC;AA0BhE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,SAAS,CAAC,EACxB,QAAQ,EACR,KAAK,EACL,YAAY,EACZ,aAAa,EACb,QAAQ,GAAG,KAAK,EAChB,YAAY,GAAG,IAAI,EACnB,SAAS,GACM;IACf,MAAM,iBAAiB,GAAG,CAAC,OAA4B,EAAE,EAAE,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC3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AC,YAAY,CAAC,WAAW,IAAC,SAAS,EAAC,uBAAuB,YACxD,QAAQ,GACgB,IACT,CACrB,CAAC;AACJ,CAAC","sourcesContent":["import { Accordion as ArkAccordion } from '@ark-ui/react/accordion';\nimport { createContext, type ReactNode, useContext } from 'react';\nimport './accordion.css';\nimport type { CardHeadingTag } from '../card/card';\nimport { cx } from '../cx';\nimport { Icon, type IconSource } from '../icon/icon';\nimport { useIconDefaults } from '../icon-defaults';\n\nexport type AccordionHeadingTag = Exclude<CardHeadingTag, 'h1'>;\n\nconst HeadingContext = createContext<AccordionHeadingTag>('h3');\n\nexport interface AccordionProps {\n /** The sections: `AccordionItem`s. */\n children: ReactNode;\n /** Controlled open sections, by `value`. */\n value?: string[];\n /** Sections open at first when uncontrolled. */\n defaultValue?: string[];\n /** Fired with every open section's value whenever one opens or closes. */\n onValueChange?: (value: string[]) => void;\n /**\n * Let several sections be open at once: a sidebar of filters. Off by\n * default, so opening one closes the other, and the open one can still be\n * closed.\n */\n multiple?: boolean;\n /**\n * The heading element each section's title sits in, so the sections take\n * their place in the page's outline. Defaults to `h3`.\n */\n headingLevel?: AccordionHeadingTag;\n /** Extra class names appended after `ds-accordion`. */\n className?: string;\n}\n\n/**\n * Stacked sections whose titles show and hide what sits under them, built on\n * Ark UI's Accordion: the filters of a list in a sidebar, the questions of\n * an FAQ.\n *\n * Ark owns the behaviour: each title is a button in a heading that says\n * whether its section is expanded and which region it controls, and the\n * arrow keys, Home and End move between the titles. This wrapper contributes\n * the `ds-` classes, the `--ds-accordion-*` bindings and a flat item API.\n *\n * ```tsx\n * <Accordion multiple defaultValue={['state']} headingLevel=\"h2\">\n * <AccordionItem value=\"state\" title=\"State\" summary=\"Open\">\n * …\n * </AccordionItem>\n * <AccordionItem value=\"category\" title=\"Category\" summary=\"Any\">\n * …\n * </AccordionItem>\n * </Accordion>\n * ```\n *\n * A closed section's content stays mounted, hidden, so state held in it\n * survives closing it.\n */\nexport function Accordion({\n children,\n value,\n defaultValue,\n onValueChange,\n multiple = false,\n headingLevel = 'h3',\n className,\n}: AccordionProps) {\n const handleValueChange = (details: { value: string[] }) => onValueChange?.(details.value);\n return (\n <HeadingContext.Provider value={headingLevel}>\n <ArkAccordion.Root\n className={cx('ds-accordion', className)}\n value={value}\n defaultValue={defaultValue}\n onValueChange={handleValueChange}\n multiple={multiple}\n collapsible\n >\n {children}\n </ArkAccordion.Root>\n </HeadingContext.Provider>\n );\n}\n\nexport interface AccordionItemProps {\n /** Stable id of the section, reported by `onValueChange`. */\n value: string;\n /** The section's title: what its content is about. */\n title: ReactNode;\n /**\n * What the section holds right now, beside the title and muted: a filter's\n * choice (\"Open\", \"High, Low\"), so a closed section still says what it does.\n * Part of the title button's name.\n */\n summary?: ReactNode;\n /** The section's content, shown while it is open. */\n children: ReactNode;\n /** Keep the section closed and its title out of reach. */\n disabled?: boolean;\n /**\n * Glyph after the title. Must point RIGHT: it turns down while the section\n * is open. Defaults to the `IconDefaultsProvider`'s `chevronRight`.\n */\n indicator?: IconSource;\n /** Extra class names appended after `ds-accordion__item`. */\n className?: string;\n}\n\n/** One section of an `Accordion`: a title that opens and closes its content. */\nexport function AccordionItem({\n value,\n title,\n summary,\n children,\n disabled,\n indicator: indicatorProp,\n className,\n}: AccordionItemProps) {\n const Heading = useContext(HeadingContext);\n const icons = useIconDefaults();\n const indicator = indicatorProp ?? icons.chevronRight;\n return (\n <ArkAccordion.Item\n value={value}\n disabled={disabled}\n className={cx('ds-accordion__item', className)}\n >\n <Heading className=\"ds-accordion__heading\">\n <ArkAccordion.ItemTrigger className=\"ds-accordion__trigger\">\n <span className=\"ds-accordion__label\">\n <span className=\"ds-accordion__title\">{title}</span>\n {summary !== undefined && (\n <>\n {' '}\n <span className=\"ds-accordion__summary\">{summary}</span>\n </>\n )}\n </span>\n <ArkAccordion.ItemIndicator className=\"ds-accordion__indicator\">\n <Icon source={indicator} size=\"sm\" decorative />\n </ArkAccordion.ItemIndicator>\n </ArkAccordion.ItemTrigger>\n </Heading>\n <ArkAccordion.ItemContent className=\"ds-accordion__content\">\n {children}\n </ArkAccordion.ItemContent>\n </ArkAccordion.Item>\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/accordion/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,mBAAmB,EACxB,aAAa,EACb,KAAK,kBAAkB,EACvB,KAAK,cAAc,GACpB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/accordion/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAET,aAAa,GAGd,MAAM,aAAa,CAAC","sourcesContent":["export {\n Accordion,\n type AccordionHeadingTag,\n AccordionItem,\n type AccordionItemProps,\n type AccordionProps,\n} from './accordion';\n"]}
|
package/dist/button/button.css
CHANGED
|
@@ -115,7 +115,8 @@
|
|
|
115
115
|
* `aria-disabled` keeps the button in the tab order while it does
|
|
116
116
|
* nothing, so focus is not dropped from a control that becomes unavailable
|
|
117
117
|
* while it is focused (the last step of a stepper, a sort that is already
|
|
118
|
-
* applied). It looks the same as `disabled`; the consumer guards
|
|
118
|
+
* applied). It looks the same as `disabled`; the consumer guards a manually
|
|
119
|
+
* set state. Loading sets it and guards activation in the component.
|
|
119
120
|
*/
|
|
120
121
|
&:disabled,
|
|
121
122
|
&[aria-disabled="true"] {
|
|
@@ -123,6 +124,11 @@
|
|
|
123
124
|
cursor: not-allowed;
|
|
124
125
|
}
|
|
125
126
|
|
|
127
|
+
/* Element opacity would also fade the focus ring below its measured contrast. */
|
|
128
|
+
&[aria-disabled="true"]:focus-visible {
|
|
129
|
+
opacity: initial;
|
|
130
|
+
}
|
|
131
|
+
|
|
126
132
|
&.ds-button--loading {
|
|
127
133
|
position: relative;
|
|
128
134
|
color: transparent;
|
package/dist/button/button.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ interface ButtonOwnProps {
|
|
|
38
38
|
type ArkButtonProps = Omit<ComponentProps<typeof ark.button>, 'asChild'>;
|
|
39
39
|
interface ButtonAsButtonProps extends ButtonOwnProps, ArkButtonProps {
|
|
40
40
|
asChild?: false;
|
|
41
|
-
/** Show
|
|
41
|
+
/** Show a spinner and block activation while keeping keyboard focus. */
|
|
42
42
|
loading?: boolean;
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
@@ -73,13 +73,15 @@ export type ButtonProps = ButtonAsButtonProps | ButtonAsChildProps;
|
|
|
73
73
|
/**
|
|
74
74
|
* Shared base button for the Manakind design system.
|
|
75
75
|
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
76
|
+
* Uses Ark UI's element factory and native button keyboard behavior, with
|
|
77
|
+
* loading interaction handled here. Styled against the `--ds-*` token
|
|
78
78
|
* contract; the consuming product is responsible for providing those values
|
|
79
79
|
* via its tokens package (e.g. `@manakind/manuia-tokens/css/theme`).
|
|
80
80
|
*
|
|
81
81
|
* For an icon-only button (no visible label), use `IconButton` instead —
|
|
82
82
|
* it enforces an `aria-label` at the type level.
|
|
83
|
+
* Loading uses `aria-disabled` and `aria-busy` with blocked activation so focus
|
|
84
|
+
* stays on the control. An explicit `disabled` still uses native disabling.
|
|
83
85
|
*
|
|
84
86
|
* For an action that navigates, pass `asChild` and a link as the only child.
|
|
85
87
|
* The link is what renders, so it keeps what a link does: open in a new tab,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/button/button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EACL,KAAK,cAAc,EAInB,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"button.d.ts","s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ACrE,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,WAAW,GAAG,mBAAmB,GAAG,kBAAkB,CAAC;AAqHnE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,2CAExC"}
|
package/dist/button/button.js
CHANGED
|
@@ -4,6 +4,7 @@ import { cloneElement, Fragment, isValidElement, } from 'react';
|
|
|
4
4
|
import { Icon } from '../icon/icon';
|
|
5
5
|
import './button.css';
|
|
6
6
|
import { cx } from '../cx';
|
|
7
|
+
import { guardLoadingClick, guardLoadingKey } from './loading-interaction';
|
|
7
8
|
function ButtonContent({ loading, leadingIcon, trailingIcon, children }) {
|
|
8
9
|
return (_jsxs(_Fragment, { children: [loading && _jsx("span", { className: "ds-button__spinner", "aria-hidden": "true" }), leadingIcon && (_jsx(Icon, { source: leadingIcon, size: "sm", decorative: true, className: "ds-button__icon ds-button__icon--leading" })), _jsx("span", { className: "ds-button__label", children: children }), trailingIcon && (_jsx(Icon, { source: trailingIcon, size: "sm", decorative: true, className: "ds-button__icon ds-button__icon--trailing" }))] }));
|
|
9
10
|
}
|
|
@@ -19,19 +20,21 @@ function ButtonAsChild({ variant, size, fullWidth, align, leadingIcon, trailingI
|
|
|
19
20
|
className: cx(classesFor({ variant, size, fullWidth, align }, className), children.props.className),
|
|
20
21
|
}, content);
|
|
21
22
|
}
|
|
22
|
-
function ButtonAsButton({ variant, size, fullWidth, align, loading = false, disabled, leadingIcon, trailingIcon, className, children, ...props }) {
|
|
23
|
-
return (_jsx(ark.button, {
|
|
23
|
+
function ButtonAsButton({ variant, size, fullWidth, align, loading = false, disabled, onClickCapture, onKeyDownCapture, onKeyUpCapture, leadingIcon, trailingIcon, className, children, ...props }) {
|
|
24
|
+
return (_jsx(ark.button, { className: cx(classesFor({ variant, size, fullWidth, align }, className), loading && 'ds-button--loading'), ...props, disabled: disabled, "aria-disabled": loading || props['aria-disabled'], "aria-busy": loading || props['aria-busy'], onClickCapture: guardLoadingClick(loading, onClickCapture), onKeyDownCapture: guardLoadingKey(loading, props['aria-haspopup'], onKeyDownCapture), onKeyUpCapture: guardLoadingKey(loading, props['aria-haspopup'], onKeyUpCapture), children: _jsx(ButtonContent, { loading: loading, leadingIcon: leadingIcon, trailingIcon: trailingIcon, children: children }) }));
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
27
|
* Shared base button for the Manakind design system.
|
|
27
28
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
29
|
+
* Uses Ark UI's element factory and native button keyboard behavior, with
|
|
30
|
+
* loading interaction handled here. Styled against the `--ds-*` token
|
|
30
31
|
* contract; the consuming product is responsible for providing those values
|
|
31
32
|
* via its tokens package (e.g. `@manakind/manuia-tokens/css/theme`).
|
|
32
33
|
*
|
|
33
34
|
* For an icon-only button (no visible label), use `IconButton` instead —
|
|
34
35
|
* it enforces an `aria-label` at the type level.
|
|
36
|
+
* Loading uses `aria-disabled` and `aria-busy` with blocked activation so focus
|
|
37
|
+
* stays on the control. An explicit `disabled` still uses native disabling.
|
|
35
38
|
*
|
|
36
39
|
* For an action that navigates, pass `asChild` and a link as the only child.
|
|
37
40
|
* The link is what renders, so it keeps what a link does: open in a new tab,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../src/button/button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAEL,YAAY,EACZ,QAAQ,EACR,cAAc,GAGf,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AACrD,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../src/button/button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MA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Ae,CAAC,OAAO,EAAE,KAAK,CAAC,eAAe,CAAC,EAAE,cAAc,CAAC,YAEhF,KAAC,aAAa,IAAC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,YAClF,QAAQ,GACK,GACL,CACd,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,MAAM,CAAC,KAAkB;IACvC,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAC,aAAa,OAAK,KAAK,GAAI,CAAC,CAAC,CAAC,KAAC,cAAc,OAAK,KAAK,GAAI,CAAC;AACtF,CAAC","sourcesContent":["import { ark } from '@ark-ui/react/factory';\nimport {\n type ComponentProps,\n cloneElement,\n Fragment,\n isValidElement,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { Icon, type IconSource } from '../icon/icon';\nimport './button.css';\nimport { cx } from '../cx';\nimport { guardLoadingClick, guardLoadingKey } from './loading-interaction';\n\nexport type ButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'danger';\nexport type ButtonSize = 'sm' | 'md' | 'lg';\n\ninterface ButtonOwnProps {\n /** Visual style variant. */\n variant?: ButtonVariant;\n /** Size preset. */\n size?: ButtonSize;\n /**\n * Decorative icon rendered before the label.\n *\n * The icon sits beside text, so it is always the `sm` step of the icon\n * scale whatever the button size, and it inherits the button's text\n * color via `currentColor`. The icon is\n * always rendered as decorative — the accessible name comes from the\n * button's children.\n */\n leadingIcon?: IconSource;\n /**\n * Decorative icon rendered after the label. Same rendering contract as\n * {@link ButtonOwnProps.leadingIcon}.\n */\n trailingIcon?: IconSource;\n /** Whether the button takes the whole width of its row: a form's submit, a card's one action. */\n fullWidth?: boolean;\n /**\n * Where the label sits when the button is wider than its content: centred\n * by default, or at the start, with a trailing icon kept at the end, for a\n * trigger that reads as a field (a picker). Inline rather than a named\n * union: `check:variant-parity` would ask the native Button, which has no\n * label alignment, to export the same name.\n */\n align?: 'center' | 'start';\n}\n\ntype ArkButtonProps = Omit<ComponentProps<typeof ark.button>, 'asChild'>;\n\ninterface ButtonAsButtonProps extends ButtonOwnProps, ArkButtonProps {\n asChild?: false;\n /** Show a spinner and block activation while keeping keyboard focus. */\n loading?: boolean;\n}\n\n/**\n * With `asChild` the child is the control, so everything that belongs to the\n * control goes on the child: `href`, handlers, `ref`, ARIA. Button adds its\n * look and nothing else, which is why no other prop is accepted here.\n *\n * A link has no disabled state: `disabled` is not an attribute of `<a>`, and\n * an anchor with an `href` stays reachable and clickable whatever it looks\n * like. So neither `disabled` nor `loading` exists. Render a `Button`, or no\n * control at all, when the destination is unavailable.\n */\ninterface ButtonAsChildProps extends ButtonOwnProps {\n /**\n * Render the single child element instead of a `<button>`, styled as this\n * button.\n */\n asChild: true;\n /**\n * The one element rendered as the control. Its own children become the\n * label. A component works if it passes `className` and `children` on to\n * the element it renders, as a router's link does.\n */\n children: ReactElement<{ className?: string; children?: ReactNode }>;\n /** Extra class names appended after the `ds-button` modifiers. */\n className?: string;\n}\n\nexport type ButtonProps = ButtonAsButtonProps | ButtonAsChildProps;\n\ninterface ButtonContentProps extends Pick<ButtonOwnProps, 'leadingIcon' | 'trailingIcon'> {\n loading: boolean;\n children: ReactNode;\n}\n\nfunction ButtonContent({ loading, leadingIcon, trailingIcon, children }: ButtonContentProps) {\n return (\n <>\n {loading && <span className=\"ds-button__spinner\" aria-hidden=\"true\" />}\n {leadingIcon && (\n <Icon\n source={leadingIcon}\n size=\"sm\"\n decorative\n className=\"ds-button__icon ds-button__icon--leading\"\n />\n )}\n <span className=\"ds-button__label\">{children}</span>\n {trailingIcon && (\n <Icon\n source={trailingIcon}\n size=\"sm\"\n decorative\n className=\"ds-button__icon ds-button__icon--trailing\"\n />\n )}\n </>\n );\n}\n\nfunction classesFor(\n { variant = 'primary', size = 'md', fullWidth = false, align = 'center' }: ButtonOwnProps,\n className?: string,\n) {\n return cx(\n 'ds-button',\n `ds-button--${variant}`,\n `ds-button--${size}`,\n fullWidth && 'ds-button--full-width',\n align !== 'center' && `ds-button--align-${align}`,\n className,\n );\n}\n\nfunction ButtonAsChild({\n variant,\n size,\n fullWidth,\n align,\n leadingIcon,\n trailingIcon,\n className,\n children,\n}: ButtonAsChildProps) {\n if (!isValidElement(children) || children.type === Fragment) {\n throw new Error(\n 'Button asChild needs exactly one element as its child, such as <a> or a router link.',\n );\n }\n\n const content = (\n <ButtonContent loading={false} leadingIcon={leadingIcon} trailingIcon={trailingIcon}>\n {children.props.children}\n </ButtonContent>\n );\n\n return cloneElement(\n children,\n {\n className: cx(\n classesFor({ variant, size, fullWidth, align }, className),\n children.props.className,\n ),\n },\n content,\n );\n}\n\nfunction ButtonAsButton({\n variant,\n size,\n fullWidth,\n align,\n loading = false,\n disabled,\n onClickCapture,\n onKeyDownCapture,\n onKeyUpCapture,\n leadingIcon,\n trailingIcon,\n className,\n children,\n ...props\n}: ButtonAsButtonProps) {\n return (\n <ark.button\n className={cx(\n classesFor({ variant, size, fullWidth, align }, className),\n loading && 'ds-button--loading',\n )}\n {...props}\n disabled={disabled}\n aria-disabled={loading || props['aria-disabled']}\n aria-busy={loading || props['aria-busy']}\n onClickCapture={guardLoadingClick(loading, onClickCapture)}\n onKeyDownCapture={guardLoadingKey(loading, props['aria-haspopup'], onKeyDownCapture)}\n onKeyUpCapture={guardLoadingKey(loading, props['aria-haspopup'], onKeyUpCapture)}\n >\n <ButtonContent loading={loading} leadingIcon={leadingIcon} trailingIcon={trailingIcon}>\n {children}\n </ButtonContent>\n </ark.button>\n );\n}\n\n/**\n * Shared base button for the Manakind design system.\n *\n * Uses Ark UI's element factory and native button keyboard behavior, with\n * loading interaction handled here. Styled against the `--ds-*` token\n * contract; the consuming product is responsible for providing those values\n * via its tokens package (e.g. `@manakind/manuia-tokens/css/theme`).\n *\n * For an icon-only button (no visible label), use `IconButton` instead —\n * it enforces an `aria-label` at the type level.\n * Loading uses `aria-disabled` and `aria-busy` with blocked activation so focus\n * stays on the control. An explicit `disabled` still uses native disabling.\n *\n * For an action that navigates, pass `asChild` and a link as the only child.\n * The link is what renders, so it keeps what a link does: open in a new tab,\n * copy its address, the router's prefetch. Its `href`, handlers and `ref`\n * stay on the link.\n *\n * ```tsx\n * <Button asChild leadingIcon={PlusCircle}>\n * <a href=\"/goals/new\">Add Goal</a>\n * </Button>\n * ```\n */\nexport function Button(props: ButtonProps) {\n return props.asChild ? <ButtonAsChild {...props} /> : <ButtonAsButton {...props} />;\n}\n"]}
|
|
@@ -20,7 +20,7 @@ export interface IconButtonProps extends Omit<ComponentProps<typeof ark.button>,
|
|
|
20
20
|
* same size from `md` up.
|
|
21
21
|
*/
|
|
22
22
|
size?: ButtonSize;
|
|
23
|
-
/** Show
|
|
23
|
+
/** Show a spinner and block activation while keeping keyboard focus. */
|
|
24
24
|
loading?: boolean;
|
|
25
25
|
/**
|
|
26
26
|
* The caption shown on hover and keyboard focus. Defaults to `aria-label`;
|
|
@@ -39,6 +39,8 @@ export interface IconButtonProps extends Omit<ComponentProps<typeof ark.button>,
|
|
|
39
39
|
* is that `aria-label` is required at the type level — an icon-only
|
|
40
40
|
* button has no visible text to derive an accessible name from — and that
|
|
41
41
|
* it shows that name as a tooltip, since the glyph alone may not say it.
|
|
42
|
+
* Loading keeps keyboard focus with `aria-disabled` and `aria-busy`, blocking
|
|
43
|
+
* activation; an explicit `disabled` still uses native disabling.
|
|
42
44
|
*/
|
|
43
|
-
export declare function IconButton({ icon, variant, size, loading, disabled, className, tooltip, ...props }: IconButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
export declare function IconButton({ icon, variant, size, loading, disabled, onClickCapture, onKeyDownCapture, onKeyUpCapture, className, tooltip, ...props }: IconButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
44
46
|
//# sourceMappingURL=icon-button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-button.d.ts","sourceRoot":"","sources":["../../src/button/icon-button.tsx"],"names":[],"mappings":"AAA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jB"}
|
|
@@ -4,6 +4,7 @@ import { Icon } from '../icon/icon';
|
|
|
4
4
|
import { Tooltip } from '../tooltip/tooltip';
|
|
5
5
|
import './button.css';
|
|
6
6
|
import { cx } from '../cx';
|
|
7
|
+
import { guardLoadingClick, guardLoadingKey } from './loading-interaction';
|
|
7
8
|
/**
|
|
8
9
|
* Square, icon-only button for the Manakind design system.
|
|
9
10
|
*
|
|
@@ -13,8 +14,10 @@ import { cx } from '../cx';
|
|
|
13
14
|
* is that `aria-label` is required at the type level — an icon-only
|
|
14
15
|
* button has no visible text to derive an accessible name from — and that
|
|
15
16
|
* it shows that name as a tooltip, since the glyph alone may not say it.
|
|
17
|
+
* Loading keeps keyboard focus with `aria-disabled` and `aria-busy`, blocking
|
|
18
|
+
* activation; an explicit `disabled` still uses native disabling.
|
|
16
19
|
*/
|
|
17
|
-
export function IconButton({ icon, variant = 'primary', size = 'md', loading = false, disabled, className, tooltip, ...props }) {
|
|
18
|
-
return (_jsx(Tooltip, { content: tooltip ?? props['aria-label'], kind: "label", children: _jsxs(ark.button, {
|
|
20
|
+
export function IconButton({ icon, variant = 'primary', size = 'md', loading = false, disabled, onClickCapture, onKeyDownCapture, onKeyUpCapture, className, tooltip, ...props }) {
|
|
21
|
+
return (_jsx(Tooltip, { content: tooltip ?? props['aria-label'], kind: "label", children: _jsxs(ark.button, { className: cx('ds-button', 'ds-button--icon-only', `ds-button--${variant}`, `ds-button--${size}`, loading && 'ds-button--loading', className), ...props, disabled: disabled, "aria-disabled": loading || props['aria-disabled'], "aria-busy": loading || props['aria-busy'], onClickCapture: guardLoadingClick(loading, onClickCapture), onKeyDownCapture: guardLoadingKey(loading, props['aria-haspopup'], onKeyDownCapture), onKeyUpCapture: guardLoadingKey(loading, props['aria-haspopup'], onKeyUpCapture), children: [loading && _jsx("span", { className: "ds-button__spinner", "aria-hidden": "true" }), _jsx(Icon, { source: icon, size: size, decorative: true, className: "ds-button__icon" })] }) }));
|
|
19
22
|
}
|
|
20
23
|
//# sourceMappingURL=icon-button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-button.js","sourceRoot":"","sources":["../../src/button/icon-button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AA+
|
|
1
|
+
{"version":3,"file":"icon-button.js","sourceRoot":"","sources":["../../src/button/icon-button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AA+B3E;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CAAC,EACzB,IAAI,EACJ,OAAO,GAAG,SAAS,EACnB,IAAI,GAAG,IAAI,EACX,OAAO,GAAG,KAAK,EACf,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,SAAS,EACT,OAAO,EACP,GAAG,KAAK,EACQ;IAChB,OAAO,CACL,KAAC,OAAO,IAAC,OAAO,EAAE,OAAO,IAAI,KAAK,CAAC,YAAY,CAAC,EAAE,IAAI,EAAC,OAAO,YAC5D,MAAC,GAAG,CAAC,MAAM,IACT,SAAS,EAAE,EAAE,CACX,WAAW,EACX,sBAAsB,EACtB,cAAc,OAAO,EAAE,EACvB,cAAc,IAAI,EAAE,EACpB,OAAO,IAAI,oBAAoB,EAC/B,SAAS,CACV,KACG,KAAK,EACT,QAAQ,EAAE,QAAQ,mBACH,OAAO,IAAI,KAAK,CAAC,eAAe,CAAC,eACrC,OAAO,IAAI,KAAK,CAAC,WAAW,CAAC,EACxC,cAAc,EAAE,iBAAiB,CAAC,OAAO,EAAE,cAAc,CAAC,EAC1D,gBAAgB,EAAE,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,eAAe,CAAC,EAAE,gBAAgB,CAAC,EACpF,cAAc,EAAE,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,eAAe,CAAC,EAAE,cAAc,CAAC,aAE/E,OAAO,IAAI,eAAM,SAAS,EAAC,oBAAoB,iBAAa,MAAM,GAAG,EACtE,KAAC,IAAI,IAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,QAAC,SAAS,EAAC,iBAAiB,GAAG,IAC9D,GACL,CACX,CAAC;AACJ,CAAC","sourcesContent":["import { ark } from '@ark-ui/react/factory';\nimport type { ComponentProps } from 'react';\nimport { Icon, type IconSource } from '../icon/icon';\nimport { Tooltip } from '../tooltip/tooltip';\nimport type { ButtonSize, ButtonVariant } from './button';\nimport './button.css';\nimport { cx } from '../cx';\nimport { guardLoadingClick, guardLoadingKey } from './loading-interaction';\n\nexport interface IconButtonProps\n extends Omit<ComponentProps<typeof ark.button>, 'children' | 'aria-label' | 'asChild' | 'title'> {\n /** Decorative icon rendered inside the button. */\n icon: IconSource;\n /**\n * Accessible label announced by assistive tech. Required because the\n * button has no visible text content to derive a name from.\n */\n 'aria-label': string;\n /** Visual style variant. Shared with {@link Button}. */\n variant?: ButtonVariant;\n /**\n * Size preset. The icon is the label, so it takes the icon scale's step of\n * the same name (16 / 24 / 32px) and the circle keeps the same inset around\n * it (32 / 40 / 48px). The circle is taller than a text `Button` of the\n * same size from `md` up.\n */\n size?: ButtonSize;\n /** Show a spinner and block activation while keeping keyboard focus. */\n loading?: boolean;\n /**\n * The caption shown on hover and keyboard focus. Defaults to `aria-label`;\n * pass a shorter one when the label carries the item's name for a screen\n * reader (\"Edit Run 10k\") and the caption only needs the verb (\"Edit\").\n * There is no `title`: the browser's own caption would show beside this one.\n */\n tooltip?: string;\n}\n\n/**\n * Square, icon-only button for the Manakind design system.\n *\n * Shares the full visual contract with `Button` (same variants, sizes,\n * focus ring, disabled + loading behavior) by reusing the `ds-button`\n * class plus a `ds-button--icon-only` modifier. The only API difference\n * is that `aria-label` is required at the type level — an icon-only\n * button has no visible text to derive an accessible name from — and that\n * it shows that name as a tooltip, since the glyph alone may not say it.\n * Loading keeps keyboard focus with `aria-disabled` and `aria-busy`, blocking\n * activation; an explicit `disabled` still uses native disabling.\n */\nexport function IconButton({\n icon,\n variant = 'primary',\n size = 'md',\n loading = false,\n disabled,\n onClickCapture,\n onKeyDownCapture,\n onKeyUpCapture,\n className,\n tooltip,\n ...props\n}: IconButtonProps) {\n return (\n <Tooltip content={tooltip ?? props['aria-label']} kind=\"label\">\n <ark.button\n className={cx(\n 'ds-button',\n 'ds-button--icon-only',\n `ds-button--${variant}`,\n `ds-button--${size}`,\n loading && 'ds-button--loading',\n className,\n )}\n {...props}\n disabled={disabled}\n aria-disabled={loading || props['aria-disabled']}\n aria-busy={loading || props['aria-busy']}\n onClickCapture={guardLoadingClick(loading, onClickCapture)}\n onKeyDownCapture={guardLoadingKey(loading, props['aria-haspopup'], onKeyDownCapture)}\n onKeyUpCapture={guardLoadingKey(loading, props['aria-haspopup'], onKeyUpCapture)}\n >\n {loading && <span className=\"ds-button__spinner\" aria-hidden=\"true\" />}\n <Icon source={icon} size={size} decorative className=\"ds-button__icon\" />\n </ark.button>\n </Tooltip>\n );\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AriaAttributes, KeyboardEventHandler, MouseEventHandler } from 'react';
|
|
2
|
+
/** Stop activation in capture, before consumer click handlers and the form's default action. */
|
|
3
|
+
export declare function guardLoadingClick(loading: boolean, handler: MouseEventHandler<HTMLButtonElement> | undefined): MouseEventHandler<HTMLButtonElement> | undefined;
|
|
4
|
+
/** Cancel activation before composed triggers dispatch their keyboard actions. */
|
|
5
|
+
export declare function guardLoadingKey(loading: boolean, popup: AriaAttributes['aria-haspopup'], handler: KeyboardEventHandler<HTMLButtonElement> | undefined): KeyboardEventHandler<HTMLButtonElement> | undefined;
|
|
6
|
+
//# sourceMappingURL=loading-interaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loading-interaction.d.ts","sourceRoot":"","sources":["../../src/button/loading-interaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAErF,gGAAgG;AAChG,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,GAAG,SAAS,GACxD,iBAAiB,CAAC,iBAAiB,CAAC,GAAG,SAAS,CAMlD;AAED,kFAAkF;AAClF,wBAAgB,eAAe,CAC7B,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,cAAc,CAAC,eAAe,CAAC,EACtC,OAAO,EAAE,oBAAoB,CAAC,iBAAiB,CAAC,GAAG,SAAS,GAC3D,oBAAoB,CAAC,iBAAiB,CAAC,GAAG,SAAS,CAerD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Stop activation in capture, before consumer click handlers and the form's default action. */
|
|
2
|
+
export function guardLoadingClick(loading, handler) {
|
|
3
|
+
if (!loading)
|
|
4
|
+
return handler;
|
|
5
|
+
return (event) => {
|
|
6
|
+
event.preventDefault();
|
|
7
|
+
event.stopPropagation();
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/** Cancel activation before composed triggers dispatch their keyboard actions. */
|
|
11
|
+
export function guardLoadingKey(loading, popup, handler) {
|
|
12
|
+
if (!loading)
|
|
13
|
+
return handler;
|
|
14
|
+
const hasPopup = Boolean(popup && popup !== 'false');
|
|
15
|
+
return (event) => {
|
|
16
|
+
if (event.key === 'Enter' ||
|
|
17
|
+
event.key === ' ' ||
|
|
18
|
+
(hasPopup && (event.key === 'ArrowDown' || event.key === 'ArrowUp'))) {
|
|
19
|
+
event.preventDefault();
|
|
20
|
+
event.stopPropagation();
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
handler?.(event);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=loading-interaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loading-interaction.js","sourceRoot":"","sources":["../../src/button/loading-interaction.ts"],"names":[],"mappings":"AAEA,gGAAgG;AAChG,MAAM,UAAU,iBAAiB,CAC/B,OAAgB,EAChB,OAAyD;IAEzD,IAAI,CAAC,OAAO;QAAE,OAAO,OAAO,CAAC;IAC7B,OAAO,CAAC,KAAK,EAAE,EAAE;QACf,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,KAAK,CAAC,eAAe,EAAE,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,eAAe,CAC7B,OAAgB,EAChB,KAAsC,EACtC,OAA4D;IAE5D,IAAI,CAAC,OAAO;QAAE,OAAO,OAAO,CAAC;IAC7B,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,KAAK,OAAO,CAAC,CAAC;IACrD,OAAO,CAAC,KAAK,EAAE,EAAE;QACf,IACE,KAAK,CAAC,GAAG,KAAK,OAAO;YACrB,KAAK,CAAC,GAAG,KAAK,GAAG;YACjB,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,GAAG,KAAK,WAAW,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,EACpE,CAAC;YACD,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,KAAK,CAAC,eAAe,EAAE,CAAC;YACxB,OAAO;QACT,CAAC;QACD,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { AriaAttributes, KeyboardEventHandler, MouseEventHandler } from 'react';\n\n/** Stop activation in capture, before consumer click handlers and the form's default action. */\nexport function guardLoadingClick(\n loading: boolean,\n handler: MouseEventHandler<HTMLButtonElement> | undefined,\n): MouseEventHandler<HTMLButtonElement> | undefined {\n if (!loading) return handler;\n return (event) => {\n event.preventDefault();\n event.stopPropagation();\n };\n}\n\n/** Cancel activation before composed triggers dispatch their keyboard actions. */\nexport function guardLoadingKey(\n loading: boolean,\n popup: AriaAttributes['aria-haspopup'],\n handler: KeyboardEventHandler<HTMLButtonElement> | undefined,\n): KeyboardEventHandler<HTMLButtonElement> | undefined {\n if (!loading) return handler;\n const hasPopup = Boolean(popup && popup !== 'false');\n return (event) => {\n if (\n event.key === 'Enter' ||\n event.key === ' ' ||\n (hasPopup && (event.key === 'ArrowDown' || event.key === 'ArrowUp'))\n ) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n handler?.(event);\n };\n}\n"]}
|
|
@@ -50,9 +50,8 @@ interface CalendarCommonProps {
|
|
|
50
50
|
/** Shows the days and the choice, pages freely, but lets nothing be chosen. */
|
|
51
51
|
readOnly?: boolean;
|
|
52
52
|
/**
|
|
53
|
-
* Glyph for the "previous month" button. Defaults to
|
|
54
|
-
*
|
|
55
|
-
* own icon set.
|
|
53
|
+
* Glyph for the "previous month" button. Defaults to the
|
|
54
|
+
* `IconDefaultsProvider`'s `chevronLeft`, or a plain built-in one.
|
|
56
55
|
*/
|
|
57
56
|
previousIcon?: IconSource;
|
|
58
57
|
/** Glyph for the "next month" button. Same defaulting rule as {@link CalendarCommonProps.previousIcon}. */
|
|
@@ -110,6 +109,6 @@ export type CalendarProps = CalendarCommonProps & CalendarSelection;
|
|
|
110
109
|
* <Calendar aria-label="Scheduled day" value={day} onValueChange={setDay} autoFocus />
|
|
111
110
|
* ```
|
|
112
111
|
*/
|
|
113
|
-
export declare function Calendar({ 'aria-label': ariaLabel, locale, startOfWeek, min, max, defaultMonth, autoFocus, disabled, readOnly, previousIcon, nextIcon, className, ...selection }: CalendarProps): import("react/jsx-runtime").JSX.Element;
|
|
112
|
+
export declare function Calendar({ 'aria-label': ariaLabel, locale, startOfWeek, min, max, defaultMonth, autoFocus, disabled, readOnly, previousIcon: previousIconProp, nextIcon: nextIconProp, className, ...selection }: CalendarProps): import("react/jsx-runtime").JSX.Element;
|
|
114
113
|
export {};
|
|
115
114
|
//# sourceMappingURL=calendar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../src/calendar/calendar.tsx"],"names":[],"mappings":"AAGA,OAAO,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../src/calendar/calendar.tsx"],"names":[],"mappings":"AAGA,OAAO,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI/C;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB;AAED,kFAAkF;AAClF,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAExD,UAAU,mBAAmB;IAC3B;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2FAA2F;IAC3F,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAC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