@kanso-labs/kanso-ui 0.43.6 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/calendar/index.js +34 -10
- package/dist/calendar/index.js.map +1 -1
- package/dist/calendar/styles.js +30 -0
- package/dist/calendar/styles.js.map +1 -1
- package/dist/chip/index.js +27 -18
- package/dist/chip/index.js.map +1 -1
- package/dist/chip/label.js +32 -0
- package/dist/chip/label.js.map +1 -0
- package/dist/chip/styles.js +32 -2
- package/dist/chip/styles.js.map +1 -1
- package/dist/collection/text.js +24 -3
- package/dist/collection/text.js.map +1 -1
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/calendar/index.d.ts +8 -1
- package/dist/components/calendar/index.js +129 -73
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/checkbox/index.js +29 -30
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/checkbox-group/index.js +4 -2
- package/dist/components/checkbox-group/index.js.map +1 -1
- package/dist/components/chip/index.js +1 -1
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/chip-group/index.d.ts +35 -5
- package/dist/components/chip-group/index.js +137 -97
- package/dist/components/chip-group/index.js.map +1 -1
- package/dist/components/copy-field/index.js +1 -1
- package/dist/components/copy-field/index.js.map +1 -1
- package/dist/components/currency/index.d.ts +64 -6
- package/dist/components/currency/index.js +117 -40
- package/dist/components/currency/index.js.map +1 -1
- package/dist/components/date-picker/index.js +1 -1
- package/dist/components/dialog/index.d.ts +3 -1
- package/dist/components/dialog/index.js +121 -81
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/disclosure-group/index.js +1 -1
- package/dist/components/disclosure-group/index.js.map +1 -1
- package/dist/components/icon-button/index.js +18 -1
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/keycap/index.d.ts +3 -0
- package/dist/components/keycap/index.js +30 -44
- package/dist/components/keycap/index.js.map +1 -1
- package/dist/components/list/index.d.ts +16 -2
- package/dist/components/list/index.js +124 -69
- package/dist/components/list/index.js.map +1 -1
- package/dist/components/list-detail/index.d.ts +11 -3
- package/dist/components/list-detail/index.js +13 -6
- package/dist/components/list-detail/index.js.map +1 -1
- package/dist/components/list-item/index.d.ts +16 -1
- package/dist/components/list-item/index.js.map +1 -1
- package/dist/components/menu/index.d.ts +6 -2
- package/dist/components/menu/index.js +22 -15
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/meter/index.d.ts +4 -1
- package/dist/components/meter/index.js +6 -0
- package/dist/components/meter/index.js.map +1 -1
- package/dist/components/navigation-bar/index.d.ts +14 -4
- package/dist/components/navigation-bar/index.js +77 -50
- package/dist/components/navigation-bar/index.js.map +1 -1
- package/dist/components/navigation-rail/index.d.ts +3 -2
- package/dist/components/navigation-rail/index.js +59 -52
- package/dist/components/navigation-rail/index.js.map +1 -1
- package/dist/components/navigation-tree/index.js +4 -1
- package/dist/components/navigation-tree/index.js.map +1 -1
- package/dist/components/number-field/index.d.ts +3 -2
- package/dist/components/number-field/index.js +91 -115
- package/dist/components/number-field/index.js.map +1 -1
- package/dist/components/popover/index.d.ts +3 -1
- package/dist/components/popover/index.js +102 -100
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/progress-indicator/index.d.ts +4 -2
- package/dist/components/progress-indicator/index.js +4 -3
- package/dist/components/progress-indicator/index.js.map +1 -1
- package/dist/components/radio-group/index.js +34 -24
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/search-field/index.d.ts +11 -1
- package/dist/components/search-field/index.js +32 -28
- package/dist/components/search-field/index.js.map +1 -1
- package/dist/components/segmented-button/index.d.ts +9 -2
- package/dist/components/segmented-button/index.js +1 -1
- package/dist/components/segmented-button/index.js.map +1 -1
- package/dist/components/separator/index.d.ts +19 -7
- package/dist/components/separator/index.js +36 -13
- package/dist/components/separator/index.js.map +1 -1
- package/dist/components/sheet/index.js +72 -61
- package/dist/components/sheet/index.js.map +1 -1
- package/dist/components/snackbar/index.d.ts +4 -1
- package/dist/components/snackbar/index.js +140 -55
- package/dist/components/snackbar/index.js.map +1 -1
- package/dist/components/stack/index.d.ts +6 -3
- package/dist/components/stack/index.js +48 -31
- package/dist/components/stack/index.js.map +1 -1
- package/dist/components/switch/index.d.ts +16 -6
- package/dist/components/switch/index.js +115 -62
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/text-area/index.d.ts +10 -1
- package/dist/components/text-area/index.js +21 -19
- package/dist/components/text-area/index.js.map +1 -1
- package/dist/components/text-field/index.d.ts +16 -2
- package/dist/components/text-field/index.js +49 -43
- package/dist/components/text-field/index.js.map +1 -1
- package/dist/components/time-picker/index.js +42 -38
- package/dist/components/time-picker/index.js.map +1 -1
- package/dist/components/tooltip/index.d.ts +3 -1
- package/dist/components/tooltip/index.js.map +1 -1
- package/dist/components/tree/index.d.ts +15 -3
- package/dist/components/tree/index.js +41 -28
- package/dist/components/tree/index.js.map +1 -1
- package/dist/control/index.js +26 -23
- package/dist/control/index.js.map +1 -1
- package/dist/control/styles.js +8 -1
- package/dist/control/styles.js.map +1 -1
- package/dist/field/index.js +149 -131
- package/dist/field/index.js.map +1 -1
- package/dist/field/styles.js +14 -1
- package/dist/field/styles.js.map +1 -1
- package/dist/glyphs/index.js +37 -1
- package/dist/glyphs/index.js.map +1 -1
- package/dist/hooks/useClippedTitle.js +44 -0
- package/dist/hooks/useClippedTitle.js.map +1 -0
- package/dist/hooks/useRipple.js +6 -5
- package/dist/hooks/useRipple.js.map +1 -1
- package/dist/hooks/useScrollStop.js +133 -0
- package/dist/hooks/useScrollStop.js.map +1 -0
- package/dist/i18n/index.js +1 -0
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.js +34 -0
- package/dist/i18n/messages.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/indicator/index.js +18 -16
- package/dist/indicator/index.js.map +1 -1
- package/dist/indicator/styles.js +3 -0
- package/dist/indicator/styles.js.map +1 -1
- package/dist/keycap/context.js +7 -0
- package/dist/keycap/context.js.map +1 -0
- package/dist/navigation/index.d.ts +16 -2
- package/dist/navigation/index.js +145 -44
- package/dist/navigation/index.js.map +1 -1
- package/dist/navigation/styles.js +79 -16
- package/dist/navigation/styles.js.map +1 -1
- package/dist/overlay/modal.js +7 -0
- package/dist/overlay/modal.js.map +1 -0
- package/dist/row/index.js +92 -89
- package/dist/row/index.js.map +1 -1
- package/dist/row/styles.js +24 -1
- package/dist/row/styles.js.map +1 -1
- package/dist/styles/overlay.d.ts +6 -2
- package/dist/styles/overlay.js +9 -1
- package/dist/styles/overlay.js.map +1 -1
- package/dist/styles.css +177 -20
- package/dist/theme-scope.d.ts +5 -1
- package/dist/theme-scope.js +100 -51
- package/dist/theme-scope.js.map +1 -1
- package/dist/tokens/design.tokens.stylex.js.map +1 -1
- package/package.json +21 -20
- package/dist/hooks/useScrollable.js +0 -69
- package/dist/hooks/useScrollable.js.map +0 -1
package/dist/glyphs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ReactNode","SVGProps","stylex","mergeStyles","glyphStyles","GlyphProps","Omit","SVGSVGElement","ArrowBackGlyph","props","$","_c","t0","Symbol","for","t1","ArrowDownwardGlyph","ArrowDropDownGlyph","ArrowUpwardGlyph","CalendarGlyph","CheckGlyph","ClockGlyph","Glyph","children","t2","t3","t4","t5","t6","glyph","KeyboardGlyph","MinusGlyph","IndeterminateGlyph","ChevronDownGlyph","ChevronEndGlyph","CloseGlyph","PersonGlyph","PlusGlyph","SearchGlyph","_c","props","stylex.props"],"sources":["../../src/glyphs/index.tsx"],"sourcesContent":["import type { ReactNode, SVGProps } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport { mergeStyles } from '../styles/merge';\nimport { glyphStyles } from './styles';\n\n// The glyphs the library's own controls draw: the check and the dash a\n// checkbox shows, the plus and minus a number field's steppers show, and\n// the magnifier and cross a search field shows. Inline SVG in\n// `currentColor`, sized by whatever renders them, and private to the\n// library — a call site with icons of its own passes them to IconButton and\n// the slots that take a node, which is why nothing here is exported from\n// the package.\n//\n// The paths are the check, the horizontal rule, the plus, the search, the\n// close, the right and down chevrons, the two sort arrows, the back arrow,\n// the drop-down arrow, the calendar, the schedule clock, the keyboard and the\n// person from\n// Material Symbols on their 24-unit grid, which is what the checkbox page\n// draws at 18dp, the icon buttons page at 20 and the search, menus, date\n// picker and time picker pages at 24 — the date picker's menu\n// buttons draw their arrow at 18, and a split button's menu button its\n// chevron at between 22 and 50.\n\ntype GlyphProps = Omit<SVGProps<SVGSVGElement>, 'children' | 'viewBox'>;\n\n// What a search view's back button draws, pointing at the page it returns\n// to. It says \"back\" rather than \"to the left\", so whatever renders it\n// mirrors it under a right-to-left writing mode, as ChevronEndGlyph's\n// renderers do.\nfunction ArrowBackGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z\" />\n </Glyph>;\n}\n\n// Which way a sorted column is ordered. Up is ascending and down is\n// descending, which is the direction the data tables page puts beside a\n// column header's name. Neither mirrors under a right-to-left writing mode:\n// they say \"up\" and \"down\" rather than \"onward\", and those do not flip.\nfunction ArrowDownwardGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z\" />\n </Glyph>;\n}\n\n// What a menu button draws after its label, pointing at the list it opens.\n// Down is down in either writing direction, so it does not mirror.\nfunction ArrowDropDownGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M7 10l5 5 5-5z\" />\n </Glyph>;\n}\nfunction ArrowUpwardGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z\" />\n </Glyph>;\n}\n\n// What the date picker's trigger draws: the calendar a date is picked from.\nfunction CalendarGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M19 4h-1V2h-2v2H8V2H6v2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 16H5V10h14v10zm0-12H5V6h14v2z\" />\n </Glyph>;\n}\nfunction CheckGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z\" />\n </Glyph>;\n}\n\n// What the time picker's trigger draws, and the button that takes its\n// keyboard entry back to the dial: the clock a time is picked from.\nfunction ClockGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z\" />\n </Glyph>;\n}\n\n/**\n * The svg every glyph draws: the 24-unit grid its path is on, the colour it\n * takes from the text around it, and its box. The call site's `className`\n * and `style` are merged with the glyph's own rather than replacing them.\n */\nfunction Glyph({\n children,\n ...props\n}: GlyphProps & {\n children: ReactNode;\n}) {\n return <svg aria-hidden=\"true\" fill=\"currentColor\" viewBox=\"0 0 24 24\" {...props} {...mergeStyles(stylex.props(glyphStyles.glyph), props)}>\n {children}\n </svg>;\n}\n\n// What the time picker's dial draws on the button that switches it to typed\n// entry.\nfunction KeyboardGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M20 5H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 12H4V7h16v10zm-9-9h2v2h-2zm0 3h2v2h-2zM8 8h2v2H8zm0 3h2v2H8zm-3 0h2v2H5zm0-3h2v2H5zm3 6h8v2H8zm6-3h2v2h-2zm0-3h2v2h-2zm3 3h2v2h-2zm0-3h2v2h-2z\" />\n </Glyph>;\n}\n\n// The same rule stands for a partly selected checkbox and for a stepper's\n// decrement; the two names say which is meant at the call site.\nfunction MinusGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M19 13H5v-2h14v2z\" />\n </Glyph>;\n}\nconst IndeterminateGlyph = MinusGlyph;\n\n// Points down at the menu a split button's second half opens.\nfunction ChevronDownGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z\" />\n </Glyph>;\n}\n\n// Points at the submenu a menu item opens. It says \"further in\" rather than\n// \"to the right\", so whatever renders it mirrors it under a right-to-left\n// writing mode — the glyph itself carries no direction of its own, since a\n// transform here would be an inline style.\nfunction ChevronEndGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z\" />\n </Glyph>;\n}\nfunction CloseGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z\" />\n </Glyph>;\n}\n\n// What an avatar with no name to take initials from draws: Material Design's\n// anonymous person, a head over shoulders.\nfunction PersonGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z\" />\n </Glyph>;\n}\nfunction PlusGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z\" />\n </Glyph>;\n}\nfunction SearchGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z\" />\n </Glyph>;\n}\nexport { ArrowBackGlyph, ArrowDownwardGlyph, ArrowDropDownGlyph, ArrowUpwardGlyph, CalendarGlyph, CheckGlyph, ChevronDownGlyph, ChevronEndGlyph, ClockGlyph, CloseGlyph, IndeterminateGlyph, KeyboardGlyph, MinusGlyph, PersonGlyph, PlusGlyph, SearchGlyph };"],"mappings":";;;;;;AA6BA,SAAAQ,eAAAC,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAG,OAAAC,IAAA,2BAAA,GAAA;EAEMF,KAAA,oBAAA,QAAA,EAAQ,GAAA,+DAA8D,CAAA;EAAGF,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAD,OAAA;EADtEM,KAAA,oBAAC,OAAD;GAAM,GAAKN;GACdG,UAAAA;EADS,CAAA;EAEHF,EAAA,KAAAD;EAAAC,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFHK;AAEG;AAOZ,SAAAC,mBAAAP,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAG,OAAAC,IAAA,2BAAA,GAAA;EAEMF,KAAA,oBAAA,QAAA,EAAQ,GAAA,iEAAgE,CAAA;EAAGF,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAD,OAAA;EADxEM,KAAA,oBAAC,OAAD;GAAM,GAAKN;GACdG,UAAAA;EADS,CAAA;EAEHF,EAAA,KAAAD;EAAAC,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFHK;AAEG;AAKZ,SAAAE,mBAAAR,OAAA;CAAA,MAAAC,IAAA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CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFHK;AAEG;AAEZ,SAAAuB,YAAA7B,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAG,OAAAC,IAAA,2BAAA,GAAA;EAEMF,KAAA,oBAAA,QAAA,EAAQ,GAAA,6MAA4M,CAAA;EAAGF,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAD,OAAA;EADpNM,KAAA,oBAAC,OAAD;GAAM,GAAKN;GACdG,UAAAA;EADS,CAAA;EAEHF,EAAA,KAAAD;EAAAC,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFHK;AAEG"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["ReactNode","SVGProps","stylex","mergeStyles","glyphStyles","GlyphProps","Omit","SVGSVGElement","ArrowBackGlyph","props","$","_c","t0","Symbol","for","t1","ArrowDownwardGlyph","ArrowDropDownGlyph","ArrowUpwardGlyph","CalendarGlyph","CheckCircleGlyph","CheckGlyph","ClockGlyph","ErrorGlyph","Glyph","children","t2","t3","t4","t5","t6","glyph","KeyboardGlyph","MinusGlyph","IndeterminateGlyph","ChevronDownGlyph","ChevronEndGlyph","CloseGlyph","PersonGlyph","PlusGlyph","SearchGlyph","_c","props","stylex.props"],"sources":["../../src/glyphs/index.tsx"],"sourcesContent":["import type { ReactNode, SVGProps } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport { mergeStyles } from '../styles/merge';\nimport { glyphStyles } from './styles';\n\n// The glyphs the library's own controls draw: the check and the dash a\n// checkbox shows, the plus and minus a number field's steppers show, and\n// the magnifier and cross a search field shows. Inline SVG in\n// `currentColor`, sized by whatever renders them, and private to the\n// library — a call site with icons of its own passes them to IconButton and\n// the slots that take a node, which is why nothing here is exported from\n// the package.\n//\n// The paths are the check, the horizontal rule, the plus, the search, the\n// close, the right and down chevrons, the two sort arrows, the back arrow,\n// the drop-down arrow, the calendar, the schedule clock, the keyboard, the\n// person, and the filled error and check circles from\n// Material Symbols on their 24-unit grid, which is what the checkbox page\n// draws at 18dp, the icon buttons page at 20 and the search, menus, date\n// picker and time picker pages at 24 — the date picker's menu\n// buttons draw their arrow at 18, a split button's menu button its\n// chevron at between 22 and 50, and a meter its two circles at 18.\n\ntype GlyphProps = Omit<SVGProps<SVGSVGElement>, 'children' | 'viewBox'>;\n\n// What a search view's back button draws, pointing at the page it returns\n// to. It says \"back\" rather than \"to the left\", so whatever renders it\n// mirrors it under a right-to-left writing mode, as ChevronEndGlyph's\n// renderers do.\nfunction ArrowBackGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z\" />\n </Glyph>;\n}\n\n// Which way a sorted column is ordered. Up is ascending and down is\n// descending, which is the direction the data tables page puts beside a\n// column header's name. Neither mirrors under a right-to-left writing mode:\n// they say \"up\" and \"down\" rather than \"onward\", and those do not flip.\nfunction ArrowDownwardGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z\" />\n </Glyph>;\n}\n\n// What a menu button draws after its label, pointing at the list it opens.\n// Down is down in either writing direction, so it does not mirror.\nfunction ArrowDropDownGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M7 10l5 5 5-5z\" />\n </Glyph>;\n}\nfunction ArrowUpwardGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z\" />\n </Glyph>;\n}\n\n// What the date picker's trigger draws: the calendar a date is picked from.\nfunction CalendarGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M19 4h-1V2h-2v2H8V2H6v2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 16H5V10h14v10zm0-12H5V6h14v2z\" />\n </Glyph>;\n}\n\n// What a meter in the positive tone draws beside its value: a check in a\n// filled circle, the same outline as the negative tone's error so the two\n// differ by the mark inside rather than by their colour alone.\nfunction CheckCircleGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z\" />\n </Glyph>;\n}\nfunction CheckGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z\" />\n </Glyph>;\n}\n\n// What the time picker's trigger draws, and the button that takes its\n// keyboard entry back to the dial: the clock a time is picked from.\nfunction ClockGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z\" />\n </Glyph>;\n}\n\n// What a meter in the negative tone draws beside its value: an exclamation\n// mark in a filled circle — see `CheckCircleGlyph`.\nfunction ErrorGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z\" />\n </Glyph>;\n}\n\n/**\n * The svg every glyph draws: the 24-unit grid its path is on, the colour it\n * takes from the text around it, and its box. The call site's `className`\n * and `style` are merged with the glyph's own rather than replacing them.\n */\nfunction Glyph({\n children,\n ...props\n}: GlyphProps & {\n children: ReactNode;\n}) {\n return <svg aria-hidden=\"true\" fill=\"currentColor\" viewBox=\"0 0 24 24\" {...props} {...mergeStyles(stylex.props(glyphStyles.glyph), props)}>\n {children}\n </svg>;\n}\n\n// What the time picker's dial draws on the button that switches it to typed\n// entry.\nfunction KeyboardGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M20 5H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 12H4V7h16v10zm-9-9h2v2h-2zm0 3h2v2h-2zM8 8h2v2H8zm0 3h2v2H8zm-3 0h2v2H5zm0-3h2v2H5zm3 6h8v2H8zm6-3h2v2h-2zm0-3h2v2h-2zm3 3h2v2h-2zm0-3h2v2h-2z\" />\n </Glyph>;\n}\n\n// The same rule stands for a partly selected checkbox and for a stepper's\n// decrement; the two names say which is meant at the call site.\nfunction MinusGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M19 13H5v-2h14v2z\" />\n </Glyph>;\n}\nconst IndeterminateGlyph = MinusGlyph;\n\n// Points down at the menu a split button's second half opens.\nfunction ChevronDownGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z\" />\n </Glyph>;\n}\n\n// Points at the submenu a menu item opens. It says \"further in\" rather than\n// \"to the right\", so whatever renders it mirrors it under a right-to-left\n// writing mode — the glyph itself carries no direction of its own, since a\n// transform here would be an inline style.\nfunction ChevronEndGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z\" />\n </Glyph>;\n}\nfunction CloseGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z\" />\n </Glyph>;\n}\n\n// What an avatar with no name to take initials from draws: Material Design's\n// anonymous person, a head over shoulders.\nfunction PersonGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z\" />\n </Glyph>;\n}\nfunction PlusGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z\" />\n </Glyph>;\n}\nfunction SearchGlyph(props: GlyphProps) {\n return <Glyph {...props}>\n <path d=\"M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z\" />\n </Glyph>;\n}\nexport { ArrowBackGlyph, ArrowDownwardGlyph, ArrowDropDownGlyph, ArrowUpwardGlyph, CalendarGlyph, CheckCircleGlyph, CheckGlyph, ChevronDownGlyph, ChevronEndGlyph, ClockGlyph, CloseGlyph, ErrorGlyph, IndeterminateGlyph, KeyboardGlyph, MinusGlyph, PersonGlyph, PlusGlyph, SearchGlyph };"],"mappings":";;;;;;AA6BA,SAAAQ,eAAAC,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAG,OAAAC,IAAA,2BAAA,GAAA;EAEMF,KAAA,oBAAA,QAAA,EAAQ,GAAA,+DAA8D,CAAA;EAAGF,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAD,OAAA;EADtEM,KAAA,oBAAC,OAAD;GAAM,GAAKN;GACdG,UAAAA;EADS,CAAA;EAEHF,EAAA,KAAAD;EAAAC,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFHK;AAEG;AAOZ,SAAAC,mBAAAP,OAAA;CAAA,MAAAC,IAAAC,EAAA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AA;EADS,CAAA;EAEHF,EAAA,KAAAD;EAAAC,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFHK;AAEG;AAEZ,SAAAyB,YAAA/B,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAG,OAAAC,IAAA,2BAAA,GAAA;EAEMF,KAAA,oBAAA,QAAA,EAAQ,GAAA,6MAA4M,CAAA;EAAGF,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAD,OAAA;EADpNM,KAAA,oBAAC,OAAD;GAAM,GAAKN;GACdG,UAAAA;EADS,CAAA;EAEHF,EAAA,KAAAD;EAAAC,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFHK;AAEG"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { textOf } from "../collection/text.js";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
//#region src/hooks/useClippedTitle.ts
|
|
5
|
+
/**
|
|
6
|
+
* The `title` and `onPointerEnter` for a label span that clips to one line,
|
|
7
|
+
* through `overflow: hidden` or `clip`: spread both on that span.
|
|
8
|
+
*/
|
|
9
|
+
function useClippedTitle(label) {
|
|
10
|
+
const $ = c(7);
|
|
11
|
+
const [title, setTitle] = useState();
|
|
12
|
+
let t0;
|
|
13
|
+
if ($[0] !== label) {
|
|
14
|
+
t0 = textOf(label);
|
|
15
|
+
$[0] = label;
|
|
16
|
+
$[1] = t0;
|
|
17
|
+
} else t0 = $[1];
|
|
18
|
+
const text = t0;
|
|
19
|
+
let t1;
|
|
20
|
+
if ($[2] !== text) {
|
|
21
|
+
t1 = (event) => {
|
|
22
|
+
const span = event.currentTarget;
|
|
23
|
+
setTitle(text !== void 0 && span.scrollWidth > span.clientWidth ? text : void 0);
|
|
24
|
+
};
|
|
25
|
+
$[2] = text;
|
|
26
|
+
$[3] = t1;
|
|
27
|
+
} else t1 = $[3];
|
|
28
|
+
const onPointerEnter = t1;
|
|
29
|
+
let t2;
|
|
30
|
+
if ($[4] !== onPointerEnter || $[5] !== title) {
|
|
31
|
+
t2 = {
|
|
32
|
+
onPointerEnter,
|
|
33
|
+
title
|
|
34
|
+
};
|
|
35
|
+
$[4] = onPointerEnter;
|
|
36
|
+
$[5] = title;
|
|
37
|
+
$[6] = t2;
|
|
38
|
+
} else t2 = $[6];
|
|
39
|
+
return t2;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { useClippedTitle };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=useClippedTitle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useClippedTitle.js","names":["PointerEvent","ReactNode","useState","textOf","useClippedTitle","label","$","_c","title","setTitle","t0","text","t1","event","span","currentTarget","undefined","scrollWidth","clientWidth","onPointerEnter","t2","_c"],"sources":["../../src/hooks/useClippedTitle.ts"],"sourcesContent":["import type { PointerEvent, ReactNode } from 'react'\n\nimport { useState } from 'react'\n\nimport { textOf } from '../collection/text'\n\n// A label kept to one line ends in an ellipsis when it has no room, and a\n// sighted reader then had no way to read the rest: the accessible name stays\n// whole, but nothing on screen did. This hands such a label its full text as\n// a native `title`, so the browser's own tooltip shows it on hover.\n//\n// The label is measured when the pointer reaches it rather than watched, so\n// a page of labels that fit pays for nothing: no observer, no measurement on\n// render. A label that fits gets no title, since a tooltip repeating text\n// already in full view is noise. The text is the label's own when it is text\n// alone — a string, a number, or the two mixed, read as `textOf` reads an\n// item — and a label holding an element gets nothing, since a title is a\n// string and the element's text is not this hook's to guess.\n\n/**\n * The `title` and `onPointerEnter` for a label span that clips to one line,\n * through `overflow: hidden` or `clip`: spread both on that span.\n */\nfunction useClippedTitle(label: ReactNode) {\n const [title, setTitle] = useState<string>()\n const text = textOf(label)\n\n const onPointerEnter = (event: PointerEvent<HTMLElement>) => {\n const span = event.currentTarget\n setTitle(\n text !== undefined && span.scrollWidth > span.clientWidth\n ? text\n : undefined,\n )\n }\n\n return { onPointerEnter, title }\n}\n\nexport { useClippedTitle }\n"],"mappings":";;;;;;;;AAuBA,SAAAI,gBAAAC,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CACE,MAAA,CAAAC,OAAAC,YAA0BP,SAAiB;CAAC,IAAAQ;CAAA,IAAAJ,EAAA,OAAAD,OAAA;EAC/BK,KAAAP,OAAOE,KAAK;EAACC,EAAA,KAAAD;EAAAC,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAA1B,MAAAK,OAAaD;CAAa,IAAAE;CAAA,IAAAN,EAAA,OAAAK,MAAA;EAEHC,MAAAC,UAAA;GACrB,MAAAC,OAAaD,MAAKE;GAClBN,SACEE,SAASK,KAAAA,KAAaF,KAAIG,cAAeH,KAAII,cAA7CP,OAAAK,KAAAA,CAGF;EAAC;EACFV,EAAA,KAAAK;EAAAL,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAPD,MAAAa,iBAAuBP;CAOtB,IAAAQ;CAAA,IAAAd,EAAA,OAAAa,kBAAAb,EAAA,OAAAE,OAAA;EAEMY,KAAA;GAAAD;GAAAX;EAAwB;EAACF,EAAA,KAAAa;EAAAb,EAAA,KAAAE;EAAAF,EAAA,KAAAc;CAAA,OAAAA,KAAAd,EAAA;CAAA,OAAzBc;AAAyB"}
|
package/dist/hooks/useRipple.js
CHANGED
|
@@ -130,7 +130,8 @@ function useRipple(t0, t1, t2) {
|
|
|
130
130
|
if (!ripple) return;
|
|
131
131
|
setPressed(true);
|
|
132
132
|
growAnimation.current?.cancel();
|
|
133
|
-
const
|
|
133
|
+
const surface = ripple.parentElement?.getBoundingClientRect();
|
|
134
|
+
const rect_1 = surface && (surface.width > 0 || surface.height > 0) ? surface : target.getBoundingClientRect();
|
|
134
135
|
const size_1 = determineRippleSize(rect_1);
|
|
135
136
|
const { endPoint: endPoint_0, startPoint: startPoint_0 } = getTranslationCoordinates(rect_1, positionEvent_0);
|
|
136
137
|
ripple.style.width = size_1;
|
|
@@ -404,15 +405,15 @@ function useRipple(t0, t1, t2) {
|
|
|
404
405
|
$[45] = t29;
|
|
405
406
|
$[46] = t30;
|
|
406
407
|
} else t30 = $[46];
|
|
407
|
-
const
|
|
408
|
+
const surface_0 = t30;
|
|
408
409
|
let t31;
|
|
409
|
-
if ($[47] !== handlers || $[48] !==
|
|
410
|
+
if ($[47] !== handlers || $[48] !== surface_0) {
|
|
410
411
|
t31 = {
|
|
411
412
|
handlers,
|
|
412
|
-
surface
|
|
413
|
+
surface: surface_0
|
|
413
414
|
};
|
|
414
415
|
$[47] = handlers;
|
|
415
|
-
$[48] =
|
|
416
|
+
$[48] = surface_0;
|
|
416
417
|
$[49] = t31;
|
|
417
418
|
} else t31 = $[49];
|
|
418
419
|
const enabledResult = t31;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRipple.js","names":["MouseEvent","MouseEventHandler","PointerEvent","PointerEventHandler","ReactNode","stylex","useCallback","useEffect","useMemo","useRef","useState","rippleStyles","motionDurationMs","motionEasing","spacingPx","PADDING","sm","INITIAL_ORIGIN_SCALE","SOFT_EDGE_MINIMUM_SIZE","SOFT_EDGE_CONTAINER_RATIO","surfaceProps","props","surface","RippleState","Holding","Inactive","TouchDelay","WaitingForClick","const","ReleaseHandlers","Element","Omit","RippleEventHandlers","HostElement","onClick","onContextMenu","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","isTouch","event","pointerType","prefersReducedMotion","window","matchMedia","matches","useRipple","enabled","externalHandlers","endsOnRelease","handlers","t0","t1","t2","$","_c","undefined","t3","pressed","setPressed","rippleRef","state","growAnimation","rippleStartEvent","initialSize","rippleScale","removeDocumentListeners","t4","Symbol","for","isPrimary","startEvent","current","pointerId","isPressPointer","t5","event_0","buttons","shouldReactToEvent","t6","rect","height","width","maxDimension","Math","max","softEdgeSize","size","floor","hypotenuse","hypot","maxRadius","determineRippleSize","t7","rect_0","positionEvent","height_0","left","top","width_0","size_0","endPoint","x","y","origin","clientX","clientY","startPoint","getTranslationCoordinates","t8","target","positionEvent_0","ripple","cancel","rect_1","getBoundingClientRect","size_1","endPoint_0","startPoint_0","style","animate","transform","duration","long1","easing","standard","fill","startPressAnimation","t9","animation","elapsed","currentTime","Infinity","medium1","Promise","resolve","setTimeout","endPressAnimation","t10","host","document","ownerDocument","handleEnd","event_1","composedPath","includes","addEventListener","removeEventListener","listenBeyondHost","t11","t12","t13","getState","t14","event_2","target_0","currentTarget","_temp","handlePointerDownAsync","t15","event_3","handlePointerDown","t16","event_4","handlePointerUp","t17","event_5","handlePointerLeave","t18","event_6","handlePointerCancel","t19","event_7","handleClick","t20","handleContextMenu","onClickProp","onContextMenuProp","onPointerCancelProp","onPointerDownProp","onPointerLeaveProp","onPointerUpProp","t21","event_8","t22","event_9","t23","event_10","t24","event_11","t25","event_12","t26","event_13","t27","pointer","t28","t29","press","t30","t31","enabledResult","t32","disabledResult","resolve_0","short2","stylex.props","rippleStyles","_c","disabledResult"],"sources":["../../src/hooks/useRipple.tsx"],"sourcesContent":["import type { MouseEvent, MouseEventHandler, PointerEvent, PointerEventHandler, ReactNode } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { rippleStyles } from '../styles/ripple';\nimport { motionDurationMs, motionEasing, spacingPx } from '../tokens/values';\n\n// Every timing this file drives is a motion token, spent at the point of use\n// below. They come from tokens/values rather than the StyleX theme because\n// element.animate() and setTimeout both reject a token's var() form, and the\n// same is true of the one geometry token: `PADDING` is added to a radius, and\n// a var() would concatenate rather than add. See src/styles/ripple.ts for the\n// opacity half of the mechanism, whose three timings are deliberately not\n// tokens.\n\n/** How far the ripple grows past the host's corners. `spacing.sm`. */\nconst PADDING = spacingPx.sm;\n\n// The rest are ratios and a pixel floor that no token group covers — spacing\n// is layout rhythm, and nothing in the set holds bare geometric ratios.\nconst INITIAL_ORIGIN_SCALE = 0.2;\nconst SOFT_EDGE_MINIMUM_SIZE = 75;\nconst SOFT_EDGE_CONTAINER_RATIO = 0.35;\n\n// Static input, so this is computed once for every consumer of the module\n// rather than once per component instance.\nconst surfaceProps = stylex.props(rippleStyles.surface);\n\n/**\n * On touch: `Inactive -> TouchDelay -> WaitingForClick -> Inactive`, or\n * `Inactive -> TouchDelay -> Holding -> WaitingForClick -> Inactive` for a\n * held press.\n *\n * On mouse or pen: `Inactive -> WaitingForClick -> Inactive`.\n */\nconst RippleState = {\n /** A touch has been confirmed as a press (held past the touch delay). */\n Holding: 2,\n /** No press in progress. Touch down moves to TouchDelay; mouse/pen down moves to WaitingForClick. */\n Inactive: 0,\n /** Touch down received; waiting to see if it's a tap or a scroll/swipe. */\n TouchDelay: 1,\n /** The press has finished growing; waiting for the click that ends it. */\n WaitingForClick: 3\n} as const;\ntype ReleaseHandlers<HostElement extends Element> = Omit<RippleEventHandlers<HostElement>, 'onClick'>;\ninterface RippleEventHandlers<HostElement extends Element> {\n onClick?: MouseEventHandler<HostElement>;\n onContextMenu?: MouseEventHandler<HostElement>;\n onPointerCancel?: PointerEventHandler<HostElement>;\n onPointerDown?: PointerEventHandler<HostElement>;\n onPointerLeave?: PointerEventHandler<HostElement>;\n onPointerUp?: PointerEventHandler<HostElement>;\n}\ntype RippleState = (typeof RippleState)[keyof typeof RippleState];\nfunction isTouch(event: PointerEvent) {\n return event.pointerType === 'touch';\n}\n\n/**\n * Whether the reader has asked the OS for less motion.\n *\n * Growth is a Web Animations call, which makes it the one animation in the\n * library no `@media (prefers-reduced-motion: reduce)` branch can reach — see\n * src/styles/ripple.ts for the opacity half, which is CSS and carries one.\n *\n * Read at the press rather than once at mount, so a reader who changes the\n * setting is answered by their next press rather than by their next reload.\n * The press already reads layout through `getBoundingClientRect`, which costs\n * more than this does.\n */\nfunction prefersReducedMotion() {\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\n/**\n * Renders a press ripple that grows from the pointer's position, or from\n * the element's center for a keyboard or other non-pointer activation.\n *\n * Growth runs via the Web Animations API on a single reused element (no\n * per-click DOM nodes to clean up), over a fixed duration independent of how\n * long the element is held — a real press-and-hold keeps the ripple\n * growing until release, while a quick tap is still held visible for a\n * minimum duration so it plays a complete animation rather than a flicker.\n *\n * Merges its own handlers with `externalHandlers` (e.g. a component's own\n * consumer-supplied props — ripple's own run first, then the external\n * ones) and returns `handlers` to spread onto the interactive element and\n * `surface`, the node to render as a child. The host element must\n * establish a positioning context (`position: relative` or similar) so\n * `surface`, which fills it via `inset: 0`, clips to its bounds and\n * inherits its shape.\n *\n * Pass `enabled: false` to opt out — no ripple listeners are attached and\n * no surface is rendered, leaving `externalHandlers` and a component's own\n * hover/press state layer (if any) untouched.\n *\n * Pass `endsOnRelease` for a host that never hears its own click: a\n * collection row, whose clicks React Aria's press handling keeps for itself.\n * The press then ends when the pointer is released over the host rather than\n * on the click that would follow, still held for the minimum a short press\n * gets. A keyboard press reaches such a host as no pointer event at all, so\n * it draws no ripple there.\n *\n * `handlers` and `surface` are hand-memoized (not left to build-tool\n * optimization) so a consumer rendering many instances — a list of icon\n * buttons, say — can memoize around them too, and so stability doesn't\n * depend on any particular compiler being configured.\n */\n// A host ending on the release never hears a click, so nothing is taken for\n// one and none is handed back: the handlers are the pointer ones alone, which\n// is also what a collection row's type admits.\nfunction useRipple<HostElement extends Element = Element>(enabled: boolean, externalHandlers: ReleaseHandlers<HostElement>, endsOnRelease: true): {\n handlers: ReleaseHandlers<HostElement>;\n surface: ReactNode;\n};\nfunction useRipple<HostElement extends Element = Element>(enabled?: boolean, externalHandlers?: RippleEventHandlers<HostElement>, endsOnRelease?: false): {\n handlers: RippleEventHandlers<HostElement>;\n surface: ReactNode;\n};\nfunction useRipple<HostElement extends Element = Element>(enabled = true, externalHandlers: RippleEventHandlers<HostElement> = {}, endsOnRelease = false): {\n handlers: RippleEventHandlers<HostElement>;\n surface: ReactNode;\n} {\n const [pressed, setPressed] = useState(false);\n const rippleRef = useRef<HTMLSpanElement>(null);\n const state = useRef<RippleState>(RippleState.Inactive);\n const growAnimation = useRef<Animation | undefined>(undefined);\n const rippleStartEvent = useRef<PointerEvent<HostElement> | undefined>(undefined);\n const initialSize = useRef(0);\n const rippleScale = useRef('1');\n // Removes the listeners a press keeps on its host's document, while one is\n // in flight — see `listenBeyondHost`.\n const removeDocumentListeners = useRef<(() => void) | undefined>(undefined);\n\n // Whether `event` comes from the pointer a press would follow: the primary\n // one, and the one that started the press already in flight, if any.\n const isPressPointer = useCallback((event: PointerEvent<HostElement>) => {\n if (!event.isPrimary) {\n return false;\n }\n const startEvent = rippleStartEvent.current;\n return !startEvent || startEvent.pointerId === event.pointerId;\n }, []);\n const shouldReactToEvent = useCallback((event: PointerEvent<HostElement>) => isPressPointer(event) && (isTouch(event) || event.buttons === 1), [isPressPointer]);\n const determineRippleSize = useCallback((rect: DOMRect) => {\n const {\n height,\n width\n } = rect;\n const maxDimension = Math.max(height, width);\n const softEdgeSize = Math.max(SOFT_EDGE_CONTAINER_RATIO * maxDimension, SOFT_EDGE_MINIMUM_SIZE);\n const size = Math.floor(maxDimension * INITIAL_ORIGIN_SCALE);\n const hypotenuse = Math.hypot(width, height);\n const maxRadius = hypotenuse + PADDING;\n initialSize.current = size;\n rippleScale.current = `${(maxRadius + softEdgeSize) / size}`;\n return `${size}px`;\n }, []);\n const getTranslationCoordinates = useCallback((rect: DOMRect, positionEvent?: PointerEvent<HostElement>) => {\n const {\n height,\n left,\n top,\n width\n } = rect;\n const size = initialSize.current;\n const endPoint = {\n x: (width - size) / 2,\n y: (height - size) / 2\n };\n const origin = positionEvent ? {\n x: positionEvent.clientX - left,\n y: positionEvent.clientY - top\n } : {\n x: width / 2,\n y: height / 2\n };\n const startPoint = {\n x: origin.x - size / 2,\n y: origin.y - size / 2\n };\n return {\n endPoint,\n startPoint\n };\n }, []);\n const startPressAnimation = useCallback((target: HostElement, positionEvent?: PointerEvent<HostElement>) => {\n const ripple = rippleRef.current;\n if (!ripple) {\n return;\n }\n setPressed(true);\n growAnimation.current?.cancel();\n\n // Read once and share: the two helpers below both only need the\n // target's rect, and a second `getBoundingClientRect()` call back to\n // back with the first would be a redundant layout read.\n const rect = target.getBoundingClientRect();\n const size = determineRippleSize(rect);\n const {\n endPoint,\n startPoint\n } = getTranslationCoordinates(rect, positionEvent);\n ripple.style.width = size;\n ripple.style.height = size;\n growAnimation.current = ripple.animate({\n transform: [`translate(${startPoint.x}px, ${startPoint.y}px) scale(1)`, `translate(${endPoint.x}px, ${endPoint.y}px) scale(${rippleScale.current})`]\n }, {\n // Growth runs over a fixed duration regardless of how long the\n // press is held, so the token is spent here rather than named as a\n // constant — element.animate() is one of the two places a StyleX\n // token could not have gone.\n //\n // Zeroed rather than skipped under reduced motion, which lands the\n // disc at its full size with the growth never drawn. Skipping the\n // call outright would leave `growAnimation` unset, and the release\n // below reads its `currentTime` to decide whether the press has\n // been visible long enough — so the press would still be shown, and\n // would stop being held for its minimum.\n duration: prefersReducedMotion() ? 0 : motionDurationMs.long1,\n easing: motionEasing.standard,\n fill: 'forwards'\n });\n }, [determineRippleSize, getTranslationCoordinates]);\n const endPressAnimation = useCallback(async () => {\n removeDocumentListeners.current?.();\n removeDocumentListeners.current = undefined;\n rippleStartEvent.current = undefined;\n state.current = RippleState.Inactive;\n const animation = growAnimation.current;\n const elapsed = typeof animation?.currentTime === 'number' ? animation.currentTime : Infinity;\n\n // The floor on how briefly a ripple may be visible, so a quick tap reads\n // as a deliberate ripple rather than a flicker.\n if (elapsed >= motionDurationMs.medium1) {\n setPressed(false);\n return;\n }\n await new Promise(resolve => {\n setTimeout(resolve, motionDurationMs.medium1 - elapsed);\n });\n if (growAnimation.current !== animation) {\n // A newer press started; let it own the pressed state instead.\n return;\n }\n setPressed(false);\n }, []);\n\n // A press can end somewhere other than its host. React Aria's press\n // handling releases the capture a touch takes on its pointerdown, so that a\n // finger can leave the element, and a press that turns into a scroll — or\n // a finger that slides off and lifts — then ends with a pointercancel or\n // pointerup on whatever is under it, which the host never hears. Left to\n // the host's handlers alone, the ripple held at its pressed opacity until\n // the next press on that host finished a cycle.\n //\n // So the press listens on its host's document, in the capture phase, for\n // its own pointer, the way React Aria's own press handling does. An end the\n // host does hear is left to the host's handlers, which run after these.\n const listenBeyondHost = useCallback((host: HostElement, pointerId: number) => {\n removeDocumentListeners.current?.();\n const document = host.ownerDocument;\n const handleEnd = (event: globalThis.PointerEvent) => {\n if (event.pointerId !== pointerId || event.composedPath().includes(host)) {\n return;\n }\n void endPressAnimation();\n };\n document.addEventListener('pointercancel', handleEnd, true);\n document.addEventListener('pointerup', handleEnd, true);\n removeDocumentListeners.current = () => {\n document.removeEventListener('pointercancel', handleEnd, true);\n document.removeEventListener('pointerup', handleEnd, true);\n };\n }, [endPressAnimation]);\n\n // A host unmounted mid-press leaves nothing listening behind it.\n useEffect(() => () => {\n removeDocumentListeners.current?.();\n }, []);\n\n // Reads through a function so a stale narrowing of `state.current` from\n // before the `await` below isn't (incorrectly) carried across it — the\n // ref can change via a different handler while this one is suspended.\n const getState = useCallback(() => state.current, []);\n const handlePointerDownAsync = useCallback(async (event: PointerEvent<HostElement>) => {\n if (!shouldReactToEvent(event)) {\n return;\n }\n rippleStartEvent.current = event;\n const target = event.currentTarget;\n listenBeyondHost(target, event.pointerId);\n if (!isTouch(event)) {\n state.current = RippleState.WaitingForClick;\n startPressAnimation(target, event);\n return;\n }\n\n // Delay so a scroll/swipe starting on the element doesn't flash a\n // ripple — only a held (or quickly released) touch counts as a press.\n state.current = RippleState.TouchDelay;\n await new Promise(resolve => {\n setTimeout(resolve, motionDurationMs.short2);\n });\n if (getState() !== RippleState.TouchDelay) {\n return;\n }\n state.current = RippleState.Holding;\n startPressAnimation(target, event);\n }, [getState, listenBeyondHost, shouldReactToEvent, startPressAnimation]);\n const handlePointerDown = useCallback((event: PointerEvent<HostElement>) => {\n void handlePointerDownAsync(event);\n }, [handlePointerDownAsync]);\n const handlePointerUp = useCallback((event: PointerEvent<HostElement>) => {\n // A mouse or pen release carries no pressed button, so the guard the\n // other handlers share turns it away, which is right while a click\n // follows to end the press. A host ending on the release matches it by\n // its pointer alone.\n if (endsOnRelease && !isTouch(event)) {\n if (isPressPointer(event) && state.current === RippleState.WaitingForClick) {\n void endPressAnimation();\n }\n return;\n }\n if (!shouldReactToEvent(event)) {\n return;\n }\n if (state.current === RippleState.Holding) {\n state.current = RippleState.WaitingForClick;\n } else if (state.current === RippleState.TouchDelay) {\n // Released before the delay elapsed: treat as a completed tap.\n state.current = RippleState.WaitingForClick;\n startPressAnimation(event.currentTarget, rippleStartEvent.current);\n }\n\n // The release is as far as such a host hears, so it is where the\n // press ends — see `endsOnRelease` above.\n if (endsOnRelease && state.current === RippleState.WaitingForClick) {\n void endPressAnimation();\n }\n }, [endPressAnimation, endsOnRelease, isPressPointer, shouldReactToEvent, startPressAnimation]);\n const handlePointerLeave = useCallback((event: PointerEvent<HostElement>) => {\n if (isTouch(event) || !shouldReactToEvent(event)) {\n return;\n }\n if (state.current !== RippleState.Inactive) {\n void endPressAnimation();\n }\n }, [endPressAnimation, shouldReactToEvent]);\n const handlePointerCancel = useCallback((event: PointerEvent<HostElement>) => {\n if (!shouldReactToEvent(event)) {\n return;\n }\n void endPressAnimation();\n }, [endPressAnimation, shouldReactToEvent]);\n const handleClick = useCallback((event: MouseEvent<HostElement>) => {\n if (state.current === RippleState.WaitingForClick) {\n void endPressAnimation();\n return;\n }\n if (state.current === RippleState.Inactive) {\n // No pointerdown preceded this click — keyboard activation, a\n // programmatic `.click()`, or assistive-tech-synthesized activation.\n // Play a complete, centered press immediately.\n startPressAnimation(event.currentTarget);\n void endPressAnimation();\n }\n }, [endPressAnimation, startPressAnimation]);\n const handleContextMenu = useCallback(() => {\n void endPressAnimation();\n }, [endPressAnimation]);\n const {\n onClick: onClickProp,\n onContextMenu: onContextMenuProp,\n onPointerCancel: onPointerCancelProp,\n onPointerDown: onPointerDownProp,\n onPointerLeave: onPointerLeaveProp,\n onPointerUp: onPointerUpProp\n } = externalHandlers;\n const onClick = useCallback((event: MouseEvent<HostElement>) => {\n handleClick(event);\n onClickProp?.(event);\n }, [handleClick, onClickProp]);\n const onContextMenu = useCallback((event: MouseEvent<HostElement>) => {\n handleContextMenu();\n onContextMenuProp?.(event);\n }, [handleContextMenu, onContextMenuProp]);\n const onPointerCancel = useCallback((event: PointerEvent<HostElement>) => {\n handlePointerCancel(event);\n onPointerCancelProp?.(event);\n }, [handlePointerCancel, onPointerCancelProp]);\n const onPointerDown = useCallback((event: PointerEvent<HostElement>) => {\n handlePointerDown(event);\n onPointerDownProp?.(event);\n }, [handlePointerDown, onPointerDownProp]);\n const onPointerLeave = useCallback((event: PointerEvent<HostElement>) => {\n handlePointerLeave(event);\n onPointerLeaveProp?.(event);\n }, [handlePointerLeave, onPointerLeaveProp]);\n const onPointerUp = useCallback((event: PointerEvent<HostElement>) => {\n handlePointerUp(event);\n onPointerUpProp?.(event);\n }, [handlePointerUp, onPointerUpProp]);\n const handlers = useMemo(() => {\n const pointer = {\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp\n };\n return endsOnRelease ? pointer : {\n onClick,\n ...pointer\n };\n }, [endsOnRelease, onClick, onContextMenu, onPointerCancel, onPointerDown, onPointerLeave, onPointerUp]);\n const surface = useMemo(() => <span aria-hidden=\"true\" {...surfaceProps}>\n <span ref={rippleRef} {...stylex.props(rippleStyles.press, pressed && rippleStyles.pressed)} />\n </span>, [pressed]);\n\n // Two separate memos rather than one branching on `enabled`, so that\n // whichever branch is actually active stays keyed only on its own\n // inputs — the enabled result doesn't get a new identity every time\n // `externalHandlers` does (a component typically passes a fresh object\n // literal each render), and vice versa.\n const enabledResult = useMemo(() => ({\n handlers,\n surface\n }), [handlers, surface]);\n const disabledResult = useMemo(() => ({\n handlers: externalHandlers,\n surface: null\n }), [externalHandlers]);\n return enabled ? enabledResult : disabledResult;\n}\nexport { useRipple };"],"mappings":";;;;;;;;AAeA,MAAMe,UAAUD,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AC;CAAA,IAAA/I,EAAA,QAAAI,SAAA;EAEzE2I,MAAAjM,MAAaM,OAAY4L,OAAQ5I,WAAWhD,OAAYgD,OAAQ;EAACJ,EAAA,MAAAI;EAAAJ,EAAA,MAAA+I;CAAA,OAAAA,MAAA/I,EAAA;CAAA,IAAAiJ;CAAA,IAAAjJ,EAAA,QAAA+I,KAAA;EADnEE,MAAA,oBAAA,QAAA;GAAkB,eAAA;GAAM,GAAKpL;GACrD,UAAA,oBAAA,QAAA;IAAWyC,KAAAA;IAAS,GAAMyI;GAAiE,CAAA;EACtF,CAAA;EAAA/I,EAAA,MAAA+I;EAAA/I,EAAA,MAAAiJ;CAAA,OAAAA,MAAAjJ,EAAA;CAFX,MAAAjC,UAA8BkL;CAEN,IAAAC;CAAA,IAAAlJ,EAAA,QAAAJ,YAAAI,EAAA,QAAAjC,SAAA;EAOamL,MAAA;GAAAtJ;GAAA7B;EAGrC;EAACiC,EAAA,MAAAJ;EAAAI,EAAA,MAAAjC;EAAAiC,EAAA,MAAAkJ;CAAA,OAAAA,MAAAlJ,EAAA;CAHD,MAAAmJ,gBAAqCD;CAGZ,IAAAE;CAAA,IAAApJ,EAAA,QAAAN,kBAAA;EACa0J,MAAA;GAAAxJ,UAC1BF;GAAgB3B,SACjB;EACX;EAACiC,EAAA,MAAAN;EAAAM,EAAA,MAAAoJ;CAAA,OAAAA,MAAApJ,EAAA;CAAuB,OACjBP,UAAA0J,gBAAAE;AAAwC;AA1TjD,SAAA9C,MAAA+C,WAAA;CAuLMpE,WAAWD,WAAS5H,iBAAgBkM,MAAO;AAAC"}
|
|
1
|
+
{"version":3,"file":"useRipple.js","names":["MouseEvent","MouseEventHandler","PointerEvent","PointerEventHandler","ReactNode","stylex","useCallback","useEffect","useMemo","useRef","useState","rippleStyles","motionDurationMs","motionEasing","spacingPx","PADDING","sm","INITIAL_ORIGIN_SCALE","SOFT_EDGE_MINIMUM_SIZE","SOFT_EDGE_CONTAINER_RATIO","surfaceProps","props","surface","RippleState","Holding","Inactive","TouchDelay","WaitingForClick","const","ReleaseHandlers","Element","Omit","RippleEventHandlers","HostElement","onClick","onContextMenu","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","isTouch","event","pointerType","prefersReducedMotion","window","matchMedia","matches","useRipple","enabled","externalHandlers","endsOnRelease","handlers","t0","t1","t2","$","_c","undefined","t3","pressed","setPressed","rippleRef","state","growAnimation","rippleStartEvent","initialSize","rippleScale","removeDocumentListeners","t4","Symbol","for","isPrimary","startEvent","current","pointerId","isPressPointer","t5","event_0","buttons","shouldReactToEvent","t6","rect","height","width","maxDimension","Math","max","softEdgeSize","size","floor","hypotenuse","hypot","maxRadius","determineRippleSize","t7","rect_0","positionEvent","height_0","left","top","width_0","size_0","endPoint","x","y","origin","clientX","clientY","startPoint","getTranslationCoordinates","t8","target","positionEvent_0","ripple","cancel","parentElement","getBoundingClientRect","rect_1","size_1","endPoint_0","startPoint_0","style","animate","transform","duration","long1","easing","standard","fill","startPressAnimation","t9","animation","elapsed","currentTime","Infinity","medium1","Promise","resolve","setTimeout","endPressAnimation","t10","host","document","ownerDocument","handleEnd","event_1","composedPath","includes","addEventListener","removeEventListener","listenBeyondHost","t11","t12","t13","getState","t14","event_2","target_0","currentTarget","_temp","handlePointerDownAsync","t15","event_3","handlePointerDown","t16","event_4","handlePointerUp","t17","event_5","handlePointerLeave","t18","event_6","handlePointerCancel","t19","event_7","handleClick","t20","handleContextMenu","onClickProp","onContextMenuProp","onPointerCancelProp","onPointerDownProp","onPointerLeaveProp","onPointerUpProp","t21","event_8","t22","event_9","t23","event_10","t24","event_11","t25","event_12","t26","event_13","t27","pointer","t28","t29","press","t30","surface_0","t31","enabledResult","t32","disabledResult","resolve_0","short2","stylex.props","rippleStyles","_c","disabledResult"],"sources":["../../src/hooks/useRipple.tsx"],"sourcesContent":["import type { MouseEvent, MouseEventHandler, PointerEvent, PointerEventHandler, ReactNode } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { rippleStyles } from '../styles/ripple';\nimport { motionDurationMs, motionEasing, spacingPx } from '../tokens/values';\n\n// Every timing this file drives is a motion token, spent at the point of use\n// below. They come from tokens/values rather than the StyleX theme because\n// element.animate() and setTimeout both reject a token's var() form, and the\n// same is true of the one geometry token: `PADDING` is added to a radius, and\n// a var() would concatenate rather than add. See src/styles/ripple.ts for the\n// opacity half of the mechanism, whose three timings are deliberately not\n// tokens.\n\n/** How far the ripple grows past the host's corners. `spacing.sm`. */\nconst PADDING = spacingPx.sm;\n\n// The rest are ratios and a pixel floor that no token group covers — spacing\n// is layout rhythm, and nothing in the set holds bare geometric ratios.\nconst INITIAL_ORIGIN_SCALE = 0.2;\nconst SOFT_EDGE_MINIMUM_SIZE = 75;\nconst SOFT_EDGE_CONTAINER_RATIO = 0.35;\n\n// Static input, so this is computed once for every consumer of the module\n// rather than once per component instance.\nconst surfaceProps = stylex.props(rippleStyles.surface);\n\n/**\n * On touch: `Inactive -> TouchDelay -> WaitingForClick -> Inactive`, or\n * `Inactive -> TouchDelay -> Holding -> WaitingForClick -> Inactive` for a\n * held press.\n *\n * On mouse or pen: `Inactive -> WaitingForClick -> Inactive`.\n */\nconst RippleState = {\n /** A touch has been confirmed as a press (held past the touch delay). */\n Holding: 2,\n /** No press in progress. Touch down moves to TouchDelay; mouse/pen down moves to WaitingForClick. */\n Inactive: 0,\n /** Touch down received; waiting to see if it's a tap or a scroll/swipe. */\n TouchDelay: 1,\n /** The press has finished growing; waiting for the click that ends it. */\n WaitingForClick: 3\n} as const;\ntype ReleaseHandlers<HostElement extends Element> = Omit<RippleEventHandlers<HostElement>, 'onClick'>;\ninterface RippleEventHandlers<HostElement extends Element> {\n onClick?: MouseEventHandler<HostElement>;\n onContextMenu?: MouseEventHandler<HostElement>;\n onPointerCancel?: PointerEventHandler<HostElement>;\n onPointerDown?: PointerEventHandler<HostElement>;\n onPointerLeave?: PointerEventHandler<HostElement>;\n onPointerUp?: PointerEventHandler<HostElement>;\n}\ntype RippleState = (typeof RippleState)[keyof typeof RippleState];\nfunction isTouch(event: PointerEvent) {\n return event.pointerType === 'touch';\n}\n\n/**\n * Whether the reader has asked the OS for less motion.\n *\n * Growth is a Web Animations call, which makes it the one animation in the\n * library no `@media (prefers-reduced-motion: reduce)` branch can reach — see\n * src/styles/ripple.ts for the opacity half, which is CSS and carries one.\n *\n * Read at the press rather than once at mount, so a reader who changes the\n * setting is answered by their next press rather than by their next reload.\n * The press already reads layout through `getBoundingClientRect`, which costs\n * more than this does.\n */\nfunction prefersReducedMotion() {\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\n/**\n * Renders a press ripple that grows from the pointer's position, or from\n * the element's center for a keyboard or other non-pointer activation.\n *\n * Growth runs via the Web Animations API on a single reused element (no\n * per-click DOM nodes to clean up), over a fixed duration independent of how\n * long the element is held — a real press-and-hold keeps the ripple\n * growing until release, while a quick tap is still held visible for a\n * minimum duration so it plays a complete animation rather than a flicker.\n *\n * Merges its own handlers with `externalHandlers` (e.g. a component's own\n * consumer-supplied props — ripple's own run first, then the external\n * ones) and returns `handlers` to spread onto the interactive element and\n * `surface`, the node to render as a child. The host element must\n * establish a positioning context (`position: relative` or similar) so\n * `surface`, which fills it via `inset: 0`, clips to its bounds and\n * inherits its shape. A host can render `surface` in a positioned part of\n * itself instead, and the ripple then grows in that part alone, from where\n * the pointer is over it: a navigation destination draws it in its\n * indicator.\n *\n * Pass `enabled: false` to opt out — no ripple listeners are attached and\n * no surface is rendered, leaving `externalHandlers` and a component's own\n * hover/press state layer (if any) untouched.\n *\n * Pass `endsOnRelease` for a host that never hears its own click: a\n * collection row, whose clicks React Aria's press handling keeps for itself.\n * The press then ends when the pointer is released over the host rather than\n * on the click that would follow, still held for the minimum a short press\n * gets. A keyboard press reaches such a host as no pointer event at all, so\n * it draws no ripple there.\n *\n * `handlers` and `surface` are hand-memoized (not left to build-tool\n * optimization) so a consumer rendering many instances — a list of icon\n * buttons, say — can memoize around them too, and so stability doesn't\n * depend on any particular compiler being configured.\n */\n// A host ending on the release never hears a click, so nothing is taken for\n// one and none is handed back: the handlers are the pointer ones alone, which\n// is also what a collection row's type admits.\nfunction useRipple<HostElement extends Element = Element>(enabled: boolean, externalHandlers: ReleaseHandlers<HostElement>, endsOnRelease: true): {\n handlers: ReleaseHandlers<HostElement>;\n surface: ReactNode;\n};\nfunction useRipple<HostElement extends Element = Element>(enabled?: boolean, externalHandlers?: RippleEventHandlers<HostElement>, endsOnRelease?: false): {\n handlers: RippleEventHandlers<HostElement>;\n surface: ReactNode;\n};\nfunction useRipple<HostElement extends Element = Element>(enabled = true, externalHandlers: RippleEventHandlers<HostElement> = {}, endsOnRelease = false): {\n handlers: RippleEventHandlers<HostElement>;\n surface: ReactNode;\n} {\n const [pressed, setPressed] = useState(false);\n const rippleRef = useRef<HTMLSpanElement>(null);\n const state = useRef<RippleState>(RippleState.Inactive);\n const growAnimation = useRef<Animation | undefined>(undefined);\n const rippleStartEvent = useRef<PointerEvent<HostElement> | undefined>(undefined);\n const initialSize = useRef(0);\n const rippleScale = useRef('1');\n // Removes the listeners a press keeps on its host's document, while one is\n // in flight — see `listenBeyondHost`.\n const removeDocumentListeners = useRef<(() => void) | undefined>(undefined);\n\n // Whether `event` comes from the pointer a press would follow: the primary\n // one, and the one that started the press already in flight, if any.\n const isPressPointer = useCallback((event: PointerEvent<HostElement>) => {\n if (!event.isPrimary) {\n return false;\n }\n const startEvent = rippleStartEvent.current;\n return !startEvent || startEvent.pointerId === event.pointerId;\n }, []);\n const shouldReactToEvent = useCallback((event: PointerEvent<HostElement>) => isPressPointer(event) && (isTouch(event) || event.buttons === 1), [isPressPointer]);\n const determineRippleSize = useCallback((rect: DOMRect) => {\n const {\n height,\n width\n } = rect;\n const maxDimension = Math.max(height, width);\n const softEdgeSize = Math.max(SOFT_EDGE_CONTAINER_RATIO * maxDimension, SOFT_EDGE_MINIMUM_SIZE);\n const size = Math.floor(maxDimension * INITIAL_ORIGIN_SCALE);\n const hypotenuse = Math.hypot(width, height);\n const maxRadius = hypotenuse + PADDING;\n initialSize.current = size;\n rippleScale.current = `${(maxRadius + softEdgeSize) / size}`;\n return `${size}px`;\n }, []);\n const getTranslationCoordinates = useCallback((rect: DOMRect, positionEvent?: PointerEvent<HostElement>) => {\n const {\n height,\n left,\n top,\n width\n } = rect;\n const size = initialSize.current;\n const endPoint = {\n x: (width - size) / 2,\n y: (height - size) / 2\n };\n const origin = positionEvent ? {\n x: positionEvent.clientX - left,\n y: positionEvent.clientY - top\n } : {\n x: width / 2,\n y: height / 2\n };\n const startPoint = {\n x: origin.x - size / 2,\n y: origin.y - size / 2\n };\n return {\n endPoint,\n startPoint\n };\n }, []);\n const startPressAnimation = useCallback((target: HostElement, positionEvent?: PointerEvent<HostElement>) => {\n const ripple = rippleRef.current;\n if (!ripple) {\n return;\n }\n setPressed(true);\n growAnimation.current?.cancel();\n\n // Read once and share: the two helpers below both only need the\n // rect, and a second `getBoundingClientRect()` call back to back with\n // the first would be a redundant layout read.\n //\n // The surface's rect rather than the host's, since the ripple is placed\n // inside the surface. The two are one box wherever the surface fills\n // the host, which is every host but one drawing the surface in a part\n // of itself. Under forced colours the surface is not drawn and has no\n // box, so the host's stands in for a ripple nobody sees.\n const surface = ripple.parentElement?.getBoundingClientRect();\n const rect = surface && (surface.width > 0 || surface.height > 0) ? surface : target.getBoundingClientRect();\n const size = determineRippleSize(rect);\n const {\n endPoint,\n startPoint\n } = getTranslationCoordinates(rect, positionEvent);\n ripple.style.width = size;\n ripple.style.height = size;\n growAnimation.current = ripple.animate({\n transform: [`translate(${startPoint.x}px, ${startPoint.y}px) scale(1)`, `translate(${endPoint.x}px, ${endPoint.y}px) scale(${rippleScale.current})`]\n }, {\n // Growth runs over a fixed duration regardless of how long the\n // press is held, so the token is spent here rather than named as a\n // constant — element.animate() is one of the two places a StyleX\n // token could not have gone.\n //\n // Zeroed rather than skipped under reduced motion, which lands the\n // disc at its full size with the growth never drawn. Skipping the\n // call outright would leave `growAnimation` unset, and the release\n // below reads its `currentTime` to decide whether the press has\n // been visible long enough — so the press would still be shown, and\n // would stop being held for its minimum.\n duration: prefersReducedMotion() ? 0 : motionDurationMs.long1,\n easing: motionEasing.standard,\n fill: 'forwards'\n });\n }, [determineRippleSize, getTranslationCoordinates]);\n const endPressAnimation = useCallback(async () => {\n removeDocumentListeners.current?.();\n removeDocumentListeners.current = undefined;\n rippleStartEvent.current = undefined;\n state.current = RippleState.Inactive;\n const animation = growAnimation.current;\n const elapsed = typeof animation?.currentTime === 'number' ? animation.currentTime : Infinity;\n\n // The floor on how briefly a ripple may be visible, so a quick tap reads\n // as a deliberate ripple rather than a flicker.\n if (elapsed >= motionDurationMs.medium1) {\n setPressed(false);\n return;\n }\n await new Promise(resolve => {\n setTimeout(resolve, motionDurationMs.medium1 - elapsed);\n });\n if (growAnimation.current !== animation) {\n // A newer press started; let it own the pressed state instead.\n return;\n }\n setPressed(false);\n }, []);\n\n // A press can end somewhere other than its host. React Aria's press\n // handling releases the capture a touch takes on its pointerdown, so that a\n // finger can leave the element, and a press that turns into a scroll — or\n // a finger that slides off and lifts — then ends with a pointercancel or\n // pointerup on whatever is under it, which the host never hears. Left to\n // the host's handlers alone, the ripple held at its pressed opacity until\n // the next press on that host finished a cycle.\n //\n // So the press listens on its host's document, in the capture phase, for\n // its own pointer, the way React Aria's own press handling does. An end the\n // host does hear is left to the host's handlers, which run after these.\n const listenBeyondHost = useCallback((host: HostElement, pointerId: number) => {\n removeDocumentListeners.current?.();\n const document = host.ownerDocument;\n const handleEnd = (event: globalThis.PointerEvent) => {\n if (event.pointerId !== pointerId || event.composedPath().includes(host)) {\n return;\n }\n void endPressAnimation();\n };\n document.addEventListener('pointercancel', handleEnd, true);\n document.addEventListener('pointerup', handleEnd, true);\n removeDocumentListeners.current = () => {\n document.removeEventListener('pointercancel', handleEnd, true);\n document.removeEventListener('pointerup', handleEnd, true);\n };\n }, [endPressAnimation]);\n\n // A host unmounted mid-press leaves nothing listening behind it.\n useEffect(() => () => {\n removeDocumentListeners.current?.();\n }, []);\n\n // Reads through a function so a stale narrowing of `state.current` from\n // before the `await` below isn't (incorrectly) carried across it — the\n // ref can change via a different handler while this one is suspended.\n const getState = useCallback(() => state.current, []);\n const handlePointerDownAsync = useCallback(async (event: PointerEvent<HostElement>) => {\n if (!shouldReactToEvent(event)) {\n return;\n }\n rippleStartEvent.current = event;\n const target = event.currentTarget;\n listenBeyondHost(target, event.pointerId);\n if (!isTouch(event)) {\n state.current = RippleState.WaitingForClick;\n startPressAnimation(target, event);\n return;\n }\n\n // Delay so a scroll/swipe starting on the element doesn't flash a\n // ripple — only a held (or quickly released) touch counts as a press.\n state.current = RippleState.TouchDelay;\n await new Promise(resolve => {\n setTimeout(resolve, motionDurationMs.short2);\n });\n if (getState() !== RippleState.TouchDelay) {\n return;\n }\n state.current = RippleState.Holding;\n startPressAnimation(target, event);\n }, [getState, listenBeyondHost, shouldReactToEvent, startPressAnimation]);\n const handlePointerDown = useCallback((event: PointerEvent<HostElement>) => {\n void handlePointerDownAsync(event);\n }, [handlePointerDownAsync]);\n const handlePointerUp = useCallback((event: PointerEvent<HostElement>) => {\n // A mouse or pen release carries no pressed button, so the guard the\n // other handlers share turns it away, which is right while a click\n // follows to end the press. A host ending on the release matches it by\n // its pointer alone.\n if (endsOnRelease && !isTouch(event)) {\n if (isPressPointer(event) && state.current === RippleState.WaitingForClick) {\n void endPressAnimation();\n }\n return;\n }\n if (!shouldReactToEvent(event)) {\n return;\n }\n if (state.current === RippleState.Holding) {\n state.current = RippleState.WaitingForClick;\n } else if (state.current === RippleState.TouchDelay) {\n // Released before the delay elapsed: treat as a completed tap.\n state.current = RippleState.WaitingForClick;\n startPressAnimation(event.currentTarget, rippleStartEvent.current);\n }\n\n // The release is as far as such a host hears, so it is where the\n // press ends — see `endsOnRelease` above.\n if (endsOnRelease && state.current === RippleState.WaitingForClick) {\n void endPressAnimation();\n }\n }, [endPressAnimation, endsOnRelease, isPressPointer, shouldReactToEvent, startPressAnimation]);\n const handlePointerLeave = useCallback((event: PointerEvent<HostElement>) => {\n if (isTouch(event) || !shouldReactToEvent(event)) {\n return;\n }\n if (state.current !== RippleState.Inactive) {\n void endPressAnimation();\n }\n }, [endPressAnimation, shouldReactToEvent]);\n const handlePointerCancel = useCallback((event: PointerEvent<HostElement>) => {\n if (!shouldReactToEvent(event)) {\n return;\n }\n void endPressAnimation();\n }, [endPressAnimation, shouldReactToEvent]);\n const handleClick = useCallback((event: MouseEvent<HostElement>) => {\n if (state.current === RippleState.WaitingForClick) {\n void endPressAnimation();\n return;\n }\n if (state.current === RippleState.Inactive) {\n // No pointerdown preceded this click — keyboard activation, a\n // programmatic `.click()`, or assistive-tech-synthesized activation.\n // Play a complete, centered press immediately.\n startPressAnimation(event.currentTarget);\n void endPressAnimation();\n }\n }, [endPressAnimation, startPressAnimation]);\n const handleContextMenu = useCallback(() => {\n void endPressAnimation();\n }, [endPressAnimation]);\n const {\n onClick: onClickProp,\n onContextMenu: onContextMenuProp,\n onPointerCancel: onPointerCancelProp,\n onPointerDown: onPointerDownProp,\n onPointerLeave: onPointerLeaveProp,\n onPointerUp: onPointerUpProp\n } = externalHandlers;\n const onClick = useCallback((event: MouseEvent<HostElement>) => {\n handleClick(event);\n onClickProp?.(event);\n }, [handleClick, onClickProp]);\n const onContextMenu = useCallback((event: MouseEvent<HostElement>) => {\n handleContextMenu();\n onContextMenuProp?.(event);\n }, [handleContextMenu, onContextMenuProp]);\n const onPointerCancel = useCallback((event: PointerEvent<HostElement>) => {\n handlePointerCancel(event);\n onPointerCancelProp?.(event);\n }, [handlePointerCancel, onPointerCancelProp]);\n const onPointerDown = useCallback((event: PointerEvent<HostElement>) => {\n handlePointerDown(event);\n onPointerDownProp?.(event);\n }, [handlePointerDown, onPointerDownProp]);\n const onPointerLeave = useCallback((event: PointerEvent<HostElement>) => {\n handlePointerLeave(event);\n onPointerLeaveProp?.(event);\n }, [handlePointerLeave, onPointerLeaveProp]);\n const onPointerUp = useCallback((event: PointerEvent<HostElement>) => {\n handlePointerUp(event);\n onPointerUpProp?.(event);\n }, [handlePointerUp, onPointerUpProp]);\n const handlers = useMemo(() => {\n const pointer = {\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp\n };\n return endsOnRelease ? pointer : {\n onClick,\n ...pointer\n };\n }, [endsOnRelease, onClick, onContextMenu, onPointerCancel, onPointerDown, onPointerLeave, onPointerUp]);\n const surface = useMemo(() => <span aria-hidden=\"true\" {...surfaceProps}>\n <span ref={rippleRef} {...stylex.props(rippleStyles.press, pressed && rippleStyles.pressed)} />\n </span>, [pressed]);\n\n // Two separate memos rather than one branching on `enabled`, so that\n // whichever branch is actually active stays keyed only on its own\n // inputs — the enabled result doesn't get a new identity every time\n // `externalHandlers` does (a component typically passes a fresh object\n // literal each render), and vice versa.\n const enabledResult = useMemo(() => ({\n handlers,\n surface\n }), [handlers, surface]);\n const disabledResult = useMemo(() => ({\n handlers: externalHandlers,\n surface: null\n }), [externalHandlers]);\n return enabled ? enabledResult : disabledResult;\n}\nexport { useRipple };"],"mappings":";;;;;;;;AAeA,MAAMe,UAAUD,UAAUE;AAI1B,MAAMC,uBAAuB;AAC7B,MAAMC,yBAAyB;AAC/B,MAAMC,4BAA4B;AAIlC,MAAMC,eAAef,MAAaM,OAAaW,OAAO;;;;;;;;AAStD,MAAMC,cAAc;;CAElBC,SAAS;;CAETC,UAAU;;CAEVC,YAAY;;CAEZC,iBAAiB;AACnB;AAWA,SAASa,QAAQC,OAAqB;CACpC,OAAOA,MAAMC,gBAAgB;AAC/B;;;;;;;;;;;;;AAcA,SAASC,uBAAuB;CAC9B,OAAOC,OAAOC,WAAW,kCAAkC,CAAC,CAACC;AAC/D;AAkDA,SAAAC,UAAAK,IAAAC,IAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAA0D,MAAAR,UAAAI,OAAAK,KAAAA,IAAA,OAAAL;CAAc,IAAAM;CAAA,IAAAH,EAAA,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EAAA,MAAAkJ;CAAA,OAAAA,MAAAlJ,EAAA;CAFX,MAAAmJ,YAA8BD;CAEN,IAAAE;CAAA,IAAApJ,EAAA,QAAAJ,YAAAI,EAAA,QAAAmJ,WAAA;EAOaC,MAAA;GAAAxJ;GAAA7B,SAEnCA;EACF;EAACiC,EAAA,MAAAJ;EAAAI,EAAA,MAAAmJ;EAAAnJ,EAAA,MAAAoJ;CAAA,OAAAA,MAAApJ,EAAA;CAHD,MAAAqJ,gBAAqCD;CAGZ,IAAAE;CAAA,IAAAtJ,EAAA,QAAAN,kBAAA;EACa4J,MAAA;GAAA1J,UAC1BF;GAAgB3B,SACjB;EACX;EAACiC,EAAA,MAAAN;EAAAM,EAAA,MAAAsJ;CAAA,OAAAA,MAAAtJ,EAAA;CAAuB,OACjBP,UAAA4J,gBAAAE;AAAwC;AAjUjD,SAAA/C,MAAAgD,WAAA;CA8LMrE,WAAWD,WAAS7H,iBAAgBoM,MAAO;AAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
2
|
+
import { useLayoutEffect, useState } from "react";
|
|
3
|
+
//#region src/hooks/useScrollStop.ts
|
|
4
|
+
const TABBABLE = [
|
|
5
|
+
"a[href]",
|
|
6
|
+
"area[href]",
|
|
7
|
+
"audio[controls]",
|
|
8
|
+
"button:not(:disabled)",
|
|
9
|
+
"iframe",
|
|
10
|
+
"input:not(:disabled):not([type=\"hidden\"])",
|
|
11
|
+
"select:not(:disabled)",
|
|
12
|
+
"summary",
|
|
13
|
+
"textarea:not(:disabled)",
|
|
14
|
+
"video[controls]",
|
|
15
|
+
"[contenteditable]:not([contenteditable=\"false\"])",
|
|
16
|
+
"[tabindex]"
|
|
17
|
+
].join(", ");
|
|
18
|
+
const TAB_ORDER_ATTRIBUTES = [
|
|
19
|
+
"contenteditable",
|
|
20
|
+
"disabled",
|
|
21
|
+
"hidden",
|
|
22
|
+
"href",
|
|
23
|
+
"inert",
|
|
24
|
+
"tabindex"
|
|
25
|
+
];
|
|
26
|
+
/**
|
|
27
|
+
* The props that make the element in `ref` a tab stop while it scrolls its
|
|
28
|
+
* content and holds nothing a keyboard can reach: its content runs past the
|
|
29
|
+
* element's own size in either direction, and nothing inside it is in the
|
|
30
|
+
* tab order. Kept current as the element resizes and as its content changes.
|
|
31
|
+
*
|
|
32
|
+
* What it is for is keyboard access. A scroll container with nothing
|
|
33
|
+
* focusable inside it cannot be reached from the keyboard in every browser,
|
|
34
|
+
* so it is made a tab stop, and only then — a body short enough to show
|
|
35
|
+
* whole is no stop at all, and one holding a field or a button is reached
|
|
36
|
+
* and scrolled through that, where a stop of its own would be one more press
|
|
37
|
+
* of Tab before the control.
|
|
38
|
+
*
|
|
39
|
+
* While it is a stop it is a region named by the panel's title, so a screen
|
|
40
|
+
* reader landing on it says what it is rather than announcing an unnamed
|
|
41
|
+
* group. A call site's `aria-label` names it instead, and a body with neither
|
|
42
|
+
* stays a plain stop, since a region with no name is not one. The call site's
|
|
43
|
+
* own `role`, `aria-labelledby` and `tabIndex` are spread after these, so
|
|
44
|
+
* they win.
|
|
45
|
+
*
|
|
46
|
+
* The element is watched for its own size, and each child for its size, since
|
|
47
|
+
* a child growing is how content outgrows a container whose size is capped.
|
|
48
|
+
* The children are re-observed whenever the content changes, and a change of
|
|
49
|
+
* text alone is caught by the same mutation observer, as is a control
|
|
50
|
+
* entering or leaving the tab order. Measured in a layout effect, so the
|
|
51
|
+
* first paint already has the answer rather than a frame later.
|
|
52
|
+
*/
|
|
53
|
+
function useScrollStop(ref, t0) {
|
|
54
|
+
const $ = c(7);
|
|
55
|
+
const { label, title } = t0;
|
|
56
|
+
const [scrolls, setScrolls] = useState(false);
|
|
57
|
+
const [holdsTabStop, setHoldsTabStop] = useState(false);
|
|
58
|
+
let t1;
|
|
59
|
+
let t2;
|
|
60
|
+
if ($[0] !== ref) {
|
|
61
|
+
t1 = () => {
|
|
62
|
+
const element = ref.current;
|
|
63
|
+
if (element === null) return;
|
|
64
|
+
const measure = () => {
|
|
65
|
+
setScrolls(element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth);
|
|
66
|
+
};
|
|
67
|
+
const read = () => {
|
|
68
|
+
setHoldsTabStop([...element.querySelectorAll(TABBABLE)].some(_temp));
|
|
69
|
+
};
|
|
70
|
+
const resize = new ResizeObserver(measure);
|
|
71
|
+
const observe = () => {
|
|
72
|
+
resize.disconnect();
|
|
73
|
+
resize.observe(element);
|
|
74
|
+
for (const child of element.children) resize.observe(child);
|
|
75
|
+
};
|
|
76
|
+
const mutation = new MutationObserver(() => {
|
|
77
|
+
observe();
|
|
78
|
+
measure();
|
|
79
|
+
read();
|
|
80
|
+
});
|
|
81
|
+
observe();
|
|
82
|
+
mutation.observe(element, {
|
|
83
|
+
attributeFilter: TAB_ORDER_ATTRIBUTES,
|
|
84
|
+
characterData: true,
|
|
85
|
+
childList: true,
|
|
86
|
+
subtree: true
|
|
87
|
+
});
|
|
88
|
+
measure();
|
|
89
|
+
read();
|
|
90
|
+
return () => {
|
|
91
|
+
resize.disconnect();
|
|
92
|
+
mutation.disconnect();
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
t2 = [ref];
|
|
96
|
+
$[0] = ref;
|
|
97
|
+
$[1] = t1;
|
|
98
|
+
$[2] = t2;
|
|
99
|
+
} else {
|
|
100
|
+
t1 = $[1];
|
|
101
|
+
t2 = $[2];
|
|
102
|
+
}
|
|
103
|
+
useLayoutEffect(t1, t2);
|
|
104
|
+
if (!scrolls || holdsTabStop) {
|
|
105
|
+
let t3;
|
|
106
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
107
|
+
t3 = {};
|
|
108
|
+
$[3] = t3;
|
|
109
|
+
} else t3 = $[3];
|
|
110
|
+
return t3;
|
|
111
|
+
}
|
|
112
|
+
const t3 = label === void 0 ? title : void 0;
|
|
113
|
+
const t4 = label === void 0 && title === void 0 ? void 0 : "region";
|
|
114
|
+
let t5;
|
|
115
|
+
if ($[4] !== t3 || $[5] !== t4) {
|
|
116
|
+
t5 = {
|
|
117
|
+
"aria-labelledby": t3,
|
|
118
|
+
role: t4,
|
|
119
|
+
tabIndex: 0
|
|
120
|
+
};
|
|
121
|
+
$[4] = t3;
|
|
122
|
+
$[5] = t4;
|
|
123
|
+
$[6] = t5;
|
|
124
|
+
} else t5 = $[6];
|
|
125
|
+
return t5;
|
|
126
|
+
}
|
|
127
|
+
function _temp(candidate) {
|
|
128
|
+
return candidate.tabIndex >= 0 && candidate.closest("[inert]") === null && candidate.getClientRects().length > 0;
|
|
129
|
+
}
|
|
130
|
+
//#endregion
|
|
131
|
+
export { useScrollStop };
|
|
132
|
+
|
|
133
|
+
//# sourceMappingURL=useScrollStop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useScrollStop.js","names":["HTMLAttributes","RefObject","useLayoutEffect","useState","TABBABLE","join","TAB_ORDER_ATTRIBUTES","Naming","label","title","ScrollStopProps","Pick","HTMLElement","useScrollStop","ref","t0","$","_c","scrolls","setScrolls","holdsTabStop","setHoldsTabStop","t1","t2","element","current","measure","scrollHeight","clientHeight","scrollWidth","clientWidth","read","querySelectorAll","some","_temp","resize","ResizeObserver","observe","disconnect","child","children","mutation","MutationObserver","attributeFilter","characterData","childList","subtree","t3","Symbol","for","undefined","t4","t5","role","tabIndex","candidate","closest","getClientRects","length","_c"],"sources":["../../src/hooks/useScrollStop.ts"],"sourcesContent":["import type { HTMLAttributes, RefObject } from 'react'\n\nimport { useLayoutEffect, useState } from 'react'\n\n// What a keyboard reaches with Tab: the controls that are focusable by\n// default, and anything a `tabindex` puts in the order. Each match is then\n// held to `tabIndex >= 0`, which drops a control taken out with\n// `tabindex=\"-1\"`, and to being drawn, which drops a hidden one.\nconst TABBABLE = [\n 'a[href]',\n 'area[href]',\n 'audio[controls]',\n 'button:not(:disabled)',\n 'iframe',\n 'input:not(:disabled):not([type=\"hidden\"])',\n 'select:not(:disabled)',\n 'summary',\n 'textarea:not(:disabled)',\n 'video[controls]',\n '[contenteditable]:not([contenteditable=\"false\"])',\n '[tabindex]',\n].join(', ')\n\n// The attributes that move a control in or out of the tab order, so a\n// change to one re-reads what the element holds.\nconst TAB_ORDER_ATTRIBUTES = [\n 'contenteditable',\n 'disabled',\n 'hidden',\n 'href',\n 'inert',\n 'tabindex',\n]\n\n/** What a panel's body is named by while it is a tab stop. */\ntype Naming = {\n /** The call site's own `aria-label`, which names it in place of the title. */\n label: string | undefined\n /** The id of the panel's title. */\n title: string | undefined\n}\n\ntype ScrollStopProps = Pick<\n HTMLAttributes<HTMLElement>,\n 'aria-labelledby' | 'role' | 'tabIndex'\n>\n\n/**\n * The props that make the element in `ref` a tab stop while it scrolls its\n * content and holds nothing a keyboard can reach: its content runs past the\n * element's own size in either direction, and nothing inside it is in the\n * tab order. Kept current as the element resizes and as its content changes.\n *\n * What it is for is keyboard access. A scroll container with nothing\n * focusable inside it cannot be reached from the keyboard in every browser,\n * so it is made a tab stop, and only then — a body short enough to show\n * whole is no stop at all, and one holding a field or a button is reached\n * and scrolled through that, where a stop of its own would be one more press\n * of Tab before the control.\n *\n * While it is a stop it is a region named by the panel's title, so a screen\n * reader landing on it says what it is rather than announcing an unnamed\n * group. A call site's `aria-label` names it instead, and a body with neither\n * stays a plain stop, since a region with no name is not one. The call site's\n * own `role`, `aria-labelledby` and `tabIndex` are spread after these, so\n * they win.\n *\n * The element is watched for its own size, and each child for its size, since\n * a child growing is how content outgrows a container whose size is capped.\n * The children are re-observed whenever the content changes, and a change of\n * text alone is caught by the same mutation observer, as is a control\n * entering or leaving the tab order. Measured in a layout effect, so the\n * first paint already has the answer rather than a frame later.\n */\nfunction useScrollStop(\n ref: RefObject<HTMLElement | null>,\n { label, title }: Naming,\n): ScrollStopProps {\n const [scrolls, setScrolls] = useState(false)\n const [holdsTabStop, setHoldsTabStop] = useState(false)\n\n useLayoutEffect(() => {\n const element = ref.current\n if (element === null) {\n return undefined\n }\n\n const measure = () => {\n setScrolls(\n element.scrollHeight > element.clientHeight ||\n element.scrollWidth > element.clientWidth,\n )\n }\n const read = () => {\n setHoldsTabStop(\n [...element.querySelectorAll<HTMLElement>(TABBABLE)].some(\n (candidate) =>\n candidate.tabIndex >= 0 &&\n candidate.closest('[inert]') === null &&\n candidate.getClientRects().length > 0,\n ),\n )\n }\n const resize = new ResizeObserver(measure)\n const observe = () => {\n resize.disconnect()\n resize.observe(element)\n for (const child of element.children) {\n resize.observe(child)\n }\n }\n const mutation = new MutationObserver(() => {\n observe()\n measure()\n read()\n })\n\n observe()\n mutation.observe(element, {\n attributeFilter: TAB_ORDER_ATTRIBUTES,\n characterData: true,\n childList: true,\n subtree: true,\n })\n measure()\n read()\n\n return () => {\n resize.disconnect()\n mutation.disconnect()\n }\n }, [ref])\n\n if (!scrolls || holdsTabStop) {\n return {}\n }\n return {\n 'aria-labelledby': label === undefined ? title : undefined,\n role: label === undefined && title === undefined ? undefined : 'region',\n tabIndex: 0,\n }\n}\n\nexport { useScrollStop }\n"],"mappings":";;;AAQA,MAAMI,WAAW;CACf;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAAY,CACb,CAACC,KAAK,IAAI;AAIX,MAAMC,uBAAuB;CAC3B;CACA;CACA;CACA;CACA;CACA;AAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CZ,SAAAO,cAAAC,KAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAEE,MAAA,EAAAT,OAAAC,UAAAM;CAEA,MAAA,CAAAG,SAAAC,cAA8BhB,SAAS,KAAK;CAC5C,MAAA,CAAAiB,cAAAC,mBAAwClB,SAAS,KAAK;CAAC,IAAAmB;CAAA,IAAAC;CAAA,IAAAP,EAAA,OAAAF,KAAA;EAEvCQ,WAAA;GACd,MAAAE,UAAgBV,IAAGW;GACnB,IAAID,YAAY,MAAI;GAIpB,MAAAE,gBAAgB;IACdP,WACEK,QAAOG,eAAgBH,QAAOI,gBAC5BJ,QAAOK,c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7D;EACZ;EAACtC,EAAA,KAAA+B;EAAA/B,EAAA,KAAAmC;EAAAnC,EAAA,KAAAoC;CAAA,OAAAA,KAAApC,EAAA;CAAA,OAJMoC;AAIN;AAlEH,SAAAlB,MAAAqB,WAAA;CAAA,OAuBYA,UAASD,YAAa,KACtBC,UAASC,QAAS,SAAS,MAAM,QACjCD,UAASE,eAAgB,CAAC,CAAAC,SAAU;AAAC"}
|
package/dist/i18n/index.js
CHANGED
|
@@ -19,6 +19,7 @@ function messagesFor(locale) {
|
|
|
19
19
|
count: numbers.format(count),
|
|
20
20
|
rule: rules.select(count)
|
|
21
21
|
}),
|
|
22
|
+
characterLimitReached: formatter.format("characterLimitReached"),
|
|
22
23
|
confirm: formatter.format("confirm"),
|
|
23
24
|
copied: formatter.format("copied"),
|
|
24
25
|
copy: formatter.format("copy"),
|
package/dist/i18n/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["LocalizedStringDictionary","LocalizedStringFormatter","useLocale","MESSAGES","LibraryMessages","back","cancel","carousel","characterLimit","count","confirm","copied","copy","copySelected","enterTime","loading","loadingMore","nextSlide","noResults","previousSlide","selectTime","slide","slideLabel","index","dictionary","cache","Map","messagesFor","locale","cached","get","undefined","formatter","numbers","Intl","NumberFormat","rules","PluralRules","messages","format","rule","select","set","useMessages","$","_c","t0","t1","_c"],"sources":["../../src/i18n/index.ts"],"sourcesContent":["import {\n LocalizedStringDictionary,\n LocalizedStringFormatter,\n} from '@internationalized/string'\nimport { useLocale } from 'react-aria-components'\n\nimport { MESSAGES } from './messages'\n\n// The words the library writes itself, in the locale React Aria's\n// I18nProvider sets — the same locale every other name a control announces is\n// written in. Each one stands behind a prop that names it otherwise:\n// `pendingLabel`, a LoadMore's `label`, `copyLabel`, `copiedLabel` and\n// `selectedLabel`,\n//
|
|
1
|
+
{"version":3,"file":"index.js","names":["LocalizedStringDictionary","LocalizedStringFormatter","useLocale","MESSAGES","LibraryMessages","back","cancel","carousel","characterLimit","count","characterLimitReached","confirm","copied","copy","copySelected","enterTime","loading","loadingMore","nextSlide","noResults","previousSlide","selectTime","slide","slideLabel","index","dictionary","cache","Map","messagesFor","locale","cached","get","undefined","formatter","numbers","Intl","NumberFormat","rules","PluralRules","messages","format","rule","select","set","useMessages","$","_c","t0","t1","_c"],"sources":["../../src/i18n/index.ts"],"sourcesContent":["import {\n LocalizedStringDictionary,\n LocalizedStringFormatter,\n} from '@internationalized/string'\nimport { useLocale } from 'react-aria-components'\n\nimport { MESSAGES } from './messages'\n\n// The words the library writes itself, in the locale React Aria's\n// I18nProvider sets — the same locale every other name a control announces is\n// written in. Each one stands behind a prop that names it otherwise:\n// `pendingLabel`, a LoadMore's `label`, `copyLabel`, `copiedLabel` and\n// `selectedLabel`, `characterLimitLabel` and `characterLimitReachedLabel`,\n// the time picker's `cancelLabel`, `confirmLabel`, `selectTimeLabel` and\n// `enterTimeLabel`, and a collection's `renderEmptyState` for its empty row.\n\ntype LibraryMessages = {\n /** What a search view's back button is called. */\n back: string\n /** The time picker's action that closes it and keeps the time it had. */\n cancel: string\n /** What a carousel calls itself, as its role description. */\n carousel: string\n /** The limit on a field's length, in words, for a count of characters. */\n characterLimit: (count: number) => string\n /** What a field announces once its length reaches its limit. */\n characterLimitReached: string\n /** The time picker's action that closes it and keeps the time picked. */\n confirm: string\n copied: string\n copy: string\n /**\n * What a copy field says when the clipboard refused it and the value has\n * been selected for the reader to copy themselves.\n */\n copySelected: string\n /** The time picker's headline while it takes a time typed. */\n enterTime: string\n loading: string\n loadingMore: string\n /** What a carousel's next button is called. */\n nextSlide: string\n /** What a collection says when filtering leaves nothing in it. */\n noResults: string\n /** What a carousel's previous button is called. */\n previousSlide: string\n /** The time picker's headline while it shows the dial. */\n selectTime: string\n /** What a carousel calls one of its slides, as its role description. */\n slide: string\n /** A slide's name: which of how many it is, as \"2 of 6\". */\n slideLabel: (index: number, count: number) => string\n}\n\nconst dictionary = new LocalizedStringDictionary(MESSAGES)\n\n// One set per locale an app renders in, built the first time a component asks\n// for it. Every string but the limit is fixed for its locale, so the set holds\n// them already formatted rather than formatting them on each render.\nconst cache = new Map<string, LibraryMessages>()\n\nfunction messagesFor(locale: string): LibraryMessages {\n const cached = cache.get(locale)\n if (cached !== undefined) {\n return cached\n }\n\n const formatter = new LocalizedStringFormatter(locale, dictionary)\n const numbers = new Intl.NumberFormat(locale)\n const rules = new Intl.PluralRules(locale)\n const messages = {\n back: formatter.format('back'),\n cancel: formatter.format('cancel'),\n carousel: formatter.format('carousel'),\n characterLimit: (count: number) =>\n formatter.format('characterLimit', {\n count: numbers.format(count),\n rule: rules.select(count),\n }),\n characterLimitReached: formatter.format('characterLimitReached'),\n confirm: formatter.format('confirm'),\n copied: formatter.format('copied'),\n copy: formatter.format('copy'),\n copySelected: formatter.format('copySelected'),\n enterTime: formatter.format('enterTime'),\n loading: formatter.format('loading'),\n loadingMore: formatter.format('loadingMore'),\n nextSlide: formatter.format('nextSlide'),\n noResults: formatter.format('noResults'),\n previousSlide: formatter.format('previousSlide'),\n selectTime: formatter.format('selectTime'),\n slide: formatter.format('slide'),\n slideLabel: (index: number, count: number) =>\n formatter.format('slideLabel', {\n count: numbers.format(count),\n index: numbers.format(index),\n }),\n }\n cache.set(locale, messages)\n return messages\n}\n\n/** The library's own words, in the I18nProvider's locale. */\nfunction useMessages(): LibraryMessages {\n return messagesFor(useLocale().locale)\n}\n\nexport type { LibraryMessages }\n\nexport { messagesFor, useMessages }\n"],"mappings":";;;;;AAsDA,MAAMyB,aAAa,IAAIzB,0BAA0BG,QAAQ;AAKzD,MAAMuB,wBAAQ,IAAIC,IAA6B;AAE/C,SAASC,YAAYC,QAAiC;CACpD,MAAMC,SAASJ,MAAMK,IAAIF,MAAM;CAC/B,IAAIC,WAAWE,KAAAA,GACb,OAAOF;CAGT,MAAMG,YAAY,IAAIhC,yBAAyB4B,QAAQJ,UAAU;CACjE,MAAMS,UAAU,IAAIC,KAAKC,aAAaP,MAAM;CAC5C,M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