@manakind/ui-core 0.28.0 → 0.29.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 +2 -2
- 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/side-panel-layout/side-panel-layout.css +17 -1
- package/dist/side-panel-layout/side-panel-layout.d.ts +7 -4
- package/dist/side-panel-layout/side-panel-layout.d.ts.map +1 -1
- package/dist/side-panel-layout/side-panel-layout.js +7 -4
- package/dist/side-panel-layout/side-panel-layout.js.map +1 -1
- package/dist/sticky/sticky.css +10 -0
- 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 +1 -1
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
|
|
|
@@ -62,7 +62,7 @@ separately, so an app can load only what it renders.
|
|
|
62
62
|
| `@manakind/ui-core/avatar` | `Avatar` + `initialsOf` |
|
|
63
63
|
| `@manakind/ui-core/badge` | `Badge` |
|
|
64
64
|
| `@manakind/ui-core/breadcrumb` | `Breadcrumb` |
|
|
65
|
-
| `@manakind/ui-core/button` | `Button` + `IconButton
|
|
65
|
+
| `@manakind/ui-core/button` | `Button` + `IconButton`; loading retains keyboard focus and blocks activation/form submission |
|
|
66
66
|
| `@manakind/ui-core/calendar` | `Calendar` |
|
|
67
67
|
| `@manakind/ui-core/card` | `Card`, `CardHeader`, `CardTitle`, `CardLink`, `CardDescription`, `CardContent`, `CardFooter` |
|
|
68
68
|
| `@manakind/ui-core/dialog` | `Dialog` + `DialogClose` |
|
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","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;AAItB,MAAM,MAAM,aAAa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|
|
|
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,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;AAC3B,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AA8E3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AO,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":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"icon-button.d.ts","sourceRoot":"","sources":["../../src/button/icon-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,cAAc,CAAC;AAItB,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,YAAY,GAAG,SAAS,GAAG,OAAO,CAAC;IAChG,kDAAkD;IAClD,IAAI,EAAE,UAAU,CAAC;IACjB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,wEAAwE;IACxE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,OAAmB,EACnB,IAAW,EACX,OAAe,EACf,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,SAAS,EACT,OAAO,EACP,GAAG,KAAK,EACT,EAAE,eAAe,2CAyBjB"}
|
|
@@ -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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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"]}
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* `lg` step the panel goes above the content, in the flow, as a band across
|
|
6
6
|
* the layout's width: the layout sits outside the page's padding, so the
|
|
7
7
|
* panel squares its corners and keeps only its top and bottom borders, and
|
|
8
|
-
* the page's own padding spaces the content from it.
|
|
8
|
+
* the page's own padding spaces the content from it. The content is a
|
|
9
|
+
* column that fills the layout's height, so an app's footer placed in it
|
|
10
|
+
* after a growing page sits at the foot of a short one. Breakpoints are
|
|
9
11
|
* viewport tokens written as literals (`check:breakpoints`).
|
|
10
12
|
*/
|
|
11
13
|
.ds-side-panel-layout {
|
|
@@ -14,6 +16,9 @@
|
|
|
14
16
|
min-width: 0;
|
|
15
17
|
|
|
16
18
|
& > .ds-side-panel-layout__main {
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
flex-grow: 1;
|
|
17
22
|
min-width: 0;
|
|
18
23
|
}
|
|
19
24
|
|
|
@@ -31,6 +36,17 @@
|
|
|
31
36
|
border-inline-width: 0;
|
|
32
37
|
border-radius: 0;
|
|
33
38
|
}
|
|
39
|
+
|
|
40
|
+
/*
|
|
41
|
+
* A panel that replaces another opens while the one it closed is still
|
|
42
|
+
* in the slot for a render; the newer is portalled in last. Taking the
|
|
43
|
+
* older out of the layout at once lets the newer scroll into view
|
|
44
|
+
* against the page as it will be, rather than scroll past the older
|
|
45
|
+
* and then jump back when it leaves.
|
|
46
|
+
*/
|
|
47
|
+
& > .ds-dialog:not(:last-child) {
|
|
48
|
+
display: none;
|
|
49
|
+
}
|
|
34
50
|
}
|
|
35
51
|
}
|
|
36
52
|
|
|
@@ -19,10 +19,13 @@ export type SidePanelLayoutProps = Omit<ComponentProps<typeof ark.div>, 'asChild
|
|
|
19
19
|
* header and with nothing after it in the page: the drawer is as tall as the
|
|
20
20
|
* viewport below the header and can't leave the layout, so content above the
|
|
21
21
|
* layout pushes its foot off the screen and content after it lifts its top
|
|
22
|
-
* under the header.
|
|
23
|
-
* page
|
|
24
|
-
*
|
|
25
|
-
*
|
|
22
|
+
* under the header. An app's footer therefore goes inside the layout, after
|
|
23
|
+
* the page, where the drawer narrows it as it does the page; the content is a
|
|
24
|
+
* column that fills the layout's height, so with the page growing
|
|
25
|
+
* (`Frame grow`) the footer sits at the foot of a short page. Below `lg` the
|
|
26
|
+
* panel goes above the content, in the page's flow, and pushes it down. With
|
|
27
|
+
* no panel open the content takes the whole width. One panel shows at a time:
|
|
28
|
+
* opening another closes the one that was open.
|
|
26
29
|
*
|
|
27
30
|
* ```tsx
|
|
28
31
|
* <SidePanelLayout>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"side-panel-layout.d.ts","sourceRoot":"","sources":["../../src/side-panel-layout/side-panel-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,KAAK,cAAc,EAA0C,MAAM,OAAO,CAAC;AAGpF,OAAO,yBAAyB,CAAC;AAEjC;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;AAEnF
|
|
1
|
+
{"version":3,"file":"side-panel-layout.d.ts","sourceRoot":"","sources":["../../src/side-panel-layout/side-panel-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,KAAK,cAAc,EAA0C,MAAM,OAAO,CAAC;AAGpF,OAAO,yBAAyB,CAAC;AAEjC;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;AAEnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,eAAe,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,oBAAoB,2CAqBtF"}
|
|
@@ -17,10 +17,13 @@ import './side-panel-layout.css';
|
|
|
17
17
|
* header and with nothing after it in the page: the drawer is as tall as the
|
|
18
18
|
* viewport below the header and can't leave the layout, so content above the
|
|
19
19
|
* layout pushes its foot off the screen and content after it lifts its top
|
|
20
|
-
* under the header.
|
|
21
|
-
* page
|
|
22
|
-
*
|
|
23
|
-
*
|
|
20
|
+
* under the header. An app's footer therefore goes inside the layout, after
|
|
21
|
+
* the page, where the drawer narrows it as it does the page; the content is a
|
|
22
|
+
* column that fills the layout's height, so with the page growing
|
|
23
|
+
* (`Frame grow`) the footer sits at the foot of a short page. Below `lg` the
|
|
24
|
+
* panel goes above the content, in the page's flow, and pushes it down. With
|
|
25
|
+
* no panel open the content takes the whole width. One panel shows at a time:
|
|
26
|
+
* opening another closes the one that was open.
|
|
24
27
|
*
|
|
25
28
|
* ```tsx
|
|
26
29
|
* <SidePanelLayout>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"side-panel-layout.js","sourceRoot":"","sources":["../../src/side-panel-layout/side-panel-layout.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAuB,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpF,OAAO,EAAE,EAAE,EAAE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EtF,OAAO,CACL,KAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,YACxC,MAAC,GAAG,CAAC,GAAG,IAAC,SAAS,EAAE,EAAE,CAAC,sBAAsB,EAAE,SAAS,CAAC,KAAM,KAAK,aAClE,cAAK,SAAS,EAAC,4BAA4B,YAAE,QAAQ,GAAO,EAC5D,cAAK,GAAG,EAAE,YAAY,EAAE,SAAS,EAAC,6BAA6B,GAAG,IAC1D,GACoB,CACjC,CAAC;AACJ,CAAC","sourcesContent":["import { ark } from '@ark-ui/react/factory';\nimport { type ComponentProps, useCallback, useMemo, useRef, useState } from 'react';\nimport { cx } from '../cx';\nimport { type SidePanelSlot, SidePanelSlotContext } from './side-panel-context';\nimport './side-panel-layout.css';\n\n/**\n * No `asChild`: the layout renders its content and its panel slot, and Ark's\n * `asChild` clones exactly one.\n */\nexport type SidePanelLayoutProps = Omit<ComponentProps<typeof ark.div>, 'asChild'>;\n\n/**\n * Content with room for a side panel: a `Dialog` with `presentation=\"side\"`\n * opened anywhere inside it opens beside the content and narrows it, so the\n * list it was opened from stays in view and usable.\n *\n * From the `lg` viewport step up the panel is a drawer at the layout's end\n * edge, from under the app's header (`--ds-sticky-offset-top`) to the bottom\n * of the viewport, and the content gives up its width rather than being\n * covered. Put the layout outside the page's own padding, around the page\n * template, so the drawer meets the window's edge, directly under the app's\n * header and with nothing after it in the page: the drawer is as tall as the\n * viewport below the header and can't leave the layout, so content above the\n * layout pushes its foot off the screen and content after it lifts its top\n * under the header. An app's footer therefore goes inside the layout, after\n * the page, where the drawer narrows it as it does the page; the content is a\n * column that fills the layout's height, so with the page growing\n * (`Frame grow`) the footer sits at the foot of a short page. Below `lg` the\n * panel goes above the content, in the page's flow, and pushes it down. With\n * no panel open the content takes the whole width. One panel shows at a time:\n * opening another closes the one that was open.\n *\n * ```tsx\n * <SidePanelLayout>\n * <PageLayout>\n * <ActionList />\n * <Dialog presentation=\"side\" title=\"Add action\" trigger={<Button>Add action</Button>}>\n * <ActionForm />\n * </Dialog>\n * </PageLayout>\n * </SidePanelLayout>\n * ```\n */\nexport function SidePanelLayout({ className, children, ...props }: SidePanelLayoutProps) {\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const closeHolder = useRef<(() => void) | null>(null);\n const claim = useCallback((close: () => void) => {\n const previous = closeHolder.current;\n closeHolder.current = close;\n previous?.();\n return () => {\n if (closeHolder.current === close) closeHolder.current = null;\n };\n }, []);\n const slot = useMemo<SidePanelSlot>(() => ({ container, claim }), [container, claim]);\n\n return (\n <SidePanelSlotContext.Provider value={slot}>\n <ark.div className={cx('ds-side-panel-layout', className)} {...props}>\n <div className=\"ds-side-panel-layout__main\">{children}</div>\n <div ref={setContainer} className=\"ds-side-panel-layout__panel\" />\n </ark.div>\n </SidePanelSlotContext.Provider>\n );\n}\n"]}
|
package/dist/sticky/sticky.css
CHANGED
|
@@ -24,6 +24,16 @@
|
|
|
24
24
|
bottom: var(--_sticky-inset);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
/*
|
|
28
|
+
* The app's header fills the inset the chrome's offset keeps clear of,
|
|
29
|
+
* so a bar or a side panel under it starts where it ends.
|
|
30
|
+
*/
|
|
31
|
+
&.ds-sticky--header {
|
|
32
|
+
display: grid;
|
|
33
|
+
align-content: center;
|
|
34
|
+
min-block-size: var(--ds-sticky-offset-top);
|
|
35
|
+
}
|
|
36
|
+
|
|
27
37
|
&.ds-sticky--top.ds-sticky--offset {
|
|
28
38
|
--_sticky-inset: var(--ds-sticky-offset-top);
|
|
29
39
|
}
|
package/dist/sticky/sticky.d.ts
CHANGED
|
@@ -30,6 +30,12 @@ export interface StickyProps extends ComponentProps<typeof ark.div> {
|
|
|
30
30
|
scroll?: boolean;
|
|
31
31
|
/** What it paints behind itself. Defaults to `none`. */
|
|
32
32
|
surface?: StickySurface;
|
|
33
|
+
/**
|
|
34
|
+
* The app's header itself: at least as tall as `--ds-sticky-offset-top`,
|
|
35
|
+
* where every offset bar and side panel under it starts, with its content
|
|
36
|
+
* centred in that height. Takes no `offset`.
|
|
37
|
+
*/
|
|
38
|
+
header?: boolean;
|
|
33
39
|
}
|
|
34
40
|
/**
|
|
35
41
|
* An element that holds to an edge of the viewport while the page scrolls
|
|
@@ -41,7 +47,7 @@ export interface StickyProps extends ComponentProps<typeof ark.div> {
|
|
|
41
47
|
* settles into its own place when the page ends, with nothing to clear.
|
|
42
48
|
* Sits on the `sticky` stacking layer, above the page's raised controls
|
|
43
49
|
* and below every overlay. Renders a `div`; pass `asChild` to stick your
|
|
44
|
-
* own element (`<Sticky asChild><header>…</header></Sticky>`).
|
|
50
|
+
* own element (`<Sticky asChild header><header>…</header></Sticky>`).
|
|
45
51
|
*/
|
|
46
|
-
export declare function Sticky({ edge, offset, from, scroll, surface, className, children, ...props }: StickyProps): import("react/jsx-runtime").JSX.Element;
|
|
52
|
+
export declare function Sticky({ edge, offset, from, scroll, surface, header, className, children, ...props }: StickyProps): import("react/jsx-runtime").JSX.Element;
|
|
47
53
|
//# sourceMappingURL=sticky.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sticky.d.ts","sourceRoot":"","sources":["../../src/sticky/sticky.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,kFAAkF;AAClF,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,QAAQ,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEzD,MAAM,WAAW,WAAY,SAAQ,cAAc,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC;IACjE,+CAA+C;IAC/C,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB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-12,9 +12,9 @@ import { cx } from '../cx';
|
|
|
12
12
|
* settles into its own place when the page ends, with nothing to clear.
|
|
13
13
|
* Sits on the `sticky` stacking layer, above the page's raised controls
|
|
14
14
|
* and below every overlay. Renders a `div`; pass `asChild` to stick your
|
|
15
|
-
* own element (`<Sticky asChild><header>…</header></Sticky>`).
|
|
15
|
+
* own element (`<Sticky asChild header><header>…</header></Sticky>`).
|
|
16
16
|
*/
|
|
17
|
-
export function Sticky({ edge = 'top', offset = false, from, scroll = false, surface = 'none', className, children, ...props }) {
|
|
18
|
-
return (_jsx(ark.div, { className: cx('ds-sticky', `ds-sticky--${edge}`, offset && 'ds-sticky--offset', from && `ds-sticky--from-${from}`, scroll && 'ds-sticky--scroll', surface !== 'none' && `ds-sticky--surface-${surface}`, className), ...props, children: children }));
|
|
17
|
+
export function Sticky({ edge = 'top', offset = false, from, scroll = false, surface = 'none', header = false, className, children, ...props }) {
|
|
18
|
+
return (_jsx(ark.div, { className: cx('ds-sticky', `ds-sticky--${edge}`, offset && 'ds-sticky--offset', from && `ds-sticky--from-${from}`, scroll && 'ds-sticky--scroll', surface !== 'none' && `ds-sticky--surface-${surface}`, header && 'ds-sticky--header', className), ...props, children: children }));
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=sticky.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sticky.js","sourceRoot":"","sources":["../../src/sticky/sticky.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"sticky.js","sourceRoot":"","sources":["../../src/sticky/sticky.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAyC3B;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,MAAM,CAAC,EACrB,IAAI,GAAG,KAAK,EACZ,MAAM,GAAG,KAAK,EACd,IAAI,EACJ,MAAM,GAAG,KAAK,EACd,OAAO,GAAG,MAAM,EAChB,MAAM,GAAG,KAAK,EACd,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACI;IACZ,OAAO,CACL,KAAC,GAAG,CAAC,GAAG,IACN,SAAS,EAAE,EAAE,CACX,WAAW,EACX,cAAc,IAAI,EAAE,EACpB,MAAM,IAAI,mBAAmB,EAC7B,IAAI,IAAI,mBAAmB,IAAI,EAAE,EACjC,MAAM,IAAI,mBAAmB,EAC7B,OAAO,KAAK,MAAM,IAAI,sBAAsB,OAAO,EAAE,EACrD,MAAM,IAAI,mBAAmB,EAC7B,SAAS,CACV,KACG,KAAK,YAER,QAAQ,GACD,CACX,CAAC;AACJ,CAAC","sourcesContent":["import { ark } from '@ark-ui/react/factory';\nimport type { ComponentProps } from 'react';\nimport './sticky.css';\nimport { cx } from '../cx';\nimport type { Breakpoint } from '../layout/layout';\n\n/** The viewport edge a sticky element holds to while the page scrolls past it. */\nexport type StickyEdge = 'top' | 'bottom';\n\n/**\n * What a sticky element paints behind itself. `none` leaves the children\n * to draw their own surface (a card); `canvas` paints the page's canvas so\n * content scrolling under it is covered, with the bar's block inset;\n * `raised` is the chrome's surface with a hairline and shadow on the side\n * facing the page.\n */\nexport type StickySurface = 'none' | 'canvas' | 'raised';\n\nexport interface StickyProps extends ComponentProps<typeof ark.div> {\n /** The edge it holds to. Defaults to `top`. */\n edge?: StickyEdge;\n /**\n * Keep clear of the app's chrome: under the header at the top\n * (`--ds-sticky-offset-top`), above the viewport's edge at the bottom\n * (`--ds-sticky-offset-bottom`). Off by default, for the header itself.\n */\n offset?: boolean;\n /** Stick only from this viewport step up; stay in the flow on narrower viewports. */\n from?: Breakpoint;\n /**\n * Scroll inside its own box when taller than the room it holds, instead\n * of pushing past the viewport: a pinned aside longer than the screen.\n */\n scroll?: boolean;\n /** What it paints behind itself. Defaults to `none`. */\n surface?: StickySurface;\n /**\n * The app's header itself: at least as tall as `--ds-sticky-offset-top`,\n * where every offset bar and side panel under it starts, with its content\n * centred in that height. Takes no `offset`.\n */\n header?: boolean;\n}\n\n/**\n * An element that holds to an edge of the viewport while the page scrolls\n * past it: the app's header, a filter row under it, a bar of bulk actions\n * at the foot of a list, an aside pinned beside a long form.\n *\n * Sticky, never fixed, so it stays in the page's flow and column: a bottom\n * bar at the end of a page floats above the rows while they scroll and\n * settles into its own place when the page ends, with nothing to clear.\n * Sits on the `sticky` stacking layer, above the page's raised controls\n * and below every overlay. Renders a `div`; pass `asChild` to stick your\n * own element (`<Sticky asChild header><header>…</header></Sticky>`).\n */\nexport function Sticky({\n edge = 'top',\n offset = false,\n from,\n scroll = false,\n surface = 'none',\n header = false,\n className,\n children,\n ...props\n}: StickyProps) {\n return (\n <ark.div\n className={cx(\n 'ds-sticky',\n `ds-sticky--${edge}`,\n offset && 'ds-sticky--offset',\n from && `ds-sticky--from-${from}`,\n scroll && 'ds-sticky--scroll',\n surface !== 'none' && `ds-sticky--surface-${surface}`,\n header && 'ds-sticky--header',\n className,\n )}\n {...props}\n >\n {children}\n </ark.div>\n );\n}\n"]}
|