@kanso-labs/kanso-ui 0.47.4 → 0.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/button/hooks.js +35 -1
- package/dist/button/hooks.js.map +1 -1
- package/dist/button/index.js +78 -65
- package/dist/button/index.js.map +1 -1
- package/dist/calendar/styles.js +5 -5
- package/dist/calendar/styles.js.map +1 -1
- package/dist/chip/styles.js +1 -1
- package/dist/chip/styles.js.map +1 -1
- package/dist/collection/context.js +6 -0
- package/dist/collection/context.js.map +1 -0
- package/dist/collection/styles.js +29 -6
- package/dist/collection/styles.js.map +1 -1
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/calendar/index.js +7 -0
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/checkbox/index.js +10 -7
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/checkbox-group/index.js +2 -1
- package/dist/components/checkbox-group/index.js.map +1 -1
- package/dist/components/chip-group/index.js +69 -66
- package/dist/components/chip-group/index.js.map +1 -1
- package/dist/components/color-swatch-picker/index.js +1 -0
- package/dist/components/color-swatch-picker/index.js.map +1 -1
- package/dist/components/combo-box/index.js +5 -1
- package/dist/components/combo-box/index.js.map +1 -1
- package/dist/components/drop-zone/styles.js +11 -11
- package/dist/components/drop-zone/styles.js.map +1 -1
- package/dist/components/fab-menu/index.js +3 -3
- package/dist/components/fab-menu/index.js.map +1 -1
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/list/index.js +58 -11
- package/dist/components/list/index.js.map +1 -1
- package/dist/components/list-box/index.js +82 -103
- package/dist/components/list-box/index.js.map +1 -1
- package/dist/components/navigation-rail/index.js +4 -4
- package/dist/components/navigation-rail/index.js.map +1 -1
- package/dist/components/number-field/index.js +3 -3
- package/dist/components/number-field/index.js.map +1 -1
- package/dist/components/popover/index.js +3 -3
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/radio-group/index.js +12 -11
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/search-field/index.js +4 -4
- package/dist/components/search-field/index.js.map +1 -1
- package/dist/components/select/index.js +5 -1
- package/dist/components/select/index.js.map +1 -1
- package/dist/components/sheet/index.js +1 -1
- package/dist/components/sheet/index.js.map +1 -1
- package/dist/components/slider/index.js +2 -2
- package/dist/components/slider/index.js.map +1 -1
- package/dist/components/snackbar/index.js +3 -3
- package/dist/components/snackbar/index.js.map +1 -1
- package/dist/components/split-button/index.js +53 -41
- package/dist/components/split-button/index.js.map +1 -1
- package/dist/components/table/index.js +58 -45
- package/dist/components/table/index.js.map +1 -1
- package/dist/components/tabs/index.js +81 -30
- package/dist/components/tabs/index.js.map +1 -1
- package/dist/components/time-picker/index.js +5 -5
- package/dist/components/time-picker/index.js.map +1 -1
- package/dist/components/tree/index.js +78 -21
- package/dist/components/tree/index.js.map +1 -1
- package/dist/field/index.js +103 -104
- package/dist/field/index.js.map +1 -1
- package/dist/field/styles.js +1 -1
- package/dist/field/styles.js.map +1 -1
- package/dist/hooks/useScrollEdges.js +73 -0
- package/dist/hooks/useScrollEdges.js.map +1 -0
- package/dist/navigation/styles.js +5 -5
- package/dist/navigation/styles.js.map +1 -1
- package/dist/row/styles.js +7 -7
- package/dist/row/styles.js.map +1 -1
- package/dist/styles/color.js +16 -16
- package/dist/styles/color.js.map +1 -1
- package/dist/styles/focus.js +4 -4
- package/dist/styles/focus.js.map +1 -1
- package/dist/styles/overlay.js +3 -3
- package/dist/styles/overlay.js.map +1 -1
- package/dist/styles/scroll-fade.js +33 -0
- package/dist/styles/scroll-fade.js.map +1 -0
- package/dist/styles.css +61 -20
- package/package.json +9 -9
package/dist/chip/styles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","names":["chipStyles","assist","kMwMTN","$$css","base","k6CgDc","kGNEyG","kZKoxP","kaIpWk","ksu8eU","kMzoRj","kB7OPa","kkrTdU","k1xSpc","kmuXW","kMv6JI","kGuDYH","k63SB2","kOIVth","kb6lSQ","kLWn49","ks0D6T","k8WAf4","kg3NbH","kIyJzY","k1ekBW","kAMwcw","disabled","disabledSelected","kWkggS","disabledUnselected","kVAM5u","elevated","elevatedDisabled","kGVxlE","glyph","kzqmXN","kjj79g","keTefX","glyphFolded","k71WvV","kSiTet","glyphOpening","kVQacm","glyphSvg","icon","inert","label","kVAEAm","kg5iWk","kQ0QjF","khDVqt","raised","raisedHovered","remove","kgeoSG","kFcpXp","kEoFBp","kjBf7l","kInvED","k3XXqK","kMeerF","kmVPX3","removeDisabled","removeGlyph","selected","selectedHovered","surfaceCorners","target","kGOzcv","kpsdNU","trailing","unselected","chipLayers","elevatedFocused","elevatedHovered","elevatedPressed","removeHovered","removePressed","selectedFocused","selectedPressed","unselectedFocused","unselectedHovered","unselectedPressed"],"sources":["../../src/chip/styles.ts"],"sourcesContent":["import * as stylex from '@stylexjs/stylex';\nimport '../tokens/design.tokens.stylex';\nimport { colors, motion, radii, shadows, sizing, spacing, stateLayerOpacity, typography } from '../tokens/design.tokens.stylex';\n\n// The pill the chips page draws, shared by the three components that draw\n// one: Chip, which is a toggle on its own or one of the page's two action\n// chips; ChipGroup's chip, which is one of a set that can also be removed;\n// and TokenField's token, which takes `base` and `unselected` alone — a token\n// is not selectable, so it reaches for neither the selected container nor\n// the check below. The measurements and roles are the page's filter chip — a\n// 32dp container with an 8dp corner and 16dp of inline padding, an outline\n// variant border while unselected, the secondary container pair once\n// selected.\n//\n// The assist and suggestion chips are that unselected pill, never selected.\n// The page's only difference between them is the label: on surface on an\n// assist chip, on surface variant on a suggestion chip as on a filter one.\n//\n// **An elevated chip trades the outline for a container**, surface container\n// low at the page's elevation 1, raised to 2 under a hovering pointer and\n// back to 1 while pressed, since a mouse press does not end the hover. A\n// selected one keeps the secondary container and takes the shadow with it.\n// Its 1px border stays, transparent, as every chip's does: a forced-colours\n// mode paints a transparent border in its text colour and drops the shadow\n// and the fill, so the border is the boundary left there.\n//\n// **A flat chip lies on the page, apart from one state.** A selected filter\n// chip under a hovering pointer rises to elevation 1, and comes back down\n// while pressed, as the page's filter chip tokens give it; every other flat\n// state, and every state of an input chip, stays at 0.\n//\n// **A disabled chip is translucent**, its content at 38% and its container at\n// 12% of on surface over whatever is behind it, as the page gives them,\n// rather than mixed into the surface. Mixed into the surface, a disabled chip\n// on a coloured container drew an opaque pale patch with grey text on it.\n//\n// **A label with no room on one line is cut short, never wrapped.** The\n// container is a fixed 32dp, so a second line has nowhere to go but out of\n// the pill: a chip or a token in a room narrower than its label drew the\n// rest below its own edge, and a chip in a group's row ran past the row's\n// end instead. The pill is held to the room it is in, and the label sits in\n// a span of its own that ends in an ellipsis where the pill does — a span,\n// because a flex container ignores `text-overflow`, which is also why\n// Material's own chips carry one. The whole label stays in the DOM, so a\n// screen reader still reads all of it.\n//\n// Each state composites an on-colour over its own container at the\n// interaction state's opacity rather than swapping in a separate hover\n// colour. `calc(<opacity> * 100%)` turns the token's unitless 0-1 ratio into\n// the percentage `color-mix()` takes, and it is inlined at each property\n// because @stylexjs/babel-plugin only statically recognises expressions\n// written directly as property values.\n//\n// The selected chip drops its border rather than recolouring it: it has a\n// container of its own to define its edge, and a border on top of that reads\n// as a second, competing outline.\n//\n// Disabled is applied from render state rather than from `:disabled`. Chip is\n// a button and would match the pseudo-class; a chip in a group is React\n// Aria's `Tag`, which is a div and never will. One mechanism serves both, and\n// StyleX replaces a property whole, so the disabled styles take the hover and\n// pressed branches of whichever state they are applied over.\n//\n// A selected chip carries the page's check before its label, which is what\n// makes the selection legible without colour. The two containers differ in\n// colour alone, and under a scheme whose secondary container sits close to\n// the surface — or for a reader who does not see colour — that is no\n// difference at all.\n//\n// The chip widens when the check appears, and that is the page's behaviour\n// rather than a cost of drawing it: a chip is flow content, laid out in a\n// row that wraps, so nothing around it has a width to hold. A segmented\n// button's segments are equal columns of one track, which is a different\n// geometry answering a different question, and the two should not be read\n// across. A chip given an icon does not widen, since the check takes the\n// icon's place in the same slot.\n//\n// **A filter chip can carry an icon after its label as well**, the page's\n// trailing icon, which is what draws its dropdown filter chip: an arrow\n// saying the chip opens a menu. It takes the same 18dp slot at the other\n// end, and the chip's content role rather than the primary one the leading\n// icon takes — on surface variant, then on secondary container once\n// selected, then the disabled 38% — so it is drawn in the chip's own colour\n// rather than a role of its own. The check never displaces it.\n//\n// **The widening is animated rather than taken in one frame.** A chip with\n// no icon keeps its slot mounted while unselected, folded to nothing, and\n// selecting it opens the slot over the chip's own short duration while the\n// check fades in, so the chips after it in a wrapped row glide rather than\n// jump 18dp. Reduced motion takes the change at once, as it does the\n// colours. A chip that can never be selected, an assist or suggestion chip\n// or one in a group that does not select, has no slot to open.\n//\n// **The press ripple takes the chip's corner from here** wherever the chip\n// is a ChipGroup's. The ripple clips itself to its host's corner by\n// inheriting it, and React Aria puts a cell between a group's chip and its\n// content, so what the ripple would inherit is the cell's square corner.\n// `surfaceCorners` restates the chip's own corner on a box the ripple sits\n// in, less the 1px border every chip keeps, since the ripple fills the\n// inside of that border.\n//\n// Apart from any component so a chip in a group and a chip on its own cannot\n// drift; see `src/row` for the same arrangement around a list's row.\n\n// The press area the chips page requires around its 32dp chip. A literal for\n// the reason IconButton's `TARGET_SIZE` gives.\nconst TARGET_SIZE = '48px';\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 chipStyles = {\n assist: {\n kMwMTN: \"x139gbkf\",\n $$css: true\n },\n base: {\n k6CgDc: \"x12w9bfk\",\n kGNEyG: \"x6s0dn4\",\n kZKoxP: \"xig8zya\",\n kaIpWk: \"x1xdvaa9\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xmkeg23\",\n kB7OPa: \"x9f619\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n kmuXW: \"x2lah0s\",\n kMv6JI: \"xkknnkr\",\n kGuDYH: \"x14zspaw\",\n k63SB2: \"x1v9cpvo\",\n kOIVth: \"x126z3so\",\n kb6lSQ: \"x155f00i\",\n kLWn49: \"x1lz68p4\",\n ks0D6T: \"x193iq5w\",\n k8WAf4: \"xt970qd\",\n kg3NbH: \"x790zyz\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"xu8237s\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n disabled: {\n kMwMTN: \"x1gpw424 x1bhcspo\",\n kkrTdU: \"x1h6gzvc\",\n $$css: true\n },\n disabledSelected: {\n kWkggS: \"x19v6zzp\",\n $$css: true\n },\n disabledUnselected: {\n kWkggS: \"xjbqb8w\",\n kVAM5u: \"xrh88j3 xmnqt3w\",\n $$css: true\n },\n elevated: {\n kWkggS: \"x1vnz5z6\",\n kVAM5u: \"x9r1u3d\",\n $$css: true\n },\n elevatedDisabled: {\n kWkggS: \"x19v6zzp\",\n kVAM5u: \"x9r1u3d\",\n kGVxlE: \"x1gnnqk1\",\n $$css: true\n },\n glyph: {\n kGNEyG: \"x6s0dn4\",\n kZKoxP: \"xmix8c7\",\n k1xSpc: \"x3nfvp2\",\n kmuXW: \"x2lah0s\",\n kGuDYH: \"xosj86m\",\n kzqmXN: \"x1xp8n7a\",\n kjj79g: \"xl56j7k\",\n keTefX: \"xxuhe3a\",\n $$css: true\n },\n glyphFolded: {\n kzqmXN: \"xnalus7\",\n k71WvV: \"x1kfc2zf\",\n keTefX: \"x1lziwak\",\n kSiTet: \"xg01cxk\",\n $$css: true\n },\n glyphOpening: {\n k6CgDc: \"x12w9bfk\",\n kVQacm: \"xb3r6kr\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"x17vvy08\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n glyphSvg: {\n kZKoxP: \"xmix8c7\",\n kmuXW: \"x2lah0s\",\n kzqmXN: \"x1xp8n7a\",\n $$css: true\n },\n icon: {\n kMwMTN: \"x1mxwv8y\",\n $$css: true\n },\n inert: {\n kkrTdU: \"xt0e3qv\",\n $$css: true\n },\n label: {\n kB7OPa: \"x9f619\",\n kVQacm: \"xb3r6kr\",\n kVAEAm: \"x1n2onr6\",\n kg5iWk: \"xlyipyv\",\n kQ0QjF: \"x4ej8vm\",\n khDVqt: \"xuxw1ft\",\n $$css: true\n },\n raised: {\n kGVxlE: \"x19efjv6\",\n $$css: true\n },\n raisedHovered: {\n kGVxlE: \"x1os83gw\",\n $$css: true\n },\n remove: {\n kgeoSG: \"x1cpjm7i\",\n kFcpXp: \"xtu493u\",\n kEoFBp: \"x1hmns74\",\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"xmix8c7\",\n kaIpWk: \"x1dkaolv\",\n kMzoRj: \"xc342km\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x1heor9g\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n kmuXW: \"x2lah0s\",\n kzqmXN: \"x1xp8n7a\",\n kjj79g: \"xl56j7k\",\n k71WvV: \"x1kfc2zf\",\n kjBf7l: \"x14ytart\",\n kInvED: \"x1y3gkto\",\n k3XXqK: \"x9v5kkp x1t137rt\",\n kMeerF: \"x1de99jn\",\n kmVPX3: \"x1717udv\",\n kVAEAm: \"x1n2onr6\",\n $$css: true\n },\n removeDisabled: {\n kkrTdU: \"x1h6gzvc\",\n $$css: true\n },\n removeGlyph: {\n kZKoxP: \"xmix8c7\",\n kzqmXN: \"x1xp8n7a\",\n $$css: true\n },\n selected: {\n kWkggS: \"x15dekr4\",\n kVAM5u: \"x9r1u3d\",\n kMwMTN: \"x1sawysd\",\n $$css: true\n },\n selectedHovered: {\n kGVxlE: \"x19efjv6\",\n $$css: true\n },\n surfaceCorners: {\n kaIpWk: \"x5a2xki\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"xjp7ctv\",\n $$css: true\n },\n target: {\n kgeoSG: \"x1cpjm7i\",\n kGOzcv: \"x1xkszu9\",\n kpsdNU: \"x1ecwmwu\",\n kEoFBp: \"x1hmns74\",\n kVAEAm: \"x1n2onr6\",\n $$css: true\n },\n trailing: {\n k71WvV: \"x1kfc2zf\",\n keTefX: \"x1lziwak\",\n $$css: true\n },\n unselected: {\n kWkggS: \"xjbqb8w\",\n kVAM5u: \"x133yhug\",\n kMwMTN: \"x1w5n3ug\",\n $$css: true\n }\n};\n\n// The hover and pressed layers, applied from React Aria's render state rather\n// than from `:hover` and `:active`, for Button's reasons — see its header: a\n// hover layer stayed on after a tap, and no pressed layer showed for a press\n// made from the keyboard. One pair per container, the pressed after the\n// hovered so a press wins, and one for the close target, whose own render\n// state is its button's. A token in a TokenField draws none of them: React\n// Aria reports neither state for one, since it is text the caret moves\n// through rather than a control a press acts on.\nconst chipLayers = {\n elevatedFocused: {\n kWkggS: \"x1drsm1c\",\n $$css: true\n },\n elevatedHovered: {\n kWkggS: \"x1ei6177\",\n $$css: true\n },\n elevatedPressed: {\n kWkggS: \"x1vt8e7r\",\n $$css: true\n },\n removeHovered: {\n kWkggS: \"x930l3l\",\n $$css: true\n },\n removePressed: {\n kWkggS: \"xsykwg8\",\n $$css: true\n },\n selectedFocused: {\n kWkggS: \"x1s5x49g\",\n $$css: true\n },\n selectedHovered: {\n kWkggS: \"x1fctxn6\",\n $$css: true\n },\n selectedPressed: {\n kWkggS: \"xzpauq9\",\n $$css: true\n },\n unselectedFocused: {\n kWkggS: \"xwqhyid\",\n $$css: true\n },\n unselectedHovered: {\n kWkggS: \"x1b18xnh\",\n $$css: true\n },\n unselectedPressed: {\n kWkggS: \"xjeeohs\",\n $$css: true\n }\n};\nexport { chipLayers, chipStyles };"],"mappings":";AAiHA,MAAMA,aAAa;CACjBC,QAAQ;EACNC,QAAQ;EACRC,OAAO;CACT;CACAC,MAAM;EACJC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;EACPC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B,OAAO;CACT;CACA+E,mBAAmB;EACjBrD,QAAQ;EACR1B,OAAO;CACT;CACAgF,mBAAmB;EACjBtD,QAAQ;EACR1B,OAAO;CACT;AACF"}
|
|
1
|
+
{"version":3,"file":"styles.js","names":["chipStyles","assist","kMwMTN","$$css","base","k6CgDc","kGNEyG","kZKoxP","kaIpWk","ksu8eU","kMzoRj","kB7OPa","kkrTdU","k1xSpc","kmuXW","kMv6JI","kGuDYH","k63SB2","kOIVth","kb6lSQ","kLWn49","ks0D6T","k8WAf4","kg3NbH","kIyJzY","k1ekBW","kAMwcw","disabled","disabledSelected","kWkggS","disabledUnselected","kVAM5u","elevated","elevatedDisabled","kGVxlE","glyph","kzqmXN","kjj79g","keTefX","glyphFolded","k71WvV","kSiTet","glyphOpening","kVQacm","glyphSvg","icon","inert","label","kVAEAm","kg5iWk","kQ0QjF","khDVqt","raised","raisedHovered","remove","kgeoSG","kFcpXp","kEoFBp","kjBf7l","kInvED","k3XXqK","kMeerF","kmVPX3","removeDisabled","removeGlyph","selected","selectedHovered","surfaceCorners","target","kGOzcv","kpsdNU","trailing","unselected","chipLayers","elevatedFocused","elevatedHovered","elevatedPressed","removeHovered","removePressed","selectedFocused","selectedPressed","unselectedFocused","unselectedHovered","unselectedPressed"],"sources":["../../src/chip/styles.ts"],"sourcesContent":["import * as stylex from '@stylexjs/stylex';\nimport '../tokens/design.tokens.stylex';\nimport { colors, motion, radii, shadows, sizing, spacing, stateLayerOpacity, typography } from '../tokens/design.tokens.stylex';\n\n// The pill the chips page draws, shared by the three components that draw\n// one: Chip, which is a toggle on its own or one of the page's two action\n// chips; ChipGroup's chip, which is one of a set that can also be removed;\n// and TokenField's token, which takes `base` and `unselected` alone — a token\n// is not selectable, so it reaches for neither the selected container nor\n// the check below. The measurements and roles are the page's filter chip — a\n// 32dp container with an 8dp corner and 16dp of inline padding, an outline\n// variant border while unselected, the secondary container pair once\n// selected.\n//\n// The assist and suggestion chips are that unselected pill, never selected.\n// The page's only difference between them is the label: on surface on an\n// assist chip, on surface variant on a suggestion chip as on a filter one.\n//\n// **An elevated chip trades the outline for a container**, surface container\n// low at the page's elevation 1, raised to 2 under a hovering pointer and\n// back to 1 while pressed, since a mouse press does not end the hover. A\n// selected one keeps the secondary container and takes the shadow with it.\n// Its 1px border stays, transparent, as every chip's does: a forced-colours\n// mode paints a transparent border in its text colour and drops the shadow\n// and the fill, so the border is the boundary left there.\n//\n// **A flat chip lies on the page, apart from one state.** A selected filter\n// chip under a hovering pointer rises to elevation 1, and comes back down\n// while pressed, as the page's filter chip tokens give it; every other flat\n// state, and every state of an input chip, stays at 0.\n//\n// **A disabled chip is translucent**, its content at 38% and its container at\n// 12% of on surface over whatever is behind it, as the page gives them,\n// rather than mixed into the surface. Mixed into the surface, a disabled chip\n// on a coloured container drew an opaque pale patch with grey text on it.\n//\n// **A label with no room on one line is cut short, never wrapped.** The\n// container is a fixed 32dp, so a second line has nowhere to go but out of\n// the pill: a chip or a token in a room narrower than its label drew the\n// rest below its own edge, and a chip in a group's row ran past the row's\n// end instead. The pill is held to the room it is in, and the label sits in\n// a span of its own that ends in an ellipsis where the pill does — a span,\n// because a flex container ignores `text-overflow`, which is also why\n// Material's own chips carry one. The whole label stays in the DOM, so a\n// screen reader still reads all of it.\n//\n// Each state composites an on-colour over its own container at the\n// interaction state's opacity rather than swapping in a separate hover\n// colour. `calc(<opacity> * 100%)` turns the token's unitless 0-1 ratio into\n// the percentage `color-mix()` takes, and it is inlined at each property\n// because @stylexjs/babel-plugin only statically recognises expressions\n// written directly as property values.\n//\n// The selected chip drops its border rather than recolouring it: it has a\n// container of its own to define its edge, and a border on top of that reads\n// as a second, competing outline.\n//\n// Disabled is applied from render state rather than from `:disabled`. Chip is\n// a button and would match the pseudo-class; a chip in a group is React\n// Aria's `Tag`, which is a div and never will. One mechanism serves both, and\n// StyleX replaces a property whole, so the disabled styles take the hover and\n// pressed branches of whichever state they are applied over.\n//\n// A selected chip carries the page's check before its label, which is what\n// makes the selection legible without colour. The two containers differ in\n// colour alone, and under a scheme whose secondary container sits close to\n// the surface — or for a reader who does not see colour — that is no\n// difference at all.\n//\n// The chip widens when the check appears, and that is the page's behaviour\n// rather than a cost of drawing it: a chip is flow content, laid out in a\n// row that wraps, so nothing around it has a width to hold. A segmented\n// button's segments are equal columns of one track, which is a different\n// geometry answering a different question, and the two should not be read\n// across. A chip given an icon does not widen, since the check takes the\n// icon's place in the same slot.\n//\n// **A filter chip can carry an icon after its label as well**, the page's\n// trailing icon, which is what draws its dropdown filter chip: an arrow\n// saying the chip opens a menu. It takes the same 18dp slot at the other\n// end, and the chip's content role rather than the primary one the leading\n// icon takes — on surface variant, then on secondary container once\n// selected, then the disabled 38% — so it is drawn in the chip's own colour\n// rather than a role of its own. The check never displaces it.\n//\n// **The widening is animated rather than taken in one frame.** A chip with\n// no icon keeps its slot mounted while unselected, folded to nothing, and\n// selecting it opens the slot over the chip's own short duration while the\n// check fades in, so the chips after it in a wrapped row glide rather than\n// jump 18dp. Reduced motion takes the change at once, as it does the\n// colours. A chip that can never be selected, an assist or suggestion chip\n// or one in a group that does not select, has no slot to open.\n//\n// **The press ripple takes the chip's corner from here** wherever the chip\n// is a ChipGroup's. The ripple clips itself to its host's corner by\n// inheriting it, and React Aria puts a cell between a group's chip and its\n// content, so what the ripple would inherit is the cell's square corner.\n// `surfaceCorners` restates the chip's own corner on a box the ripple sits\n// in, less the 1px border every chip keeps, since the ripple fills the\n// inside of that border.\n//\n// Apart from any component so a chip in a group and a chip on its own cannot\n// drift; see `src/row` for the same arrangement around a list's row.\n\n// The press area the chips page requires around its 32dp chip. A literal for\n// the reason IconButton's `TARGET_SIZE` gives.\nconst TARGET_SIZE = '48px';\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 chipStyles = {\n assist: {\n kMwMTN: \"x139gbkf\",\n $$css: true\n },\n base: {\n k6CgDc: \"x12w9bfk\",\n kGNEyG: \"x6s0dn4\",\n kZKoxP: \"xig8zya\",\n kaIpWk: \"x1xdvaa9\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xmkeg23\",\n kB7OPa: \"x9f619\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n kmuXW: \"x2lah0s\",\n kMv6JI: \"xkknnkr\",\n kGuDYH: \"x14zspaw\",\n k63SB2: \"x1v9cpvo\",\n kOIVth: \"x126z3so\",\n kb6lSQ: \"x155f00i\",\n kLWn49: \"x1lz68p4\",\n ks0D6T: \"x193iq5w\",\n k8WAf4: \"xt970qd\",\n kg3NbH: \"x790zyz\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"xu8237s\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n disabled: {\n kMwMTN: \"x1gpw424 x1bhcspo\",\n kkrTdU: \"x1h6gzvc\",\n $$css: true\n },\n disabledSelected: {\n kWkggS: \"x19v6zzp\",\n $$css: true\n },\n disabledUnselected: {\n kWkggS: \"xjbqb8w\",\n kVAM5u: \"xrh88j3 xmnqt3w\",\n $$css: true\n },\n elevated: {\n kWkggS: \"x1vnz5z6\",\n kVAM5u: \"x9r1u3d\",\n $$css: true\n },\n elevatedDisabled: {\n kWkggS: \"x19v6zzp\",\n kVAM5u: \"x9r1u3d\",\n kGVxlE: \"x1gnnqk1\",\n $$css: true\n },\n glyph: {\n kGNEyG: \"x6s0dn4\",\n kZKoxP: \"xmix8c7\",\n k1xSpc: \"x3nfvp2\",\n kmuXW: \"x2lah0s\",\n kGuDYH: \"xosj86m\",\n kzqmXN: \"x1xp8n7a\",\n kjj79g: \"xl56j7k\",\n keTefX: \"xxuhe3a\",\n $$css: true\n },\n glyphFolded: {\n kzqmXN: \"xnalus7\",\n k71WvV: \"x1kfc2zf\",\n keTefX: \"x1lziwak\",\n kSiTet: \"xg01cxk\",\n $$css: true\n },\n glyphOpening: {\n k6CgDc: \"x12w9bfk\",\n kVQacm: \"xb3r6kr\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"x17vvy08\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n glyphSvg: {\n kZKoxP: \"xmix8c7\",\n kmuXW: \"x2lah0s\",\n kzqmXN: \"x1xp8n7a\",\n $$css: true\n },\n icon: {\n kMwMTN: \"x1mxwv8y\",\n $$css: true\n },\n inert: {\n kkrTdU: \"xt0e3qv\",\n $$css: true\n },\n label: {\n kB7OPa: \"x9f619\",\n kVQacm: \"xb3r6kr\",\n kVAEAm: \"x1n2onr6\",\n kg5iWk: \"xlyipyv\",\n kQ0QjF: \"x4ej8vm\",\n khDVqt: \"xuxw1ft\",\n $$css: true\n },\n raised: {\n kGVxlE: \"x19efjv6\",\n $$css: true\n },\n raisedHovered: {\n kGVxlE: \"x1os83gw\",\n $$css: true\n },\n remove: {\n kgeoSG: \"x1cpjm7i\",\n kFcpXp: \"xtu493u\",\n kEoFBp: \"x1hmns74\",\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"xmix8c7\",\n kaIpWk: \"x1dkaolv\",\n kMzoRj: \"xc342km\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x1heor9g\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n kmuXW: \"x2lah0s\",\n kzqmXN: \"x1xp8n7a\",\n kjj79g: \"xl56j7k\",\n k71WvV: \"x1kfc2zf\",\n kjBf7l: \"x14ytart\",\n kInvED: \"x1y3gkto\",\n k3XXqK: \"x9v5kkp x1t137rt\",\n kMeerF: \"x1s780dp\",\n kmVPX3: \"x1717udv\",\n kVAEAm: \"x1n2onr6\",\n $$css: true\n },\n removeDisabled: {\n kkrTdU: \"x1h6gzvc\",\n $$css: true\n },\n removeGlyph: {\n kZKoxP: \"xmix8c7\",\n kzqmXN: \"x1xp8n7a\",\n $$css: true\n },\n selected: {\n kWkggS: \"x15dekr4\",\n kVAM5u: \"x9r1u3d\",\n kMwMTN: \"x1sawysd\",\n $$css: true\n },\n selectedHovered: {\n kGVxlE: \"x19efjv6\",\n $$css: true\n },\n surfaceCorners: {\n kaIpWk: \"x5a2xki\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"xjp7ctv\",\n $$css: true\n },\n target: {\n kgeoSG: \"x1cpjm7i\",\n kGOzcv: \"x1xkszu9\",\n kpsdNU: \"x1ecwmwu\",\n kEoFBp: \"x1hmns74\",\n kVAEAm: \"x1n2onr6\",\n $$css: true\n },\n trailing: {\n k71WvV: \"x1kfc2zf\",\n keTefX: \"x1lziwak\",\n $$css: true\n },\n unselected: {\n kWkggS: \"xjbqb8w\",\n kVAM5u: \"x133yhug\",\n kMwMTN: \"x1w5n3ug\",\n $$css: true\n }\n};\n\n// The hover and pressed layers, applied from React Aria's render state rather\n// than from `:hover` and `:active`, for Button's reasons — see its header: a\n// hover layer stayed on after a tap, and no pressed layer showed for a press\n// made from the keyboard. One pair per container, the pressed after the\n// hovered so a press wins, and one for the close target, whose own render\n// state is its button's. A token in a TokenField draws none of them: React\n// Aria reports neither state for one, since it is text the caret moves\n// through rather than a control a press acts on.\nconst chipLayers = {\n elevatedFocused: {\n kWkggS: \"x1drsm1c\",\n $$css: true\n },\n elevatedHovered: {\n kWkggS: \"x1ei6177\",\n $$css: true\n },\n elevatedPressed: {\n kWkggS: \"x1vt8e7r\",\n $$css: true\n },\n removeHovered: {\n kWkggS: \"x930l3l\",\n $$css: true\n },\n removePressed: {\n kWkggS: \"xsykwg8\",\n $$css: true\n },\n selectedFocused: {\n kWkggS: \"x1s5x49g\",\n $$css: true\n },\n selectedHovered: {\n kWkggS: \"x1fctxn6\",\n $$css: true\n },\n selectedPressed: {\n kWkggS: \"xzpauq9\",\n $$css: true\n },\n unselectedFocused: {\n kWkggS: \"xwqhyid\",\n $$css: true\n },\n unselectedHovered: {\n kWkggS: \"x1b18xnh\",\n $$css: true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,QAAQ;EACR1B,OAAO;CACT;CACA0E,eAAe;EACbhD,QAAQ;EACR1B,OAAO;CACT;CACA2E,eAAe;EACbjD,QAAQ;EACR1B,OAAO;CACT;CACA4E,iBAAiB;EACflD,QAAQ;EACR1B,OAAO;CACT;CACA+D,iBAAiB;EACfrC,QAAQ;EACR1B,OAAO;CACT;CACA6E,iBAAiB;EACfnD,QAAQ;EACR1B,OAAO;CACT;CACA8E,mBAAmB;EACjBpD,QAAQ;EACR1B,OAAO;CACT;CACA+E,mBAAmB;EACjBrD,QAAQ;EACR1B,OAAO;CACT;CACAgF,mBAAmB;EACjBtD,QAAQ;EACR1B,OAAO;CACT;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","names":["createContext","OptionRowContext"],"sources":["../../src/collection/context.ts"],"sourcesContent":["import { createContext } from 'react'\n\n// Which row a ListBox's options draw: the lists page's, wherever the list\n// sits on its own, or the menus page's inside the popup of a Select or a\n// ComboBox. Material Design draws an exposed dropdown menu — which is what\n// those two are — as a menu, so their options are 48dp rows at the menu's\n// 12dp with its selected container, and the list's section header, its\n// empty row and its load-more row follow the same page. The field providing\n// it is what decides; a ListBox cannot tell from inside whether it is in a\n// popup. Apart from the components so their modules export components alone,\n// which is what keeps fast refresh working for them.\nconst OptionRowContext = createContext<'list' | 'menu'>('list')\n\nexport { OptionRowContext }\n"],"mappings":";;AAWA,MAAMC,mBAAmBD,cAA+B,MAAM"}
|
|
@@ -23,6 +23,13 @@ const collectionStyles = {
|
|
|
23
23
|
kMwMTN: "x1w5n3ug",
|
|
24
24
|
$$css: true
|
|
25
25
|
},
|
|
26
|
+
focusVisible: {
|
|
27
|
+
kjBf7l: "xat36cu x1x84bn5",
|
|
28
|
+
kInvED: "x1v57pqu",
|
|
29
|
+
k3XXqK: "xaatb59",
|
|
30
|
+
kMeerF: "x1s780dp",
|
|
31
|
+
$$css: true
|
|
32
|
+
},
|
|
26
33
|
header: {
|
|
27
34
|
kB7OPa: "x9f619",
|
|
28
35
|
kMwMTN: "x1w5n3ug",
|
|
@@ -36,6 +43,11 @@ const collectionStyles = {
|
|
|
36
43
|
kg3NbH: "x790zyz",
|
|
37
44
|
$$css: true
|
|
38
45
|
},
|
|
46
|
+
headerMenu: {
|
|
47
|
+
kLKAdn: "x6gmt8y",
|
|
48
|
+
kg3NbH: "x18fpw6u",
|
|
49
|
+
$$css: true
|
|
50
|
+
},
|
|
39
51
|
loading: {
|
|
40
52
|
kGNEyG: "x6s0dn4",
|
|
41
53
|
kB7OPa: "x9f619",
|
|
@@ -44,6 +56,10 @@ const collectionStyles = {
|
|
|
44
56
|
kAzted: "xyax5pk",
|
|
45
57
|
$$css: true
|
|
46
58
|
},
|
|
59
|
+
loadingMenu: {
|
|
60
|
+
kAzted: "x1ddmzdj",
|
|
61
|
+
$$css: true
|
|
62
|
+
},
|
|
47
63
|
section: {
|
|
48
64
|
kB7OPa: "x9f619",
|
|
49
65
|
k1xSpc: "x78zum5",
|
|
@@ -63,14 +79,17 @@ const collectionStyles = {
|
|
|
63
79
|
};
|
|
64
80
|
/**
|
|
65
81
|
* A collection's own box, as the function React Aria's `className` prop
|
|
66
|
-
* wants: the container,
|
|
67
|
-
*
|
|
82
|
+
* wants: the container, its ring while it holds keyboard focus itself, and
|
|
83
|
+
* the drop target while a drop would land on the collection as a whole.
|
|
84
|
+
* List, ListBox and Tree each draw it.
|
|
68
85
|
*/
|
|
69
86
|
function containerClasses(state) {
|
|
70
87
|
return {
|
|
71
88
|
0: { className: "x9f619 x78zum5 xdt5ytf x1t137rt x1cmllll" },
|
|
72
|
-
|
|
73
|
-
|
|
89
|
+
2: { className: "x9f619 x78zum5 xdt5ytf x1cmllll xat36cu x1x84bn5 x1v57pqu xaatb59 x1s780dp" },
|
|
90
|
+
1: { className: "x9f619 x78zum5 xdt5ytf x1cmllll x659ado xrgy624 x1x84bn5 x2ssjo2 xaatb59 x1de99jn" },
|
|
91
|
+
3: { className: "x9f619 x78zum5 xdt5ytf x1cmllll x659ado xrgy624 x1x84bn5 x2ssjo2 xaatb59 x1de99jn" }
|
|
92
|
+
}[!!state.isFocusVisible << 1 | !!state.isDropTarget << 0];
|
|
74
93
|
}
|
|
75
94
|
/**
|
|
76
95
|
* The styles a selectable row in a list takes, as the function React Aria's
|
|
@@ -90,10 +109,14 @@ function containerClasses(state) {
|
|
|
90
109
|
* end. NavigationTree is not a caller: it draws the drawer variant, branches
|
|
91
110
|
* on an ancestor being current, and reads `isCurrent` where these read
|
|
92
111
|
* `isSelected`.
|
|
112
|
+
*
|
|
113
|
+
* `variant` is the row the item draws: the lists page's, or the menus
|
|
114
|
+
* page's floor, inset and selected container for a ListBox in the popup of a
|
|
115
|
+
* Select or a ComboBox — see `OptionRowContext` in ./context.ts.
|
|
93
116
|
*/
|
|
94
|
-
function rowItemStyles(supporting, overline, extra) {
|
|
117
|
+
function rowItemStyles(supporting, overline, extra, variant = "list") {
|
|
95
118
|
const lines = (hasContent(overline) ? 1 : 0) + (hasContent(supporting) ? 1 : 0);
|
|
96
|
-
return (state) => props(rowStyles.base, rowStyles.list, extra, lines === 1 && rowStyles.twoLine, lines === 2 && rowStyles.threeLine, state.isDragging === true && rowStyles.dragging, state.isSelected && rowStyles.selectedList, state.isHovered && rowStyles.hovered, state.isFocusVisible && rowStyles.focusVisible, state.isFocusVisible && state.isSelected && rowStyles.focusVisibleSelected, state.isPressed && rowStyles.pressed, state.isDropTarget === true && rowStyles.dropTarget, state.isDisabled && rowStyles.disabled);
|
|
119
|
+
return (state) => props(rowStyles.base, variant === "menu" ? rowStyles.menu : rowStyles.list, extra, lines === 1 && rowStyles.twoLine, lines === 2 && rowStyles.threeLine, state.isDragging === true && rowStyles.dragging, state.isSelected && (variant === "menu" ? rowStyles.selectedMenu : rowStyles.selectedList), state.isHovered && rowStyles.hovered, state.isFocusVisible && rowStyles.focusVisible, state.isFocusVisible && state.isSelected && rowStyles.focusVisibleSelected, state.isPressed && rowStyles.pressed, state.isDropTarget === true && rowStyles.dropTarget, state.isDisabled && rowStyles.disabled);
|
|
97
120
|
}
|
|
98
121
|
export { collectionStyles, containerClasses, rowItemStyles };
|
|
99
122
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","names":["stylex","hasContent","rowStyles","collectionStyles","container","kB7OPa","k1xSpc","kXwgrk","k3XXqK","k8WAf4","$$css","dropTarget","kWkggS","kjBf7l","kInvED","kMeerF","empty","kMwMTN","header","kMv6JI","kGuDYH","k63SB2","kb6lSQ","kLWn49","kGO01o","kLKAdn","kg3NbH","loading","kGNEyG","kjj79g","kAzted","section","status","kZKoxP","kz4h6p","kzqmXN","kVQacm","kVAEAm","khDVqt","isDisabled","isDragging","isDropTarget","isFocusVisible","isHovered","isPressed","isSelected","containerClasses","state","className","rowItemStyles","supporting","overline","extra","lines","base","list","twoLine","threeLine","dragging","
|
|
1
|
+
{"version":3,"file":"styles.js","names":["stylex","hasContent","rowStyles","collectionStyles","container","kB7OPa","k1xSpc","kXwgrk","k3XXqK","k8WAf4","$$css","dropTarget","kWkggS","kjBf7l","kInvED","kMeerF","empty","kMwMTN","focusVisible","header","kMv6JI","kGuDYH","k63SB2","kb6lSQ","kLWn49","kGO01o","kLKAdn","kg3NbH","headerMenu","loading","kGNEyG","kjj79g","kAzted","loadingMenu","section","status","kZKoxP","kz4h6p","kzqmXN","kVQacm","kVAEAm","khDVqt","isDisabled","isDragging","isDropTarget","isFocusVisible","isHovered","isPressed","isSelected","containerClasses","state","className","rowItemStyles","supporting","overline","extra","variant","lines","base","menu","list","twoLine","threeLine","dragging","selectedMenu","selectedList","hovered","focusVisibleSelected","pressed","disabled"],"sources":["../../src/collection/styles.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport { hasContent } from '../render/content';\nimport { rowStyles } from '../row/styles';\nimport '../tokens/design.tokens.stylex';\nimport { colors, sizing, spacing, stateLayerOpacity, typography } from '../tokens/design.tokens.stylex';\n\n// The chrome around the row. `src/row` was extracted so a list, menu, tree and\n// drawer draw the same row; everything wrapped around it stayed behind in each\n// component, so a change to the subhead over a list was three edits with\n// nothing failing if one were missed.\n//\n// Two of these are shared by four components and two by three, and the split\n// is the Material Design spec pages rather than convenience:\n//\n// - `container` and `section` are the box and the grouping, which List,\n// ListBox, Tree and NavigationTree all draw the same way.\n// - `header` and `loading` are the lists page's, so they are shared by the\n// three components that follow it. Menu and NavigationTree keep their own,\n// because the menus page and the navigation drawer page give different\n// values — a subhead tighter to the items above it, a label role rather\n// than a title role, and an inset that lines up with pill-shaped rows.\n// Those are the specs disagreeing rather than the code drifting, so each\n// stays where its comment explaining it is.\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 collectionStyles = {\n container: {\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kXwgrk: \"xdt5ytf\",\n k3XXqK: \"x1t137rt\",\n k8WAf4: \"x1cmllll\",\n $$css: true\n },\n dropTarget: {\n kWkggS: \"x659ado\",\n kjBf7l: \"xrgy624 x1x84bn5\",\n kInvED: \"x2ssjo2\",\n k3XXqK: \"xaatb59\",\n kMeerF: \"x1de99jn\",\n $$css: true\n },\n empty: {\n kMwMTN: \"x1w5n3ug\",\n $$css: true\n },\n focusVisible: {\n kjBf7l: \"xat36cu x1x84bn5\",\n kInvED: \"x1v57pqu\",\n k3XXqK: \"xaatb59\",\n kMeerF: \"x1s780dp\",\n $$css: true\n },\n header: {\n kB7OPa: \"x9f619\",\n kMwMTN: \"x1w5n3ug\",\n kMv6JI: \"xrgwony\",\n kGuDYH: \"x12s497w\",\n k63SB2: \"x1szcwkt\",\n kb6lSQ: \"xo803ec\",\n kLWn49: \"xyl1r0q\",\n kGO01o: \"xw3mh6e\",\n kLKAdn: \"x1clyivc\",\n kg3NbH: \"x790zyz\",\n $$css: true\n },\n headerMenu: {\n kLKAdn: \"x6gmt8y\",\n kg3NbH: \"x18fpw6u\",\n $$css: true\n },\n loading: {\n kGNEyG: \"x6s0dn4\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kjj79g: \"xl56j7k\",\n kAzted: \"xyax5pk\",\n $$css: true\n },\n loadingMenu: {\n kAzted: \"x1ddmzdj\",\n $$css: true\n },\n section: {\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kXwgrk: \"xdt5ytf\",\n $$css: true\n },\n status: {\n kZKoxP: \"xjm9jq1\",\n kB7OPa: \"x9f619\",\n kz4h6p: \"x1hyvwdk\",\n kzqmXN: \"x1i1rx1s\",\n kVQacm: \"xb3r6kr\",\n kVAEAm: \"x10l6tqk\",\n khDVqt: \"xuxw1ft\",\n $$css: true\n }\n};\n\n/**\n * The render state every collection item this covers reports. Each of React\n * Aria's own is wider than this, and this is the part the three share.\n */\ntype CollectionItemState = {\n isDisabled: boolean;\n /** Reported only where the collection drags; see `dragging` in `src/row`. */\n isDragging?: boolean;\n /** Reported only where the collection takes drops onto its items. */\n isDropTarget?: boolean;\n isFocusVisible: boolean;\n isHovered: boolean;\n isPressed: boolean;\n isSelected: boolean;\n};\n\n/**\n * A collection's own box, as the function React Aria's `className` prop\n * wants: the container, its ring while it holds keyboard focus itself, and\n * the drop target while a drop would land on the collection as a whole.\n * List, ListBox and Tree each draw it.\n */\nfunction containerClasses(state: {\n isDropTarget: boolean;\n isFocusVisible: boolean;\n}) {\n return {\n 0: {\n className: \"x9f619 x78zum5 xdt5ytf x1t137rt x1cmllll\"\n },\n 2: {\n className: \"x9f619 x78zum5 xdt5ytf x1cmllll xat36cu x1x84bn5 x1v57pqu xaatb59 x1s780dp\"\n },\n 1: {\n className: \"x9f619 x78zum5 xdt5ytf x1cmllll x659ado xrgy624 x1x84bn5 x2ssjo2 xaatb59 x1de99jn\"\n },\n 3: {\n className: \"x9f619 x78zum5 xdt5ytf x1cmllll x659ado xrgy624 x1x84bn5 x2ssjo2 xaatb59 x1de99jn\"\n }\n }[!!state.isFocusVisible << 1 | !!state.isDropTarget << 0];\n}\n\n/**\n * The styles a selectable row in a list takes, as the function React Aria's\n * `className` prop wants.\n *\n * Which of the lists page's three items the row is, read from the content\n * rather than taken as a prop: a row holding all three lines already says it\n * is three lines, and a word for it would be a second place to get it wrong.\n * `ListItem` does the same arithmetic for the static row, and this is where\n * the collection forms share it.\n *\n * The three-line item is the only row whose slots move, which is why it alone\n * carries an alignment as well as a height.\n *\n * `extra` is the one difference between the three callers — Tree passes its\n * indent, which is why it sits where Tree already had it rather than at the\n * end. NavigationTree is not a caller: it draws the drawer variant, branches\n * on an ancestor being current, and reads `isCurrent` where these read\n * `isSelected`.\n *\n * `variant` is the row the item draws: the lists page's, or the menus\n * page's floor, inset and selected container for a ListBox in the popup of a\n * Select or a ComboBox — see `OptionRowContext` in ./context.ts.\n */\nfunction rowItemStyles(supporting: ReactNode, overline: ReactNode, extra?: stylex.StyleXStyles, variant: 'list' | 'menu' = 'list') {\n const lines = (hasContent(overline) ? 1 : 0) + (hasContent(supporting) ? 1 : 0);\n return (state: CollectionItemState) => stylex.props(rowStyles.base, variant === 'menu' ? rowStyles.menu : rowStyles.list, extra, lines === 1 && rowStyles.twoLine, lines === 2 && rowStyles.threeLine, state.isDragging === true && rowStyles.dragging, state.isSelected && (variant === 'menu' ? rowStyles.selectedMenu : rowStyles.selectedList), state.isHovered && rowStyles.hovered, state.isFocusVisible && rowStyles.focusVisible, state.isFocusVisible && state.isSelected && rowStyles.focusVisibleSelected, state.isPressed && rowStyles.pressed, state.isDropTarget === true && rowStyles.dropTarget, state.isDisabled && rowStyles.disabled);\n}\nexport type { CollectionItemState };\nexport { collectionStyles, containerClasses, rowItemStyles };"],"mappings":";;;;AA6BA,MAAMG,mBAAmB;CACvBC,WAAW;EACTC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EAC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,UAA+BlD,MAAaE,UAAUwD,MAAMF,YAAY,SAAStD,UAAUyD,OAAOzD,UAAU0D,MAAML,OAAOE,UAAU,KAAKvD,UAAU2D,SAASJ,UAAU,KAAKvD,UAAU4D,WAAWZ,MAAMP,eAAe,QAAQzC,UAAU6D,UAAUb,MAAMF,eAAeQ,YAAY,SAAStD,UAAU8D,eAAe9D,UAAU+D,eAAef,MAAMJ,aAAa5C,UAAUgE,SAAShB,MAAML,kBAAkB3C,UAAUgB,cAAcgC,MAAML,kBAAkBK,MAAMF,cAAc9C,UAAUiE,sBAAsBjB,MAAMH,aAAa7C,UAAUkE,SAASlB,MAAMN,iBAAiB,QAAQ1C,UAAUS,YAAYuC,MAAMR,cAAcxC,UAAUmE,QAAQ;AACznB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_c","stylex","useContext","useState","ToggleGroupStateContext","ButtonGroupItemContext","groupPressHandlers","useSelection","pressThen","focus","spacing","styles","base","kGNEyG","kVAM5u","ksu8eU","kMzoRj","kB7OPa","kkrTdU","k1xSpc","kMv6JI","kGuDYH","k63SB2","kOIVth","kjj79g","kb6lSQ","kLWn49","ks0D6T","kHjlTd","kVAEAm","k9WMMc","kybGjl","kIyJzY","k1ekBW","kAMwcw","$$css","disabled","elevated","kWkggS","kGVxlE","kMwMTN","elevatedDisabled","elevatedToggleSelected","filled","filledDisabled","filledToggle","filledToggleSelected","icon","kmuXW","lg","kAzted","k8WAf4","kg3NbH","md","kgeoSG","kGOzcv","kpsdNU","kEoFBp","outlined","outlinedDisabled","outlinedToggleSelected","pending","text","textDisabled","tonal","tonalDisabled","tonalToggleSelected","xl","xs","xxl","OUTLINE_WIDTHS","outlinedSizes","iconSizes","PADDINGS","shifted","padding","value","undefined","val","roundShapes","kaIpWk","squareShapes","pressedShapes","hovered","focused","pressed","disabledStyles","toggleContainers","selected","unselected","variant","children","disableRipple","pendingLabel","shape","size","Button","t0","$","defaultSelected","href","isPending","isSelected","onChange","rel","t1","ownSize","target","t2","props","group","inSelectingGroup","grouped","onPressStart","onPressEnd","t3","selection","keyHeld","setKeyHeld","press","event","event_0","pointerType","ripples","t4","content","t5","buttonClasses","toggleClasses","isToggle","onPress","toggle","state","ring","isHovered","isPressed","isFocusVisible","groupStyles","isDisabled","border","shift","container"],"sources":["../../../src/components/button/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { ClassNameOrFunction, PressEvent, StyleOrFunction } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useContext, useState } from 'react';\nimport { ToggleGroupStateContext } from 'react-aria-components';\nimport type { ButtonClassesState, ButtonDOMProps, ButtonLinkForm, ButtonPressForm, ButtonState, ButtonToggleForm } from '../../button';\nimport type { ButtonGroupItem } from '../../button/context';\nimport { ButtonBase, ToggleButtonBase } from '../../button';\nimport { ButtonGroupItemContext } from '../../button/context';\nimport { groupPressHandlers } from '../../button/group';\nimport { useSelection } from '../../button/hooks';\nimport { pressThen } from '../../button/toggle';\nimport { focus } from '../../styles/focus';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, radii, shadows, sizing, spacing, stateLayerOpacity, typography } from '../../tokens/design.tokens.stylex';\n\n// Each variant composites its label colour over its container at the\n// interaction state's opacity, rather than swapping in a separate\n// hover/pressed color: filled and tonal paint the 'on-color' over the\n// container, outlined, text and elevated paint the label colour over their\n// own. The pairs are the buttons spec page's newer values: tonal on\n// secondary container, outlined with an outline variant border and an\n// on-surface-variant label, text on primary, elevated on surface container\n// low with a primary label.\n//\n// **The outlined rule is faint on purpose.** Outline variant sits at about\n// 1.6:1 against the surface in the light theme and 2:1 in the dark, under the\n// 3:1 WCAG asks of a boundary that identifies a control. The rule is not that\n// boundary: the label identifies the button, in on-surface-variant at about\n// 9:1, and the rule only shows how far the button reaches. IconButton's\n// outlined variant draws its rule in the same role for the same reason.\n//\n// **Elevated is the one variant whose shadow is part of its identity.** The\n// page rests it at elevation 1 rather than flat, raises it on hover and\n// returns it to 1 while pressed — where filled and tonal rest flat and lift\n// only on hover. Disabled drops it to none, since a shadow says a control is\n// available to press.\n// calc(<opacity> * 100%) turns the token's unitless 0-1 ratio into the\n// percentage color-mix() takes. Inlined rather than factored into a helper:\n// @stylexjs/babel-plugin only statically recognizes expressions written\n// directly as property values, and a call to an externally-defined function\n// isn't one of them.\n//\n// The hover, focus and pressed layers come from React Aria's render state,\n// `isHovered`, `isFocusVisible` and `isPressed`, rather than from `:hover`,\n// `:focus-visible` and `:active`. On a touch screen Chromium leaves `:hover`\n// on the last element tapped, so the layer and its lifted shadow stayed on a\n// button after the tap had ended, where React Aria ignores the emulated mouse\n// events that follow a touch. And React Aria prevents the default of the\n// keydown that presses a button with Space or Enter, so `:active` never\n// matched a keyboard press, which `isPressed` reports like any other.\n//\n// A press is one layer, as the page draws it: the ripple at the pressed\n// opacity, over the container at rest. The hover layer and its lift come off\n// while the button is pressed, so neither stacks under the ripple, and the\n// `pressed` table is the layer a button draws in the ripple's place: when\n// `disableRipple` turns the ripple off, and while a key holds the button\n// down, since the ripple answers a key only once it is released. The layer\n// then gives way to the ripple, which plays its whole press from there.\n//\n// Disabled is a style of its own per variant rather than a `:disabled`\n// branch inside each property: a button given `href` renders as a link,\n// which React Aria turns into a <span> while disabled, and neither matches\n// the pseudo-class. The disabled styles are applied last from the render\n// state's `isDisabled`, and StyleX replaces a property whole, so they win\n// over any state layer applied before them.\n//\n// **Under forced colours a container is drawn as a rule.** That mode drops\n// the shadow and paints author backgrounds in a system colour, which left a\n// filled, tonal or elevated button as a label with nothing round it. `base`\n// draws a 1px `ButtonText` border there instead. Outlined keeps its own rule,\n// and text stays without one, as the page draws it. The mode repaints a\n// disabled button's fade at full strength as well. Chromium greys a disabled\n// `<button>` there by itself, but not the `<span>` React Aria renders for a\n// disabled link, so the disabled styles name `GrayText` for the label and\n// the edge rather than leave it to the browser.\n//\n// Two independent axes, applied base -> variant -> size. The variant carries\n// colour and the size carries geometry, so the two never argue: inline\n// padding belongs to the size alone, and every size declares its own.\n//\n// That is deliberate rather than incidental. The buttons page gives padding\n// per size — its Small button padding is 16dp, the 24dp beside it being the\n// older value the page marks as not recommended — and gives the five colour\n// styles no padding of their own. A text button is therefore as wide as a\n// filled one at the same size, which is what the code draws.\n//\n// This did once read the other way, with `md` declaring no padding so a\n// medium button fell through to its variant's. `fix(button)!: the spec's\n// five sizes` replaced that when the component took the page's sizes, since\n// a per-variant padding had nowhere to sit once every size carried one. The\n// comment describing the old cascade outlived it by some months, which is\n// how it came to say `text` keeps a tighter padding it has never had — back\n// then `text` declared 16dp while a filled `md` declared none at all, so the\n// text button was the wider of the two.\n//\n// **A toggle is the same button reporting a state.** Given `isSelected`,\n// `defaultSelected` or `onChange` it is React Aria's `ToggleButton`, which\n// announces the state through `aria-pressed`, as IconButton's toggle does.\n// The page gives four of the five styles a second pair of colour roles for\n// it: a filled toggle rests on surface container with an on-surface-variant\n// label and takes primary once selected, a tonal one moves from the\n// secondary container pair to secondary, an elevated one keeps its low\n// surface until it takes primary, and an outlined one swaps its rule for the\n// inverse surface pair. Under forced colours a selected toggle of any style\n// is filled `Highlight`, as IconButton's is. The page gives text no pair, so\n// a text button given those props stays a plain one.\n//\n// **The corner is a shape the button morphs between**, from the page's size\n// token sets. `round` rests at half the container's height, which is the pill\n// for a label on one line, and `square` at the size's square corner: 12dp up\n// to the page's S, 16dp at M and 28dp above. A press tightens either to the\n// size's pressed corner, 8dp, 12dp or 16dp, and a toggle trades its shape for\n// the other once selected — a round one for the square corner, a square one\n// for the round. The corner eases over the motion tokens' short duration, as\n// the container, label and rule colours and the shadow do between states, and\n// all of them move at once for a reader who asks for reduced motion.\n//\n// The round corner is a length rather than the pill token's 9999px, because\n// the browser draws a corner no larger than half the box and eases the value\n// as written. From 9999px a press spent all but the last frame or two of its\n// 150ms above the 20dp a medium button can show, so the corner held round and\n// then jumped. From half the height every frame of the ease is one the eye\n// can see. A label that wraps makes a button taller than that, and its ends a\n// little less than round, as a connected ButtonGroup's already are.\n//\n// What every button does past its own styles — the ripple, the link and\n// toggle forms, the pending ring and `aria-busy`, a parent's disabled state\n// — is `src/button`'s, shared with IconButton.\n\n/**\n * The press area the buttons page requires, which its two smallest sizes are\n * drawn under. A literal rather than `sizing.controlMd`, which holds the same\n * number, for the reason IconButton's `TARGET_SIZE` gives: a consumer\n * resizing their medium controls should not shrink a target the page states\n * as a floor.\n */\nconst TARGET_SIZE = '48px';\n\n// Windows High Contrast and the rest of the forced-colours modes. Spelled\n// here rather than imported, for the reason src/field/styles.ts records: the\n// StyleX compiler resolves a constant across files only out of a `.stylex.ts`\n// module, and the generated one holds design tokens rather than queries.\nconst FORCED_COLORS = '@media (forced-colors: active)';\nconst styles = {\n base: {\n kGNEyG: \"x6s0dn4\",\n kVAM5u: \"x1ylmb6m\",\n ksu8eU: \"xx61lck\",\n kMzoRj: \"xc342km x13rsnn2\",\n kB7OPa: \"x9f619\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n kMv6JI: \"xkknnkr\",\n kGuDYH: \"x14zspaw\",\n k63SB2: \"x1v9cpvo\",\n kOIVth: \"x126z3so\",\n kjj79g: \"xl56j7k\",\n kb6lSQ: \"x155f00i\",\n kLWn49: \"x1lz68p4\",\n ks0D6T: \"x193iq5w\",\n kHjlTd: \"xj0a0fe\",\n kVAEAm: \"x1n2onr6\",\n k9WMMc: \"x2b8uid\",\n kybGjl: \"x1hl2dhg\",\n kIyJzY: \"x4ukx00 x12w9bfk\",\n k1ekBW: \"xidvh3d\",\n kAMwcw: \"xmg88ys\",\n $$css: true\n },\n disabled: {\n kkrTdU: \"x1h6gzvc\",\n $$css: true\n },\n elevated: {\n kWkggS: \"x1vnz5z6\",\n kGVxlE: \"x19efjv6\",\n kMwMTN: \"x1mxwv8y\",\n $$css: true\n },\n elevatedDisabled: {\n kWkggS: \"xepofeg\",\n kVAM5u: \"xmnqt3w\",\n kGVxlE: \"x1gnnqk1\",\n kMwMTN: \"x1xj74d8 x1bhcspo\",\n $$css: true\n },\n elevatedToggleSelected: {\n kWkggS: \"xnety89 x1jzqe4\",\n kMwMTN: \"xwjo7ld x1k5gbb1\",\n $$css: true\n },\n filled: {\n kWkggS: \"xnety89\",\n kGVxlE: \"x1gnnqk1\",\n kMwMTN: \"xwjo7ld\",\n $$css: true\n },\n filledDisabled: {\n kWkggS: \"xepofeg\",\n kVAM5u: \"xmnqt3w\",\n kGVxlE: \"x1gnnqk1\",\n kMwMTN: \"x1xj74d8 x1bhcspo\",\n $$css: true\n },\n filledToggle: {\n kWkggS: \"x1mjdul6\",\n kMwMTN: \"x1w5n3ug\",\n $$css: true\n },\n filledToggleSelected: {\n kWkggS: \"xnety89 x1jzqe4\",\n kMwMTN: \"xwjo7ld x1k5gbb1\",\n $$css: true\n },\n icon: {\n kGNEyG: \"x6s0dn4\",\n k1xSpc: \"x3nfvp2\",\n kmuXW: \"x2lah0s\",\n kjj79g: \"xl56j7k\",\n $$css: true\n },\n lg: {\n kMv6JI: \"x46eyla\",\n kGuDYH: \"x5ehqhr\",\n k63SB2: \"xrf6cl6\",\n kb6lSQ: \"x1g135zh\",\n kLWn49: \"x1ggk5va\",\n kAzted: \"xdovgog\",\n k8WAf4: \"x1uvvd8r\",\n kg3NbH: \"xg0ps1x\",\n $$css: true\n },\n md: {\n kgeoSG: \"x1cpjm7i\",\n kGOzcv: \"xun2zgk\",\n kpsdNU: \"xm4btww\",\n kEoFBp: \"x1hmns74\",\n kAzted: \"x1cio8j0\",\n k8WAf4: \"x1cmllll\",\n kg3NbH: \"x790zyz\",\n $$css: true\n },\n outlined: {\n kWkggS: \"xjbqb8w\",\n kVAM5u: \"x133yhug\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xmkeg23\",\n kMwMTN: \"x1w5n3ug\",\n $$css: true\n },\n outlinedDisabled: {\n kWkggS: \"xjbqb8w\",\n kVAM5u: \"xrh88j3 xmnqt3w\",\n kMwMTN: \"x1xj74d8 x1bhcspo\",\n $$css: true\n },\n outlinedToggleSelected: {\n kWkggS: \"x1c5gpgi x1jzqe4\",\n kVAM5u: \"x9r1u3d x1n2ykn\",\n kMwMTN: \"x1girmi0 x1k5gbb1\",\n $$css: true\n },\n pending: {\n kkrTdU: \"x19v85br\",\n $$css: true\n },\n text: {\n kWkggS: \"xjbqb8w\",\n kMzoRj: \"xc342km\",\n kMwMTN: \"x1mxwv8y\",\n $$css: true\n },\n textDisabled: {\n kWkggS: \"xjbqb8w\",\n kMwMTN: \"x1xj74d8 x1bhcspo\",\n $$css: true\n },\n tonal: {\n kWkggS: \"x15dekr4\",\n kGVxlE: \"x1gnnqk1\",\n kMwMTN: \"x1sawysd\",\n $$css: true\n },\n tonalDisabled: {\n kWkggS: \"xepofeg\",\n kVAM5u: \"xmnqt3w\",\n kGVxlE: \"x1gnnqk1\",\n kMwMTN: \"x1xj74d8 x1bhcspo\",\n $$css: true\n },\n tonalToggleSelected: {\n kWkggS: \"x167r6xl x1jzqe4\",\n kMwMTN: \"x1lba3jz x1k5gbb1\",\n $$css: true\n },\n xl: {\n kMv6JI: \"x1fz0g89\",\n kGuDYH: \"xkb6epg\",\n k63SB2: \"x76yrz5\",\n kOIVth: \"x1gka490\",\n kb6lSQ: \"x1s1qhaa\",\n kLWn49: \"x1voeury\",\n kAzted: \"x112cvos\",\n k8WAf4: \"xny1cbh\",\n kg3NbH: \"x1sdxjpb\",\n $$css: true\n },\n xs: {\n kgeoSG: \"x1cpjm7i\",\n kGOzcv: \"xun2zgk\",\n kpsdNU: \"x1ecwmwu\",\n kEoFBp: \"x1hmns74\",\n kOIVth: \"xzoy561\",\n kAzted: \"xlzjxrf\",\n k8WAf4: \"xmqoko8\",\n kg3NbH: \"x18fpw6u\",\n $$css: true\n },\n xxl: {\n kMv6JI: \"x1vsmgmf\",\n kGuDYH: \"xh9c4x\",\n k63SB2: \"x1y15vu6\",\n kOIVth: \"xxj4525\",\n kb6lSQ: \"xoqu3bc\",\n kLWn49: \"x10x9d6x\",\n kAzted: \"xldltni\",\n k8WAf4: \"x1lrxzt4\",\n kg3NbH: \"x1dao9b2\",\n $$css: true\n }\n};\n\n// The outlined button's border thickens with the size, as the page's size\n// tokens have it: 1dp up to M, 2dp at L, 3dp at XL. A style per size rather\n// than a value in the size style, since a border on a filled button would\n// draw in the label colour.\nconst OUTLINE_WIDTHS = {\n lg: '1px',\n md: '1px',\n xl: '2px',\n xs: '1px',\n xxl: '3px'\n} as const;\n\n// The outlined button draws its rule inside the width the other variants\n// take, as the page's buttons do: the padding gives up what the border takes,\n// so an outlined and a filled button with one label are one width, and a\n// group mixing them lines up. The height needs nothing, since it is a floor\n// the border already counts towards.\nconst outlinedSizes = {\n lg: {\n kMzoRj: \"xmkeg23\",\n kg3NbH: \"xfeiziq\",\n $$css: true\n },\n md: {\n kMzoRj: \"xmkeg23\",\n kg3NbH: \"x1uvede8\",\n $$css: true\n },\n xl: {\n kMzoRj: \"xdh2fpr\",\n kg3NbH: \"xrhf21y\",\n $$css: true\n },\n xs: {\n kMzoRj: \"xmkeg23\",\n kg3NbH: \"x9t8nta\",\n $$css: true\n },\n xxl: {\n kMzoRj: \"x9r2w2z\",\n kg3NbH: \"x1wz3vkj\",\n $$css: true\n }\n};\n\n// The icon each size draws, from the page's size token sets: 20dp for the\n// two small sizes, then 24, 32 and 40. The gap before it is the size's own,\n// which `base`, `xl` and `xxl` already set as the page gives them.\nconst iconSizes = {\n lg: {\n kGuDYH: \"x1pvqxga\",\n $$css: true\n },\n md: {\n kGuDYH: \"xwsyq91\",\n $$css: true\n },\n xl: {\n kGuDYH: \"x1s3cmhv\",\n $$css: true\n },\n xs: {\n kGuDYH: \"xwsyq91\",\n $$css: true\n },\n xxl: {\n kGuDYH: \"x1tgwohi\",\n $$css: true\n }\n};\n\n// Each size's inline padding again, for the one place it is read at runtime:\n// a standard ButtonGroup widening a pressed button by adding to it. The size\n// styles above write the same values, and an outlined button's border comes\n// off them here as it does in `outlinedSizes`.\nconst PADDINGS = {\n lg: spacing.xl,\n md: spacing.lg,\n xl: '48px',\n xs: spacing.md,\n xxl: '64px'\n};\n\n// The padding a standard group sets while it widens or narrows the button.\nconst shifted = {\n padding: (value: string) => [value !== undefined && {\n kg3NbH: value != null ? \"x30g6up\" : \"\",\n $$css: true\n }, {\n \"--x-paddingInline\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(value)\n }]\n};\n\n// The round corner each size rests at, and a square toggle once selected:\n// half the container's height — see the header for why not the pill's\n// 9999px. `min()` leaves the pill token in charge below that, so a scheme\n// that sets `--kui-radius-pill` small still draws round buttons at its corner.\nconst roundShapes = {\n lg: {\n kaIpWk: \"x1j5kmnq\",\n $$css: true\n },\n md: {\n kaIpWk: \"x1y5wlyh\",\n $$css: true\n },\n xl: {\n kaIpWk: \"x39tcx0\",\n $$css: true\n },\n xs: {\n kaIpWk: \"xcslhsm\",\n $$css: true\n },\n xxl: {\n kaIpWk: \"xjy9rn5\",\n $$css: true\n }\n};\n\n// The square corner each size rests at, and a round toggle once selected.\nconst squareShapes = {\n lg: {\n kaIpWk: \"xhpdng0\",\n $$css: true\n },\n md: {\n kaIpWk: \"x62ce2h\",\n $$css: true\n },\n xl: {\n kaIpWk: \"x19pkqky\",\n $$css: true\n },\n xs: {\n kaIpWk: \"x62ce2h\",\n $$css: true\n },\n xxl: {\n kaIpWk: \"x19pkqky\",\n $$css: true\n }\n};\n\n// The corner each size presses to, whatever its shape. Applied after the\n// resting and selected shapes, so a press is felt whichever the button rests\n// at.\nconst pressedShapes = {\n lg: {\n kaIpWk: \"x62ce2h\",\n $$css: true\n },\n md: {\n kaIpWk: \"x1xdvaa9\",\n $$css: true\n },\n xl: {\n kaIpWk: \"xhpdng0\",\n $$css: true\n },\n xs: {\n kaIpWk: \"x1xdvaa9\",\n $$css: true\n },\n xxl: {\n kaIpWk: \"xhpdng0\",\n $$css: true\n }\n};\n\n// The interaction state layers, one style per variant for each state, applied\n// from React Aria's render state — see the header for why that and not the\n// pseudo-classes. In the order they are applied, so where two hold the later\n// wins, as the page draws one layer at a time: focus over hover, and a press\n// over both. Hover lifts filled and tonal off the page and raises elevated a\n// level, and a press brings each back to where it rests.\n//\n// A toggle's containers carry a layer of their own, each the label colour\n// over that container, applied after the variant's so the variant still\n// decides the shadow. A selected toggle's keeps its forced-colours\n// `Highlight`, since a later style replaces the property whole.\nconst hovered = {\n elevated: {\n kWkggS: \"xltxkvm\",\n kGVxlE: \"x1os83gw\",\n $$css: true\n },\n elevatedToggleSelected: {\n kWkggS: \"xo1ct44 x1jzqe4\",\n $$css: true\n },\n filled: {\n kWkggS: \"xo1ct44\",\n kGVxlE: \"x19efjv6\",\n $$css: true\n },\n filledToggle: {\n kWkggS: \"xtxe0ya\",\n $$css: true\n },\n filledToggleSelected: {\n kWkggS: \"xo1ct44 x1jzqe4\",\n $$css: true\n },\n outlined: {\n kWkggS: \"x14noynh\",\n $$css: true\n },\n outlinedToggleSelected: {\n kWkggS: \"x1hxzsxp x1jzqe4\",\n $$css: true\n },\n text: {\n kWkggS: \"x659ado\",\n $$css: true\n },\n tonal: {\n kWkggS: \"x1fctxn6\",\n kGVxlE: \"x19efjv6\",\n $$css: true\n },\n tonalToggleSelected: {\n kWkggS: \"x12r95rf x1jzqe4\",\n $$css: true\n }\n};\nconst focused = {\n elevated: {\n kWkggS: \"xcn1wy9\",\n $$css: true\n },\n elevatedToggleSelected: {\n kWkggS: \"xhodiby x1jzqe4\",\n $$css: true\n },\n filled: {\n kWkggS: \"xhodiby\",\n $$css: true\n },\n filledToggle: {\n kWkggS: \"x1ppcb1\",\n $$css: true\n },\n filledToggleSelected: {\n kWkggS: \"xhodiby x1jzqe4\",\n $$css: true\n },\n outlined: {\n kWkggS: \"x19p5drm\",\n $$css: true\n },\n outlinedToggleSelected: {\n kWkggS: \"xn4e5mw x1jzqe4\",\n $$css: true\n },\n text: {\n kWkggS: \"x1sog3nf\",\n $$css: true\n },\n tonal: {\n kWkggS: \"x1s5x49g\",\n $$css: true\n },\n tonalToggleSelected: {\n kWkggS: \"x16tkg7c x1jzqe4\",\n $$css: true\n }\n};\n\n// The pressed layer of a button whose ripple is off, drawn in the ripple's\n// place — see the header. Its shadow is the variant's resting one, which the\n// hover's lift no longer covers while the button is pressed.\nconst pressed = {\n elevated: {\n kWkggS: \"x1d33wxb\",\n $$css: true\n },\n elevatedToggleSelected: {\n kWkggS: \"x7b25lv x1jzqe4\",\n $$css: true\n },\n filled: {\n kWkggS: \"x7b25lv\",\n $$css: true\n },\n filledToggle: {\n kWkggS: \"x1qdfkg1\",\n $$css: true\n },\n filledToggleSelected: {\n kWkggS: \"x7b25lv x1jzqe4\",\n $$css: true\n },\n outlined: {\n kWkggS: \"x123fei2\",\n $$css: true\n },\n outlinedToggleSelected: {\n kWkggS: \"x167cdfs x1jzqe4\",\n $$css: true\n },\n text: {\n kWkggS: \"x1dvjsmr\",\n $$css: true\n },\n tonal: {\n kWkggS: \"xzpauq9\",\n $$css: true\n },\n tonalToggleSelected: {\n kWkggS: \"x12o6fnv x1jzqe4\",\n $$css: true\n }\n};\nconst disabledStyles = {\n elevated: styles.elevatedDisabled,\n filled: styles.filledDisabled,\n outlined: styles.outlinedDisabled,\n text: styles.textDisabled,\n tonal: styles.tonalDisabled\n};\n\n// Which container a toggle draws, selected and not, by its name in the\n// tables above. Three of the eight are the plain button's own: an unselected\n// tonal, elevated or outlined toggle is the tonal, elevated or outlined\n// button.\nconst toggleContainers = {\n elevated: {\n selected: 'elevatedToggleSelected',\n unselected: 'elevated'\n },\n filled: {\n selected: 'filledToggleSelected',\n unselected: 'filledToggle'\n },\n outlined: {\n selected: 'outlinedToggleSelected',\n unselected: 'outlined'\n },\n tonal: {\n selected: 'tonalToggleSelected',\n unselected: 'tonal'\n }\n} as const;\ntype ButtonProps = ButtonDOMProps & (ButtonLinkForm | ButtonPressForm | (ButtonToggleForm & {\n /**\n * A toggle takes any variant but `text`, which the page gives no\n * selected colours.\n */\n variant?: Exclude<ButtonVariant, 'text'>;\n})) & {\n children?: ReactNode;\n /** A function may compute the class from the button's render state. */\n className?: ClassNameOrFunction<ButtonState>;\n /**\n * Disables the press ripple. A press then draws its layer as a background\n * instead, at the same pressed opacity, so the button reads the same\n * either way. The hover and focus layers are unaffected.\n * @default false\n */\n disableRipple?: boolean;\n /**\n * An icon before the label, at the page's icon size for the button's size:\n * 20px at `xs` and `md`, 24px at `lg`, 32px at `xl` and 40px at `xxl`. Draw\n * it `1em` square in `currentColor`, as every icon here is, and it follows.\n * Hidden with the label while the button is pending.\n */\n icon?: ReactNode;\n /**\n * The name of the ring shown while the button is pending, for a screen\n * reader. The label it replaces is hidden while it shows. Left out, it is\n * the word for it in the I18nProvider's locale — \"Loading\" in English.\n */\n pendingLabel?: string;\n /**\n * The corner the button rests at: `round` is the pill, `square` the\n * page's rounded rectangle, 12px up to `md`, 16px at `lg` and 28px above.\n * Either tightens while pressed, and a toggle trades one for the other\n * once selected.\n * @default 'round'\n */\n shape?: ButtonShape;\n /**\n * Control height: `xs` 32px, `md` 40px, `lg` 56px, `xl` 96px, `xxl` 136px —\n * the buttons spec page's XS, S, M, L and XL, each with its own inline\n * padding and type role. `md` is the page's default.\n * @default 'md'\n */\n size?: ButtonSize;\n /** A function may compute the style from the button's render state. */\n style?: StyleOrFunction<ButtonState>;\n /**\n * How much weight the button pulls. `filled` and `tonal` carry a container\n * of their own; `outlined` and `text` sit on the page; `elevated` sits on\n * a low surface and lifts off it with a shadow, for a button that has to\n * separate from a busy background rather than from the page.\n * @default 'filled'\n */\n variant?: ButtonVariant;\n};\ntype ButtonShape = 'round' | 'square';\ntype ButtonSize = 'lg' | 'md' | 'xl' | 'xs' | 'xxl';\ntype ButtonVariant = 'elevated' | 'filled' | 'outlined' | 'text' | 'tonal';\n\n// The four styles the page gives a toggle's colour pairs; see the header.\ntype ToggleVariant = keyof typeof toggleContainers;\n\n/**\n * The design's button, at five emphasis levels and five control heights,\n * round or square. Given `href` it is a link with the same appearance. Every\n * `aria-*` prop is forwarded to the element; React Aria alone would keep only\n * the labelling ones.\n *\n * Given `isSelected`, `defaultSelected` or `onChange` it is a toggle, which\n * reports its state through `aria-pressed` and draws the page's second pair\n * of colour roles for its variant. The three forms are exclusive, so a toggle\n * given `href` does not compile, and nor does a `text` toggle, which the page\n * gives no selected colours — a `text` button in a selecting `ButtonGroup`\n * is the one that toggles, for the group's sake. A toggle may be pending,\n * for a state saved somewhere slow: the ring replaces its label and a press\n * changes nothing until it clears.\n *\n * ```tsx\n * <Button defaultSelected variant=\"tonal\">\n * Label\n * </Button>\n * ```\n */\nfunction Button({\n children,\n defaultSelected,\n href,\n icon,\n isPending,\n isSelected,\n onChange,\n pendingLabel,\n rel,\n shape = 'round',\n size: ownSize,\n target,\n variant = 'filled',\n ...props\n}: ButtonProps & RefAttributes<HTMLAnchorElement | HTMLButtonElement>) {\n // A ButtonGroup or a SplitButton around the button hands it a size, its\n // shape at the group's inner edges and the press interaction; see\n // src/button/context.ts. A size named here still wins.\n const group = useContext(ButtonGroupItemContext);\n const size = ownSize ?? group?.size ?? 'md';\n // A group that selects is React Aria's ToggleButtonGroup, whose buttons\n // have to be toggles to take part in its selection.\n const inSelectingGroup = useContext(ToggleGroupStateContext) !== null;\n const grouped = groupPressHandlers(group, props.onPressStart, props.onPressEnd);\n const onPressEnd = grouped.onPressEnd ?? props.onPressEnd;\n const onPressStart = grouped.onPressStart ?? props.onPressStart;\n const selection = useSelection({\n defaultSelected,\n isSelected,\n onChange\n });\n // Whether a key holds the button down, which the ripple does not draw\n // until the key is released, so the pressed layer draws in its place.\n const [keyHeld, setKeyHeld] = useState(false);\n const press = {\n onPressEnd: (event: PressEvent) => {\n setKeyHeld(false);\n onPressEnd?.(event);\n },\n onPressStart: (event: PressEvent) => {\n setKeyHeld(event.pointerType === 'keyboard');\n onPressStart?.(event);\n }\n };\n const ripples = props.disableRipple !== true && !keyHeld;\n\n // The icon goes in with the label, inside what ButtonBase hides while the\n // button is pending, so the ring takes the place of both.\n const content = icon === undefined ? children : <>\n <span {...stylex.props(styles.icon, iconSizes[size])}>{icon}</span>\n {children}\n </>;\n\n // A selecting ButtonGroup around it makes it React Aria's ToggleButton, to\n // take part in the group's selection — a text button too, which draws its\n // selection by nothing but the group's shape. Whether a button sits in one\n // does not change from one render to the next.\n if (inSelectingGroup) {\n return <ToggleButtonBase {...props} {...press} classes={variant === 'text' ? buttonClasses(shape, size, variant, group, ripples) : toggleClasses(shape, size, variant, group, ripples)} isPending={isPending}>\n {content}\n </ToggleButtonBase>;\n }\n\n // The three props that make this a toggle on its own, read as IconButton\n // reads them, and on the same component as the plain button so a toggle\n // whose `isSelected` is still loading stays one element when it arrives.\n // The types keep them off a `text` button; the check here keeps a call\n // site that slipped past them a plain button, as it always was.\n const isToggle = variant !== 'text' && (defaultSelected !== undefined || isSelected !== undefined || onChange !== undefined);\n return <ButtonBase {...props} {...press} classes={isToggle ? toggleClasses(shape, size, variant, group, ripples) : buttonClasses(shape, size, variant, group, ripples)} href={href} isPending={isPending} isSelected={isToggle ? selection.selected : undefined} onPress={isToggle ? pressThen(props.onPress, selection.toggle) : props.onPress} pendingLabel={pendingLabel} rel={rel} target={target}>\n {content}\n </ButtonBase>;\n}\n\n// The button's own classes, from React Aria's render state — see the header\n// for why that and not the pseudo-classes, and for why a press drops the\n// hover layer and draws its own only where the ripple does not. Built by a\n// call rather than written inline at the prop, which is what react-perf's\n// no-new-function-as-prop is after; the React Compiler memoises the result on\n// its inputs.\nfunction buttonClasses(shape: ButtonShape, size: ButtonSize, variant: ButtonVariant, group: ButtonGroupItem | null, ripples: boolean) {\n return (state: ButtonClassesState) => stylex.props(styles.base, focus.ring, styles[variant], styles[size], shape === 'square' ? squareShapes[size] : roundShapes[size], variant === 'outlined' && outlinedSizes[size], state.isHovered && !state.isPressed && hovered[variant], state.isFocusVisible && focused[variant], state.isPressed && !ripples && pressed[variant], state.isPressed && pressedShapes[size], groupStyles(group, size, variant, state), state.isPending === true && styles.pending, state.isDisabled && styles.disabled, state.isDisabled && disabledStyles[variant]);\n}\n\n// What a group lays over the button: its own styles for the button's state,\n// and the standard group's widening or narrowing as extra inline padding,\n// half of the shift on either side.\nfunction groupStyles(group: ButtonGroupItem | null, size: ButtonSize, variant: ButtonVariant, state: ButtonState) {\n if (group === null) {\n return null;\n }\n const border = variant === 'outlined' ? OUTLINE_WIDTHS[size] : '0px';\n return [group.styles?.(state), group.shift !== 0 && shifted.padding(`calc(${PADDINGS[size]} - ${border} + ${group.shift / 2}px)`)];\n}\n\n// A toggle's classes: the plain button's, with the container and its layers\n// swapped for the toggle's pair, and the selected shape between the resting\n// and the pressed one. The variant's own style and layers still go first, for\n// the shadow and the rule they carry. Built by a call for the reason\n// `buttonClasses` is.\nfunction toggleClasses(shape: ButtonShape, size: ButtonSize, variant: ToggleVariant, group: ButtonGroupItem | null, ripples: boolean) {\n return (state: ButtonClassesState) => {\n const isSelected = state.isSelected === true;\n const container = toggleContainers[variant][isSelected ? 'selected' : 'unselected'];\n return stylex.props(styles.base, focus.ring, styles[variant], styles[container], styles[size], shape === 'square' ? squareShapes[size] : roundShapes[size], isSelected && (shape === 'square' ? roundShapes[size] : squareShapes[size]), variant === 'outlined' && outlinedSizes[size], state.isHovered && !state.isPressed && hovered[variant], state.isHovered && !state.isPressed && hovered[container], state.isFocusVisible && focused[variant], state.isFocusVisible && focused[container], state.isPressed && !ripples && pressed[variant], state.isPressed && !ripples && pressed[container], state.isPressed && pressedShapes[size], groupStyles(group, size, variant, state), state.isPending === true && styles.pending, state.isDisabled && styles.disabled, state.isDisabled && disabledStyles[variant]);\n };\n}\nexport type { ButtonDOMProps, ButtonProps, ButtonShape, ButtonSize, ButtonState, ButtonVariant };\nexport default Button;"],"mappings":";;;;;;;;;;;;;;AAkJA,MAAMW,SAAS;CACbC,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;E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AYlI,OAAOoF,OAAOD,UAAU,WAAWb,aAAac,QAAQhB,YAAYgB,OAAOO,eAAeR,UAAU,WAAWf,YAAYgB,QAAQd,aAAac,QAAQL,YAAY,cAAcnB,cAAcwB,OAAOqC,MAAME,aAAa,CAACF,MAAMG,aAAapD,QAAQO,UAAU0C,MAAME,aAAa,CAACF,MAAMG,aAAapD,QAAQ0D,YAAYT,MAAMI,kBAAkBpD,QAAQM,UAAU0C,MAAMI,kBAAkBpD,QAAQyD,YAAYT,MAAMG,aAAa,CAACZ,WAAWtC,QAAQK,UAAU0C,MAAMG,aAAa,CAACZ,WAAWtC,QAAQwD,YAAYT,MAAMG,aAAarD,cAAca,OAAO0C,YAAY3B,OAAOf,MAAML,SAAS0C,KAAK,GAAGA,MAAM/B,cAAc,QAAQ1F,OAAOkD,SAASuE,MAAMM,cAAc/H,OAAOyB,UAAUgG,MAAMM,cAAcpD,eAAeI,QAAQ;CACtxB;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_c","stylex","useContext","useState","ToggleGroupStateContext","ButtonGroupItemContext","groupPressHandlers","useSelection","pressThen","focus","spacing","styles","base","kGNEyG","kVAM5u","ksu8eU","kMzoRj","kB7OPa","kkrTdU","k1xSpc","kMv6JI","kGuDYH","k63SB2","kOIVth","kjj79g","kb6lSQ","kLWn49","ks0D6T","kHjlTd","kVAEAm","k9WMMc","kybGjl","kIyJzY","k1ekBW","kAMwcw","$$css","disabled","elevated","kWkggS","kGVxlE","kMwMTN","elevatedDisabled","elevatedToggleSelected","filled","filledDisabled","filledToggle","filledToggleSelected","icon","kmuXW","lg","kAzted","k8WAf4","kg3NbH","md","kgeoSG","kGOzcv","kpsdNU","kEoFBp","outlined","outlinedDisabled","outlinedToggleSelected","pending","text","textDisabled","tonal","tonalDisabled","tonalToggleSelected","xl","xs","xxl","OUTLINE_WIDTHS","outlinedSizes","iconSizes","PADDINGS","shifted","padding","value","undefined","val","roundShapes","kaIpWk","squareShapes","pressedShapes","hovered","focused","pressed","disabledStyles","toggleContainers","selected","unselected","variant","children","disableRipple","pendingLabel","shape","size","Button","t0","$","defaultSelected","href","isPending","isSelected","onChange","rel","t1","ownSize","target","t2","props","group","inSelectingGroup","grouped","onPressStart","onPressEnd","t3","selection","keyHeld","setKeyHeld","press","event","event_0","pointerType","ripples","t4","content","t5","buttonClasses","toggleClasses","isToggle","onPress","toggle","state","ring","isHovered","isPressed","isFocusVisible","groupStyles","isDisabled","border","shift","container"],"sources":["../../../src/components/button/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { ClassNameOrFunction, PressEvent, StyleOrFunction } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useContext, useState } from 'react';\nimport { ToggleGroupStateContext } from 'react-aria-components';\nimport type { ButtonClassesState, ButtonDOMProps, ButtonLinkForm, ButtonPressForm, ButtonState, ButtonToggleForm } from '../../button';\nimport type { ButtonGroupItem } from '../../button/context';\nimport { ButtonBase, ToggleButtonBase } from '../../button';\nimport { ButtonGroupItemContext } from '../../button/context';\nimport { groupPressHandlers } from '../../button/group';\nimport { useSelection } from '../../button/hooks';\nimport { pressThen } from '../../button/toggle';\nimport { focus } from '../../styles/focus';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, radii, shadows, sizing, spacing, stateLayerOpacity, typography } from '../../tokens/design.tokens.stylex';\n\n// Each variant composites its label colour over its container at the\n// interaction state's opacity, rather than swapping in a separate\n// hover/pressed color: filled and tonal paint the 'on-color' over the\n// container, outlined, text and elevated paint the label colour over their\n// own. The pairs are the buttons spec page's newer values: tonal on\n// secondary container, outlined with an outline variant border and an\n// on-surface-variant label, text on primary, elevated on surface container\n// low with a primary label.\n//\n// **The outlined rule is faint on purpose.** Outline variant sits at about\n// 1.6:1 against the surface in the light theme and 2:1 in the dark, under the\n// 3:1 WCAG asks of a boundary that identifies a control. The rule is not that\n// boundary: the label identifies the button, in on-surface-variant at about\n// 9:1, and the rule only shows how far the button reaches. IconButton's\n// outlined variant draws its rule in the same role for the same reason.\n//\n// **Elevated is the one variant whose shadow is part of its identity.** The\n// page rests it at elevation 1 rather than flat, raises it on hover and\n// returns it to 1 while pressed — where filled and tonal rest flat and lift\n// only on hover. Disabled drops it to none, since a shadow says a control is\n// available to press.\n// calc(<opacity> * 100%) turns the token's unitless 0-1 ratio into the\n// percentage color-mix() takes. Inlined rather than factored into a helper:\n// @stylexjs/babel-plugin only statically recognizes expressions written\n// directly as property values, and a call to an externally-defined function\n// isn't one of them.\n//\n// The hover, focus and pressed layers come from React Aria's render state,\n// `isHovered`, `isFocusVisible` and `isPressed`, rather than from `:hover`,\n// `:focus-visible` and `:active`. On a touch screen Chromium leaves `:hover`\n// on the last element tapped, so the layer and its lifted shadow stayed on a\n// button after the tap had ended, where React Aria ignores the emulated mouse\n// events that follow a touch. And React Aria prevents the default of the\n// keydown that presses a button with Space or Enter, so `:active` never\n// matched a keyboard press, which `isPressed` reports like any other.\n//\n// A press is one layer, as the page draws it: the ripple at the pressed\n// opacity, over the container at rest. The hover layer and its lift come off\n// while the button is pressed, so neither stacks under the ripple, and the\n// `pressed` table is the layer a button draws in the ripple's place: when\n// `disableRipple` turns the ripple off, and while a key holds the button\n// down, since the ripple answers a key only once it is released. The layer\n// then gives way to the ripple, which plays its whole press from there. A\n// press is a pointer or a key on the button, never an overlay it opened:\n// React Aria reports a trigger pressed for as long as its menu, popover or\n// dialog is open, and the button rests and answers hover through all of it\n// — see src/button.\n//\n// Disabled is a style of its own per variant rather than a `:disabled`\n// branch inside each property: a button given `href` renders as a link,\n// which React Aria turns into a <span> while disabled, and neither matches\n// the pseudo-class. The disabled styles are applied last from the render\n// state's `isDisabled`, and StyleX replaces a property whole, so they win\n// over any state layer applied before them.\n//\n// **Under forced colours a container is drawn as a rule.** That mode drops\n// the shadow and paints author backgrounds in a system colour, which left a\n// filled, tonal or elevated button as a label with nothing round it. `base`\n// draws a 1px `ButtonText` border there instead. Outlined keeps its own rule,\n// and text stays without one, as the page draws it. The mode repaints a\n// disabled button's fade at full strength as well. Chromium greys a disabled\n// `<button>` there by itself, but not the `<span>` React Aria renders for a\n// disabled link, so the disabled styles name `GrayText` for the label and\n// the edge rather than leave it to the browser.\n//\n// Two independent axes, applied base -> variant -> size. The variant carries\n// colour and the size carries geometry, so the two never argue: inline\n// padding belongs to the size alone, and every size declares its own.\n//\n// That is deliberate rather than incidental. The buttons page gives padding\n// per size — its Small button padding is 16dp, the 24dp beside it being the\n// older value the page marks as not recommended — and gives the five colour\n// styles no padding of their own. A text button is therefore as wide as a\n// filled one at the same size, which is what the code draws.\n//\n// This did once read the other way, with `md` declaring no padding so a\n// medium button fell through to its variant's. `fix(button)!: the spec's\n// five sizes` replaced that when the component took the page's sizes, since\n// a per-variant padding had nowhere to sit once every size carried one. The\n// comment describing the old cascade outlived it by some months, which is\n// how it came to say `text` keeps a tighter padding it has never had — back\n// then `text` declared 16dp while a filled `md` declared none at all, so the\n// text button was the wider of the two.\n//\n// **A toggle is the same button reporting a state.** Given `isSelected`,\n// `defaultSelected` or `onChange` it is React Aria's `ToggleButton`, which\n// announces the state through `aria-pressed`, as IconButton's toggle does.\n// The page gives four of the five styles a second pair of colour roles for\n// it: a filled toggle rests on surface container with an on-surface-variant\n// label and takes primary once selected, a tonal one moves from the\n// secondary container pair to secondary, an elevated one keeps its low\n// surface until it takes primary, and an outlined one swaps its rule for the\n// inverse surface pair. Under forced colours a selected toggle of any style\n// is filled `Highlight`, as IconButton's is. The page gives text no pair, so\n// a text button given those props stays a plain one.\n//\n// **The corner is a shape the button morphs between**, from the page's size\n// token sets. `round` rests at half the container's height, which is the pill\n// for a label on one line, and `square` at the size's square corner: 12dp up\n// to the page's S, 16dp at M and 28dp above. A press tightens either to the\n// size's pressed corner, 8dp, 12dp or 16dp, and a toggle trades its shape for\n// the other once selected — a round one for the square corner, a square one\n// for the round. The corner eases over the motion tokens' short duration, as\n// the container, label and rule colours and the shadow do between states, and\n// all of them move at once for a reader who asks for reduced motion.\n//\n// The round corner is a length rather than the pill token's 9999px, because\n// the browser draws a corner no larger than half the box and eases the value\n// as written. From 9999px a press spent all but the last frame or two of its\n// 150ms above the 20dp a medium button can show, so the corner held round and\n// then jumped. From half the height every frame of the ease is one the eye\n// can see. A label that wraps makes a button taller than that, and its ends a\n// little less than round, as a connected ButtonGroup's already are.\n//\n// What every button does past its own styles — the ripple, the link and\n// toggle forms, the pending ring and `aria-busy`, a parent's disabled state\n// — is `src/button`'s, shared with IconButton.\n\n/**\n * The press area the buttons page requires, which its two smallest sizes are\n * drawn under. A literal rather than `sizing.controlMd`, which holds the same\n * number, for the reason IconButton's `TARGET_SIZE` gives: a consumer\n * resizing their medium controls should not shrink a target the page states\n * as a floor.\n */\nconst TARGET_SIZE = '48px';\n\n// Windows High Contrast and the rest of the forced-colours modes. Spelled\n// here rather than imported, for the reason src/field/styles.ts records: the\n// StyleX compiler resolves a constant across files only out of a `.stylex.ts`\n// module, and the generated one holds design tokens rather than queries.\nconst FORCED_COLORS = '@media (forced-colors: active)';\nconst styles = {\n base: {\n kGNEyG: \"x6s0dn4\",\n kVAM5u: \"x1ylmb6m\",\n ksu8eU: \"xx61lck\",\n kMzoRj: \"xc342km x13rsnn2\",\n kB7OPa: \"x9f619\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n kMv6JI: \"xkknnkr\",\n kGuDYH: \"x14zspaw\",\n k63SB2: \"x1v9cpvo\",\n kOIVth: \"x126z3so\",\n kjj79g: \"xl56j7k\",\n kb6lSQ: \"x155f00i\",\n kLWn49: \"x1lz68p4\",\n ks0D6T: \"x193iq5w\",\n kHjlTd: \"xj0a0fe\",\n kVAEAm: \"x1n2onr6\",\n k9WMMc: \"x2b8uid\",\n kybGjl: \"x1hl2dhg\",\n kIyJzY: \"x4ukx00 x12w9bfk\",\n k1ekBW: \"xidvh3d\",\n kAMwcw: \"xmg88ys\",\n $$css: true\n },\n disabled: {\n kkrTdU: \"x1h6gzvc\",\n $$css: true\n },\n elevated: {\n kWkggS: \"x1vnz5z6\",\n kGVxlE: \"x19efjv6\",\n kMwMTN: \"x1mxwv8y\",\n $$css: true\n },\n elevatedDisabled: {\n kWkggS: \"xepofeg\",\n kVAM5u: \"xmnqt3w\",\n kGVxlE: \"x1gnnqk1\",\n kMwMTN: \"x1xj74d8 x1bhcspo\",\n $$css: true\n },\n elevatedToggleSelected: {\n kWkggS: \"xnety89 x1jzqe4\",\n kMwMTN: \"xwjo7ld x1k5gbb1\",\n $$css: true\n },\n filled: {\n kWkggS: \"xnety89\",\n kGVxlE: \"x1gnnqk1\",\n kMwMTN: \"xwjo7ld\",\n $$css: true\n },\n filledDisabled: {\n kWkggS: \"xepofeg\",\n kVAM5u: \"xmnqt3w\",\n kGVxlE: \"x1gnnqk1\",\n kMwMTN: \"x1xj74d8 x1bhcspo\",\n $$css: true\n },\n filledToggle: {\n kWkggS: \"x1mjdul6\",\n kMwMTN: \"x1w5n3ug\",\n $$css: true\n },\n filledToggleSelected: {\n kWkggS: \"xnety89 x1jzqe4\",\n kMwMTN: \"xwjo7ld x1k5gbb1\",\n $$css: true\n },\n icon: {\n kGNEyG: \"x6s0dn4\",\n k1xSpc: \"x3nfvp2\",\n kmuXW: \"x2lah0s\",\n kjj79g: \"xl56j7k\",\n $$css: true\n },\n lg: {\n kMv6JI: \"x46eyla\",\n kGuDYH: \"x5ehqhr\",\n k63SB2: \"xrf6cl6\",\n kb6lSQ: \"x1g135zh\",\n kLWn49: \"x1ggk5va\",\n kAzted: \"xdovgog\",\n k8WAf4: \"x1uvvd8r\",\n kg3NbH: \"xg0ps1x\",\n $$css: true\n },\n md: {\n kgeoSG: \"x1cpjm7i\",\n kGOzcv: \"xun2zgk\",\n kpsdNU: \"xm4btww\",\n kEoFBp: \"x1hmns74\",\n kAzted: \"x1cio8j0\",\n k8WAf4: \"x1cmllll\",\n kg3NbH: \"x790zyz\",\n $$css: true\n },\n outlined: {\n kWkggS: \"xjbqb8w\",\n kVAM5u: \"x133yhug\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xmkeg23\",\n kMwMTN: \"x1w5n3ug\",\n $$css: true\n },\n outlinedDisabled: {\n kWkggS: \"xjbqb8w\",\n kVAM5u: \"xrh88j3 xmnqt3w\",\n kMwMTN: \"x1xj74d8 x1bhcspo\",\n $$css: true\n },\n outlinedToggleSelected: {\n kWkggS: \"x1c5gpgi x1jzqe4\",\n kVAM5u: \"x9r1u3d x1n2ykn\",\n kMwMTN: \"x1girmi0 x1k5gbb1\",\n $$css: true\n },\n pending: {\n kkrTdU: \"x19v85br\",\n $$css: true\n },\n text: {\n kWkggS: \"xjbqb8w\",\n kMzoRj: \"xc342km\",\n kMwMTN: \"x1mxwv8y\",\n $$css: true\n },\n textDisabled: {\n kWkggS: \"xjbqb8w\",\n kMwMTN: \"x1xj74d8 x1bhcspo\",\n $$css: true\n },\n tonal: {\n kWkggS: \"x15dekr4\",\n kGVxlE: \"x1gnnqk1\",\n kMwMTN: \"x1sawysd\",\n $$css: true\n },\n tonalDisabled: {\n kWkggS: \"xepofeg\",\n kVAM5u: \"xmnqt3w\",\n kGVxlE: \"x1gnnqk1\",\n kMwMTN: \"x1xj74d8 x1bhcspo\",\n $$css: true\n },\n tonalToggleSelected: {\n kWkggS: \"x167r6xl x1jzqe4\",\n kMwMTN: \"x1lba3jz x1k5gbb1\",\n $$css: true\n },\n xl: {\n kMv6JI: \"x1fz0g89\",\n kGuDYH: \"xkb6epg\",\n k63SB2: \"x76yrz5\",\n kOIVth: \"x1gka490\",\n kb6lSQ: \"x1s1qhaa\",\n kLWn49: \"x1voeury\",\n kAzted: \"x112cvos\",\n k8WAf4: \"xny1cbh\",\n kg3NbH: \"x1sdxjpb\",\n $$css: true\n },\n xs: {\n kgeoSG: \"x1cpjm7i\",\n kGOzcv: \"xun2zgk\",\n kpsdNU: \"x1ecwmwu\",\n kEoFBp: \"x1hmns74\",\n kOIVth: \"xzoy561\",\n kAzted: \"xlzjxrf\",\n k8WAf4: \"xmqoko8\",\n kg3NbH: \"x18fpw6u\",\n $$css: true\n },\n xxl: {\n kMv6JI: \"x1vsmgmf\",\n kGuDYH: \"xh9c4x\",\n k63SB2: \"x1y15vu6\",\n kOIVth: \"xxj4525\",\n kb6lSQ: \"xoqu3bc\",\n kLWn49: \"x10x9d6x\",\n kAzted: \"xldltni\",\n k8WAf4: \"x1lrxzt4\",\n kg3NbH: \"x1dao9b2\",\n $$css: true\n }\n};\n\n// The outlined button's border thickens with the size, as the page's size\n// tokens have it: 1dp up to M, 2dp at L, 3dp at XL. A style per size rather\n// than a value in the size style, since a border on a filled button would\n// draw in the label colour.\nconst OUTLINE_WIDTHS = {\n lg: '1px',\n md: '1px',\n xl: '2px',\n xs: '1px',\n xxl: '3px'\n} as const;\n\n// The outlined button draws its rule inside the width the other variants\n// take, as the page's buttons do: the padding gives up what the border takes,\n// so an outlined and a filled button with one label are one width, and a\n// group mixing them lines up. The height needs nothing, since it is a floor\n// the border already counts towards.\nconst outlinedSizes = {\n lg: {\n kMzoRj: \"xmkeg23\",\n kg3NbH: \"xfeiziq\",\n $$css: true\n },\n md: {\n kMzoRj: \"xmkeg23\",\n kg3NbH: \"x1uvede8\",\n $$css: true\n },\n xl: {\n kMzoRj: \"xdh2fpr\",\n kg3NbH: \"xrhf21y\",\n $$css: true\n },\n xs: {\n kMzoRj: \"xmkeg23\",\n kg3NbH: \"x9t8nta\",\n $$css: true\n },\n xxl: {\n kMzoRj: \"x9r2w2z\",\n kg3NbH: \"x1wz3vkj\",\n $$css: true\n }\n};\n\n// The icon each size draws, from the page's size token sets: 20dp for the\n// two small sizes, then 24, 32 and 40. The gap before it is the size's own,\n// which `base`, `xl` and `xxl` already set as the page gives them.\nconst iconSizes = {\n lg: {\n kGuDYH: \"x1pvqxga\",\n $$css: true\n },\n md: {\n kGuDYH: \"xwsyq91\",\n $$css: true\n },\n xl: {\n kGuDYH: \"x1s3cmhv\",\n $$css: true\n },\n xs: {\n kGuDYH: \"xwsyq91\",\n $$css: true\n },\n xxl: {\n kGuDYH: \"x1tgwohi\",\n $$css: true\n }\n};\n\n// Each size's inline padding again, for the one place it is read at runtime:\n// a standard ButtonGroup widening a pressed button by adding to it. The size\n// styles above write the same values, and an outlined button's border comes\n// off them here as it does in `outlinedSizes`.\nconst PADDINGS = {\n lg: spacing.xl,\n md: spacing.lg,\n xl: '48px',\n xs: spacing.md,\n xxl: '64px'\n};\n\n// The padding a standard group sets while it widens or narrows the button.\nconst shifted = {\n padding: (value: string) => [value !== undefined && {\n kg3NbH: value != null ? \"x30g6up\" : \"\",\n $$css: true\n }, {\n \"--x-paddingInline\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(value)\n }]\n};\n\n// The round corner each size rests at, and a square toggle once selected:\n// half the container's height — see the header for why not the pill's\n// 9999px. `min()` leaves the pill token in charge below that, so a scheme\n// that sets `--kui-radius-pill` small still draws round buttons at its corner.\nconst roundShapes = {\n lg: {\n kaIpWk: \"x1j5kmnq\",\n $$css: true\n },\n md: {\n kaIpWk: \"x1y5wlyh\",\n $$css: true\n },\n xl: {\n kaIpWk: \"x39tcx0\",\n $$css: true\n },\n xs: {\n kaIpWk: \"xcslhsm\",\n $$css: true\n },\n xxl: {\n kaIpWk: \"xjy9rn5\",\n $$css: true\n }\n};\n\n// The square corner each size rests at, and a round toggle once selected.\nconst squareShapes = {\n lg: {\n kaIpWk: \"xhpdng0\",\n $$css: true\n },\n md: {\n kaIpWk: \"x62ce2h\",\n $$css: true\n },\n xl: {\n kaIpWk: \"x19pkqky\",\n $$css: true\n },\n xs: {\n kaIpWk: \"x62ce2h\",\n $$css: true\n },\n xxl: {\n kaIpWk: \"x19pkqky\",\n $$css: true\n }\n};\n\n// The corner each size presses to, whatever its shape. Applied after the\n// resting and selected shapes, so a press is felt whichever the button rests\n// at.\nconst pressedShapes = {\n lg: {\n kaIpWk: \"x62ce2h\",\n $$css: true\n },\n md: {\n kaIpWk: \"x1xdvaa9\",\n $$css: true\n },\n xl: {\n kaIpWk: \"xhpdng0\",\n $$css: true\n },\n xs: {\n kaIpWk: \"x1xdvaa9\",\n $$css: true\n },\n xxl: {\n kaIpWk: \"xhpdng0\",\n $$css: true\n }\n};\n\n// The interaction state layers, one style per variant for each state, applied\n// from React Aria's render state — see the header for why that and not the\n// pseudo-classes. In the order they are applied, so where two hold the later\n// wins, as the page draws one layer at a time: focus over hover, and a press\n// over both. Hover lifts filled and tonal off the page and raises elevated a\n// level, and a press brings each back to where it rests.\n//\n// A toggle's containers carry a layer of their own, each the label colour\n// over that container, applied after the variant's so the variant still\n// decides the shadow. A selected toggle's keeps its forced-colours\n// `Highlight`, since a later style replaces the property whole.\nconst hovered = {\n elevated: {\n kWkggS: \"xltxkvm\",\n kGVxlE: \"x1os83gw\",\n $$css: true\n },\n elevatedToggleSelected: {\n kWkggS: \"xo1ct44 x1jzqe4\",\n $$css: true\n },\n filled: {\n kWkggS: \"xo1ct44\",\n kGVxlE: \"x19efjv6\",\n $$css: true\n },\n filledToggle: {\n kWkggS: \"xtxe0ya\",\n $$css: true\n },\n filledToggleSelected: {\n kWkggS: \"xo1ct44 x1jzqe4\",\n $$css: true\n },\n outlined: {\n kWkggS: \"x14noynh\",\n $$css: true\n },\n outlinedToggleSelected: {\n kWkggS: \"x1hxzsxp x1jzqe4\",\n $$css: true\n },\n text: {\n kWkggS: \"x659ado\",\n $$css: true\n },\n tonal: {\n kWkggS: \"x1fctxn6\",\n kGVxlE: \"x19efjv6\",\n $$css: true\n },\n tonalToggleSelected: {\n kWkggS: \"x12r95rf x1jzqe4\",\n $$css: true\n }\n};\nconst focused = {\n elevated: {\n kWkggS: \"xcn1wy9\",\n $$css: true\n },\n elevatedToggleSelected: {\n kWkggS: \"xhodiby x1jzqe4\",\n $$css: true\n },\n filled: {\n kWkggS: \"xhodiby\",\n $$css: true\n },\n filledToggle: {\n kWkggS: \"x1ppcb1\",\n $$css: true\n },\n filledToggleSelected: {\n kWkggS: \"xhodiby x1jzqe4\",\n $$css: true\n },\n outlined: {\n kWkggS: \"x19p5drm\",\n $$css: true\n },\n outlinedToggleSelected: {\n kWkggS: \"xn4e5mw x1jzqe4\",\n $$css: true\n },\n text: {\n kWkggS: \"x1sog3nf\",\n $$css: true\n },\n tonal: {\n kWkggS: \"x1s5x49g\",\n $$css: true\n },\n tonalToggleSelected: {\n kWkggS: \"x16tkg7c x1jzqe4\",\n $$css: true\n }\n};\n\n// The pressed layer of a button whose ripple is off, drawn in the ripple's\n// place — see the header. Its shadow is the variant's resting one, which the\n// hover's lift no longer covers while the button is pressed.\nconst pressed = {\n elevated: {\n kWkggS: \"x1d33wxb\",\n $$css: true\n },\n elevatedToggleSelected: {\n kWkggS: \"x7b25lv x1jzqe4\",\n $$css: true\n },\n filled: {\n kWkggS: \"x7b25lv\",\n $$css: true\n },\n filledToggle: {\n kWkggS: \"x1qdfkg1\",\n $$css: true\n },\n filledToggleSelected: {\n kWkggS: \"x7b25lv x1jzqe4\",\n $$css: true\n },\n outlined: {\n kWkggS: \"x123fei2\",\n $$css: true\n },\n outlinedToggleSelected: {\n kWkggS: \"x167cdfs x1jzqe4\",\n $$css: true\n },\n text: {\n kWkggS: \"x1dvjsmr\",\n $$css: true\n },\n tonal: {\n kWkggS: \"xzpauq9\",\n $$css: true\n },\n tonalToggleSelected: {\n kWkggS: \"x12o6fnv x1jzqe4\",\n $$css: true\n }\n};\nconst disabledStyles = {\n elevated: styles.elevatedDisabled,\n filled: styles.filledDisabled,\n outlined: styles.outlinedDisabled,\n text: styles.textDisabled,\n tonal: styles.tonalDisabled\n};\n\n// Which container a toggle draws, selected and not, by its name in the\n// tables above. Three of the eight are the plain button's own: an unselected\n// tonal, elevated or outlined toggle is the tonal, elevated or outlined\n// button.\nconst toggleContainers = {\n elevated: {\n selected: 'elevatedToggleSelected',\n unselected: 'elevated'\n },\n filled: {\n selected: 'filledToggleSelected',\n unselected: 'filledToggle'\n },\n outlined: {\n selected: 'outlinedToggleSelected',\n unselected: 'outlined'\n },\n tonal: {\n selected: 'tonalToggleSelected',\n unselected: 'tonal'\n }\n} as const;\ntype ButtonProps = ButtonDOMProps & (ButtonLinkForm | ButtonPressForm | (ButtonToggleForm & {\n /**\n * A toggle takes any variant but `text`, which the page gives no\n * selected colours.\n */\n variant?: Exclude<ButtonVariant, 'text'>;\n})) & {\n children?: ReactNode;\n /** A function may compute the class from the button's render state. */\n className?: ClassNameOrFunction<ButtonState>;\n /**\n * Disables the press ripple. A press then draws its layer as a background\n * instead, at the same pressed opacity, so the button reads the same\n * either way. The hover and focus layers are unaffected.\n * @default false\n */\n disableRipple?: boolean;\n /**\n * An icon before the label, at the page's icon size for the button's size:\n * 20px at `xs` and `md`, 24px at `lg`, 32px at `xl` and 40px at `xxl`. Draw\n * it `1em` square in `currentColor`, as every icon here is, and it follows.\n * Hidden with the label while the button is pending.\n */\n icon?: ReactNode;\n /**\n * The name of the ring shown while the button is pending, for a screen\n * reader. The label it replaces is hidden while it shows. Left out, it is\n * the word for it in the I18nProvider's locale — \"Loading\" in English.\n */\n pendingLabel?: string;\n /**\n * The corner the button rests at: `round` is the pill, `square` the\n * page's rounded rectangle, 12px up to `md`, 16px at `lg` and 28px above.\n * Either tightens while pressed, and a toggle trades one for the other\n * once selected.\n * @default 'round'\n */\n shape?: ButtonShape;\n /**\n * Control height: `xs` 32px, `md` 40px, `lg` 56px, `xl` 96px, `xxl` 136px —\n * the buttons spec page's XS, S, M, L and XL, each with its own inline\n * padding and type role. `md` is the page's default.\n * @default 'md'\n */\n size?: ButtonSize;\n /** A function may compute the style from the button's render state. */\n style?: StyleOrFunction<ButtonState>;\n /**\n * How much weight the button pulls. `filled` and `tonal` carry a container\n * of their own; `outlined` and `text` sit on the page; `elevated` sits on\n * a low surface and lifts off it with a shadow, for a button that has to\n * separate from a busy background rather than from the page.\n * @default 'filled'\n */\n variant?: ButtonVariant;\n};\ntype ButtonShape = 'round' | 'square';\ntype ButtonSize = 'lg' | 'md' | 'xl' | 'xs' | 'xxl';\ntype ButtonVariant = 'elevated' | 'filled' | 'outlined' | 'text' | 'tonal';\n\n// The four styles the page gives a toggle's colour pairs; see the header.\ntype ToggleVariant = keyof typeof toggleContainers;\n\n/**\n * The design's button, at five emphasis levels and five control heights,\n * round or square. Given `href` it is a link with the same appearance. Every\n * `aria-*` prop is forwarded to the element; React Aria alone would keep only\n * the labelling ones.\n *\n * Given `isSelected`, `defaultSelected` or `onChange` it is a toggle, which\n * reports its state through `aria-pressed` and draws the page's second pair\n * of colour roles for its variant. The three forms are exclusive, so a toggle\n * given `href` does not compile, and nor does a `text` toggle, which the page\n * gives no selected colours — a `text` button in a selecting `ButtonGroup`\n * is the one that toggles, for the group's sake. A toggle may be pending,\n * for a state saved somewhere slow: the ring replaces its label and a press\n * changes nothing until it clears.\n *\n * ```tsx\n * <Button defaultSelected variant=\"tonal\">\n * Label\n * </Button>\n * ```\n */\nfunction Button({\n children,\n defaultSelected,\n href,\n icon,\n isPending,\n isSelected,\n onChange,\n pendingLabel,\n rel,\n shape = 'round',\n size: ownSize,\n target,\n variant = 'filled',\n ...props\n}: ButtonProps & RefAttributes<HTMLAnchorElement | HTMLButtonElement>) {\n // A ButtonGroup or a SplitButton around the button hands it a size, its\n // shape at the group's inner edges and the press interaction; see\n // src/button/context.ts. A size named here still wins.\n const group = useContext(ButtonGroupItemContext);\n const size = ownSize ?? group?.size ?? 'md';\n // A group that selects is React Aria's ToggleButtonGroup, whose buttons\n // have to be toggles to take part in its selection.\n const inSelectingGroup = useContext(ToggleGroupStateContext) !== null;\n const grouped = groupPressHandlers(group, props.onPressStart, props.onPressEnd);\n const onPressEnd = grouped.onPressEnd ?? props.onPressEnd;\n const onPressStart = grouped.onPressStart ?? props.onPressStart;\n const selection = useSelection({\n defaultSelected,\n isSelected,\n onChange\n });\n // Whether a key holds the button down, which the ripple does not draw\n // until the key is released, so the pressed layer draws in its place.\n const [keyHeld, setKeyHeld] = useState(false);\n const press = {\n onPressEnd: (event: PressEvent) => {\n setKeyHeld(false);\n onPressEnd?.(event);\n },\n onPressStart: (event: PressEvent) => {\n setKeyHeld(event.pointerType === 'keyboard');\n onPressStart?.(event);\n }\n };\n const ripples = props.disableRipple !== true && !keyHeld;\n\n // The icon goes in with the label, inside what ButtonBase hides while the\n // button is pending, so the ring takes the place of both.\n const content = icon === undefined ? children : <>\n <span {...stylex.props(styles.icon, iconSizes[size])}>{icon}</span>\n {children}\n </>;\n\n // A selecting ButtonGroup around it makes it React Aria's ToggleButton, to\n // take part in the group's selection — a text button too, which draws its\n // selection by nothing but the group's shape. Whether a button sits in one\n // does not change from one render to the next.\n if (inSelectingGroup) {\n return <ToggleButtonBase {...props} {...press} classes={variant === 'text' ? buttonClasses(shape, size, variant, group, ripples) : toggleClasses(shape, size, variant, group, ripples)} isPending={isPending}>\n {content}\n </ToggleButtonBase>;\n }\n\n // The three props that make this a toggle on its own, read as IconButton\n // reads them, and on the same component as the plain button so a toggle\n // whose `isSelected` is still loading stays one element when it arrives.\n // The types keep them off a `text` button; the check here keeps a call\n // site that slipped past them a plain button, as it always was.\n const isToggle = variant !== 'text' && (defaultSelected !== undefined || isSelected !== undefined || onChange !== undefined);\n return <ButtonBase {...props} {...press} classes={isToggle ? toggleClasses(shape, size, variant, group, ripples) : buttonClasses(shape, size, variant, group, ripples)} href={href} isPending={isPending} isSelected={isToggle ? selection.selected : undefined} onPress={isToggle ? pressThen(props.onPress, selection.toggle) : props.onPress} pendingLabel={pendingLabel} rel={rel} target={target}>\n {content}\n </ButtonBase>;\n}\n\n// The button's own classes, from React Aria's render state — see the header\n// for why that and not the pseudo-classes, and for why a press drops the\n// hover layer and draws its own only where the ripple does not. Built by a\n// call rather than written inline at the prop, which is what react-perf's\n// no-new-function-as-prop is after; the React Compiler memoises the result on\n// its inputs.\nfunction buttonClasses(shape: ButtonShape, size: ButtonSize, variant: ButtonVariant, group: ButtonGroupItem | null, ripples: boolean) {\n return (state: ButtonClassesState) => stylex.props(styles.base, focus.ring, styles[variant], styles[size], shape === 'square' ? squareShapes[size] : roundShapes[size], variant === 'outlined' && outlinedSizes[size], state.isHovered && !state.isPressed && hovered[variant], state.isFocusVisible && focused[variant], state.isPressed && !ripples && pressed[variant], state.isPressed && pressedShapes[size], groupStyles(group, size, variant, state), state.isPending === true && styles.pending, state.isDisabled && styles.disabled, state.isDisabled && disabledStyles[variant]);\n}\n\n// What a group lays over the button: its own styles for the button's state,\n// and the standard group's widening or narrowing as extra inline padding,\n// half of the shift on either side.\nfunction groupStyles(group: ButtonGroupItem | null, size: ButtonSize, variant: ButtonVariant, state: ButtonState) {\n if (group === null) {\n return null;\n }\n const border = variant === 'outlined' ? OUTLINE_WIDTHS[size] : '0px';\n return [group.styles?.(state), group.shift !== 0 && shifted.padding(`calc(${PADDINGS[size]} - ${border} + ${group.shift / 2}px)`)];\n}\n\n// A toggle's classes: the plain button's, with the container and its layers\n// swapped for the toggle's pair, and the selected shape between the resting\n// and the pressed one. The variant's own style and layers still go first, for\n// the shadow and the rule they carry. Built by a call for the reason\n// `buttonClasses` is.\nfunction toggleClasses(shape: ButtonShape, size: ButtonSize, variant: ToggleVariant, group: ButtonGroupItem | null, ripples: boolean) {\n return (state: ButtonClassesState) => {\n const isSelected = state.isSelected === true;\n const container = toggleContainers[variant][isSelected ? 'selected' : 'unselected'];\n return stylex.props(styles.base, focus.ring, styles[variant], styles[container], styles[size], shape === 'square' ? squareShapes[size] : roundShapes[size], isSelected && (shape === 'square' ? roundShapes[size] : squareShapes[size]), variant === 'outlined' && outlinedSizes[size], state.isHovered && !state.isPressed && hovered[variant], state.isHovered && !state.isPressed && hovered[container], state.isFocusVisible && focused[variant], state.isFocusVisible && focused[container], state.isPressed && !ripples && pressed[variant], state.isPressed && !ripples && pressed[container], state.isPressed && pressedShapes[size], groupStyles(group, size, variant, state), state.isPending === true && styles.pending, state.isDisabled && styles.disabled, state.isDisabled && disabledStyles[variant]);\n };\n}\nexport type { ButtonDOMProps, ButtonProps, ButtonShape, ButtonSize, ButtonState, ButtonVariant };\nexport default Button;"],"mappings":";;;;;;;;;;;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CACpI,QAAQS,UAA8B;EACpC,MAAM9B,aAAa8B,MAAM9B,eAAe;EACxC,MAAMuC,YAAYtD,iBAAiBG,QAAQ,CAACY,aAAa,aAAa;EACtE,OAAOrG,MAAaU,OAAOC,MAAMH,MAAM4H,MAAM1H,OAAO+E,UAAU/E,OAAOkI,YAAYlI,OAAOoF,OAAOD,UAAU,WAAWb,aAAac,QAAQhB,YAAYgB,OAAOO,eAAeR,UAAU,WAAWf,YAAYgB,QAAQd,aAAac,QAAQL,YAAY,cAAcnB,cAAcwB,OAAOqC,MAAME,aAAa,CAACF,MAAMG,aAAapD,QAAQO,UAAU0C,MAAME,aAAa,CAACF,MAAMG,aAAapD,QAAQ0D,YAAYT,MAAMI,kBAAkBpD,QAAQM,UAAU0C,MAAMI,kBAAkBpD,QAAQyD,YAAYT,MAAMG,aAAa,CAACZ,WAAWtC,QAAQK,UAAU0C,MAAMG,aAAa,CAACZ,WAAWtC,QAAQwD,YAAYT,MAAMG,aAAarD,cAAca,OAAO0C,YAAY3B,OAAOf,MAAML,SAAS0C,KAAK,GAAGA,MAAM/B,cAAc,QAAQ1F,OAAOkD,SAASuE,MAAMM,cAAc/H,OAAOyB,UAAUgG,MAAMM,cAAcpD,eAAeI,QAAQ;CACtxB;AACF"}
|
|
@@ -126,6 +126,13 @@ function cellClassNameIn(calendar) {
|
|
|
126
126
|
* Held means what React Aria would have called selected with the calendar
|
|
127
127
|
* enabled: the value, inside the bounds, and in its own month's grid rather
|
|
128
128
|
* than a neighbour's, which the classes check.
|
|
129
|
+
*
|
|
130
|
+
* Every cell of the month renders again on each focus move, and the React
|
|
131
|
+
* Compiler's memoisation of this one does not hold. React Aria's grid builds
|
|
132
|
+
* a new `CalendarDate` for every cell on every render, so `date` is a new
|
|
133
|
+
* prop each time, and `CalendarStateContext` changes with each move, which
|
|
134
|
+
* React Aria's own cell reads as well as this one. Rendering only the cells a
|
|
135
|
+
* move changes would take a copy of React Aria's `CalendarCell`.
|
|
129
136
|
*/
|
|
130
137
|
function DateCell(t0) {
|
|
131
138
|
const $ = c(8);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_c","isSameDay","stylex","useContext","CalendarStateContext","Calendar","RACCalendar","RACCalendarCell","calendarStyles","dateLayers","invalidFrom","fieldChromeStyles","focus","mergeStatefulStyles","className","error","showMonthYearMenus","isHeldWhileDisabled","isReadOnly","t0","$","T0","props","t1","t2","t3","t4","t5","t6","undefined","root","visibleDuration","months","isInvalid","gridCell","message","messageError","cellClassName","state","calendar","cell","ring","isToday","cellToday","isSelected","cellSelected","cellInvalid","cellReadOnly","isHovered","hoveredLayer","isPressed","pressedLayer","isUnavailable","cellUnavailable","isDisabled","cellDisabled","isOutsideMonth","cellSelectedDisabled","cellClassNameIn","DateCell","date","holds","value","some","entry","plainHovered","invalidHovered","selectedHovered","plainPressed","invalidPressed","selectedPressed","RACText"],"sources":["../../../src/components/calendar/index.tsx"],"sourcesContent":["'use client';\n\nimport type { CalendarDate } from '@internationalized/date';\nimport type { ReactElement, RefAttributes } from 'react';\nimport type { CalendarCellRenderProps, CalendarRenderProps, DateValue, CalendarProps as RACCalendarProps } from 'react-aria-components';\nimport { isSameDay } from '@internationalized/date';\nimport * as stylex from '@stylexjs/stylex';\nimport { useContext } from 'react';\nimport { CalendarStateContext, Calendar as RACCalendar, CalendarCell as RACCalendarCell, Text as RACText } from 'react-aria-components';\nimport { CalendarFrame, CalendarMonths } from '../../calendar';\nimport { calendarStyles, dateLayers } from '../../calendar/styles';\nimport { invalidFrom } from '../../field/root';\nimport { fieldChromeStyles } from '../../field/styles';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\n\n// The date pickers page's docked calendar: a month grid with a circle on the\n// selected date and an outline on today. Its values are that page's — a\n// 360dp container on the high surface container, 48dp date cells with a 40dp\n// state layer inside them, body-large for both the weekday row and the dates,\n// primary for the selected circle and for today's outline.\n//\n// The page's container is 456dp tall, which this does not take: that height\n// is a picker's, counting a headline and an action row the calendar itself\n// does not draw. What is held instead is the grid, at six weeks — the most\n// any month occupies — so the calendar keeps its height as the month moves\n// and a shorter month leaves its last rows empty. `months` in\n// `src/calendar/styles.ts` is where the room is reserved.\n//\n// `showMonthYearMenus` draws the page's docked header instead of one heading:\n// the month's menu button between the chevrons that step it and the year's\n// after them, each opening its list where the grid was. The parts are in\n// `src/calendar`, shared with RangeCalendar.\n//\n// The calendar's own disabled, read-only and invalid states are drawn on its\n// dates, from React Aria's calendar state rather than each date's, since\n// that is the one place all three are known:\n//\n// - **Disabled** fades every date, the weekday row, the chevrons and the\n// menu buttons to the page's 38%, and keeps the date it holds as a\n// disabled filled circle — React Aria stops calling a disabled date\n// selected, which left the calendar looking empty.\n// - **Read-only** keeps every date at full strength, since it still reports\n// a value, but drops the pointer and the state layers from the dates, which\n// a press no longer changes. The chevrons and the menus still move the\n// month, so they keep theirs.\n// - **Invalid** draws the date held in the error and on error roles, and\n// `error` writes the reason under the months in the field's supporting\n// type and error colour. Each date React Aria marks invalid points\n// `aria-describedby` at it, so a screen reader hears why as well as that.\n//\n// Five things are this component's own.\n//\n// **The year menu has no chevrons of its own.** The page draws a pair either\n// side of it that step a year, which would need two names React Aria has no\n// message for — the library writes a word of its own only behind a prop that\n// can replace it, and it would take a pair on four components. The year list\n// reaches any year within a century of the one shown in one press, or any\n// the bounds allow where they are closer, and Shift with Page Up or Page\n// Down steps a year from the keyboard.\n//\n// **The cell is a circle in a square.** The page gives the date a 48dp\n// container and a 40dp state layer, which is a 40dp circle with 4dp of room\n// around it. The circle is the element, centred in a 48dp column and a 48dp\n// row — the pitch Compose lays its days at — and a transparent box reaching\n// the 4dp past it on every side makes the whole square the press target,\n// rather than a 48dp box with a 40dp box inside it. The chevrons and the\n// month and year menu buttons reach a 48dp target the same way.\n//\n// **It narrows to its container.** The page's docked calendar is 360dp, and\n// a compact window leaves 328dp between its margins, so the calendar is 360\n// at most and the columns share whatever is left below that. Under about\n// 304dp of content a column is narrower than its 40dp circle, and the\n// circles of neighbouring dates meet.\n//\n// **A date from the month either side is faded because it is disabled, not\n// because it is outside.** React Aria marks those cells `data-outside-month`\n// and disables them in the same breath, so a treatment keyed on the first\n// would never draw anything the second had not already drawn. The disabled\n// fade is the page's 38% either way.\n//\n// **Today reads as today whether or not it is selected.** The page gives it\n// an outline and the primary label; selected gives it a filled circle and the\n// on-primary label. A selected today takes the fill, since a circle already\n// says where you are and two rings would say it twice.\n//\n// **The month is moved by IconButton's shape rather than by IconButton.**\n// React Aria wires `slot=\"previous\"` and `slot=\"next\"` on its own `Button`,\n// and IconButton renders React Aria's `Button` too — so nesting one inside\n// the slot would put two buttons where the page draws one. The chevrons take\n// the standard icon button's 40dp square and its state layer instead.\n\ntype CalendarProps<T extends DateValue = DateValue> = {\n /** A function may compute the class from the calendar's render state. */\n className?: RACCalendarProps<T>['className'];\n /**\n * The message shown under the months, which also marks the calendar\n * invalid: the date it holds turns to the error colours, and React Aria\n * points that date's description at the message. `isInvalid` on its own\n * marks the date with no message.\n */\n error?: string;\n /**\n * Whether the header draws the month and the year as menu buttons, each\n * opening a list of them in the grid's place, as the docked date picker's\n * header does, rather than one heading between the chevrons. For a date\n * far from the one shown, such as a date of birth: the year list runs a\n * century either side of the year shown, or to `minValue` and `maxValue`\n * where they are closer.\n *\n * For one visible month. With `visibleDuration` of more than one, the\n * header is the plain one, whose heading names every month shown — the\n * menus name only the first, which would leave the others unlabelled.\n * @default false\n */\n showMonthYearMenus?: boolean;\n /** A function may compute the style from the calendar's render state. */\n style?: RACCalendarProps<T>['style'];\n} & Omit<RACCalendarProps<T>, 'children' | 'className' | 'style'>;\n\n/** What a date's classes read off the calendar around it. */\ntype CalendarStates = {\n /**\n * Whether this date is the one a disabled calendar holds, inside its\n * bounds. A copy of it in a neighbouring month's grid is told apart by\n * React Aria's own `isOutsideMonth`.\n */\n isHeldWhileDisabled: boolean;\n isReadOnly: boolean;\n};\n\n/**\n * A month calendar for picking a date. The value is React Aria's: pass\n * `value` with `onChange` to control it, or `defaultValue` to let it keep its\n * own, both as an `@internationalized/date` value from this package's\n * `./date` subpath.\n *\n * ```tsx\n * import { today, getLocalTimeZone } from '@kanso-labs/kanso-ui/date'\n *\n * <Calendar aria-label=\"Label\" defaultValue={today(getLocalTimeZone())} />\n * ```\n *\n * `minValue` and `maxValue` bound it, `isDateUnavailable` rules individual\n * dates out, and `visibleDuration` of `{ months: 2 }` draws two months side\n * by side, stacked below the expanded breakpoint with each month named over\n * its grid. Name it with `aria-label` or `aria-labelledby`; React Aria\n * composes the visible month into that name itself.\n *\n * The call site's `className` and `style` land on the container, which is the\n * element a layout positions.\n */\nfunction Calendar<T extends DateValue>({\n error,\n showMonthYearMenus = false,\n ...props\n}: CalendarProps<T> & RefAttributes<HTMLDivElement>) {\n return <RACCalendar<T> isInvalid={invalidFrom(error)} {...props} {...mergeStatefulStyles(stylex.props(calendarStyles.root), props)}>\n {({\n isInvalid\n }: CalendarRenderProps) => <>\n <CalendarFrame months={props.visibleDuration?.months ?? 1} showMonthYearMenus={showMonthYearMenus}>\n <CalendarMonths months={props.visibleDuration?.months ?? 1}>\n {gridCell}\n </CalendarMonths>\n </CalendarFrame>\n {/*\n * Through React Aria's error slot, which gives it the id an\n * invalid date's `aria-describedby` names. Drawn only while the\n * calendar is invalid: React Aria looks for the element when\n * `isInvalid` changes, which is when this appears and goes.\n */}\n {isInvalid && error !== undefined ? <RACText slot=\"errorMessage\" {...stylex.props(fieldChromeStyles.message, fieldChromeStyles.messageError)}>\n {error}\n </RACText> : null}\n </>}\n </RACCalendar>;\n}\n\n// A date's classes, from React Aria's render state and the calendar's.\n// StyleX cannot target `[data-selected]` on the element it is styling, so the\n// state comes from what React Aria hands the className.\n//\n// The order matters. `selected` is applied after `today`, so a selected today\n// takes the fill rather than the outline — a circle already says where you\n// are, and two rings would say it twice — and `invalid` after `selected`,\n// which it repaints. The hover and pressed layers come next, over whichever\n// ground the date has, a press over a hover. A read-only calendar takes no\n// hover layer, and React Aria reports no press there to draw one for.\n// `unavailable` and `disabled` come last, and StyleX replaces a property\n// whole, so they take the layers with them; the date a disabled calendar\n// holds then puts its disabled circle back.\nfunction cellClassName(state: CalendarCellRenderProps, calendar: CalendarStates) {\n return stylex.props(calendarStyles.cell, focus.ring, state.isToday && calendarStyles.cellToday, state.isSelected && calendarStyles.cellSelected, state.isSelected && state.isInvalid && calendarStyles.cellInvalid, calendar.isReadOnly && calendarStyles.cellReadOnly, !calendar.isReadOnly && state.isHovered && hoveredLayer(state), state.isPressed && pressedLayer(state), state.isUnavailable && calendarStyles.cellUnavailable, state.isDisabled && calendarStyles.cellDisabled, calendar.isHeldWhileDisabled && !state.isOutsideMonth && calendarStyles.cellSelectedDisabled).className ?? '';\n}\n\n// The calendar's part of a date's classes, bound once per date. Built by a\n// call rather than written inline at the prop, which is what react-perf's\n// no-new-function-as-prop is after.\nfunction cellClassNameIn(calendar: CalendarStates) {\n return (state: CalendarCellRenderProps) => cellClassName(state, calendar);\n}\n\n/**\n * One date. React Aria's cell, with what its classes need from the calendar\n * read from React Aria's calendar state: whether it is read-only, and the\n * date it holds, which React Aria hides from the cell itself once the\n * calendar is disabled.\n *\n * Held means what React Aria would have called selected with the calendar\n * enabled: the value, inside the bounds, and in its own month's grid rather\n * than a neighbour's, which the classes check.\n */\nfunction DateCell({\n date\n}: {\n date: CalendarDate;\n}): ReactElement {\n const calendar = useContext(CalendarStateContext);\n const isHeldWhileDisabled = calendar !== null && calendar.isDisabled && !calendar.isInvalid(date) && holds(calendar.value, date);\n return <RACCalendarCell className={cellClassNameIn({\n isHeldWhileDisabled,\n isReadOnly: calendar?.isReadOnly ?? false\n })} date={date} />;\n}\nfunction gridCell(date: CalendarDate): ReactElement {\n return <DateCell date={date} />;\n}\n\n// Whether a calendar's value includes a date: one date, or several where the\n// calendar takes more than one.\nfunction holds(value: CalendarDate | null | readonly (CalendarDate | null)[], date: CalendarDate) {\n const held = value !== null && 'length' in value ? value : [value];\n return held.some(entry => entry !== null && isSameDay(entry, date));\n}\nfunction hoveredLayer(state: CalendarCellRenderProps) {\n if (!state.isSelected) {\n return dateLayers.plainHovered;\n }\n return state.isInvalid ? dateLayers.invalidHovered : dateLayers.selectedHovered;\n}\nfunction pressedLayer(state: CalendarCellRenderProps) {\n if (!state.isSelected) {\n return dateLayers.plainPressed;\n }\n return state.isInvalid ? dateLayers.invalidPressed : dateLayers.selectedPressed;\n}\nexport type { CalendarProps };\nexport default Calendar;"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwJA,SAAAK,SAAAc,IAAA;CAAA,MAAAC,IAAApB,EAAA,EAAA;CAAA,IAAAqB;CAAA,IAAAN;CAAA,IAAAO;CAAA,IAAAN;CAAA,IAAAO;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAL,EAAA,OAAAD,IAAA;EAAuC,MAAA,EAAAJ,OAAAW,IAAAV,oBAAAW,IAAA,GAAAC,OAAAT;EAAAJ,QAAAW;EAAAJ,UAAAM;EAErCZ,qBAAAW,OAAAE,KAAAA,IAAA,QAAAF;EAGQN,KAAAf;EAAW,IAAAc,EAAA,OAAAL,OAAA;GAAeQ,KAAAb,YAAYK,KAAK;GAACK,EAAA,KAAAL;GAAAK,EAAA,KAAAG;EAAA,OAAAA,KAAAH,EAAA;EAAME,KAAAA;EAAWG,KAAAZ,oBAAoBX,MAAaM,eAAcsB,IAAK,GAAGR,OAAK;EAACF,EAAA,KAAAD;EAAAC,EAAA,KAAAC;EAAAD,EAAA,KAAAL;EAAAK,EAAA,KAAAE;EAAAF,EAAA,KAAAJ;EAAAI,EAAA,KAAAG;EAAAH,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;CAAA,OAAA;EAAAJ,KAAAD,EAAA;EAAAL,QAAAK,EAAA;EAAAE,UAAAF,EAAA;EAAAJ,qBAAAI,EAAA;EAAAG,KAAAH,EAAA;EAAAI,KAAAJ,EAAA;EAAAK,KAAAL,EAAA;CAAA;CAAA,IAAAM;CAAA,IAAAN,EAAA,QA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ASU,SAAS0B,MAAkC;CAClD,OAAO,oBAAC,UAAD,EAAgBA,KAAK,CAAA;AAC9B;AAIA,SAASC,MAAMC,OAA+DF,MAAoB;CAEhG,QADaE,UAAU,QAAQ,YAAYA,QAAQA,QAAQ,CAACA,KAAK,EAAA,CACrDC,MAAKC,UAASA,UAAU,QAAQ/D,UAAU+D,OAAOJ,IAAI,CAAC;AACpE;AACA,SAASX,aAAaX,OAAgC;CACpD,IAAI,CAACA,MAAMM,YACT,OAAOnC,WAAWwD;CAEpB,OAAO3B,MAAML,YAAYxB,WAAWyD,iBAAiBzD,WAAW0D;AAClE;AACA,SAAShB,aAAab,OAAgC;CACpD,IAAI,CAACA,MAAMM,YACT,OAAOnC,WAAW2D;CAEpB,OAAO9B,MAAML,YAAYxB,WAAW4D,iBAAiB5D,WAAW6D;AAClE"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_c","isSameDay","stylex","useContext","CalendarStateContext","Calendar","RACCalendar","RACCalendarCell","calendarStyles","dateLayers","invalidFrom","fieldChromeStyles","focus","mergeStatefulStyles","className","error","showMonthYearMenus","isHeldWhileDisabled","isReadOnly","t0","$","T0","props","t1","t2","t3","t4","t5","t6","undefined","root","visibleDuration","months","isInvalid","gridCell","message","messageError","cellClassName","state","calendar","cell","ring","isToday","cellToday","isSelected","cellSelected","cellInvalid","cellReadOnly","isHovered","hoveredLayer","isPressed","pressedLayer","isUnavailable","cellUnavailable","isDisabled","cellDisabled","isOutsideMonth","cellSelectedDisabled","cellClassNameIn","DateCell","date","holds","value","some","entry","plainHovered","invalidHovered","selectedHovered","plainPressed","invalidPressed","selectedPressed","RACText"],"sources":["../../../src/components/calendar/index.tsx"],"sourcesContent":["'use client';\n\nimport type { CalendarDate } from '@internationalized/date';\nimport type { ReactElement, RefAttributes } from 'react';\nimport type { CalendarCellRenderProps, CalendarRenderProps, DateValue, CalendarProps as RACCalendarProps } from 'react-aria-components';\nimport { isSameDay } from '@internationalized/date';\nimport * as stylex from '@stylexjs/stylex';\nimport { useContext } from 'react';\nimport { CalendarStateContext, Calendar as RACCalendar, CalendarCell as RACCalendarCell, Text as RACText } from 'react-aria-components';\nimport { CalendarFrame, CalendarMonths } from '../../calendar';\nimport { calendarStyles, dateLayers } from '../../calendar/styles';\nimport { invalidFrom } from '../../field/root';\nimport { fieldChromeStyles } from '../../field/styles';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\n\n// The date pickers page's docked calendar: a month grid with a circle on the\n// selected date and an outline on today. Its values are that page's — a\n// 360dp container on the high surface container, 48dp date cells with a 40dp\n// state layer inside them, body-large for both the weekday row and the dates,\n// primary for the selected circle and for today's outline.\n//\n// The page's container is 456dp tall, which this does not take: that height\n// is a picker's, counting a headline and an action row the calendar itself\n// does not draw. What is held instead is the grid, at six weeks — the most\n// any month occupies — so the calendar keeps its height as the month moves\n// and a shorter month leaves its last rows empty. `months` in\n// `src/calendar/styles.ts` is where the room is reserved.\n//\n// `showMonthYearMenus` draws the page's docked header instead of one heading:\n// the month's menu button between the chevrons that step it and the year's\n// after them, each opening its list where the grid was. The parts are in\n// `src/calendar`, shared with RangeCalendar.\n//\n// The calendar's own disabled, read-only and invalid states are drawn on its\n// dates, from React Aria's calendar state rather than each date's, since\n// that is the one place all three are known:\n//\n// - **Disabled** fades every date, the weekday row, the chevrons and the\n// menu buttons to the page's 38%, and keeps the date it holds as a\n// disabled filled circle — React Aria stops calling a disabled date\n// selected, which left the calendar looking empty.\n// - **Read-only** keeps every date at full strength, since it still reports\n// a value, but drops the pointer and the state layers from the dates, which\n// a press no longer changes. The chevrons and the menus still move the\n// month, so they keep theirs.\n// - **Invalid** draws the date held in the error and on error roles, and\n// `error` writes the reason under the months in the field's supporting\n// type and error colour. Each date React Aria marks invalid points\n// `aria-describedby` at it, so a screen reader hears why as well as that.\n//\n// Five things are this component's own.\n//\n// **The year menu has no chevrons of its own.** The page draws a pair either\n// side of it that step a year, which would need two names React Aria has no\n// message for — the library writes a word of its own only behind a prop that\n// can replace it, and it would take a pair on four components. The year list\n// reaches any year within a century of the one shown in one press, or any\n// the bounds allow where they are closer, and Shift with Page Up or Page\n// Down steps a year from the keyboard.\n//\n// **The cell is a circle in a square.** The page gives the date a 48dp\n// container and a 40dp state layer, which is a 40dp circle with 4dp of room\n// around it. The circle is the element, centred in a 48dp column and a 48dp\n// row — the pitch Compose lays its days at — and a transparent box reaching\n// the 4dp past it on every side makes the whole square the press target,\n// rather than a 48dp box with a 40dp box inside it. The chevrons and the\n// month and year menu buttons reach a 48dp target the same way.\n//\n// **It narrows to its container.** The page's docked calendar is 360dp, and\n// a compact window leaves 328dp between its margins, so the calendar is 360\n// at most and the columns share whatever is left below that. Under about\n// 304dp of content a column is narrower than its 40dp circle, and the\n// circles of neighbouring dates meet.\n//\n// **A date from the month either side is faded because it is disabled, not\n// because it is outside.** React Aria marks those cells `data-outside-month`\n// and disables them in the same breath, so a treatment keyed on the first\n// would never draw anything the second had not already drawn. The disabled\n// fade is the page's 38% either way.\n//\n// **Today reads as today whether or not it is selected.** The page gives it\n// an outline and the primary label; selected gives it a filled circle and the\n// on-primary label. A selected today takes the fill, since a circle already\n// says where you are and two rings would say it twice.\n//\n// **The month is moved by IconButton's shape rather than by IconButton.**\n// React Aria wires `slot=\"previous\"` and `slot=\"next\"` on its own `Button`,\n// and IconButton renders React Aria's `Button` too — so nesting one inside\n// the slot would put two buttons where the page draws one. The chevrons take\n// the standard icon button's 40dp square and its state layer instead.\n\ntype CalendarProps<T extends DateValue = DateValue> = {\n /** A function may compute the class from the calendar's render state. */\n className?: RACCalendarProps<T>['className'];\n /**\n * The message shown under the months, which also marks the calendar\n * invalid: the date it holds turns to the error colours, and React Aria\n * points that date's description at the message. `isInvalid` on its own\n * marks the date with no message.\n */\n error?: string;\n /**\n * Whether the header draws the month and the year as menu buttons, each\n * opening a list of them in the grid's place, as the docked date picker's\n * header does, rather than one heading between the chevrons. For a date\n * far from the one shown, such as a date of birth: the year list runs a\n * century either side of the year shown, or to `minValue` and `maxValue`\n * where they are closer.\n *\n * For one visible month. With `visibleDuration` of more than one, the\n * header is the plain one, whose heading names every month shown — the\n * menus name only the first, which would leave the others unlabelled.\n * @default false\n */\n showMonthYearMenus?: boolean;\n /** A function may compute the style from the calendar's render state. */\n style?: RACCalendarProps<T>['style'];\n} & Omit<RACCalendarProps<T>, 'children' | 'className' | 'style'>;\n\n/** What a date's classes read off the calendar around it. */\ntype CalendarStates = {\n /**\n * Whether this date is the one a disabled calendar holds, inside its\n * bounds. A copy of it in a neighbouring month's grid is told apart by\n * React Aria's own `isOutsideMonth`.\n */\n isHeldWhileDisabled: boolean;\n isReadOnly: boolean;\n};\n\n/**\n * A month calendar for picking a date. The value is React Aria's: pass\n * `value` with `onChange` to control it, or `defaultValue` to let it keep its\n * own, both as an `@internationalized/date` value from this package's\n * `./date` subpath.\n *\n * ```tsx\n * import { today, getLocalTimeZone } from '@kanso-labs/kanso-ui/date'\n *\n * <Calendar aria-label=\"Label\" defaultValue={today(getLocalTimeZone())} />\n * ```\n *\n * `minValue` and `maxValue` bound it, `isDateUnavailable` rules individual\n * dates out, and `visibleDuration` of `{ months: 2 }` draws two months side\n * by side, stacked below the expanded breakpoint with each month named over\n * its grid. Name it with `aria-label` or `aria-labelledby`; React Aria\n * composes the visible month into that name itself.\n *\n * The call site's `className` and `style` land on the container, which is the\n * element a layout positions.\n */\nfunction Calendar<T extends DateValue>({\n error,\n showMonthYearMenus = false,\n ...props\n}: CalendarProps<T> & RefAttributes<HTMLDivElement>) {\n return <RACCalendar<T> isInvalid={invalidFrom(error)} {...props} {...mergeStatefulStyles(stylex.props(calendarStyles.root), props)}>\n {({\n isInvalid\n }: CalendarRenderProps) => <>\n <CalendarFrame months={props.visibleDuration?.months ?? 1} showMonthYearMenus={showMonthYearMenus}>\n <CalendarMonths months={props.visibleDuration?.months ?? 1}>\n {gridCell}\n </CalendarMonths>\n </CalendarFrame>\n {/*\n * Through React Aria's error slot, which gives it the id an\n * invalid date's `aria-describedby` names. Drawn only while the\n * calendar is invalid: React Aria looks for the element when\n * `isInvalid` changes, which is when this appears and goes.\n */}\n {isInvalid && error !== undefined ? <RACText slot=\"errorMessage\" {...stylex.props(fieldChromeStyles.message, fieldChromeStyles.messageError)}>\n {error}\n </RACText> : null}\n </>}\n </RACCalendar>;\n}\n\n// A date's classes, from React Aria's render state and the calendar's.\n// StyleX cannot target `[data-selected]` on the element it is styling, so the\n// state comes from what React Aria hands the className.\n//\n// The order matters. `selected` is applied after `today`, so a selected today\n// takes the fill rather than the outline — a circle already says where you\n// are, and two rings would say it twice — and `invalid` after `selected`,\n// which it repaints. The hover and pressed layers come next, over whichever\n// ground the date has, a press over a hover. A read-only calendar takes no\n// hover layer, and React Aria reports no press there to draw one for.\n// `unavailable` and `disabled` come last, and StyleX replaces a property\n// whole, so they take the layers with them; the date a disabled calendar\n// holds then puts its disabled circle back.\nfunction cellClassName(state: CalendarCellRenderProps, calendar: CalendarStates) {\n return stylex.props(calendarStyles.cell, focus.ring, state.isToday && calendarStyles.cellToday, state.isSelected && calendarStyles.cellSelected, state.isSelected && state.isInvalid && calendarStyles.cellInvalid, calendar.isReadOnly && calendarStyles.cellReadOnly, !calendar.isReadOnly && state.isHovered && hoveredLayer(state), state.isPressed && pressedLayer(state), state.isUnavailable && calendarStyles.cellUnavailable, state.isDisabled && calendarStyles.cellDisabled, calendar.isHeldWhileDisabled && !state.isOutsideMonth && calendarStyles.cellSelectedDisabled).className ?? '';\n}\n\n// The calendar's part of a date's classes, bound once per date. Built by a\n// call rather than written inline at the prop, which is what react-perf's\n// no-new-function-as-prop is after.\nfunction cellClassNameIn(calendar: CalendarStates) {\n return (state: CalendarCellRenderProps) => cellClassName(state, calendar);\n}\n\n/**\n * One date. React Aria's cell, with what its classes need from the calendar\n * read from React Aria's calendar state: whether it is read-only, and the\n * date it holds, which React Aria hides from the cell itself once the\n * calendar is disabled.\n *\n * Held means what React Aria would have called selected with the calendar\n * enabled: the value, inside the bounds, and in its own month's grid rather\n * than a neighbour's, which the classes check.\n *\n * Every cell of the month renders again on each focus move, and the React\n * Compiler's memoisation of this one does not hold. React Aria's grid builds\n * a new `CalendarDate` for every cell on every render, so `date` is a new\n * prop each time, and `CalendarStateContext` changes with each move, which\n * React Aria's own cell reads as well as this one. Rendering only the cells a\n * move changes would take a copy of React Aria's `CalendarCell`.\n */\nfunction DateCell({\n date\n}: {\n date: CalendarDate;\n}): ReactElement {\n const calendar = useContext(CalendarStateContext);\n const isHeldWhileDisabled = calendar !== null && calendar.isDisabled && !calendar.isInvalid(date) && holds(calendar.value, date);\n return <RACCalendarCell className={cellClassNameIn({\n isHeldWhileDisabled,\n isReadOnly: calendar?.isReadOnly ?? false\n })} date={date} />;\n}\nfunction gridCell(date: CalendarDate): ReactElement {\n return <DateCell date={date} />;\n}\n\n// Whether a calendar's value includes a date: one date, or several where the\n// calendar takes more than one.\nfunction holds(value: CalendarDate | null | readonly (CalendarDate | null)[], date: CalendarDate) {\n const held = value !== null && 'length' in value ? value : [value];\n return held.some(entry => entry !== null && isSameDay(entry, date));\n}\nfunction hoveredLayer(state: CalendarCellRenderProps) {\n if (!state.isSelected) {\n return dateLayers.plainHovered;\n }\n return state.isInvalid ? dateLayers.invalidHovered : dateLayers.selectedHovered;\n}\nfunction pressedLayer(state: CalendarCellRenderProps) {\n if (!state.isSelected) {\n return dateLayers.plainPressed;\n }\n return state.isInvalid ? dateLayers.invalidPressed : dateLayers.selectedPressed;\n}\nexport type { CalendarProps };\nexport default Calendar;"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwJA,SAAAK,SAAAc,IAAA;CAAA,MAAAC,IAAApB,EAAA,EAAA;CAAA,IAAAqB;CAAA,IAAAN;CAAA,IAAAO;CAAA,IAAAN;CAAA,IAAAO;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAL,EAAA,OAAAD,IAAA;EAAuC,MAAA,EAAAJ,OAAAW,IAAAV,oBAAAW,IAAA,GAAAC,OAAAT;EAAAJ,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