@kanso-labs/kanso-ui 0.37.0 → 0.39.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 +157 -27
- package/dist/button/hooks.js +1 -1
- package/dist/button/index.js +1 -1
- package/dist/button/index.js.map +1 -1
- package/dist/calendar/styles.js +2 -1
- package/dist/calendar/styles.js.map +1 -1
- package/dist/carousel/arrangement.d.ts +5 -0
- package/dist/carousel/arrangement.js +123 -0
- package/dist/carousel/arrangement.js.map +1 -0
- package/dist/collection/index.js +4 -4
- package/dist/collection/index.js.map +1 -1
- package/dist/color-scheme.d.ts +19 -12
- package/dist/color-scheme.js +22 -15
- package/dist/color-scheme.js.map +1 -1
- package/dist/components/app-bar/index.d.ts +10 -14
- package/dist/components/app-bar/index.js +12 -12
- package/dist/components/app-bar/index.js.map +1 -1
- package/dist/components/avatar/index.d.ts +15 -1
- package/dist/components/avatar/index.js +43 -145
- package/dist/components/avatar/index.js.map +1 -1
- package/dist/components/breadcrumbs/index.d.ts +1 -1
- package/dist/components/breadcrumbs/index.js.map +1 -1
- package/dist/components/button/index.js +3 -3
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/calendar/index.d.ts +3 -2
- package/dist/components/calendar/index.js +3 -2
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/carousel/index.d.ts +68 -0
- package/dist/components/carousel/index.js +395 -0
- package/dist/components/carousel/index.js.map +1 -0
- package/dist/components/chip/index.js +27 -25
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/chip-group/index.d.ts +22 -1
- package/dist/components/chip-group/index.js +3 -3
- package/dist/components/chip-group/index.js.map +1 -1
- package/dist/components/code/index.js +1 -1
- package/dist/components/code/index.js.map +1 -1
- package/dist/components/color-picker/index.d.ts +5 -5
- package/dist/components/color-picker/index.js +46 -51
- package/dist/components/color-picker/index.js.map +1 -1
- package/dist/components/color-slider/index.js +82 -57
- package/dist/components/color-slider/index.js.map +1 -1
- package/dist/components/color-swatch-picker/index.d.ts +1 -1
- package/dist/components/color-swatch-picker/index.js.map +1 -1
- package/dist/components/combo-box/index.d.ts +5 -5
- package/dist/components/combo-box/index.js +33 -35
- package/dist/components/combo-box/index.js.map +1 -1
- package/dist/components/copy-field/index.js +1 -1
- package/dist/components/copy-field/index.js.map +1 -1
- package/dist/components/currency/index.d.ts +16 -0
- package/dist/components/currency/index.js +16 -0
- package/dist/components/currency/index.js.map +1 -1
- package/dist/components/date-picker/index.d.ts +14 -6
- package/dist/components/date-picker/index.js +29 -32
- package/dist/components/date-picker/index.js.map +1 -1
- package/dist/components/date-range-picker/index.d.ts +15 -6
- package/dist/components/date-range-picker/index.js +29 -32
- package/dist/components/date-range-picker/index.js.map +1 -1
- package/dist/components/dialog/index.d.ts +9 -9
- package/dist/components/dialog/index.js +29 -22
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/disclosure/index.d.ts +1 -1
- package/dist/components/disclosure/index.js.map +1 -1
- package/dist/components/fab-menu/index.d.ts +4 -2
- package/dist/components/fab-menu/index.js.map +1 -1
- package/dist/components/index.d.ts +7 -3
- package/dist/components/list/index.d.ts +3 -3
- package/dist/components/list/index.js +2 -2
- package/dist/components/list/index.js.map +1 -1
- package/dist/components/list-box/index.d.ts +3 -3
- package/dist/components/list-box/index.js +2 -2
- package/dist/components/list-box/index.js.map +1 -1
- package/dist/components/list-item/index.js +1 -1
- package/dist/components/loading-indicator/index.d.ts +30 -0
- package/dist/components/loading-indicator/index.js +71 -0
- package/dist/components/loading-indicator/index.js.map +1 -0
- package/dist/components/menu/index.d.ts +8 -8
- package/dist/components/menu/index.js +2 -2
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/navigation-tree/index.d.ts +2 -2
- package/dist/components/navigation-tree/index.js.map +1 -1
- package/dist/components/number-field/index.js +1 -1
- package/dist/components/popover/index.d.ts +7 -7
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/product-icon/index.d.ts +1 -1
- package/dist/components/product-icon/index.js +28 -142
- package/dist/components/product-icon/index.js.map +1 -1
- package/dist/components/progress-indicator/index.d.ts +21 -15
- package/dist/components/progress-indicator/index.js +485 -185
- package/dist/components/progress-indicator/index.js.map +1 -1
- package/dist/components/search-field/index.js +1 -1
- package/dist/components/search-view/index.d.ts +5 -5
- package/dist/components/search-view/index.js +1 -1
- 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/select/index.d.ts +5 -5
- package/dist/components/select/index.js +5 -2
- package/dist/components/select/index.js.map +1 -1
- package/dist/components/sheet/index.d.ts +10 -10
- package/dist/components/sheet/index.js +27 -20
- package/dist/components/sheet/index.js.map +1 -1
- package/dist/components/slider/index.d.ts +24 -3
- package/dist/components/slider/index.js +317 -88
- package/dist/components/slider/index.js.map +1 -1
- package/dist/components/split-button/index.d.ts +4 -2
- package/dist/components/split-button/index.js.map +1 -1
- package/dist/components/stack/index.d.ts +4 -1
- package/dist/components/stack/index.js +7 -1
- package/dist/components/stack/index.js.map +1 -1
- package/dist/components/table/index.d.ts +7 -7
- package/dist/components/table/index.js +39 -26
- package/dist/components/table/index.js.map +1 -1
- package/dist/components/tabs/index.d.ts +4 -4
- package/dist/components/tabs/index.js +59 -27
- package/dist/components/tabs/index.js.map +1 -1
- package/dist/components/text/index.d.ts +22 -9
- package/dist/components/text/index.js +22 -5
- package/dist/components/text/index.js.map +1 -1
- package/dist/components/time-picker/index.d.ts +110 -0
- package/dist/components/time-picker/index.js +954 -0
- package/dist/components/time-picker/index.js.map +1 -0
- package/dist/components/tooltip/index.d.ts +5 -5
- package/dist/components/tooltip/index.js +1 -0
- package/dist/components/tooltip/index.js.map +1 -1
- package/dist/components/tree/index.d.ts +2 -2
- package/dist/components/tree/index.js +2 -2
- package/dist/components/tree/index.js.map +1 -1
- package/dist/glyphs/index.js +37 -1
- package/dist/glyphs/index.js.map +1 -1
- package/dist/i18n/index.js +13 -1
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.js +340 -34
- package/dist/i18n/messages.js.map +1 -1
- package/dist/index.d.ts +9 -4
- package/dist/index.js +7 -3
- package/dist/indicator/index.js +38 -35
- package/dist/indicator/index.js.map +1 -1
- package/dist/mark/index.js +137 -0
- package/dist/mark/index.js.map +1 -0
- package/dist/mark/initials.js +42 -0
- package/dist/mark/initials.js.map +1 -0
- package/dist/mark/styles.js +91 -0
- package/dist/mark/styles.js.map +1 -0
- package/dist/render/ref.js +35 -1
- package/dist/render/ref.js.map +1 -1
- package/dist/render/useRender.js +1 -30
- package/dist/render/useRender.js.map +1 -1
- package/dist/styles/color.js +18 -4
- package/dist/styles/color.js.map +1 -1
- package/dist/styles/picker.js +37 -1
- package/dist/styles/picker.js.map +1 -1
- package/dist/styles.css +910 -239
- package/dist/theme-scope.d.ts +40 -0
- package/dist/theme-scope.js +112 -0
- package/dist/theme-scope.js.map +1 -0
- package/dist/tokens/design.tokens.stylex.js +39 -5
- package/dist/tokens/design.tokens.stylex.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -20,6 +20,9 @@ Every component is documented in Storybook, published from the latest release at
|
|
|
20
20
|
npm install @kanso-labs/kanso-ui
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
Coming from an earlier 0.x release? [`UPGRADING.md`](UPGRADING.md) lists every
|
|
24
|
+
breaking change on the way to 1.0, with the edit each one asks for.
|
|
25
|
+
|
|
23
26
|
## Usage
|
|
24
27
|
|
|
25
28
|
```tsx
|
|
@@ -36,13 +39,19 @@ default, in both light and dark (respecting the OS-level
|
|
|
36
39
|
`prefers-color-scheme`), and every component sizes itself with
|
|
37
40
|
`box-sizing: border-box` rather than leaving that to a reset you supply.
|
|
38
41
|
|
|
39
|
-
A bundler is what resolves that stylesheet
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
A bundler is what resolves that stylesheet, so the package always loads through
|
|
43
|
+
one. The main entry imports `./styles.css` itself and Node has no loader for
|
|
44
|
+
CSS, so in plain Node an `import` or a `require()` of `@kanso-labs/kanso-ui`
|
|
45
|
+
throws `ERR_UNKNOWN_FILE_EXTENSION`; `@kanso-labs/kanso-ui/date` is the one
|
|
46
|
+
entry plain Node can load. A server renderer or a test runner that leaves
|
|
47
|
+
dependencies to Node takes one setting to hand this package to its bundler
|
|
48
|
+
instead, and [Server rendering and tests](#server-rendering-and-tests) gives it
|
|
49
|
+
for Vite, Vitest and Jest.
|
|
42
50
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
The same stylesheet is published on its own, as
|
|
52
|
+
`@kanso-labs/kanso-ui/styles.css`, for CSS that loads it apart from the
|
|
53
|
+
JavaScript: an `@import` in a stylesheet of your own, or a `<link>`. It adds the
|
|
54
|
+
rules and nothing else, so it is not a way round the main entry's own import.
|
|
46
55
|
|
|
47
56
|
`className` and `style` reach the element a component renders, so a component is
|
|
48
57
|
positioned from the call site like any other element:
|
|
@@ -203,7 +212,7 @@ the page scrolls, becoming the small bar:
|
|
|
203
212
|
contentMaxInlineSize="960px"
|
|
204
213
|
headline="Headline"
|
|
205
214
|
scrolled={scrollTop > 0}
|
|
206
|
-
size="
|
|
215
|
+
size="lg"
|
|
207
216
|
/>
|
|
208
217
|
{page}
|
|
209
218
|
</div>
|
|
@@ -367,13 +376,70 @@ Four things follow from where that boundary falls.
|
|
|
367
376
|
```
|
|
368
377
|
|
|
369
378
|
- **The React Aria utilities the package re-exports are client-only** —
|
|
370
|
-
`I18nProvider`, `useListData`, `parseColor` and the rest. `collectionSizes
|
|
371
|
-
|
|
379
|
+
`I18nProvider`, `useListData`, `parseColor` and the rest. `collectionSizes`,
|
|
380
|
+
`colorScheme` and `themeScope` are plain values and work on either side.
|
|
372
381
|
- **A server-rendered app wraps its tree in `I18nProvider`** with the request's
|
|
373
382
|
locale. React Aria reads the browser's locale on the client and has none on
|
|
374
383
|
the server, so without it a date or a number can render differently on the two
|
|
375
384
|
and fail hydration.
|
|
376
385
|
|
|
386
|
+
### Server rendering and tests
|
|
387
|
+
|
|
388
|
+
The main entry imports its own stylesheet, so the package has to reach a bundler
|
|
389
|
+
wherever it runs. Three tools hand dependencies to Node by default, and each has
|
|
390
|
+
a setting that sends this package through its bundler instead.
|
|
391
|
+
|
|
392
|
+
**Vite's server rendering** leaves dependencies to Node, in `vite dev` and in a
|
|
393
|
+
built server alike, so the server of a Vite-based framework — React Router's
|
|
394
|
+
framework mode, TanStack Start, Astro, Vike — throws
|
|
395
|
+
`ERR_UNKNOWN_FILE_EXTENSION` for `dist/styles.css` as it starts. Name the
|
|
396
|
+
package in `ssr.noExternal`, wherever the framework takes its Vite settings
|
|
397
|
+
(Astro's sit under `vite` in `astro.config.mjs`):
|
|
398
|
+
|
|
399
|
+
```ts
|
|
400
|
+
// vite.config.ts
|
|
401
|
+
import { defineConfig } from 'vite'
|
|
402
|
+
|
|
403
|
+
export default defineConfig({
|
|
404
|
+
ssr: { noExternal: ['@kanso-labs/kanso-ui'] },
|
|
405
|
+
})
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
**Vitest** leaves dependencies to Node too, so the first test that imports a
|
|
409
|
+
component fails with `Unknown file extension ".css"`. Inline the package:
|
|
410
|
+
|
|
411
|
+
```ts
|
|
412
|
+
// vitest.config.ts
|
|
413
|
+
import { defineConfig } from 'vitest/config'
|
|
414
|
+
|
|
415
|
+
export default defineConfig({
|
|
416
|
+
test: { server: { deps: { inline: ['@kanso-labs/kanso-ui'] } } },
|
|
417
|
+
})
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
**Jest** wants a stand-in for the stylesheet, since it has no loader for CSS,
|
|
421
|
+
and a transform for the package, since the package is ES modules:
|
|
422
|
+
|
|
423
|
+
```js
|
|
424
|
+
// jest.config.cjs
|
|
425
|
+
module.exports = {
|
|
426
|
+
moduleNameMapper: { '\\.css$': '<rootDir>/style-stub.cjs' },
|
|
427
|
+
transformIgnorePatterns: [
|
|
428
|
+
'^(?!.*/node_modules/@kanso-labs/kanso-ui/).*/node_modules/',
|
|
429
|
+
],
|
|
430
|
+
}
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
`style-stub.cjs` is `module.exports = {}`, and the transform needs a Babel
|
|
434
|
+
config that compiles modules to CommonJS, such as `@babel/preset-env`. The
|
|
435
|
+
pattern is written to let in everything under the package, its own
|
|
436
|
+
`dist/node_modules` included, which carries StyleX's runtime: the shorter
|
|
437
|
+
`/node_modules/(?!@kanso-labs/kanso-ui/)` matches again at that second
|
|
438
|
+
`node_modules` and leaves the runtime untransformed. On Node 24.9 or newer, Jest
|
|
439
|
+
30 can load the package as ES modules instead, under
|
|
440
|
+
`NODE_OPTIONS=--experimental-vm-modules`, and then needs the `moduleNameMapper`
|
|
441
|
+
alone.
|
|
442
|
+
|
|
377
443
|
## Theming
|
|
378
444
|
|
|
379
445
|
Every design token — color, spacing, radii, sizing, shadows, typography,
|
|
@@ -395,10 +461,8 @@ component, independent of your app's build tooling:
|
|
|
395
461
|
}
|
|
396
462
|
```
|
|
397
463
|
|
|
398
|
-
Overrides
|
|
399
|
-
|
|
400
|
-
`--kui-*` property on a smaller scope (e.g. a wrapping `<div>`) doesn't reach
|
|
401
|
-
them.
|
|
464
|
+
Overrides on `:root` reach the whole page. To theme part of one, declare them on
|
|
465
|
+
a `ThemeScope` instead — see [Theming part of a page](#theming-part-of-a-page).
|
|
402
466
|
|
|
403
467
|
[`@kanso-labs/kanso-ui/tokens.css`](src/tokens/design.tokens.css) is the
|
|
404
468
|
canonical, generated reference for every available variable and its current
|
|
@@ -409,41 +473,107 @@ default value — useful for discovering names, not required at runtime
|
|
|
409
473
|
import '@kanso-labs/kanso-ui/tokens.css'
|
|
410
474
|
```
|
|
411
475
|
|
|
476
|
+
### Theming part of a page
|
|
477
|
+
|
|
478
|
+
The tokens resolve once, on `:root`, and every component inherits them already
|
|
479
|
+
resolved, so a `--kui-*` property redeclared on a smaller element — a wrapping
|
|
480
|
+
`<div>` — reaches nothing on its own. `ThemeScope` resolves them again on an
|
|
481
|
+
element of its own. An override declared on the scope, through `className` or
|
|
482
|
+
`style`, or on any element around it, reaches every component inside, and the
|
|
483
|
+
rest of the page keeps its own tokens:
|
|
484
|
+
|
|
485
|
+
```css
|
|
486
|
+
.accent {
|
|
487
|
+
--kui-color-primary: #7d5260;
|
|
488
|
+
--kui-color-on-primary: #ffffff;
|
|
489
|
+
}
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
```tsx
|
|
493
|
+
import { Select, ThemeScope } from '@kanso-labs/kanso-ui'
|
|
494
|
+
|
|
495
|
+
function Section() {
|
|
496
|
+
return (
|
|
497
|
+
<ThemeScope className="accent">
|
|
498
|
+
<Select label="Label">…</Select>
|
|
499
|
+
</ThemeScope>
|
|
500
|
+
)
|
|
501
|
+
}
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
`scheme` pins the scope to `'light'` or `'dark'`, whatever the OS asks for. Left
|
|
505
|
+
unset, the scope keeps the scheme around it, so a scope inside a dark page stays
|
|
506
|
+
dark.
|
|
507
|
+
|
|
508
|
+
Overlays come along. React Aria portals a popover, a sheet, a tooltip or a
|
|
509
|
+
snackbar to the end of `<body>`, outside any wrapper; one opened inside a
|
|
510
|
+
`ThemeScope` portals into the scope instead, and takes its tokens with it. The
|
|
511
|
+
cost is that an ancestor confining its descendants confines those overlays too —
|
|
512
|
+
a `transform` or a `filter` makes a sheet's scrim cover that ancestor rather
|
|
513
|
+
than the viewport, and `overflow: hidden` clips a popover — so put the scope
|
|
514
|
+
around such an element rather than inside it.
|
|
515
|
+
|
|
516
|
+
`themeScope` is the same thing as a class name, for an element you render
|
|
517
|
+
yourself. Overlays opened under it still portal to the body and keep the page's
|
|
518
|
+
tokens, since nothing tells them otherwise.
|
|
519
|
+
|
|
412
520
|
### Pinning light or dark
|
|
413
521
|
|
|
414
522
|
The colours follow the reader's OS through `prefers-color-scheme` unless the app
|
|
415
523
|
says otherwise. An app with a theme switch of its own pins a scheme with
|
|
416
|
-
`colorScheme
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
524
|
+
`colorScheme`: put `colorScheme.light` or `colorScheme.dark` on the `<html>`
|
|
525
|
+
element, and remove it to follow the OS again. The `<html>` element is the place
|
|
526
|
+
for it, since overlays are portalled to the body and still sit inside it. Either
|
|
527
|
+
also works on a smaller element, as a `themeScope` that pins.
|
|
420
528
|
|
|
421
|
-
|
|
422
|
-
|
|
529
|
+
Each is several class names separated by spaces, so set it through `className`,
|
|
530
|
+
or spread `name.split(' ')` into `classList.add`. A provider that adds one class
|
|
531
|
+
per scheme throws on it — next-themes' `value` option is one. With a provider of
|
|
532
|
+
that kind, render a `ThemeScope` around the app instead and hand it the
|
|
533
|
+
provider's scheme:
|
|
423
534
|
|
|
424
535
|
```tsx
|
|
425
|
-
|
|
426
|
-
|
|
536
|
+
'use client'
|
|
537
|
+
|
|
538
|
+
import { ThemeProvider, useTheme } from 'next-themes'
|
|
539
|
+
import { useEffect, useState } from 'react'
|
|
540
|
+
import { ThemeScope } from '@kanso-labs/kanso-ui'
|
|
541
|
+
|
|
542
|
+
function Scheme({ children }: { children: React.ReactNode }) {
|
|
543
|
+
const { resolvedTheme } = useTheme()
|
|
544
|
+
const [mounted, setMounted] = useState(false)
|
|
545
|
+
useEffect(() => setMounted(true), [])
|
|
546
|
+
const scheme =
|
|
547
|
+
mounted && (resolvedTheme === 'dark' || resolvedTheme === 'light')
|
|
548
|
+
? resolvedTheme
|
|
549
|
+
: undefined
|
|
550
|
+
|
|
551
|
+
return <ThemeScope scheme={scheme}>{children}</ThemeScope>
|
|
552
|
+
}
|
|
427
553
|
|
|
428
554
|
function Providers({ children }: { children: React.ReactNode }) {
|
|
429
555
|
return (
|
|
430
|
-
<ThemeProvider attribute="
|
|
431
|
-
{children}
|
|
556
|
+
<ThemeProvider attribute="data-theme">
|
|
557
|
+
<Scheme>{children}</Scheme>
|
|
432
558
|
</ThemeProvider>
|
|
433
559
|
)
|
|
434
560
|
}
|
|
435
561
|
```
|
|
436
562
|
|
|
563
|
+
The server cannot know the stored choice, so the scope takes it only once the
|
|
564
|
+
page has mounted, which keeps the first client render matching the server's. The
|
|
565
|
+
first paint follows the OS until then.
|
|
566
|
+
|
|
437
567
|
A `--kui-color-*` override on `:root` still applies under a pinned scheme. To
|
|
438
568
|
give one scheme a value of its own, key the override on an attribute your switch
|
|
439
569
|
sets beside the class, since the class names are generated.
|
|
440
570
|
|
|
441
571
|
### For StyleX consumers
|
|
442
572
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
573
|
+
An app that also uses StyleX themes the same way, through the `--kui-*`
|
|
574
|
+
properties and `ThemeScope`. The token objects
|
|
575
|
+
[`stylex.createTheme()`](https://stylexjs.com/docs/learn/theming/) would take
|
|
576
|
+
(`colors`, `typography`, `spacing`, `radii`, `sizing`, `shadows`,
|
|
447
577
|
`stateLayerOpacity` and `motion`) aren't part of the public API yet; open an
|
|
448
578
|
issue if you need them exported.
|
|
449
579
|
|
package/dist/button/hooks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { refCallback } from "../render/ref.js";
|
|
1
2
|
import { ariaAttributesOf } from "../render/aria.js";
|
|
2
3
|
import { useRipple } from "../hooks/useRipple.js";
|
|
3
|
-
import { refCallback } from "../render/ref.js";
|
|
4
4
|
import { c } from "react/compiler-runtime";
|
|
5
5
|
import { ButtonContext, useSlottedContext } from "react-aria-components";
|
|
6
6
|
//#region src/button/hooks.ts
|
package/dist/button/index.js
CHANGED
|
@@ -146,8 +146,8 @@ function buttonContent(children, pendingLabel, surface) {
|
|
|
146
146
|
...props(buttonBaseStyles.pending),
|
|
147
147
|
children: /* @__PURE__ */ jsx(ProgressIndicator, {
|
|
148
148
|
"aria-label": pendingLabel,
|
|
149
|
+
diameter: "1em",
|
|
149
150
|
isIndeterminate: true,
|
|
150
|
-
size: "1em",
|
|
151
151
|
tone: "inherit",
|
|
152
152
|
variant: "circular"
|
|
153
153
|
})
|
package/dist/button/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["DOMAttributes","ReactNode","RefAttributes","ButtonRenderProps","ClassNameOrFunction","ButtonProps","RACButtonProps","ToggleButtonProps","RACToggleButtonProps","StyleOrFunction","stylex","Button","RACButton","Link","RACLink","ToggleButton","RACToggleButton","ProgressIndicator","useToggleGroupDisabled","useMessages","buttonRenderer","linkRenderer","toggleButtonRenderer","mergeStatefulStyles","useButtonBase","buttonBaseStyles","ButtonBaseProps","children","classes","state","ButtonState","ReturnType","props","className","disableRipple","href","pendingLabel","rel","style","target","ButtonDOMProps","HTMLAnchorElement","HTMLButtonElement","Omit","GlobalEventKey","Pick","HTMLElement","isSelected","Exclude","ToggleButtonBaseProps","defaultSelected","onChange","ButtonBase","t0","$","_c","input","render","t1","isPending","undefined","messages","disabled","element","ref","ripple","t2","styleProps","t3","t4","handlers","surface","t5","loading","t6","buttonContent","t7","label","labelPending","pending","ToggleButtonBase","disabledByGroup","id","isDisabled","toggleRender","toggleContent","_c","RACLink","RACButton","stylex.props","RACToggleButton"],"sources":["../../src/button/index.tsx"],"sourcesContent":["import type { DOMAttributes, ReactNode, RefAttributes } from 'react';\nimport type { ButtonRenderProps, ClassNameOrFunction, ButtonProps as RACButtonProps, ToggleButtonProps as RACToggleButtonProps, StyleOrFunction } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { Button as RACButton, Link as RACLink, ToggleButton as RACToggleButton } from 'react-aria-components';\nimport ProgressIndicator from '../components/progress-indicator';\nimport { useToggleGroupDisabled } from '../hooks/useToggleGroupDisabled';\nimport { useMessages } from '../i18n';\nimport { buttonRenderer, linkRenderer, toggleButtonRenderer } from '../render/aria';\nimport { mergeStatefulStyles } from '../styles/merge';\nimport { useButtonBase } from './hooks';\nimport { buttonBaseStyles } from './styles';\n\n// The press-button core Button and IconButton both render through. A button\n// is React Aria's `Button`, its `Link` once given `href`, or its\n// `ToggleButton` once it reports a state, and around each this adds what\n// React Aria leaves out: the ripple, the disabled state a parent's context\n// sets, the `aria-*` props and keyboard handlers it would drop or wrap, and\n// the ring drawn over the label while the button is pending. Each component\n// brings its own classes, as a function of the render state, and the call\n// site's `className` and `style` are merged over them.\n//\n// One module rather than a copy in each, since the copies had already drifted\n// once: IconButton read `ButtonContext` for a parent's disabled state and\n// Button did not. Not a component of the library's own and not exported from\n// the package; see `src/row` for the same arrangement around a list's row.\n\ntype ButtonBaseProps = {\n children?: ReactNode;\n /**\n * The component's own classes, from the render state. The call site's\n * `className` and `style` are merged over them.\n */\n classes: (state: ButtonState) => ReturnType<typeof stylex.props>;\n className?: ClassNameOrFunction<ButtonState>;\n disableRipple?: boolean;\n href?: string;\n pendingLabel?: string;\n rel?: string;\n style?: StyleOrFunction<ButtonState>;\n target?: string;\n} & ButtonDOMProps & RefAttributes<HTMLAnchorElement | HTMLButtonElement>;\n\n// The props a button hands React Aria. React Aria types the global DOM events\n// — pointer, mouse, touch, wheel and the rest — against the element each\n// component renders, and a handler written for a <button> does not type-check\n// against an <a>. The keys are retyped against HTMLElement here so one set of\n// props serves both forms; the events React Aria defines itself (press,\n// focus, keyboard) keep its types, since it hands those its own event objects.\ntype ButtonDOMProps = Omit<RACButtonProps, 'children' | 'className' | 'style' | GlobalEventKey> & Pick<DOMAttributes<HTMLElement>, GlobalEventKey>;\n\n// The render state React Aria's three elements share. A className or style\n// function written against it serves the button, the link and the toggle\n// alike; `isPending` belongs to the button alone, and `isCurrent` to the\n// link, so neither is here. What the button draws while pending is decided\n// in `buttonContent`, which sees React Aria's own state rather than this one.\n//\n// `isSelected` is optional because only the toggle has one: React Aria hands\n// the button and the link a state without it and the toggle a state with\n// it, and a parameter type this wide accepts either.\ntype ButtonState = Pick<ButtonRenderProps, 'isDisabled' | 'isFocused' | 'isFocusVisible' | 'isHovered' | 'isPressed'> & {\n isSelected?: boolean;\n};\ntype GlobalEventKey = Exclude<keyof DOMAttributes<HTMLElement> & keyof RACButtonProps, 'onBlur' | 'onClick' | 'onFocus'>;\ntype ToggleButtonBaseProps = {\n children?: ReactNode;\n /** As for ButtonBase, handed `isSelected` as well. */\n classes: (state: ButtonState) => ReturnType<typeof stylex.props>;\n className?: ClassNameOrFunction<ButtonState>;\n defaultSelected?: boolean;\n disableRipple?: boolean;\n isSelected?: boolean;\n onChange?: (isSelected: boolean) => void;\n style?: StyleOrFunction<ButtonState>;\n} & ButtonDOMProps & RefAttributes<HTMLAnchorElement | HTMLButtonElement>;\n\n/**\n * A button drawn with the classes a component hands it: React Aria's\n * `Button`, or its `Link` given `href`. See the header.\n */\nfunction ButtonBase({\n children,\n classes,\n href,\n isPending = false,\n pendingLabel,\n rel,\n render,\n target,\n ...input\n}: ButtonBaseProps) {\n const messages = useMessages();\n const {\n disabled,\n element,\n props,\n ref,\n ripple\n } = useButtonBase(input, isPending);\n const styleProps = mergeStatefulStyles(classes, props);\n if (href !== undefined) {\n return <RACLink href={href} isDisabled={disabled} ref={ref} rel={rel} render={linkRenderer(element)} target={target} {...ripple.handlers} {...props} {...styleProps}>\n {children}\n {ripple.surface}\n </RACLink>;\n }\n return <RACButton isDisabled={disabled} isPending={isPending} ref={ref} render={buttonRenderer(element, render)} {...ripple.handlers} {...props} {...styleProps}>\n {buttonContent(children, pendingLabel ?? messages.loading, ripple.surface)}\n </RACButton>;\n}\n\n// What the button draws: its label, hidden while the button is pending, with\n// the ring over it. The ring takes the button's own content colour rather\n// than the progress page's primary, which on a filled button is the fill\n// itself and so invisible. The label stays in the flow so the button keeps its\n// width, which is what stops a form jumping the moment it is submitted.\n// React Aria wants the progress bar in the accessibility tree as soon as the\n// button goes pending, so it is rendered from the render state rather than\n// after a delay.\n//\n// Built by a call rather than written inline at the prop, which is what\n// react-perf's no-new-function-as-prop is after; the React Compiler\n// memoises the result on its inputs.\nfunction buttonContent(children: ReactNode, pendingLabel: string, surface: ReactNode) {\n return (state: ButtonRenderProps) => <>\n <span {...stylex.props(buttonBaseStyles.label, state.isPending && buttonBaseStyles.labelPending)}>\n {children}\n </span>\n {state.isPending ? <span {...stylex.props(buttonBaseStyles.pending)}>\n <ProgressIndicator aria-label={pendingLabel} isIndeterminate size=\"1em\" tone=\"inherit\" variant=\"circular\" />\n </span> : null}\n {surface}\n </>;\n}\n\n/**\n * A toggle drawn with the classes a component hands it: React Aria's\n * `ToggleButton`, which reports its state through `aria-pressed`. It is never\n * a link and never pending — React Aria's toggle takes neither, and neither\n * means anything for a control whose whole job is to report which of two\n * states it is in — so `isPending` reaches it only to keep the ripple off,\n * as it does for the plain button.\n */\nfunction ToggleButtonBase({\n children,\n classes,\n defaultSelected,\n isPending = false,\n isSelected,\n onChange,\n render,\n ...input\n}: ToggleButtonBaseProps) {\n // A selecting ButtonGroup disables its toggles through React Aria's group\n // state, which no prop here carries, so the ripple would stay on in a\n // disabled group and answer a press with an animation. Handed on as the\n // toggle's own `isDisabled`, which is what React Aria makes of it anyway.\n const disabledByGroup = useToggleGroupDisabled(input.id);\n const {\n disabled,\n element,\n props,\n ref,\n ripple\n } = useButtonBase(disabledByGroup ? {\n ...input,\n isDisabled: true\n } : input, isPending);\n return <RACToggleButton defaultSelected={defaultSelected} isDisabled={disabled} isSelected={isSelected} onChange={onChange} ref={ref} render={toggleButtonRenderer(element, toggleRender(render))} {...ripple.handlers} {...props} {...mergeStatefulStyles(classes, props)}>\n {toggleContent(children, ripple.surface)}\n </RACToggleButton>;\n}\n\n// What a toggle draws: its label and the ripple. No pending ring — see\n// ToggleButtonBase. Built by a call for the reason `buttonContent` is.\nfunction toggleContent(children: ReactNode, surface: ReactNode) {\n return () => <>\n {children}\n {surface}\n </>;\n}\n\n// A call site's `render` is written for React Aria's button, whose render\n// state says whether it is pending; a toggle's says nothing of it, and a\n// toggle never is. So the toggle hands that function its own state with\n// `isPending` filled in, which is what lets one `render` prop serve a button\n// whichever element it turns out to be.\nfunction toggleRender(render: RACButtonProps['render']): RACToggleButtonProps['render'] {\n if (render === undefined) {\n return undefined;\n }\n return (props, state) => render(props, {\n ...state,\n isPending: false\n });\n}\n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AA,KAAAtB,EAAA;CAAA,OAFbsB;AAEa;AAKtB,SAASS,cAAc1D,UAAqB4C,SAAoB;CAC9D,aAAa,qBAAA,UAAA,EAAA,UAAA,CACR5C,UACA4C,OACH,EAAA,CAAA;AACJ;AAOA,SAASa,aAAa3B,QAAkE;CACtF,IAAIA,WAAWG,KAAAA,GACb;CAEF,QAAQ5B,OAAOH,UAAU4B,OAAOzB,OAAO;EACrC,GAAGH;EACH8B,WAAW;CACb,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["DOMAttributes","ReactNode","RefAttributes","ButtonRenderProps","ClassNameOrFunction","ButtonProps","RACButtonProps","ToggleButtonProps","RACToggleButtonProps","StyleOrFunction","stylex","Button","RACButton","Link","RACLink","ToggleButton","RACToggleButton","ProgressIndicator","useToggleGroupDisabled","useMessages","buttonRenderer","linkRenderer","toggleButtonRenderer","mergeStatefulStyles","useButtonBase","buttonBaseStyles","ButtonBaseProps","children","classes","state","ButtonState","ReturnType","props","className","disableRipple","href","pendingLabel","rel","style","target","ButtonDOMProps","HTMLAnchorElement","HTMLButtonElement","Omit","GlobalEventKey","Pick","HTMLElement","isSelected","Exclude","ToggleButtonBaseProps","defaultSelected","onChange","ButtonBase","t0","$","_c","input","render","t1","isPending","undefined","messages","disabled","element","ref","ripple","t2","styleProps","t3","t4","handlers","surface","t5","loading","t6","buttonContent","t7","label","labelPending","pending","ToggleButtonBase","disabledByGroup","id","isDisabled","toggleRender","toggleContent","_c","RACLink","RACButton","stylex.props","RACToggleButton"],"sources":["../../src/button/index.tsx"],"sourcesContent":["import type { DOMAttributes, ReactNode, RefAttributes } from 'react';\nimport type { ButtonRenderProps, ClassNameOrFunction, ButtonProps as RACButtonProps, ToggleButtonProps as RACToggleButtonProps, StyleOrFunction } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { Button as RACButton, Link as RACLink, ToggleButton as RACToggleButton } from 'react-aria-components';\nimport ProgressIndicator from '../components/progress-indicator';\nimport { useToggleGroupDisabled } from '../hooks/useToggleGroupDisabled';\nimport { useMessages } from '../i18n';\nimport { buttonRenderer, linkRenderer, toggleButtonRenderer } from '../render/aria';\nimport { mergeStatefulStyles } from '../styles/merge';\nimport { useButtonBase } from './hooks';\nimport { buttonBaseStyles } from './styles';\n\n// The press-button core Button and IconButton both render through. A button\n// is React Aria's `Button`, its `Link` once given `href`, or its\n// `ToggleButton` once it reports a state, and around each this adds what\n// React Aria leaves out: the ripple, the disabled state a parent's context\n// sets, the `aria-*` props and keyboard handlers it would drop or wrap, and\n// the ring drawn over the label while the button is pending. Each component\n// brings its own classes, as a function of the render state, and the call\n// site's `className` and `style` are merged over them.\n//\n// One module rather than a copy in each, since the copies had already drifted\n// once: IconButton read `ButtonContext` for a parent's disabled state and\n// Button did not. Not a component of the library's own and not exported from\n// the package; see `src/row` for the same arrangement around a list's row.\n\ntype ButtonBaseProps = {\n children?: ReactNode;\n /**\n * The component's own classes, from the render state. The call site's\n * `className` and `style` are merged over them.\n */\n classes: (state: ButtonState) => ReturnType<typeof stylex.props>;\n className?: ClassNameOrFunction<ButtonState>;\n disableRipple?: boolean;\n href?: string;\n pendingLabel?: string;\n rel?: string;\n style?: StyleOrFunction<ButtonState>;\n target?: string;\n} & ButtonDOMProps & RefAttributes<HTMLAnchorElement | HTMLButtonElement>;\n\n// The props a button hands React Aria. React Aria types the global DOM events\n// — pointer, mouse, touch, wheel and the rest — against the element each\n// component renders, and a handler written for a <button> does not type-check\n// against an <a>. The keys are retyped against HTMLElement here so one set of\n// props serves both forms; the events React Aria defines itself (press,\n// focus, keyboard) keep its types, since it hands those its own event objects.\ntype ButtonDOMProps = Omit<RACButtonProps, 'children' | 'className' | 'style' | GlobalEventKey> & Pick<DOMAttributes<HTMLElement>, GlobalEventKey>;\n\n// The render state React Aria's three elements share. A className or style\n// function written against it serves the button, the link and the toggle\n// alike; `isPending` belongs to the button alone, and `isCurrent` to the\n// link, so neither is here. What the button draws while pending is decided\n// in `buttonContent`, which sees React Aria's own state rather than this one.\n//\n// `isSelected` is optional because only the toggle has one: React Aria hands\n// the button and the link a state without it and the toggle a state with\n// it, and a parameter type this wide accepts either.\ntype ButtonState = Pick<ButtonRenderProps, 'isDisabled' | 'isFocused' | 'isFocusVisible' | 'isHovered' | 'isPressed'> & {\n isSelected?: boolean;\n};\ntype GlobalEventKey = Exclude<keyof DOMAttributes<HTMLElement> & keyof RACButtonProps, 'onBlur' | 'onClick' | 'onFocus'>;\ntype ToggleButtonBaseProps = {\n children?: ReactNode;\n /** As for ButtonBase, handed `isSelected` as well. */\n classes: (state: ButtonState) => ReturnType<typeof stylex.props>;\n className?: ClassNameOrFunction<ButtonState>;\n defaultSelected?: boolean;\n disableRipple?: boolean;\n isSelected?: boolean;\n onChange?: (isSelected: boolean) => void;\n style?: StyleOrFunction<ButtonState>;\n} & ButtonDOMProps & RefAttributes<HTMLAnchorElement | HTMLButtonElement>;\n\n/**\n * A button drawn with the classes a component hands it: React Aria's\n * `Button`, or its `Link` given `href`. See the header.\n */\nfunction ButtonBase({\n children,\n classes,\n href,\n isPending = false,\n pendingLabel,\n rel,\n render,\n target,\n ...input\n}: ButtonBaseProps) {\n const messages = useMessages();\n const {\n disabled,\n element,\n props,\n ref,\n ripple\n } = useButtonBase(input, isPending);\n const styleProps = mergeStatefulStyles(classes, props);\n if (href !== undefined) {\n return <RACLink href={href} isDisabled={disabled} ref={ref} rel={rel} render={linkRenderer(element)} target={target} {...ripple.handlers} {...props} {...styleProps}>\n {children}\n {ripple.surface}\n </RACLink>;\n }\n return <RACButton isDisabled={disabled} isPending={isPending} ref={ref} render={buttonRenderer(element, render)} {...ripple.handlers} {...props} {...styleProps}>\n {buttonContent(children, pendingLabel ?? messages.loading, ripple.surface)}\n </RACButton>;\n}\n\n// What the button draws: its label, hidden while the button is pending, with\n// the ring over it. The ring takes the button's own content colour rather\n// than the progress page's primary, which on a filled button is the fill\n// itself and so invisible. The label stays in the flow so the button keeps its\n// width, which is what stops a form jumping the moment it is submitted.\n// React Aria wants the progress bar in the accessibility tree as soon as the\n// button goes pending, so it is rendered from the render state rather than\n// after a delay.\n//\n// Built by a call rather than written inline at the prop, which is what\n// react-perf's no-new-function-as-prop is after; the React Compiler\n// memoises the result on its inputs.\nfunction buttonContent(children: ReactNode, pendingLabel: string, surface: ReactNode) {\n return (state: ButtonRenderProps) => <>\n <span {...stylex.props(buttonBaseStyles.label, state.isPending && buttonBaseStyles.labelPending)}>\n {children}\n </span>\n {state.isPending ? <span {...stylex.props(buttonBaseStyles.pending)}>\n <ProgressIndicator aria-label={pendingLabel} diameter=\"1em\" isIndeterminate tone=\"inherit\" variant=\"circular\" />\n </span> : null}\n {surface}\n </>;\n}\n\n/**\n * A toggle drawn with the classes a component hands it: React Aria's\n * `ToggleButton`, which reports its state through `aria-pressed`. It is never\n * a link and never pending — React Aria's toggle takes neither, and neither\n * means anything for a control whose whole job is to report which of two\n * states it is in — so `isPending` reaches it only to keep the ripple off,\n * as it does for the plain button.\n */\nfunction ToggleButtonBase({\n children,\n classes,\n defaultSelected,\n isPending = false,\n isSelected,\n onChange,\n render,\n ...input\n}: ToggleButtonBaseProps) {\n // A selecting ButtonGroup disables its toggles through React Aria's group\n // state, which no prop here carries, so the ripple would stay on in a\n // disabled group and answer a press with an animation. Handed on as the\n // toggle's own `isDisabled`, which is what React Aria makes of it anyway.\n const disabledByGroup = useToggleGroupDisabled(input.id);\n const {\n disabled,\n element,\n props,\n ref,\n ripple\n } = useButtonBase(disabledByGroup ? {\n ...input,\n isDisabled: true\n } : input, isPending);\n return <RACToggleButton defaultSelected={defaultSelected} isDisabled={disabled} isSelected={isSelected} onChange={onChange} ref={ref} render={toggleButtonRenderer(element, toggleRender(render))} {...ripple.handlers} {...props} {...mergeStatefulStyles(classes, props)}>\n {toggleContent(children, ripple.surface)}\n </RACToggleButton>;\n}\n\n// What a toggle draws: its label and the ripple. No pending ring — see\n// ToggleButtonBase. Built by a call for the reason `buttonContent` is.\nfunction toggleContent(children: ReactNode, surface: ReactNode) {\n return () => <>\n {children}\n {surface}\n </>;\n}\n\n// A call site's `render` is written for React Aria's button, whose render\n// state says whether it is pending; a toggle's says nothing of it, and a\n// toggle never is. So the toggle hands that function its own state with\n// `isPending` filled in, which is what lets one `render` prop serve a button\n// whichever element it turns out to be.\nfunction toggleRender(render: RACButtonProps['render']): RACToggleButtonProps['render'] {\n if (render === undefined) {\n return undefined;\n }\n return (props, state) => render(props, {\n ...state,\n isPending: false\n });\n}\nexport type { ButtonDOMProps, ButtonState };\nexport { ButtonBase, ToggleButtonBase };"],"mappings":";;;;;;;;;;;;;;;;AA+EA,SAAAoD,WAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAA5B;CAAA,IAAAC;CAAA,IAAAO;CAAA,IAAAqB;CAAA,IAAApB;CAAA,IAAAC;CAAA,IAAAoB;CAAA,IAAAC;CAAA,IAAAnB;CAAA,IAAAe,EAAA,OAAAD,IAAA;EAAoB,CAAA,CAAA1B,UAAAC,SAAAO,MAAAwB,WAAAD,IAAAtB,cAAAC,KAAAoB,QAAAlB,QAAA,GAAAiB,SAAAH;EAUFC,EAAA,KAAAD;EAAAC,EAAA,KAAA3B;EAAA2B,EAAA,KAAA1B;EAAA0B,EAAA,KAAAnB;EAAAmB,EAAA,KAAAE;EAAAF,EAAA,KAAAlB;EAAAkB,EAAA,KAAAjB;EAAAiB,EAAA,KAAAG;EAAAH,EAAA,KAAAI;EAAAJ,EAAA,KAAAf;CAAA,OAAA;EAAAZ,WAAA2B,EAAA;EAAA1B,UAAA0B,EAAA;EAAAnB,OAAAmB,EAAA;EAAAE,QAAAF,EAAA;EAAAlB,eAAAkB,EAAA;EAAAjB,MAAAiB,EAAA;EAAAG,SAAAH,EAAA;EAAAI,KAAAJ,EAAA;EAAAf,SAAAe,EAAA;CAAA;CANhB,MAAAK,YAAAD,OAAAE,KAAAA,IAAA,QAAAF;CAOA,MAAAG,WAAiB1C,YAAY;CAC7B,MAAA,EAAA2C,UAAAC,SA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GAAMwC;GAClOE,UAAAA;EADkB,CAAA;EAEHpB,EAAA,MAAAJ;EAAAI,EAAA,MAAAQ;EAAAR,EAAA,MAAAP;EAAAO,EAAA,MAAAH;EAAAG,EAAA,MAAAtB;EAAAsB,EAAA,MAAAU;EAAAV,EAAA,MAAAW,OAAAK;EAAAhB,EAAA,MAAAc;EAAAd,EAAA,MAAAkB;EAAAlB,EAAA,MAAAoB;EAAApB,EAAA,MAAAsB;CAAA,OAAAA,KAAAtB,EAAA;CAAA,OAFbsB;AAEa;AAKtB,SAASS,cAAc1D,UAAqB4C,SAAoB;CAC9D,aAAa,qBAAA,UAAA,EAAA,UAAA,CACR5C,UACA4C,OACH,EAAA,CAAA;AACJ;AAOA,SAASa,aAAa3B,QAAkE;CACtF,IAAIA,WAAWG,KAAAA,GACb;CAEF,QAAQ5B,OAAOH,UAAU4B,OAAOzB,OAAO;EACrC,GAAGH;EACH8B,WAAW;CACb,CAAC;AACH"}
|
package/dist/calendar/styles.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","names":["stylex","colors","radii","sizing","spacing","stateLayerOpacity","typography","ROW_BLOCK_SIZE","WEEKS_HELD","FORCED_COLORS","calendarStyles","cell","kGNEyG","kWkggS","kZKoxP","kaIpWk","kB7OPa","kMwMTN","kkrTdU","k1xSpc","kMv6JI","kGuDYH","k63SB2","kzqmXN","kjj79g","kb6lSQ","kLWn49","kUOVxO","$$css","cellDisabled","kAXs8y","cellInRange","kVAM5u","kjBf7l","cellRangeEnd","kT0f0o","kfmiAY","cellRangeStart","kVL7Gh","krdFHd","cellSelected","cellToday","ksu8eU","kMzoRj","cellUnavailable","kMnn75","chevron","chevronGlyph","k3aq6I","chevronGlyphPrevious","chevronHidden","k33iCy","grid","kLvRdT","kheTzg","header","kOIVth","kAzted","headerCell","headerGroup","heading","kogj98","k9WMMc","menuArrow","kmuXW","menuArrowExpanded","menuButton","kg3NbH","menuCheck","menuItem","k3XXqK","menuItemDisabled","menuItemFocused","kInvED","kMeerF","menuItemSelected","menuList","kLZC3w","kPef9Z","kEafiO","kORKVm","months","root","kXwgrk","k7Eaqz","kmVPX3","dateLayers","inRangeHovered","inRangePressed","plainHovered","plainPressed","selectedHovered","selectedPressed","menuLayers"],"sources":["../../src/calendar/styles.ts"],"sourcesContent":["import * as stylex from '@stylexjs/stylex';\nimport '../tokens/design.tokens.stylex';\nimport { colors, radii, sizing, spacing, stateLayerOpacity, typography } from '../tokens/design.tokens.stylex';\n\n// The styles Calendar and RangeCalendar both draw. Apart from either\n// component so the two cannot drift, and outside `src/components` because a\n// directory there is a public component with stories, a barrel entry and a\n// `styling.test.tsx` case — which shared styles are none of.\n//\n// The values are the date pickers page's docked calendar, named in\n// `src/components/calendar/index.tsx` along with the departures from it. What\n// is only a range's — the band between the two ends — takes its colours from\n// the modal date picker's range-selection tokens instead, since the docked\n// token set stops at the selected date; see `cellInRange`.\n//\n// Under forced colours a selected date and a range's band are fills, which\n// that mode paints in a system colour, so a calendar showed no selection and\n// no range there, only today's outline. Both take `Highlight` with\n// `HighlightText` over it, the pair the mode gives whatever is chosen, which\n// draws a range as one run from its first day to its last.\n//\n// They take the pair with `forced-color-adjust: none`. Left to adjust, the\n// mode lays a `Canvas` backplate behind every run of text, and a date in\n// `HighlightText` on that backplate is a blank box. With it off nothing is\n// forced on those cells, so they name a system colour for everything they\n// draw — the fill, the date, today's outline and the focus ring. A day ruled\n// out or disabled names none, so it hands itself back to the mode.\n\n// One row of the grid. The weekday row and every week of dates are the same\n// 40dp, so `cell`, `headerCell` and the room `months` reserves are all this\n// one number — a date resized without the reservation following it would put\n// the calendar's height back on its month.\nconst ROW_BLOCK_SIZE = '40px';\n\n// The weeks the grid holds room for, which is the most any month occupies: a\n// 31-day month beginning on the last day of a week runs one day, then four\n// whole weeks, then two days. February 2026 is the other end at four. Holding\n// six draws every month in the box the longest one fills.\nconst WEEKS_HELD = 6;\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 calendarStyles = {\n cell: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"x1vqgdyp\",\n kaIpWk: \"x16fbrrb\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x139gbkf\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x78zum5\",\n kMv6JI: \"x16svsjw\",\n kGuDYH: \"x1848etk\",\n k63SB2: \"x1c52epr\",\n kzqmXN: \"x100vrsf\",\n kjj79g: \"xl56j7k\",\n kb6lSQ: \"x1qn8t5l\",\n kLWn49: \"xh7dzej\",\n kUOVxO: \"x34s64n\",\n $$css: true\n },\n cellDisabled: {\n kWkggS: \"xjbqb8w\",\n kMwMTN: \"x9w6zvh\",\n kkrTdU: \"x1h6gzvc\",\n kAXs8y: \"xr5dkdi\",\n $$css: true\n },\n cellInRange: {\n kWkggS: \"x15dekr4 x1jzqe4\",\n kVAM5u: \"x1uajy3w x1n2ykn\",\n kaIpWk: \"x2u8bby\",\n kMwMTN: \"x1sawysd x1k5gbb1\",\n kAXs8y: \"x1g12otp\",\n kzqmXN: \"xh8yej3\",\n kUOVxO: \"xrxpjvj\",\n kjBf7l: \"xrgy624 x3teovq\",\n $$css: true\n },\n cellRangeEnd: {\n kT0f0o: \"x187kppt\",\n kfmiAY: \"x1fpsnkq\",\n $$css: true\n },\n cellRangeStart: {\n kVL7Gh: \"x17kgqx\",\n krdFHd: \"x1uni95s\",\n $$css: true\n },\n cellSelected: {\n kWkggS: \"xnety89 x1jzqe4\",\n kVAM5u: \"x1uajy3w x1n2ykn\",\n kMwMTN: \"xwjo7ld x1k5gbb1\",\n kAXs8y: \"x1g12otp\",\n kjBf7l: \"xrgy624 x3teovq\",\n $$css: true\n },\n cellToday: {\n kVAM5u: \"x1uajy3w\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xmkeg23\",\n kMwMTN: \"x1mxwv8y\",\n $$css: true\n },\n cellUnavailable: {\n kWkggS: \"xjbqb8w\",\n kkrTdU: \"x1h6gzvc\",\n kAXs8y: \"xr5dkdi\",\n kMnn75: \"x5lhwog\",\n $$css: true\n },\n chevron: {\n kUOVxO: \"x34s64n\",\n $$css: true\n },\n chevronGlyph: {\n kZKoxP: \"xxk0z11\",\n kzqmXN: \"xvy4d1p\",\n k3aq6I: \"x19axjrm x1c071of\",\n $$css: true\n },\n chevronGlyphPrevious: {\n k3aq6I: \"xdg80k9 xpk2tj9\",\n $$css: true\n },\n chevronHidden: {\n k33iCy: \"xlshs6z\",\n $$css: true\n },\n grid: {\n kLvRdT: \"x1vathgz\",\n kheTzg: \"x1gukg7c\",\n kzqmXN: \"xh8yej3\",\n $$css: true\n },\n header: {\n kGNEyG: \"x6s0dn4\",\n k1xSpc: \"x78zum5\",\n kOIVth: \"x126z3so\",\n kjj79g: \"x1qughib\",\n kAzted: \"x1ba4aug\",\n $$css: true\n },\n headerCell: {\n kZKoxP: \"x1vqgdyp\",\n kMwMTN: \"x139gbkf\",\n kMv6JI: \"x16svsjw\",\n kGuDYH: \"x1848etk\",\n k63SB2: \"x1c52epr\",\n kb6lSQ: \"x1qn8t5l\",\n kLWn49: \"xh7dzej\",\n $$css: true\n },\n headerGroup: {\n kGNEyG: \"x6s0dn4\",\n k1xSpc: \"x78zum5\",\n $$css: true\n },\n heading: {\n kMwMTN: \"x1w5n3ug\",\n kMv6JI: \"xkknnkr\",\n kGuDYH: \"x14zspaw\",\n k63SB2: \"x1v9cpvo\",\n kb6lSQ: \"x155f00i\",\n kLWn49: \"x1lz68p4\",\n kogj98: \"x1ghz6dp\",\n k9WMMc: \"x2b8uid\",\n $$css: true\n },\n menuArrow: {\n kZKoxP: \"xmix8c7\",\n kmuXW: \"x2lah0s\",\n kzqmXN: \"x1xp8n7a\",\n $$css: true\n },\n menuArrowExpanded: {\n k3aq6I: \"x19jd1h0\",\n $$css: true\n },\n menuButton: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"x1rv7mn0\",\n kaIpWk: \"x1dkaolv\",\n kMzoRj: \"xc342km\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x1w5n3ug\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x78zum5\",\n kmuXW: \"x2lah0s\",\n kMv6JI: \"xkknnkr\",\n kGuDYH: \"x14zspaw\",\n k63SB2: \"x1v9cpvo\",\n kOIVth: \"xzoy561\",\n kb6lSQ: \"x155f00i\",\n kLWn49: \"x1lz68p4\",\n kg3NbH: \"xn60lsn\",\n $$css: true\n },\n menuCheck: {\n kZKoxP: \"xxk0z11\",\n kMwMTN: \"x139gbkf\",\n kmuXW: \"x2lah0s\",\n kzqmXN: \"xvy4d1p\",\n $$css: true\n },\n menuItem: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"xbg5kjn\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x139gbkf\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x78zum5\",\n kMv6JI: \"x16svsjw\",\n kGuDYH: \"x1848etk\",\n k63SB2: \"x1c52epr\",\n kOIVth: \"xxj4525\",\n kb6lSQ: \"x1qn8t5l\",\n kLWn49: \"xh7dzej\",\n k3XXqK: \"x1t137rt\",\n kg3NbH: \"x790zyz\",\n $$css: true\n },\n menuItemDisabled: {\n kWkggS: \"xjbqb8w\",\n kMwMTN: \"x9w6zvh\",\n kkrTdU: \"x1h6gzvc\",\n $$css: true\n },\n menuItemFocused: {\n kjBf7l: \"xrgy624\",\n kInvED: \"x2ssjo2\",\n k3XXqK: \"xaatb59\",\n kMeerF: \"x1de99jn\",\n $$css: true\n },\n menuItemSelected: {\n kWkggS: \"xkrgufg\",\n $$css: true\n },\n menuList: {\n kZKoxP: \"x1mj9p22\",\n kLZC3w: \"x12smttz\",\n kPef9Z: \"x13fuv20\",\n kEafiO: \"x178xt8z\",\n kB7OPa: \"x9f619\",\n kUOVxO: \"xnx04jz\",\n k3XXqK: \"x1t137rt\",\n kORKVm: \"x1odjw0f\",\n $$css: true\n },\n months: {\n kGNEyG: \"x7a106z\",\n k1xSpc: \"x78zum5\",\n kOIVth: \"xj2l1yv\",\n kAzted: \"x1fivsg2\",\n $$css: true\n },\n root: {\n kWkggS: \"xvkjz1l\",\n kaIpWk: \"xhpdng0\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x139gbkf\",\n k1xSpc: \"x78zum5\",\n kXwgrk: \"xdt5ytf\",\n kOIVth: \"x1gka490\",\n kzqmXN: \"xeq5yr9\",\n k7Eaqz: \"x1gvwcb\",\n kmVPX3: \"xa36j16\",\n $$css: true\n }\n};\n\n// A date's hover and pressed layers, one pair per ground it sits on: nothing,\n// the range band, and the selected circle. From React Aria's render state rather than `:hover` and `:active`, for Button's\n// reasons — see its header: a hover layer stayed on after a tap, and no\n// pressed layer showed for a press made from the keyboard.\n// Each layer is written whole for its ground because StyleX replaces a\n// property whole, and the band and the circle keep their forced-colours\n// `Highlight` under the layer.\nconst dateLayers = {\n inRangeHovered: {\n kWkggS: \"x3zumxv x1jzqe4\",\n $$css: true\n },\n inRangePressed: {\n kWkggS: \"x1as5h4c x1jzqe4\",\n $$css: true\n },\n plainHovered: {\n kWkggS: \"x1b18xnh\",\n $$css: true\n },\n plainPressed: {\n kWkggS: \"xjeeohs\",\n $$css: true\n },\n selectedHovered: {\n kWkggS: \"xo1ct44 x1jzqe4\",\n $$css: true\n },\n selectedPressed: {\n kWkggS: \"x7b25lv x1jzqe4\",\n $$css: true\n }\n};\n\n// A list row's hover and pressed layers over the checked row's surface\n// variant. Over nothing a row takes a date's own pair, `dateLayers.plain*`,\n// since the page gives both the same on-surface layer.\nconst menuLayers = {\n selectedHovered: {\n kWkggS: \"xgw93rf\",\n $$css: true\n },\n selectedPressed: {\n kWkggS: \"x113d7pk\",\n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;EACRI,QAAQ;EACR9C,OAAO;CACT;CACA+C,kBAAkB;EAChB9D,QAAQ;EACRe,OAAO;CACT;CACAgD,UAAU;EACR9D,QAAQ;EACR+D,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACR/D,QAAQ;EACRW,QAAQ;EACR2C,QAAQ;EACRU,QAAQ;EACRpD,OAAO;CACT;CACAqD,QAAQ;EACNrE,QAAQ;EACRO,QAAQ;EACRqC,QAAQ;EACRC,QAAQ;EACR7B,OAAO;CACT;CACAsD,MAAM;EACJrE,QAAQ;EACRE,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRE,QAAQ;EACRgE,QAAQ;EACR3B,QAAQ;EACRjC,QAAQ;EACR6D,QAAQ;EACRC,QAAQ;EACRzD,OAAO;CACT;AACF;AASA,MAAM0D,aAAa;CACjBC,gBAAgB;EACd1E,QAAQ;EACRe,OAAO;CACT;CACA4D,gBAAgB;EACd3E,QAAQ;EACRe,OAAO;CACT;CACA6D,cAAc;EACZ5E,QAAQ;EACRe,OAAO;CACT;CACA8D,cAAc;EACZ7E,QAAQ;EACRe,OAAO;CACT;CACA+D,iBAAiB;EACf9E,QAAQ;EACRe,OAAO;CACT;CACAgE,iBAAiB;EACf/E,QAAQ;EACRe,OAAO;CACT;AACF;AAKA,MAAMiE,aAAa;CACjBF,iBAAiB;EACf9E,QAAQ;EACRe,OAAO;CACT;CACAgE,iBAAiB;EACf/E,QAAQ;EACRe,OAAO;CACT;AACF"}
|
|
1
|
+
{"version":3,"file":"styles.js","names":["stylex","colors","media","radii","sizing","spacing","stateLayerOpacity","typography","ROW_BLOCK_SIZE","WEEKS_HELD","FORCED_COLORS","calendarStyles","cell","kGNEyG","kWkggS","kZKoxP","kaIpWk","kB7OPa","kMwMTN","kkrTdU","k1xSpc","kMv6JI","kGuDYH","k63SB2","kzqmXN","kjj79g","kb6lSQ","kLWn49","kUOVxO","$$css","cellDisabled","kAXs8y","cellInRange","kVAM5u","kjBf7l","cellRangeEnd","kT0f0o","kfmiAY","cellRangeStart","kVL7Gh","krdFHd","cellSelected","cellToday","ksu8eU","kMzoRj","cellUnavailable","kMnn75","chevron","chevronGlyph","k3aq6I","chevronGlyphPrevious","chevronHidden","k33iCy","grid","kLvRdT","kheTzg","header","kOIVth","kAzted","headerCell","headerGroup","heading","kogj98","k9WMMc","menuArrow","kmuXW","menuArrowExpanded","menuButton","kg3NbH","menuCheck","menuItem","k3XXqK","menuItemDisabled","menuItemFocused","kInvED","kMeerF","menuItemSelected","menuList","kLZC3w","kPef9Z","kEafiO","kORKVm","months","kJBjZk","root","kXwgrk","k7Eaqz","kmVPX3","dateLayers","inRangeHovered","inRangePressed","plainHovered","plainPressed","selectedHovered","selectedPressed","menuLayers"],"sources":["../../src/calendar/styles.ts"],"sourcesContent":["import * as stylex from '@stylexjs/stylex';\nimport '../tokens/design.tokens.stylex';\nimport { colors, media, radii, sizing, spacing, stateLayerOpacity, typography } from '../tokens/design.tokens.stylex';\n\n// The styles Calendar and RangeCalendar both draw. Apart from either\n// component so the two cannot drift, and outside `src/components` because a\n// directory there is a public component with stories, a barrel entry and a\n// `styling.test.tsx` case — which shared styles are none of.\n//\n// The values are the date pickers page's docked calendar, named in\n// `src/components/calendar/index.tsx` along with the departures from it. What\n// is only a range's — the band between the two ends — takes its colours from\n// the modal date picker's range-selection tokens instead, since the docked\n// token set stops at the selected date; see `cellInRange`.\n//\n// Under forced colours a selected date and a range's band are fills, which\n// that mode paints in a system colour, so a calendar showed no selection and\n// no range there, only today's outline. Both take `Highlight` with\n// `HighlightText` over it, the pair the mode gives whatever is chosen, which\n// draws a range as one run from its first day to its last.\n//\n// They take the pair with `forced-color-adjust: none`. Left to adjust, the\n// mode lays a `Canvas` backplate behind every run of text, and a date in\n// `HighlightText` on that backplate is a blank box. With it off nothing is\n// forced on those cells, so they name a system colour for everything they\n// draw — the fill, the date, today's outline and the focus ring. A day ruled\n// out or disabled names none, so it hands itself back to the mode.\n\n// One row of the grid. The weekday row and every week of dates are the same\n// 40dp, so `cell`, `headerCell` and the room `months` reserves are all this\n// one number — a date resized without the reservation following it would put\n// the calendar's height back on its month.\nconst ROW_BLOCK_SIZE = '40px';\n\n// The weeks the grid holds room for, which is the most any month occupies: a\n// 31-day month beginning on the last day of a week runs one day, then four\n// whole weeks, then two days. February 2026 is the other end at four. Holding\n// six draws every month in the box the longest one fills.\nconst WEEKS_HELD = 6;\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 calendarStyles = {\n cell: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"x1vqgdyp\",\n kaIpWk: \"x16fbrrb\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x139gbkf\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x78zum5\",\n kMv6JI: \"x16svsjw\",\n kGuDYH: \"x1848etk\",\n k63SB2: \"x1c52epr\",\n kzqmXN: \"x100vrsf\",\n kjj79g: \"xl56j7k\",\n kb6lSQ: \"x1qn8t5l\",\n kLWn49: \"xh7dzej\",\n kUOVxO: \"x34s64n\",\n $$css: true\n },\n cellDisabled: {\n kWkggS: \"xjbqb8w\",\n kMwMTN: \"x9w6zvh\",\n kkrTdU: \"x1h6gzvc\",\n kAXs8y: \"xr5dkdi\",\n $$css: true\n },\n cellInRange: {\n kWkggS: \"x15dekr4 x1jzqe4\",\n kVAM5u: \"x1uajy3w x1n2ykn\",\n kaIpWk: \"x2u8bby\",\n kMwMTN: \"x1sawysd x1k5gbb1\",\n kAXs8y: \"x1g12otp\",\n kzqmXN: \"xh8yej3\",\n kUOVxO: \"xrxpjvj\",\n kjBf7l: \"xrgy624 x3teovq\",\n $$css: true\n },\n cellRangeEnd: {\n kT0f0o: \"x187kppt\",\n kfmiAY: \"x1fpsnkq\",\n $$css: true\n },\n cellRangeStart: {\n kVL7Gh: \"x17kgqx\",\n krdFHd: \"x1uni95s\",\n $$css: true\n },\n cellSelected: {\n kWkggS: \"xnety89 x1jzqe4\",\n kVAM5u: \"x1uajy3w x1n2ykn\",\n kMwMTN: \"xwjo7ld x1k5gbb1\",\n kAXs8y: \"x1g12otp\",\n kjBf7l: \"xrgy624 x3teovq\",\n $$css: true\n },\n cellToday: {\n kVAM5u: \"x1uajy3w\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xmkeg23\",\n kMwMTN: \"x1mxwv8y\",\n $$css: true\n },\n cellUnavailable: {\n kWkggS: \"xjbqb8w\",\n kkrTdU: \"x1h6gzvc\",\n kAXs8y: \"xr5dkdi\",\n kMnn75: \"x5lhwog\",\n $$css: true\n },\n chevron: {\n kUOVxO: \"x34s64n\",\n $$css: true\n },\n chevronGlyph: {\n kZKoxP: \"xxk0z11\",\n kzqmXN: \"xvy4d1p\",\n k3aq6I: \"x19axjrm x1c071of\",\n $$css: true\n },\n chevronGlyphPrevious: {\n k3aq6I: \"xdg80k9 xpk2tj9\",\n $$css: true\n },\n chevronHidden: {\n k33iCy: \"xlshs6z\",\n $$css: true\n },\n grid: {\n kLvRdT: \"x1vathgz\",\n kheTzg: \"x1gukg7c\",\n kzqmXN: \"xh8yej3\",\n $$css: true\n },\n header: {\n kGNEyG: \"x6s0dn4\",\n k1xSpc: \"x78zum5\",\n kOIVth: \"x126z3so\",\n kjj79g: \"x1qughib\",\n kAzted: \"x1ba4aug\",\n $$css: true\n },\n headerCell: {\n kZKoxP: \"x1vqgdyp\",\n kMwMTN: \"x139gbkf\",\n kMv6JI: \"x16svsjw\",\n kGuDYH: \"x1848etk\",\n k63SB2: \"x1c52epr\",\n kb6lSQ: \"x1qn8t5l\",\n kLWn49: \"xh7dzej\",\n $$css: true\n },\n headerGroup: {\n kGNEyG: \"x6s0dn4\",\n k1xSpc: \"x78zum5\",\n $$css: true\n },\n heading: {\n kMwMTN: \"x1w5n3ug\",\n kMv6JI: \"xkknnkr\",\n kGuDYH: \"x14zspaw\",\n k63SB2: \"x1v9cpvo\",\n kb6lSQ: \"x155f00i\",\n kLWn49: \"x1lz68p4\",\n kogj98: \"x1ghz6dp\",\n k9WMMc: \"x2b8uid\",\n $$css: true\n },\n menuArrow: {\n kZKoxP: \"xmix8c7\",\n kmuXW: \"x2lah0s\",\n kzqmXN: \"x1xp8n7a\",\n $$css: true\n },\n menuArrowExpanded: {\n k3aq6I: \"x19jd1h0\",\n $$css: true\n },\n menuButton: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"x1rv7mn0\",\n kaIpWk: \"x1dkaolv\",\n kMzoRj: \"xc342km\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x1w5n3ug\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x78zum5\",\n kmuXW: \"x2lah0s\",\n kMv6JI: \"xkknnkr\",\n kGuDYH: \"x14zspaw\",\n k63SB2: \"x1v9cpvo\",\n kOIVth: \"xzoy561\",\n kb6lSQ: \"x155f00i\",\n kLWn49: \"x1lz68p4\",\n kg3NbH: \"xn60lsn\",\n $$css: true\n },\n menuCheck: {\n kZKoxP: \"xxk0z11\",\n kMwMTN: \"x139gbkf\",\n kmuXW: \"x2lah0s\",\n kzqmXN: \"xvy4d1p\",\n $$css: true\n },\n menuItem: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"xbg5kjn\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x139gbkf\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x78zum5\",\n kMv6JI: \"x16svsjw\",\n kGuDYH: \"x1848etk\",\n k63SB2: \"x1c52epr\",\n kOIVth: \"xxj4525\",\n kb6lSQ: \"x1qn8t5l\",\n kLWn49: \"xh7dzej\",\n k3XXqK: \"x1t137rt\",\n kg3NbH: \"x790zyz\",\n $$css: true\n },\n menuItemDisabled: {\n kWkggS: \"xjbqb8w\",\n kMwMTN: \"x9w6zvh\",\n kkrTdU: \"x1h6gzvc\",\n $$css: true\n },\n menuItemFocused: {\n kjBf7l: \"xrgy624\",\n kInvED: \"x2ssjo2\",\n k3XXqK: \"xaatb59\",\n kMeerF: \"x1de99jn\",\n $$css: true\n },\n menuItemSelected: {\n kWkggS: \"xkrgufg\",\n $$css: true\n },\n menuList: {\n kZKoxP: \"x1mj9p22\",\n kLZC3w: \"x12smttz\",\n kPef9Z: \"x13fuv20\",\n kEafiO: \"x178xt8z\",\n kB7OPa: \"x9f619\",\n kUOVxO: \"xnx04jz\",\n k3XXqK: \"x1t137rt\",\n kORKVm: \"x1odjw0f\",\n $$css: true\n },\n months: {\n kGNEyG: \"x7a106z\",\n k1xSpc: \"x78zum5 x1yrkhk\",\n kOIVth: \"xj2l1yv\",\n kJBjZk: \"x12n7ir1\",\n kAzted: \"x1fivsg2\",\n $$css: true\n },\n root: {\n kWkggS: \"xvkjz1l\",\n kaIpWk: \"xhpdng0\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x139gbkf\",\n k1xSpc: \"x78zum5\",\n kXwgrk: \"xdt5ytf\",\n kOIVth: \"x1gka490\",\n kzqmXN: \"xeq5yr9\",\n k7Eaqz: \"x1gvwcb\",\n kmVPX3: \"xa36j16\",\n $$css: true\n }\n};\n\n// A date's hover and pressed layers, one pair per ground it sits on: nothing,\n// the range band, and the selected circle. From React Aria's render state rather than `:hover` and `:active`, for Button's\n// reasons — see its header: a hover layer stayed on after a tap, and no\n// pressed layer showed for a press made from the keyboard.\n// Each layer is written whole for its ground because StyleX replaces a\n// property whole, and the band and the circle keep their forced-colours\n// `Highlight` under the layer.\nconst dateLayers = {\n inRangeHovered: {\n kWkggS: \"x3zumxv x1jzqe4\",\n $$css: true\n },\n inRangePressed: {\n kWkggS: \"x1as5h4c x1jzqe4\",\n $$css: true\n },\n plainHovered: {\n kWkggS: \"x1b18xnh\",\n $$css: true\n },\n plainPressed: {\n kWkggS: \"xjeeohs\",\n $$css: true\n },\n selectedHovered: {\n kWkggS: \"xo1ct44 x1jzqe4\",\n $$css: true\n },\n selectedPressed: {\n kWkggS: \"x7b25lv x1jzqe4\",\n $$css: true\n }\n};\n\n// A list row's hover and pressed layers over the checked row's surface\n// variant. Over nothing a row takes a date's own pair, `dateLayers.plain*`,\n// since the page gives both the same on-surface layer.\nconst menuLayers = {\n selectedHovered: {\n kWkggS: \"xgw93rf\",\n $$css: true\n },\n selectedPressed: {\n kWkggS: \"x113d7pk\",\n $$css: true\n }\n};\nexport { calendarStyles, dateLayers, menuLayers };"],"mappings":";AA6CA,MAAMW,iBAAiB;CACrBC,MAAM;EACJC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;CACT;CACAC,cAAc;EACZhB,QAAQ;EACRI,QAAQ;EACRC,QAAQ;EACRY,QAAQ;EACRF,OAAO;CACT;CACAG,aAAa;EACXlB,QAAQ;EACRmB,QAAQ;EACRjB,QAAQ;EACRE,QAAQ;EACRa,QAAQ;EACRP,QAAQ;EACRI,QAAQ;EACRM,QAAQ;EACRL,OAAO;CACT;CACAM,cAAc;EACZC,QAAQ;EACRC,QAAQ;EACRR,OAAO;CACT;CACAS,gBAAgB;EACdC,QAAQ;EACRC,QAAQ;EACRX,OAAO;CACT;CACAY,cAAc;EACZ3B,QAAQ;EACRmB,QAAQ;EACRf,QAAQ;EACRa,QAAQ;EACRG,QAAQ;EACRL,OAAO;CACT;CACAa,WAAW;EACTT,QAAQ;EACRU,QAAQ;EACRC,QAAQ;EACR1B,QAAQ;EACRW,OAAO;CACT;CACAgB,iBAAiB;EACf/B,QAAQ;EACRK,QAAQ;EACRY,QAAQ;EACRe,QAAQ;EACRjB,OAA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CACT;AACF"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/** The page's small item: 40dp at the least and 56dp at the most. */
|
|
2
|
+
const SMALL_MAX = 56;
|
|
3
|
+
const SMALL_MIN = 40;
|
|
4
|
+
/**
|
|
5
|
+
* The sizes a layout draws its items at in a content box `room` wide, for
|
|
6
|
+
* `count` items and a preferred large width of `itemSize`.
|
|
7
|
+
*/
|
|
8
|
+
function arrange(layout, room, itemSize, count) {
|
|
9
|
+
if (layout === "uncontained") return {
|
|
10
|
+
large: Math.min(itemSize, room),
|
|
11
|
+
largeCount: 0,
|
|
12
|
+
medium: 0,
|
|
13
|
+
small: 0,
|
|
14
|
+
steps: 0
|
|
15
|
+
};
|
|
16
|
+
const small = room >= 184 ? SMALL_MAX : SMALL_MIN;
|
|
17
|
+
if (layout === "hero") return withSteps({
|
|
18
|
+
large: Math.max(room - 8 - small, small),
|
|
19
|
+
largeCount: 1,
|
|
20
|
+
medium: 0,
|
|
21
|
+
small
|
|
22
|
+
}, count);
|
|
23
|
+
const fit = Math.floor((room - small - 8) / (itemSize + 8));
|
|
24
|
+
const most = Math.max(1, Math.min(fit, count - 2));
|
|
25
|
+
for (let largeCount = most; largeCount >= 1; largeCount--) {
|
|
26
|
+
const gaps = (largeCount + 1) * 8;
|
|
27
|
+
const medium = room - largeCount * itemSize - gaps - small;
|
|
28
|
+
if (medium >= small && medium <= itemSize) return withSteps({
|
|
29
|
+
large: itemSize,
|
|
30
|
+
largeCount,
|
|
31
|
+
medium,
|
|
32
|
+
small
|
|
33
|
+
}, count);
|
|
34
|
+
const large = (room - gaps - 1.5 * small) / (largeCount + .5);
|
|
35
|
+
if (large >= small) return withSteps({
|
|
36
|
+
large,
|
|
37
|
+
largeCount,
|
|
38
|
+
medium: (large + small) / 2,
|
|
39
|
+
small
|
|
40
|
+
}, count);
|
|
41
|
+
}
|
|
42
|
+
return arrange("hero", room, itemSize, count);
|
|
43
|
+
}
|
|
44
|
+
function filledOf(sizes, count) {
|
|
45
|
+
return Math.min(count, sizes.largeCount + trailingOf(sizes).length);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Where every item is drawn with the carousel `position` rests along: a
|
|
49
|
+
* whole number at a rest, and the fraction between two while it moves.
|
|
50
|
+
* `room` is the content box's width and `padding` the space on each side of
|
|
51
|
+
* it, which an item past the edge is drawn beyond.
|
|
52
|
+
*/
|
|
53
|
+
function placements(layout, arrangement, room, padding, count, position) {
|
|
54
|
+
if (layout === "uncontained") return Array.from({ length: count }, (_, index) => ({
|
|
55
|
+
left: index * (arrangement.large + 8),
|
|
56
|
+
width: arrangement.large
|
|
57
|
+
}));
|
|
58
|
+
const clamped = Math.min(Math.max(position, 0), arrangement.steps);
|
|
59
|
+
const from = Math.floor(clamped);
|
|
60
|
+
const to = Math.min(from + 1, arrangement.steps);
|
|
61
|
+
const fraction = clamped - from;
|
|
62
|
+
const start = rest(arrangement, room, padding, count, from);
|
|
63
|
+
const end = rest(arrangement, room, padding, count, to);
|
|
64
|
+
return start.map((placement, index) => {
|
|
65
|
+
const next = end[index] ?? placement;
|
|
66
|
+
return {
|
|
67
|
+
left: placement.left + (next.left - placement.left) * fraction,
|
|
68
|
+
width: placement.width + (next.width - placement.width) * fraction
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function rest(arrangement, room, padding, count, step) {
|
|
73
|
+
const { large, largeCount, small } = arrangement;
|
|
74
|
+
const filled = filledOf(arrangement, count);
|
|
75
|
+
const trailing = trailingOf(arrangement).slice(0, filled - largeCount);
|
|
76
|
+
const last = count - filled;
|
|
77
|
+
const turned = Math.max(0, step - last);
|
|
78
|
+
const kept = trailing.length - turned;
|
|
79
|
+
const sizes = [
|
|
80
|
+
...Array.from({ length: turned }, (_, slot) => trailing[trailing.length - 1 - slot] ?? small),
|
|
81
|
+
...Array.from({ length: Math.min(largeCount, filled) }, () => large),
|
|
82
|
+
...trailing.slice(0, kept)
|
|
83
|
+
];
|
|
84
|
+
const first = Math.min(step, last);
|
|
85
|
+
const lefts = [];
|
|
86
|
+
let cursor = 0;
|
|
87
|
+
for (const size of sizes) {
|
|
88
|
+
lefts.push(cursor);
|
|
89
|
+
cursor += size + 8;
|
|
90
|
+
}
|
|
91
|
+
const shift = turned > 0 ? room - (cursor - 8) : 0;
|
|
92
|
+
const away = small > 0 ? small : large;
|
|
93
|
+
return Array.from({ length: count }, (_, index) => {
|
|
94
|
+
const slot = index - first;
|
|
95
|
+
if (slot < 0) return {
|
|
96
|
+
left: -padding + slot * (away + 8),
|
|
97
|
+
width: away
|
|
98
|
+
};
|
|
99
|
+
if (slot >= sizes.length) return {
|
|
100
|
+
left: room + padding + 8 + (slot - sizes.length) * (away + 8),
|
|
101
|
+
width: away
|
|
102
|
+
};
|
|
103
|
+
return {
|
|
104
|
+
left: (lefts[slot] ?? 0) + shift,
|
|
105
|
+
width: sizes[slot] ?? away
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function trailingOf({ medium, small }) {
|
|
110
|
+
return [medium, small].filter((size) => size > 0);
|
|
111
|
+
}
|
|
112
|
+
function withSteps(sizes, count) {
|
|
113
|
+
const filled = filledOf(sizes, count);
|
|
114
|
+
const turning = Math.max(0, filled - sizes.largeCount);
|
|
115
|
+
return {
|
|
116
|
+
...sizes,
|
|
117
|
+
steps: count - filled + turning
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
export { arrange, placements };
|
|
122
|
+
|
|
123
|
+
//# sourceMappingURL=arrangement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrangement.js","names":["CarouselLayout","GAP","SMALL_MAX","SMALL_MIN","Arrangement","large","largeCount","medium","small","steps","Placement","left","width","arrange","layout","room","itemSize","count","Math","min","max","withSteps","fit","floor","most","gaps","sizes","filledOf","Omit","trailingOf","length","placements","arrangement","padding","position","Array","from","_","index","clamped","to","fraction","start","rest","end","map","placement","next","step","filled","trailing","slice","last","turned","kept","slot","first","lefts","cursor","size","push","shift","away","filter","turning"],"sources":["../../src/carousel/arrangement.ts"],"sourcesContent":["// The carousel page's layouts as numbers: which items are large, medium and\n// small at each place a carousel comes to rest, and where each is drawn as\n// it moves between two of them. Apart from the component so the arithmetic\n// can be tested without a browser laying anything out, and so the\n// component's file holds what it renders.\n//\n// The model is MDC-Android's keylines, simplified to what the page draws.\n// At rest a multi-browse carousel shows `largeCount` large items, one medium\n// and one small, filling the room exactly; a hero carousel one large and one\n// small. Each rest is one item further along than the last, and once the\n// last item has come into view the rests that remain turn the arrangement\n// round a slot at a time — small, the large ones, medium; then small,\n// medium, the large ones — so every item is drawn large at one rest at\n// least. At rest `s` the large items are always `s` to `s + largeCount - 1`.\n// Between two rests every item's place and width are interpolated, which is\n// what makes an item grow or shrink as it moves rather than jump. Items past\n// either edge are drawn small and out of sight, so they arrive at the size\n// of the slot they enter.\n//\n// Everything is in pixels along the inline axis of the carousel's content\n// box: 0 is its start edge, inside the leading padding.\n\ntype CarouselLayout = 'hero' | 'multi-browse' | 'uncontained'\n\n/** The page's 8dp between items. */\nconst GAP = 8\n\n/** The page's small item: 40dp at the least and 56dp at the most. */\nconst SMALL_MAX = 56\nconst SMALL_MIN = 40\n\ntype Arrangement = {\n /** The large item's width, which every item is laid out at. */\n large: number\n /** How many items are large at rest. */\n largeCount: number\n /** The medium item's width, or 0 for a layout without one. */\n medium: number\n /** The small item's width, or 0 for a layout without one. */\n small: number\n /** The last place the carousel comes to rest, counting from 0. */\n steps: number\n}\n\n/** Where an item is drawn: the start of what shows of it, and its width. */\ntype Placement = { left: number; width: number }\n\n/**\n * The sizes a layout draws its items at in a content box `room` wide, for\n * `count` items and a preferred large width of `itemSize`.\n */\nfunction arrange(\n layout: CarouselLayout,\n room: number,\n itemSize: number,\n count: number,\n): Arrangement {\n if (layout === 'uncontained') {\n const large = Math.min(itemSize, room)\n return { large, largeCount: 0, medium: 0, small: 0, steps: 0 }\n }\n\n // The small item at its largest unless the room is too narrow for it.\n const small = room >= 3 * SMALL_MAX + 2 * GAP ? SMALL_MAX : SMALL_MIN\n\n if (layout === 'hero') {\n const large = Math.max(room - GAP - small, small)\n return withSteps({ large, largeCount: 1, medium: 0, small }, count)\n }\n\n // As many items at the preferred width as fit beside a medium and a small\n // one, and no more than leave a medium and a small item to fill those two\n // slots, so a short run of items still fills the room rather than leaving\n // its last slots empty. Where what is left for the medium item is not\n // between the small and the large width, the large width gives way, to\n // whatever leaves the medium item halfway between the two.\n const fit = Math.floor((room - small - GAP) / (itemSize + GAP))\n const most = Math.max(1, Math.min(fit, count - 2))\n for (let largeCount = most; largeCount >= 1; largeCount--) {\n const gaps = (largeCount + 1) * GAP\n const medium = room - largeCount * itemSize - gaps - small\n if (medium >= small && medium <= itemSize) {\n return withSteps({ large: itemSize, largeCount, medium, small }, count)\n }\n const large = (room - gaps - 1.5 * small) / (largeCount + 0.5)\n if (large >= small) {\n const sizes = { large, largeCount, medium: (large + small) / 2, small }\n return withSteps(sizes, count)\n }\n }\n // Too narrow for three: one large item and one small, as a hero draws.\n return arrange('hero', room, itemSize, count)\n}\n\n// How many of the slots are filled: all of them, unless there are fewer\n// items, which leaves the last slots empty.\nfunction filledOf(sizes: Omit<Arrangement, 'steps'>, count: number) {\n return Math.min(count, sizes.largeCount + trailingOf(sizes).length)\n}\n\n/**\n * Where every item is drawn with the carousel `position` rests along: a\n * whole number at a rest, and the fraction between two while it moves.\n * `room` is the content box's width and `padding` the space on each side of\n * it, which an item past the edge is drawn beyond.\n */\nfunction placements(\n layout: CarouselLayout,\n arrangement: Arrangement,\n room: number,\n padding: number,\n count: number,\n position: number,\n): Placement[] {\n if (layout === 'uncontained') {\n return Array.from({ length: count }, (_, index) => ({\n left: index * (arrangement.large + GAP),\n width: arrangement.large,\n }))\n }\n\n const clamped = Math.min(Math.max(position, 0), arrangement.steps)\n const from = Math.floor(clamped)\n const to = Math.min(from + 1, arrangement.steps)\n const fraction = clamped - from\n const start = rest(arrangement, room, padding, count, from)\n const end = rest(arrangement, room, padding, count, to)\n\n return start.map((placement, index) => {\n const next = end[index] ?? placement\n return {\n left: placement.left + (next.left - placement.left) * fraction,\n width: placement.width + (next.width - placement.width) * fraction,\n }\n })\n}\n\n// Where every item is drawn at one rest.\nfunction rest(\n arrangement: Arrangement,\n room: number,\n padding: number,\n count: number,\n step: number,\n) {\n const { large, largeCount, small } = arrangement\n const filled = filledOf(arrangement, count)\n const trailing = trailingOf(arrangement).slice(0, filled - largeCount)\n // The last rest drawn from the start; past it, how many trailing slots\n // have turned round to the front, the last of them first.\n const last = count - filled\n const turned = Math.max(0, step - last)\n const kept = trailing.length - turned\n const sizes = [\n ...Array.from(\n { length: turned },\n (_, slot) => trailing[trailing.length - 1 - slot] ?? small,\n ),\n ...Array.from({ length: Math.min(largeCount, filled) }, () => large),\n ...trailing.slice(0, kept),\n ]\n // The item in the first slot. Once the arrangement turns, the slots hold\n // the last items, whichever way round they are drawn.\n const first = Math.min(step, last)\n\n // The slots, laid out from the start edge.\n const lefts: number[] = []\n let cursor = 0\n for (const size of sizes) {\n lefts.push(cursor)\n cursor += size + GAP\n }\n // A turned arrangement that does not fill the room is set against the end\n // edge instead, which is where its large items belong.\n const shift = turned > 0 ? room - (cursor - GAP) : 0\n const away = small > 0 ? small : large\n\n return Array.from({ length: count }, (_, index): Placement => {\n const slot = index - first\n if (slot < 0) {\n // Past the start edge, beyond the padding, a small item per place.\n return { left: -padding + slot * (away + GAP), width: away }\n }\n if (slot >= sizes.length) {\n // Past the end edge, likewise.\n return {\n left: room + padding + GAP + (slot - sizes.length) * (away + GAP),\n width: away,\n }\n }\n return { left: (lefts[slot] ?? 0) + shift, width: sizes[slot] ?? away }\n })\n}\n\n// The widths that follow the large ones at rest: medium then small, or the\n// small alone for a hero.\nfunction trailingOf({ medium, small }: Omit<Arrangement, 'steps'>) {\n return [medium, small].filter((size) => size > 0)\n}\n\n// A rest starts at each item while every slot after it is filled, and each\n// trailing slot turning round to the front is one rest more.\nfunction withSteps(\n sizes: Omit<Arrangement, 'steps'>,\n count: number,\n): Arrangement {\n const filled = filledOf(sizes, count)\n const turning = Math.max(0, filled - sizes.largeCount)\n return { ...sizes, steps: count - filled + turning }\n}\n\nexport type { Arrangement, CarouselLayout, Placement }\n\nexport { arrange, GAP, placements }\n"],"mappings":";AA4BA,MAAME,YAAY;AAClB,MAAMC,YAAY;;;;;AAsBlB,SAASU,QACPC,QACAC,MACAC,UACAC,OACa;CACb,IAAIH,WAAW,eAEb,OAAO;EAAET,OADKa,KAAKC,IAAIH,UAAUD,IACxBV;EAAOC,YAAY;EAAGC,QAAQ;EAAGC,OAAO;EAAGC,OAAO;CAAE;CAI/D,MAAMD,QAAQO,QAAQ,MAA0Bb,YAAYC;CAE5D,IAAIW,WAAW,QAEb,OAAOO,UAAU;EAAEhB,OADLa,KAAKE,IAAIL,OAAAA,IAAaP,OAAOA,KACxBH;EAAOC,YAAY;EAAGC,QAAQ;EAAGC;CAAM,GAAGS,KAAK;CASpE,MAAMK,MAAMJ,KAAKK,OAAOR,OAAOP,QAAAA,MAAgBQ,WAAAA,EAAe;CAC9D,MAAMQ,OAAON,KAAKE,IAAI,GAAGF,KAAKC,IAAIG,KAAKL,QAAQ,CAAC,CAAC;CACjD,KAAK,IAAIX,aAAakB,MAAMlB,cAAc,GAAGA,cAAc;EACzD,MAAMmB,QAAQnB,aAAa,KAAA;EAC3B,MAAMC,SAASQ,OAAOT,aAAaU,WAAWS,OAAOjB;EACrD,IAAID,UAAUC,SAASD,UAAUS,UAC/B,OAAOK,UAAU;GAAEhB,OAAOW;GAAUV;GAAYC;GAAQC;EAAM,GAAGS,KAAK;EAExE,MAAMZ,SAASU,OAAOU,OAAO,MAAMjB,UAAUF,aAAa;EAC1D,IAAID,SAASG,OAEX,OAAOa,UAAUK;GADDrB;GAAOC;GAAYC,SAASF,QAAQG,SAAS;GAAGA;EAC/CkB,GAAOT,KAAK;CAEjC;CAEA,OAAOJ,QAAQ,QAAQE,MAAMC,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ACb,MAAMgC,SAAStB,SAASD,OAAOT,KAAK;CACpC,MAAM+C,UAAU9C,KAAKE,IAAI,GAAG6B,SAASvB,MAAMpB,UAAU;CACrD,OAAO;EAAE,GAAGoB;EAAOjB,OAAOQ,QAAQgC,SAASe;CAAQ;AACrD"}
|
package/dist/collection/index.js
CHANGED
|
@@ -11,18 +11,18 @@ import { jsx } from "react/jsx-runtime";
|
|
|
11
11
|
*/
|
|
12
12
|
function CollectionLoadMore(t0) {
|
|
13
13
|
const $ = c(3);
|
|
14
|
-
const {
|
|
14
|
+
const { diameter, label } = t0;
|
|
15
15
|
const messages = useMessages();
|
|
16
16
|
const t1 = label ?? messages.loadingMore;
|
|
17
17
|
let t2;
|
|
18
|
-
if ($[0] !==
|
|
18
|
+
if ($[0] !== diameter || $[1] !== t1) {
|
|
19
19
|
t2 = /* @__PURE__ */ jsx(ProgressIndicator, {
|
|
20
20
|
"aria-label": t1,
|
|
21
|
+
diameter,
|
|
21
22
|
isIndeterminate: true,
|
|
22
|
-
size,
|
|
23
23
|
variant: "circular"
|
|
24
24
|
});
|
|
25
|
-
$[0] =
|
|
25
|
+
$[0] = diameter;
|
|
26
26
|
$[1] = t1;
|
|
27
27
|
$[2] = t2;
|
|
28
28
|
} else t2 = $[2];
|