@kanso-labs/react-native-kanso-ui 0.7.0 → 0.9.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.
Files changed (150) hide show
  1. package/README.md +37 -0
  2. package/dist/badge/index.js +9 -68
  3. package/dist/badge/index.js.map +1 -1
  4. package/dist/button/index.d.ts +2 -1
  5. package/dist/button/index.js +1 -1
  6. package/dist/button/index.js.map +1 -1
  7. package/dist/button/palettes.d.ts +2 -0
  8. package/dist/button/pending.js +17 -21
  9. package/dist/button/pending.js.map +1 -1
  10. package/dist/calendar/index.js +1 -1
  11. package/dist/components/autocomplete/index.js +28 -26
  12. package/dist/components/autocomplete/index.js.map +1 -1
  13. package/dist/components/avatar/index.d.ts +2 -2
  14. package/dist/components/avatar/index.js +2 -2
  15. package/dist/components/avatar/index.js.map +1 -1
  16. package/dist/components/badge/index.d.ts +48 -0
  17. package/dist/components/badge/index.js +122 -0
  18. package/dist/components/badge/index.js.map +1 -0
  19. package/dist/{badge → components/badge}/styles.js +10 -6
  20. package/dist/components/badge/styles.js.map +1 -0
  21. package/dist/components/breadcrumbs/index.d.ts +66 -0
  22. package/dist/components/breadcrumbs/index.js +285 -0
  23. package/dist/components/breadcrumbs/index.js.map +1 -0
  24. package/dist/components/calendar/index.d.ts +1 -1
  25. package/dist/components/calendar/index.js +77 -38
  26. package/dist/components/calendar/index.js.map +1 -1
  27. package/dist/components/checkbox/index.d.ts +7 -1
  28. package/dist/components/checkbox/index.js +183 -138
  29. package/dist/components/checkbox/index.js.map +1 -1
  30. package/dist/components/checkbox-group/index.d.ts +93 -0
  31. package/dist/components/checkbox-group/index.js +306 -0
  32. package/dist/components/checkbox-group/index.js.map +1 -0
  33. package/dist/components/chip-group/index.d.ts +4 -3
  34. package/dist/components/chip-group/index.js +47 -45
  35. package/dist/components/chip-group/index.js.map +1 -1
  36. package/dist/components/code/index.d.ts +25 -0
  37. package/dist/components/code/index.js +87 -0
  38. package/dist/components/code/index.js.map +1 -0
  39. package/dist/components/container/index.d.ts +47 -0
  40. package/dist/components/container/index.js +85 -0
  41. package/dist/components/container/index.js.map +1 -0
  42. package/dist/components/copy-field/index.d.ts +5 -5
  43. package/dist/components/copy-field/index.js +30 -28
  44. package/dist/components/copy-field/index.js.map +1 -1
  45. package/dist/components/currency/index.d.ts +2 -2
  46. package/dist/components/currency/index.js +3 -1
  47. package/dist/components/currency/index.js.map +1 -1
  48. package/dist/components/fab/index.d.ts +80 -0
  49. package/dist/components/fab/index.js +231 -0
  50. package/dist/components/fab/index.js.map +1 -0
  51. package/dist/components/fab-menu/index.d.ts +120 -0
  52. package/dist/components/fab-menu/index.js +640 -0
  53. package/dist/components/fab-menu/index.js.map +1 -0
  54. package/dist/components/feed/index.d.ts +57 -0
  55. package/dist/components/feed/index.js +167 -0
  56. package/dist/components/feed/index.js.map +1 -0
  57. package/dist/components/keycap/index.d.ts +27 -0
  58. package/dist/components/keycap/index.js +136 -0
  59. package/dist/components/keycap/index.js.map +1 -0
  60. package/dist/components/list/index.d.ts +6 -5
  61. package/dist/components/list/index.js +97 -106
  62. package/dist/components/list/index.js.map +1 -1
  63. package/dist/components/menu/index.d.ts +4 -3
  64. package/dist/components/menu/index.js +33 -40
  65. package/dist/components/menu/index.js.map +1 -1
  66. package/dist/components/meter/index.d.ts +2 -1
  67. package/dist/components/meter/index.js +9 -7
  68. package/dist/components/meter/index.js.map +1 -1
  69. package/dist/components/number-field/index.d.ts +7 -3
  70. package/dist/components/number-field/index.js +214 -192
  71. package/dist/components/number-field/index.js.map +1 -1
  72. package/dist/components/product-icon/index.d.ts +2 -2
  73. package/dist/components/product-icon/index.js +2 -2
  74. package/dist/components/product-icon/index.js.map +1 -1
  75. package/dist/components/progress-indicator/index.d.ts +2 -1
  76. package/dist/components/progress-indicator/index.js +15 -13
  77. package/dist/components/progress-indicator/index.js.map +1 -1
  78. package/dist/components/search-field/index.d.ts +3 -3
  79. package/dist/components/search-field/index.js +105 -104
  80. package/dist/components/search-field/index.js.map +1 -1
  81. package/dist/components/separator/index.d.ts +3 -2
  82. package/dist/components/separator/index.js +29 -26
  83. package/dist/components/separator/index.js.map +1 -1
  84. package/dist/components/sheet/index.d.ts +2 -2
  85. package/dist/components/sheet/index.js +22 -26
  86. package/dist/components/sheet/index.js.map +1 -1
  87. package/dist/components/snackbar/index.d.ts +3 -3
  88. package/dist/components/snackbar/index.js +36 -34
  89. package/dist/components/snackbar/index.js.map +1 -1
  90. package/dist/components/supporting-pane/index.d.ts +44 -0
  91. package/dist/components/supporting-pane/index.js +109 -0
  92. package/dist/components/supporting-pane/index.js.map +1 -0
  93. package/dist/components/tag/index.d.ts +58 -0
  94. package/dist/components/tag/index.js +205 -0
  95. package/dist/components/tag/index.js.map +1 -0
  96. package/dist/components/text/index.d.ts +1 -1
  97. package/dist/components/text/index.js +49 -21
  98. package/dist/components/text/index.js.map +1 -1
  99. package/dist/components/text-area/index.d.ts +145 -0
  100. package/dist/components/text-area/index.js +231 -0
  101. package/dist/components/text-area/index.js.map +1 -0
  102. package/dist/components/text-field/index.d.ts +6 -3
  103. package/dist/components/text-field/index.js +3 -0
  104. package/dist/components/text-field/index.js.map +1 -1
  105. package/dist/components/toolbar/index.d.ts +53 -0
  106. package/dist/components/toolbar/index.js +185 -0
  107. package/dist/components/toolbar/index.js.map +1 -0
  108. package/dist/control/group.js +23 -0
  109. package/dist/control/group.js.map +1 -0
  110. package/dist/fab/index.d.ts +19 -0
  111. package/dist/fab/index.js +147 -0
  112. package/dist/fab/index.js.map +1 -0
  113. package/dist/field/index.js +123 -79
  114. package/dist/field/index.js.map +1 -1
  115. package/dist/field/styles.js +18 -0
  116. package/dist/field/styles.js.map +1 -1
  117. package/dist/form/index.d.ts +1 -2
  118. package/dist/form/index.js +1 -1
  119. package/dist/form/index.js.map +1 -1
  120. package/dist/i18n/index.js +12 -1
  121. package/dist/i18n/index.js.map +1 -1
  122. package/dist/i18n/messages.js +367 -0
  123. package/dist/i18n/messages.js.map +1 -1
  124. package/dist/i18n/provider.d.ts +53 -0
  125. package/dist/i18n/provider.js +96 -0
  126. package/dist/i18n/provider.js.map +1 -0
  127. package/dist/index.d.ts +19 -4
  128. package/dist/index.js +17 -3
  129. package/dist/indicator/index.js +1 -2
  130. package/dist/indicator/index.js.map +1 -1
  131. package/dist/mark/index.js +77 -117
  132. package/dist/mark/index.js.map +1 -1
  133. package/dist/mark/initials.js.map +1 -1
  134. package/dist/modal/index.js +59 -46
  135. package/dist/modal/index.js.map +1 -1
  136. package/dist/navigation/index.js +8 -5
  137. package/dist/navigation/index.js.map +1 -1
  138. package/dist/number/count.js +15 -0
  139. package/dist/number/count.js.map +1 -0
  140. package/dist/number/locale.js.map +1 -1
  141. package/dist/overlay/host.js +30 -21
  142. package/dist/overlay/host.js.map +1 -1
  143. package/dist/overlay/placement.js +3 -1
  144. package/dist/overlay/placement.js.map +1 -1
  145. package/dist/separator/index.js +7 -0
  146. package/dist/separator/index.js.map +1 -0
  147. package/dist/typography/size.js +14 -0
  148. package/dist/typography/size.js.map +1 -0
  149. package/package.json +1 -1
  150. package/dist/badge/styles.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ReactNode","LayoutChangeEvent","ViewStyle","AnimatedStyle","SharedValue","NumberFormatter","useEffect","useState","View","Animated","Easing","useAnimatedStyle","useReducedMotion","useSharedValue","withTiming","Text","useIconStyle","localeOf","withOpacity","useTheme","composeStyles","RESERVED","styles","stylesOf","IndicatorColors","active","track","IndicatorTiming","duration","easing","IndicatorTone","activeLength","width","percentage","Math","max","fillOf","color","backgroundColor","IndicatorLabels","t0","$","_c","label","value","theme","hasLabel","undefined","hasValue","t1","t2","t3","t4","labels","IndicatorLine","activeOpacity","children","colors","sheet","opacity","get","T0","stop","line","readingOf","formatOptions","style","locale","maxValue","minValue","valueLabel","Intl","NumberFormatOptions","clamped","min","range","share","text","format","useEased","target","timing","reduceMotion","shown","x1","y1","x2","y2","set","bezier","useIndicatorColors","tone","slot","onSurface","secondaryContainer","useMeasuredWidth","setWidth","Symbol","for","event","nativeEvent","layout","onLayout","_c","Text"],"sources":["../../src/indicator/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { LayoutChangeEvent, ViewStyle } from 'react-native'\nimport type { AnimatedStyle, SharedValue } from 'react-native-reanimated'\n\nimport { NumberFormatter } from '@internationalized/number'\nimport { useEffect, useState } from 'react'\nimport { View } from 'react-native'\nimport Animated, {\n Easing,\n useAnimatedStyle,\n useReducedMotion,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated'\n\nimport { Text } from '../components/text'\nimport { useIconStyle } from '../glyphs/icon-style'\nimport { localeOf } from '../number/locale'\nimport { withOpacity } from '../theme/color'\nimport { useTheme } from '../theme/scope'\nimport { composeStyles } from '../theme/styles'\nimport { RESERVED, styles, stylesOf } from './styles'\n\n// The pieces a linear indicator is drawn from, shared by ProgressIndicator and\n// Meter as web's src/indicator is. The styles they use are in ./styles.ts.\n//\n// Web lays the line out with `calc()` against the row's own width. React\n// Native has no `calc()`, so the row is measured through `onLayout` and the\n// active indicator's width worked out from that, which is also the length a\n// wave along the line follows.\n\n/** What a line draws its parts in. */\ntype IndicatorColors = {\n /** The active indicator and the stop indicator. */\n readonly active: string\n /** The track. */\n readonly track: string\n}\n\n/** How a value that changes moves: a duration in ms and a cubic Bézier. */\ntype IndicatorTiming = {\n readonly duration: number\n readonly easing: readonly [number, number, number, number]\n}\n\n/**\n * The line's colour. `primary` is the page's own pair. `negative` and\n * `positive` swap the active indicator and the stop indicator alone, leaving\n * the track in secondary container, so a column of meters reads as one scale\n * with bars of different colours. `inherit` takes the colour of the slot the\n * line sits in for both, and gives the track a quarter of it.\n */\ntype IndicatorTone = 'inherit' | 'negative' | 'positive' | 'primary'\n\n/**\n * The active indicator's length at a value: the value's share of what the two\n * gaps and the stop leave of the row, as web's `activeAt` gives it. A share of\n * the whole row would run the row 12dp long at the maximum, with the stop\n * drawn past its end.\n */\nfunction activeLength(width: number, percentage: number) {\n 'worklet'\n return (Math.max(0, width - RESERVED) * percentage) / 100\n}\n\n// A view's fill, built by a call rather than written inline at the prop,\n// which is what react-perf's no-new-object-as-prop is after.\nfunction fillOf(color: string) {\n return { backgroundColor: color }\n}\n\n/**\n * The label and, optionally, the value, on a row above the indicator, both in\n * the label-large role and on-surface-variant. Renders nothing when there is\n * neither to show.\n */\nfunction IndicatorLabels({\n label,\n value,\n}: {\n readonly label: string | undefined\n readonly value: string | undefined\n}) {\n const theme = useTheme()\n const hasLabel = label !== undefined && label !== ''\n const hasValue = value !== undefined && value !== ''\n\n if (!hasLabel && !hasValue) {\n return null\n }\n\n return (\n <View style={stylesOf(theme).labels}>\n {hasLabel ? (\n <Text style={styles.label} tone=\"muted\" variant=\"labelLarge\">\n {label}\n </Text>\n ) : null}\n {hasValue ? (\n <Text\n numberOfLines={1}\n style={styles.value}\n tone=\"muted\"\n variant=\"labelLarge\"\n >\n {value}\n </Text>\n ) : null}\n </View>\n )\n}\n\n/**\n * The page's line: the active indicator at its share of the measured width,\n * the track taking what is left, and the stop indicator at the end. Anything\n * passed as `children` is drawn inside the track, which is what the progress\n * indicator's buffer fills it with; with none the track is solid.\n * `activeOpacity` is how far the active indicator shows, which is how the\n * progress indicator fades it under a wave.\n */\nfunction IndicatorLine({\n activeOpacity,\n children,\n colors,\n percentage,\n width,\n}: {\n readonly activeOpacity?: SharedValue<number>\n readonly children?: ReactNode\n readonly colors: IndicatorColors\n readonly percentage: SharedValue<number>\n readonly width: number\n}) {\n const theme = useTheme()\n const sheet = stylesOf(theme)\n const active = useAnimatedStyle(() => {\n 'worklet'\n return {\n opacity: activeOpacity === undefined ? 1 : activeOpacity.get(),\n width: activeLength(width, percentage.get()),\n }\n })\n\n return (\n <View style={styles.line}>\n <Animated.View\n style={composeStyles<AnimatedStyle<ViewStyle>>(\n styles.active,\n sheet.active,\n fillOf(colors.active),\n active,\n )}\n />\n <View\n style={composeStyles<ViewStyle>(\n styles.track,\n sheet.track,\n children === undefined ? fillOf(colors.track) : undefined,\n )}\n >\n {children}\n </View>\n <View\n style={composeStyles<ViewStyle>(\n styles.stop,\n sheet.stop,\n fillOf(colors.active),\n )}\n />\n </View>\n )\n}\n\n/**\n * The value as React Aria's `useProgressBar` and `useMeter` read it: clamped to the range,\n * as a percentage of it, and written out by `formatOptions` in the locale,\n * the share of the range under a percent style and the value itself under\n * any other, unless `valueLabel` says it in words.\n */\nfunction readingOf({\n formatOptions = { style: 'percent' },\n locale,\n maxValue,\n minValue,\n value,\n valueLabel,\n}: {\n readonly formatOptions: Intl.NumberFormatOptions | undefined\n readonly locale: string | undefined\n readonly maxValue: number\n readonly minValue: number\n readonly value: number\n readonly valueLabel: string | undefined\n}) {\n const clamped = Math.min(Math.max(value, minValue), maxValue)\n const range = maxValue - minValue\n const share = range === 0 ? 0 : (clamped - minValue) / range\n const text =\n valueLabel ??\n new NumberFormatter(localeOf(locale), formatOptions).format(\n formatOptions.style === 'percent' ? share : clamped,\n )\n\n return { percentage: share * 100, text, value: clamped }\n}\n\n/**\n * A value that moves to each new target over `timing`, or jumps to it while\n * the reader has asked for reduced motion, as web's transition drops to `0s`\n * there. It starts at its first target, so nothing moves as it mounts.\n */\nfunction useEased(target: number, timing: IndicatorTiming) {\n const reduceMotion = useReducedMotion()\n const shown = useSharedValue(target)\n const { duration } = timing\n const [x1, y1, x2, y2] = timing.easing\n\n useEffect(() => {\n shown.set(\n reduceMotion\n ? target\n : withTiming(target, {\n duration,\n easing: Easing.bezier(x1, y1, x2, y2),\n }),\n )\n }, [duration, reduceMotion, shown, target, x1, x2, y1, y2])\n\n return shown\n}\n\n/**\n * The colours a tone draws the line in. `inherit` reads the colour of the\n * slot the line sits in, as a button hands its content colour to what it\n * holds, and falls back to on-surface outside one.\n */\nfunction useIndicatorColors(tone: IndicatorTone): IndicatorColors {\n const { colors } = useTheme()\n const slot = useIconStyle().color\n\n if (tone === 'inherit') {\n const color = typeof slot === 'string' ? slot : colors.onSurface\n\n return { active: color, track: withOpacity(color, 0.25) }\n }\n\n return { active: colors[tone], track: colors.secondaryContainer }\n}\n\n/** The width a view was last laid out at, and the handler that reads it. */\nfunction useMeasuredWidth() {\n const [width, setWidth] = useState(0)\n\n return {\n onLayout: (event: LayoutChangeEvent) => {\n setWidth(event.nativeEvent.layout.width)\n },\n width,\n }\n}\n\nexport {\n activeLength,\n fillOf,\n IndicatorLabels,\n IndicatorLine,\n readingOf,\n useEased,\n useIndicatorColors,\n useMeasuredWidth,\n}\nexport type { IndicatorColors, IndicatorTiming, IndicatorTone }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4DA,SAAS+B,aAAaC,OAAeC,YAAoB;CACvD;CACA,OAAQC,KAAKC,IAAI,GAAGH,QAAAA,EAAgB,IAAIC,aAAc;AACxD;AAIA,SAASG,OAAOC,OAAe;CAC7B,OAAO,EAAEC,iBAAiBD,MAAM;AAClC;;;;;;AAOA,SAAAE,gBAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAyB,MAAA,EAAAC,OAAAC,UAAAJ;CAOvB,MAAAK,QAAc1B,SAAS;CACvB,MAAA2B,WAAiBH,UAAUI,KAAAA,KAAaJ,UAAU;CAClD,MAAAK,WAAiBJ,UAAUG,KAAAA,KAAaH,UAAU;CAElD,IAAI,CAACE,YAAD,CAAcE,UAAQ,OACjB;CACR,IAAAC;CAAA,IAAAR,EAAA,OAAAI,OAAA;EAGcI,KAAA1B,SAASsB,KAAK;EAACJ,EAAA,KAAAI;EAAAJ,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,IAAAS;CAAA,IAAAT,EAAA,OAAAK,YAAAL,EAAA,OAAAE,OAAA;EACzBO,KAAAJ,WACC,oBAAC0D,QAAD;GAAa,OAAAlF,OAAMqB;GAAa,MAAA;GAAgB,SAAA;GAC7CA,UAAAA;EADE,CAAA,IADN;EAIOF,EAAA,KAAAK;EAAAL,EAAA,KAAAE;EAAAF,EAAA,KAAAS;CAAA,OAAAA,KAAAT,EAAA;CAA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EAAA,OAAlDQ;CAAkD;CAG1C,MAAAT,KAAAiB,OAAOkC;CAAK,IAAA1C;CAAA,IAAAR,EAAA,OAAAgB,OAAAqC,sBAAArD,EAAA,OAAAD,IAAA;EAAtBS,KAAA;GAAAxB,QAAUe;GAAYd,OAAS+B,OAAMqC;EAAoB;EAACrD,EAAA,KAAAgB,OAAAqC;EAAArD,EAAA,KAAAD;EAAAC,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,OAA1DQ;AAA0D;;AAInE,SAAA8C,mBAAA;CAAA,MAAAtD,IAAAC,EAAA,CAAA;CACE,MAAA,CAAAV,OAAAgE,YAA0BzF,SAAS,CAAC;CAAC,IAAAiC;CAAA,IAAAC,EAAA,OAAAwD,OAAAC,IAAA,2BAAA,GAAA;EAGzB1D,MAAA2D,UAAA;GACRH,SAASG,MAAKC,YAAYC,OAAOrE,KAAM;EAAC;EACzCS,EAAA,KAAAD;CAAA,OAAAA,KAAAC,EAAA;CAAA,IAAAQ;CAAA,IAAAR,EAAA,OAAAT,OAAA;EAHIiB,KAAA;GAAAqD,UACK9D;GAETR;EAEH;EAACS,EAAA,KAAAT;EAAAS,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,OALMQ;AAKN"}
1
+ {"version":3,"file":"index.js","names":["ReactNode","LayoutChangeEvent","ViewStyle","AnimatedStyle","SharedValue","NumberFormatter","useEffect","useState","View","Animated","Easing","useAnimatedStyle","useReducedMotion","useSharedValue","withTiming","Text","useIconStyle","withOpacity","useTheme","composeStyles","RESERVED","styles","stylesOf","IndicatorColors","active","track","IndicatorTiming","duration","easing","IndicatorTone","activeLength","width","percentage","Math","max","fillOf","color","backgroundColor","IndicatorLabels","t0","$","_c","label","value","theme","hasLabel","undefined","hasValue","t1","t2","t3","t4","labels","IndicatorLine","activeOpacity","children","colors","sheet","opacity","get","T0","stop","line","readingOf","formatOptions","style","locale","maxValue","minValue","valueLabel","Intl","NumberFormatOptions","clamped","min","range","share","text","format","useEased","target","timing","reduceMotion","shown","x1","y1","x2","y2","set","bezier","useIndicatorColors","tone","slot","onSurface","secondaryContainer","useMeasuredWidth","setWidth","Symbol","for","event","nativeEvent","layout","onLayout","_c","Text"],"sources":["../../src/indicator/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { LayoutChangeEvent, ViewStyle } from 'react-native'\nimport type { AnimatedStyle, SharedValue } from 'react-native-reanimated'\n\nimport { NumberFormatter } from '@internationalized/number'\nimport { useEffect, useState } from 'react'\nimport { View } from 'react-native'\nimport Animated, {\n Easing,\n useAnimatedStyle,\n useReducedMotion,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated'\n\nimport { Text } from '../components/text'\nimport { useIconStyle } from '../glyphs/icon-style'\nimport { withOpacity } from '../theme/color'\nimport { useTheme } from '../theme/scope'\nimport { composeStyles } from '../theme/styles'\nimport { RESERVED, styles, stylesOf } from './styles'\n\n// The pieces a linear indicator is drawn from, shared by ProgressIndicator and\n// Meter as web's src/indicator is. The styles they use are in ./styles.ts.\n//\n// Web lays the line out with `calc()` against the row's own width. React\n// Native has no `calc()`, so the row is measured through `onLayout` and the\n// active indicator's width worked out from that, which is also the length a\n// wave along the line follows.\n\n/** What a line draws its parts in. */\ntype IndicatorColors = {\n /** The active indicator and the stop indicator. */\n readonly active: string\n /** The track. */\n readonly track: string\n}\n\n/** How a value that changes moves: a duration in ms and a cubic Bézier. */\ntype IndicatorTiming = {\n readonly duration: number\n readonly easing: readonly [number, number, number, number]\n}\n\n/**\n * The line's colour. `primary` is the page's own pair. `negative` and\n * `positive` swap the active indicator and the stop indicator alone, leaving\n * the track in secondary container, so a column of meters reads as one scale\n * with bars of different colours. `inherit` takes the colour of the slot the\n * line sits in for both, and gives the track a quarter of it.\n */\ntype IndicatorTone = 'inherit' | 'negative' | 'positive' | 'primary'\n\n/**\n * The active indicator's length at a value: the value's share of what the two\n * gaps and the stop leave of the row, as web's `activeAt` gives it. A share of\n * the whole row would run the row 12dp long at the maximum, with the stop\n * drawn past its end.\n */\nfunction activeLength(width: number, percentage: number) {\n 'worklet'\n return (Math.max(0, width - RESERVED) * percentage) / 100\n}\n\n// A view's fill, built by a call rather than written inline at the prop,\n// which is what react-perf's no-new-object-as-prop is after.\nfunction fillOf(color: string) {\n return { backgroundColor: color }\n}\n\n/**\n * The label and, optionally, the value, on a row above the indicator, both in\n * the label-large role and on-surface-variant. Renders nothing when there is\n * neither to show.\n */\nfunction IndicatorLabels({\n label,\n value,\n}: {\n readonly label: string | undefined\n readonly value: string | undefined\n}) {\n const theme = useTheme()\n const hasLabel = label !== undefined && label !== ''\n const hasValue = value !== undefined && value !== ''\n\n if (!hasLabel && !hasValue) {\n return null\n }\n\n return (\n <View style={stylesOf(theme).labels}>\n {hasLabel ? (\n <Text style={styles.label} tone=\"muted\" variant=\"labelLarge\">\n {label}\n </Text>\n ) : null}\n {hasValue ? (\n <Text\n numberOfLines={1}\n style={styles.value}\n tone=\"muted\"\n variant=\"labelLarge\"\n >\n {value}\n </Text>\n ) : null}\n </View>\n )\n}\n\n/**\n * The page's line: the active indicator at its share of the measured width,\n * the track taking what is left, and the stop indicator at the end. Anything\n * passed as `children` is drawn inside the track, which is what the progress\n * indicator's buffer fills it with; with none the track is solid.\n * `activeOpacity` is how far the active indicator shows, which is how the\n * progress indicator fades it under a wave.\n */\nfunction IndicatorLine({\n activeOpacity,\n children,\n colors,\n percentage,\n width,\n}: {\n readonly activeOpacity?: SharedValue<number>\n readonly children?: ReactNode\n readonly colors: IndicatorColors\n readonly percentage: SharedValue<number>\n readonly width: number\n}) {\n const theme = useTheme()\n const sheet = stylesOf(theme)\n const active = useAnimatedStyle(() => {\n 'worklet'\n return {\n opacity: activeOpacity === undefined ? 1 : activeOpacity.get(),\n width: activeLength(width, percentage.get()),\n }\n })\n\n return (\n <View style={styles.line}>\n <Animated.View\n style={composeStyles<AnimatedStyle<ViewStyle>>(\n styles.active,\n sheet.active,\n fillOf(colors.active),\n active,\n )}\n />\n <View\n style={composeStyles<ViewStyle>(\n styles.track,\n sheet.track,\n children === undefined ? fillOf(colors.track) : undefined,\n )}\n >\n {children}\n </View>\n <View\n style={composeStyles<ViewStyle>(\n styles.stop,\n sheet.stop,\n fillOf(colors.active),\n )}\n />\n </View>\n )\n}\n\n/**\n * The value as React Aria's `useProgressBar` and `useMeter` read it: clamped to the range,\n * as a percentage of it, and written out by `formatOptions` in the locale,\n * the share of the range under a percent style and the value itself under\n * any other, unless `valueLabel` says it in words.\n */\nfunction readingOf({\n formatOptions = { style: 'percent' },\n locale,\n maxValue,\n minValue,\n value,\n valueLabel,\n}: {\n readonly formatOptions: Intl.NumberFormatOptions | undefined\n readonly locale: string\n readonly maxValue: number\n readonly minValue: number\n readonly value: number\n readonly valueLabel: string | undefined\n}) {\n const clamped = Math.min(Math.max(value, minValue), maxValue)\n const range = maxValue - minValue\n const share = range === 0 ? 0 : (clamped - minValue) / range\n const text =\n valueLabel ??\n new NumberFormatter(locale, formatOptions).format(\n formatOptions.style === 'percent' ? share : clamped,\n )\n\n return { percentage: share * 100, text, value: clamped }\n}\n\n/**\n * A value that moves to each new target over `timing`, or jumps to it while\n * the reader has asked for reduced motion, as web's transition drops to `0s`\n * there. It starts at its first target, so nothing moves as it mounts.\n */\nfunction useEased(target: number, timing: IndicatorTiming) {\n const reduceMotion = useReducedMotion()\n const shown = useSharedValue(target)\n const { duration } = timing\n const [x1, y1, x2, y2] = timing.easing\n\n useEffect(() => {\n shown.set(\n reduceMotion\n ? target\n : withTiming(target, {\n duration,\n easing: Easing.bezier(x1, y1, x2, y2),\n }),\n )\n }, [duration, reduceMotion, shown, target, x1, x2, y1, y2])\n\n return shown\n}\n\n/**\n * The colours a tone draws the line in. `inherit` reads the colour of the\n * slot the line sits in, as a button hands its content colour to what it\n * holds, and falls back to on-surface outside one.\n */\nfunction useIndicatorColors(tone: IndicatorTone): IndicatorColors {\n const { colors } = useTheme()\n const slot = useIconStyle().color\n\n if (tone === 'inherit') {\n const color = typeof slot === 'string' ? slot : colors.onSurface\n\n return { active: color, track: withOpacity(color, 0.25) }\n }\n\n return { active: colors[tone], track: colors.secondaryContainer }\n}\n\n/** The width a view was last laid out at, and the handler that reads it. */\nfunction useMeasuredWidth() {\n const [width, setWidth] = useState(0)\n\n return {\n onLayout: (event: LayoutChangeEvent) => {\n setWidth(event.nativeEvent.layout.width)\n },\n width,\n }\n}\n\nexport {\n activeLength,\n fillOf,\n IndicatorLabels,\n IndicatorLine,\n readingOf,\n useEased,\n useIndicatorColors,\n useMeasuredWidth,\n}\nexport type { IndicatorColors, IndicatorTiming, IndicatorTone }\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA2DA,SAAS8B,aAAaC,OAAeC,YAAoB;CACvD;CACA,OAAQC,KAAKC,IAAI,GAAGH,QAAAA,EAAgB,IAAIC,aAAc;AACxD;AAIA,SAASG,OAAOC,OAAe;CAC7B,OAAO,EAAEC,iBAAiBD,MAAM;AAClC;;;;;;AAOA,SAAAE,gBAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAyB,MAAA,EAAAC,OAAAC,UAAAJ;CAOvB,MAAAK,QAAc1B,SAAS;CACvB,MAAA2B,WAAiBH,UAAUI,KAAAA,KAAaJ,UAAU;CAClD,MAAAK,WAAiBJ,UAAUG,KAAAA,KAAaH,UAAU;CAElD,IAAI,CAACE,YAAD,CAAcE,UAAQ,OACjB;CACR,IAAAC;CAAA,IAAAR,EAAA,OAAAI,OAAA;EAGcI,KAAA1B,SAASsB,KAAK;EAACJ,EAAA,KAAAI;EAAAJ,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,IAAAS;CAAA,IAAAT,EAAA,OAAAK,YAAAL,EAAA,OAAAE,OAAA;EACzBO,KAAAJ,WACC,oBAAC0D,QAAD;GAAa,OAAAlF,OAAMqB;GAAa,MAAA;GAAgB,SAAA;GAC7CA,UAAAA;EADE,CAAA,IADN;EAIOF,EAAA,KAAAK;EAAAL,EAAA,KAAAE;EAAAF,EAA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AQ;EAAA,OAAAA,KAAAR,EAAA;EAAA,OAAlDQ;CAAkD;CAG1C,MAAAT,KAAAiB,OAAOkC;CAAK,IAAA1C;CAAA,IAAAR,EAAA,OAAAgB,OAAAqC,sBAAArD,EAAA,OAAAD,IAAA;EAAtBS,KAAA;GAAAxB,QAAUe;GAAYd,OAAS+B,OAAMqC;EAAoB;EAACrD,EAAA,KAAAgB,OAAAqC;EAAArD,EAAA,KAAAD;EAAAC,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,OAA1DQ;AAA0D;;AAInE,SAAA8C,mBAAA;CAAA,MAAAtD,IAAAC,EAAA,CAAA;CACE,MAAA,CAAAV,OAAAgE,YAA0BxF,SAAS,CAAC;CAAC,IAAAgC;CAAA,IAAAC,EAAA,OAAAwD,OAAAC,IAAA,2BAAA,GAAA;EAGzB1D,MAAA2D,UAAA;GACRH,SAASG,MAAKC,YAAYC,OAAOrE,KAAM;EAAC;EACzCS,EAAA,KAAAD;CAAA,OAAAA,KAAAC,EAAA;CAAA,IAAAQ;CAAA,IAAAR,EAAA,OAAAT,OAAA;EAHIiB,KAAA;GAAAqD,UACK9D;GAETR;EAEH;EAACS,EAAA,KAAAT;EAAAS,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,OALMQ;AAKN"}
@@ -1,6 +1,7 @@
1
1
  import { useTheme } from "../theme/scope.js";
2
2
  import { composeStyles } from "../theme/styles.js";
3
3
  import { useTypeRole } from "../typography/roles.js";
4
+ import { useLocaleOf } from "../i18n/provider.js";
4
5
  import { PersonGlyph } from "../glyphs/index.js";
5
6
  import { useImageLoadingStatus } from "./image.js";
6
7
  import { initialOfThing, initialsOfPerson } from "./initials.js";
@@ -38,7 +39,7 @@ const CONTENT = {
38
39
  * exported from the package.
39
40
  */
40
41
  function Mark(t0) {
41
- const $ = c(62);
42
+ const $ = c(40);
42
43
  let imgProps;
43
44
  let kind;
44
45
  let name;
@@ -80,107 +81,66 @@ function Mark(t0) {
80
81
  const theme = useTheme();
81
82
  const label = useTypeRole("labelLarge");
82
83
  const { handlersFor, previous, status } = useImageLoadingStatus(src);
83
- let T0;
84
- let initialsNode;
84
+ const own = markStylesOf(theme);
85
+ const text = initialsStylesOf(theme);
86
+ const locale = useLocaleOf(void 0);
85
87
  let t3;
86
- let t4;
87
- let t5;
88
- let t6;
89
- let t7;
90
- let t8;
91
- if ($[11] !== decorative || $[12] !== initials || $[13] !== kind || $[14] !== label || $[15] !== name || $[16] !== previous || $[17] !== props || $[18] !== shape || $[19] !== showPersonIcon || $[20] !== size || $[21] !== status || $[22] !== style || $[23] !== theme || $[24] !== tintsFallback || $[25] !== tone) {
92
- const own = markStylesOf(theme);
93
- const text = initialsStylesOf(theme);
94
- let t9;
95
- if ($[34] !== initials || $[35] !== name) {
96
- t9 = initials(name);
97
- $[34] = initials;
98
- $[35] = name;
99
- $[36] = t9;
100
- } else t9 = $[36];
101
- const fallback = t9;
102
- const named = !decorative && name.trim() !== "";
103
- const showsPicture = status === "loaded" || previous !== void 0;
104
- initialsNode = null;
105
- if (!showsPicture && kind === "person" && fallback === "") {
106
- let t10;
107
- if ($[37] !== showPersonIcon || $[38] !== size || $[39] !== theme || $[40] !== tone) {
108
- t10 = showPersonIcon ? /* @__PURE__ */ jsx(PersonGlyph, {
109
- color: theme.colors[CONTENT[tone]],
110
- size: DIAMETERS[size] * GLYPH_SHARE
111
- }) : null;
112
- $[37] = showPersonIcon;
113
- $[38] = size;
114
- $[39] = theme;
115
- $[40] = tone;
116
- $[41] = t10;
117
- } else t10 = $[41];
118
- initialsNode = t10;
119
- } else if (!showsPicture) {
120
- const initialsText = /* @__PURE__ */ jsx(Text, {
121
- allowFontScaling: false,
122
- style: composeStyles(label, text[size], text[tone]),
123
- children: fallback
124
- });
125
- initialsNode = tintsFallback ? /* @__PURE__ */ jsx(View, {
126
- style: composeStyles(markStyles.fallback, own[tone]),
127
- children: initialsText
128
- }) : initialsText;
129
- }
130
- T0 = View;
131
- t3 = named ? true : void 0;
132
- t4 = decorative ? true : void 0;
133
- t5 = named ? name : void 0;
134
- t6 = named ? "img" : void 0;
135
- t7 = props;
136
- t8 = composeStyles(own.base, own[shape], markStyles[size], tintsFallback ? void 0 : own[tone], style);
137
- $[11] = decorative;
138
- $[12] = initials;
139
- $[13] = kind;
140
- $[14] = label;
141
- $[15] = name;
142
- $[16] = previous;
143
- $[17] = props;
144
- $[18] = shape;
145
- $[19] = showPersonIcon;
146
- $[20] = size;
147
- $[21] = status;
148
- $[22] = style;
149
- $[23] = theme;
150
- $[24] = tintsFallback;
151
- $[25] = tone;
152
- $[26] = T0;
153
- $[27] = initialsNode;
154
- $[28] = t3;
155
- $[29] = t4;
156
- $[30] = t5;
157
- $[31] = t6;
158
- $[32] = t7;
159
- $[33] = t8;
160
- } else {
161
- T0 = $[26];
162
- initialsNode = $[27];
163
- t3 = $[28];
164
- t4 = $[29];
165
- t5 = $[30];
166
- t6 = $[31];
167
- t7 = $[32];
168
- t8 = $[33];
88
+ if ($[11] !== initials || $[12] !== locale || $[13] !== name) {
89
+ t3 = initials(name, locale);
90
+ $[11] = initials;
91
+ $[12] = locale;
92
+ $[13] = name;
93
+ $[14] = t3;
94
+ } else t3 = $[14];
95
+ const fallback = t3;
96
+ const named = !decorative && name.trim() !== "";
97
+ const showsPicture = status === "loaded" || previous !== void 0;
98
+ let initialsNode = null;
99
+ if (!showsPicture && kind === "person" && fallback === "") {
100
+ let t4;
101
+ if ($[15] !== showPersonIcon || $[16] !== size || $[17] !== theme || $[18] !== tone) {
102
+ t4 = showPersonIcon ? /* @__PURE__ */ jsx(PersonGlyph, {
103
+ color: theme.colors[CONTENT[tone]],
104
+ size: DIAMETERS[size] * GLYPH_SHARE
105
+ }) : null;
106
+ $[15] = showPersonIcon;
107
+ $[16] = size;
108
+ $[17] = theme;
109
+ $[18] = tone;
110
+ $[19] = t4;
111
+ } else t4 = $[19];
112
+ initialsNode = t4;
113
+ } else if (!showsPicture) {
114
+ const initialsText = /* @__PURE__ */ jsx(Text, {
115
+ allowFontScaling: false,
116
+ style: composeStyles(label, text[size], text[tone]),
117
+ children: fallback
118
+ });
119
+ initialsNode = tintsFallback ? /* @__PURE__ */ jsx(View, {
120
+ style: composeStyles(markStyles.fallback, own[tone]),
121
+ children: initialsText
122
+ }) : initialsText;
169
123
  }
124
+ const T0 = View;
125
+ const t4 = named ? true : void 0;
126
+ const t5 = decorative ? true : void 0;
127
+ const t6 = named ? name : void 0;
128
+ const t7 = named ? "img" : void 0;
129
+ const t8 = composeStyles(own.base, own[shape], markStyles[size], tintsFallback ? void 0 : own[tone], style);
170
130
  let t9;
171
- if ($[42] !== previous || $[43] !== resizeMode) {
131
+ if ($[20] !== previous || $[21] !== resizeMode) {
172
132
  t9 = previous === void 0 ? null : /* @__PURE__ */ jsx(Image, {
173
133
  accessibilityIgnoresInvertColors: true,
174
134
  resizeMode,
175
135
  source: sourceOf(previous),
176
136
  style: markStyles.image
177
137
  }, previous);
178
- $[42] = previous;
179
- $[43] = resizeMode;
180
- $[44] = t9;
181
- } else t9 = $[44];
138
+ $[20] = previous;
139
+ $[21] = resizeMode;
140
+ $[22] = t9;
141
+ } else t9 = $[22];
182
142
  let t10;
183
- if ($[45] !== handlersFor || $[46] !== imgProps || $[47] !== resizeMode || $[48] !== src || $[49] !== status) {
143
+ if ($[23] !== handlersFor || $[24] !== imgProps || $[25] !== resizeMode || $[26] !== src || $[27] !== status) {
184
144
  t10 = src === void 0 || status === "error" ? null : /* @__PURE__ */ jsx(Image, {
185
145
  accessibilityIgnoresInvertColors: true,
186
146
  ...imgProps,
@@ -189,21 +149,21 @@ function Mark(t0) {
189
149
  source: sourceOf(src),
190
150
  style: composeStyles(markStyles.image, status === "loaded" ? void 0 : markStyles.imagePending)
191
151
  }, src);
192
- $[45] = handlersFor;
193
- $[46] = imgProps;
194
- $[47] = resizeMode;
195
- $[48] = src;
196
- $[49] = status;
197
- $[50] = t10;
198
- } else t10 = $[50];
152
+ $[23] = handlersFor;
153
+ $[24] = imgProps;
154
+ $[25] = resizeMode;
155
+ $[26] = src;
156
+ $[27] = status;
157
+ $[28] = t10;
158
+ } else t10 = $[28];
199
159
  let t11;
200
- if ($[51] !== T0 || $[52] !== initialsNode || $[53] !== t10 || $[54] !== t3 || $[55] !== t4 || $[56] !== t5 || $[57] !== t6 || $[58] !== t7 || $[59] !== t8 || $[60] !== t9) {
160
+ if ($[29] !== T0 || $[30] !== initialsNode || $[31] !== props || $[32] !== t10 || $[33] !== t4 || $[34] !== t5 || $[35] !== t6 || $[36] !== t7 || $[37] !== t8 || $[38] !== t9) {
201
161
  t11 = /* @__PURE__ */ jsxs(T0, {
202
- accessible: t3,
203
- "aria-hidden": t4,
204
- "aria-label": t5,
205
- role: t6,
206
- ...t7,
162
+ accessible: t4,
163
+ "aria-hidden": t5,
164
+ "aria-label": t6,
165
+ role: t7,
166
+ ...props,
207
167
  style: t8,
208
168
  children: [
209
169
  initialsNode,
@@ -211,18 +171,18 @@ function Mark(t0) {
211
171
  t10
212
172
  ]
213
173
  });
214
- $[51] = T0;
215
- $[52] = initialsNode;
216
- $[53] = t10;
217
- $[54] = t3;
218
- $[55] = t4;
219
- $[56] = t5;
220
- $[57] = t6;
221
- $[58] = t7;
222
- $[59] = t8;
223
- $[60] = t9;
224
- $[61] = t11;
225
- } else t11 = $[61];
174
+ $[29] = T0;
175
+ $[30] = initialsNode;
176
+ $[31] = props;
177
+ $[32] = t10;
178
+ $[33] = t4;
179
+ $[34] = t5;
180
+ $[35] = t6;
181
+ $[36] = t7;
182
+ $[37] = t8;
183
+ $[38] = t9;
184
+ $[39] = t11;
185
+ } else t11 = $[39];
226
186
  return t11;
227
187
  }
228
188
  function sourceOf(uri) {
@@ -1 +1 @@
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,MAAA,GAAAoB,SAAAH;EAWFC,EAAA,KAAAD;EAAAC,EAAA,KAAA3B;EAAA2B,EAAA,KAAA1B;EAAA0B,EAAA,KAAAxB;EAAAwB,EAAA,KAAAE;EAAAF,EAAA,KAAArB;EAAAqB,EAAA,KAAApB;EAAAoB,EAAA,KAAAnB;EAAAmB,EAAA,KAAAG;EAAAH,EAAA,KAAAI;EAAAJ,EAAA,MAAAlB;CAAA,OAAA;EAAAT,WAAA2B,EAAA;EAAA1B,OAAA0B,EAAA;EAAAxB,OAAAwB,EAAA;EAAAE,QAAAF,EAAA;EAAArB,OAAAqB,EAAA;EAAApB,MAAAoB,EAAA;EAAAnB,QAAAm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A,MAAAf;EAAAe,EAAA,MAAApB;EAAAoB,EAAA,MAAAU;EAAAV,EAAA,MAAA0B;CAAA,OAAAA,MAAA1B,EAAA;CAAA,IAAAiC;CAAA,IAAAjC,EAAA,QAAAW,MAAAX,EAAA,QAAAY,gBAAAZ,EAAA,QAAA0B,OAAA1B,EAAA,QAAAa,MAAAb,EAAA,QAAAc,MAAAd,EAAA,QAAAe,MAAAf,EAAA,QAAAgB,MAAAhB,EAAA,QAAAiB,MAAAjB,EAAA,QAAAkB,MAAAlB,EAAA,QAAAqB,IAAA;EA1CHY,MAAA,qBAAC,IAAD;GACc,YAAApB;GACC,eAAAC;GACD,cAAAC;GACN,MAAAC;GAAyB,GAC3Bd;GACG,OAAAgB;GANT,UAAA;IAcGN;IAMAS;IASAK;GA7BE;;EA2CE1B,EAAA,MAAAW;EAAAX,EAAA,MAAAY;EAAAZ,EAAA,MAAA0B;EAAA1B,EAAA,MAAAa;EAAAb,EAAA,MAAAc;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","useLocaleOf","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","own","text","locale","t3","fallback","named","trim","showsPicture","initialsNode","t4","colors","initialsText","T0","t5","t6","t7","t8","base","t9","sourceOf","image","t10","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 { useLocaleOf } from '../i18n/provider'\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 locale = useLocaleOf(undefined)\n const fallback = initials(name, locale)\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\n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QJ;EAEJoB,EAAA,MAAAQ;EAAAR,EAAA,MAAA3B;EAAA2B,EAAA,MAAAf;EAAAe,EAAA,MAAApB;EAAAoB,EAAA,MAAAU;EAAAV,EAAA,MAAAgC;CAAA,OAAAA,MAAAhC,EAAA;CAAA,IAAAkC;CAAA,IAAAlC,EAAA,QAAAuB,MAAAvB,EAAA,QAAAmB,gBAAAnB,EAAA,QAAAE,SAAAF,EAAA,QAAAgC,OAAAhC,EAAA,QAAAoB,MAAApB,EAAA,QAAAwB,MAAAxB,EAAA,QAAAyB,MAAAzB,EAAA,QAAA0B,MAAA1B,EAAA,QAAA2B,MAAA3B,EAAA,QAAA6B,IAAA;EA1CHK,MAAA,qBAAC,IAAD;GACc,YAAAd;GACC,eAAAI;GACD,cAAAC;GACN,MAAAC;GAAyB,GAC3BxB;GACG,OAAAyB;GANT,UAAA;IAcGR;IAMAU;IASAG;GA7BE;;EA2CEhC,EAAA,MAAAuB;EAAAvB,EAAA,MAAAmB;EAAAnB,EAAA,MAAAE;EAAAF,EAAA,MAAAgC;EAAAhC,EAAA,MAAAoB;EAAApB,EAAA,MAAAwB;EAAAxB,EAAA,MAAAyB;EAAAzB,EAAA,MAAA0B;EAAA1B,EAAA,MAAA2B;EAAA3B,EAAA,MAAA6B;EAAA7B,EAAA,MAAAkC;CAAA,OAAAA,MAAAlC,EAAA;CAAA,OA3CPkC;AA2CO;AAOX,SAASJ,SAASK,KAAkC;CAClD,OAAO,EAAEA,IAAI;AACf"}
@@ -1 +1 @@
1
- {"version":3,"file":"initials.js","names":["INITIAL","JOINING","ZERO_WIDTH_NON_JOINER","TITLE","SUFFIX","TRAILING_ASIDE","GRAPHEME","segmenters","Map","Intl","Segmenter","graphemesOf","text","locale","match","key","segmenter","get","undefined","granularity","set","Array","from","segment","initialOf","word","graphemes","chosen","find","grapheme","test","at","toLocaleUpperCase","initialOfThing","name","trim","initialsOfPerson","words","replace","split","filter","Boolean","length","slice","first","last","between"],"sources":["../../src/mark/initials.ts"],"sourcesContent":["// What a mark shows while it has no picture: the initials of a person's\n// name, or the initial of a thing's. Copied from kanso-ui's\n// `src/mark/initials.ts` rather than shared through a package, so the two\n// read a name the same way and each can be read without the other.\n//\n// It works in graphemes, what a reader sees as one character, in the\n// device's locale. A code point drops an accent written as a combining mark,\n// splits an Indic conjunct and cuts a flag or a joined emoji in half;\n// upper-casing without the locale turns a Turkish \"i\" into \"I\" rather than\n// \"İ\".\n//\n// Graphemes come from `Intl.Segmenter` where the engine has it, as browsers\n// and Node do. Hermes's Intl has no Segmenter, only a collator and the date\n// and number formats, so on a device `GRAPHEME` stands in: a\n// character with the marks and emoji modifiers after it, a pair of regional\n// indicators as one flag, a sequence joined by a zero-width joiner, and the\n// consonants Unicode joins through a virama into one conjunct. It has no rule\n// for the rest of Unicode's, so it splits a Hangul syllable written as\n// separate jamo, which a name typed on a phone is not.\n\n// What a word's initial can be: a letter, a number, or a picture — an emoji,\n// or a flag, which is a pair of regional indicators. A word opening with\n// anything else — a bracket, a quote, the @ of a handle, the # of a channel\n// — is initialised by the first of these inside it.\nconst INITIAL = /^[\\p{L}\\p{N}\\p{Extended_Pictographic}\\p{Regional_Indicator}]/u\n\n// The scripts whose letters join to the next one. Two initials in one of\n// them, written side by side, shape into a single connected word rather than\n// two letters, so a zero-width non-joiner goes between them.\nconst JOINING =\n /^[\\p{Script=Arabic}\\p{Script=Syriac}\\p{Script=Mongolian}\\p{Script=Nko}\\p{Script=Adlam}\\p{Script=Mandaic}\\p{Script=Manichaean}\\p{Script=Psalter_Pahlavi}\\p{Script=Hanifi_Rohingya}\\p{Script=Sogdian}\\p{Script=Old_Uyghur}]/u\n\nconst ZERO_WIDTH_NON_JOINER = '\\u200C'\n\n// A title before a name — \"Dr.\", \"Mrs.\", \"Prof.\" — which is not one of its\n// words. Two letters at least, so a first initial written \"J.\" is kept.\nconst TITLE = /^\\p{L}{2,4}\\.$/u\n\n// A generational suffix after a name — \"Jr.\", \"Sr\", \"III\", \"3rd\" — which is\n// not its last word either. The numerals are the generational ones only, so\n// a surname that reads as a numeral, \"Xi\" say, is kept.\nconst SUFFIX = /^(?:jr|sr|ii|iii|iv|\\d+(?:st|nd|rd|th))\\.?,?$/iu\n\n// Something said about the name rather than part of it, in brackets at its\n// end: \"(she/her)\", \"[away]\".\nconst TRAILING_ASIDE = /\\s*[([{][^)\\]}]*[)\\]}]\\s*$/u\n\n// One grapheme, where the engine has no `Intl.Segmenter`: a flag, or a\n// character followed by what attaches to it. The viramas are the six Unicode\n// joins the next consonant through, in Devanagari, Bengali, Gujarati, Oriya,\n// Telugu and Malayalam, and they are tried before the plain mark they also\n// are, so the consonant after one stays in the grapheme.\nconst GRAPHEME =\n /\\p{Regional_Indicator}{2}|\\P{M}(?:[\\u094D\\u09CD\\u0ACD\\u0B4D\\u0C4D\\u0D4D]\\u200D?\\p{L}|[\\p{M}\\p{Emoji_Modifier}]|\\u200D\\P{M})*/gu\n\nconst segmenters = new Map<string, Intl.Segmenter>()\n\nfunction graphemesOf(text: string, locale: string | undefined) {\n // Asked on every call rather than once, so a test can take it away.\n if (typeof Intl.Segmenter !== 'function') {\n return text.match(GRAPHEME) ?? []\n }\n\n const key = locale ?? ''\n let segmenter = segmenters.get(key)\n if (segmenter === undefined) {\n segmenter = new Intl.Segmenter(locale, { granularity: 'grapheme' })\n segmenters.set(key, segmenter)\n }\n return Array.from(segmenter.segment(text), ({ segment }) => segment)\n}\n\n/**\n * The character that stands for `word`: its first grapheme that is a letter,\n * a number or a picture, or its first grapheme where it has none of those,\n * so something always shows. Upper-cased in the locale, and then one\n * grapheme of that, since upper-casing can lengthen it: \"ß\" is \"SS\".\n */\nfunction initialOf(word: string, locale: string | undefined) {\n const graphemes = graphemesOf(word, locale)\n const chosen =\n graphemes.find((grapheme) => INITIAL.test(grapheme)) ??\n graphemes.at(0) ??\n ''\n return graphemesOf(chosen.toLocaleUpperCase(locale), locale).at(0) ?? ''\n}\n\n/**\n * One letter, where a person takes two. A person has a first name and a last\n * name to initialise; a thing usually has neither, so the same rule applied\n * to \"Second item\" would produce \"SI\", a pair of initials for something that\n * was never two words in that sense.\n *\n * `locale` is the device's when left out, which is what a product icon\n * passes.\n */\nfunction initialOfThing(name: string, locale?: string) {\n return initialOf(name.trim(), locale)\n}\n\n/**\n * The initials of the first and the last word, which handles both \"Ada\" and\n * \"Ada Lovelace\" without a separate prop for how many to take. What a\n * display name carries around the name itself is left out first: a title\n * before it, a generational suffix after it, and an aside in brackets at its\n * end. A name written without spaces between its words — Japanese, Chinese —\n * is one word to this, and takes one initial.\n *\n * `locale` is the device's when left out, which is what an avatar passes.\n */\nfunction initialsOfPerson(name: string, locale?: string) {\n let words = name.replace(TRAILING_ASIDE, '').split(/\\s+/u).filter(Boolean)\n if (words.length > 1 && TITLE.test(words[0] ?? '')) {\n words = words.slice(1)\n }\n if (words.length > 1 && SUFFIX.test(words.at(-1) ?? '')) {\n words = words.slice(0, -1)\n }\n if (words.length === 0) {\n return ''\n }\n const first = initialOf(words[0] ?? '', locale)\n if (words.length === 1) {\n return first\n }\n const last = initialOf(words.at(-1) ?? '', locale)\n const between =\n JOINING.test(first) && JOINING.test(last) ? ZERO_WIDTH_NON_JOINER : ''\n return `${first}${between}${last}`\n}\n\nexport { initialOfThing, initialsOfPerson }\n"],"mappings":";AAwBA,MAAMA,UAAU;AAKhB,MAAMC,UACJ;AAEF,MAAMC,wBAAwB;AAI9B,MAAMC,QAAQ;AAKd,MAAMC,SAAS;AAIf,MAAMC,iBAAiB;AAOvB,MAAMC,WACJ;AAEF,MAAMC,6BAAa,IAAIC,IAA4B;AAEnD,SAASG,YAAYC,MAAcC,QAA4B;CAE7D,IAAI,OAAOJ,KAAKC,cAAc,YAC5B,OAAOE,KAAKE,MAAMR,QAAQ,KAAK,CAAA;CAGjC,MAAMS,MAAMF,UAAU;CACtB,IAAIG,YAAYT,WAAWU,IAAIF,GAAG;CAClC,IAAIC,cAAcE,KAAAA,GAAW;EAC3BF,YAAY,IAAIP,KAAKC,UAAUG,QAAQ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":3,"file":"initials.js","names":["INITIAL","JOINING","ZERO_WIDTH_NON_JOINER","TITLE","SUFFIX","TRAILING_ASIDE","GRAPHEME","segmenters","Map","Intl","Segmenter","graphemesOf","text","locale","match","key","segmenter","get","undefined","granularity","set","Array","from","segment","initialOf","word","graphemes","chosen","find","grapheme","test","at","toLocaleUpperCase","initialOfThing","name","trim","initialsOfPerson","words","replace","split","filter","Boolean","length","slice","first","last","between"],"sources":["../../src/mark/initials.ts"],"sourcesContent":["// What a mark shows while it has no picture: the initials of a person's\n// name, or the initial of a thing's. Copied from kanso-ui's\n// `src/mark/initials.ts` rather than shared through a package, so the two\n// read a name the same way and each can be read without the other.\n//\n// It works in graphemes, what a reader sees as one character, in the locale\n// the mark is drawn in. A code point drops an accent written as a combining mark,\n// splits an Indic conjunct and cuts a flag or a joined emoji in half;\n// upper-casing without the locale turns a Turkish \"i\" into \"I\" rather than\n// \"İ\".\n//\n// Graphemes come from `Intl.Segmenter` where the engine has it, as browsers\n// and Node do. Hermes's Intl has no Segmenter, only a collator and the date\n// and number formats, so on a device `GRAPHEME` stands in: a\n// character with the marks and emoji modifiers after it, a pair of regional\n// indicators as one flag, a sequence joined by a zero-width joiner, and the\n// consonants Unicode joins through a virama into one conjunct. It has no rule\n// for the rest of Unicode's, so it splits a Hangul syllable written as\n// separate jamo, which a name typed on a phone is not.\n\n// What a word's initial can be: a letter, a number, or a picture — an emoji,\n// or a flag, which is a pair of regional indicators. A word opening with\n// anything else — a bracket, a quote, the @ of a handle, the # of a channel\n// — is initialised by the first of these inside it.\nconst INITIAL = /^[\\p{L}\\p{N}\\p{Extended_Pictographic}\\p{Regional_Indicator}]/u\n\n// The scripts whose letters join to the next one. Two initials in one of\n// them, written side by side, shape into a single connected word rather than\n// two letters, so a zero-width non-joiner goes between them.\nconst JOINING =\n /^[\\p{Script=Arabic}\\p{Script=Syriac}\\p{Script=Mongolian}\\p{Script=Nko}\\p{Script=Adlam}\\p{Script=Mandaic}\\p{Script=Manichaean}\\p{Script=Psalter_Pahlavi}\\p{Script=Hanifi_Rohingya}\\p{Script=Sogdian}\\p{Script=Old_Uyghur}]/u\n\nconst ZERO_WIDTH_NON_JOINER = '\\u200C'\n\n// A title before a name — \"Dr.\", \"Mrs.\", \"Prof.\" — which is not one of its\n// words. Two letters at least, so a first initial written \"J.\" is kept.\nconst TITLE = /^\\p{L}{2,4}\\.$/u\n\n// A generational suffix after a name — \"Jr.\", \"Sr\", \"III\", \"3rd\" — which is\n// not its last word either. The numerals are the generational ones only, so\n// a surname that reads as a numeral, \"Xi\" say, is kept.\nconst SUFFIX = /^(?:jr|sr|ii|iii|iv|\\d+(?:st|nd|rd|th))\\.?,?$/iu\n\n// Something said about the name rather than part of it, in brackets at its\n// end: \"(she/her)\", \"[away]\".\nconst TRAILING_ASIDE = /\\s*[([{][^)\\]}]*[)\\]}]\\s*$/u\n\n// One grapheme, where the engine has no `Intl.Segmenter`: a flag, or a\n// character followed by what attaches to it. The viramas are the six Unicode\n// joins the next consonant through, in Devanagari, Bengali, Gujarati, Oriya,\n// Telugu and Malayalam, and they are tried before the plain mark they also\n// are, so the consonant after one stays in the grapheme.\nconst GRAPHEME =\n /\\p{Regional_Indicator}{2}|\\P{M}(?:[\\u094D\\u09CD\\u0ACD\\u0B4D\\u0C4D\\u0D4D]\\u200D?\\p{L}|[\\p{M}\\p{Emoji_Modifier}]|\\u200D\\P{M})*/gu\n\nconst segmenters = new Map<string, Intl.Segmenter>()\n\nfunction graphemesOf(text: string, locale: string | undefined) {\n // Asked on every call rather than once, so a test can take it away.\n if (typeof Intl.Segmenter !== 'function') {\n return text.match(GRAPHEME) ?? []\n }\n\n const key = locale ?? ''\n let segmenter = segmenters.get(key)\n if (segmenter === undefined) {\n segmenter = new Intl.Segmenter(locale, { granularity: 'grapheme' })\n segmenters.set(key, segmenter)\n }\n return Array.from(segmenter.segment(text), ({ segment }) => segment)\n}\n\n/**\n * The character that stands for `word`: its first grapheme that is a letter,\n * a number or a picture, or its first grapheme where it has none of those,\n * so something always shows. Upper-cased in the locale, and then one\n * grapheme of that, since upper-casing can lengthen it: \"ß\" is \"SS\".\n */\nfunction initialOf(word: string, locale: string | undefined) {\n const graphemes = graphemesOf(word, locale)\n const chosen =\n graphemes.find((grapheme) => INITIAL.test(grapheme)) ??\n graphemes.at(0) ??\n ''\n return graphemesOf(chosen.toLocaleUpperCase(locale), locale).at(0) ?? ''\n}\n\n/**\n * One letter, where a person takes two. A person has a first name and a last\n * name to initialise; a thing usually has neither, so the same rule applied\n * to \"Second item\" would produce \"SI\", a pair of initials for something that\n * was never two words in that sense.\n *\n * `locale` is the device's when left out, which is what a product icon\n * passes.\n */\nfunction initialOfThing(name: string, locale?: string) {\n return initialOf(name.trim(), locale)\n}\n\n/**\n * The initials of the first and the last word, which handles both \"Ada\" and\n * \"Ada Lovelace\" without a separate prop for how many to take. What a\n * display name carries around the name itself is left out first: a title\n * before it, a generational suffix after it, and an aside in brackets at its\n * end. A name written without spaces between its words — Japanese, Chinese —\n * is one word to this, and takes one initial.\n *\n * `locale` is the device's when left out, which is what an avatar passes.\n */\nfunction initialsOfPerson(name: string, locale?: string) {\n let words = name.replace(TRAILING_ASIDE, '').split(/\\s+/u).filter(Boolean)\n if (words.length > 1 && TITLE.test(words[0] ?? '')) {\n words = words.slice(1)\n }\n if (words.length > 1 && SUFFIX.test(words.at(-1) ?? '')) {\n words = words.slice(0, -1)\n }\n if (words.length === 0) {\n return ''\n }\n const first = initialOf(words[0] ?? '', locale)\n if (words.length === 1) {\n return first\n }\n const last = initialOf(words.at(-1) ?? '', locale)\n const between =\n JOINING.test(first) && JOINING.test(last) ? ZERO_WIDTH_NON_JOINER : ''\n return `${first}${between}${last}`\n}\n\nexport { initialOfThing, initialsOfPerson }\n"],"mappings":";AAwBA,MAAMA,UAAU;AAKhB,MAAMC,UACJ;AAEF,MAAMC,wBAAwB;AAI9B,MAAMC,QAAQ;AAKd,MAAMC,SAAS;AAIf,MAAMC,iBAAiB;AAOvB,MAAMC,WACJ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B,OAAO;CAET,MAAME,QAAQpB,UAAUa,MAAM,MAAM,IAAIxB,MAAM;CAC9C,IAAIwB,MAAMK,WAAW,GACnB,OAAOE;CAET,MAAMC,OAAOrB,UAAUa,MAAMN,GAAG,EAAE,KAAK,IAAIlB,MAAM;CAGjD,OAAO,GAAG+B,QADR3C,QAAQ6B,KAAKc,KAAK,KAAK3C,QAAQ6B,KAAKe,IAAI,IAAI3C,wBAAwB,KAC1C2C;AAC9B"}
@@ -4,6 +4,7 @@ import { withOpacity } from "../theme/color.js";
4
4
  import { ButtonSlotContext } from "../button/slots.js";
5
5
  import { AnimatedPressable } from "../button/index.js";
6
6
  import { OverlayHost } from "../overlay/host.js";
7
+ import { SeparatorOrientationContext } from "../separator/index.js";
7
8
  import { c } from "react/compiler-runtime";
8
9
  import { AccessibilityInfo, I18nManager, Modal, Platform, StyleSheet } from "react-native";
9
10
  import { useEffect, useRef, useState } from "react";
@@ -52,7 +53,7 @@ function insetsOf(insets) {
52
53
  * and the scrim, with the surface itself as its children.
53
54
  */
54
55
  function ModalWindow(t0) {
55
- const $ = c(20);
56
+ const $ = c(23);
56
57
  const { children, isKeyboardDismissDisabled, labelledBy, onClose, onScrimPress, scrim, title } = t0;
57
58
  const styles = stylesOf(useTheme());
58
59
  const T0 = Modal;
@@ -72,48 +73,60 @@ function ModalWindow(t0) {
72
73
  const t9 = true;
73
74
  const T1 = ButtonSlotContext;
74
75
  const t10 = null;
75
- const T2 = OverlayHost;
76
- const T3 = AnimatedPressable;
77
- const t11 = false;
78
- const t12 = true;
79
- const t13 = false;
80
- const t14 = composeStyles(styles.scrim, scrim);
81
- let t15;
82
- if ($[2] !== T3 || $[3] !== onScrimPress || $[4] !== t14) {
83
- t15 = /* @__PURE__ */ jsx(T3, {
84
- accessible: t11,
85
- "aria-hidden": t12,
86
- focusable: t13,
76
+ const T2 = SeparatorOrientationContext;
77
+ const t11 = null;
78
+ const T3 = OverlayHost;
79
+ const T4 = AnimatedPressable;
80
+ const t12 = false;
81
+ const t13 = true;
82
+ const t14 = false;
83
+ const t15 = composeStyles(styles.scrim, scrim);
84
+ let t16;
85
+ if ($[2] !== T4 || $[3] !== onScrimPress || $[4] !== t15) {
86
+ t16 = /* @__PURE__ */ jsx(T4, {
87
+ accessible: t12,
88
+ "aria-hidden": t13,
89
+ focusable: t14,
87
90
  onPress: onScrimPress,
88
- style: t14,
91
+ style: t15,
89
92
  tabIndex: -1
90
93
  });
91
- $[2] = T3;
94
+ $[2] = T4;
92
95
  $[3] = onScrimPress;
93
- $[4] = t14;
94
- $[5] = t15;
95
- } else t15 = $[5];
96
- let t16;
97
- if ($[6] !== T2 || $[7] !== children || $[8] !== t15) {
98
- t16 = /* @__PURE__ */ jsxs(T2, { children: [t15, children] });
99
- $[6] = T2;
100
- $[7] = children;
101
- $[8] = t15;
102
- $[9] = t16;
103
- } else t16 = $[9];
96
+ $[4] = t15;
97
+ $[5] = t16;
98
+ } else t16 = $[5];
104
99
  let t17;
105
- if ($[10] !== T1 || $[11] !== t16) {
106
- t17 = /* @__PURE__ */ jsx(T1, {
100
+ if ($[6] !== T3 || $[7] !== children || $[8] !== t16) {
101
+ t17 = /* @__PURE__ */ jsxs(T3, { children: [t16, children] });
102
+ $[6] = T3;
103
+ $[7] = children;
104
+ $[8] = t16;
105
+ $[9] = t17;
106
+ } else t17 = $[9];
107
+ let t18;
108
+ if ($[10] !== T2 || $[11] !== t17) {
109
+ t18 = /* @__PURE__ */ jsx(T2, {
110
+ value: t11,
111
+ children: t17
112
+ });
113
+ $[10] = T2;
114
+ $[11] = t17;
115
+ $[12] = t18;
116
+ } else t18 = $[12];
117
+ let t19;
118
+ if ($[13] !== T1 || $[14] !== t18) {
119
+ t19 = /* @__PURE__ */ jsx(T1, {
107
120
  value: t10,
108
- children: t16
121
+ children: t18
109
122
  });
110
- $[10] = T1;
111
- $[11] = t16;
112
- $[12] = t17;
113
- } else t17 = $[12];
114
- let t18;
115
- if ($[13] !== T0 || $[14] !== t17 || $[15] !== t2 || $[16] !== t4 || $[17] !== t5 || $[18] !== t7) {
116
- t18 = /* @__PURE__ */ jsx(T0, {
123
+ $[13] = T1;
124
+ $[14] = t18;
125
+ $[15] = t19;
126
+ } else t19 = $[15];
127
+ let t20;
128
+ if ($[16] !== T0 || $[17] !== t19 || $[18] !== t2 || $[19] !== t4 || $[20] !== t5 || $[21] !== t7) {
129
+ t20 = /* @__PURE__ */ jsx(T0, {
117
130
  animationType: t1,
118
131
  "aria-labelledby": t2,
119
132
  navigationBarTranslucent: t3,
@@ -123,17 +136,17 @@ function ModalWindow(t0) {
123
136
  supportedOrientations: t7,
124
137
  transparent: t8,
125
138
  visible: t9,
126
- children: t17
139
+ children: t19
127
140
  });
128
- $[13] = T0;
129
- $[14] = t17;
130
- $[15] = t2;
131
- $[16] = t4;
132
- $[17] = t5;
133
- $[18] = t7;
134
- $[19] = t18;
135
- } else t18 = $[19];
136
- return t18;
141
+ $[16] = T0;
142
+ $[17] = t19;
143
+ $[18] = t2;
144
+ $[19] = t4;
145
+ $[20] = t5;
146
+ $[21] = t7;
147
+ $[22] = t20;
148
+ } else t20 = $[22];
149
+ return t20;
137
150
  }
138
151
  function panelRoleOf(role, labelledBy) {
139
152
  if (Platform.OS === "web") return {};