@kanso-labs/kanso-ui 0.49.0 → 0.50.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.
@@ -28,7 +28,7 @@ type AppBarProps = Omit<RenderComponentProps<'header'>, 'children'> & {
28
28
  * headline and the subtitle move up into the row the slots sit in and take
29
29
  * the small bar's type roles, which fit both lines in its 64px, and the
30
30
  * slots never leave that row: they stay where they are while the bar
31
- * shrinks under them.
31
+ * shrinks under them. A kicker goes, and fades back in on expanding.
32
32
  *
33
33
  * Collapsing hands the page back the height the bar gives up, and a bar
34
34
  * whose state is read off the scroll offset can then undo itself in two
@@ -86,6 +86,14 @@ type AppBarProps = Omit<RenderComponentProps<'header'>, 'children'> & {
86
86
  * is cut short with an ellipsis — see `align`.
87
87
  */
88
88
  headline?: ReactNode;
89
+ /**
90
+ * A line over the headline in `md` and `lg`, in label medium on on surface
91
+ * variant, naming where the screen sits — the parent a detail screen opened
92
+ * from, say, which it may hold as a link back there. Makes the bar taller
93
+ * by its line, and goes as the bar collapses, leaving the headline and any
94
+ * subtitle. `sm` draws none.
95
+ */
96
+ kicker?: ReactNode;
89
97
  /**
90
98
  * Usually a back or menu icon button. Sits before the text, and a standard
91
99
  * icon button here draws its icon in on surface, the colour the page gives
@@ -116,7 +124,7 @@ type AppBarProps = Omit<RenderComponentProps<'header'>, 'children'> & {
116
124
  * Height and headline size, as steps of the library's size scale. `sm` is
117
125
  * Material Design's small bar, a fixed 64px row; `md` and `lg` are its
118
126
  * medium and large flexible bars, which put the text in a row of its own
119
- * under the slots and hug it.
127
+ * under the slots and hug it. A kicker adds its line to `md` and `lg`.
120
128
  * @default 'sm'
121
129
  */
122
130
  size?: 'lg' | 'md' | 'sm';
@@ -135,13 +143,14 @@ type AppBarProps = Omit<RenderComponentProps<'header'>, 'children'> & {
135
143
  *
136
144
  * Three sizes. `sm` is a fixed 64px bar for a page whose title is a label;
137
145
  * `md` and `lg` are the flexible bars, which give the headline a larger
138
- * type role in a row of its own under the slots, and grow to fit a subtitle
139
- * or a headline that wraps.
146
+ * type role in a row of its own under the slots, with a kicker over it where
147
+ * one is given, and grow to fit a kicker, a subtitle or a headline that
148
+ * wraps.
140
149
  *
141
150
  * It paints its own surface, unlike the layout components, because separating
142
151
  * itself from the content beneath is the job — which is also why `scrolled`
143
152
  * and `collapsed` exist. Neither watches the page: only the app knows which
144
153
  * element scrolls, so both are set from its own scroll handler.
145
154
  */
146
- 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>>;
155
+ declare function AppBar({ align, collapsed, contentInset, contentMaxInlineSize, headingLevel, headline, kicker, leading, pinned, render, scrolled, size, subtitle, trailing, ...props }: AppBarProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
147
156
  export { type AppBarProps, AppBar as default };
@@ -6,7 +6,7 @@ import "../../hooks/useAppBarScroll.js";
6
6
  import { hasContent } from "../../render/content.js";
7
7
  import { useRender } from "../../render/useRender.js";
8
8
  import { mergeStyles } from "../../styles/merge.js";
9
- import { spacing } from "../../tokens/design.tokens.stylex.js";
9
+ import { spacing, typography } from "../../tokens/design.tokens.stylex.js";
10
10
  import { motionDurationMs, motionEasing } from "../../tokens/values.js";
11
11
  import Text from "../text/index.js";
12
12
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -129,6 +129,7 @@ function heading(level) {
129
129
  return createElement(Number.isInteger(level) && level >= 1 && level <= 6 ? HEADINGS[level - 1] : HEADINGS[0]);
130
130
  }
131
131
  const PARAGRAPH = /* @__PURE__ */ jsx("p", {});
132
+ const KICKER = /* @__PURE__ */ jsx("div", {});
132
133
  const _temp = {
133
134
  kAzted: "x1chvrdh",
134
135
  "$$css": true
@@ -194,6 +195,7 @@ const textStyles = {
194
195
  };
195
196
  const UNDER_TARGETS = `calc((${COLLAPSED_HEIGHT} - ${ICON_BUTTON_TARGET}) / 2)`;
196
197
  const LINES = [":scope > :is(h1, h2, h3, h4, h5, h6)", ":scope > p"];
198
+ const KICKER_LINE = ":scope > div";
197
199
  /**
198
200
  * Material Design's app bar: the container at the top of a page carrying its
199
201
  * title, one or two actions, and the way back out.
@@ -204,8 +206,9 @@ const LINES = [":scope > :is(h1, h2, h3, h4, h5, h6)", ":scope > p"];
204
206
  *
205
207
  * Three sizes. `sm` is a fixed 64px bar for a page whose title is a label;
206
208
  * `md` and `lg` are the flexible bars, which give the headline a larger
207
- * type role in a row of its own under the slots, and grow to fit a subtitle
208
- * or a headline that wraps.
209
+ * type role in a row of its own under the slots, with a kicker over it where
210
+ * one is given, and grow to fit a kicker, a subtitle or a headline that
211
+ * wraps.
209
212
  *
210
213
  * It paints its own surface, unlike the layout components, because separating
211
214
  * itself from the content beneath is the job — which is also why `scrolled`
@@ -213,8 +216,8 @@ const LINES = [":scope > :is(h1, h2, h3, h4, h5, h6)", ":scope > p"];
213
216
  * element scrolls, so both are set from its own scroll handler.
214
217
  */
215
218
  function AppBar(t0) {
216
- const $ = c(32);
217
- 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;
219
+ const $ = c(39);
220
+ const { align: t1, collapsed: t2, contentInset: t3, contentMaxInlineSize: t4, headingLevel: t5, headline, kicker, leading, pinned: t6, render, scrolled: t7, size: t8, subtitle, trailing, ...props$1 } = t0;
218
221
  const align = t1 === void 0 ? "start" : t1;
219
222
  const collapsed = t2 === void 0 ? false : t2;
220
223
  const contentInset = t3 === void 0 ? spacing.lg : t3;
@@ -225,7 +228,16 @@ function AppBar(t0) {
225
228
  const size = t8 === void 0 ? "sm" : t8;
226
229
  const collapse = collapsed && size !== "sm";
227
230
  const below = size !== "sm" && !collapse;
228
- const expandedHeight = hasContent(subtitle) ? HEIGHTS[size].withSubtitle : HEIGHTS[size].plain;
231
+ let t9;
232
+ if ($[0] !== below || $[1] !== kicker) {
233
+ t9 = below && hasContent(kicker);
234
+ $[0] = below;
235
+ $[1] = kicker;
236
+ $[2] = t9;
237
+ } else t9 = $[2];
238
+ const showsKicker = t9;
239
+ const textHeight = hasContent(subtitle) ? HEIGHTS[size].withSubtitle : HEIGHTS[size].plain;
240
+ const expandedHeight = showsKicker ? `calc(${textHeight} + ${typography.labelMediumLineHeight})` : textHeight;
229
241
  const height = collapse ? COLLAPSED_HEIGHT : expandedHeight;
230
242
  const hasLeading = hasContent(leading);
231
243
  const hasTrailing = hasContent(trailing);
@@ -233,117 +245,134 @@ function AppBar(t0) {
233
245
  const hasSlot = hasLeading || hasTrailing;
234
246
  const padsForStart = centred ? hasSlot : hasLeading;
235
247
  const padsForEnd = centred ? hasSlot : hasTrailing;
236
- let t9;
237
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
238
- t9 = {
248
+ let t10;
249
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
250
+ t10 = {
239
251
  0: {},
240
252
  1: { className: "xb3r6kr xlyipyv xuxw1ft" }
241
253
  };
242
- $[0] = t9;
243
- } else t9 = $[0];
244
- const line = t9[!!(centred && !below) << 0];
254
+ $[3] = t10;
255
+ } else t10 = $[3];
256
+ const line = t10[!!(centred && !below) << 0];
245
257
  const textRef = useCollapseMotion(collapse, align);
246
- const t10 = "header";
247
- const t11 = 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]);
248
- const t12 = !hasLeading ? null : /* @__PURE__ */ jsx("div", {
258
+ const t11 = "header";
259
+ const t12 = 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]);
260
+ const t13 = !hasLeading ? null : /* @__PURE__ */ jsx("div", {
249
261
  className: "x6s0dn4 xamitd3 x9f619 x78zum5 x1r8zjiw x1let9r4 x155k8fu x139gbkf x1kxrqrs x1lqcxt8 x15ir4sr",
250
262
  children: leading
251
263
  });
252
- const t13 = 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);
253
- let t14;
254
- if ($[1] !== collapse || $[2] !== headingLevel || $[3] !== headline || $[4] !== line || $[5] !== size) {
255
- t14 = !hasContent(headline) ? null : /* @__PURE__ */ jsx(Text, {
264
+ const t14 = 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);
265
+ let t15;
266
+ if ($[4] !== kicker || $[5] !== showsKicker) {
267
+ t15 = !showsKicker ? null : /* @__PURE__ */ jsx(Text, {
268
+ render: KICKER,
269
+ tone: "muted",
270
+ variant: "labelMedium",
271
+ children: kicker
272
+ });
273
+ $[4] = kicker;
274
+ $[5] = showsKicker;
275
+ $[6] = t15;
276
+ } else t15 = $[6];
277
+ let t16;
278
+ if ($[7] !== collapse || $[8] !== headingLevel || $[9] !== headline || $[10] !== line || $[11] !== size) {
279
+ t16 = !hasContent(headline) ? null : /* @__PURE__ */ jsx(Text, {
256
280
  ...line,
257
281
  render: heading(headingLevel),
258
282
  variant: collapse ? HEADLINE_VARIANT.sm : HEADLINE_VARIANT[size],
259
283
  children: headline
260
284
  });
261
- $[1] = collapse;
262
- $[2] = headingLevel;
263
- $[3] = headline;
264
- $[4] = line;
265
- $[5] = size;
266
- $[6] = t14;
267
- } else t14 = $[6];
268
- let t15;
269
- if ($[7] !== collapse || $[8] !== line || $[9] !== size || $[10] !== subtitle) {
270
- t15 = !hasContent(subtitle) ? null : /* @__PURE__ */ jsx(Text, {
285
+ $[7] = collapse;
286
+ $[8] = headingLevel;
287
+ $[9] = headline;
288
+ $[10] = line;
289
+ $[11] = size;
290
+ $[12] = t16;
291
+ } else t16 = $[12];
292
+ let t17;
293
+ if ($[13] !== collapse || $[14] !== line || $[15] !== size || $[16] !== subtitle) {
294
+ t17 = !hasContent(subtitle) ? null : /* @__PURE__ */ jsx(Text, {
271
295
  ...line,
272
296
  render: PARAGRAPH,
273
297
  tone: "muted",
274
298
  variant: collapse ? SUBTITLE_VARIANT.sm : SUBTITLE_VARIANT[size],
275
299
  children: subtitle
276
300
  });
277
- $[7] = collapse;
278
- $[8] = line;
279
- $[9] = size;
280
- $[10] = subtitle;
281
- $[11] = t15;
282
- } else t15 = $[11];
283
- let t16;
284
- if ($[12] !== t13 || $[13] !== t14 || $[14] !== t15 || $[15] !== textRef) {
285
- t16 = /* @__PURE__ */ jsxs("div", {
286
- ...t13,
287
- ref: textRef,
288
- children: [t14, t15]
289
- });
290
- $[12] = t13;
291
- $[13] = t14;
292
- $[14] = t15;
293
- $[15] = textRef;
294
- $[16] = t16;
295
- } else t16 = $[16];
296
- let t17;
297
- if ($[17] !== hasTrailing || $[18] !== trailing) {
298
- t17 = !hasTrailing ? null : /* @__PURE__ */ jsx("div", {
299
- className: "x6s0dn4 xamitd3 x9f619 x78zum5 x1r8zjiw x1let9r4 x1w5n3ug x1txd71x x1qab1bc x6aqprb",
300
- children: trailing
301
- });
302
- $[17] = hasTrailing;
303
- $[18] = trailing;
304
- $[19] = t17;
305
- } else t17 = $[19];
301
+ $[13] = collapse;
302
+ $[14] = line;
303
+ $[15] = size;
304
+ $[16] = subtitle;
305
+ $[17] = t17;
306
+ } else t17 = $[17];
306
307
  let t18;
307
- if ($[20] !== t11 || $[21] !== t12 || $[22] !== t16 || $[23] !== t17) {
308
+ if ($[18] !== t14 || $[19] !== t15 || $[20] !== t16 || $[21] !== t17 || $[22] !== textRef) {
308
309
  t18 = /* @__PURE__ */ jsxs("div", {
309
- ...t11,
310
+ ...t14,
311
+ ref: textRef,
310
312
  children: [
311
- t12,
313
+ t15,
312
314
  t16,
313
315
  t17
314
316
  ]
315
317
  });
316
- $[20] = t11;
317
- $[21] = t12;
318
- $[22] = t16;
319
- $[23] = t17;
320
- $[24] = t18;
321
- } else t18 = $[24];
322
- const t19 = mergeStyles(props(styles.root, heightStyles.root(height), scrolled && styles.scrolled, pinned && styles.pinned), props$1);
318
+ $[18] = t14;
319
+ $[19] = t15;
320
+ $[20] = t16;
321
+ $[21] = t17;
322
+ $[22] = textRef;
323
+ $[23] = t18;
324
+ } else t18 = $[23];
325
+ let t19;
326
+ if ($[24] !== hasTrailing || $[25] !== trailing) {
327
+ t19 = !hasTrailing ? null : /* @__PURE__ */ jsx("div", {
328
+ className: "x6s0dn4 xamitd3 x9f619 x78zum5 x1r8zjiw x1let9r4 x1w5n3ug x1txd71x x1qab1bc x6aqprb",
329
+ children: trailing
330
+ });
331
+ $[24] = hasTrailing;
332
+ $[25] = trailing;
333
+ $[26] = t19;
334
+ } else t19 = $[26];
323
335
  let t20;
324
- if ($[25] !== props$1 || $[26] !== t18 || $[27] !== t19) {
325
- t20 = {
336
+ if ($[27] !== t12 || $[28] !== t13 || $[29] !== t18 || $[30] !== t19) {
337
+ t20 = /* @__PURE__ */ jsxs("div", {
338
+ ...t12,
339
+ children: [
340
+ t13,
341
+ t18,
342
+ t19
343
+ ]
344
+ });
345
+ $[27] = t12;
346
+ $[28] = t13;
347
+ $[29] = t18;
348
+ $[30] = t19;
349
+ $[31] = t20;
350
+ } else t20 = $[31];
351
+ const t21 = mergeStyles(props(styles.root, heightStyles.root(height), scrolled && styles.scrolled, pinned && styles.pinned), props$1);
352
+ let t22;
353
+ if ($[32] !== props$1 || $[33] !== t20 || $[34] !== t21) {
354
+ t22 = {
326
355
  ...props$1,
327
- children: t18,
328
- ...t19
356
+ children: t20,
357
+ ...t21
329
358
  };
330
- $[25] = props$1;
331
- $[26] = t18;
332
- $[27] = t19;
333
- $[28] = t20;
334
- } else t20 = $[28];
335
- let t21;
336
- if ($[29] !== render || $[30] !== t20) {
337
- t21 = {
338
- defaultTagName: t10,
339
- props: t20,
359
+ $[32] = props$1;
360
+ $[33] = t20;
361
+ $[34] = t21;
362
+ $[35] = t22;
363
+ } else t22 = $[35];
364
+ let t23;
365
+ if ($[36] !== render || $[37] !== t22) {
366
+ t23 = {
367
+ defaultTagName: t11,
368
+ props: t22,
340
369
  render
341
370
  };
342
- $[29] = render;
343
- $[30] = t20;
344
- $[31] = t21;
345
- } else t21 = $[31];
346
- return useRender(t21);
371
+ $[36] = render;
372
+ $[37] = t22;
373
+ $[38] = t23;
374
+ } else t23 = $[38];
375
+ return useRender(t23);
347
376
  }
348
377
  /**
349
378
  * A centred bar's columns: the text in the middle at its own width, and a
@@ -550,6 +579,19 @@ function useCollapseMotion(collapse, align) {
550
579
  transformOrigin: [origin, origin]
551
580
  }, timing));
552
581
  }
582
+ const kicker = collapse ? null : text.querySelector(KICKER_LINE);
583
+ if (kicker !== null) animations.current.push(kicker.animate([
584
+ { opacity: 0 },
585
+ {
586
+ easing: motionEasing.emphasized,
587
+ offset: .5,
588
+ opacity: 0
589
+ },
590
+ { opacity: 1 }
591
+ ], {
592
+ duration: timing.duration,
593
+ easing: "linear"
594
+ }));
553
595
  };
554
596
  $[1] = align;
555
597
  $[2] = collapse;