@kanso-labs/kanso-ui 0.40.9 → 0.41.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 +11 -2
- package/dist/components/app-bar/index.js +53 -46
- package/dist/components/app-bar/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/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/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 +86 -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 +1 -1
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
|
*
|
|
@@ -76,6 +76,15 @@ type AppBarProps = Omit<RenderComponentProps<'header'>, 'children'> & {
|
|
|
76
76
|
headline?: ReactNode;
|
|
77
77
|
/** Usually a back or menu icon button. Sits before the text. */
|
|
78
78
|
leading?: ReactNode;
|
|
79
|
+
/**
|
|
80
|
+
* Holds the bar at the top of its scroll container while the content
|
|
81
|
+
* scrolls beneath it, and keeps it painted over that content. The bar
|
|
82
|
+
* still needs a scrolling ancestor to stick inside: the window, or an
|
|
83
|
+
* element with its own overflow. A pinned bar is the one `collapsed` and
|
|
84
|
+
* `scrolled` are for.
|
|
85
|
+
* @default false
|
|
86
|
+
*/
|
|
87
|
+
pinned?: boolean;
|
|
79
88
|
/**
|
|
80
89
|
* Whether the content beneath has been scrolled. Material Design separates
|
|
81
90
|
* a bar from scrolled content with a fill colour rather than a shadow, and
|
|
@@ -112,7 +121,7 @@ type AppBarProps = Omit<RenderComponentProps<'header'>, 'children'> & {
|
|
|
112
121
|
* and `collapsed` exist. Neither watches the page: only the app knows which
|
|
113
122
|
* element scrolls, so both are set from its own scroll handler.
|
|
114
123
|
*/
|
|
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>>;
|
|
124
|
+
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
125
|
//#endregion
|
|
117
126
|
export { type AppBarProps, AppBar as default };
|
|
118
127
|
//# 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",
|
|
@@ -117,15 +123,16 @@ function AppBar(t0) {
|
|
|
117
123
|
let t4;
|
|
118
124
|
let t5;
|
|
119
125
|
if ($[0] !== t0) {
|
|
120
|
-
const { align: t6, collapsed: t7, contentInset: t8, contentMaxInlineSize: t9, headingLevel: t10, headline, leading,
|
|
121
|
-
render =
|
|
126
|
+
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;
|
|
127
|
+
render = t12;
|
|
122
128
|
const align = t6 === void 0 ? "start" : t6;
|
|
123
129
|
const collapsed = t7 === void 0 ? false : t7;
|
|
124
130
|
const contentInset = t8 === void 0 ? spacing.lg : t8;
|
|
125
131
|
const contentMaxInlineSize = t9 === void 0 ? "none" : t9;
|
|
126
132
|
const headingLevel = t10 === void 0 ? 1 : t10;
|
|
127
|
-
const
|
|
128
|
-
const
|
|
133
|
+
const pinned = t11 === void 0 ? false : t11;
|
|
134
|
+
const scrolled = t13 === void 0 ? false : t13;
|
|
135
|
+
const size = t14 === void 0 ? "sm" : t14;
|
|
129
136
|
const collapse = collapsed && size !== "sm";
|
|
130
137
|
const expandedHeight = hasContent(subtitle) ? HEIGHTS[size].withSubtitle : HEIGHTS[size].plain;
|
|
131
138
|
const height = collapse ? COLLAPSED_HEIGHT : expandedHeight;
|
|
@@ -134,29 +141,29 @@ function AppBar(t0) {
|
|
|
134
141
|
t5 = useRender;
|
|
135
142
|
t4 = "header";
|
|
136
143
|
t1 = props$1;
|
|
137
|
-
const
|
|
138
|
-
let
|
|
144
|
+
const t15 = props(styles.row, rowStyles.root(edgePadding(contentInset, hasLeading), edgePadding(contentInset, hasTrailing), contentMaxInlineSize));
|
|
145
|
+
let t16;
|
|
139
146
|
if ($[7] !== hasLeading || $[8] !== leading) {
|
|
140
|
-
|
|
147
|
+
t16 = !hasLeading ? null : /* @__PURE__ */ jsx("div", {
|
|
141
148
|
className: "x6s0dn4 x9f619 x78zum5 x2lah0s x1r8zjiw x1let9r4",
|
|
142
149
|
children: leading
|
|
143
150
|
});
|
|
144
151
|
$[7] = hasLeading;
|
|
145
152
|
$[8] = leading;
|
|
146
|
-
$[9] =
|
|
147
|
-
} else
|
|
148
|
-
let
|
|
153
|
+
$[9] = t16;
|
|
154
|
+
} else t16 = $[9];
|
|
155
|
+
let t17;
|
|
149
156
|
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
150
|
-
|
|
157
|
+
t17 = {
|
|
151
158
|
0: { className: "x9f619 x78zum5 xdt5ytf x1iyjqo2 xkjl1po xl56j7k xeuugli xj0a0fe x1cmllll" },
|
|
152
159
|
1: { className: "x9f619 x78zum5 xdt5ytf x1iyjqo2 xkjl1po xl56j7k xeuugli xj0a0fe x1cmllll x2b8uid" }
|
|
153
160
|
};
|
|
154
|
-
$[10] =
|
|
155
|
-
} else
|
|
156
|
-
const
|
|
157
|
-
let
|
|
161
|
+
$[10] = t17;
|
|
162
|
+
} else t17 = $[10];
|
|
163
|
+
const t18 = t17[!!(align === "center") << 0];
|
|
164
|
+
let t19;
|
|
158
165
|
if ($[11] !== collapse || $[12] !== headingLevel || $[13] !== headline || $[14] !== size) {
|
|
159
|
-
|
|
166
|
+
t19 = !hasContent(headline) ? null : /* @__PURE__ */ jsx(Text, {
|
|
160
167
|
className: "x12w9bfk xioksi3 x1nxaspg x1seskgd",
|
|
161
168
|
render: heading(headingLevel),
|
|
162
169
|
variant: collapse ? HEADLINE_VARIANT.sm : HEADLINE_VARIANT[size],
|
|
@@ -166,11 +173,11 @@ function AppBar(t0) {
|
|
|
166
173
|
$[12] = headingLevel;
|
|
167
174
|
$[13] = headline;
|
|
168
175
|
$[14] = size;
|
|
169
|
-
$[15] =
|
|
170
|
-
} else
|
|
171
|
-
let
|
|
176
|
+
$[15] = t19;
|
|
177
|
+
} else t19 = $[15];
|
|
178
|
+
let t20;
|
|
172
179
|
if ($[16] !== collapse || $[17] !== subtitle) {
|
|
173
|
-
|
|
180
|
+
t20 = !hasContent(subtitle) || collapse ? null : /* @__PURE__ */ jsx(Text, {
|
|
174
181
|
render: PARAGRAPH,
|
|
175
182
|
tone: "muted",
|
|
176
183
|
variant: "bodyMedium",
|
|
@@ -178,45 +185,45 @@ function AppBar(t0) {
|
|
|
178
185
|
});
|
|
179
186
|
$[16] = collapse;
|
|
180
187
|
$[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];
|
|
188
|
+
$[18] = t20;
|
|
189
|
+
} else t20 = $[18];
|
|
194
190
|
let t21;
|
|
191
|
+
if ($[19] !== t18 || $[20] !== t19 || $[21] !== t20) {
|
|
192
|
+
t21 = /* @__PURE__ */ jsxs("div", {
|
|
193
|
+
...t18,
|
|
194
|
+
children: [t19, t20]
|
|
195
|
+
});
|
|
196
|
+
$[19] = t18;
|
|
197
|
+
$[20] = t19;
|
|
198
|
+
$[21] = t20;
|
|
199
|
+
$[22] = t21;
|
|
200
|
+
} else t21 = $[22];
|
|
201
|
+
let t22;
|
|
195
202
|
if ($[23] !== hasTrailing || $[24] !== trailing) {
|
|
196
|
-
|
|
203
|
+
t22 = !hasTrailing ? null : /* @__PURE__ */ jsx("div", {
|
|
197
204
|
className: "x6s0dn4 x9f619 x78zum5 x2lah0s x1r8zjiw x1let9r4",
|
|
198
205
|
children: trailing
|
|
199
206
|
});
|
|
200
207
|
$[23] = hasTrailing;
|
|
201
208
|
$[24] = trailing;
|
|
202
|
-
$[25] =
|
|
203
|
-
} else
|
|
204
|
-
if ($[26] !==
|
|
209
|
+
$[25] = t22;
|
|
210
|
+
} else t22 = $[25];
|
|
211
|
+
if ($[26] !== t15 || $[27] !== t16 || $[28] !== t21 || $[29] !== t22) {
|
|
205
212
|
t2 = /* @__PURE__ */ jsxs("div", {
|
|
206
|
-
...
|
|
213
|
+
...t15,
|
|
207
214
|
children: [
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
215
|
+
t16,
|
|
216
|
+
t21,
|
|
217
|
+
t22
|
|
211
218
|
]
|
|
212
219
|
});
|
|
213
|
-
$[26] =
|
|
214
|
-
$[27] =
|
|
215
|
-
$[28] =
|
|
216
|
-
$[29] =
|
|
220
|
+
$[26] = t15;
|
|
221
|
+
$[27] = t16;
|
|
222
|
+
$[28] = t21;
|
|
223
|
+
$[29] = t22;
|
|
217
224
|
$[30] = t2;
|
|
218
225
|
} else t2 = $[30];
|
|
219
|
-
t3 = mergeStyles(props(styles.root, heightStyles.root(height), scrolled && styles.scrolled), props$1);
|
|
226
|
+
t3 = mergeStyles(props(styles.root, heightStyles.root(height), scrolled && styles.scrolled, pinned && styles.pinned), props$1);
|
|
220
227
|
$[0] = t0;
|
|
221
228
|
$[1] = render;
|
|
222
229
|
$[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,MAAM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P,EAAA;CAAA,IAAAQ;CAAA,IAAAR,EAAA,QAAAC,UAAAD,EAAA,QAAAK,MAAAL,EAAA,QAAAO,IAAA;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","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","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. 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 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. 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 * 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;EACRd,OAAO;CACT;CACAe,UAAU;EACRX,QAAQ;EACRY,QAAQ;EACRC,QAAQ;EAC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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,OA1BMnF,GAAU2F,EA0BhB;AAAC;;;;;;;;AAUJ,SAASe,YAAYjC,cAAsBgD,SAAkB;CAC3D,MAAMC,QAAQjD,aAAakD,KAAK,MAAM,MAAM,QAAQlD;CACpD,OAAOgD,UAAU,YAAYC,MAAK,KAAMhH,YAAW,KAAMgH;AAC3D"}
|
|
@@ -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
|
|
@@ -5,7 +5,8 @@ import { mergeStyles } from "../../styles/merge.js";
|
|
|
5
5
|
import { focus } from "../../styles/focus.js";
|
|
6
6
|
import { useRipple } from "../../hooks/useRipple.js";
|
|
7
7
|
import { c } from "react/compiler-runtime";
|
|
8
|
-
import {
|
|
8
|
+
import { cloneElement, isValidElement } from "react";
|
|
9
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
//#region src/components/card/index.tsx
|
|
10
11
|
const styles = {
|
|
11
12
|
base: {
|
|
@@ -26,6 +27,28 @@ const styles = {
|
|
|
26
27
|
kAzted: "x1us19tq",
|
|
27
28
|
$$css: true
|
|
28
29
|
},
|
|
30
|
+
disabled: {
|
|
31
|
+
kVAM5u: "xmnqt3w",
|
|
32
|
+
kkrTdU: "xt0e3qv",
|
|
33
|
+
$$css: true
|
|
34
|
+
},
|
|
35
|
+
disabledContent: {
|
|
36
|
+
kSiTet: "x1ppv7y9",
|
|
37
|
+
$$css: true
|
|
38
|
+
},
|
|
39
|
+
disabledElevated: {
|
|
40
|
+
kWkggS: "x1jfv5e4",
|
|
41
|
+
kGVxlE: "x1gnnqk1",
|
|
42
|
+
$$css: true
|
|
43
|
+
},
|
|
44
|
+
disabledFilled: {
|
|
45
|
+
kWkggS: "x6mg230",
|
|
46
|
+
$$css: true
|
|
47
|
+
},
|
|
48
|
+
disabledOutlined: {
|
|
49
|
+
kVAM5u: "x1y3ic1l xmnqt3w",
|
|
50
|
+
$$css: true
|
|
51
|
+
},
|
|
29
52
|
elevated: {
|
|
30
53
|
kWkggS: "x1vnz5z6",
|
|
31
54
|
kGVxlE: "x19efjv6",
|
|
@@ -92,87 +115,134 @@ const interactionStyles = {
|
|
|
92
115
|
* navigates.
|
|
93
116
|
*/
|
|
94
117
|
function Card(t0) {
|
|
95
|
-
const $ = c(
|
|
96
|
-
const { children, interactive: t1, onClick, onContextMenu, onPointerCancel, onPointerDown, onPointerLeave, onPointerUp, padding:
|
|
118
|
+
const $ = c(34);
|
|
119
|
+
const { children, interactive: t1, isDisabled: t2, onClick, onContextMenu, onPointerCancel, onPointerDown, onPointerLeave, onPointerUp, padding: t3, render, variant: t4, ...props$1 } = t0;
|
|
97
120
|
const interactive = t1 === void 0 ? false : t1;
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
121
|
+
const isDisabled = t2 === void 0 ? false : t2;
|
|
122
|
+
const padding = t3 === void 0 ? "default" : t3;
|
|
123
|
+
const variant = t4 === void 0 ? "elevated" : t4;
|
|
124
|
+
const disabled = interactive && isDisabled;
|
|
125
|
+
const t5 = disabled ? void 0 : onClick;
|
|
126
|
+
let t6;
|
|
127
|
+
if ($[0] !== onContextMenu || $[1] !== onPointerCancel || $[2] !== onPointerDown || $[3] !== onPointerLeave || $[4] !== onPointerUp || $[5] !== t5) {
|
|
128
|
+
t6 = {
|
|
129
|
+
onClick: t5,
|
|
104
130
|
onContextMenu,
|
|
105
131
|
onPointerCancel,
|
|
106
132
|
onPointerDown,
|
|
107
133
|
onPointerLeave,
|
|
108
134
|
onPointerUp
|
|
109
135
|
};
|
|
110
|
-
$[0] =
|
|
111
|
-
$[1] =
|
|
112
|
-
$[2] =
|
|
113
|
-
$[3] =
|
|
114
|
-
$[4] =
|
|
115
|
-
$[5] =
|
|
116
|
-
$[6] =
|
|
117
|
-
} else
|
|
118
|
-
const ripple = useRipple(interactive,
|
|
136
|
+
$[0] = onContextMenu;
|
|
137
|
+
$[1] = onPointerCancel;
|
|
138
|
+
$[2] = onPointerDown;
|
|
139
|
+
$[3] = onPointerLeave;
|
|
140
|
+
$[4] = onPointerUp;
|
|
141
|
+
$[5] = t5;
|
|
142
|
+
$[6] = t6;
|
|
143
|
+
} else t6 = $[6];
|
|
144
|
+
const ripple = useRipple(interactive && !disabled, t6);
|
|
119
145
|
const padded = padding === "none" ? styles.paddingNone : styles.paddingDefault;
|
|
120
|
-
const
|
|
121
|
-
let
|
|
146
|
+
const t7 = interactive ? "button" : "div";
|
|
147
|
+
let t8;
|
|
122
148
|
if ($[7] !== interactive || $[8] !== render) {
|
|
123
|
-
|
|
149
|
+
t8 = interactive && render === void 0 ? { type: "button" } : void 0;
|
|
124
150
|
$[7] = interactive;
|
|
125
151
|
$[8] = render;
|
|
126
|
-
$[9] =
|
|
127
|
-
} else
|
|
128
|
-
const
|
|
129
|
-
let
|
|
130
|
-
if ($[10] !==
|
|
131
|
-
|
|
132
|
-
|
|
152
|
+
$[9] = t8;
|
|
153
|
+
} else t8 = $[9];
|
|
154
|
+
const t9 = ripple.handlers;
|
|
155
|
+
let t10;
|
|
156
|
+
if ($[10] !== disabled || $[11] !== render) {
|
|
157
|
+
t10 = disabledAttributes(disabled, render);
|
|
158
|
+
$[10] = disabled;
|
|
159
|
+
$[11] = render;
|
|
160
|
+
$[12] = t10;
|
|
161
|
+
} else t10 = $[12];
|
|
162
|
+
let t11;
|
|
163
|
+
if ($[13] !== children || $[14] !== disabled || $[15] !== interactive) {
|
|
164
|
+
t11 = interactive ? /* @__PURE__ */ jsx("span", {
|
|
165
|
+
...{
|
|
166
|
+
0: { className: "x9f619 x1lliihq x1us19tq" },
|
|
167
|
+
1: { className: "x9f619 x1lliihq x1us19tq x1ppv7y9" }
|
|
168
|
+
}[!!disabled << 0],
|
|
133
169
|
children
|
|
134
170
|
}) : children;
|
|
135
|
-
$[
|
|
136
|
-
$[
|
|
137
|
-
$[
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
$[
|
|
143
|
-
$[
|
|
144
|
-
$[
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
171
|
+
$[13] = children;
|
|
172
|
+
$[14] = disabled;
|
|
173
|
+
$[15] = interactive;
|
|
174
|
+
$[16] = t11;
|
|
175
|
+
} else t11 = $[16];
|
|
176
|
+
let t12;
|
|
177
|
+
if ($[17] !== ripple.surface || $[18] !== t11) {
|
|
178
|
+
t12 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t11, ripple.surface] });
|
|
179
|
+
$[17] = ripple.surface;
|
|
180
|
+
$[18] = t11;
|
|
181
|
+
$[19] = t12;
|
|
182
|
+
} else t12 = $[19];
|
|
183
|
+
const t13 = mergeStyles(props(styles.base, styles[variant], padded, interactive && styles.interactive, interactive && variant !== "outlined" && styles.interactiveBoundary, interactive && !disabled && focus.ring, interactive && !disabled && interactionStyles[variant], disabled && styles.disabled, disabled && disabledStyles[variant]), props$1);
|
|
184
|
+
let t14;
|
|
185
|
+
if ($[20] !== props$1 || $[21] !== ripple.handlers || $[22] !== t10 || $[23] !== t12 || $[24] !== t13 || $[25] !== t8) {
|
|
186
|
+
t14 = {
|
|
150
187
|
...props$1,
|
|
151
|
-
...
|
|
152
|
-
...
|
|
153
|
-
|
|
154
|
-
|
|
188
|
+
...t8,
|
|
189
|
+
...t9,
|
|
190
|
+
...t10,
|
|
191
|
+
children: t12,
|
|
192
|
+
...t13
|
|
155
193
|
};
|
|
156
|
-
$[
|
|
157
|
-
$[
|
|
158
|
-
$[
|
|
159
|
-
$[
|
|
160
|
-
$[
|
|
161
|
-
$[
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
194
|
+
$[20] = props$1;
|
|
195
|
+
$[21] = ripple.handlers;
|
|
196
|
+
$[22] = t10;
|
|
197
|
+
$[23] = t12;
|
|
198
|
+
$[24] = t13;
|
|
199
|
+
$[25] = t8;
|
|
200
|
+
$[26] = t14;
|
|
201
|
+
} else t14 = $[26];
|
|
202
|
+
let t15;
|
|
203
|
+
if ($[27] !== disabled || $[28] !== render) {
|
|
204
|
+
t15 = disabled ? withoutActivation(render) : render;
|
|
205
|
+
$[27] = disabled;
|
|
206
|
+
$[28] = render;
|
|
207
|
+
$[29] = t15;
|
|
208
|
+
} else t15 = $[29];
|
|
209
|
+
let t16;
|
|
210
|
+
if ($[30] !== t14 || $[31] !== t15 || $[32] !== t7) {
|
|
211
|
+
t16 = {
|
|
212
|
+
defaultTagName: t7,
|
|
213
|
+
props: t14,
|
|
214
|
+
render: t15
|
|
169
215
|
};
|
|
170
|
-
$[
|
|
171
|
-
$[
|
|
172
|
-
$[
|
|
173
|
-
$[
|
|
174
|
-
} else
|
|
175
|
-
return useRender(
|
|
216
|
+
$[30] = t14;
|
|
217
|
+
$[31] = t15;
|
|
218
|
+
$[32] = t7;
|
|
219
|
+
$[33] = t16;
|
|
220
|
+
} else t16 = $[33];
|
|
221
|
+
return useRender(t16);
|
|
222
|
+
}
|
|
223
|
+
const disabledStyles = {
|
|
224
|
+
elevated: styles.disabledElevated,
|
|
225
|
+
filled: styles.disabledFilled,
|
|
226
|
+
outlined: styles.disabledOutlined
|
|
227
|
+
};
|
|
228
|
+
function disabledAttributes(disabled, render) {
|
|
229
|
+
if (!disabled) return;
|
|
230
|
+
if (render === void 0) return { disabled: true };
|
|
231
|
+
return {
|
|
232
|
+
"aria-disabled": true,
|
|
233
|
+
onClick: preventDefault
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function preventDefault(event) {
|
|
237
|
+
event.preventDefault();
|
|
238
|
+
}
|
|
239
|
+
function withoutActivation(render) {
|
|
240
|
+
if (!isValidElement(render)) return render;
|
|
241
|
+
return cloneElement(render, {
|
|
242
|
+
href: void 0,
|
|
243
|
+
onClick: preventDefault,
|
|
244
|
+
tabIndex: void 0
|
|
245
|
+
});
|
|
176
246
|
}
|
|
177
247
|
//#endregion
|
|
178
248
|
export { Card as default };
|