@kanso-labs/kanso-ui 0.44.0 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -7
- package/dist/chip/index.js +24 -4
- package/dist/chip/index.js.map +1 -1
- package/dist/chip/styles.js +13 -5
- package/dist/chip/styles.js.map +1 -1
- package/dist/components/app-bar/index.d.ts +23 -7
- package/dist/components/app-bar/index.js +428 -169
- package/dist/components/app-bar/index.js.map +1 -1
- package/dist/components/autocomplete/index.d.ts +44 -0
- package/dist/components/autocomplete/index.js +44 -0
- package/dist/components/autocomplete/index.js.map +1 -1
- package/dist/components/button/index.d.ts +3 -2
- package/dist/components/button/index.js +53 -59
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/card/index.d.ts +11 -3
- package/dist/components/card/index.js +23 -1
- package/dist/components/card/index.js.map +1 -1
- package/dist/components/checkbox/index.js +66 -58
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/chip/index.d.ts +46 -30
- package/dist/components/chip/index.js +38 -17
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/chip-group/index.d.ts +5 -2
- package/dist/components/chip-group/index.js +8 -2
- package/dist/components/chip-group/index.js.map +1 -1
- package/dist/components/dialog/index.d.ts +27 -0
- package/dist/components/dialog/index.js +107 -69
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/fab/index.d.ts +1 -1
- package/dist/components/fab/index.js.map +1 -1
- package/dist/components/form/index.d.ts +14 -4
- package/dist/components/form/index.js +6 -3
- package/dist/components/form/index.js.map +1 -1
- package/dist/components/icon-button/index.d.ts +15 -1
- package/dist/components/icon-button/index.js +15 -1
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/link/index.d.ts +4 -0
- package/dist/components/link/index.js +4 -0
- package/dist/components/link/index.js.map +1 -1
- package/dist/components/list/index.d.ts +34 -0
- package/dist/components/list/index.js +47 -13
- package/dist/components/list/index.js.map +1 -1
- package/dist/components/list-detail/index.d.ts +34 -1
- package/dist/components/list-detail/index.js +34 -1
- package/dist/components/list-detail/index.js.map +1 -1
- package/dist/components/list-item/index.d.ts +21 -2
- package/dist/components/list-item/index.js +6 -0
- package/dist/components/list-item/index.js.map +1 -1
- package/dist/components/menu/index.d.ts +6 -3
- package/dist/components/menu/index.js +3 -1
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/meter/index.d.ts +4 -0
- package/dist/components/meter/index.js +4 -0
- package/dist/components/meter/index.js.map +1 -1
- package/dist/components/navigation-bar/index.d.ts +14 -2
- package/dist/components/navigation-bar/index.js +14 -2
- package/dist/components/navigation-bar/index.js.map +1 -1
- package/dist/components/navigation-tree/index.js +2 -9
- package/dist/components/navigation-tree/index.js.map +1 -1
- package/dist/components/number-field/index.d.ts +7 -1
- package/dist/components/number-field/index.js +7 -1
- package/dist/components/number-field/index.js.map +1 -1
- package/dist/components/popover/index.d.ts +15 -1
- package/dist/components/popover/index.js +15 -1
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/product-icon/index.d.ts +8 -1
- package/dist/components/product-icon/index.js +8 -1
- package/dist/components/product-icon/index.js.map +1 -1
- package/dist/components/progress-indicator/index.d.ts +12 -6
- package/dist/components/progress-indicator/index.js +57 -46
- package/dist/components/progress-indicator/index.js.map +1 -1
- package/dist/components/radio-group/index.d.ts +7 -0
- package/dist/components/radio-group/index.js +23 -14
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/search-field/index.d.ts +13 -4
- package/dist/components/search-field/index.js +10 -4
- package/dist/components/search-field/index.js.map +1 -1
- package/dist/components/search-view/index.d.ts +2 -0
- package/dist/components/search-view/index.js.map +1 -1
- package/dist/components/segmented-button/index.d.ts +1 -1
- package/dist/components/segmented-button/index.js.map +1 -1
- package/dist/components/separator/index.d.ts +31 -6
- package/dist/components/separator/index.js +30 -6
- package/dist/components/separator/index.js.map +1 -1
- package/dist/components/sheet/index.d.ts +96 -37
- package/dist/components/sheet/index.js +420 -143
- package/dist/components/sheet/index.js.map +1 -1
- package/dist/components/snackbar/index.d.ts +8 -1
- package/dist/components/snackbar/index.js +7 -0
- package/dist/components/snackbar/index.js.map +1 -1
- package/dist/components/stack/index.d.ts +21 -5
- package/dist/components/stack/index.js +10 -0
- package/dist/components/stack/index.js.map +1 -1
- package/dist/components/switch/index.d.ts +12 -0
- package/dist/components/switch/index.js +13 -0
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/text-field/index.d.ts +39 -9
- package/dist/components/text-field/index.js +29 -7
- package/dist/components/text-field/index.js.map +1 -1
- package/dist/components/time-picker/index.js +37 -41
- package/dist/components/time-picker/index.js.map +1 -1
- package/dist/components/tree/index.js +11 -15
- package/dist/components/tree/index.js.map +1 -1
- package/dist/control/index.js +1 -1
- package/dist/control/index.js.map +1 -1
- package/dist/control/styles.js +0 -1
- package/dist/control/styles.js.map +1 -1
- package/dist/field/index.js +148 -139
- package/dist/field/index.js.map +1 -1
- package/dist/field/styles.js +50 -7
- package/dist/field/styles.js.map +1 -1
- package/dist/hooks/useBottomEdge.js +6 -3
- package/dist/hooks/useBottomEdge.js.map +1 -1
- package/dist/hooks/useRipple.js +217 -193
- package/dist/hooks/useRipple.js.map +1 -1
- package/dist/i18n/index.js +1 -0
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.js +34 -0
- package/dist/i18n/messages.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/indicator/styles.js +7 -4
- package/dist/indicator/styles.js.map +1 -1
- package/dist/layout.d.ts +4 -1
- package/dist/layout.js +4 -1
- package/dist/layout.js.map +1 -1
- package/dist/mark/styles.js +11 -5
- package/dist/mark/styles.js.map +1 -1
- package/dist/react-aria.d.ts +2 -2
- package/dist/row/index.js +90 -62
- package/dist/row/index.js.map +1 -1
- package/dist/row/styles.js +8 -2
- package/dist/row/styles.js.map +1 -1
- package/dist/styles/focus.js.map +1 -1
- package/dist/styles/overlay.js +8 -5
- package/dist/styles/overlay.js.map +1 -1
- package/dist/styles.css +252 -130
- package/dist/theme-scope.d.ts +14 -2
- package/dist/theme-scope.js +12 -0
- package/dist/theme-scope.js.map +1 -1
- package/package.json +3 -3
- package/dist/overlay/modal.js +0 -7
- package/dist/overlay/modal.js.map +0 -1
|
@@ -4,12 +4,14 @@ import { spacing } from "../../tokens/design.tokens.stylex.js";
|
|
|
4
4
|
import { hasContent } from "../../render/content.js";
|
|
5
5
|
import { useRender } from "../../render/useRender.js";
|
|
6
6
|
import { mergeStyles } from "../../styles/merge.js";
|
|
7
|
+
import { motionDurationMs, motionEasing } from "../../tokens/values.js";
|
|
7
8
|
import Text from "../text/index.js";
|
|
8
9
|
import { c } from "react/compiler-runtime";
|
|
9
|
-
import { createElement } from "react";
|
|
10
|
+
import { createElement, useLayoutEffect, useRef } from "react";
|
|
10
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
12
|
//#region src/components/app-bar/index.tsx
|
|
12
|
-
const
|
|
13
|
+
const ICON_BUTTON_TARGET = "48px";
|
|
14
|
+
const GLYPH_INSET = `(${ICON_BUTTON_TARGET} - 24px) / 2`;
|
|
13
15
|
const HEIGHTS = {
|
|
14
16
|
lg: {
|
|
15
17
|
plain: "120px",
|
|
@@ -34,21 +36,21 @@ const styles = {
|
|
|
34
36
|
},
|
|
35
37
|
root: {
|
|
36
38
|
k6CgDc: "x12w9bfk",
|
|
37
|
-
kGNEyG: "
|
|
39
|
+
kGNEyG: "x1qjc9v5",
|
|
38
40
|
kWkggS: "x14s9m32",
|
|
39
41
|
kB7OPa: "x9f619",
|
|
40
42
|
k1xSpc: "x78zum5",
|
|
41
43
|
kjj79g: "xl56j7k",
|
|
42
44
|
kIyJzY: "xioksi3",
|
|
43
|
-
k1ekBW: "
|
|
45
|
+
k1ekBW: "x15406qy",
|
|
44
46
|
kAMwcw: "x1seskgd",
|
|
45
47
|
$$css: true
|
|
46
48
|
},
|
|
47
49
|
row: {
|
|
48
|
-
|
|
50
|
+
kfiyM8: "x10ukxgv",
|
|
49
51
|
kB7OPa: "x9f619",
|
|
50
|
-
k1xSpc: "
|
|
51
|
-
|
|
52
|
+
k1xSpc: "xrvj5dj",
|
|
53
|
+
kC13JO: "x97ohe",
|
|
52
54
|
kzqmXN: "xh8yej3",
|
|
53
55
|
kUOVxO: "xvueqy4",
|
|
54
56
|
$$css: true
|
|
@@ -59,13 +61,61 @@ const styles = {
|
|
|
59
61
|
kfdmCh: "xe3zi7u",
|
|
60
62
|
kt9PQ7: "x15anc7y",
|
|
61
63
|
$$css: true
|
|
64
|
+
},
|
|
65
|
+
text: {
|
|
66
|
+
kSGwAc: "xamitd3",
|
|
67
|
+
kB7OPa: "x9f619",
|
|
68
|
+
k1xSpc: "x78zum5",
|
|
69
|
+
kXwgrk: "xdt5ytf",
|
|
70
|
+
kJuA4N: "x12gd1sl",
|
|
71
|
+
kE4Cay: "xkjl1po",
|
|
72
|
+
k7Eaqz: "xeuugli",
|
|
73
|
+
kHjlTd: "xj0a0fe",
|
|
74
|
+
k8WAf4: "x1cmllll",
|
|
75
|
+
$$css: true
|
|
76
|
+
},
|
|
77
|
+
textBelow: {
|
|
78
|
+
kSGwAc: "xnav3zx",
|
|
79
|
+
k8WAf4: "xt970qd",
|
|
80
|
+
$$css: true
|
|
81
|
+
},
|
|
82
|
+
textCenter: {
|
|
83
|
+
k9WMMc: "x2b8uid",
|
|
84
|
+
$$css: true
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const twoRows = {
|
|
88
|
+
lg: {
|
|
89
|
+
kTDh7v: "x1mna9mr",
|
|
90
|
+
k4zj60: "x1gmr53x",
|
|
91
|
+
kWgvks: "xx38sju",
|
|
92
|
+
k5JduY: "x1s928wv",
|
|
93
|
+
kVb13B: "x1vlsijy",
|
|
94
|
+
k5jvz2: "x1fh8phi",
|
|
95
|
+
kC13JO: "xc3o5yk",
|
|
96
|
+
$$css: true
|
|
97
|
+
},
|
|
98
|
+
md: {
|
|
99
|
+
kTDh7v: "x1mna9mr",
|
|
100
|
+
k4zj60: "x1gmr53x",
|
|
101
|
+
kWgvks: "xx38sju",
|
|
102
|
+
k5JduY: "x1s928wv",
|
|
103
|
+
kVb13B: "x1vlsijy",
|
|
104
|
+
k5jvz2: "x1v6yq59",
|
|
105
|
+
kC13JO: "xc3o5yk",
|
|
106
|
+
$$css: true
|
|
62
107
|
}
|
|
63
108
|
};
|
|
64
109
|
const HEADLINE_VARIANT = {
|
|
65
|
-
lg: "
|
|
66
|
-
md: "
|
|
110
|
+
lg: "displaySmall",
|
|
111
|
+
md: "headlineMedium",
|
|
67
112
|
sm: "titleLarge"
|
|
68
113
|
};
|
|
114
|
+
const SUBTITLE_VARIANT = {
|
|
115
|
+
lg: "titleMedium",
|
|
116
|
+
md: "labelLarge",
|
|
117
|
+
sm: "labelMedium"
|
|
118
|
+
};
|
|
69
119
|
const HEADINGS = [
|
|
70
120
|
"h1",
|
|
71
121
|
"h2",
|
|
@@ -87,26 +137,59 @@ const _temp2 = {
|
|
|
87
137
|
ks0D6T: "x13i5qev",
|
|
88
138
|
"$$css": true
|
|
89
139
|
};
|
|
90
|
-
const rowStyles = {
|
|
91
|
-
|
|
92
|
-
|
|
140
|
+
const rowStyles = {
|
|
141
|
+
root: (start, end, maxInlineSize) => [
|
|
142
|
+
_temp2,
|
|
143
|
+
{
|
|
144
|
+
kwRFfy: end != null ? "x120eax6" : end,
|
|
145
|
+
kZCmMZ: start != null ? "xnvo3vl" : start,
|
|
146
|
+
$$css: true
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"--x-maxInlineSize": ((val) => typeof val === "number" ? val + "px" : val != null ? val : void 0)(maxInlineSize),
|
|
150
|
+
"--x-paddingInlineEnd": ((val) => typeof val === "number" ? val + "px" : val != null ? val : void 0)(end),
|
|
151
|
+
"--x-paddingInlineStart": ((val) => typeof val === "number" ? val + "px" : val != null ? val : void 0)(start)
|
|
152
|
+
}
|
|
153
|
+
],
|
|
154
|
+
tracks: (gridTemplateColumns, gridTemplateRows) => [{
|
|
155
|
+
kumcoG: gridTemplateColumns != null ? "xqketvx" : gridTemplateColumns,
|
|
156
|
+
k9llMU: gridTemplateRows != null ? "x1xxtoay" : gridTemplateRows,
|
|
157
|
+
$$css: true
|
|
158
|
+
}, {
|
|
159
|
+
"--x-gridTemplateColumns": gridTemplateColumns != null ? gridTemplateColumns : void 0,
|
|
160
|
+
"--x-gridTemplateRows": gridTemplateRows != null ? gridTemplateRows : void 0
|
|
161
|
+
}]
|
|
162
|
+
};
|
|
163
|
+
const START_COLUMNS = "auto minmax(0, 1fr) auto";
|
|
164
|
+
const _temp3 = {
|
|
165
|
+
keoZOQ: "x1vhfslr",
|
|
166
|
+
"$$css": true
|
|
167
|
+
};
|
|
168
|
+
const textStyles = {
|
|
169
|
+
inset: (start, end) => [{
|
|
93
170
|
kwRFfy: end != null ? "x120eax6" : end,
|
|
94
171
|
kZCmMZ: start != null ? "xnvo3vl" : start,
|
|
95
172
|
$$css: true
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
"--x-maxInlineSize": ((val) => typeof val === "number" ? val + "px" : val != null ? val : void 0)(maxInlineSize),
|
|
173
|
+
}, {
|
|
99
174
|
"--x-paddingInlineEnd": ((val) => typeof val === "number" ? val + "px" : val != null ? val : void 0)(end),
|
|
100
175
|
"--x-paddingInlineStart": ((val) => typeof val === "number" ? val + "px" : val != null ? val : void 0)(start)
|
|
101
|
-
}
|
|
102
|
-
|
|
176
|
+
}],
|
|
177
|
+
reach: (marginBlockStart) => [_temp3, { "--x-marginBlockStart": ((val) => typeof val === "number" ? val + "px" : val != null ? val : void 0)(marginBlockStart) }]
|
|
178
|
+
};
|
|
179
|
+
const UNDER_TARGETS = `calc((${COLLAPSED_HEIGHT} - ${ICON_BUTTON_TARGET}) / 2)`;
|
|
180
|
+
const LINES = [":scope > :is(h1, h2, h3, h4, h5, h6)", ":scope > p"];
|
|
103
181
|
/**
|
|
104
182
|
* Material Design's app bar: the container at the top of a page carrying its
|
|
105
183
|
* title, one or two actions, and the way back out.
|
|
106
184
|
*
|
|
185
|
+
* ```tsx
|
|
186
|
+
* <AppBar headline="Headline" leading={back} size="md" trailing={actions} />
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
107
189
|
* Three sizes. `sm` is a fixed 64px bar for a page whose title is a label;
|
|
108
190
|
* `md` and `lg` are the flexible bars, which give the headline a larger
|
|
109
|
-
* type role and grow to fit a subtitle
|
|
191
|
+
* type role in a row of its own under the slots, and grow to fit a subtitle
|
|
192
|
+
* or a headline that wraps.
|
|
110
193
|
*
|
|
111
194
|
* It paints its own surface, unlike the layout components, because separating
|
|
112
195
|
* itself from the content beneath is the job — which is also why `scrolled`
|
|
@@ -114,167 +197,343 @@ const rowStyles = { root: (start, end, maxInlineSize) => [
|
|
|
114
197
|
* element scrolls, so both are set from its own scroll handler.
|
|
115
198
|
*/
|
|
116
199
|
function AppBar(t0) {
|
|
117
|
-
const $ = c(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
]
|
|
218
|
-
});
|
|
219
|
-
$[26] = t15;
|
|
220
|
-
$[27] = t16;
|
|
221
|
-
$[28] = t21;
|
|
222
|
-
$[29] = t22;
|
|
223
|
-
$[30] = t2;
|
|
224
|
-
} else t2 = $[30];
|
|
225
|
-
t3 = mergeStyles(props(styles.root, heightStyles.root(height), scrolled && styles.scrolled, pinned && styles.pinned), props$1);
|
|
226
|
-
$[0] = t0;
|
|
227
|
-
$[1] = render;
|
|
228
|
-
$[2] = t1;
|
|
229
|
-
$[3] = t2;
|
|
230
|
-
$[4] = t3;
|
|
231
|
-
$[5] = t4;
|
|
232
|
-
$[6] = t5;
|
|
233
|
-
} else {
|
|
234
|
-
render = $[1];
|
|
235
|
-
t1 = $[2];
|
|
236
|
-
t2 = $[3];
|
|
237
|
-
t3 = $[4];
|
|
238
|
-
t4 = $[5];
|
|
239
|
-
t5 = $[6];
|
|
240
|
-
}
|
|
241
|
-
let t6;
|
|
242
|
-
if ($[31] !== t1 || $[32] !== t2 || $[33] !== t3) {
|
|
243
|
-
t6 = {
|
|
244
|
-
...t1,
|
|
245
|
-
children: t2,
|
|
246
|
-
...t3
|
|
200
|
+
const $ = c(29);
|
|
201
|
+
const { align: t1, collapsed: t2, contentInset: t3, contentMaxInlineSize: t4, headingLevel: t5, headline, leading, pinned: t6, render, scrolled: t7, size: t8, subtitle, trailing, ...props$1 } = t0;
|
|
202
|
+
const align = t1 === void 0 ? "start" : t1;
|
|
203
|
+
const collapsed = t2 === void 0 ? false : t2;
|
|
204
|
+
const contentInset = t3 === void 0 ? spacing.lg : t3;
|
|
205
|
+
const contentMaxInlineSize = t4 === void 0 ? "none" : t4;
|
|
206
|
+
const headingLevel = t5 === void 0 ? 1 : t5;
|
|
207
|
+
const pinned = t6 === void 0 ? false : t6;
|
|
208
|
+
const scrolled = t7 === void 0 ? false : t7;
|
|
209
|
+
const size = t8 === void 0 ? "sm" : t8;
|
|
210
|
+
const collapse = collapsed && size !== "sm";
|
|
211
|
+
const below = size !== "sm" && !collapse;
|
|
212
|
+
const expandedHeight = hasContent(subtitle) ? HEIGHTS[size].withSubtitle : HEIGHTS[size].plain;
|
|
213
|
+
const height = collapse ? COLLAPSED_HEIGHT : expandedHeight;
|
|
214
|
+
const hasLeading = hasContent(leading);
|
|
215
|
+
const hasTrailing = hasContent(trailing);
|
|
216
|
+
const centred = align === "center";
|
|
217
|
+
const hasSlot = hasLeading || hasTrailing;
|
|
218
|
+
const padsForStart = centred ? hasSlot : hasLeading;
|
|
219
|
+
const padsForEnd = centred ? hasSlot : hasTrailing;
|
|
220
|
+
const textRef = useCollapseMotion(collapse, align);
|
|
221
|
+
const t9 = "header";
|
|
222
|
+
const t10 = props(styles.row, rowStyles.root(edgePadding(contentInset, padsForStart), edgePadding(contentInset, padsForEnd), contentMaxInlineSize), rowStyles.tracks(centred ? centredColumns(contentInset, hasLeading, hasTrailing) : START_COLUMNS, below ? `minmax(${COLLAPSED_HEIGHT}, auto) 1fr` : `minmax(${COLLAPSED_HEIGHT}, auto)`), heightStyles.root(height), below && twoRows[size]);
|
|
223
|
+
const t11 = !hasLeading ? null : /* @__PURE__ */ jsx("div", {
|
|
224
|
+
className: "x6s0dn4 xamitd3 x9f619 x78zum5 x1r8zjiw x1let9r4 x155k8fu x139gbkf x1kxrqrs x1lqcxt8 x15ir4sr",
|
|
225
|
+
children: leading
|
|
226
|
+
});
|
|
227
|
+
const t12 = props(styles.text, below && styles.textBelow, below && textStyles.inset(glyphRoom(contentInset, padsForStart), glyphRoom(contentInset, padsForEnd)), below && textStyles.reach(`calc(-1 * ${UNDER_TARGETS})`), align === "center" && styles.textCenter);
|
|
228
|
+
let t13;
|
|
229
|
+
if ($[0] !== collapse || $[1] !== headingLevel || $[2] !== headline || $[3] !== size) {
|
|
230
|
+
t13 = !hasContent(headline) ? null : /* @__PURE__ */ jsx(Text, {
|
|
231
|
+
render: heading(headingLevel),
|
|
232
|
+
variant: collapse ? HEADLINE_VARIANT.sm : HEADLINE_VARIANT[size],
|
|
233
|
+
children: headline
|
|
234
|
+
});
|
|
235
|
+
$[0] = collapse;
|
|
236
|
+
$[1] = headingLevel;
|
|
237
|
+
$[2] = headline;
|
|
238
|
+
$[3] = size;
|
|
239
|
+
$[4] = t13;
|
|
240
|
+
} else t13 = $[4];
|
|
241
|
+
let t14;
|
|
242
|
+
if ($[5] !== collapse || $[6] !== size || $[7] !== subtitle) {
|
|
243
|
+
t14 = !hasContent(subtitle) ? null : /* @__PURE__ */ jsx(Text, {
|
|
244
|
+
render: PARAGRAPH,
|
|
245
|
+
tone: "muted",
|
|
246
|
+
variant: collapse ? SUBTITLE_VARIANT.sm : SUBTITLE_VARIANT[size],
|
|
247
|
+
children: subtitle
|
|
248
|
+
});
|
|
249
|
+
$[5] = collapse;
|
|
250
|
+
$[6] = size;
|
|
251
|
+
$[7] = subtitle;
|
|
252
|
+
$[8] = t14;
|
|
253
|
+
} else t14 = $[8];
|
|
254
|
+
let t15;
|
|
255
|
+
if ($[9] !== t12 || $[10] !== t13 || $[11] !== t14 || $[12] !== textRef) {
|
|
256
|
+
t15 = /* @__PURE__ */ jsxs("div", {
|
|
257
|
+
...t12,
|
|
258
|
+
ref: textRef,
|
|
259
|
+
children: [t13, t14]
|
|
260
|
+
});
|
|
261
|
+
$[9] = t12;
|
|
262
|
+
$[10] = t13;
|
|
263
|
+
$[11] = t14;
|
|
264
|
+
$[12] = textRef;
|
|
265
|
+
$[13] = t15;
|
|
266
|
+
} else t15 = $[13];
|
|
267
|
+
let t16;
|
|
268
|
+
if ($[14] !== hasTrailing || $[15] !== trailing) {
|
|
269
|
+
t16 = !hasTrailing ? null : /* @__PURE__ */ jsx("div", {
|
|
270
|
+
className: "x6s0dn4 xamitd3 x9f619 x78zum5 x1r8zjiw x1let9r4 x1w5n3ug x1txd71x x1qab1bc x6aqprb",
|
|
271
|
+
children: trailing
|
|
272
|
+
});
|
|
273
|
+
$[14] = hasTrailing;
|
|
274
|
+
$[15] = trailing;
|
|
275
|
+
$[16] = t16;
|
|
276
|
+
} else t16 = $[16];
|
|
277
|
+
let t17;
|
|
278
|
+
if ($[17] !== t10 || $[18] !== t11 || $[19] !== t15 || $[20] !== t16) {
|
|
279
|
+
t17 = /* @__PURE__ */ jsxs("div", {
|
|
280
|
+
...t10,
|
|
281
|
+
children: [
|
|
282
|
+
t11,
|
|
283
|
+
t15,
|
|
284
|
+
t16
|
|
285
|
+
]
|
|
286
|
+
});
|
|
287
|
+
$[17] = t10;
|
|
288
|
+
$[18] = t11;
|
|
289
|
+
$[19] = t15;
|
|
290
|
+
$[20] = t16;
|
|
291
|
+
$[21] = t17;
|
|
292
|
+
} else t17 = $[21];
|
|
293
|
+
const t18 = mergeStyles(props(styles.root, heightStyles.root(height), scrolled && styles.scrolled, pinned && styles.pinned), props$1);
|
|
294
|
+
let t19;
|
|
295
|
+
if ($[22] !== props$1 || $[23] !== t17 || $[24] !== t18) {
|
|
296
|
+
t19 = {
|
|
297
|
+
...props$1,
|
|
298
|
+
children: t17,
|
|
299
|
+
...t18
|
|
247
300
|
};
|
|
248
|
-
$[
|
|
249
|
-
$[
|
|
250
|
-
$[
|
|
251
|
-
$[
|
|
252
|
-
} else
|
|
253
|
-
let
|
|
254
|
-
if ($[
|
|
255
|
-
|
|
256
|
-
defaultTagName:
|
|
257
|
-
props:
|
|
301
|
+
$[22] = props$1;
|
|
302
|
+
$[23] = t17;
|
|
303
|
+
$[24] = t18;
|
|
304
|
+
$[25] = t19;
|
|
305
|
+
} else t19 = $[25];
|
|
306
|
+
let t20;
|
|
307
|
+
if ($[26] !== render || $[27] !== t19) {
|
|
308
|
+
t20 = {
|
|
309
|
+
defaultTagName: t9,
|
|
310
|
+
props: t19,
|
|
258
311
|
render
|
|
259
312
|
};
|
|
260
|
-
$[
|
|
261
|
-
$[
|
|
262
|
-
$[
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
return t5(t7);
|
|
313
|
+
$[26] = render;
|
|
314
|
+
$[27] = t19;
|
|
315
|
+
$[28] = t20;
|
|
316
|
+
} else t20 = $[28];
|
|
317
|
+
return useRender(t20);
|
|
266
318
|
}
|
|
267
319
|
/**
|
|
268
|
-
*
|
|
320
|
+
* A centred bar's columns: the text in the middle at its own width, and a
|
|
321
|
+
* column either side sharing what it leaves equally, so the text is centred
|
|
322
|
+
* on the row. A side column is never narrower than its slot, which is what
|
|
323
|
+
* moves the text off the middle when a slot is wider than the other side's
|
|
324
|
+
* share, and never as far as overlapping it.
|
|
269
325
|
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
326
|
+
* The row pads both edges for a slot, so the two sides match, and an edge
|
|
327
|
+
* with no slot puts back what that padding held off for a glyph as its
|
|
328
|
+
* column's least width. A headline long enough to reach that edge stops on
|
|
329
|
+
* the inset, as it does at the start.
|
|
330
|
+
*/
|
|
331
|
+
function centredColumns(contentInset, hasLeading, hasTrailing) {
|
|
332
|
+
const room = glyphRoom(contentInset, hasLeading || hasTrailing);
|
|
333
|
+
const side = (hasSlot) => hasSlot ? "minmax(auto, 1fr)" : `minmax(${room}, 1fr)`;
|
|
334
|
+
return `${side(hasLeading)} auto ${side(hasTrailing)}`;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Where an animation still under way has the bar and the text drawn: the
|
|
338
|
+
* height it holds the bar at, and each line where its transform has taken it
|
|
339
|
+
* and at the size its scale has reached. A line scales about the point it
|
|
340
|
+
* hangs from, so the transform's translation is how far that point has moved.
|
|
273
341
|
*/
|
|
342
|
+
function drawnAt(bar, text, settled) {
|
|
343
|
+
return {
|
|
344
|
+
height: bar.getBoundingClientRect().height,
|
|
345
|
+
lines: LINES.map((selector, index) => {
|
|
346
|
+
const line = settled.lines[index];
|
|
347
|
+
const element = text.querySelector(selector);
|
|
348
|
+
if (line === null || element === null) return null;
|
|
349
|
+
const moved = matrixOf(element);
|
|
350
|
+
return {
|
|
351
|
+
size: line.size * moved.a,
|
|
352
|
+
x: line.x + moved.e,
|
|
353
|
+
y: line.y + moved.f
|
|
354
|
+
};
|
|
355
|
+
})
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
/** The row's padding on one edge, for the inset the call site gave. */
|
|
274
359
|
function edgePadding(contentInset, hasSlot) {
|
|
275
|
-
const inset = contentInset
|
|
360
|
+
const inset = withUnit(contentInset);
|
|
276
361
|
return hasSlot ? `max(0px, ${inset} - ${GLYPH_INSET})` : inset;
|
|
277
362
|
}
|
|
363
|
+
/**
|
|
364
|
+
* Where the bar and each of the text's lines are drawn. A line's point is on
|
|
365
|
+
* the edge its text hangs from: the middle when it is centred, and the start
|
|
366
|
+
* edge otherwise, which is the right edge in a right-to-left page. Each line
|
|
367
|
+
* is as wide as the text block, so that edge is its box's.
|
|
368
|
+
*/
|
|
369
|
+
function geometryOf(bar, text, align) {
|
|
370
|
+
const frame = bar.getBoundingClientRect();
|
|
371
|
+
return {
|
|
372
|
+
height: frame.height,
|
|
373
|
+
lines: LINES.map((selector) => {
|
|
374
|
+
const element = text.querySelector(selector);
|
|
375
|
+
if (element === null) return null;
|
|
376
|
+
const box = element.getBoundingClientRect();
|
|
377
|
+
const edge = align === "center" ? (box.left + box.right) / 2 : isRightToLeft(element) ? box.right : box.left;
|
|
378
|
+
return {
|
|
379
|
+
size: Number.parseFloat(getComputedStyle(element).fontSize),
|
|
380
|
+
x: edge - frame.left,
|
|
381
|
+
y: glyphTopOf(element) - frame.top
|
|
382
|
+
};
|
|
383
|
+
})
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* What the row's padding held back on one edge for a slot's glyph, which the
|
|
388
|
+
* text in the second row puts back: the inset less `edgePadding`, so the
|
|
389
|
+
* smaller of the inset and GLYPH_INSET.
|
|
390
|
+
*/
|
|
391
|
+
function glyphRoom(contentInset, hasSlot) {
|
|
392
|
+
return hasSlot ? `min(${withUnit(contentInset)}, ${GLYPH_INSET})` : "0px";
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Where an element's first glyphs start, which is below its box's top by
|
|
396
|
+
* half its line's leading. The leading is a share of the line height, and
|
|
397
|
+
* the two roles a line moves between do not keep line height and type size
|
|
398
|
+
* in one ratio, so a line scaled by its type size from its box's corner
|
|
399
|
+
* starts its glyphs off where they were drawn: about a pixel, for a large
|
|
400
|
+
* bar's headline.
|
|
401
|
+
*/
|
|
402
|
+
function glyphTopOf(element) {
|
|
403
|
+
const range = document.createRange();
|
|
404
|
+
range.selectNodeContents(element);
|
|
405
|
+
const first = range.getClientRects().item(0);
|
|
406
|
+
return first === null ? element.getBoundingClientRect().top : first.top;
|
|
407
|
+
}
|
|
408
|
+
/** Whether the text runs right to left, which decides the edge it hangs from. */
|
|
409
|
+
function isRightToLeft(element) {
|
|
410
|
+
return getComputedStyle(element).direction === "rtl";
|
|
411
|
+
}
|
|
412
|
+
/** The transform an element is drawn with, `none` reading as no change. */
|
|
413
|
+
function matrixOf(element) {
|
|
414
|
+
return new DOMMatrixReadOnly(getComputedStyle(element).transform);
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* The point a line scales about, in its own box: the top of its glyphs, on
|
|
418
|
+
* the edge its text hangs from.
|
|
419
|
+
*/
|
|
420
|
+
function originOf(element, align) {
|
|
421
|
+
return `${align === "center" ? "center" : isRightToLeft(element) ? "right" : "left"} ${glyphTopOf(element) - element.getBoundingClientRect().top}px`;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Read when the bar changes state rather than once at mount, so a reader who
|
|
425
|
+
* changes the setting is answered by the next collapse.
|
|
426
|
+
*/
|
|
427
|
+
function prefersReducedMotion() {
|
|
428
|
+
return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Animates a flexible bar between its two states, and returns the ref for the
|
|
432
|
+
* text block whose lines it moves.
|
|
433
|
+
*
|
|
434
|
+
* Collapsing changes the bar's layout rather than a value — the text leaves
|
|
435
|
+
* the second row for the strip, both lines take the small bar's type roles,
|
|
436
|
+
* and the bar's height drops from a minimum to whatever its content takes —
|
|
437
|
+
* so there is nothing for a CSS transition to interpolate. This plays it the
|
|
438
|
+
* other way round: the change has already been laid out when the effect runs,
|
|
439
|
+
* so the bar is animated from the height it had to the one it has, and each
|
|
440
|
+
* line from where and how large it was drawn to where and how large it is,
|
|
441
|
+
* by a transform that starts at the difference and ends at none. A line
|
|
442
|
+
* scales about the point its glyphs hang from, which is what lands its first
|
|
443
|
+
* frame on the glyphs it replaces — see glyphTopOf. A scale rather than a
|
|
444
|
+
* transition of the type itself, which would lay the text out again on every
|
|
445
|
+
* frame and move it away from the place it was measured at. Each line moves
|
|
446
|
+
* on its own rather than with the block, since the subtitle starts under the
|
|
447
|
+
* headline's line, whose height changes with its role. The slots need
|
|
448
|
+
* nothing: they are in the strip in both states.
|
|
449
|
+
*
|
|
450
|
+
* The bar's height is animated through `min-block-size` as well as its
|
|
451
|
+
* height, since the minimum would otherwise hold an expanding bar at its new
|
|
452
|
+
* height from the first frame, and it is clipped while it moves, since an
|
|
453
|
+
* expanding bar's second row is laid out at full height from the start.
|
|
454
|
+
*
|
|
455
|
+
* Where the text was is measured after every commit that leaves the state
|
|
456
|
+
* alone, so it is current when the state does change. A change that lands
|
|
457
|
+
* while the last one is still moving starts from where the bar and the text
|
|
458
|
+
* are drawn at that moment, read off the running animations, so reversing
|
|
459
|
+
* mid-way turns round rather than jumping to the end first.
|
|
460
|
+
*
|
|
461
|
+
* Its timing is the root's `background-color` transition's, the `medium1`
|
|
462
|
+
* duration and the emphasized curve, so the fill and the height move as one.
|
|
463
|
+
* Those come from tokens/values rather than the theme, since `animate()`
|
|
464
|
+
* throws on a var(), and the motion is skipped under reduced motion, as the
|
|
465
|
+
* root's transition is.
|
|
466
|
+
*/
|
|
467
|
+
function useCollapseMotion(collapse, align) {
|
|
468
|
+
const $ = c(4);
|
|
469
|
+
const textRef = useRef(null);
|
|
470
|
+
const settled = useRef(null);
|
|
471
|
+
const collapsedBefore = useRef(collapse);
|
|
472
|
+
let t0;
|
|
473
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
474
|
+
t0 = [];
|
|
475
|
+
$[0] = t0;
|
|
476
|
+
} else t0 = $[0];
|
|
477
|
+
const animations = useRef(t0);
|
|
478
|
+
let t1;
|
|
479
|
+
if ($[1] !== align || $[2] !== collapse) {
|
|
480
|
+
t1 = () => {
|
|
481
|
+
const text = textRef.current;
|
|
482
|
+
const bar = text?.parentElement?.parentElement;
|
|
483
|
+
if (text == null || bar == null) return;
|
|
484
|
+
const moving = animations.current.some(_temp4);
|
|
485
|
+
if (collapsedBefore.current === collapse) {
|
|
486
|
+
if (!moving) settled.current = geometryOf(bar, text, align);
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
collapsedBefore.current = collapse;
|
|
490
|
+
const last = settled.current;
|
|
491
|
+
const from = moving && last !== null ? drawnAt(bar, text, last) : last;
|
|
492
|
+
for (const animation_0 of animations.current) animation_0.cancel();
|
|
493
|
+
animations.current = [];
|
|
494
|
+
const to = geometryOf(bar, text, align);
|
|
495
|
+
settled.current = to;
|
|
496
|
+
if (from === null || prefersReducedMotion()) return;
|
|
497
|
+
const timing = {
|
|
498
|
+
duration: motionDurationMs.medium1,
|
|
499
|
+
easing: motionEasing.emphasized
|
|
500
|
+
};
|
|
501
|
+
const heights = [`${from.height}px`, `${to.height}px`];
|
|
502
|
+
animations.current = [bar.animate({
|
|
503
|
+
blockSize: heights,
|
|
504
|
+
clipPath: ["inset(0)", "inset(0)"],
|
|
505
|
+
minBlockSize: heights
|
|
506
|
+
}, timing)];
|
|
507
|
+
for (const [index, selector] of LINES.entries()) {
|
|
508
|
+
const element = text.querySelector(selector);
|
|
509
|
+
const was = from.lines[index];
|
|
510
|
+
const is = to.lines[index];
|
|
511
|
+
if (element === null || was == null || is == null || is.size === 0) continue;
|
|
512
|
+
const origin = originOf(element, align);
|
|
513
|
+
animations.current.push(element.animate({
|
|
514
|
+
transform: [`translate(${was.x - is.x}px, ${was.y - is.y}px) scale(${was.size / is.size})`, "none"],
|
|
515
|
+
transformOrigin: [origin, origin]
|
|
516
|
+
}, timing));
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
$[1] = align;
|
|
520
|
+
$[2] = collapse;
|
|
521
|
+
$[3] = t1;
|
|
522
|
+
} else t1 = $[3];
|
|
523
|
+
useLayoutEffect(t1);
|
|
524
|
+
return textRef;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* The inset as a length CSS arithmetic accepts. A bare `0` is the one length
|
|
528
|
+
* CSS takes without a unit, and the one it rejects inside `max()` and `min()`,
|
|
529
|
+
* where it reads as a number.
|
|
530
|
+
*/
|
|
531
|
+
function _temp4(animation) {
|
|
532
|
+
return animation.playState === "running";
|
|
533
|
+
}
|
|
534
|
+
function withUnit(contentInset) {
|
|
535
|
+
return contentInset.trim() === "0" ? "0px" : contentInset;
|
|
536
|
+
}
|
|
278
537
|
//#endregion
|
|
279
538
|
export { AppBar as default };
|
|
280
539
|
|