@kanso-labs/kanso-ui 0.40.9 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/color-scheme.d.ts +6 -0
- package/dist/color-scheme.js +9 -2
- package/dist/color-scheme.js.map +1 -1
- package/dist/components/app-bar/index.d.ts +16 -6
- package/dist/components/app-bar/index.js +54 -48
- package/dist/components/app-bar/index.js.map +1 -1
- package/dist/components/avatar/index.d.ts +28 -2
- package/dist/components/avatar/index.js +3 -0
- package/dist/components/avatar/index.js.map +1 -1
- package/dist/components/card/index.d.ts +12 -1
- package/dist/components/card/index.js +136 -66
- package/dist/components/card/index.js.map +1 -1
- package/dist/components/dialog/index.js +3 -2
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/popover/index.js +3 -2
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/product-icon/index.d.ts +18 -0
- package/dist/components/product-icon/index.js +3 -0
- package/dist/components/product-icon/index.js.map +1 -1
- package/dist/components/segmented-button/index.d.ts +3 -0
- package/dist/components/segmented-button/index.js +131 -65
- package/dist/components/segmented-button/index.js.map +1 -1
- package/dist/components/separator/index.js +2 -2
- package/dist/components/separator/index.js.map +1 -1
- package/dist/components/sheet/index.js +17 -16
- package/dist/components/sheet/index.js.map +1 -1
- package/dist/components/snackbar/index.d.ts +10 -3
- package/dist/components/snackbar/index.js +32 -12
- package/dist/components/snackbar/index.js.map +1 -1
- package/dist/components/switch/index.js +12 -3
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/toolbar/index.d.ts +3 -2
- package/dist/components/toolbar/index.js +3 -2
- package/dist/components/toolbar/index.js.map +1 -1
- package/dist/field/index.js +75 -48
- package/dist/field/index.js.map +1 -1
- package/dist/glyphs/index.js +19 -1
- package/dist/glyphs/index.js.map +1 -1
- package/dist/hooks/useImageLoadingStatus.js +56 -45
- package/dist/hooks/useImageLoadingStatus.js.map +1 -1
- package/dist/mark/index.js +126 -86
- package/dist/mark/index.js.map +1 -1
- package/dist/mark/styles.js +14 -0
- package/dist/mark/styles.js.map +1 -1
- package/dist/overlay/index.js +24 -0
- package/dist/overlay/index.js.map +1 -0
- package/dist/styles/scheme.js +19 -0
- package/dist/styles/scheme.js.map +1 -0
- package/dist/styles.css +94 -26
- package/dist/theme-scope.d.ts +5 -2
- package/dist/theme-scope.js +2 -1
- package/dist/theme-scope.js.map +1 -1
- package/package.json +2 -2
package/dist/color-scheme.d.ts
CHANGED
|
@@ -26,6 +26,12 @@ declare const themeScope: string;
|
|
|
26
26
|
*
|
|
27
27
|
* A `--kui-color-*` override still applies under either, declared on the
|
|
28
28
|
* same element or above it.
|
|
29
|
+
*
|
|
30
|
+
* Either also paints the element's surface and text in its scheme and sets
|
|
31
|
+
* `color-scheme`, which native controls and scrollbars follow, as
|
|
32
|
+
* `ThemeScope` does with `scheme` set. On `<html>` that makes the page's
|
|
33
|
+
* own background and text colour the scheme's; an app's own stylesheet
|
|
34
|
+
* still wins over both, since the library's rules sit in a cascade layer.
|
|
29
35
|
*/
|
|
30
36
|
declare const colorScheme: {
|
|
31
37
|
dark: string;
|
package/dist/color-scheme.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { props } from "./node_modules/@stylexjs/stylex/lib/es/stylex.js";
|
|
2
2
|
import { colorDefaultsDarkTheme, colorDefaultsLightTheme, tokenScope } from "./tokens/design.tokens.stylex.js";
|
|
3
|
+
import { pinnedScheme } from "./styles/scheme.js";
|
|
3
4
|
//#region src/color-scheme.ts
|
|
4
5
|
/**
|
|
5
6
|
* The class that lets an element theme what is inside it. A `--kui-*`
|
|
@@ -28,10 +29,16 @@ const themeScope = props(tokenScope).className ?? "";
|
|
|
28
29
|
*
|
|
29
30
|
* A `--kui-color-*` override still applies under either, declared on the
|
|
30
31
|
* same element or above it.
|
|
32
|
+
*
|
|
33
|
+
* Either also paints the element's surface and text in its scheme and sets
|
|
34
|
+
* `color-scheme`, which native controls and scrollbars follow, as
|
|
35
|
+
* `ThemeScope` does with `scheme` set. On `<html>` that makes the page's
|
|
36
|
+
* own background and text colour the scheme's; an app's own stylesheet
|
|
37
|
+
* still wins over both, since the library's rules sit in a cascade layer.
|
|
31
38
|
*/
|
|
32
39
|
const colorScheme = {
|
|
33
|
-
dark: props(tokenScope, colorDefaultsDarkTheme).className ?? "",
|
|
34
|
-
light: props(tokenScope, colorDefaultsLightTheme).className ?? ""
|
|
40
|
+
dark: props(tokenScope, colorDefaultsDarkTheme, pinnedScheme.dark).className ?? "",
|
|
41
|
+
light: props(tokenScope, colorDefaultsLightTheme, pinnedScheme.light).className ?? ""
|
|
35
42
|
};
|
|
36
43
|
//#endregion
|
|
37
44
|
export { colorScheme, themeScope };
|
package/dist/color-scheme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-scheme.js","names":["stylex","colorDefaultsDarkTheme","colorDefaultsLightTheme","tokenScope","themeScope","props","className","colorScheme","dark","light","stylex.props"],"sources":["../src/color-scheme.ts"],"sourcesContent":["import * as stylex from '@stylexjs/stylex';\nimport { colorDefaultsDarkTheme, colorDefaultsLightTheme, tokenScope } from './tokens/design.tokens.stylex';\n\n// The library's tokens resolve once, on `:root`, and follow the reader's OS\n// through `prefers-color-scheme` unless something says otherwise. These are\n// the classes that say otherwise, for a page that cannot or would rather not\n// render `ThemeScope`: `themeScope` resolves every token again on the element\n// it lands on, and each `colorScheme` class does that and pins the scheme\n// too. All three were generated for Storybook first, where the Theme control\n// uses the scheme pair; nothing in the package named them, so an app with a\n// switch of its own had to restate every colour token under its own\n// selector, twice — dark for a light OS, light for a dark one.\n//\n// A server module like the entry, since it is three strings.\n\n/**\n * The class that lets an element theme what is inside it. A `--kui-*`\n * override declared on that element, or on one around it, reaches every\n * component rendered inside, where on any element but `<html>` it would\n * otherwise reach none — the tokens resolve on `:root` and are inherited from\n * there already resolved. The scheme is inherited from around it, so a scope\n * inside a dark page stays dark.\n *\n * Overlays are portalled to the body, outside the element, so they keep the\n * page's tokens; `ThemeScope` is the same class with a portal container of\n * its own, which takes them along.\n */\nconst themeScope = stylex.props(tokenScope).className ?? '';\n\n/**\n * The classes that pin the library's colours to its light or its dark\n * scheme, whatever the reader's OS asks for — for an app with a theme switch\n * of its own. Put one on the `<html>` element, where overlays portalled to\n * the body still sit inside it; with neither there, the colours follow the\n * OS as they always have. Each is also a {@link themeScope}, so either on a\n * smaller element pins and scopes the subtree under it.\n *\n * Shaped as an object of class names, one per scheme. Each name is several\n * classes separated by spaces, so add them with `className` rather than\n * `classList.add`, which takes one class per argument.\n *\n * A `--kui-color-*` override still applies under either, declared on the\n * same element or above it.\n */\nconst colorScheme = {\n dark: stylex.props(tokenScope, colorDefaultsDarkTheme).className ?? '',\n light: stylex.props(tokenScope, colorDefaultsLightTheme).className ?? ''\n};\nexport { colorScheme, themeScope };"],"mappings":"
|
|
1
|
+
{"version":3,"file":"color-scheme.js","names":["stylex","pinnedScheme","colorDefaultsDarkTheme","colorDefaultsLightTheme","tokenScope","themeScope","props","className","colorScheme","dark","light","stylex.props"],"sources":["../src/color-scheme.ts"],"sourcesContent":["import * as stylex from '@stylexjs/stylex';\nimport { pinnedScheme } from './styles/scheme';\nimport { colorDefaultsDarkTheme, colorDefaultsLightTheme, tokenScope } from './tokens/design.tokens.stylex';\n\n// The library's tokens resolve once, on `:root`, and follow the reader's OS\n// through `prefers-color-scheme` unless something says otherwise. These are\n// the classes that say otherwise, for a page that cannot or would rather not\n// render `ThemeScope`: `themeScope` resolves every token again on the element\n// it lands on, and each `colorScheme` class does that and pins the scheme\n// too. All three were generated for Storybook first, where the Theme control\n// uses the scheme pair; nothing in the package named them, so an app with a\n// switch of its own had to restate every colour token under its own\n// selector, twice — dark for a light OS, light for a dark one.\n//\n// A server module like the entry, since it is three strings.\n\n/**\n * The class that lets an element theme what is inside it. A `--kui-*`\n * override declared on that element, or on one around it, reaches every\n * component rendered inside, where on any element but `<html>` it would\n * otherwise reach none — the tokens resolve on `:root` and are inherited from\n * there already resolved. The scheme is inherited from around it, so a scope\n * inside a dark page stays dark.\n *\n * Overlays are portalled to the body, outside the element, so they keep the\n * page's tokens; `ThemeScope` is the same class with a portal container of\n * its own, which takes them along.\n */\nconst themeScope = stylex.props(tokenScope).className ?? '';\n\n/**\n * The classes that pin the library's colours to its light or its dark\n * scheme, whatever the reader's OS asks for — for an app with a theme switch\n * of its own. Put one on the `<html>` element, where overlays portalled to\n * the body still sit inside it; with neither there, the colours follow the\n * OS as they always have. Each is also a {@link themeScope}, so either on a\n * smaller element pins and scopes the subtree under it.\n *\n * Shaped as an object of class names, one per scheme. Each name is several\n * classes separated by spaces, so add them with `className` rather than\n * `classList.add`, which takes one class per argument.\n *\n * A `--kui-color-*` override still applies under either, declared on the\n * same element or above it.\n *\n * Either also paints the element's surface and text in its scheme and sets\n * `color-scheme`, which native controls and scrollbars follow, as\n * `ThemeScope` does with `scheme` set. On `<html>` that makes the page's\n * own background and text colour the scheme's; an app's own stylesheet\n * still wins over both, since the library's rules sit in a cascade layer.\n */\nconst colorScheme = {\n dark: stylex.props(tokenScope, colorDefaultsDarkTheme, pinnedScheme.dark).className ?? '',\n light: stylex.props(tokenScope, colorDefaultsLightTheme, pinnedScheme.light).className ?? ''\n};\nexport { colorScheme, themeScope };"],"mappings":";;;;;;;;;;;;;;;;AA4BA,MAAMK,aAAaL,MAAaI,UAAU,CAAC,CAACG,aAAa;;;;;;;;;;;;;;;;;;;;;;AAuBzD,MAAMC,cAAc;CAClBC,MAAMT,MAAaI,YAAYF,wBAAwBD,aAAaQ,IAAI,CAAC,CAACF,aAAa;CACvFG,OAAOV,MAAaI,YAAYD,yBAAyBF,aAAaS,KAAK,CAAC,CAACH,aAAa;AAC5F"}
|
|
@@ -10,7 +10,7 @@ type AppBarProps = Omit<RenderComponentProps<'header'>, 'children'> & {
|
|
|
10
10
|
align?: 'center' | 'start';
|
|
11
11
|
/**
|
|
12
12
|
* Collapses a flexible bar to the height and headline of the small one, for
|
|
13
|
-
* a pinned
|
|
13
|
+
* a bar `pinned` over content that has been scrolled. Material Design
|
|
14
14
|
* specifies it for the flexible sizes, and without it a pinned `lg` costs
|
|
15
15
|
* 152px of the viewport for as long as the page is open.
|
|
16
16
|
*
|
|
@@ -66,16 +66,26 @@ type AppBarProps = Omit<RenderComponentProps<'header'>, 'children'> & {
|
|
|
66
66
|
*/
|
|
67
67
|
contentMaxInlineSize?: string;
|
|
68
68
|
/**
|
|
69
|
-
* Where the headline sits in the page's outline
|
|
70
|
-
* between headings, so a bar drawn beside
|
|
71
|
-
* heading of its own, should lower it.
|
|
69
|
+
* Where the headline sits in the page's outline, as one of the six heading
|
|
70
|
+
* levels. A screen reader moves between headings, so a bar drawn beside
|
|
71
|
+
* another bar, or under a page heading of its own, should lower it. A value
|
|
72
|
+
* outside the six that reaches it untyped falls back to 1.
|
|
72
73
|
* @default 1
|
|
73
74
|
*/
|
|
74
|
-
headingLevel?:
|
|
75
|
+
headingLevel?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
75
76
|
/** The page's title. Wraps rather than truncating, and grows the bar with it. */
|
|
76
77
|
headline?: ReactNode;
|
|
77
78
|
/** Usually a back or menu icon button. Sits before the text. */
|
|
78
79
|
leading?: ReactNode;
|
|
80
|
+
/**
|
|
81
|
+
* Holds the bar at the top of its scroll container while the content
|
|
82
|
+
* scrolls beneath it, and keeps it painted over that content. The bar
|
|
83
|
+
* still needs a scrolling ancestor to stick inside: the window, or an
|
|
84
|
+
* element with its own overflow. A pinned bar is the one `collapsed` and
|
|
85
|
+
* `scrolled` are for.
|
|
86
|
+
* @default false
|
|
87
|
+
*/
|
|
88
|
+
pinned?: boolean;
|
|
79
89
|
/**
|
|
80
90
|
* Whether the content beneath has been scrolled. Material Design separates
|
|
81
91
|
* a bar from scrolled content with a fill colour rather than a shadow, and
|
|
@@ -112,7 +122,7 @@ type AppBarProps = Omit<RenderComponentProps<'header'>, 'children'> & {
|
|
|
112
122
|
* and `collapsed` exist. Neither watches the page: only the app knows which
|
|
113
123
|
* element scrolls, so both are set from its own scroll handler.
|
|
114
124
|
*/
|
|
115
|
-
declare function AppBar({ align, collapsed, contentInset, contentMaxInlineSize, headingLevel, headline, leading, render, scrolled, size, subtitle, trailing, ...props }: AppBarProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
125
|
+
declare function AppBar({ align, collapsed, contentInset, contentMaxInlineSize, headingLevel, headline, leading, pinned, render, scrolled, size, subtitle, trailing, ...props }: AppBarProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
116
126
|
//#endregion
|
|
117
127
|
export { type AppBarProps, AppBar as default };
|
|
118
128
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -26,6 +26,12 @@ const HEIGHTS = {
|
|
|
26
26
|
};
|
|
27
27
|
const COLLAPSED_HEIGHT = HEIGHTS.sm.plain;
|
|
28
28
|
const styles = {
|
|
29
|
+
pinned: {
|
|
30
|
+
k87sOh: "x13vifvy",
|
|
31
|
+
kVAEAm: "x7wzq59",
|
|
32
|
+
kY2c9j: "xfj7q76",
|
|
33
|
+
$$css: true
|
|
34
|
+
},
|
|
29
35
|
root: {
|
|
30
36
|
k6CgDc: "x12w9bfk",
|
|
31
37
|
kGNEyG: "x6s0dn4",
|
|
@@ -69,8 +75,7 @@ const HEADINGS = [
|
|
|
69
75
|
"h6"
|
|
70
76
|
];
|
|
71
77
|
function heading(level) {
|
|
72
|
-
|
|
73
|
-
return createElement(HEADINGS[index]);
|
|
78
|
+
return createElement(Number.isInteger(level) && level >= 1 && level <= 6 ? HEADINGS[level - 1] : HEADINGS[0]);
|
|
74
79
|
}
|
|
75
80
|
const PARAGRAPH = /* @__PURE__ */ jsx("p", {});
|
|
76
81
|
const _temp = {
|
|
@@ -117,15 +122,16 @@ function AppBar(t0) {
|
|
|
117
122
|
let t4;
|
|
118
123
|
let t5;
|
|
119
124
|
if ($[0] !== t0) {
|
|
120
|
-
const { align: t6, collapsed: t7, contentInset: t8, contentMaxInlineSize: t9, headingLevel: t10, headline, leading,
|
|
121
|
-
render =
|
|
125
|
+
const { align: t6, collapsed: t7, contentInset: t8, contentMaxInlineSize: t9, headingLevel: t10, headline, leading, pinned: t11, render: t12, scrolled: t13, size: t14, subtitle, trailing, ...props$1 } = t0;
|
|
126
|
+
render = t12;
|
|
122
127
|
const align = t6 === void 0 ? "start" : t6;
|
|
123
128
|
const collapsed = t7 === void 0 ? false : t7;
|
|
124
129
|
const contentInset = t8 === void 0 ? spacing.lg : t8;
|
|
125
130
|
const contentMaxInlineSize = t9 === void 0 ? "none" : t9;
|
|
126
131
|
const headingLevel = t10 === void 0 ? 1 : t10;
|
|
127
|
-
const
|
|
128
|
-
const
|
|
132
|
+
const pinned = t11 === void 0 ? false : t11;
|
|
133
|
+
const scrolled = t13 === void 0 ? false : t13;
|
|
134
|
+
const size = t14 === void 0 ? "sm" : t14;
|
|
129
135
|
const collapse = collapsed && size !== "sm";
|
|
130
136
|
const expandedHeight = hasContent(subtitle) ? HEIGHTS[size].withSubtitle : HEIGHTS[size].plain;
|
|
131
137
|
const height = collapse ? COLLAPSED_HEIGHT : expandedHeight;
|
|
@@ -134,29 +140,29 @@ function AppBar(t0) {
|
|
|
134
140
|
t5 = useRender;
|
|
135
141
|
t4 = "header";
|
|
136
142
|
t1 = props$1;
|
|
137
|
-
const
|
|
138
|
-
let
|
|
143
|
+
const t15 = props(styles.row, rowStyles.root(edgePadding(contentInset, hasLeading), edgePadding(contentInset, hasTrailing), contentMaxInlineSize));
|
|
144
|
+
let t16;
|
|
139
145
|
if ($[7] !== hasLeading || $[8] !== leading) {
|
|
140
|
-
|
|
146
|
+
t16 = !hasLeading ? null : /* @__PURE__ */ jsx("div", {
|
|
141
147
|
className: "x6s0dn4 x9f619 x78zum5 x2lah0s x1r8zjiw x1let9r4",
|
|
142
148
|
children: leading
|
|
143
149
|
});
|
|
144
150
|
$[7] = hasLeading;
|
|
145
151
|
$[8] = leading;
|
|
146
|
-
$[9] =
|
|
147
|
-
} else
|
|
148
|
-
let
|
|
152
|
+
$[9] = t16;
|
|
153
|
+
} else t16 = $[9];
|
|
154
|
+
let t17;
|
|
149
155
|
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
150
|
-
|
|
156
|
+
t17 = {
|
|
151
157
|
0: { className: "x9f619 x78zum5 xdt5ytf x1iyjqo2 xkjl1po xl56j7k xeuugli xj0a0fe x1cmllll" },
|
|
152
158
|
1: { className: "x9f619 x78zum5 xdt5ytf x1iyjqo2 xkjl1po xl56j7k xeuugli xj0a0fe x1cmllll x2b8uid" }
|
|
153
159
|
};
|
|
154
|
-
$[10] =
|
|
155
|
-
} else
|
|
156
|
-
const
|
|
157
|
-
let
|
|
160
|
+
$[10] = t17;
|
|
161
|
+
} else t17 = $[10];
|
|
162
|
+
const t18 = t17[!!(align === "center") << 0];
|
|
163
|
+
let t19;
|
|
158
164
|
if ($[11] !== collapse || $[12] !== headingLevel || $[13] !== headline || $[14] !== size) {
|
|
159
|
-
|
|
165
|
+
t19 = !hasContent(headline) ? null : /* @__PURE__ */ jsx(Text, {
|
|
160
166
|
className: "x12w9bfk xioksi3 x1nxaspg x1seskgd",
|
|
161
167
|
render: heading(headingLevel),
|
|
162
168
|
variant: collapse ? HEADLINE_VARIANT.sm : HEADLINE_VARIANT[size],
|
|
@@ -166,11 +172,11 @@ function AppBar(t0) {
|
|
|
166
172
|
$[12] = headingLevel;
|
|
167
173
|
$[13] = headline;
|
|
168
174
|
$[14] = size;
|
|
169
|
-
$[15] =
|
|
170
|
-
} else
|
|
171
|
-
let
|
|
175
|
+
$[15] = t19;
|
|
176
|
+
} else t19 = $[15];
|
|
177
|
+
let t20;
|
|
172
178
|
if ($[16] !== collapse || $[17] !== subtitle) {
|
|
173
|
-
|
|
179
|
+
t20 = !hasContent(subtitle) || collapse ? null : /* @__PURE__ */ jsx(Text, {
|
|
174
180
|
render: PARAGRAPH,
|
|
175
181
|
tone: "muted",
|
|
176
182
|
variant: "bodyMedium",
|
|
@@ -178,45 +184,45 @@ function AppBar(t0) {
|
|
|
178
184
|
});
|
|
179
185
|
$[16] = collapse;
|
|
180
186
|
$[17] = subtitle;
|
|
181
|
-
$[18] =
|
|
182
|
-
} else
|
|
183
|
-
let t20;
|
|
184
|
-
if ($[19] !== t17 || $[20] !== t18 || $[21] !== t19) {
|
|
185
|
-
t20 = /* @__PURE__ */ jsxs("div", {
|
|
186
|
-
...t17,
|
|
187
|
-
children: [t18, t19]
|
|
188
|
-
});
|
|
189
|
-
$[19] = t17;
|
|
190
|
-
$[20] = t18;
|
|
191
|
-
$[21] = t19;
|
|
192
|
-
$[22] = t20;
|
|
193
|
-
} else t20 = $[22];
|
|
187
|
+
$[18] = t20;
|
|
188
|
+
} else t20 = $[18];
|
|
194
189
|
let t21;
|
|
190
|
+
if ($[19] !== t18 || $[20] !== t19 || $[21] !== t20) {
|
|
191
|
+
t21 = /* @__PURE__ */ jsxs("div", {
|
|
192
|
+
...t18,
|
|
193
|
+
children: [t19, t20]
|
|
194
|
+
});
|
|
195
|
+
$[19] = t18;
|
|
196
|
+
$[20] = t19;
|
|
197
|
+
$[21] = t20;
|
|
198
|
+
$[22] = t21;
|
|
199
|
+
} else t21 = $[22];
|
|
200
|
+
let t22;
|
|
195
201
|
if ($[23] !== hasTrailing || $[24] !== trailing) {
|
|
196
|
-
|
|
202
|
+
t22 = !hasTrailing ? null : /* @__PURE__ */ jsx("div", {
|
|
197
203
|
className: "x6s0dn4 x9f619 x78zum5 x2lah0s x1r8zjiw x1let9r4",
|
|
198
204
|
children: trailing
|
|
199
205
|
});
|
|
200
206
|
$[23] = hasTrailing;
|
|
201
207
|
$[24] = trailing;
|
|
202
|
-
$[25] =
|
|
203
|
-
} else
|
|
204
|
-
if ($[26] !==
|
|
208
|
+
$[25] = t22;
|
|
209
|
+
} else t22 = $[25];
|
|
210
|
+
if ($[26] !== t15 || $[27] !== t16 || $[28] !== t21 || $[29] !== t22) {
|
|
205
211
|
t2 = /* @__PURE__ */ jsxs("div", {
|
|
206
|
-
...
|
|
212
|
+
...t15,
|
|
207
213
|
children: [
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
214
|
+
t16,
|
|
215
|
+
t21,
|
|
216
|
+
t22
|
|
211
217
|
]
|
|
212
218
|
});
|
|
213
|
-
$[26] =
|
|
214
|
-
$[27] =
|
|
215
|
-
$[28] =
|
|
216
|
-
$[29] =
|
|
219
|
+
$[26] = t15;
|
|
220
|
+
$[27] = t16;
|
|
221
|
+
$[28] = t21;
|
|
222
|
+
$[29] = t22;
|
|
217
223
|
$[30] = t2;
|
|
218
224
|
} else t2 = $[30];
|
|
219
|
-
t3 = mergeStyles(props(styles.root, heightStyles.root(height), scrolled && styles.scrolled), props$1);
|
|
225
|
+
t3 = mergeStyles(props(styles.root, heightStyles.root(height), scrolled && styles.scrolled, pinned && styles.pinned), props$1);
|
|
220
226
|
$[0] = t0;
|
|
221
227
|
$[1] = render;
|
|
222
228
|
$[2] = t1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","ReactNode","stylex","createElement","RenderComponentProps","COLLAPSED_BLOCK_SIZE","hasContent","useRender","mergeStyles","colors","motion","sizing","spacing","Text","ICON_BUTTON_TARGET","ICON_SIZE","GLYPH_INSET","HEIGHTS","lg","plain","withSubtitle","md","sm","const","COLLAPSED_HEIGHT","FORCED_COLORS","styles","root","k6CgDc","kGNEyG","kWkggS","kB7OPa","k1xSpc","kjj79g","kIyJzY","k1ekBW","kAMwcw","$$css","row","kOIVth","kzqmXN","kUOVxO","scrolled","kL6WhQ","kfdmCh","kt9PQ7","HEADLINE_VARIANT","HEADINGS","heading","level","index","Math","min","max","round","length","PARAGRAPH","_temp","kAzted","heightStyles","minBlockSize","val","undefined","_temp2","ks0D6T","rowStyles","start","end","maxInlineSize","kwRFfy","kZCmMZ","AppBarProps","Omit","align","collapsed","contentInset","contentMaxInlineSize","headingLevel","headline","leading","size","subtitle","trailing","AppBar","t0","$","render","t1","t2","t3","t4","t5","t6","t7","t8","t9","t10","t11","t12","t13","props","collapse","expandedHeight","height","hasLeading","hasTrailing","t14","edgePadding","t15","t16","Symbol","for","0","className","1","t17","t18","t19","t20","t21","children","defaultTagName","hasSlot","inset","trim","_c","props","stylex.props"],"sources":["../../../src/components/app-bar/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport { createElement } from 'react';\nimport type { RenderComponentProps } from '../../render/useRender';\nimport { COLLAPSED_BLOCK_SIZE } from '../../hooks/useAppBarScroll';\nimport { hasContent } from '../../render/content';\nimport { useRender } from '../../render/useRender';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, sizing, spacing } from '../../tokens/design.tokens.stylex';\nimport Text from '../text';\n\n// Material Design's app bar, in the three sizes the spec recommends.\n//\n// `md` and `lg` are Material Design's medium and large *flexible* bars, the\n// newer of the two sets the spec gives and the one it recommends, which is why\n// those two steps are theirs.\n//\n// Material Design also merged the old center-aligned variant into small as a\n// configuration rather than a variant, which is why alignment is a prop here\n// and applies to every size.\n//\n// Heights are Material Design's, and they are minimums rather than fixed. The\n// spec says the flexible bars \"hug the text contents\" and gives them multi-line\n// support and text wrapping, so a headline long enough to wrap has to be able\n// to make its bar taller. Fixing the height would truncate exactly the case\n// the variant was redesigned for.\n\n// The geometry Material Design lays a bar's icon buttons out on. Its tokens\n// give a 4dp leading and trailing space between the bar's edge and the first\n// button's 48dp target, no space between one target and the next, and a 24dp\n// icon centred in each — so a glyph lands 4 + 12 = 16dp in, on the page's own\n// margin.\n//\n// The library's icon button draws a 40dp box with its 48dp target out of\n// flow, so a slot pads half the difference either side and puts the whole\n// difference between two buttons, which lays the targets edge to edge as the\n// tokens do. The target is IconButton's TARGET_SIZE, a literal there for the\n// reason it gives: it is a floor the page states, not a step of the control\n// scale.\nconst ICON_BUTTON_TARGET = '48px';\nconst ICON_SIZE = '24px';\n\n// How far an icon sits inside its target, which is how much less than the\n// content inset the row is padded on an edge that holds a slot. That is what\n// puts a leading glyph, rather than the edge of its target, at the inset.\nconst GLYPH_INSET = `(${ICON_BUTTON_TARGET} - ${ICON_SIZE}) / 2`;\nconst HEIGHTS = {\n lg: {\n plain: '120px',\n withSubtitle: '152px'\n },\n md: {\n plain: '112px',\n withSubtitle: '136px'\n },\n sm: {\n plain: `${COLLAPSED_BLOCK_SIZE}px`,\n withSubtitle: `${COLLAPSED_BLOCK_SIZE}px`\n }\n} as const;\n\n// What a flexible bar collapses to, which is the small bar exactly. Material\n// Design does not describe the collapsed large bar as a state of its own — it\n// describes it as becoming the small bar, which is why this reads off the same\n// table rather than being a fourth height.\nconst COLLAPSED_HEIGHT = HEIGHTS.sm.plain;\n\n// Windows High Contrast and the rest of the forced-colours modes. Spelled\n// here rather than imported, for the reason src/field/styles.ts records: the\n// StyleX compiler resolves a constant across files only out of a `.stylex.ts`\n// module, and the generated one holds design tokens rather than queries.\nconst FORCED_COLORS = '@media (forced-colors: active)';\nconst styles = {\n root: {\n k6CgDc: \"x12w9bfk\",\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"x14s9m32\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kjj79g: \"xl56j7k\",\n kIyJzY: \"xioksi3\",\n k1ekBW: \"x8u3r54\",\n kAMwcw: \"x1seskgd\",\n $$css: true\n },\n row: {\n kGNEyG: \"x6s0dn4\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kOIVth: \"xzoy561\",\n kzqmXN: \"xh8yej3\",\n kUOVxO: \"xvueqy4\",\n $$css: true\n },\n scrolled: {\n kWkggS: \"x1mjdul6\",\n kL6WhQ: \"xszdk7l\",\n kfdmCh: \"xe3zi7u\",\n kt9PQ7: \"x15anc7y\",\n $$css: true\n }\n};\n\n// One entry per size, and each names a type role rather than a figure.\n// Material Design's own tokens are `md.comp.app-bar.<size>.title.font`,\n// aliases onto the type scale rather than sizes of their own, so this maps to\n// the scale the same way and lets Text apply it.\nconst HEADLINE_VARIANT = {\n lg: 'headlineMedium',\n md: 'headlineSmall',\n sm: 'titleLarge'\n} as const;\n\n// The headline is the page's title in Material Design's model, so it is the\n// page's <h1> unless the call site says otherwise. `headingLevel` is what says\n// otherwise, and a bar drawn beside another bar — one per pane in a\n// `ListDetail` or a `SupportingPane` — or under a page heading of its own\n// should lower it.\n//\n// Built here rather than kept as a constant per level: `headline` becomes the\n// heading's children, so a call site cannot demote the heading by passing one\n// of its own. `headline={<h2>…</h2>}` renders an h2 inside the h1 — two\n// headings where one was wanted, which React does not warn about.\n//\n// The level is looked up rather than interpolated into a tag name. `h7` is a\n// custom element as far as React is concerned, so it renders without a word\n// said and leaves the outline worse than the default would have. Disclosure's\n// own `headingLevel` hands the number to React Aria, which is why that one\n// needs no equivalent.\nconst HEADINGS = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as const;\nfunction heading(level: number) {\n const index = Math.min(Math.max(Math.round(level), 1), HEADINGS.length) - 1;\n return createElement(HEADINGS[index]);\n}\nconst PARAGRAPH = <p />;\n\n// Height is the one value the call site does not choose, and it depends on two\n// props at once, so it is a function style rather than one key per\n// combination. StyleX writes it to a custom property inline, the same\n// mechanism Feed uses for its cell minimum.\nconst _temp = {\n kAzted: \"x1chvrdh\",\n \"$$css\": true\n};\nconst heightStyles = {\n root: (minBlockSize: string) => [_temp, {\n \"--x-minBlockSize\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(minBlockSize)\n }]\n};\n\n// The row's measure and inset both come from the call site, so both are\n// function styles too. Each edge is worked out on its own: where it holds a\n// slot the row stops short of the inset by GLYPH_INSET, so the glyph rather\n// than its target is what sits at the inset, and where it holds none the\n// headline itself starts there. Clamped at zero, since an inset smaller than\n// a glyph's own room would otherwise ask for a negative padding, which CSS\n// throws away whole.\nconst _temp2 = {\n ks0D6T: \"x13i5qev\",\n \"$$css\": true\n};\nconst rowStyles = {\n root: (start: string, end: string, maxInlineSize: string) => [_temp2, {\n kwRFfy: end != null ? \"x120eax6\" : end,\n kZCmMZ: start != null ? \"xnvo3vl\" : start,\n $$css: true\n }, {\n \"--x-maxInlineSize\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(maxInlineSize),\n \"--x-paddingInlineEnd\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(end),\n \"--x-paddingInlineStart\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(start)\n }]\n};\ntype AppBarProps = Omit<RenderComponentProps<'header'>, 'children'> & {\n /**\n * Which of Material Design's alignments the text takes. `center` is the\n * configuration that replaced the old center-aligned variant.\n * @default 'start'\n */\n align?: 'center' | 'start';\n /**\n * Collapses a flexible bar to the height and headline of the small one, for\n * a pinned bar over content that has been scrolled. Material Design\n * specifies it for the flexible sizes, and without it a pinned `lg` costs\n * 152px of the viewport for as long as the page is open.\n *\n * Controlled, and for the same reason `scrolled` is: only the app knows\n * which element scrolls, and how far into it the bar should have finished\n * collapsing. `useAppBarScroll` derives both from that element's scroll,\n * and is the way to set them unless the app needs a rule of its own.\n *\n * Ignored on `sm`, which is already the height this collapses to. The\n * subtitle goes with the height, since there is no room for a second line\n * in the small bar.\n *\n * Collapsing hands the page back the height the bar gives up, and a bar\n * whose state is read off the scroll offset can then undo itself in two\n * ways. Both move the offset back under the threshold, so the bar expands,\n * the page regains its height, and the two take turns for as long as the\n * reader stays there.\n *\n * - **Scroll anchoring.** Browsers answer a change in height above the\n * viewport by moving the offset by the same amount, to keep the content\n * in place. Give the scroll container `overflow-anchor: none`, which is\n * also the movement you want: the content follows the bar's bottom edge\n * up rather than standing still while the bar shrinks behind it.\n * - **The shorter page.** A page that overflows by less than the threshold\n * plus the height the bar gives back cannot scroll that far once the bar\n * has collapsed, so the browser pulls the offset back inside it. No\n * threshold avoids this, since the band moves with it; what does is not\n * collapsing on such a page, which is the rule `useAppBarScroll` applies.\n * @default false\n */\n collapsed?: boolean;\n /**\n * Where the bar's content starts on each edge: the headline where nothing\n * comes before it, and the leading icon's glyph where something does, with\n * the headline after the icon button's target. The trailing edge is the\n * same mirrored. Any length works, `0` included, for a bar drawn flush.\n *\n * The default is Material Design's own margin for a top app bar, the\n * spacing scale's `lg` step, which is also the margin it gives body\n * content, so a bar and the page beneath line up without either being told\n * about the other. Set it to the page's gutter where that differs.\n * @default spacing.lg\n */\n contentInset?: string;\n /**\n * How wide the bar's contents may run before they stop growing, with the\n * row centred in whatever is left. The bar's own surface still paints edge\n * to edge.\n *\n * This is what lines a full-bleed bar up with a page whose content sits in\n * a measure: give it the page's measure, and `contentInset` the page's\n * gutter. Unset, the row is as wide as the bar.\n */\n contentMaxInlineSize?: string;\n /**\n * Where the headline sits in the page's outline. A screen reader moves\n * between headings, so a bar drawn beside another bar, or under a page\n * heading of its own, should lower it.\n * @default 1\n */\n headingLevel?: number;\n /** The page's title. Wraps rather than truncating, and grows the bar with it. */\n headline?: ReactNode;\n /** Usually a back or menu icon button. Sits before the text. */\n leading?: ReactNode;\n /**\n * Whether the content beneath has been scrolled. Material Design separates\n * a bar from scrolled content with a fill colour rather than a shadow, and\n * this is what applies it.\n *\n * Controlled, with no listener of its own: only the app knows which element\n * scrolls, and a bar that watched the window would be wrong inside every\n * pane and dialog that scrolls independently.\n * @default false\n */\n scrolled?: boolean;\n /**\n * Height and headline size, as steps of the library's size scale. `sm` is\n * Material Design's small bar, a fixed 64px; `md` and `lg` are its medium\n * and large flexible bars, which hug their text.\n * @default 'sm'\n */\n size?: 'lg' | 'md' | 'sm';\n /** A second line under the headline. Makes `md` and `lg` taller. */\n subtitle?: ReactNode;\n /** Actions, at the far end. Usually icon buttons. */\n trailing?: ReactNode;\n};\n\n/**\n * Material Design's app bar: the container at the top of a page carrying its\n * title, one or two actions, and the way back out.\n *\n * Three sizes. `sm` is a fixed 64px bar for a page whose title is a label;\n * `md` and `lg` are the flexible bars, which give the headline a larger\n * type role and grow to fit a subtitle or a headline that wraps.\n *\n * It paints its own surface, unlike the layout components, because separating\n * itself from the content beneath is the job — which is also why `scrolled`\n * and `collapsed` exist. Neither watches the page: only the app knows which\n * element scrolls, so both are set from its own scroll handler.\n */\nfunction AppBar({\n align = 'start',\n collapsed = false,\n contentInset = spacing.lg,\n contentMaxInlineSize = 'none',\n headingLevel = 1,\n headline,\n leading,\n render,\n scrolled = false,\n size = 'sm',\n subtitle,\n trailing,\n ...props\n}: AppBarProps) {\n // `sm` is already what the flexible bars collapse to, so collapsing it is\n // a no-op rather than an error. A bar whose size is chosen at the call site\n // from a breakpoint would otherwise have to guard the prop as well.\n const collapse = collapsed && size !== 'sm';\n const expandedHeight = hasContent(subtitle) ? HEIGHTS[size].withSubtitle : HEIGHTS[size].plain;\n const height = collapse ? COLLAPSED_HEIGHT : expandedHeight;\n const hasLeading = hasContent(leading);\n const hasTrailing = hasContent(trailing);\n return useRender({\n defaultTagName: 'header',\n props: {\n ...props,\n children: <div {...stylex.props(styles.row, rowStyles.root(edgePadding(contentInset, hasLeading), edgePadding(contentInset, hasTrailing), contentMaxInlineSize))}>\n {!hasLeading ? null : <div className=\"x6s0dn4 x9f619 x78zum5 x2lah0s x1r8zjiw x1let9r4\">{leading}</div>}\n <div {...{\n 0: {\n className: \"x9f619 x78zum5 xdt5ytf x1iyjqo2 xkjl1po xl56j7k xeuugli xj0a0fe x1cmllll\"\n },\n 1: {\n className: \"x9f619 x78zum5 xdt5ytf x1iyjqo2 xkjl1po xl56j7k xeuugli xj0a0fe x1cmllll x2b8uid\"\n }\n }[!!(align === 'center') << 0]}>\n {!hasContent(headline) ? null : <Text className=\"x12w9bfk xioksi3 x1nxaspg x1seskgd\" render={heading(headingLevel)} variant={collapse ? HEADLINE_VARIANT.sm : HEADLINE_VARIANT[size]}>\n {headline}\n </Text>}\n {!hasContent(subtitle) || collapse ? null : <Text render={PARAGRAPH} tone=\"muted\" variant=\"bodyMedium\">\n {subtitle}\n </Text>}\n </div>\n {!hasTrailing ? null : <div className=\"x6s0dn4 x9f619 x78zum5 x2lah0s x1r8zjiw x1let9r4\">{trailing}</div>}\n </div>,\n ...mergeStyles(stylex.props(styles.root, heightStyles.root(height), scrolled && styles.scrolled), props)\n },\n render\n });\n}\n\n/**\n * The row's padding on one edge, for the inset the call site gave.\n *\n * A bare `0` is the one length CSS accepts without a unit, and the one it\n * rejects inside `max()`, where it reads as a number, so it is given its\n * unit before the arithmetic sees it.\n */\nfunction edgePadding(contentInset: string, hasSlot: boolean) {\n const inset = contentInset.trim() === '0' ? '0px' : contentInset;\n return hasSlot ? `max(0px, ${inset} - ${GLYPH_INSET})` : inset;\n}\nexport type { AppBarProps };\nexport default AppBar;"],"mappings":";;;;;;;;;;;AAgDA,MAAMiB,cAAc;AACpB,MAAMC,UAAU;CACdC,IAAI;EACFC,OAAO;EACPC,cAAc;CAChB;CACAC,IAAI;EACFF,OAAO;EACPC,cAAc;CAChB;CACAE,IAAI;EACFH,OAAO;EACPC,cAAc;CAChB;AACF;AAMA,MAAMI,mBAAmBP,QAAQK,GAAGH;AAOpC,MAAMO,SAAS;CACbC,MAAM;EACJC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;CACT;CACAC,KAAK;EACHT,QAAQ;EACRE,QAAQ;EACRC,QAAQ;EACRO,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRJ,OAAO;CACT;CACAK,UAAU;EACRZ,QAAQ;EACRa,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRR,OAAO;CACT;AACF;AAMA,MAAMS,mBAAmB;CACvB5B,IAAI;CACJG,IAAI;CACJC,IAAI;AACN;AAkBA,MAAMyB,WAAW;CAAC;CAAM;CAAM;CAAM;CAAM;CAAM;AAAI;AACpD,SAASC,QAAQC,OAAe;CAC9B,MAAMC,QAAQC,KAAKC,IAAID,KAAKE,IAAIF,KAAKG,MAAML,KAAK,GAAG,CAAC,GAAGF,SAASQ,MAAM,IAA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AA;EAxBcC,KAAA;GAAA4B,gBACC/B;GAAQU,OACjBR;GAsBNN;EAEH;EAACD,EAAA,MAAAC;EAAAD,EAAA,MAAAK;EAAAL,EAAA,MAAAO;EAAAP,EAAA,MAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,OA1BM9E,GAAUsF,EA0BhB;AAAC;;;;;;;;AAUJ,SAASc,YAAYhC,cAAsB+C,SAAkB;CAC3D,MAAMC,QAAQhD,aAAaiD,KAAK,MAAM,MAAM,QAAQjD;CACpD,OAAO+C,UAAU,YAAYC,MAAK,KAAM3G,YAAW,KAAM2G;AAC3D"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","ReactNode","stylex","createElement","RenderComponentProps","COLLAPSED_BLOCK_SIZE","hasContent","useRender","layers","mergeStyles","colors","motion","sizing","spacing","Text","ICON_BUTTON_TARGET","ICON_SIZE","GLYPH_INSET","HEIGHTS","lg","plain","withSubtitle","md","sm","const","COLLAPSED_HEIGHT","FORCED_COLORS","styles","pinned","k87sOh","kVAEAm","kY2c9j","$$css","root","k6CgDc","kGNEyG","kWkggS","kB7OPa","k1xSpc","kjj79g","kIyJzY","k1ekBW","kAMwcw","row","kOIVth","kzqmXN","kUOVxO","scrolled","kL6WhQ","kfdmCh","kt9PQ7","HEADLINE_VARIANT","HEADINGS","heading","level","known","Number","isInteger","PARAGRAPH","_temp","kAzted","heightStyles","minBlockSize","val","undefined","_temp2","ks0D6T","rowStyles","start","end","maxInlineSize","kwRFfy","kZCmMZ","AppBarProps","Omit","align","collapsed","contentInset","contentMaxInlineSize","headingLevel","headline","leading","size","subtitle","trailing","AppBar","t0","$","render","t1","t2","t3","t4","t5","t6","t7","t8","t9","t10","t11","t12","t13","t14","props","collapse","expandedHeight","height","hasLeading","hasTrailing","t15","edgePadding","t16","t17","Symbol","for","0","className","1","t18","t19","t20","t21","t22","children","defaultTagName","hasSlot","inset","trim","_c","props","stylex.props"],"sources":["../../../src/components/app-bar/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport { createElement } from 'react';\nimport type { RenderComponentProps } from '../../render/useRender';\nimport { COLLAPSED_BLOCK_SIZE } from '../../hooks/useAppBarScroll';\nimport { hasContent } from '../../render/content';\nimport { useRender } from '../../render/useRender';\nimport '../../styles/layers.stylex';\nimport { layers } from '../../styles/layers.stylex';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, sizing, spacing } from '../../tokens/design.tokens.stylex';\nimport Text from '../text';\n\n// Material Design's app bar, in the three sizes the spec recommends.\n//\n// `md` and `lg` are Material Design's medium and large *flexible* bars, the\n// newer of the two sets the spec gives and the one it recommends, which is why\n// those two steps are theirs.\n//\n// Material Design also merged the old center-aligned variant into small as a\n// configuration rather than a variant, which is why alignment is a prop here\n// and applies to every size.\n//\n// Heights are Material Design's, and they are minimums rather than fixed. The\n// spec says the flexible bars \"hug the text contents\" and gives them multi-line\n// support and text wrapping, so a headline long enough to wrap has to be able\n// to make its bar taller. Fixing the height would truncate exactly the case\n// the variant was redesigned for.\n\n// The geometry Material Design lays a bar's icon buttons out on. Its tokens\n// give a 4dp leading and trailing space between the bar's edge and the first\n// button's 48dp target, no space between one target and the next, and a 24dp\n// icon centred in each — so a glyph lands 4 + 12 = 16dp in, on the page's own\n// margin.\n//\n// The library's icon button draws a 40dp box with its 48dp target out of\n// flow, so a slot pads half the difference either side and puts the whole\n// difference between two buttons, which lays the targets edge to edge as the\n// tokens do. The target is IconButton's TARGET_SIZE, a literal there for the\n// reason it gives: it is a floor the page states, not a step of the control\n// scale.\nconst ICON_BUTTON_TARGET = '48px';\nconst ICON_SIZE = '24px';\n\n// How far an icon sits inside its target, which is how much less than the\n// content inset the row is padded on an edge that holds a slot. That is what\n// puts a leading glyph, rather than the edge of its target, at the inset.\nconst GLYPH_INSET = `(${ICON_BUTTON_TARGET} - ${ICON_SIZE}) / 2`;\nconst HEIGHTS = {\n lg: {\n plain: '120px',\n withSubtitle: '152px'\n },\n md: {\n plain: '112px',\n withSubtitle: '136px'\n },\n sm: {\n plain: `${COLLAPSED_BLOCK_SIZE}px`,\n withSubtitle: `${COLLAPSED_BLOCK_SIZE}px`\n }\n} as const;\n\n// What a flexible bar collapses to, which is the small bar exactly. Material\n// Design does not describe the collapsed large bar as a state of its own — it\n// describes it as becoming the small bar, which is why this reads off the same\n// table rather than being a fourth height.\nconst COLLAPSED_HEIGHT = HEIGHTS.sm.plain;\n\n// Windows High Contrast and the rest of the forced-colours modes. Spelled\n// here rather than imported, for the reason src/field/styles.ts records: the\n// StyleX compiler resolves a constant across files only out of a `.stylex.ts`\n// module, and the generated one holds design tokens rather than queries.\nconst FORCED_COLORS = '@media (forced-colors: active)';\nconst styles = {\n pinned: {\n k87sOh: \"x13vifvy\",\n kVAEAm: \"x7wzq59\",\n kY2c9j: \"xfj7q76\",\n $$css: true\n },\n root: {\n k6CgDc: \"x12w9bfk\",\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"x14s9m32\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kjj79g: \"xl56j7k\",\n kIyJzY: \"xioksi3\",\n k1ekBW: \"x8u3r54\",\n kAMwcw: \"x1seskgd\",\n $$css: true\n },\n row: {\n kGNEyG: \"x6s0dn4\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kOIVth: \"xzoy561\",\n kzqmXN: \"xh8yej3\",\n kUOVxO: \"xvueqy4\",\n $$css: true\n },\n scrolled: {\n kWkggS: \"x1mjdul6\",\n kL6WhQ: \"xszdk7l\",\n kfdmCh: \"xe3zi7u\",\n kt9PQ7: \"x15anc7y\",\n $$css: true\n }\n};\n\n// One entry per size, and each names a type role rather than a figure.\n// Material Design's own tokens are `md.comp.app-bar.<size>.title.font`,\n// aliases onto the type scale rather than sizes of their own, so this maps to\n// the scale the same way and lets Text apply it.\nconst HEADLINE_VARIANT = {\n lg: 'headlineMedium',\n md: 'headlineSmall',\n sm: 'titleLarge'\n} as const;\n\n// The headline is the page's title in Material Design's model, so it is the\n// page's <h1> unless the call site says otherwise. `headingLevel` is what says\n// otherwise, and a bar drawn beside another bar — one per pane in a\n// `ListDetail` or a `SupportingPane` — or under a page heading of its own\n// should lower it.\n//\n// Built here rather than kept as a constant per level: `headline` becomes the\n// heading's children, so a call site cannot demote the heading by passing one\n// of its own. `headline={<h2>…</h2>}` renders an h2 inside the h1 — two\n// headings where one was wanted, which React does not warn about.\n//\n// The level is looked up rather than interpolated into a tag name. `h7` is a\n// custom element as far as React is concerned, so it renders without a word\n// said and leaves the outline worse than the default would have. The prop's\n// type is the six levels, and a value outside them from a call site the type\n// does not reach — `NaN`, which rounded and clamped to no element at all and\n// took the headline out of the outline — falls back to the default h1.\n// Disclosure's own `headingLevel` hands the number to React Aria, which is\n// why that one needs no equivalent.\nconst HEADINGS = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as const;\nfunction heading(level: number) {\n const known = Number.isInteger(level) && level >= 1 && level <= 6;\n return createElement(known ? HEADINGS[level - 1] : HEADINGS[0]);\n}\nconst PARAGRAPH = <p />;\n\n// Height is the one value the call site does not choose, and it depends on two\n// props at once, so it is a function style rather than one key per\n// combination. StyleX writes it to a custom property inline, the same\n// mechanism Feed uses for its cell minimum.\nconst _temp = {\n kAzted: \"x1chvrdh\",\n \"$$css\": true\n};\nconst heightStyles = {\n root: (minBlockSize: string) => [_temp, {\n \"--x-minBlockSize\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(minBlockSize)\n }]\n};\n\n// The row's measure and inset both come from the call site, so both are\n// function styles too. Each edge is worked out on its own: where it holds a\n// slot the row stops short of the inset by GLYPH_INSET, so the glyph rather\n// than its target is what sits at the inset, and where it holds none the\n// headline itself starts there. Clamped at zero, since an inset smaller than\n// a glyph's own room would otherwise ask for a negative padding, which CSS\n// throws away whole.\nconst _temp2 = {\n ks0D6T: \"x13i5qev\",\n \"$$css\": true\n};\nconst rowStyles = {\n root: (start: string, end: string, maxInlineSize: string) => [_temp2, {\n kwRFfy: end != null ? \"x120eax6\" : end,\n kZCmMZ: start != null ? \"xnvo3vl\" : start,\n $$css: true\n }, {\n \"--x-maxInlineSize\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(maxInlineSize),\n \"--x-paddingInlineEnd\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(end),\n \"--x-paddingInlineStart\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(start)\n }]\n};\ntype AppBarProps = Omit<RenderComponentProps<'header'>, 'children'> & {\n /**\n * Which of Material Design's alignments the text takes. `center` is the\n * configuration that replaced the old center-aligned variant.\n * @default 'start'\n */\n align?: 'center' | 'start';\n /**\n * Collapses a flexible bar to the height and headline of the small one, for\n * a bar `pinned` over content that has been scrolled. Material Design\n * specifies it for the flexible sizes, and without it a pinned `lg` costs\n * 152px of the viewport for as long as the page is open.\n *\n * Controlled, and for the same reason `scrolled` is: only the app knows\n * which element scrolls, and how far into it the bar should have finished\n * collapsing. `useAppBarScroll` derives both from that element's scroll,\n * and is the way to set them unless the app needs a rule of its own.\n *\n * Ignored on `sm`, which is already the height this collapses to. The\n * subtitle goes with the height, since there is no room for a second line\n * in the small bar.\n *\n * Collapsing hands the page back the height the bar gives up, and a bar\n * whose state is read off the scroll offset can then undo itself in two\n * ways. Both move the offset back under the threshold, so the bar expands,\n * the page regains its height, and the two take turns for as long as the\n * reader stays there.\n *\n * - **Scroll anchoring.** Browsers answer a change in height above the\n * viewport by moving the offset by the same amount, to keep the content\n * in place. Give the scroll container `overflow-anchor: none`, which is\n * also the movement you want: the content follows the bar's bottom edge\n * up rather than standing still while the bar shrinks behind it.\n * - **The shorter page.** A page that overflows by less than the threshold\n * plus the height the bar gives back cannot scroll that far once the bar\n * has collapsed, so the browser pulls the offset back inside it. No\n * threshold avoids this, since the band moves with it; what does is not\n * collapsing on such a page, which is the rule `useAppBarScroll` applies.\n * @default false\n */\n collapsed?: boolean;\n /**\n * Where the bar's content starts on each edge: the headline where nothing\n * comes before it, and the leading icon's glyph where something does, with\n * the headline after the icon button's target. The trailing edge is the\n * same mirrored. Any length works, `0` included, for a bar drawn flush.\n *\n * The default is Material Design's own margin for a top app bar, the\n * spacing scale's `lg` step, which is also the margin it gives body\n * content, so a bar and the page beneath line up without either being told\n * about the other. Set it to the page's gutter where that differs.\n * @default spacing.lg\n */\n contentInset?: string;\n /**\n * How wide the bar's contents may run before they stop growing, with the\n * row centred in whatever is left. The bar's own surface still paints edge\n * to edge.\n *\n * This is what lines a full-bleed bar up with a page whose content sits in\n * a measure: give it the page's measure, and `contentInset` the page's\n * gutter. Unset, the row is as wide as the bar.\n */\n contentMaxInlineSize?: string;\n /**\n * Where the headline sits in the page's outline, as one of the six heading\n * levels. A screen reader moves between headings, so a bar drawn beside\n * another bar, or under a page heading of its own, should lower it. A value\n * outside the six that reaches it untyped falls back to 1.\n * @default 1\n */\n headingLevel?: 1 | 2 | 3 | 4 | 5 | 6;\n /** The page's title. Wraps rather than truncating, and grows the bar with it. */\n headline?: ReactNode;\n /** Usually a back or menu icon button. Sits before the text. */\n leading?: ReactNode;\n /**\n * Holds the bar at the top of its scroll container while the content\n * scrolls beneath it, and keeps it painted over that content. The bar\n * still needs a scrolling ancestor to stick inside: the window, or an\n * element with its own overflow. A pinned bar is the one `collapsed` and\n * `scrolled` are for.\n * @default false\n */\n pinned?: boolean;\n /**\n * Whether the content beneath has been scrolled. Material Design separates\n * a bar from scrolled content with a fill colour rather than a shadow, and\n * this is what applies it.\n *\n * Controlled, with no listener of its own: only the app knows which element\n * scrolls, and a bar that watched the window would be wrong inside every\n * pane and dialog that scrolls independently.\n * @default false\n */\n scrolled?: boolean;\n /**\n * Height and headline size, as steps of the library's size scale. `sm` is\n * Material Design's small bar, a fixed 64px; `md` and `lg` are its medium\n * and large flexible bars, which hug their text.\n * @default 'sm'\n */\n size?: 'lg' | 'md' | 'sm';\n /** A second line under the headline. Makes `md` and `lg` taller. */\n subtitle?: ReactNode;\n /** Actions, at the far end. Usually icon buttons. */\n trailing?: ReactNode;\n};\n\n/**\n * Material Design's app bar: the container at the top of a page carrying its\n * title, one or two actions, and the way back out.\n *\n * Three sizes. `sm` is a fixed 64px bar for a page whose title is a label;\n * `md` and `lg` are the flexible bars, which give the headline a larger\n * type role and grow to fit a subtitle or a headline that wraps.\n *\n * It paints its own surface, unlike the layout components, because separating\n * itself from the content beneath is the job — which is also why `scrolled`\n * and `collapsed` exist. Neither watches the page: only the app knows which\n * element scrolls, so both are set from its own scroll handler.\n */\nfunction AppBar({\n align = 'start',\n collapsed = false,\n contentInset = spacing.lg,\n contentMaxInlineSize = 'none',\n headingLevel = 1,\n headline,\n leading,\n pinned = false,\n render,\n scrolled = false,\n size = 'sm',\n subtitle,\n trailing,\n ...props\n}: AppBarProps) {\n // `sm` is already what the flexible bars collapse to, so collapsing it is\n // a no-op rather than an error. A bar whose size is chosen at the call site\n // from a breakpoint would otherwise have to guard the prop as well.\n const collapse = collapsed && size !== 'sm';\n const expandedHeight = hasContent(subtitle) ? HEIGHTS[size].withSubtitle : HEIGHTS[size].plain;\n const height = collapse ? COLLAPSED_HEIGHT : expandedHeight;\n const hasLeading = hasContent(leading);\n const hasTrailing = hasContent(trailing);\n return useRender({\n defaultTagName: 'header',\n props: {\n ...props,\n children: <div {...stylex.props(styles.row, rowStyles.root(edgePadding(contentInset, hasLeading), edgePadding(contentInset, hasTrailing), contentMaxInlineSize))}>\n {!hasLeading ? null : <div className=\"x6s0dn4 x9f619 x78zum5 x2lah0s x1r8zjiw x1let9r4\">{leading}</div>}\n <div {...{\n 0: {\n className: \"x9f619 x78zum5 xdt5ytf x1iyjqo2 xkjl1po xl56j7k xeuugli xj0a0fe x1cmllll\"\n },\n 1: {\n className: \"x9f619 x78zum5 xdt5ytf x1iyjqo2 xkjl1po xl56j7k xeuugli xj0a0fe x1cmllll x2b8uid\"\n }\n }[!!(align === 'center') << 0]}>\n {!hasContent(headline) ? null : <Text className=\"x12w9bfk xioksi3 x1nxaspg x1seskgd\" render={heading(headingLevel)} variant={collapse ? HEADLINE_VARIANT.sm : HEADLINE_VARIANT[size]}>\n {headline}\n </Text>}\n {!hasContent(subtitle) || collapse ? null : <Text render={PARAGRAPH} tone=\"muted\" variant=\"bodyMedium\">\n {subtitle}\n </Text>}\n </div>\n {!hasTrailing ? null : <div className=\"x6s0dn4 x9f619 x78zum5 x2lah0s x1r8zjiw x1let9r4\">{trailing}</div>}\n </div>,\n ...mergeStyles(stylex.props(styles.root, heightStyles.root(height), scrolled && styles.scrolled, pinned && styles.pinned), props)\n },\n render\n });\n}\n\n/**\n * The row's padding on one edge, for the inset the call site gave.\n *\n * A bare `0` is the one length CSS accepts without a unit, and the one it\n * rejects inside `max()`, where it reads as a number, so it is given its\n * unit before the arithmetic sees it.\n */\nfunction edgePadding(contentInset: string, hasSlot: boolean) {\n const inset = contentInset.trim() === '0' ? '0px' : contentInset;\n return hasSlot ? `max(0px, ${inset} - ${GLYPH_INSET})` : inset;\n}\nexport type { AppBarProps };\nexport default AppBar;"],"mappings":";;;;;;;;;;;AAkDA,MAAMkB,cAAc;AACpB,MAAMC,UAAU;CACdC,IAAI;EACFC,OAAO;EACPC,cAAc;CAChB;CACAC,IAAI;EACFF,OAAO;EACPC,cAAc;CAChB;CACAE,IAAI;EACFH,OAAO;EACPC,cAAc;CAChB;AACF;AAMA,MAAMI,mBAAmBP,QAAQK,GAAGH;AAOpC,MAAMO,SAAS;CACbC,QAAQ;EACNC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;CACT;CACAC,MAAM;EACJC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRV,OAAO;CACT;CACAW,KAAK;EACHR,QAAQ;EACRE,QAAQ;EACRC,QAAQ;EACRM,QAAQ;EACRC,QAAQ;EACRC,QAAQ;E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,EAAA;EAAAI,KAAAJ,EAAA;EAAAK,KAAAL,EAAA;EAAAM,KAAAN,EAAA;CAAA;CAAA,IAAAO;CAAA,IAAAP,EAAA,QAAAE,MAAAF,EAAA,QAAAG,MAAAH,EAAA,QAAAI,IAAA;EArB5HG,KAAA;GAAA,GACFS;GAAKoB,UACEjC;GAkBF,GACLC;EACL;EAACJ,EAAA,MAAAE;EAAAF,EAAA,MAAAG;EAAAH,EAAA,MAAAI;EAAAJ,EAAA,MAAAO;CAAA,OAAAA,KAAAP,EAAA;CAAA,IAAAQ;CAAA,IAAAR,EAAA,QAAAC,UAAAD,EAAA,QAAAK,MAAAL,EAAA,QAAAO,IAAA;EAxBcC,KAAA;GAAA6B,gBACChC;GAAQW,OACjBT;GAsBNN;EAEH;EAACD,EAAA,MAAAC;EAAAD,EAAA,MAAAK;EAAAL,EAAA,MAAAO;EAAAP,EAAA,MAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,OA1BMhF,GAAUwF,EA0BhB;AAAC;;;;;;;;AAUJ,SAASe,YAAYjC,cAAsBgD,SAAkB;CAC3D,MAAMC,QAAQjD,aAAakD,KAAK,MAAM,MAAM,QAAQlD;CACpD,OAAOgD,UAAU,YAAYC,MAAK,KAAM7G,YAAW,KAAM6G;AAC3D"}
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import { RenderComponentProps } from "../../render/useRender.js";
|
|
2
|
+
import { ImgHTMLAttributes } from "react";
|
|
2
3
|
//#region src/components/avatar/index.d.ts
|
|
3
|
-
type AvatarProps =
|
|
4
|
+
type AvatarProps = {
|
|
5
|
+
/**
|
|
6
|
+
* Hides the avatar from assistive technology, for one beside the person's
|
|
7
|
+
* name — a row whose headline is the name, a byline — where it would
|
|
8
|
+
* otherwise announce the name a second time. `name` still supplies the
|
|
9
|
+
* initials, and is not announced.
|
|
10
|
+
* @default false
|
|
11
|
+
*/
|
|
12
|
+
decorative?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Attributes for the picture's own `<img>`: a `srcSet` and `sizes` for a
|
|
15
|
+
* screen's density, a `referrerPolicy` or `crossOrigin` for where it is
|
|
16
|
+
* served from, a `fetchPriority`, or `loading` and `decoding`, which are
|
|
17
|
+
* `lazy` and `async` unless given.
|
|
18
|
+
*/
|
|
19
|
+
imgProps?: Pick<ImgHTMLAttributes<HTMLImageElement>, 'crossOrigin' | 'decoding' | 'fetchPriority' | 'loading' | 'referrerPolicy' | 'sizes' | 'srcSet'>;
|
|
4
20
|
/**
|
|
5
21
|
* The person this represents. Supplies both the initials and the accessible
|
|
6
22
|
* name, so a screen reader announces who it is rather than reading two
|
|
@@ -14,6 +30,13 @@ type AvatarProps = Omit<RenderComponentProps<'span'>, 'children'> & {
|
|
|
14
30
|
* names are, is one word, and takes one initial.
|
|
15
31
|
*/
|
|
16
32
|
name: string;
|
|
33
|
+
/**
|
|
34
|
+
* Whether an avatar with no initials to take, for a blank `name`, draws
|
|
35
|
+
* Material Design's anonymous person. `false` leaves the tinted disc empty,
|
|
36
|
+
* for a loading skeleton.
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
showPersonIcon?: boolean;
|
|
17
40
|
/**
|
|
18
41
|
* Diameter: `sm` 36px, `md` 40px, `lg` 56px.
|
|
19
42
|
* @default 'md'
|
|
@@ -29,7 +52,7 @@ type AvatarProps = Omit<RenderComponentProps<'span'>, 'children'> & {
|
|
|
29
52
|
* @default 'primary'
|
|
30
53
|
*/
|
|
31
54
|
tone?: 'negative' | 'positive' | 'primary' | 'secondary' | 'tertiary';
|
|
32
|
-
}
|
|
55
|
+
} & Omit<RenderComponentProps<'span'>, 'children'>;
|
|
33
56
|
/**
|
|
34
57
|
* A person, as a circle holding their photo or, until it loads or when there
|
|
35
58
|
* is none, their initials. `name` is both where the initials come from and
|
|
@@ -39,6 +62,9 @@ type AvatarProps = Omit<RenderComponentProps<'span'>, 'children'> & {
|
|
|
39
62
|
* <Avatar name="Ada Lovelace" src={photo} size="lg" />
|
|
40
63
|
* ```
|
|
41
64
|
*
|
|
65
|
+
* When the person's name is already written next to the avatar, mark it
|
|
66
|
+
* `decorative`, so a screen reader reads the name once.
|
|
67
|
+
*
|
|
42
68
|
* Reach for ProductIcon when what is drawn is not a person; the two share
|
|
43
69
|
* their sizes, so either fills the same slot in a row or a card.
|
|
44
70
|
*
|
|
@@ -12,6 +12,9 @@ import { jsx } from "react/jsx-runtime";
|
|
|
12
12
|
* <Avatar name="Ada Lovelace" src={photo} size="lg" />
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
|
+
* When the person's name is already written next to the avatar, mark it
|
|
16
|
+
* `decorative`, so a screen reader reads the name once.
|
|
17
|
+
*
|
|
15
18
|
* Reach for ProductIcon when what is drawn is not a person; the two share
|
|
16
19
|
* their sizes, so either fills the same slot in a row or a card.
|
|
17
20
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","RenderComponentProps","Mark","AvatarProps","
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","ImgHTMLAttributes","RenderComponentProps","Mark","AvatarProps","decorative","imgProps","Pick","HTMLImageElement","name","showPersonIcon","size","src","tone","Omit","Avatar","t0","$","props","t1","t2","undefined","t3","_c"],"sources":["../../../src/components/avatar/index.tsx"],"sourcesContent":["'use client'\n\nimport type { ImgHTMLAttributes } from 'react'\n\nimport type { RenderComponentProps } from '../../render/useRender'\n\nimport Mark from '../../mark'\n\n// A person, drawn as a circle with the photo cropped to fill it. The box, the\n// sizes, the tones, the photo's loading and the labelling are the mark's in\n// `src/mark`, which ProductIcon draws a thing through as well, so a person\n// and a thing fill the same slot.\n//\n// Which tone a given person gets is the consuming app's decision — the design\n// cycles colours per person, and that cycle belongs where the list of people\n// is, not in this component.\n\ntype AvatarProps = {\n /**\n * Hides the avatar from assistive technology, for one beside the person's\n * name — a row whose headline is the name, a byline — where it would\n * otherwise announce the name a second time. `name` still supplies the\n * initials, and is not announced.\n * @default false\n */\n decorative?: boolean\n /**\n * Attributes for the picture's own `<img>`: a `srcSet` and `sizes` for a\n * screen's density, a `referrerPolicy` or `crossOrigin` for where it is\n * served from, a `fetchPriority`, or `loading` and `decoding`, which are\n * `lazy` and `async` unless given.\n */\n imgProps?: Pick<\n ImgHTMLAttributes<HTMLImageElement>,\n | 'crossOrigin'\n | 'decoding'\n | 'fetchPriority'\n | 'loading'\n | 'referrerPolicy'\n | 'sizes'\n | 'srcSet'\n >\n /**\n * The person this represents. Supplies both the initials and the accessible\n * name, so a screen reader announces who it is rather than reading two\n * letters aloud.\n *\n * A display name, as a reader would see it written: the initials are its\n * first and last words. A title before the name (\"Dr.\"), a generational\n * suffix after it (\"Jr.\", \"III\") and an aside in brackets at its end\n * (\"(she/her)\") are passed over, as is punctuation a word opens with. A\n * name written without spaces between its words, as Japanese and Chinese\n * names are, is one word, and takes one initial.\n */\n name: string\n /**\n * Whether an avatar with no initials to take, for a blank `name`, draws\n * Material Design's anonymous person. `false` leaves the tinted disc empty,\n * for a loading skeleton.\n * @default true\n */\n showPersonIcon?: boolean\n /**\n * Diameter: `sm` 36px, `md` 40px, `lg` 56px.\n * @default 'md'\n */\n size?: 'lg' | 'md' | 'sm'\n /**\n * A photo to show in place of the initials. The initials stay until it has\n * loaded, and come back if it fails.\n */\n src?: string\n /**\n * Which container/on-container colour pair to tint with.\n * @default 'primary'\n */\n tone?: 'negative' | 'positive' | 'primary' | 'secondary' | 'tertiary'\n} & Omit<RenderComponentProps<'span'>, 'children'>\n\n/**\n * A person, as a circle holding their photo or, until it loads or when there\n * is none, their initials. `name` is both where the initials come from and\n * what a screen reader announces, so it is required even with a photo.\n *\n * ```tsx\n * <Avatar name=\"Ada Lovelace\" src={photo} size=\"lg\" />\n * ```\n *\n * When the person's name is already written next to the avatar, mark it\n * `decorative`, so a screen reader reads the name once.\n *\n * Reach for ProductIcon when what is drawn is not a person; the two share\n * their sizes, so either fills the same slot in a row or a card.\n *\n * The call site's `className` and `style` land on the circle.\n */\nfunction Avatar({ size = 'md', tone = 'primary', ...props }: AvatarProps) {\n return <Mark {...props} kind=\"person\" size={size} tone={tone} />\n}\n\nexport type { AvatarProps }\n\nexport default Avatar\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgGA,SAAAgB,OAAAC,IAAA;CAAA,MAAAC,IAAAjB,EAAA,CAAA;CAAA,IAAAkB;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAH,EAAA,OAAAD,IAAA;EAAgB,CAAA,CAAAL,MAAAQ,IAAAN,MAAAO,IAAA,GAAAF,SAAAF;EAAwDC,EAAA,KAAAD;EAAAC,EAAA,KAAAC;EAAAD,EAAA,KAAAE;EAAAF,EAAA,KAAAG;CAAA,OAAA;EAAAF,QAAAD,EAAA;EAAAE,KAAAF,EAAA;EAAAG,KAAAH,EAAA;CAAA;CAAtD,MAAAN,OAAAQ,OAAAE,KAAAA,IAAA,OAAAF;CAAa,MAAAN,OAAAO,OAAAC,KAAAA,IAAA,YAAAD;CAAgB,IAAAE;CAAA,IAAAL,EAAA,OAAAC,SAAAD,EAAA,OAAAN,QAAAM,EAAA,OAAAJ,MAAA;EACtCS,KAAA,oBAAC,MAAD;GAAK,GAAKJ;GAAY,MAAA;GAAeP;GAAYE;EAAI,CAAA;EAAII,EAAA,KAAAC;EAAAD,EAAA,KAAAN;EAAAM,EAAA,KAAAJ;EAAAI,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAAzDK;AAAyD"}
|
|
@@ -9,6 +9,17 @@ type CardProps = {
|
|
|
9
9
|
* @default false
|
|
10
10
|
*/
|
|
11
11
|
interactive?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Turns an interactive card off: it fades as the cards page draws a
|
|
14
|
+
* disabled card, stops rippling and lifting, and takes no press. The
|
|
15
|
+
* default `<button>` is disabled outright. An element of the call site's
|
|
16
|
+
* own through `render` is marked `aria-disabled`, and an element handed in
|
|
17
|
+
* directly loses its `href`, `tabIndex` and `onClick`, so a link card can
|
|
18
|
+
* neither be followed nor focused. Has no effect on a card that is not
|
|
19
|
+
* `interactive`, which cannot be pressed to begin with.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
isDisabled?: boolean;
|
|
12
23
|
/**
|
|
13
24
|
* `none` removes the card's own padding, for a card whose children run to
|
|
14
25
|
* its edges — a list of rows separated by rules.
|
|
@@ -35,7 +46,7 @@ type CardVariant = 'elevated' | 'filled' | 'outlined';
|
|
|
35
46
|
* `<button>`, which is the right default for one that acts rather than
|
|
36
47
|
* navigates.
|
|
37
48
|
*/
|
|
38
|
-
declare function Card({ children, interactive, onClick, onContextMenu, onPointerCancel, onPointerDown, onPointerLeave, onPointerUp, padding, render, variant, ...props }: CardProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
49
|
+
declare function Card({ children, interactive, isDisabled, onClick, onContextMenu, onPointerCancel, onPointerDown, onPointerLeave, onPointerUp, padding, render, variant, ...props }: CardProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
39
50
|
//#endregion
|
|
40
51
|
export { type CardProps, type CardVariant, Card as default };
|
|
41
52
|
//# sourceMappingURL=index.d.ts.map
|