@kanso-labs/react-native-kanso-ui 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/button/index.d.ts +32 -2
- package/dist/button/index.js +38 -26
- package/dist/button/index.js.map +1 -1
- package/dist/button/pending.js +144 -0
- package/dist/button/pending.js.map +1 -0
- package/dist/button/slots.js +7 -0
- package/dist/button/slots.js.map +1 -0
- package/dist/components/avatar/index.d.ts +2 -2
- package/dist/components/avatar/index.js.map +1 -1
- package/dist/components/button/index.d.ts +3 -3
- package/dist/components/button/index.js +159 -111
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/card/index.d.ts +2 -2
- package/dist/components/card/index.js.map +1 -1
- package/dist/components/checkbox/index.d.ts +2 -2
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/chip/index.d.ts +2 -2
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/chip-group/index.d.ts +3 -3
- package/dist/components/chip-group/index.js.map +1 -1
- package/dist/components/copy-field/index.d.ts +2 -2
- package/dist/components/copy-field/index.js.map +1 -1
- package/dist/components/dialog/index.d.ts +131 -0
- package/dist/components/dialog/index.js +861 -0
- package/dist/components/dialog/index.js.map +1 -0
- package/dist/components/icon-button/index.d.ts +3 -3
- package/dist/components/icon-button/index.js +165 -109
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/link/index.js +1 -1
- package/dist/components/link/index.js.map +1 -1
- package/dist/components/meter/index.d.ts +73 -0
- package/dist/components/meter/index.js +179 -0
- package/dist/components/meter/index.js.map +1 -0
- package/dist/components/number-field/index.d.ts +3 -3
- package/dist/components/number-field/index.js +1 -9
- package/dist/components/number-field/index.js.map +1 -1
- package/dist/components/product-icon/index.d.ts +2 -2
- package/dist/components/product-icon/index.js.map +1 -1
- package/dist/components/progress-indicator/index.d.ts +113 -0
- package/dist/components/progress-indicator/index.js +1024 -0
- package/dist/components/progress-indicator/index.js.map +1 -0
- package/dist/components/radio-group/index.d.ts +3 -3
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/search-field/index.d.ts +3 -3
- package/dist/components/search-field/index.js.map +1 -1
- package/dist/components/segmented-button/index.d.ts +3 -3
- package/dist/components/segmented-button/index.js.map +1 -1
- package/dist/components/snackbar/index.d.ts +120 -0
- package/dist/components/snackbar/index.js +540 -0
- package/dist/components/snackbar/index.js.map +1 -0
- package/dist/components/switch/index.d.ts +2 -2
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/text-field/index.d.ts +3 -3
- package/dist/components/text-field/index.js.map +1 -1
- package/dist/field/index.d.ts +1 -1
- package/dist/field/index.js.map +1 -1
- package/dist/form/index.d.ts +1 -1
- package/dist/form/index.js.map +1 -1
- package/dist/glyphs/hidden.js +13 -0
- package/dist/glyphs/hidden.js.map +1 -0
- package/dist/glyphs/index.js +2 -8
- package/dist/glyphs/index.js.map +1 -1
- package/dist/i18n/index.js +23 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/messages.js +41 -0
- package/dist/i18n/messages.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +7 -3
- package/dist/indicator/index.d.ts +15 -0
- package/dist/indicator/index.js +256 -0
- package/dist/indicator/index.js.map +1 -0
- package/dist/indicator/motion.js +86 -0
- package/dist/indicator/motion.js.map +1 -0
- package/dist/indicator/paths.js +72 -0
- package/dist/indicator/paths.js.map +1 -0
- package/dist/indicator/styles.js +62 -0
- package/dist/indicator/styles.js.map +1 -0
- package/dist/mark/index.d.ts +1 -1
- package/dist/mark/index.js.map +1 -1
- package/dist/number/locale.js +14 -0
- package/dist/number/locale.js.map +1 -0
- package/dist/overlay/host.js +65 -2
- package/dist/overlay/host.js.map +1 -1
- package/dist/press/index.js +63 -63
- package/dist/press/index.js.map +1 -1
- package/dist/theme/resolve.js +1 -1
- package/dist/theme/resolve.js.map +1 -1
- package/package.json +11 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","names":["StyleSheet","themedStyles","THICKNESS","GAP","RESERVED","DETERMINATE_EASING","const","styles","create","active","flexShrink","height","label","minWidth","line","alignItems","alignSelf","flexDirection","gap","stop","width","track","flexGrow","overflow","value","marginStart","stylesOf","radii","spacing","borderRadius","pill","labels","sm","justifyContent","root","xs","circle"],"sources":["../../src/indicator/styles.ts"],"sourcesContent":["import { StyleSheet } from 'react-native'\n\nimport { themedStyles } from '../theme/styles'\n\n// The line the progress indicators page draws, and the label row above it,\n// shared by the two components that draw one, as web's src/indicator is:\n// ProgressIndicator, which adds the ring and the two indeterminate\n// presentations on top, and Meter, which is this and nothing else.\n//\n// The page's anatomy names three parts, the active indicator, the track and\n// the stop indicator at the end, at 4dp thick with 4dp between them. The row\n// is a flex row and the two gaps are its `gap`. The active indicator takes the\n// value's share of what the two gaps and the stop leave, and the track takes\n// the rest, so the stop ends the row at every value.\n\n/** The thickness of every part, and the room the page leaves between them. */\nconst THICKNESS = 4\nconst GAP = 4\n\n/** What the two gaps and the stop indicator take from the row. */\nconst RESERVED = GAP * 2 + THICKNESS\n\n/**\n * The curve a determinate value moves along, Material's own, over the motion\n * scale's `durationMedium1`.\n */\nconst DETERMINATE_EASING = [0.4, 0, 0.6, 1] as const\n\nconst styles = StyleSheet.create({\n // The active indicator. Its width is the value's, and is set where it\n // renders.\n active: {\n flexShrink: 0,\n height: THICKNESS,\n },\n // The label's own part of the row. It gives way to the value, and breaks a\n // word wider than the room rather than widening the row: a file name or a\n // compound otherwise pushed the value off the end. The browser keeps a flex\n // item as wide as its longest word unless told it may be narrower.\n label: {\n flexShrink: 1,\n minWidth: 0,\n },\n // The three parts, with the page's 4dp between them.\n line: {\n alignItems: 'center',\n alignSelf: 'stretch',\n flexDirection: 'row',\n gap: GAP,\n height: THICKNESS,\n },\n stop: {\n flexShrink: 0,\n height: THICKNESS,\n width: THICKNESS,\n },\n // The track: whatever the active indicator and the gaps leave. Given\n // something to hold it becomes a row of its own, clipped to its corners.\n track: {\n flexDirection: 'row',\n flexGrow: 1,\n flexShrink: 1,\n height: THICKNESS,\n minWidth: 0,\n overflow: 'hidden',\n },\n // The value: whole, on one line, and at the end of the row whether or not a\n // label is beside it.\n value: {\n flexShrink: 0,\n marginStart: 'auto',\n },\n})\n\nconst stylesOf = themedStyles(({ radii, spacing }) =>\n StyleSheet.create({\n // The active indicator and the track are pills, and the stop a dot.\n active: { borderRadius: radii.pill },\n // The label and the value either end of a row above the indicator.\n labels: {\n alignItems: 'baseline',\n flexDirection: 'row',\n gap: spacing.sm,\n justifyContent: 'space-between',\n },\n // The label row and the line, stacked.\n root: { gap: spacing.xs },\n stop: { borderRadius: radii.circle },\n track: { borderRadius: radii.pill },\n }),\n)\n\nexport { DETERMINATE_EASING, GAP, RESERVED, styles, stylesOf, THICKNESS }\n"],"mappings":";;;;;;AA0BA,MAAMK,qBAAqB;CAAC;CAAK;CAAG;CAAK;AAAC;AAE1C,MAAME,SAASP,WAAWQ,OAAO;CAG/BC,QAAQ;EACNC,YAAY;EACZC,QAAAA;CACF;CAKAC,OAAO;EACLF,YAAY;EACZG,UAAU;CACZ;CAEAC,MAAM;EACJC,YAAY;EACZC,WAAW;EACXC,eAAe;EACfC,KAAAA;EACAP,QAAAA;CACF;CACAQ,MAAM;EACJT,YAAY;EACZC,QAAAA;EACAS,OAAAA;CACF;CAGAC,OAAO;EACLJ,eAAe;EACfK,UAAU;EACVZ,YAAY;EACZC,QAAAA;EACAE,UAAU;EACVU,UAAU;CACZ;CAGAC,OAAO;EACLd,YAAY;EACZe,aAAa;CACf;AACF,CAAC;AAED,MAAMC,WAAWzB,cAAc,EAAE0B,OAAOC,cACtC5B,WAAWQ,OAAO;CAEhBC,QAAQ,EAAEoB,cAAcF,MAAMG,KAAK;CAEnCC,QAAQ;EACNhB,YAAY;EACZE,eAAe;EACfC,KAAKU,QAAQI;EACbC,gBAAgB;CAClB;CAEAC,MAAM,EAAEhB,KAAKU,QAAQO,GAAG;CACxBhB,MAAM,EAAEU,cAAcF,MAAMS,OAAO;CACnCf,OAAO,EAAEQ,cAAcF,MAAMG,KAAK;AACpC,CAAC,CACH"}
|
package/dist/mark/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./styles.js";
|
|
2
2
|
import { ImageProps, StyleProp, View, ViewProps, ViewStyle } from "react-native";
|
|
3
|
-
import { Ref } from "react";
|
|
3
|
+
import { ComponentRef, Ref } from "react";
|
|
4
4
|
//#region src/mark/index.d.ts
|
|
5
5
|
/** The native props a picture's own `Image` takes, as Avatar and ProductIcon take them. */
|
|
6
6
|
type MarkImageProps = Pick<ImageProps, 'crossOrigin' | 'fadeDuration' | 'progressiveRenderingEnabled' | 'referrerPolicy' | 'resizeMethod'>;
|
package/dist/mark/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Ref","ImageProps","ImageSourcePropType","ImageStyle","StyleProp","TextStyle","ViewProps","ViewStyle","Image","Text","NativeText","View","ResolvedTheme","MarkSize","MarkTone","PersonGlyph","useTheme","composeStyles","useTypeRole","useImageLoadingStatus","initialOfThing","initialsOfPerson","DIAMETERS","GLYPH_SHARE","initialsStylesOf","markStyles","markStylesOf","MarkImageProps","Pick","MarkProps","Omit","decorative","imgProps","kind","KINDS","name","ref","showPersonIcon","size","src","style","tone","person","initials","resizeMode","shape","tintsFallback","thing","const","CONTENT","Readonly","Record","negative","positive","primary","secondary","tertiary","Mark","t0","$","_c","props","t1","t2","undefined","theme","label","handlersFor","previous","status","T0","initialsNode","t3","t4","t5","t6","t7","t8","own","text","t9","fallback","named","trim","showsPicture","t10","colors","initialsText","base","sourceOf","image","imagePending","t11","uri","_c","NativeText"],"sources":["../../src/mark/index.tsx"],"sourcesContent":["import type { Ref } from 'react'\nimport type {\n ImageProps,\n ImageSourcePropType,\n ImageStyle,\n StyleProp,\n TextStyle,\n ViewProps,\n ViewStyle,\n} from 'react-native'\n\nimport { Image, Text as NativeText, View } from 'react-native'\n\nimport type { ResolvedTheme } from '../theme/scope'\nimport type { MarkSize, MarkTone } from './styles'\n\nimport { PersonGlyph } from '../glyphs'\nimport { useTheme } from '../theme/scope'\nimport { composeStyles } from '../theme/styles'\nimport { useTypeRole } from '../typography/roles'\nimport { useImageLoadingStatus } from './image'\nimport { initialOfThing, initialsOfPerson } from './initials'\nimport {\n DIAMETERS,\n GLYPH_SHARE,\n initialsStylesOf,\n markStyles,\n markStylesOf,\n} from './styles'\n\n/** The native props a picture's own `Image` takes, as Avatar and ProductIcon take them. */\ntype MarkImageProps = Pick<\n ImageProps,\n | 'crossOrigin'\n | 'fadeDuration'\n | 'progressiveRenderingEnabled'\n | 'referrerPolicy'\n | 'resizeMethod'\n>\n\ntype MarkProps = Omit<ViewProps, 'children' | 'style'> & {\n /**\n * Hides the mark from screen readers, for one beside the name it stands\n * for, which would otherwise be announced twice.\n */\n readonly decorative?: boolean\n /** Props for the picture's own `Image`. */\n readonly imgProps?: MarkImageProps\n /** A person, which Avatar draws, or anything else, which ProductIcon does. */\n readonly kind: keyof typeof KINDS\n /** Supplies the fallback's initials, and the accessible name unless decorative. */\n readonly name: string\n readonly ref?: Ref<View>\n /**\n * Whether a person with no initials to take, a blank name, draws the\n * anonymous person, or an empty disc, as a loading skeleton wants.\n */\n readonly showPersonIcon?: boolean\n readonly size: MarkSize\n /** A picture to show in place of the initials once it has loaded. */\n readonly src?: string\n readonly style?: StyleProp<ViewStyle>\n readonly tone: MarkTone\n}\n\n// What each kind of mark is drawn as. The header of `./styles` says why the\n// two differ where they do; everything not in this table is the same for\n// both.\nconst KINDS = {\n person: {\n initials: initialsOfPerson,\n resizeMode: 'cover',\n shape: 'circle',\n tintsFallback: false,\n },\n thing: {\n initials: initialOfThing,\n resizeMode: 'contain',\n shape: 'square',\n tintsFallback: true,\n },\n} as const\n\n// The role each tone draws the anonymous person in.\nconst CONTENT: Readonly<Record<MarkTone, keyof ResolvedTheme['colors']>> = {\n negative: 'onNegativeContainer',\n positive: 'onPositiveContainer',\n primary: 'onPrimaryContainer',\n secondary: 'onSecondaryContainer',\n tertiary: 'onTertiaryContainer',\n}\n\n/**\n * The small identity mark Avatar and ProductIcon both render: a picture once\n * it has loaded, initials until then or if it fails, named for whoever or\n * whatever it stands for. Shared rather than written into each, so a fix to\n * one reaches both, as on web. Not a component of the library's own, and not\n * exported from the package.\n */\nfunction Mark({\n decorative = false,\n imgProps,\n kind,\n name,\n showPersonIcon = true,\n size,\n src,\n style,\n tone,\n ...props\n}: MarkProps) {\n const { initials, resizeMode, shape, tintsFallback } = KINDS[kind]\n const theme = useTheme()\n const label = useTypeRole('labelLarge')\n const { handlersFor, previous, status } = useImageLoadingStatus(src)\n\n const own = markStylesOf(theme)\n const text = initialsStylesOf(theme)\n const fallback = initials(name)\n\n // Announced as an image named for whoever or whatever it stands for,\n // rather than letting the initials be read: \"AL\" is not what anyone means\n // to announce. A blank name names nothing, so the mark is then a plain\n // view, which a screen reader passes over rather than reading as an image\n // with no name. A decorative mark is hidden outright, its initials with it.\n const named = !decorative && name.trim() !== ''\n\n // The initials while no picture shows: before the first loads, and once\n // one fails. They are left out under a picture rather than kept beneath\n // it, since a letterboxed logo would show them through its transparent\n // parts.\n const showsPicture = status === 'loaded' || previous !== undefined\n let initialsNode = null\n if (!showsPicture && kind === 'person' && fallback === '') {\n // A person with no initials to take, a blank name or one still loading,\n // draws Material Design's anonymous person in the tone's on-container\n // colour. The glyph hides itself from screen readers.\n initialsNode = showPersonIcon ? (\n <PersonGlyph\n color={theme.colors[CONTENT[tone]]}\n size={DIAMETERS[size] * GLYPH_SHARE}\n />\n ) : null\n } else if (!showsPicture) {\n // The initials keep their size whatever the device's text size asks\n // for: the mark is a fixed size and clips what runs past it, and the\n // name a screen reader reads is what they stand for.\n const initialsText = (\n <NativeText\n allowFontScaling={false}\n style={composeStyles<TextStyle>(label, text[size], text[tone])}\n >\n {fallback}\n </NativeText>\n )\n initialsNode = tintsFallback ? (\n <View style={composeStyles<ViewStyle>(markStyles.fallback, own[tone])}>\n {initialsText}\n </View>\n ) : (\n initialsText\n )\n }\n\n return (\n <View\n accessible={named ? true : undefined}\n aria-hidden={decorative ? true : undefined}\n aria-label={named ? name : undefined}\n role={named ? 'img' : undefined}\n {...props}\n style={composeStyles<ViewStyle>(\n own.base,\n own[shape],\n markStyles[size],\n tintsFallback ? undefined : own[tone],\n style,\n )}\n >\n {initialsNode}\n {/* Two pictures at most, laid over the initials. The one last loaded\n stays while a new `src` loads, and the new one is drawn on top of\n it from the start, hidden until it has loaded. Neither is inverted\n by the iOS Smart Invert setting, which is meant for interface\n colours rather than pictures. */}\n {previous === undefined ? null : (\n <Image\n accessibilityIgnoresInvertColors\n key={previous}\n resizeMode={resizeMode}\n source={sourceOf(previous)}\n style={markStyles.image}\n />\n )}\n {src === undefined || status === 'error' ? null : (\n <Image\n accessibilityIgnoresInvertColors\n key={src}\n {...imgProps}\n {...handlersFor(src)}\n resizeMode={resizeMode}\n source={sourceOf(src)}\n style={composeStyles<ImageStyle>(\n markStyles.image,\n status === 'loaded' ? undefined : markStyles.imagePending,\n )}\n />\n )}\n </View>\n )\n}\n\n// An address as the source `Image` takes. The compiler keeps the one it made\n// for as long as the address is the same, so a re-render hands the image the\n// object it already had.\nfunction sourceOf(uri: string): ImageSourcePropType {\n return { uri }\n}\n\nexport type { MarkImageProps, MarkProps }\n\nexport { Mark }\n"],"mappings":";;;;;;;;;;;AAoEA,MAAMkC,QAAQ;CACZQ,QAAQ;EACNC,UAAUtB;EACVuB,YAAY;EACZC,OAAO;EACPC,eAAe;CACjB;CACAC,OAAO;EACLJ,UAAUvB;EACVwB,YAAY;EACZC,OAAO;EACPC,eAAe;CACjB;AACF;AAGA,MAAMG,UAAqE;CACzEG,UAAU;CACVC,UAAU;CACVC,SAAS;CACTC,WAAW;CACXC,UAAU;AACZ;;;;;;;;AASA,SAAAC,KAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAA5B;CAAA,IAAAC;CAAA,IAAAE;CAAA,IAAA0B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Ac;EAAAd,EAAA,MAAAe;EAAAf,EAAA,MAAAgB;EAAAhB,EAAA,MAAAiB;EAAAjB,EAAA,MAAAkB;EAAAlB,EAAA,MAAAqB;EAAArB,EAAA,MAAAiC;CAAA,OAAAA,MAAAjC,EAAA;CAAA,OA3CPiC;AA2CO;AAOX,SAASH,SAASI,KAAkC;CAClD,OAAO,EAAEA,IAAI;AACf"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["ComponentRef","Ref","ImageProps","ImageSourcePropType","ImageStyle","StyleProp","TextStyle","ViewProps","ViewStyle","Image","Text","NativeText","View","ResolvedTheme","MarkSize","MarkTone","PersonGlyph","useTheme","composeStyles","useTypeRole","useImageLoadingStatus","initialOfThing","initialsOfPerson","DIAMETERS","GLYPH_SHARE","initialsStylesOf","markStyles","markStylesOf","MarkImageProps","Pick","MarkProps","Omit","decorative","imgProps","kind","KINDS","name","ref","showPersonIcon","size","src","style","tone","person","initials","resizeMode","shape","tintsFallback","thing","const","CONTENT","Readonly","Record","negative","positive","primary","secondary","tertiary","Mark","t0","$","_c","props","t1","t2","undefined","theme","label","handlersFor","previous","status","T0","initialsNode","t3","t4","t5","t6","t7","t8","own","text","t9","fallback","named","trim","showsPicture","t10","colors","initialsText","base","sourceOf","image","imagePending","t11","uri","_c","NativeText"],"sources":["../../src/mark/index.tsx"],"sourcesContent":["import type { ComponentRef, Ref } from 'react'\nimport type {\n ImageProps,\n ImageSourcePropType,\n ImageStyle,\n StyleProp,\n TextStyle,\n ViewProps,\n ViewStyle,\n} from 'react-native'\n\nimport { Image, Text as NativeText, View } from 'react-native'\n\nimport type { ResolvedTheme } from '../theme/scope'\nimport type { MarkSize, MarkTone } from './styles'\n\nimport { PersonGlyph } from '../glyphs'\nimport { useTheme } from '../theme/scope'\nimport { composeStyles } from '../theme/styles'\nimport { useTypeRole } from '../typography/roles'\nimport { useImageLoadingStatus } from './image'\nimport { initialOfThing, initialsOfPerson } from './initials'\nimport {\n DIAMETERS,\n GLYPH_SHARE,\n initialsStylesOf,\n markStyles,\n markStylesOf,\n} from './styles'\n\n/** The native props a picture's own `Image` takes, as Avatar and ProductIcon take them. */\ntype MarkImageProps = Pick<\n ImageProps,\n | 'crossOrigin'\n | 'fadeDuration'\n | 'progressiveRenderingEnabled'\n | 'referrerPolicy'\n | 'resizeMethod'\n>\n\ntype MarkProps = Omit<ViewProps, 'children' | 'style'> & {\n /**\n * Hides the mark from screen readers, for one beside the name it stands\n * for, which would otherwise be announced twice.\n */\n readonly decorative?: boolean\n /** Props for the picture's own `Image`. */\n readonly imgProps?: MarkImageProps\n /** A person, which Avatar draws, or anything else, which ProductIcon does. */\n readonly kind: keyof typeof KINDS\n /** Supplies the fallback's initials, and the accessible name unless decorative. */\n readonly name: string\n readonly ref?: Ref<ComponentRef<typeof View>>\n /**\n * Whether a person with no initials to take, a blank name, draws the\n * anonymous person, or an empty disc, as a loading skeleton wants.\n */\n readonly showPersonIcon?: boolean\n readonly size: MarkSize\n /** A picture to show in place of the initials once it has loaded. */\n readonly src?: string\n readonly style?: StyleProp<ViewStyle>\n readonly tone: MarkTone\n}\n\n// What each kind of mark is drawn as. The header of `./styles` says why the\n// two differ where they do; everything not in this table is the same for\n// both.\nconst KINDS = {\n person: {\n initials: initialsOfPerson,\n resizeMode: 'cover',\n shape: 'circle',\n tintsFallback: false,\n },\n thing: {\n initials: initialOfThing,\n resizeMode: 'contain',\n shape: 'square',\n tintsFallback: true,\n },\n} as const\n\n// The role each tone draws the anonymous person in.\nconst CONTENT: Readonly<Record<MarkTone, keyof ResolvedTheme['colors']>> = {\n negative: 'onNegativeContainer',\n positive: 'onPositiveContainer',\n primary: 'onPrimaryContainer',\n secondary: 'onSecondaryContainer',\n tertiary: 'onTertiaryContainer',\n}\n\n/**\n * The small identity mark Avatar and ProductIcon both render: a picture once\n * it has loaded, initials until then or if it fails, named for whoever or\n * whatever it stands for. Shared rather than written into each, so a fix to\n * one reaches both, as on web. Not a component of the library's own, and not\n * exported from the package.\n */\nfunction Mark({\n decorative = false,\n imgProps,\n kind,\n name,\n showPersonIcon = true,\n size,\n src,\n style,\n tone,\n ...props\n}: MarkProps) {\n const { initials, resizeMode, shape, tintsFallback } = KINDS[kind]\n const theme = useTheme()\n const label = useTypeRole('labelLarge')\n const { handlersFor, previous, status } = useImageLoadingStatus(src)\n\n const own = markStylesOf(theme)\n const text = initialsStylesOf(theme)\n const fallback = initials(name)\n\n // Announced as an image named for whoever or whatever it stands for,\n // rather than letting the initials be read: \"AL\" is not what anyone means\n // to announce. A blank name names nothing, so the mark is then a plain\n // view, which a screen reader passes over rather than reading as an image\n // with no name. A decorative mark is hidden outright, its initials with it.\n const named = !decorative && name.trim() !== ''\n\n // The initials while no picture shows: before the first loads, and once\n // one fails. They are left out under a picture rather than kept beneath\n // it, since a letterboxed logo would show them through its transparent\n // parts.\n const showsPicture = status === 'loaded' || previous !== undefined\n let initialsNode = null\n if (!showsPicture && kind === 'person' && fallback === '') {\n // A person with no initials to take, a blank name or one still loading,\n // draws Material Design's anonymous person in the tone's on-container\n // colour. The glyph hides itself from screen readers.\n initialsNode = showPersonIcon ? (\n <PersonGlyph\n color={theme.colors[CONTENT[tone]]}\n size={DIAMETERS[size] * GLYPH_SHARE}\n />\n ) : null\n } else if (!showsPicture) {\n // The initials keep their size whatever the device's text size asks\n // for: the mark is a fixed size and clips what runs past it, and the\n // name a screen reader reads is what they stand for.\n const initialsText = (\n <NativeText\n allowFontScaling={false}\n style={composeStyles<TextStyle>(label, text[size], text[tone])}\n >\n {fallback}\n </NativeText>\n )\n initialsNode = tintsFallback ? (\n <View style={composeStyles<ViewStyle>(markStyles.fallback, own[tone])}>\n {initialsText}\n </View>\n ) : (\n initialsText\n )\n }\n\n return (\n <View\n accessible={named ? true : undefined}\n aria-hidden={decorative ? true : undefined}\n aria-label={named ? name : undefined}\n role={named ? 'img' : undefined}\n {...props}\n style={composeStyles<ViewStyle>(\n own.base,\n own[shape],\n markStyles[size],\n tintsFallback ? undefined : own[tone],\n style,\n )}\n >\n {initialsNode}\n {/* Two pictures at most, laid over the initials. The one last loaded\n stays while a new `src` loads, and the new one is drawn on top of\n it from the start, hidden until it has loaded. Neither is inverted\n by the iOS Smart Invert setting, which is meant for interface\n colours rather than pictures. */}\n {previous === undefined ? null : (\n <Image\n accessibilityIgnoresInvertColors\n key={previous}\n resizeMode={resizeMode}\n source={sourceOf(previous)}\n style={markStyles.image}\n />\n )}\n {src === undefined || status === 'error' ? null : (\n <Image\n accessibilityIgnoresInvertColors\n key={src}\n {...imgProps}\n {...handlersFor(src)}\n resizeMode={resizeMode}\n source={sourceOf(src)}\n style={composeStyles<ImageStyle>(\n markStyles.image,\n status === 'loaded' ? undefined : markStyles.imagePending,\n )}\n />\n )}\n </View>\n )\n}\n\n// An address as the source `Image` takes. The compiler keeps the one it made\n// for as long as the address is the same, so a re-render hands the image the\n// object it already had.\nfunction sourceOf(uri: string): ImageSourcePropType {\n return { uri }\n}\n\nexport type { MarkImageProps, MarkProps }\n\nexport { Mark }\n"],"mappings":";;;;;;;;;;;AAoEA,MAAMmC,QAAQ;CACZQ,QAAQ;EACNC,UAAUtB;EACVuB,YAAY;EACZC,OAAO;EACPC,eAAe;CACjB;CACAC,OAAO;EACLJ,UAAUvB;EACVwB,YAAY;EACZC,OAAO;EACPC,eAAe;CACjB;AACF;AAGA,MAAMG,UAAqE;CACzEG,UAAU;CACVC,UAAU;CACVC,SAAS;CACTC,WAAW;CACXC,UAAU;AACZ;;;;;;;;AASA,SAAAC,KAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAA5B;CAAA,IAAAC;CAAA,IAAAE;CAAA,IAAA0B;CAAA,IAAAvB;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAsB;CAAA,IAAAC;CAAA,IAAAtB;CAAA,IAAAkB,EAAA,OAAAD,IAAA;EAAc,CAAA,CAAA3B,YAAA+B,IAAA9B,UAAAC,MAAAE,MAAAE,gBAAA0B,IAAAzB,MAAAC,KAAAC,OAAAC,M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OAAO,EAAEA,IAAI;AACf"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/number/locale.ts
|
|
2
|
+
let deviceLocale;
|
|
3
|
+
function localeOf(locale) {
|
|
4
|
+
if (locale !== void 0) try {
|
|
5
|
+
Intl.NumberFormat.supportedLocalesOf(locale);
|
|
6
|
+
return locale;
|
|
7
|
+
} catch {}
|
|
8
|
+
deviceLocale ??= new Intl.NumberFormat().resolvedOptions().locale;
|
|
9
|
+
return deviceLocale;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { localeOf };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=locale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale.js","names":["deviceLocale","localeOf","locale","undefined","Intl","NumberFormat","supportedLocalesOf","resolvedOptions"],"sources":["../../src/number/locale.ts"],"sourcesContent":["// The locale a component writes its numbers in, and src/i18n its words: the\n// one given, where the runtime takes it as a locale at all, or the device's.\n// Web reads the page's from React Aria's `I18nProvider`; React Native has no\n// such context, so a component that formats a number takes the locale as a\n// prop and falls back to this.\n\nlet deviceLocale: string | undefined\n\nfunction localeOf(locale: string | undefined) {\n if (locale !== undefined) {\n try {\n Intl.NumberFormat.supportedLocalesOf(locale)\n return locale\n } catch {\n // A malformed tag, which falls back to the device's.\n }\n }\n\n deviceLocale ??= new Intl.NumberFormat().resolvedOptions().locale\n return deviceLocale\n}\n\nexport { localeOf }\n"],"mappings":";AAMA,IAAIA;AAEJ,SAASC,SAASC,QAA4B;CAC5C,IAAIA,WAAWC,KAAAA,GACb,IAAI;EACFC,KAAKC,aAAaC,mBAAmBJ,MAAM;EAC3C,OAAOA;CACT,QAAQ,CACN;CAIJF,iBAAiB,IAAII,KAAKC,aAAa,CAAC,CAACE,gBAAgB,CAAC,CAACL;CAC3D,OAAOF;AACT"}
|
package/dist/overlay/host.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { ScopeContext, useScope } from "../theme/scope.js";
|
|
1
2
|
import { c } from "react/compiler-runtime";
|
|
2
3
|
import { StyleSheet, View } from "react-native";
|
|
3
|
-
import { createContext, useState, useSyncExternalStore } from "react";
|
|
4
|
+
import { createContext, use, useId, useLayoutEffect, useState, useSyncExternalStore } from "react";
|
|
4
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
//#region src/overlay/host.tsx
|
|
6
7
|
const OverlayHostContext = createContext(null);
|
|
@@ -13,6 +14,68 @@ const styles = StyleSheet.create({ fill: {
|
|
|
13
14
|
top: 0
|
|
14
15
|
} });
|
|
15
16
|
/**
|
|
17
|
+
* Draws its content above the screen, in the overlay host of the app's
|
|
18
|
+
* outermost `ThemeScope`, for as long as it is mounted. A later overlay draws
|
|
19
|
+
* above an earlier one.
|
|
20
|
+
*
|
|
21
|
+
* The content reads the `ThemeScope` around the `Overlay`, as anything else
|
|
22
|
+
* there would. Other context set between the host and the `Overlay` does not
|
|
23
|
+
* reach it: an overlay is a surface of its own, as web's `OverlayScope` makes
|
|
24
|
+
* one, so it starts from what is around the app rather than from what is
|
|
25
|
+
* around the control that opened it.
|
|
26
|
+
*/
|
|
27
|
+
function Overlay(t0) {
|
|
28
|
+
const $ = c(10);
|
|
29
|
+
const { children } = t0;
|
|
30
|
+
const store = use(OverlayHostContext);
|
|
31
|
+
const scope = useScope();
|
|
32
|
+
const key = useId();
|
|
33
|
+
if (store === null) throw new Error("An overlay draws in the host of the outermost ThemeScope, and there is no ThemeScope around this one. Wrap the app in a ThemeScope.");
|
|
34
|
+
let t1;
|
|
35
|
+
let t2;
|
|
36
|
+
if ($[0] !== children || $[1] !== key || $[2] !== scope || $[3] !== store) {
|
|
37
|
+
t1 = () => {
|
|
38
|
+
store.set(key, /* @__PURE__ */ jsx(ScopeContext, {
|
|
39
|
+
value: scope,
|
|
40
|
+
children
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
43
|
+
t2 = [
|
|
44
|
+
children,
|
|
45
|
+
key,
|
|
46
|
+
scope,
|
|
47
|
+
store
|
|
48
|
+
];
|
|
49
|
+
$[0] = children;
|
|
50
|
+
$[1] = key;
|
|
51
|
+
$[2] = scope;
|
|
52
|
+
$[3] = store;
|
|
53
|
+
$[4] = t1;
|
|
54
|
+
$[5] = t2;
|
|
55
|
+
} else {
|
|
56
|
+
t1 = $[4];
|
|
57
|
+
t2 = $[5];
|
|
58
|
+
}
|
|
59
|
+
useLayoutEffect(t1, t2);
|
|
60
|
+
let t3;
|
|
61
|
+
let t4;
|
|
62
|
+
if ($[6] !== key || $[7] !== store) {
|
|
63
|
+
t3 = () => () => {
|
|
64
|
+
store.remove(key);
|
|
65
|
+
};
|
|
66
|
+
t4 = [key, store];
|
|
67
|
+
$[6] = key;
|
|
68
|
+
$[7] = store;
|
|
69
|
+
$[8] = t3;
|
|
70
|
+
$[9] = t4;
|
|
71
|
+
} else {
|
|
72
|
+
t3 = $[8];
|
|
73
|
+
t4 = $[9];
|
|
74
|
+
}
|
|
75
|
+
useLayoutEffect(t3, t4);
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
16
79
|
* Hosts the overlays drawn inside it: its children, then a layer over them
|
|
17
80
|
* that fills the view around the host. Mounting or unmounting an overlay
|
|
18
81
|
* renders the layer alone, so the screen under it keeps its state.
|
|
@@ -106,6 +169,6 @@ function storeFor() {
|
|
|
106
169
|
};
|
|
107
170
|
}
|
|
108
171
|
//#endregion
|
|
109
|
-
export { OverlayHost, OverlayHostContext };
|
|
172
|
+
export { Overlay, OverlayHost, OverlayHostContext };
|
|
110
173
|
|
|
111
174
|
//# sourceMappingURL=host.js.map
|
package/dist/overlay/host.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.js","names":["ReactNode","createContext","use","useId","useLayoutEffect","useState","useSyncExternalStore","StyleSheet","View","ScopeContext","useScope","Entry","key","content","OverlayStore","attach","layer","entries","remove","set","subscribe","listener","OverlayHostContext","styles","create","fill","bottom","left","pointerEvents","position","right","top","Overlay","t0","$","_c","children","store","scope","Error","t1","t2","t3","t4","OverlayHost","storeFor","OverlayLayer","map","_temp","Map","listeners","Set","changed","view","delete","node","add","_c"],"sources":["../../src/overlay/host.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\n\nimport {\n createContext,\n use,\n useId,\n useLayoutEffect,\n useState,\n useSyncExternalStore,\n} from 'react'\nimport { StyleSheet, View } from 'react-native'\n\nimport { ScopeContext, useScope } from '../theme/scope'\n\ntype Entry = readonly [key: string, content: ReactNode]\n\n/** What an overlay reaches its host through. */\ntype OverlayStore = {\n /** Takes the layer the host draws its overlays in, as its ref. */\n readonly attach: (layer:
|
|
1
|
+
{"version":3,"file":"host.js","names":["ComponentRef","ReactNode","createContext","use","useId","useLayoutEffect","useState","useSyncExternalStore","StyleSheet","View","ScopeContext","useScope","Entry","key","content","OverlayStore","attach","layer","entries","remove","set","subscribe","listener","OverlayHostContext","styles","create","fill","bottom","left","pointerEvents","position","right","top","Overlay","t0","$","_c","children","store","scope","Error","t1","t2","t3","t4","OverlayHost","storeFor","OverlayLayer","map","_temp","Map","listeners","Set","changed","view","delete","node","add","_c"],"sources":["../../src/overlay/host.tsx"],"sourcesContent":["import type { ComponentRef, ReactNode } from 'react'\n\nimport {\n createContext,\n use,\n useId,\n useLayoutEffect,\n useState,\n useSyncExternalStore,\n} from 'react'\nimport { StyleSheet, View } from 'react-native'\n\nimport { ScopeContext, useScope } from '../theme/scope'\n\ntype Entry = readonly [key: string, content: ReactNode]\n\n/** What an overlay reaches its host through. */\ntype OverlayStore = {\n /** Takes the layer the host draws its overlays in, as its ref. */\n readonly attach: (layer: ComponentRef<typeof View> | null) => void\n readonly entries: () => readonly Entry[]\n /** The layer the host draws its overlays in, for placing one in it. */\n readonly layer: () => ComponentRef<typeof View> | null\n readonly remove: (key: string) => void\n readonly set: (key: string, content: ReactNode) => void\n readonly subscribe: (listener: () => void) => () => void\n}\n\nconst OverlayHostContext = createContext<null | OverlayStore>(null)\n\nconst styles = StyleSheet.create({\n // Each overlay fills the layer on a box of its own, so one laid out in the\n // flow, as a bar along an edge is, is laid out against the screen rather\n // than after the overlay before it.\n fill: {\n bottom: 0,\n left: 0,\n pointerEvents: 'box-none',\n position: 'absolute',\n right: 0,\n top: 0,\n },\n})\n\n/**\n * Draws its content above the screen, in the overlay host of the app's\n * outermost `ThemeScope`, for as long as it is mounted. A later overlay draws\n * above an earlier one.\n *\n * The content reads the `ThemeScope` around the `Overlay`, as anything else\n * there would. Other context set between the host and the `Overlay` does not\n * reach it: an overlay is a surface of its own, as web's `OverlayScope` makes\n * one, so it starts from what is around the app rather than from what is\n * around the control that opened it.\n */\nfunction Overlay({ children }: { readonly children?: ReactNode }) {\n const store = use(OverlayHostContext)\n const scope = useScope()\n const key = useId()\n\n if (store === null) {\n throw new Error(\n 'An overlay draws in the host of the outermost ThemeScope, and there is no ThemeScope around this one. Wrap the app in a ThemeScope.',\n )\n }\n\n // Set before paint, so an overlay opening never draws a frame without it,\n // and replaced in place on an update, so it keeps its place in the stack.\n useLayoutEffect(() => {\n store.set(key, <ScopeContext value={scope}>{children}</ScopeContext>)\n }, [children, key, scope, store])\n\n useLayoutEffect(\n () => () => {\n store.remove(key)\n },\n [key, store],\n )\n\n return null\n}\n\n/**\n * Hosts the overlays drawn inside it: its children, then a layer over them\n * that fills the view around the host. Mounting or unmounting an overlay\n * renders the layer alone, so the screen under it keeps its state.\n *\n * The outermost `ThemeScope` renders one, so an app has one at its root.\n */\nfunction OverlayHost({ children }: { readonly children?: ReactNode }) {\n const [store] = useState(storeFor)\n\n return (\n <OverlayHostContext value={store}>\n {children}\n <OverlayLayer attach={store.attach} store={store} />\n </OverlayHostContext>\n )\n}\n\n// The layer passes a touch through to the screen wherever no overlay is\n// drawn, so an open overlay leaves the screen around it usable. It takes its\n// ref apart from the store, since the compiler reads an object a ref is taken\n// from as a ref itself, and the store is read during render.\nfunction OverlayLayer({\n attach,\n store,\n}: {\n readonly attach: OverlayStore['attach']\n readonly store: OverlayStore\n}) {\n const entries = useSyncExternalStore(store.subscribe, store.entries)\n\n return (\n <View ref={attach} style={styles.fill}>\n {entries.map(([key, content]) => (\n <View key={key} style={styles.fill}>\n {content}\n </View>\n ))}\n </View>\n )\n}\n\nfunction storeFor(): OverlayStore {\n const content = new Map<string, ReactNode>()\n const listeners = new Set<() => void>()\n let entries: readonly Entry[] = []\n let layer: ComponentRef<typeof View> | null = null\n\n const changed = () => {\n entries = [...content]\n for (const listener of listeners) {\n listener()\n }\n }\n\n return {\n attach: (view) => {\n layer = view\n },\n entries: () => entries,\n layer: () => layer,\n remove: (key) => {\n if (content.delete(key)) {\n changed()\n }\n },\n set: (key, node) => {\n content.set(key, node)\n changed()\n },\n subscribe: (listener) => {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n },\n }\n}\n\nexport type { OverlayStore }\n\nexport { Overlay, OverlayHost, OverlayHostContext }\n"],"mappings":";;;;;;AA4BA,MAAMuB,qBAAqBrB,cAAmC,IAAI;AAElE,MAAMsB,SAAShB,WAAWiB,OAAO,EAI/BC,MAAM;CACJC,QAAQ;CACRC,MAAM;CACNC,eAAe;CACfC,UAAU;CACVC,OAAO;CACPC,KAAK;AACP,EACF,CAAC;;;;;;;;;;;;AAaD,SAAAC,QAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAiB,MAAA,EAAAC,aAAAH;CACf,MAAAI,QAAcnC,IAAIoB,kBAAkB;CACpC,MAAAgB,QAAc5B,SAAS;CACvB,MAAAE,MAAYT,MAAM;CAElB,IAAIkC,UAAU,MACZ,MAAM,IAAIE,MACR,qIACF;CACD,IAAAC;CAAA,IAAAC;CAAA,IAAAP,EAAA,OAAAE,YAAAF,EAAA,OAAAtB,OAAAsB,EAAA,OAAAI,SAAAJ,EAAA,OAAAG,OAAA;EAIeG,WAAA;GACdH,MAAKlB,IAAKP,KAAK,oBAAC,cAAD;IAAqB0B,OAAAA;IAAQF;GAAhB,CAAA,CAAwC;EA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rBH,QAAQ;EACV;EACAhC,YAAYC,aAAa;GACvB6B,UAAUM,IAAInC,QAAQ;GACtB,aAAa;IACX6B,UAAUI,OAAOjC,QAAQ;GAC3B;EACF;CACF;AACF"}
|
package/dist/press/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useTheme } from "../theme/scope.js";
|
|
2
|
+
import { composeStyles } from "../theme/styles.js";
|
|
2
3
|
import { styles, stylesOf } from "./styles.js";
|
|
3
4
|
import { c } from "react/compiler-runtime";
|
|
4
|
-
import {
|
|
5
|
+
import { View } from "react-native";
|
|
5
6
|
import { useRef, useState } from "react";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import Animated, { Easing, useAnimatedStyle, useReducedMotion, useSharedValue, withDelay, withTiming } from "react-native-reanimated";
|
|
@@ -74,8 +75,8 @@ function hitSlop(height, width = 48) {
|
|
|
74
75
|
* ```
|
|
75
76
|
*/
|
|
76
77
|
function usePressFeedback(t0) {
|
|
77
|
-
const $ = c(
|
|
78
|
-
const { color, corners, disabled, disableRipple: t1, disc, onBlur, onFocus, onHoverIn, onHoverOut, onPressIn, onPressOut, pressedColor: t2 } = t0;
|
|
78
|
+
const $ = c(58);
|
|
79
|
+
const { color, corners, disabled, disableRipple: t1, disc, onBlur, onFocus, onHoverIn, onHoverOut, onPressIn, onPressOut, pending, pressedColor: t2 } = t0;
|
|
79
80
|
const disableRipple = t1 === void 0 ? false : t1;
|
|
80
81
|
const pressedColor = t2 === void 0 ? color : t2;
|
|
81
82
|
const theme = useTheme();
|
|
@@ -92,7 +93,8 @@ function usePressFeedback(t0) {
|
|
|
92
93
|
const fade = useSharedValue(0);
|
|
93
94
|
const { motion, spacing, stateLayerOpacity } = theme;
|
|
94
95
|
const active = disabled !== true;
|
|
95
|
-
const
|
|
96
|
+
const interactive = active && pending !== true;
|
|
97
|
+
const rippled = interactive && !disableRipple && !reduceMotion;
|
|
96
98
|
const rippleMotion = useAnimatedStyle(() => {
|
|
97
99
|
"worklet";
|
|
98
100
|
const { end, scale, size, start } = geometry.get();
|
|
@@ -213,7 +215,7 @@ function usePressFeedback(t0) {
|
|
|
213
215
|
y: disc / 2
|
|
214
216
|
});
|
|
215
217
|
phase.current = "shown";
|
|
216
|
-
} else if (rippled) {
|
|
218
|
+
} else if (rippled && typeof event_3.currentTarget !== "number") {
|
|
217
219
|
const { pageX, pageY } = event_3.nativeEvent;
|
|
218
220
|
phase.current = "measuring";
|
|
219
221
|
event_3.currentTarget.measure((_x, _y, width_0, height_0, left, top) => {
|
|
@@ -268,81 +270,79 @@ function usePressFeedback(t0) {
|
|
|
268
270
|
$[33] = t11;
|
|
269
271
|
} else t11 = $[33];
|
|
270
272
|
const handlers = t11;
|
|
271
|
-
const layerOpacity = !active ? 0 : pressed ? stateLayerOpacity.pressed : ringShown ? stateLayerOpacity.focus : hovered ? stateLayerOpacity.hover : 0;
|
|
273
|
+
const layerOpacity = !active ? 0 : interactive && pressed ? stateLayerOpacity.pressed : ringShown ? stateLayerOpacity.focus : interactive && hovered ? stateLayerOpacity.hover : 0;
|
|
272
274
|
let t12;
|
|
273
275
|
if ($[34] !== corners) {
|
|
274
|
-
t12 =
|
|
276
|
+
t12 = composeStyles(styles.surface, corners);
|
|
275
277
|
$[34] = corners;
|
|
276
278
|
$[35] = t12;
|
|
277
279
|
} else t12 = $[35];
|
|
278
280
|
const surface = t12;
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
281
|
+
const t13 = interactive && pressed ? pressedColor : color;
|
|
282
|
+
let t14;
|
|
283
|
+
if ($[36] !== layerOpacity || $[37] !== t13) {
|
|
284
|
+
t14 = composeStyles(styles.layer, {
|
|
285
|
+
backgroundColor: t13,
|
|
283
286
|
opacity: layerOpacity
|
|
284
287
|
});
|
|
285
|
-
$[36] =
|
|
286
|
-
$[37] =
|
|
287
|
-
$[38] =
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
} else t13 = $[41];
|
|
292
|
-
const state = t13;
|
|
293
|
-
const t14 = active && hovered;
|
|
294
|
-
let t15;
|
|
295
|
-
if ($[42] !== state) {
|
|
296
|
-
t15 = /* @__PURE__ */ jsx(View, { style: state });
|
|
297
|
-
$[42] = state;
|
|
298
|
-
$[43] = t15;
|
|
299
|
-
} else t15 = $[43];
|
|
288
|
+
$[36] = layerOpacity;
|
|
289
|
+
$[37] = t13;
|
|
290
|
+
$[38] = t14;
|
|
291
|
+
} else t14 = $[38];
|
|
292
|
+
const state = t14;
|
|
293
|
+
const t15 = interactive && hovered;
|
|
300
294
|
let t16;
|
|
301
|
-
if ($[
|
|
302
|
-
t16 =
|
|
303
|
-
$[
|
|
304
|
-
$[
|
|
305
|
-
|
|
306
|
-
} else t16 = $[46];
|
|
295
|
+
if ($[39] !== state) {
|
|
296
|
+
t16 = /* @__PURE__ */ jsx(View, { style: state });
|
|
297
|
+
$[39] = state;
|
|
298
|
+
$[40] = t16;
|
|
299
|
+
} else t16 = $[40];
|
|
307
300
|
let t17;
|
|
308
|
-
if ($[
|
|
309
|
-
t17 = /* @__PURE__ */
|
|
301
|
+
if ($[41] !== rippleMotion || $[42] !== rippled) {
|
|
302
|
+
t17 = rippled ? /* @__PURE__ */ jsx(Animated.View, { style: rippleMotion }) : null;
|
|
303
|
+
$[41] = rippleMotion;
|
|
304
|
+
$[42] = rippled;
|
|
305
|
+
$[43] = t17;
|
|
306
|
+
} else t17 = $[43];
|
|
307
|
+
let t18;
|
|
308
|
+
if ($[44] !== surface || $[45] !== t16 || $[46] !== t17) {
|
|
309
|
+
t18 = /* @__PURE__ */ jsxs(View, {
|
|
310
310
|
accessibilityElementsHidden: true,
|
|
311
311
|
importantForAccessibility: "no-hide-descendants",
|
|
312
312
|
style: surface,
|
|
313
|
-
children: [
|
|
313
|
+
children: [t16, t17]
|
|
314
314
|
});
|
|
315
|
-
$[
|
|
316
|
-
$[
|
|
317
|
-
$[
|
|
318
|
-
$[
|
|
319
|
-
} else
|
|
320
|
-
const
|
|
321
|
-
let t19;
|
|
322
|
-
if ($[51] !== active || $[52] !== ringShown || $[53] !== theme) {
|
|
323
|
-
t19 = active && ringShown ? stylesOf(theme).ring : void 0;
|
|
324
|
-
$[51] = active;
|
|
325
|
-
$[52] = ringShown;
|
|
326
|
-
$[53] = theme;
|
|
327
|
-
$[54] = t19;
|
|
328
|
-
} else t19 = $[54];
|
|
315
|
+
$[44] = surface;
|
|
316
|
+
$[45] = t16;
|
|
317
|
+
$[46] = t17;
|
|
318
|
+
$[47] = t18;
|
|
319
|
+
} else t18 = $[47];
|
|
320
|
+
const t19 = interactive && pressed;
|
|
329
321
|
let t20;
|
|
330
|
-
if ($[
|
|
331
|
-
t20 =
|
|
322
|
+
if ($[48] !== active || $[49] !== ringShown || $[50] !== theme) {
|
|
323
|
+
t20 = active && ringShown ? stylesOf(theme).ring : void 0;
|
|
324
|
+
$[48] = active;
|
|
325
|
+
$[49] = ringShown;
|
|
326
|
+
$[50] = theme;
|
|
327
|
+
$[51] = t20;
|
|
328
|
+
} else t20 = $[51];
|
|
329
|
+
let t21;
|
|
330
|
+
if ($[52] !== handlers || $[53] !== t15 || $[54] !== t18 || $[55] !== t19 || $[56] !== t20) {
|
|
331
|
+
t21 = {
|
|
332
332
|
handlers,
|
|
333
|
-
hovered:
|
|
334
|
-
layer:
|
|
335
|
-
pressed:
|
|
336
|
-
ring:
|
|
333
|
+
hovered: t15,
|
|
334
|
+
layer: t18,
|
|
335
|
+
pressed: t19,
|
|
336
|
+
ring: t20
|
|
337
337
|
};
|
|
338
|
-
$[
|
|
339
|
-
$[
|
|
340
|
-
$[
|
|
341
|
-
$[
|
|
342
|
-
$[
|
|
343
|
-
$[
|
|
344
|
-
} else
|
|
345
|
-
return
|
|
338
|
+
$[52] = handlers;
|
|
339
|
+
$[53] = t15;
|
|
340
|
+
$[54] = t18;
|
|
341
|
+
$[55] = t19;
|
|
342
|
+
$[56] = t20;
|
|
343
|
+
$[57] = t21;
|
|
344
|
+
} else t21 = $[57];
|
|
345
|
+
return t21;
|
|
346
346
|
}
|
|
347
347
|
//#endregion
|
|
348
348
|
export { hitSlop, usePressFeedback };
|
package/dist/press/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ReactNode","Insets","PressableProps","ViewStyle","useRef","useState","StyleSheet","View","Animated","Easing","useAnimatedStyle","useReducedMotion","useSharedValue","withDelay","withTiming","useTheme","styles","stylesOf","Corners","Pick","Handlers","Point","x","y","PressFeedback","handlers","NonNullable","Name","hovered","layer","pressed","ring","PressFeedbackOptions","color","corners","disabled","disableRipple","disc","pressedColor","RippleGeometry","end","scale","size","start","RipplePhase","TARGET_SIZE","INITIAL_ORIGIN_SCALE","FADE_IN","FADE_OUT","NO_RIPPLE","hitSlop","height","width","vertical","Math","max","horizontal","undefined","bottom","left","right","top","usePressFeedback","t0","$","_c","t1","onBlur","onFocus","onHoverIn","onHoverOut","onPressIn","onPressOut","t2","theme","reduceMotion","setHovered","setPressed","ringShown","setRingShown","focused","pressedUnfocused","pressStarted","phase","geometry","grow","fade","motion","spacing","stateLayerOpacity","active","rippled","rippleMotion","get","progress","backgroundColor","borderRadius","opacity","position","transform","translateX","translateY","t3","ripple","origin","size_0","floor","set","hypot","sm","duration","durationLong1","easing","bezier","easingStandard","linear","current","Date","now","t4","release","shown","durationMedium1","t5","event","t6","event_0","t7","event_1","t8","event_2","t9","event_3","pageX","pageY","nativeEvent","currentTarget","measure","_x","_y","width_0","height_0","Number","isFinite","t10","event_4","t11","layerOpacity","focus","hover","t12","compose","surface","t13","state","t14","t15","t16","t17","t18","t19","t20","_c"],"sources":["../../src/press/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { Insets, PressableProps, ViewStyle } from 'react-native'\n\nimport { useRef, useState } from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport Animated, {\n Easing,\n useAnimatedStyle,\n useReducedMotion,\n useSharedValue,\n withDelay,\n withTiming,\n} from 'react-native-reanimated'\n\nimport { useTheme } from '../theme/scope'\nimport { styles, stylesOf } from './styles'\n\n/** The corners a control is drawn with, which its feedback clips to. */\ntype Corners = Pick<\n ViewStyle,\n | 'borderBottomEndRadius'\n | 'borderBottomStartRadius'\n | 'borderRadius'\n | 'borderTopEndRadius'\n | 'borderTopStartRadius'\n>\n\n/** The handlers the feedback reads its states from. */\ntype Handlers = Pick<\n PressableProps,\n 'onBlur' | 'onFocus' | 'onHoverIn' | 'onHoverOut' | 'onPressIn' | 'onPressOut'\n>\n\ntype Point = { readonly x: number; readonly y: number }\n\ntype PressFeedback = {\n /**\n * The handlers to hand the control's `Pressable`. Each calls the one of\n * the same name it was given after its own.\n */\n readonly handlers: {\n readonly [Name in keyof Handlers]-?: NonNullable<Handlers[Name]>\n }\n /**\n * Whether a pointer is over the control, for a control that draws more\n * than the layer while hovered. Never while disabled.\n */\n readonly hovered: boolean\n /** The state layer and the ripple, to render as the `Pressable`'s first child. */\n readonly layer: ReactNode\n /**\n * Whether the control is pressed, for a control that draws more than the\n * layer while pressed. Never while disabled.\n */\n readonly pressed: boolean\n /** The focus ring while it shows, to compose into the control's style. */\n readonly ring: undefined | ViewStyle\n}\n\ntype PressFeedbackOptions = Handlers & {\n /**\n * The colour the layer and the ripple are drawn in: the theme's value for\n * the control's content colour role.\n */\n readonly color: string\n /** The control's corners, which the layer and the ripple clip to. */\n readonly corners?: Corners | undefined\n readonly disabled?: boolean | null | undefined\n /**\n * Draws no ripple and leaves the state layer, as `disableRipple` does on\n * web's Button.\n */\n readonly disableRipple?: boolean | undefined\n /**\n * The side of a round layer of a fixed size, for a control whose state\n * layer is a disc beside its label rather than the whole control: a\n * checkbox's. The ripple then grows from the disc's centre wherever the\n * press lands, and nothing is measured. Left out, the ripple grows from\n * the press point across the control.\n */\n readonly disc?: number | undefined\n /**\n * The colour the pressed layer and the ripple are drawn in, where it\n * differs from the hover and focus layers': a checkbox's swaps between\n * primary and on surface once pressed. Defaults to `color`.\n */\n readonly pressedColor?: string | undefined\n}\n\n/** Where the ripple starts and ends, and how far it grows, for one press. */\ntype RippleGeometry = {\n readonly end: Point\n readonly scale: number\n readonly size: number\n readonly start: Point\n}\n\n// Where the ripple of the latest press is: waiting on the control's\n// measurement, shown, or released before the measurement arrived.\ntype RipplePhase = 'idle' | 'measuring' | 'released' | 'shown'\n\n/**\n * The least a touch target measures each way, from Material Design's\n * accessibility guidance. A floor rather than a token, as web's `TARGET_SIZE`\n * is: a theme changes how big a control is drawn, never how small a target\n * may be.\n */\nconst TARGET_SIZE = 48\n\n// The ripple starts as a disc a fifth of the control's longer side, as on web.\nconst INITIAL_ORIGIN_SCALE = 0.2\n\n// The fade, in milliseconds: quick in and slow out, so a tap reads as a ripple\n// rather than a flicker. These are web's, and deliberately not motion tokens:\n// the two are tuned as a ratio to each other, which snapping either to the\n// scale would undo. Linear for the same reason, since a fade to and from a\n// state layer wants no acceleration.\nconst FADE_IN = 105\nconst FADE_OUT = 375\n\nconst NO_RIPPLE: RippleGeometry = {\n end: { x: 0, y: 0 },\n scale: 1,\n size: 0,\n start: { x: 0, y: 0 },\n}\n\n/**\n * The `hitSlop` that brings a control smaller than 48dp up to a 48dp target,\n * centred on it, as web's controls draw their target with a `::before`.\n * Nothing for a control already that big. A width left out is taken to be\n * wide enough, as a labelled button's is.\n */\nfunction hitSlop(height: number, width = TARGET_SIZE): Insets | undefined {\n const vertical = Math.max(0, (TARGET_SIZE - height) / 2)\n const horizontal = Math.max(0, (TARGET_SIZE - width) / 2)\n\n if (vertical === 0 && horizontal === 0) {\n return undefined\n }\n\n return {\n bottom: vertical,\n left: horizontal,\n right: horizontal,\n top: vertical,\n }\n}\n\n/**\n * The press feedback every interactive control draws: the state layer, the\n * ripple and the focus ring, as Material Design's state layers page sets them\n * out.\n *\n * The state layer is the control's content colour at the state's opacity\n * token, over the whole control: hover for an iPad pointer or an Android\n * mouse, focus while the ring shows, pressed while pressed. React Native has\n * no `color-mix()`, so it is a view of its own rather than a blended\n * background.\n *\n * The ripple grows from the press point to cover the control and fades out\n * once the press ends, held at least `durationMedium1` so a tap reads, and is\n * drawn the same on iOS and Android rather than through Android's own\n * `android_ripple`. It is a solid disc where web's has a soft edge, since\n * React Native draws a gradient only through an experimental style that React\n * Native Web ignores. It is not drawn while the device asks for reduced\n * motion, where the pressed layer alone marks the press.\n *\n * A control whose layer is a disc of its own beside its label, as a\n * checkbox's is, passes the disc's side as `disc`, and its ripple grows from\n * the disc's centre instead. One whose pressed layer takes another colour\n * passes it as `pressedColor`.\n *\n * The ring shows when focus arrives from a keyboard, and not when it arrives\n * with a press, which on web is a click focusing what it presses.\n *\n * ```tsx\n * const feedback = usePressFeedback({ color: colors.onPrimary, corners, onPressIn })\n *\n * <Pressable {...feedback.handlers} style={[styles.button, feedback.ring]}>\n * {feedback.layer}\n * <Text>Label</Text>\n * </Pressable>\n * ```\n */\nfunction usePressFeedback({\n color,\n corners,\n disabled,\n disableRipple = false,\n disc,\n onBlur,\n onFocus,\n onHoverIn,\n onHoverOut,\n onPressIn,\n onPressOut,\n pressedColor = color,\n}: PressFeedbackOptions): PressFeedback {\n const theme = useTheme()\n const reduceMotion = useReducedMotion()\n const [hovered, setHovered] = useState(false)\n const [pressed, setPressed] = useState(false)\n const [ringShown, setRingShown] = useState(false)\n const focused = useRef(false)\n // Whether the press in flight began while the control had no focus, which\n // makes the focus that follows it a pointer's.\n const pressedUnfocused = useRef(false)\n const pressStarted = useRef(0)\n const phase = useRef<RipplePhase>('idle')\n const geometry = useSharedValue(NO_RIPPLE)\n const grow = useSharedValue(0)\n const fade = useSharedValue(0)\n\n const { motion, spacing, stateLayerOpacity } = theme\n const active = disabled !== true\n const rippled = active && !disableRipple && !reduceMotion\n\n const rippleMotion = useAnimatedStyle(() => {\n 'worklet'\n const { end, scale, size, start } = geometry.get()\n const progress = grow.get()\n\n // The whole style is the animation's, so the view takes the one object it\n // hands back.\n return {\n backgroundColor: pressedColor,\n borderRadius: size / 2,\n height: size,\n left: 0,\n opacity: fade.get(),\n position: 'absolute',\n top: 0,\n transform: [\n { translateX: start.x + (end.x - start.x) * progress },\n { translateY: start.y + (end.y - start.y) * progress },\n { scale: 1 + (scale - 1) * progress },\n ],\n width: size,\n }\n })\n\n // Grows a disc a fifth of the control's longer side from the press point\n // to the centre, until it covers the control and `spacing.sm` beyond its\n // corners, as web's does.\n function ripple(width: number, height: number, origin: Point) {\n const size = Math.max(\n 1,\n Math.floor(Math.max(width, height) * INITIAL_ORIGIN_SCALE),\n )\n\n geometry.set({\n end: { x: (width - size) / 2, y: (height - size) / 2 },\n scale: (Math.hypot(width, height) + spacing.sm) / size,\n size,\n start: { x: origin.x - size / 2, y: origin.y - size / 2 },\n })\n grow.set(0)\n grow.set(\n withTiming(1, {\n duration: motion.durationLong1,\n easing: Easing.bezier(...motion.easingStandard),\n }),\n )\n fade.set(\n withTiming(stateLayerOpacity.pressed, {\n duration: FADE_IN,\n easing: Easing.linear,\n }),\n )\n pressStarted.current = Date.now()\n }\n\n // Fades the ripple out, once it has been shown for `durationMedium1`.\n function release() {\n const shown = Date.now() - pressStarted.current\n\n fade.set(\n withDelay(\n Math.max(0, motion.durationMedium1 - shown),\n withTiming(0, { duration: FADE_OUT, easing: Easing.linear }),\n ),\n )\n }\n\n const handlers: PressFeedback['handlers'] = {\n onBlur: (event) => {\n focused.current = false\n setRingShown(false)\n onBlur?.(event)\n },\n onFocus: (event) => {\n focused.current = true\n setRingShown(!pressedUnfocused.current)\n pressedUnfocused.current = false\n onFocus?.(event)\n },\n onHoverIn: (event) => {\n setHovered(true)\n onHoverIn?.(event)\n },\n onHoverOut: (event) => {\n setHovered(false)\n onHoverOut?.(event)\n },\n onPressIn: (event) => {\n pressedUnfocused.current = !focused.current\n setPressed(true)\n\n if (rippled && disc !== undefined) {\n ripple(disc, disc, { x: disc / 2, y: disc / 2 })\n phase.current = 'shown'\n } else if (rippled) {\n const { pageX, pageY } = event.nativeEvent\n\n // A touch's own location is measured from whichever child it landed\n // on, so the point is taken from the page and the control measured\n // there. A press from a key carries no point, and ripples from the\n // centre. React Native Web measures a frame later, so a press can end\n // first, and its ripple is then drawn whole.\n phase.current = 'measuring'\n event.currentTarget.measure((_x, _y, width, height, left, top) => {\n ripple(width, height, {\n x: Number.isFinite(pageX - left) ? pageX - left : width / 2,\n y: Number.isFinite(pageY - top) ? pageY - top : height / 2,\n })\n\n if (phase.current === 'released') {\n release()\n phase.current = 'idle'\n } else {\n phase.current = 'shown'\n }\n })\n }\n\n onPressIn?.(event)\n },\n onPressOut: (event) => {\n pressedUnfocused.current = false\n setPressed(false)\n\n if (phase.current === 'shown') {\n release()\n }\n phase.current = phase.current === 'measuring' ? 'released' : 'idle'\n\n onPressOut?.(event)\n },\n }\n\n const layerOpacity = !active\n ? 0\n : pressed\n ? stateLayerOpacity.pressed\n : ringShown\n ? stateLayerOpacity.focus\n : hovered\n ? stateLayerOpacity.hover\n : 0\n const surface = StyleSheet.compose(styles.surface, corners)\n const state = StyleSheet.compose(styles.layer, {\n backgroundColor: active && pressed ? pressedColor : color,\n opacity: layerOpacity,\n })\n\n return {\n handlers,\n hovered: active && hovered,\n layer: (\n <View\n accessibilityElementsHidden\n importantForAccessibility=\"no-hide-descendants\"\n style={surface}\n >\n <View style={state} />\n {rippled ? <Animated.View style={rippleMotion} /> : null}\n </View>\n ),\n pressed: active && pressed,\n ring: active && ringShown ? stylesOf(theme).ring : undefined,\n }\n}\n\nexport { hitSlop, TARGET_SIZE, usePressFeedback }\nexport type { Corners, PressFeedback, PressFeedbackOptions }\n"],"mappings":";;;;;;;AA8GA,MAAM8C,uBAAuB;AAO7B,MAAMC,UAAU;AAChB,MAAMC,WAAW;AAEjB,MAAMC,YAA4B;CAChCT,KAAK;EAAElB,GAAG;EAAGC,GAAG;CAAE;CAClBkB,OAAO;CACPC,MAAM;CACNC,OAAO;EAAErB,GAAG;EAAGC,GAAG;CAAE;AACtB;;;;;;;AAQA,SAAS2B,QAAQC,QAAgBC,QAAAA,IAAyC;CACxE,MAAMC,WAAWC,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C,GANE;;EAOE7F,EAAA,MAAAwF;EAAAxF,EAAA,MAAA4F;EAAA5F,EAAA,MAAA6F;EAAA7F,EAAA,MAAA8F;CAAA,OAAAA,MAAA9F,EAAA;CAEA,MAAA+F,MAAArE,UAAA5D;CAAiB,IAAAkI;CAAA,IAAAhG,EAAA,QAAA0B,UAAA1B,EAAA,QAAAc,aAAAd,EAAA,QAAAU,OAAA;EACpBsF,MAAAtE,UAAAZ,YAAsB7D,SAASyD,KAAK,CAAC,CAAA3C,OAArC0B,KAAAA;EAAsDO,EAAA,MAAA0B;EAAA1B,EAAA,MAAAc;EAAAd,EAAA,MAAAU;EAAAV,EAAA,MAAAgG;CAAA,OAAAA,MAAAhG,EAAA;CAAA,IAAAiG;CAAA,IAAAjG,EAAA,QAAAvC,YAAAuC,EAAA,QAAA2F,OAAA3F,EAAA,QAAA8F,OAAA9F,EAAA,QAAA+F,OAAA/F,EAAA,QAAAgG,KAAA;EAdvDC,MAAA;GAAAxI;GAAAG,SAEI+H;GAAiB9H,OAExBiI;GAOOhI,SAEAiI;GAAiBhI,MACpBiI;EACR;EAAChG,EAAA,MAAAvC;EAAAuC,EAAA,MAAA2F;EAAA3F,EAAA,MAAA8F;EAAA9F,EAAA,MAAA+F;EAAA/F,EAAA,MAAAgG;EAAAhG,EAAA,MAAAiG;CAAA,OAAAA,MAAAjG,EAAA;CAAA,OAfMiG;AAeN"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["ReactNode","Insets","PressableProps","ViewStyle","useRef","useState","View","Animated","Easing","useAnimatedStyle","useReducedMotion","useSharedValue","withDelay","withTiming","useTheme","composeStyles","styles","stylesOf","Corners","Pick","Handlers","Point","x","y","PressFeedback","handlers","NonNullable","Name","hovered","layer","pressed","ring","PressFeedbackOptions","color","corners","disabled","disableRipple","disc","pending","pressedColor","RippleGeometry","end","scale","size","start","RipplePhase","TARGET_SIZE","INITIAL_ORIGIN_SCALE","FADE_IN","FADE_OUT","NO_RIPPLE","hitSlop","height","width","vertical","Math","max","horizontal","undefined","bottom","left","right","top","usePressFeedback","t0","$","_c","t1","onBlur","onFocus","onHoverIn","onHoverOut","onPressIn","onPressOut","t2","theme","reduceMotion","setHovered","setPressed","ringShown","setRingShown","focused","pressedUnfocused","pressStarted","phase","geometry","grow","fade","motion","spacing","stateLayerOpacity","active","interactive","rippled","rippleMotion","get","progress","backgroundColor","borderRadius","opacity","position","transform","translateX","translateY","t3","ripple","origin","size_0","floor","set","hypot","sm","duration","durationLong1","easing","bezier","easingStandard","linear","current","Date","now","t4","release","shown","durationMedium1","t5","event","t6","event_0","t7","event_1","t8","event_2","t9","event_3","currentTarget","pageX","pageY","nativeEvent","measure","_x","_y","width_0","height_0","Number","isFinite","t10","event_4","t11","layerOpacity","focus","hover","t12","surface","t13","t14","state","t15","t16","t17","t18","t19","t20","t21","_c"],"sources":["../../src/press/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { Insets, PressableProps, ViewStyle } from 'react-native'\n\nimport { useRef, useState } from 'react'\nimport { View } from 'react-native'\nimport Animated, {\n Easing,\n useAnimatedStyle,\n useReducedMotion,\n useSharedValue,\n withDelay,\n withTiming,\n} from 'react-native-reanimated'\n\nimport { useTheme } from '../theme/scope'\nimport { composeStyles } from '../theme/styles'\nimport { styles, stylesOf } from './styles'\n\n/** The corners a control is drawn with, which its feedback clips to. */\ntype Corners = Pick<\n ViewStyle,\n | 'borderBottomEndRadius'\n | 'borderBottomStartRadius'\n | 'borderRadius'\n | 'borderTopEndRadius'\n | 'borderTopStartRadius'\n>\n\n/** The handlers the feedback reads its states from. */\ntype Handlers = Pick<\n PressableProps,\n 'onBlur' | 'onFocus' | 'onHoverIn' | 'onHoverOut' | 'onPressIn' | 'onPressOut'\n>\n\ntype Point = { readonly x: number; readonly y: number }\n\ntype PressFeedback = {\n /**\n * The handlers to hand the control's `Pressable`. Each calls the one of\n * the same name it was given after its own.\n */\n readonly handlers: {\n readonly [Name in keyof Handlers]-?: NonNullable<Handlers[Name]>\n }\n /**\n * Whether a pointer is over the control, for a control that draws more\n * than the layer while hovered. Never while disabled or pending.\n */\n readonly hovered: boolean\n /** The state layer and the ripple, to render as the `Pressable`'s first child. */\n readonly layer: ReactNode\n /**\n * Whether the control is pressed, for a control that draws more than the\n * layer while pressed. Never while disabled or pending.\n */\n readonly pressed: boolean\n /** The focus ring while it shows, to compose into the control's style. */\n readonly ring: undefined | ViewStyle\n}\n\ntype PressFeedbackOptions = Handlers & {\n /**\n * The colour the layer and the ripple are drawn in: the theme's value for\n * the control's content colour role.\n */\n readonly color: string\n /** The control's corners, which the layer and the ripple clip to. */\n readonly corners?: Corners | undefined\n readonly disabled?: boolean | null | undefined\n /**\n * Draws no ripple and leaves the state layer, as `disableRipple` does on\n * web's Button.\n */\n readonly disableRipple?: boolean | undefined\n /**\n * The side of a round layer of a fixed size, for a control whose state\n * layer is a disc beside its label rather than the whole control: a\n * checkbox's. The ripple then grows from the disc's centre wherever the\n * press lands, and nothing is measured. Left out, the ripple grows from\n * the press point across the control.\n */\n readonly disc?: number | undefined\n /**\n * Takes no press or hover while true, with no layer and no ripple for\n * either, and keeps the focus and its ring, as a pending button does.\n */\n readonly pending?: boolean | undefined\n /**\n * The colour the pressed layer and the ripple are drawn in, where it\n * differs from the hover and focus layers': a checkbox's swaps between\n * primary and on surface once pressed. Defaults to `color`.\n */\n readonly pressedColor?: string | undefined\n}\n\n/** Where the ripple starts and ends, and how far it grows, for one press. */\ntype RippleGeometry = {\n readonly end: Point\n readonly scale: number\n readonly size: number\n readonly start: Point\n}\n\n// Where the ripple of the latest press is: waiting on the control's\n// measurement, shown, or released before the measurement arrived.\ntype RipplePhase = 'idle' | 'measuring' | 'released' | 'shown'\n\n/**\n * The least a touch target measures each way, from Material Design's\n * accessibility guidance. A floor rather than a token, as web's `TARGET_SIZE`\n * is: a theme changes how big a control is drawn, never how small a target\n * may be.\n */\nconst TARGET_SIZE = 48\n\n// The ripple starts as a disc a fifth of the control's longer side, as on web.\nconst INITIAL_ORIGIN_SCALE = 0.2\n\n// The fade, in milliseconds: quick in and slow out, so a tap reads as a ripple\n// rather than a flicker. These are web's, and deliberately not motion tokens:\n// the two are tuned as a ratio to each other, which snapping either to the\n// scale would undo. Linear for the same reason, since a fade to and from a\n// state layer wants no acceleration.\nconst FADE_IN = 105\nconst FADE_OUT = 375\n\nconst NO_RIPPLE: RippleGeometry = {\n end: { x: 0, y: 0 },\n scale: 1,\n size: 0,\n start: { x: 0, y: 0 },\n}\n\n/**\n * The `hitSlop` that brings a control smaller than 48dp up to a 48dp target,\n * centred on it, as web's controls draw their target with a `::before`.\n * Nothing for a control already that big. A width left out is taken to be\n * wide enough, as a labelled button's is.\n */\nfunction hitSlop(height: number, width = TARGET_SIZE): Insets | undefined {\n const vertical = Math.max(0, (TARGET_SIZE - height) / 2)\n const horizontal = Math.max(0, (TARGET_SIZE - width) / 2)\n\n if (vertical === 0 && horizontal === 0) {\n return undefined\n }\n\n return {\n bottom: vertical,\n left: horizontal,\n right: horizontal,\n top: vertical,\n }\n}\n\n/**\n * The press feedback every interactive control draws: the state layer, the\n * ripple and the focus ring, as Material Design's state layers page sets them\n * out.\n *\n * The state layer is the control's content colour at the state's opacity\n * token, over the whole control: hover for an iPad pointer or an Android\n * mouse, focus while the ring shows, pressed while pressed. React Native has\n * no `color-mix()`, so it is a view of its own rather than a blended\n * background.\n *\n * The ripple grows from the press point to cover the control and fades out\n * once the press ends, held at least `durationMedium1` so a tap reads, and is\n * drawn the same on iOS and Android rather than through Android's own\n * `android_ripple`. It is a solid disc where web's has a soft edge, since\n * React Native draws a gradient only through an experimental style that React\n * Native Web ignores. It is not drawn while the device asks for reduced\n * motion, where the pressed layer alone marks the press.\n *\n * A control whose layer is a disc of its own beside its label, as a\n * checkbox's is, passes the disc's side as `disc`, and its ripple grows from\n * the disc's centre instead. One whose pressed layer takes another colour\n * passes it as `pressedColor`.\n *\n * The ring shows when focus arrives from a keyboard, and not when it arrives\n * with a press, which on web is a click focusing what it presses.\n *\n * ```tsx\n * const feedback = usePressFeedback({ color: colors.onPrimary, corners, onPressIn })\n *\n * <Pressable {...feedback.handlers} style={[styles.button, feedback.ring]}>\n * {feedback.layer}\n * <Text>Label</Text>\n * </Pressable>\n * ```\n */\nfunction usePressFeedback({\n color,\n corners,\n disabled,\n disableRipple = false,\n disc,\n onBlur,\n onFocus,\n onHoverIn,\n onHoverOut,\n onPressIn,\n onPressOut,\n pending,\n pressedColor = color,\n}: PressFeedbackOptions): PressFeedback {\n const theme = useTheme()\n const reduceMotion = useReducedMotion()\n const [hovered, setHovered] = useState(false)\n const [pressed, setPressed] = useState(false)\n const [ringShown, setRingShown] = useState(false)\n const focused = useRef(false)\n // Whether the press in flight began while the control had no focus, which\n // makes the focus that follows it a pointer's.\n const pressedUnfocused = useRef(false)\n const pressStarted = useRef(0)\n const phase = useRef<RipplePhase>('idle')\n const geometry = useSharedValue(NO_RIPPLE)\n const grow = useSharedValue(0)\n const fade = useSharedValue(0)\n\n const { motion, spacing, stateLayerOpacity } = theme\n const active = disabled !== true\n const interactive = active && pending !== true\n const rippled = interactive && !disableRipple && !reduceMotion\n\n const rippleMotion = useAnimatedStyle(() => {\n 'worklet'\n const { end, scale, size, start } = geometry.get()\n const progress = grow.get()\n\n // The whole style is the animation's, so the view takes the one object it\n // hands back.\n return {\n backgroundColor: pressedColor,\n borderRadius: size / 2,\n height: size,\n left: 0,\n opacity: fade.get(),\n position: 'absolute',\n top: 0,\n transform: [\n { translateX: start.x + (end.x - start.x) * progress },\n { translateY: start.y + (end.y - start.y) * progress },\n { scale: 1 + (scale - 1) * progress },\n ],\n width: size,\n }\n })\n\n // Grows a disc a fifth of the control's longer side from the press point\n // to the centre, until it covers the control and `spacing.sm` beyond its\n // corners, as web's does.\n function ripple(width: number, height: number, origin: Point) {\n const size = Math.max(\n 1,\n Math.floor(Math.max(width, height) * INITIAL_ORIGIN_SCALE),\n )\n\n geometry.set({\n end: { x: (width - size) / 2, y: (height - size) / 2 },\n scale: (Math.hypot(width, height) + spacing.sm) / size,\n size,\n start: { x: origin.x - size / 2, y: origin.y - size / 2 },\n })\n grow.set(0)\n grow.set(\n withTiming(1, {\n duration: motion.durationLong1,\n easing: Easing.bezier(...motion.easingStandard),\n }),\n )\n fade.set(\n withTiming(stateLayerOpacity.pressed, {\n duration: FADE_IN,\n easing: Easing.linear,\n }),\n )\n pressStarted.current = Date.now()\n }\n\n // Fades the ripple out, once it has been shown for `durationMedium1`.\n function release() {\n const shown = Date.now() - pressStarted.current\n\n fade.set(\n withDelay(\n Math.max(0, motion.durationMedium1 - shown),\n withTiming(0, { duration: FADE_OUT, easing: Easing.linear }),\n ),\n )\n }\n\n const handlers: PressFeedback['handlers'] = {\n onBlur: (event) => {\n focused.current = false\n setRingShown(false)\n onBlur?.(event)\n },\n onFocus: (event) => {\n focused.current = true\n setRingShown(!pressedUnfocused.current)\n pressedUnfocused.current = false\n onFocus?.(event)\n },\n onHoverIn: (event) => {\n setHovered(true)\n onHoverIn?.(event)\n },\n onHoverOut: (event) => {\n setHovered(false)\n onHoverOut?.(event)\n },\n onPressIn: (event) => {\n pressedUnfocused.current = !focused.current\n setPressed(true)\n\n if (rippled && disc !== undefined) {\n ripple(disc, disc, { x: disc / 2, y: disc / 2 })\n phase.current = 'shown'\n } else if (rippled && typeof event.currentTarget !== 'number') {\n const { pageX, pageY } = event.nativeEvent\n\n // A touch's own location is measured from whichever child it landed\n // on, so the point is taken from the page and the control measured\n // there. A press from a key carries no point, and ripples from the\n // centre. React Native Web measures a frame later, so a press can end\n // first, and its ripple is then drawn whole. React Native types the\n // target as a bare view tag too, which has nothing to measure.\n phase.current = 'measuring'\n event.currentTarget.measure((_x, _y, width, height, left, top) => {\n ripple(width, height, {\n x: Number.isFinite(pageX - left) ? pageX - left : width / 2,\n y: Number.isFinite(pageY - top) ? pageY - top : height / 2,\n })\n\n if (phase.current === 'released') {\n release()\n phase.current = 'idle'\n } else {\n phase.current = 'shown'\n }\n })\n }\n\n onPressIn?.(event)\n },\n onPressOut: (event) => {\n pressedUnfocused.current = false\n setPressed(false)\n\n if (phase.current === 'shown') {\n release()\n }\n phase.current = phase.current === 'measuring' ? 'released' : 'idle'\n\n onPressOut?.(event)\n },\n }\n\n const layerOpacity = !active\n ? 0\n : interactive && pressed\n ? stateLayerOpacity.pressed\n : ringShown\n ? stateLayerOpacity.focus\n : interactive && hovered\n ? stateLayerOpacity.hover\n : 0\n const surface = composeStyles<ViewStyle>(styles.surface, corners)\n const state = composeStyles<ViewStyle>(styles.layer, {\n backgroundColor: interactive && pressed ? pressedColor : color,\n opacity: layerOpacity,\n })\n\n return {\n handlers,\n hovered: interactive && hovered,\n layer: (\n <View\n accessibilityElementsHidden\n importantForAccessibility=\"no-hide-descendants\"\n style={surface}\n >\n <View style={state} />\n {rippled ? <Animated.View style={rippleMotion} /> : null}\n </View>\n ),\n pressed: interactive && pressed,\n ring: active && ringShown ? stylesOf(theme).ring : undefined,\n }\n}\n\nexport { hitSlop, TARGET_SIZE, usePressFeedback }\nexport type { Corners, PressFeedback, PressFeedbackOptions }\n"],"mappings":";;;;;;;;AAoHA,MAAM+C,uBAAuB;AAO7B,MAAMC,UAAU;AAChB,MAAMC,WAAW;AAEjB,MAAMC,YAA4B;CAChCT,KAAK;EAAEnB,GAAG;EAAGC,GAAG;CAAE;CAClBmB,OAAO;CACPC,MAAM;CACNC,OAAO;EAAEtB,GAAG;EAAGC,GAAG;CAAE;AACtB;;;;;;;AAQA,SAAS4B,QAAQC,QAAgBC,QAAAA,IAAyC;CACxE,MAAMC,WAAWC,KAAKC,IAAI,IAAA,KAAkBJ,UAAU,CAAC;CACvD,MAAMK,aAAaF,KAAKC,IAAI,IAAA,KAAkBH,SAAS,CAAC;CAExD,IAAIC,aAAa,KAAKG,eAAe,GACnC;CAGF,OAAO;EACLE,QAAQL;EACRM,MAAMH;EACNI,OAAOJ;EACPK,KAAKR;CACP;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAAS,iBAAAC,I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