@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.
- package/README.md +37 -0
- package/dist/badge/index.js +9 -68
- package/dist/badge/index.js.map +1 -1
- package/dist/button/index.d.ts +2 -1
- package/dist/button/index.js +1 -1
- package/dist/button/index.js.map +1 -1
- package/dist/button/palettes.d.ts +2 -0
- package/dist/button/pending.js +17 -21
- package/dist/button/pending.js.map +1 -1
- package/dist/calendar/index.js +1 -1
- package/dist/components/autocomplete/index.js +28 -26
- package/dist/components/autocomplete/index.js.map +1 -1
- package/dist/components/avatar/index.d.ts +2 -2
- package/dist/components/avatar/index.js +2 -2
- package/dist/components/avatar/index.js.map +1 -1
- package/dist/components/badge/index.d.ts +48 -0
- package/dist/components/badge/index.js +122 -0
- package/dist/components/badge/index.js.map +1 -0
- package/dist/{badge → components/badge}/styles.js +10 -6
- package/dist/components/badge/styles.js.map +1 -0
- package/dist/components/breadcrumbs/index.d.ts +66 -0
- package/dist/components/breadcrumbs/index.js +285 -0
- package/dist/components/breadcrumbs/index.js.map +1 -0
- package/dist/components/calendar/index.d.ts +1 -1
- package/dist/components/calendar/index.js +77 -38
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/checkbox/index.d.ts +7 -1
- package/dist/components/checkbox/index.js +183 -138
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/checkbox-group/index.d.ts +93 -0
- package/dist/components/checkbox-group/index.js +306 -0
- package/dist/components/checkbox-group/index.js.map +1 -0
- package/dist/components/chip-group/index.d.ts +4 -3
- package/dist/components/chip-group/index.js +47 -45
- package/dist/components/chip-group/index.js.map +1 -1
- package/dist/components/code/index.d.ts +25 -0
- package/dist/components/code/index.js +87 -0
- package/dist/components/code/index.js.map +1 -0
- package/dist/components/container/index.d.ts +47 -0
- package/dist/components/container/index.js +85 -0
- package/dist/components/container/index.js.map +1 -0
- package/dist/components/copy-field/index.d.ts +5 -5
- package/dist/components/copy-field/index.js +30 -28
- package/dist/components/copy-field/index.js.map +1 -1
- package/dist/components/currency/index.d.ts +2 -2
- package/dist/components/currency/index.js +3 -1
- package/dist/components/currency/index.js.map +1 -1
- package/dist/components/fab/index.d.ts +80 -0
- package/dist/components/fab/index.js +231 -0
- package/dist/components/fab/index.js.map +1 -0
- package/dist/components/fab-menu/index.d.ts +120 -0
- package/dist/components/fab-menu/index.js +640 -0
- package/dist/components/fab-menu/index.js.map +1 -0
- package/dist/components/feed/index.d.ts +57 -0
- package/dist/components/feed/index.js +167 -0
- package/dist/components/feed/index.js.map +1 -0
- package/dist/components/keycap/index.d.ts +27 -0
- package/dist/components/keycap/index.js +136 -0
- package/dist/components/keycap/index.js.map +1 -0
- package/dist/components/list/index.d.ts +6 -5
- package/dist/components/list/index.js +97 -106
- package/dist/components/list/index.js.map +1 -1
- package/dist/components/menu/index.d.ts +4 -3
- package/dist/components/menu/index.js +33 -40
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/meter/index.d.ts +2 -1
- package/dist/components/meter/index.js +9 -7
- package/dist/components/meter/index.js.map +1 -1
- package/dist/components/number-field/index.d.ts +7 -3
- package/dist/components/number-field/index.js +214 -192
- 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 +2 -2
- package/dist/components/product-icon/index.js.map +1 -1
- package/dist/components/progress-indicator/index.d.ts +2 -1
- package/dist/components/progress-indicator/index.js +15 -13
- package/dist/components/progress-indicator/index.js.map +1 -1
- package/dist/components/search-field/index.d.ts +3 -3
- package/dist/components/search-field/index.js +105 -104
- package/dist/components/search-field/index.js.map +1 -1
- package/dist/components/separator/index.d.ts +3 -2
- package/dist/components/separator/index.js +29 -26
- package/dist/components/separator/index.js.map +1 -1
- package/dist/components/sheet/index.d.ts +2 -2
- package/dist/components/sheet/index.js +22 -26
- package/dist/components/sheet/index.js.map +1 -1
- package/dist/components/snackbar/index.d.ts +3 -3
- package/dist/components/snackbar/index.js +36 -34
- package/dist/components/snackbar/index.js.map +1 -1
- package/dist/components/supporting-pane/index.d.ts +44 -0
- package/dist/components/supporting-pane/index.js +109 -0
- package/dist/components/supporting-pane/index.js.map +1 -0
- package/dist/components/tag/index.d.ts +58 -0
- package/dist/components/tag/index.js +205 -0
- package/dist/components/tag/index.js.map +1 -0
- package/dist/components/text/index.d.ts +1 -1
- package/dist/components/text/index.js +49 -21
- package/dist/components/text/index.js.map +1 -1
- package/dist/components/text-area/index.d.ts +145 -0
- package/dist/components/text-area/index.js +231 -0
- package/dist/components/text-area/index.js.map +1 -0
- package/dist/components/text-field/index.d.ts +6 -3
- package/dist/components/text-field/index.js +3 -0
- package/dist/components/text-field/index.js.map +1 -1
- package/dist/components/toolbar/index.d.ts +53 -0
- package/dist/components/toolbar/index.js +185 -0
- package/dist/components/toolbar/index.js.map +1 -0
- package/dist/control/group.js +23 -0
- package/dist/control/group.js.map +1 -0
- package/dist/fab/index.d.ts +19 -0
- package/dist/fab/index.js +147 -0
- package/dist/fab/index.js.map +1 -0
- package/dist/field/index.js +123 -79
- package/dist/field/index.js.map +1 -1
- package/dist/field/styles.js +18 -0
- package/dist/field/styles.js.map +1 -1
- package/dist/form/index.d.ts +1 -2
- package/dist/form/index.js +1 -1
- package/dist/form/index.js.map +1 -1
- package/dist/i18n/index.js +12 -1
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.js +367 -0
- package/dist/i18n/messages.js.map +1 -1
- package/dist/i18n/provider.d.ts +53 -0
- package/dist/i18n/provider.js +96 -0
- package/dist/i18n/provider.js.map +1 -0
- package/dist/index.d.ts +19 -4
- package/dist/index.js +17 -3
- package/dist/indicator/index.js +1 -2
- package/dist/indicator/index.js.map +1 -1
- package/dist/mark/index.js +77 -117
- package/dist/mark/index.js.map +1 -1
- package/dist/mark/initials.js.map +1 -1
- package/dist/modal/index.js +59 -46
- package/dist/modal/index.js.map +1 -1
- package/dist/navigation/index.js +8 -5
- package/dist/navigation/index.js.map +1 -1
- package/dist/number/count.js +15 -0
- package/dist/number/count.js.map +1 -0
- package/dist/number/locale.js.map +1 -1
- package/dist/overlay/host.js +30 -21
- package/dist/overlay/host.js.map +1 -1
- package/dist/overlay/placement.js +3 -1
- package/dist/overlay/placement.js.map +1 -1
- package/dist/separator/index.js +7 -0
- package/dist/separator/index.js.map +1 -0
- package/dist/typography/size.js +14 -0
- package/dist/typography/size.js.map +1 -0
- package/package.json +1 -1
- package/dist/badge/styles.js.map +0 -1
package/dist/modal/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ReactNode","GestureResponderEvent","HostInstance","ModalProps","ViewProps","ViewStyle","AnimatedStyle","EdgeInsets","OverlayTriggerState","useCallback","useEffect","useMemo","useRef","useState","AccessibilityInfo","I18nManager","Modal","Platform","StyleSheet","useOverlayTriggerState","ButtonSlots","ResolvedTheme","AnimatedPressable","ButtonSlotContext","OverlayHost","withOpacity","useTheme","composeStyles","themedStyles","NO_INSETS","bottom","left","right","top","ORIENTATIONS","SCRIM_OPACITY","stylesOf","colors","create","scrim","backgroundColor","position","ModalOpenProps","defaultOpen","isOpen","onOpenChange","ModalTrigger","state","trigger","ModalWindowProps","children","isKeyboardDismissDisabled","labelledBy","onClose","onScrimPress","title","focusOf","OS","sendAccessibilityEvent","ignore","insetsOf","insets","rtl","isRTL","paddingBottom","paddingEnd","paddingStart","paddingTop","ModalWindow","t0","$","_c","styles","T0","t1","t2","undefined","t3","t4","t5","t6","t8","t9","T1","t10","T2","T3","t11","t12","t13","t14","t15","t16","t17","t18","t7","panelRoleOf","role","Pick","registerOf","setParts","update","parts","Readonly","Record","Part","part","useModalState","outer","props","own","present","setPresent","close","slots","useReturnFocus","useModalTrigger","setTrigger","context","default","event","target","currentTarget","open","shown","gone","current","_c"],"sources":["../../src/modal/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type {\n GestureResponderEvent,\n HostInstance,\n ModalProps,\n ViewProps,\n ViewStyle,\n} from 'react-native'\nimport type { AnimatedStyle } from 'react-native-reanimated'\nimport type { EdgeInsets } from 'react-native-safe-area-context'\nimport type { OverlayTriggerState } from 'react-stately/useOverlayTriggerState'\n\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport {\n AccessibilityInfo,\n I18nManager,\n Modal,\n Platform,\n StyleSheet,\n} from 'react-native'\nimport { useOverlayTriggerState } from 'react-stately/useOverlayTriggerState'\n\nimport type { ButtonSlots } from '../button/slots'\nimport type { ResolvedTheme } from '../theme/scope'\n\nimport { AnimatedPressable } from '../button'\nimport { ButtonSlotContext } from '../button/slots'\nimport { OverlayHost } from '../overlay'\nimport { withOpacity } from '../theme/color'\nimport { useTheme } from '../theme/scope'\nimport { composeStyles, themedStyles } from '../theme/styles'\n\n// The window a modal surface is drawn in, and what a dialog and a sheet share\n// around it: the trigger that opens it, the open state, the scrim, and where\n// focus goes as it shows and once it has gone. Internal: nothing here is\n// exported from the package.\n//\n// **It is a React Native `Modal`**, which keeps React context, so the surface\n// keeps the `ThemeScope` around it, and which is a window of its own on iOS\n// and Android, above the screen and its overlays. The window therefore hosts\n// overlays of its own, so a snackbar or a popover raised from inside it draws\n// above it rather than under it.\n\n// Outside a SafeAreaProvider the insets are unknown, and the window's own edge\n// is the best bound there is.\nconst NO_INSETS: EdgeInsets = { bottom: 0, left: 0, right: 0, top: 0 }\n\n// iOS presents a `Modal` in portrait alone unless told otherwise, which would\n// turn an app held sideways round as the surface opened.\nconst ORIENTATIONS: ModalProps['supportedOrientations'] = [\n 'portrait',\n 'portrait-upside-down',\n 'landscape',\n 'landscape-left',\n 'landscape-right',\n]\n\n// The scrim is the scrim role at 32%, the opacity Material Design gives a\n// modal's scrim and web mixes in.\nconst SCRIM_OPACITY = 0.32\n\nconst stylesOf = themedStyles(({ colors }: ResolvedTheme) =>\n StyleSheet.create({\n scrim: {\n backgroundColor: withOpacity(colors.scrim, SCRIM_OPACITY),\n bottom: 0,\n left: 0,\n position: 'absolute',\n right: 0,\n top: 0,\n },\n }),\n)\n\n/** Whether a modal surface is open, and who holds that state. */\ntype ModalOpenProps = {\n readonly defaultOpen?: boolean\n readonly isOpen?: boolean\n readonly onOpenChange?: (isOpen: boolean) => void\n}\n\n/**\n * What a surface's trigger part hands its content: the open state, and the\n * button that last opened it, for focus to return to.\n */\ntype ModalTrigger = {\n readonly state: OverlayTriggerState\n readonly trigger: HostInstance | null\n}\n\ntype ModalWindowProps = {\n readonly children?: ReactNode\n /** Whether Android's back gesture and Escape on web leave it open. */\n readonly isKeyboardDismissDisabled: boolean\n /** The headline's id, which names the window on web. */\n readonly labelledBy: string | undefined\n /** What the back gesture and Escape call. */\n readonly onClose: () => void\n /** What a press on the scrim calls, or nothing where it closes nothing. */\n readonly onScrimPress: (() => void) | undefined\n /** The scrim's motion. */\n readonly scrim: AnimatedStyle<ViewStyle>\n /** The headline, which a screen reader is sent to once the window shows. */\n readonly title: HostInstance | null\n}\n\n// Sends the screen reader to the headline once the window has shown. React\n// Native Web's `Modal` moves focus into itself.\nfunction focusOf(title: HostInstance | null) {\n return () => {\n if (title !== null && Platform.OS !== 'web') {\n AccessibilityInfo.sendAccessibilityEvent(title, 'focus')\n }\n }\n}\n\n// What the back gesture does on a surface it may not close: nothing, rather\n// than leaving the handler out, which Android warns about.\nfunction ignore() {}\n\n// The safe area as padding. The insets are physical edges, and React Native\n// swaps a left and a right style under a right-to-left layout, so they are\n// handed over as the start and end they are in the direction the layout runs.\nfunction insetsOf(insets: EdgeInsets): ViewStyle {\n const rtl = I18nManager.isRTL\n\n return {\n paddingBottom: insets.bottom,\n paddingEnd: rtl ? insets.left : insets.right,\n paddingStart: rtl ? insets.right : insets.left,\n paddingTop: insets.top,\n }\n}\n\n/**\n * The window a modal surface is drawn in: the `Modal`, the overlays it hosts,\n * and the scrim, with the surface itself as its children.\n */\nfunction ModalWindow({\n children,\n isKeyboardDismissDisabled,\n labelledBy,\n onClose,\n onScrimPress,\n scrim,\n title,\n}: ModalWindowProps) {\n const styles = stylesOf(useTheme())\n\n return (\n <Modal\n animationType=\"none\"\n aria-labelledby={Platform.OS === 'web' ? labelledBy : undefined}\n navigationBarTranslucent\n onRequestClose={isKeyboardDismissDisabled ? ignore : onClose}\n onShow={focusOf(title)}\n statusBarTranslucent\n supportedOrientations={ORIENTATIONS}\n transparent\n visible\n >\n {/* Nothing in the window takes the trigger's slot, the overlays it\n hosts included, so a button in a snackbar raised from the surface\n opens nothing; only the surface's buttons take the close slot. */}\n <ButtonSlotContext value={null}>\n <OverlayHost>\n {/* A screen reader and a keyboard skip the scrim: the first closes\n the surface with the back or escape gesture, the second with\n Escape. React Native Web's Pressable is a tab stop unless told\n otherwise, whatever `focusable` says. */}\n <AnimatedPressable\n accessible={false}\n aria-hidden\n focusable={false}\n onPress={onScrimPress}\n style={composeStyles<AnimatedStyle<ViewStyle>>(styles.scrim, scrim)}\n tabIndex={-1}\n />\n {children}\n </OverlayHost>\n </ButtonSlotContext>\n </Modal>\n )\n}\n\n// The surface's role and name on iOS and Android. On web React Native Web's\n// `Modal` is the dialog element, so the surface takes neither there.\nfunction panelRoleOf(\n role: 'alertdialog' | 'dialog',\n labelledBy: string | undefined,\n): Pick<ViewProps, 'aria-labelledby' | 'aria-modal' | 'role'> {\n if (Platform.OS === 'web') {\n return {}\n }\n\n return { 'aria-labelledby': labelledBy, 'aria-modal': true, role }\n}\n\n// Counts each part as it mounts and unmounts, so the parts around it know\n// which of them are there.\nfunction registerOf<Part extends string>(\n setParts: (\n update: (\n parts: Readonly<Record<Part, number>>,\n ) => Readonly<Record<Part, number>>,\n ) => void,\n) {\n return (part: Part) => {\n setParts((parts) => ({ ...parts, [part]: parts[part] + 1 }))\n\n return () => {\n setParts((parts) => ({ ...parts, [part]: parts[part] - 1 }))\n }\n }\n}\n\n/**\n * The open state a surface's content part reads: its trigger's, inside one,\n * and its own otherwise. `present` stays true from the moment it opens until\n * the call site's exit has run and set it false, and the close slot and the\n * scrim close it through `close`.\n */\nfunction useModalState(outer: ModalTrigger | null, props: ModalOpenProps) {\n const own = useOverlayTriggerState(props)\n const state = outer?.state ?? own\n const [present, setPresent] = useState(state.isOpen)\n const close = useCallback(() => {\n state.close()\n }, [state])\n const slots = useMemo<ButtonSlots>(() => ({ close }), [close])\n\n // Mounted the moment it opens, and kept until its exit has run.\n if (state.isOpen && !present) {\n setPresent(true)\n }\n\n useReturnFocus(present, outer)\n\n return { close, present, setPresent, slots, state }\n}\n\n/**\n * The open state a surface's trigger part holds, and the default slot a\n * button inside it fills: it records itself as the button focus returns to,\n * and opens the surface. React Native types the target as a bare view tag\n * too, which focus cannot be sent to, so such a press records nothing.\n */\nfunction useModalTrigger(props: ModalOpenProps) {\n const state = useOverlayTriggerState(props)\n const [trigger, setTrigger] = useState<HostInstance | null>(null)\n const context = useMemo<ModalTrigger>(\n () => ({ state, trigger }),\n [state, trigger],\n )\n const slots = useMemo<ButtonSlots>(\n () => ({\n default: (event: GestureResponderEvent) => {\n const target = event.currentTarget\n\n setTrigger(typeof target === 'number' ? null : target)\n state.open()\n },\n }),\n [state],\n )\n\n return { context, slots }\n}\n\n// Sends the screen reader back to the button that opened the surface once it\n// has gone. React Native Web's `Modal` restores focus itself.\nfunction useReturnFocus(present: boolean, outer: ModalTrigger | null) {\n const shown = useRef(present)\n\n useEffect(() => {\n const trigger = outer?.trigger ?? null\n const gone = shown.current && !present\n\n shown.current = present\n if (gone && trigger !== null && Platform.OS !== 'web') {\n AccessibilityInfo.sendAccessibilityEvent(trigger, 'focus')\n }\n }, [outer, present])\n}\n\nexport {\n insetsOf,\n ModalWindow,\n NO_INSETS,\n panelRoleOf,\n registerOf,\n useModalState,\n useModalTrigger,\n}\nexport type { ModalOpenProps, ModalTrigger }\n"],"mappings":";;;;;;;;;;;;AA6CA,MAAM6B,YAAwB;CAAEC,QAAQ;CAAGC,MAAM;CAAGC,OAAO;CAAGC,KAAK;AAAE;AAIrE,MAAMC,eAAoD;CACxD;CACA;CACA;CACA;CACA;AA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C;EAAA5C,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAAlBK;AAAkB;AAK3B,SAAAwC,eAAAJ,SAAAH,OAAA;CAAA,MAAAtC,IAAAC,EAAA,CAAA;CACE,MAAAqD,QAAchH,OAAOmG,OAAO;CAAC,IAAA1C;CAAA,IAAAC,EAAA,OAAAsC,OAAA5D,WAAAsB,EAAA,OAAAyC,SAAA;EAEnB1C,WAAA;GACR,MAAArB,UAAgB4D,OAAK5D,WAAL;GAChB,MAAA6E,OAAaD,MAAKE,WAAL,CAAkBf;GAE/Ba,MAAKE,UAAWf;GAChB,IAAIc,QAAQ7E,YAAY,QAAQ/B,SAAQwC,OAAQ,OAC9C3C,kBAAiB4C,uBAAwBV,SAAS,OAAO;EAC1D;EACFsB,EAAA,KAAAsC,OAAA5D;EAAAsB,EAAA,KAAAyC;EAAAzC,EAAA,KAAAD;CAAA,OAAAA,KAAAC,EAAA;CAAA,IAAAI;CAAA,IAAAJ,EAAA,OAAAsC,SAAAtC,EAAA,OAAAyC,SAAA;EAAErC,KAAA,CAACkC,OAAOG,OAAO;EAACzC,EAAA,KAAAsC;EAAAtC,EAAA,KAAAyC;EAAAzC,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CARnB5D,UAAU2D,IAQPK,EAAgB;AAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["ReactNode","GestureResponderEvent","HostInstance","ModalProps","ViewProps","ViewStyle","AnimatedStyle","EdgeInsets","OverlayTriggerState","useCallback","useEffect","useMemo","useRef","useState","AccessibilityInfo","I18nManager","Modal","Platform","StyleSheet","useOverlayTriggerState","ButtonSlots","ResolvedTheme","AnimatedPressable","ButtonSlotContext","OverlayHost","SeparatorOrientationContext","withOpacity","useTheme","composeStyles","themedStyles","NO_INSETS","bottom","left","right","top","ORIENTATIONS","SCRIM_OPACITY","stylesOf","colors","create","scrim","backgroundColor","position","ModalOpenProps","defaultOpen","isOpen","onOpenChange","ModalTrigger","state","trigger","ModalWindowProps","children","isKeyboardDismissDisabled","labelledBy","onClose","onScrimPress","title","focusOf","OS","sendAccessibilityEvent","ignore","insetsOf","insets","rtl","isRTL","paddingBottom","paddingEnd","paddingStart","paddingTop","ModalWindow","t0","$","_c","styles","T0","t1","t2","undefined","t3","t4","t5","t6","t8","t9","T1","t10","T2","t11","T3","T4","t12","t13","t14","t15","t16","t17","t18","t19","t20","t7","panelRoleOf","role","Pick","registerOf","setParts","update","parts","Readonly","Record","Part","part","useModalState","outer","props","own","present","setPresent","close","slots","useReturnFocus","useModalTrigger","setTrigger","context","default","event","target","currentTarget","open","shown","gone","current","_c"],"sources":["../../src/modal/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type {\n GestureResponderEvent,\n HostInstance,\n ModalProps,\n ViewProps,\n ViewStyle,\n} from 'react-native'\nimport type { AnimatedStyle } from 'react-native-reanimated'\nimport type { EdgeInsets } from 'react-native-safe-area-context'\nimport type { OverlayTriggerState } from 'react-stately/useOverlayTriggerState'\n\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport {\n AccessibilityInfo,\n I18nManager,\n Modal,\n Platform,\n StyleSheet,\n} from 'react-native'\nimport { useOverlayTriggerState } from 'react-stately/useOverlayTriggerState'\n\nimport type { ButtonSlots } from '../button/slots'\nimport type { ResolvedTheme } from '../theme/scope'\n\nimport { AnimatedPressable } from '../button'\nimport { ButtonSlotContext } from '../button/slots'\nimport { OverlayHost } from '../overlay'\nimport { SeparatorOrientationContext } from '../separator'\nimport { withOpacity } from '../theme/color'\nimport { useTheme } from '../theme/scope'\nimport { composeStyles, themedStyles } from '../theme/styles'\n\n// The window a modal surface is drawn in, and what a dialog and a sheet share\n// around it: the trigger that opens it, the open state, the scrim, and where\n// focus goes as it shows and once it has gone. Internal: nothing here is\n// exported from the package.\n//\n// **It is a React Native `Modal`**, which keeps React context, so the surface\n// keeps the `ThemeScope` around it, and which is a window of its own on iOS\n// and Android, above the screen and its overlays. The window therefore hosts\n// overlays of its own, so a snackbar or a popover raised from inside it draws\n// above it rather than under it.\n\n// Outside a SafeAreaProvider the insets are unknown, and the window's own edge\n// is the best bound there is.\nconst NO_INSETS: EdgeInsets = { bottom: 0, left: 0, right: 0, top: 0 }\n\n// iOS presents a `Modal` in portrait alone unless told otherwise, which would\n// turn an app held sideways round as the surface opened.\nconst ORIENTATIONS: ModalProps['supportedOrientations'] = [\n 'portrait',\n 'portrait-upside-down',\n 'landscape',\n 'landscape-left',\n 'landscape-right',\n]\n\n// The scrim is the scrim role at 32%, the opacity Material Design gives a\n// modal's scrim and web mixes in.\nconst SCRIM_OPACITY = 0.32\n\nconst stylesOf = themedStyles(({ colors }: ResolvedTheme) =>\n StyleSheet.create({\n scrim: {\n backgroundColor: withOpacity(colors.scrim, SCRIM_OPACITY),\n bottom: 0,\n left: 0,\n position: 'absolute',\n right: 0,\n top: 0,\n },\n }),\n)\n\n/** Whether a modal surface is open, and who holds that state. */\ntype ModalOpenProps = {\n readonly defaultOpen?: boolean\n readonly isOpen?: boolean\n readonly onOpenChange?: (isOpen: boolean) => void\n}\n\n/**\n * What a surface's trigger part hands its content: the open state, and the\n * button that last opened it, for focus to return to.\n */\ntype ModalTrigger = {\n readonly state: OverlayTriggerState\n readonly trigger: HostInstance | null\n}\n\ntype ModalWindowProps = {\n readonly children?: ReactNode\n /** Whether Android's back gesture and Escape on web leave it open. */\n readonly isKeyboardDismissDisabled: boolean\n /** The headline's id, which names the window on web. */\n readonly labelledBy: string | undefined\n /** What the back gesture and Escape call. */\n readonly onClose: () => void\n /** What a press on the scrim calls, or nothing where it closes nothing. */\n readonly onScrimPress: (() => void) | undefined\n /** The scrim's motion. */\n readonly scrim: AnimatedStyle<ViewStyle>\n /** The headline, which a screen reader is sent to once the window shows. */\n readonly title: HostInstance | null\n}\n\n// Sends the screen reader to the headline once the window has shown. React\n// Native Web's `Modal` moves focus into itself.\nfunction focusOf(title: HostInstance | null) {\n return () => {\n if (title !== null && Platform.OS !== 'web') {\n AccessibilityInfo.sendAccessibilityEvent(title, 'focus')\n }\n }\n}\n\n// What the back gesture does on a surface it may not close: nothing, rather\n// than leaving the handler out, which Android warns about.\nfunction ignore() {}\n\n// The safe area as padding. The insets are physical edges, and React Native\n// swaps a left and a right style under a right-to-left layout, so they are\n// handed over as the start and end they are in the direction the layout runs.\nfunction insetsOf(insets: EdgeInsets): ViewStyle {\n const rtl = I18nManager.isRTL\n\n return {\n paddingBottom: insets.bottom,\n paddingEnd: rtl ? insets.left : insets.right,\n paddingStart: rtl ? insets.right : insets.left,\n paddingTop: insets.top,\n }\n}\n\n/**\n * The window a modal surface is drawn in: the `Modal`, the overlays it hosts,\n * and the scrim, with the surface itself as its children.\n */\nfunction ModalWindow({\n children,\n isKeyboardDismissDisabled,\n labelledBy,\n onClose,\n onScrimPress,\n scrim,\n title,\n}: ModalWindowProps) {\n const styles = stylesOf(useTheme())\n\n return (\n <Modal\n animationType=\"none\"\n aria-labelledby={Platform.OS === 'web' ? labelledBy : undefined}\n navigationBarTranslucent\n onRequestClose={isKeyboardDismissDisabled ? ignore : onClose}\n onShow={focusOf(title)}\n statusBarTranslucent\n supportedOrientations={ORIENTATIONS}\n transparent\n visible\n >\n {/* Nothing in the window takes the trigger's slot, the overlays it\n hosts included, so a button in a snackbar raised from the surface\n opens nothing; only the surface's buttons take the close slot. Nor\n does a rule in it run the way the toolbar that opened it set. */}\n <ButtonSlotContext value={null}>\n <SeparatorOrientationContext value={null}>\n <OverlayHost>\n {/* A screen reader and a keyboard skip the scrim: the first closes\n the surface with the back or escape gesture, the second with\n Escape. React Native Web's Pressable is a tab stop unless told\n otherwise, whatever `focusable` says. */}\n <AnimatedPressable\n accessible={false}\n aria-hidden\n focusable={false}\n onPress={onScrimPress}\n style={composeStyles<AnimatedStyle<ViewStyle>>(\n styles.scrim,\n scrim,\n )}\n tabIndex={-1}\n />\n {children}\n </OverlayHost>\n </SeparatorOrientationContext>\n </ButtonSlotContext>\n </Modal>\n )\n}\n\n// The surface's role and name on iOS and Android. On web React Native Web's\n// `Modal` is the dialog element, so the surface takes neither there.\nfunction panelRoleOf(\n role: 'alertdialog' | 'dialog',\n labelledBy: string | undefined,\n): Pick<ViewProps, 'aria-labelledby' | 'aria-modal' | 'role'> {\n if (Platform.OS === 'web') {\n return {}\n }\n\n return { 'aria-labelledby': labelledBy, 'aria-modal': true, role }\n}\n\n// Counts each part as it mounts and unmounts, so the parts around it know\n// which of them are there.\nfunction registerOf<Part extends string>(\n setParts: (\n update: (\n parts: Readonly<Record<Part, number>>,\n ) => Readonly<Record<Part, number>>,\n ) => void,\n) {\n return (part: Part) => {\n setParts((parts) => ({ ...parts, [part]: parts[part] + 1 }))\n\n return () => {\n setParts((parts) => ({ ...parts, [part]: parts[part] - 1 }))\n }\n }\n}\n\n/**\n * The open state a surface's content part reads: its trigger's, inside one,\n * and its own otherwise. `present` stays true from the moment it opens until\n * the call site's exit has run and set it false, and the close slot and the\n * scrim close it through `close`.\n */\nfunction useModalState(outer: ModalTrigger | null, props: ModalOpenProps) {\n const own = useOverlayTriggerState(props)\n const state = outer?.state ?? own\n const [present, setPresent] = useState(state.isOpen)\n const close = useCallback(() => {\n state.close()\n }, [state])\n const slots = useMemo<ButtonSlots>(() => ({ close }), [close])\n\n // Mounted the moment it opens, and kept until its exit has run.\n if (state.isOpen && !present) {\n setPresent(true)\n }\n\n useReturnFocus(present, outer)\n\n return { close, present, setPresent, slots, state }\n}\n\n/**\n * The open state a surface's trigger part holds, and the default slot a\n * button inside it fills: it records itself as the button focus returns to,\n * and opens the surface. React Native types the target as a bare view tag\n * too, which focus cannot be sent to, so such a press records nothing.\n */\nfunction useModalTrigger(props: ModalOpenProps) {\n const state = useOverlayTriggerState(props)\n const [trigger, setTrigger] = useState<HostInstance | null>(null)\n const context = useMemo<ModalTrigger>(\n () => ({ state, trigger }),\n [state, trigger],\n )\n const slots = useMemo<ButtonSlots>(\n () => ({\n default: (event: GestureResponderEvent) => {\n const target = event.currentTarget\n\n setTrigger(typeof target === 'number' ? null : target)\n state.open()\n },\n }),\n [state],\n )\n\n return { context, slots }\n}\n\n// Sends the screen reader back to the button that opened the surface once it\n// has gone. React Native Web's `Modal` restores focus itself.\nfunction useReturnFocus(present: boolean, outer: ModalTrigger | null) {\n const shown = useRef(present)\n\n useEffect(() => {\n const trigger = outer?.trigger ?? null\n const gone = shown.current && !present\n\n shown.current = present\n if (gone && trigger !== null && Platform.OS !== 'web') {\n AccessibilityInfo.sendAccessibilityEvent(trigger, 'focus')\n }\n }, [outer, present])\n}\n\nexport {\n insetsOf,\n ModalWindow,\n NO_INSETS,\n panelRoleOf,\n registerOf,\n useModalState,\n useModalTrigger,\n}\nexport type { ModalOpenProps, ModalTrigger }\n"],"mappings":";;;;;;;;;;;;;AA8CA,MAAM8B,YAAwB;CAAEC,QAAQ;CAAGC,MAAM;CAAGC,OAAO;CAAGC,KAAK;AAAE;AAIrE,MAAMC,eAAoD;CACxD;CACA;CACA;CACA;CACA;AAAiB;AAKnB,MAAMC,gBAAgB;AAEtB,MAAMC,WAAWR,cAAc,EAAES,aAC/BpB,WAAWqB,OAAO,EAChBC,OAAO;CACLC,iBAAiBf,YAAYY,OAAOE,OAAOJ,aAAa;CACxDL,QAAQ;CACRC,MAAM;CACNU,UAAU;CACVT,OAAO;CACPC,KAAK;AACP,EACF,CAAC,CACH;AAoCA,SAASuB,QAAQD,OAA4B;CAC3C,aAAa;EACX,IAAIA,UAAU,QAAQvC,SAASyC,OAAO,OACpC5C,kBAAkB6C,uBAAuBH,OAAO,OAAO;CAE3D;AACF;AAIA,SAASI,SAAS,CAAC;AAKnB,SAASC,SAASC,QAA+B;CAC/C,MAAMC,MAAMhD,YAAYiD;CAExB,OAAO;EACLC,eAAeH,OAAO/B;EACtBmC,YAAYH,MAAMD,OAAO9B,OAAO8B,OAAO7B;EACvCkC,cAAcJ,MAAMD,OAAO7B,QAAQ6B,OAAO9B;EAC1CoC,YAAYN,OAAO5B;CACrB;AACF;;;;;AAMA,SAAAmC,YAAAC,IA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E/Ba,MAAKE,UAAWf;GAChB,IAAIc,QAAQhF,YAAY,QAAQhC,SAAQyC,OAAQ,OAC9C5C,kBAAiB6C,uBAAwBV,SAAS,OAAO;EAC1D;EACFsB,EAAA,KAAAyC,OAAA/D;EAAAsB,EAAA,KAAA4C;EAAA5C,EAAA,KAAAD;CAAA,OAAAA,KAAAC,EAAA;CAAA,IAAAI;CAAA,IAAAJ,EAAA,OAAAyC,SAAAzC,EAAA,OAAA4C,SAAA;EAAExC,KAAA,CAACqC,OAAOG,OAAO;EAAC5C,EAAA,KAAAyC;EAAAzC,EAAA,KAAA4C;EAAA5C,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CARnB7D,UAAU4D,IAQPK,EAAgB;AAAC"}
|
package/dist/navigation/index.js
CHANGED
|
@@ -4,8 +4,9 @@ import { composeStyles } from "../theme/styles.js";
|
|
|
4
4
|
import { hitSlop, usePressFeedback } from "../press/index.js";
|
|
5
5
|
import { useTypeRole } from "../typography/roles.js";
|
|
6
6
|
import { withOpacity } from "../theme/color.js";
|
|
7
|
+
import { BadgeInFlowContext } from "../badge/index.js";
|
|
8
|
+
import { Badge } from "../components/badge/index.js";
|
|
7
9
|
import { useLinkPress } from "../router/index.js";
|
|
8
|
-
import { Badge } from "../badge/index.js";
|
|
9
10
|
import { INDICATOR, styles, stylesOf } from "./styles.js";
|
|
10
11
|
import { c } from "react/compiler-runtime";
|
|
11
12
|
import { Pressable, Text, View } from "react-native";
|
|
@@ -123,10 +124,12 @@ function DestinationContent(t0) {
|
|
|
123
124
|
} else t2 = $[9];
|
|
124
125
|
let t3;
|
|
125
126
|
if ($[10] !== badge || $[11] !== beside || $[12] !== icon) {
|
|
126
|
-
t3 = badge === void 0 || badge === false ? icon : /* @__PURE__ */ jsx(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
t3 = badge === void 0 || badge === false ? icon : /* @__PURE__ */ jsx(BadgeInFlowContext, {
|
|
128
|
+
value: beside,
|
|
129
|
+
children: /* @__PURE__ */ jsx(Badge, {
|
|
130
|
+
count: badge === true ? void 0 : badge,
|
|
131
|
+
children: icon
|
|
132
|
+
})
|
|
130
133
|
});
|
|
131
134
|
$[10] = badge;
|
|
132
135
|
$[11] = beside;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ComponentRef","ReactNode","Ref","ColorValue","PressableProps","StyleProp","TextStyle","ViewStyle","AnimatedStyle","createContext","use","useEffect","Text","NativeText","Pressable","View","Animated","Easing","useAnimatedStyle","useReducedMotion","useSharedValue","withTiming","IconStyle","ResolvedTheme","Badge","IconStyleContext","hitSlop","usePressFeedback","useLinkPress","withOpacity","useTheme","composeStyles","useTypeRole","INDICATOR","PILL_HEIGHT","styles","stylesOf","NavigationContextValue","form","NavigationForm","measuring","selectedRoute","NavigationDestinationProps","Omit","badge","children","icon","isDisabled","ref","style","NavigationItemProps","href","GROWN_FROM","FADE_SHARE","ICON_SIZE","BESIDE","Readonly","Record","collapsed","expanded","horizontal","vertical","NavigationContext","ActiveIndicator","t0","$","_c","selected","theme","colors","motion","reduceMotion","progress","t1","t2","target","set","duration","durationLong2","easing","bezier","easingEmphasized","motionStyle","grown","get","opacity","Math","min","transform","scaleX","t3","secondaryContainer","fill","pill","backgroundColor","t4","DestinationContent","label","beside","iconStyleOf","iconColorOf","undefined","t5","stateLayerOpacity","onSurface","disabledContent","onSecondaryContainer","onSurfaceVariant","color","size","Label","role","labelColorOf","secondary","nameOf","NavigationDestination","ariaLabel","onBlur","onFocus","onHoverIn","onHoverOut","onPressIn","onPressOut","props","own","feedback","area","corners","disabled","content","handlers","ring","layer","T0","t6","t7","T1","t8","indicator","t9","t10","t11","NavigationItem","onPress","press","_c","NativeText"],"sources":["../../src/navigation/index.tsx"],"sourcesContent":["import type { ComponentRef, ReactNode, Ref } from 'react'\nimport type {\n ColorValue,\n PressableProps,\n StyleProp,\n TextStyle,\n ViewStyle,\n} from 'react-native'\nimport type { AnimatedStyle } from 'react-native-reanimated'\n\nimport { createContext, use, useEffect } from 'react'\nimport { Text as NativeText, Pressable, View } from 'react-native'\nimport Animated, {\n Easing,\n useAnimatedStyle,\n useReducedMotion,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated'\n\nimport type { IconStyle } from '../glyphs/icon-style'\nimport type { ResolvedTheme } from '../theme/scope'\n\nimport { Badge } from '../badge'\nimport { IconStyleContext } from '../glyphs/icon-style'\nimport { hitSlop, usePressFeedback } from '../press'\nimport { useLinkPress } from '../router'\nimport { withOpacity } from '../theme/color'\nimport { useTheme } from '../theme/scope'\nimport { composeStyles } from '../theme/styles'\nimport { useTypeRole } from '../typography/roles'\nimport { INDICATOR, PILL_HEIGHT, styles, stylesOf } from './styles'\n\n// The destination NavigationBar and NavigationRail both draw, in the four\n// forms their pages give it, as kanso-ui's src/navigation draws it. Apart\n// from either component, so the two cannot drift.\n//\n// A vertical destination puts its icon in the page's 56dp by 32dp active\n// indicator with the label 4dp under it, in label medium: the bar in a\n// compact window, sharing its width with the others, and the collapsed rail,\n// as wide as the rail. A horizontal one is a pill holding the icon and the\n// label side by side, 16dp in at either end: the bar from the medium window\n// size class at 40dp with 4dp between the two in label medium, and the\n// expanded rail at 56dp with 8dp between them in label large. Which form a\n// destination draws is its bar's or its rail's to say, through the context\n// it hands them.\n//\n// The current destination's indicator is the secondary container, with its\n// icon in on secondary container and, under the indicator, its label in\n// secondary; every other is on surface variant. A label set inside the pill,\n// as a horizontal destination sets it, takes on secondary container instead,\n// as on web: secondary over secondary container is not a pair a scheme is\n// held to, and on secondary container is.\n//\n// **The indicator grows** when its destination becomes current, and shrinks\n// back when another does: from 40% of its width to the whole of it from its\n// centre over `durationLong2` on the emphasized curve, fading in over the\n// first fifth of that, as Material's Android components draw it. Web draws it\n// at once. Under reduced motion it does here too.\n//\n// The state layer, the ripple and the focus ring are src/press's, in on\n// secondary container, drawn on the pill: the indicator in a vertical\n// destination, which its ripple grows from the centre of wherever it is\n// pressed, and the whole destination in a horizontal one. The bar's 40dp\n// pill's press reaches 4dp above and below it, to the 48dp target; a\n// vertical destination is the bar's full height already, and the other two\n// forms are 56dp and 64dp tall. A disabled one draws its icon\n// and label on surface at the disabled content opacity, with no layer.\n//\n// A destination is a `tab`, reporting whether it is the selected one, and is\n// named by its label, or by `aria-label` where that is given: the badge on\n// its icon is hidden from a screen reader, so what it says belongs there.\n//\n// **The label comes first in the tree and is drawn after the icon**, through\n// a reversed column or row, so the text inside a destination starts with its\n// name. A badge's count is text, hidden from a screen reader but still\n// written inside the destination under React Native Web, and first in the\n// tree it put the count ahead of the name: a destination named \"Second item,\n// 3 new\" read \"3 Second item\", which is not what a speech-input user would\n// say, and is what axe's label-in-name check fails. src/badge sets the count\n// apart from the label with a space for the same reason.\n\n/** What a bar hands each of its destinations. */\ntype NavigationContextValue = {\n readonly form: NavigationForm\n /**\n * Whether the destinations are being drawn off screen to measure the\n * horizontal form, which draws each one's content and nothing else.\n */\n readonly measuring: boolean\n /** The route of the current destination, matched against an `href`. */\n readonly selectedRoute?: string | undefined\n}\n\ntype NavigationDestinationProps = Omit<\n PressableProps,\n 'children' | 'disabled' | 'style'\n> & {\n /**\n * A badge on the icon: `true` for the badges page's small dot, a number\n * for the large badge holding it. The badge is hidden from a screen\n * reader, so say what it says in the destination's `aria-label` too:\n * \"First item, 3 new\".\n */\n readonly badge?: boolean | number | undefined\n /** The destination's name, drawn as its label. */\n readonly children?: ReactNode\n /**\n * The destination's icon, at the page's 24dp, which the destination hands\n * its colour and size through `useIconStyle()`.\n */\n readonly icon?: ReactNode\n /**\n * Draws the destination disabled, and it takes no press.\n * @default false\n */\n readonly isDisabled?: boolean\n readonly ref?: Ref<ComponentRef<typeof View>>\n readonly style?: StyleProp<ViewStyle>\n}\n\n/**\n * Which form a destination draws: the bar's `vertical` and `horizontal`,\n * and the rail's `collapsed` and `expanded`. The label is under the icon in\n * the first and the third, and beside it in the other two.\n */\ntype NavigationForm = 'collapsed' | 'expanded' | 'horizontal' | 'vertical'\n\ntype NavigationItemProps = NavigationDestinationProps & {\n /**\n * Where the destination goes, through the app's router, and what the\n * `selectedRoute` around it is matched against.\n */\n readonly href: string\n}\n\n// The indicator's width when it starts to grow, as a share of its whole\n// width, and the share of the move it fades in over.\nconst GROWN_FROM = 0.4\nconst FADE_SHARE = 0.2\n\nconst ICON_SIZE = 24\n\n// Whether a form sets the label beside the icon rather than under it.\nconst BESIDE: Readonly<Record<NavigationForm, boolean>> = {\n collapsed: false,\n expanded: true,\n horizontal: true,\n vertical: false,\n}\n\nconst NavigationContext = createContext<NavigationContextValue>({\n form: 'vertical',\n measuring: false,\n})\n\n/**\n * The active indicator's fill, which grows from its centre while its\n * destination is current and shrinks back once it is not.\n */\nfunction ActiveIndicator({ selected }: { readonly selected: boolean }) {\n const theme = useTheme()\n const { colors, motion } = theme\n const reduceMotion = useReducedMotion()\n const progress = useSharedValue(selected ? 1 : 0)\n\n useEffect(() => {\n const target = selected ? 1 : 0\n\n progress.set(\n reduceMotion\n ? target\n : withTiming(target, {\n duration: motion.durationLong2,\n easing: Easing.bezier(...motion.easingEmphasized),\n }),\n )\n }, [motion, progress, reduceMotion, selected])\n\n const motionStyle = useAnimatedStyle(() => {\n 'worklet'\n const grown = progress.get()\n\n return {\n opacity: Math.min(1, grown / FADE_SHARE),\n transform: [{ scaleX: GROWN_FROM + (1 - GROWN_FROM) * grown }],\n }\n })\n\n return (\n <Animated.View\n style={composeStyles<AnimatedStyle<ViewStyle>>(\n styles.fill,\n stylesOf(theme).pill,\n { backgroundColor: colors.secondaryContainer },\n motionStyle,\n )}\n />\n )\n}\n\n/**\n * What a destination draws over its indicator: the icon and its badge, and\n * where the label is beside the icon the label before them in the tree,\n * which the pill's reversed row draws after them.\n */\nfunction DestinationContent({\n badge,\n form,\n icon,\n isDisabled,\n label,\n selected,\n}: {\n readonly badge: boolean | number | undefined\n readonly form: NavigationForm\n readonly icon: ReactNode\n readonly isDisabled: boolean\n readonly label: ReactNode\n readonly selected: boolean\n}) {\n const theme = useTheme()\n const beside = BESIDE[form]\n\n return (\n <>\n {beside ? (\n <Label form={form} isDisabled={isDisabled} selected={selected}>\n {label}\n </Label>\n ) : null}\n <View style={styles.icon}>\n <IconStyleContext\n value={iconStyleOf(iconColorOf(theme, isDisabled, selected))}\n >\n {badge === undefined || badge === false ? (\n icon\n ) : (\n <Badge count={badge === true ? undefined : badge} inFlow={beside}>\n {icon}\n </Badge>\n )}\n </IconStyleContext>\n </View>\n </>\n )\n}\n\n/** The colour a destination draws its icon in. */\nfunction iconColorOf(\n { colors, stateLayerOpacity }: ResolvedTheme,\n isDisabled: boolean,\n selected: boolean,\n): string {\n if (isDisabled) {\n return withOpacity(colors.onSurface, stateLayerOpacity.disabledContent)\n }\n return selected ? colors.onSecondaryContainer : colors.onSurfaceVariant\n}\n\n// Built by a call rather than written inline at the prop, which is what\n// react-perf's jsx-no-new-object-as-prop is after; the React Compiler\n// memoises the result on its inputs.\nfunction iconStyleOf(color: ColorValue): IconStyle {\n return { color, size: ICON_SIZE }\n}\n\n/**\n * A destination's label, on one line: in label large in an expanded rail,\n * and in label medium everywhere else.\n */\nfunction Label({\n children,\n form,\n isDisabled,\n selected,\n}: {\n readonly children: ReactNode\n readonly form: NavigationForm\n readonly isDisabled: boolean\n readonly selected: boolean\n}) {\n const theme = useTheme()\n const role = useTypeRole(form === 'expanded' ? 'labelLarge' : 'labelMedium')\n\n return (\n <NativeText\n numberOfLines={1}\n style={composeStyles<TextStyle>(role, styles.label, {\n color: labelColorOf(theme, form, isDisabled, selected),\n })}\n >\n {children}\n </NativeText>\n )\n}\n\n/** The colour a destination draws its label in, which its form decides. */\nfunction labelColorOf(\n theme: ResolvedTheme,\n form: NavigationForm,\n isDisabled: boolean,\n selected: boolean,\n): string {\n return selected && !isDisabled && !BESIDE[form]\n ? theme.colors.secondary\n : iconColorOf(theme, isDisabled, selected)\n}\n\n// A label that is a string names its destination; anything else leaves the\n// name to `aria-label`.\nfunction nameOf(children: ReactNode): string | undefined {\n return typeof children === 'string' ? children : undefined\n}\n\n/**\n * One destination, in the form the bar around it asks for: an icon and a\n * label, and the active indicator behind the icon while it is current. A\n * `tab` reporting whether it is selected.\n */\nfunction NavigationDestination({\n 'aria-label': ariaLabel,\n badge,\n children,\n icon,\n isDisabled = false,\n onBlur,\n onFocus,\n onHoverIn,\n onHoverOut,\n onPressIn,\n onPressOut,\n selected,\n style,\n ...props\n}: NavigationDestinationProps & { readonly selected: boolean }) {\n const theme = useTheme()\n const { form, measuring } = use(NavigationContext)\n const own = stylesOf(theme)\n const beside = BESIDE[form]\n const feedback = usePressFeedback({\n area: beside ? undefined : INDICATOR,\n color: theme.colors.onSecondaryContainer,\n corners: own.pill,\n disabled: isDisabled,\n onBlur,\n onFocus,\n onHoverIn,\n onHoverOut,\n onPressIn,\n onPressOut,\n })\n const content = (\n <DestinationContent\n badge={badge}\n form={form}\n icon={icon}\n isDisabled={isDisabled}\n label={children}\n selected={selected}\n />\n )\n\n if (measuring) {\n return <View style={own.horizontal}>{content}</View>\n }\n\n if (beside) {\n return (\n <Pressable\n aria-label={ariaLabel ?? nameOf(children)}\n aria-selected={selected}\n hitSlop={form === 'horizontal' ? hitSlop(PILL_HEIGHT) : undefined}\n role=\"tab\"\n {...props}\n {...feedback.handlers}\n disabled={isDisabled}\n style={composeStyles<ViewStyle>(own[form], feedback.ring, style)}\n >\n <ActiveIndicator selected={selected} />\n {feedback.layer}\n {content}\n </Pressable>\n )\n }\n\n return (\n <Pressable\n aria-label={ariaLabel ?? nameOf(children)}\n aria-selected={selected}\n role=\"tab\"\n {...props}\n {...feedback.handlers}\n disabled={isDisabled}\n style={composeStyles<ViewStyle>(own[form], style)}\n >\n <Label form={form} isDisabled={isDisabled} selected={selected}>\n {children}\n </Label>\n <View style={composeStyles<ViewStyle>(own.indicator, feedback.ring)}>\n <ActiveIndicator selected={selected} />\n {feedback.layer}\n {content}\n </View>\n </Pressable>\n )\n}\n\n/**\n * A destination that goes to its `href` through the app's router, selected\n * while the `selectedRoute` around it is that `href`: the item of a bar and\n * of a rail alike.\n */\nfunction NavigationItem({ href, onPress, ...props }: NavigationItemProps) {\n const { selectedRoute } = use(NavigationContext)\n const press = useLinkPress(href, onPress)\n\n return (\n <NavigationDestination\n {...props}\n onPress={press}\n selected={selectedRoute !== undefined && href === selectedRoute}\n />\n )\n}\n\nexport type {\n NavigationContextValue,\n NavigationDestinationProps,\n NavigationForm,\n NavigationItemProps,\n}\n\nexport {\n iconColorOf,\n labelColorOf,\n NavigationContext,\n NavigationDestination,\n NavigationItem,\n}\n"],"mappings":";;;;;;;;;;;;;;;AA0IA,MAAMoD,aAAa;AACnB,MAAMC,aAAa;AAEnB,MAAMC,YAAY;AAGlB,MAAMC,SAAoD;CACxDG,WAAW;CACXC,UAAU;CACVC,YAAY;CACZC,UAAU;AACZ;AAEA,MAAMC,oBAAoBrD,cAAsC;CAC9D6B,MAAM;CACNE,WAAW;AACb,CAAC;;;;;AAMD,SAAAuB,gBAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAyB,MAAA,EAAAC,aAAAH;CACvB,MAAAI,QAActC,SAAS;CACvB,MAAA,EAAAuC,QAAAC,WAA2BF;CAC3B,MAAAG,eAAqBpD,iBAAiB;CACtC,MAAAqD,WAAiBpD,eAAe+C,WAAA,IAAA,CAAgB;CAAC,IAAAM;CAAA,IAAAC;CAAA,IAAAT,EAAA,OAAAK,UAAAL,EAAA,OAAAO,YAAAP,EAAA,OAAAM,gBAAAN,EAAA,OAAAE,UAAA;EAEvCM,WAAA;GACR,MAAAE,SAAeR,WAAA,IAAA;GAEfK,SAAQI,IACNL,eAAAI,SAEItD,WAAWsD,QAAQ;IAAAE,UACPP,OAAMQ;IAAcC,QACtB9D,OAAM+D,OAAO,GAAIV,OAAMW,gBAAiB;GAClD,CAAC,CACP;EAAC;EACAP,KAAA;GAACJ;GAAQE;GAAUD;GAAcJ;EAAQ;EAACF,EAAA,KAAAK;EAAAL,EAAA,KAAAO;EAAAP,EAAA,KAAA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3E,EAAA,MAAAoE;EAAApE,EAAA,MAAA4D,SAAAK;EAAAjE,EAAA,MAAAlB;EAAAkB,EAAA,MAAA0D;EAAA1D,EAAA,MAAAE;EAAAF,EAAA,MAAA2E;EAAA3E,EAAA,MAAAyB;EAAAzB,EAAA,MAAAqE;EAAArE,EAAA,MAAAsE;EAAAtE,EAAA,MAAA4E;CAAA,OAAAA,MAAA5E,EAAA;CAAA,OAjBZ4E;AAiBY;;;;;;AAShB,SAAAC,eAAA9E,IAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAf;CAAA,IAAA4F;CAAA,IAAApB;CAAA,IAAA1D,EAAA,OAAAD,IAAA;EAAwB,CAAA,CAAAb,MAAA4F,SAAA,GAAApB,SAAA3D;EAAgDC,EAAA,KAAAD;EAAAC,EAAA,KAAAd;EAAAc,EAAA,KAAA8E;EAAA9E,EAAA,KAAA0D;CAAA,OAAA;EAAAxE,OAAAc,EAAA;EAAA8E,UAAA9E,EAAA;EAAA0D,QAAA1D,EAAA;CAAA;CACtE,MAAA,EAAAxB,kBAA0B/B,IAAIoD,iBAAiB;CAC/C,MAAAkF,QAAcpH,aAAauB,MAAM4F,OAAO;CAM1B,MAAAtE,KAAAhC,kBAAkB4D,KAAAA,KAAalD,SAASV;CAAa,IAAAiC;CAAA,IAAAT,EAAA,OAAA+E,SAAA/E,EAAA,OAAA0D,SAAA1D,EAAA,OAAAQ,IAAA;EAHjEC,KAAA,oBAAC,uBAAD;GAAsB,GAChBiD;GACKqB,SAAAA;GACC,UAAAvE;EAAqD,CAAA;EAC/DR,EAAA,KAAA+E;EAAA/E,EAAA,KAAA0D;EAAA1D,EAAA,KAAAQ;EAAAR,EAAA,KAAAS;CAAA,OAAAA,KAAAT,EAAA;CAAA,OAJFS;AAIE"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["ComponentRef","ReactNode","Ref","ColorValue","PressableProps","StyleProp","TextStyle","ViewStyle","AnimatedStyle","createContext","use","useEffect","Text","NativeText","Pressable","View","Animated","Easing","useAnimatedStyle","useReducedMotion","useSharedValue","withTiming","IconStyle","ResolvedTheme","BadgeInFlowContext","Badge","IconStyleContext","hitSlop","usePressFeedback","useLinkPress","withOpacity","useTheme","composeStyles","useTypeRole","INDICATOR","PILL_HEIGHT","styles","stylesOf","NavigationContextValue","form","NavigationForm","measuring","selectedRoute","NavigationDestinationProps","Omit","badge","children","icon","isDisabled","ref","style","NavigationItemProps","href","GROWN_FROM","FADE_SHARE","ICON_SIZE","BESIDE","Readonly","Record","collapsed","expanded","horizontal","vertical","NavigationContext","ActiveIndicator","t0","$","_c","selected","theme","colors","motion","reduceMotion","progress","t1","t2","target","set","duration","durationLong2","easing","bezier","easingEmphasized","motionStyle","grown","get","opacity","Math","min","transform","scaleX","t3","secondaryContainer","fill","pill","backgroundColor","t4","DestinationContent","label","beside","iconStyleOf","iconColorOf","undefined","t5","stateLayerOpacity","onSurface","disabledContent","onSecondaryContainer","onSurfaceVariant","color","size","Label","role","labelColorOf","secondary","nameOf","NavigationDestination","ariaLabel","onBlur","onFocus","onHoverIn","onHoverOut","onPressIn","onPressOut","props","own","feedback","area","corners","disabled","content","handlers","ring","layer","T0","t6","t7","T1","t8","indicator","t9","t10","t11","NavigationItem","onPress","press","_c","NativeText"],"sources":["../../src/navigation/index.tsx"],"sourcesContent":["import type { ComponentRef, ReactNode, Ref } from 'react'\nimport type {\n ColorValue,\n PressableProps,\n StyleProp,\n TextStyle,\n ViewStyle,\n} from 'react-native'\nimport type { AnimatedStyle } from 'react-native-reanimated'\n\nimport { createContext, use, useEffect } from 'react'\nimport { Text as NativeText, Pressable, View } from 'react-native'\nimport Animated, {\n Easing,\n useAnimatedStyle,\n useReducedMotion,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated'\n\nimport type { IconStyle } from '../glyphs/icon-style'\nimport type { ResolvedTheme } from '../theme/scope'\n\nimport { BadgeInFlowContext } from '../badge'\nimport { Badge } from '../components/badge'\nimport { IconStyleContext } from '../glyphs/icon-style'\nimport { hitSlop, usePressFeedback } from '../press'\nimport { useLinkPress } from '../router'\nimport { withOpacity } from '../theme/color'\nimport { useTheme } from '../theme/scope'\nimport { composeStyles } from '../theme/styles'\nimport { useTypeRole } from '../typography/roles'\nimport { INDICATOR, PILL_HEIGHT, styles, stylesOf } from './styles'\n\n// The destination NavigationBar and NavigationRail both draw, in the four\n// forms their pages give it, as kanso-ui's src/navigation draws it. Apart\n// from either component, so the two cannot drift.\n//\n// A vertical destination puts its icon in the page's 56dp by 32dp active\n// indicator with the label 4dp under it, in label medium: the bar in a\n// compact window, sharing its width with the others, and the collapsed rail,\n// as wide as the rail. A horizontal one is a pill holding the icon and the\n// label side by side, 16dp in at either end: the bar from the medium window\n// size class at 40dp with 4dp between the two in label medium, and the\n// expanded rail at 56dp with 8dp between them in label large. Which form a\n// destination draws is its bar's or its rail's to say, through the context\n// it hands them.\n//\n// The current destination's indicator is the secondary container, with its\n// icon in on secondary container and, under the indicator, its label in\n// secondary; every other is on surface variant. A label set inside the pill,\n// as a horizontal destination sets it, takes on secondary container instead,\n// as on web: secondary over secondary container is not a pair a scheme is\n// held to, and on secondary container is.\n//\n// **The indicator grows** when its destination becomes current, and shrinks\n// back when another does: from 40% of its width to the whole of it from its\n// centre over `durationLong2` on the emphasized curve, fading in over the\n// first fifth of that, as Material's Android components draw it. Web draws it\n// at once. Under reduced motion it does here too.\n//\n// The state layer, the ripple and the focus ring are src/press's, in on\n// secondary container, drawn on the pill: the indicator in a vertical\n// destination, which its ripple grows from the centre of wherever it is\n// pressed, and the whole destination in a horizontal one. The bar's 40dp\n// pill's press reaches 4dp above and below it, to the 48dp target; a\n// vertical destination is the bar's full height already, and the other two\n// forms are 56dp and 64dp tall. A disabled one draws its icon\n// and label on surface at the disabled content opacity, with no layer.\n//\n// A destination is a `tab`, reporting whether it is the selected one, and is\n// named by its label, or by `aria-label` where that is given: the badge on\n// its icon is hidden from a screen reader, so what it says belongs there.\n//\n// **The label comes first in the tree and is drawn after the icon**, through\n// a reversed column or row, so the text inside a destination starts with its\n// name. A badge's count is text, hidden from a screen reader but still\n// written inside the destination under React Native Web, and first in the\n// tree it put the count ahead of the name: a destination named \"Second item,\n// 3 new\" read \"3 Second item\", which is not what a speech-input user would\n// say, and is what axe's label-in-name check fails. src/badge sets the count\n// apart from the label with a space for the same reason.\n\n/** What a bar hands each of its destinations. */\ntype NavigationContextValue = {\n readonly form: NavigationForm\n /**\n * Whether the destinations are being drawn off screen to measure the\n * horizontal form, which draws each one's content and nothing else.\n */\n readonly measuring: boolean\n /** The route of the current destination, matched against an `href`. */\n readonly selectedRoute?: string | undefined\n}\n\ntype NavigationDestinationProps = Omit<\n PressableProps,\n 'children' | 'disabled' | 'style'\n> & {\n /**\n * A badge on the icon: `true` for the badges page's small dot, a number\n * for the large badge holding it. The badge is hidden from a screen\n * reader, so say what it says in the destination's `aria-label` too:\n * \"First item, 3 new\".\n */\n readonly badge?: boolean | number | undefined\n /** The destination's name, drawn as its label. */\n readonly children?: ReactNode\n /**\n * The destination's icon, at the page's 24dp, which the destination hands\n * its colour and size through `useIconStyle()`.\n */\n readonly icon?: ReactNode\n /**\n * Draws the destination disabled, and it takes no press.\n * @default false\n */\n readonly isDisabled?: boolean\n readonly ref?: Ref<ComponentRef<typeof View>>\n readonly style?: StyleProp<ViewStyle>\n}\n\n/**\n * Which form a destination draws: the bar's `vertical` and `horizontal`,\n * and the rail's `collapsed` and `expanded`. The label is under the icon in\n * the first and the third, and beside it in the other two.\n */\ntype NavigationForm = 'collapsed' | 'expanded' | 'horizontal' | 'vertical'\n\ntype NavigationItemProps = NavigationDestinationProps & {\n /**\n * Where the destination goes, through the app's router, and what the\n * `selectedRoute` around it is matched against.\n */\n readonly href: string\n}\n\n// The indicator's width when it starts to grow, as a share of its whole\n// width, and the share of the move it fades in over.\nconst GROWN_FROM = 0.4\nconst FADE_SHARE = 0.2\n\nconst ICON_SIZE = 24\n\n// Whether a form sets the label beside the icon rather than under it.\nconst BESIDE: Readonly<Record<NavigationForm, boolean>> = {\n collapsed: false,\n expanded: true,\n horizontal: true,\n vertical: false,\n}\n\nconst NavigationContext = createContext<NavigationContextValue>({\n form: 'vertical',\n measuring: false,\n})\n\n/**\n * The active indicator's fill, which grows from its centre while its\n * destination is current and shrinks back once it is not.\n */\nfunction ActiveIndicator({ selected }: { readonly selected: boolean }) {\n const theme = useTheme()\n const { colors, motion } = theme\n const reduceMotion = useReducedMotion()\n const progress = useSharedValue(selected ? 1 : 0)\n\n useEffect(() => {\n const target = selected ? 1 : 0\n\n progress.set(\n reduceMotion\n ? target\n : withTiming(target, {\n duration: motion.durationLong2,\n easing: Easing.bezier(...motion.easingEmphasized),\n }),\n )\n }, [motion, progress, reduceMotion, selected])\n\n const motionStyle = useAnimatedStyle(() => {\n 'worklet'\n const grown = progress.get()\n\n return {\n opacity: Math.min(1, grown / FADE_SHARE),\n transform: [{ scaleX: GROWN_FROM + (1 - GROWN_FROM) * grown }],\n }\n })\n\n return (\n <Animated.View\n style={composeStyles<AnimatedStyle<ViewStyle>>(\n styles.fill,\n stylesOf(theme).pill,\n { backgroundColor: colors.secondaryContainer },\n motionStyle,\n )}\n />\n )\n}\n\n/**\n * What a destination draws over its indicator: the icon and its badge, and\n * where the label is beside the icon the label before them in the tree,\n * which the pill's reversed row draws after them.\n */\nfunction DestinationContent({\n badge,\n form,\n icon,\n isDisabled,\n label,\n selected,\n}: {\n readonly badge: boolean | number | undefined\n readonly form: NavigationForm\n readonly icon: ReactNode\n readonly isDisabled: boolean\n readonly label: ReactNode\n readonly selected: boolean\n}) {\n const theme = useTheme()\n const beside = BESIDE[form]\n\n return (\n <>\n {beside ? (\n <Label form={form} isDisabled={isDisabled} selected={selected}>\n {label}\n </Label>\n ) : null}\n <View style={styles.icon}>\n <IconStyleContext\n value={iconStyleOf(iconColorOf(theme, isDisabled, selected))}\n >\n {badge === undefined || badge === false ? (\n icon\n ) : (\n <BadgeInFlowContext value={beside}>\n <Badge count={badge === true ? undefined : badge}>{icon}</Badge>\n </BadgeInFlowContext>\n )}\n </IconStyleContext>\n </View>\n </>\n )\n}\n\n/** The colour a destination draws its icon in. */\nfunction iconColorOf(\n { colors, stateLayerOpacity }: ResolvedTheme,\n isDisabled: boolean,\n selected: boolean,\n): string {\n if (isDisabled) {\n return withOpacity(colors.onSurface, stateLayerOpacity.disabledContent)\n }\n return selected ? colors.onSecondaryContainer : colors.onSurfaceVariant\n}\n\n// Built by a call rather than written inline at the prop, which is what\n// react-perf's jsx-no-new-object-as-prop is after; the React Compiler\n// memoises the result on its inputs.\nfunction iconStyleOf(color: ColorValue): IconStyle {\n return { color, size: ICON_SIZE }\n}\n\n/**\n * A destination's label, on one line: in label large in an expanded rail,\n * and in label medium everywhere else.\n */\nfunction Label({\n children,\n form,\n isDisabled,\n selected,\n}: {\n readonly children: ReactNode\n readonly form: NavigationForm\n readonly isDisabled: boolean\n readonly selected: boolean\n}) {\n const theme = useTheme()\n const role = useTypeRole(form === 'expanded' ? 'labelLarge' : 'labelMedium')\n\n return (\n <NativeText\n numberOfLines={1}\n style={composeStyles<TextStyle>(role, styles.label, {\n color: labelColorOf(theme, form, isDisabled, selected),\n })}\n >\n {children}\n </NativeText>\n )\n}\n\n/** The colour a destination draws its label in, which its form decides. */\nfunction labelColorOf(\n theme: ResolvedTheme,\n form: NavigationForm,\n isDisabled: boolean,\n selected: boolean,\n): string {\n return selected && !isDisabled && !BESIDE[form]\n ? theme.colors.secondary\n : iconColorOf(theme, isDisabled, selected)\n}\n\n// A label that is a string names its destination; anything else leaves the\n// name to `aria-label`.\nfunction nameOf(children: ReactNode): string | undefined {\n return typeof children === 'string' ? children : undefined\n}\n\n/**\n * One destination, in the form the bar around it asks for: an icon and a\n * label, and the active indicator behind the icon while it is current. A\n * `tab` reporting whether it is selected.\n */\nfunction NavigationDestination({\n 'aria-label': ariaLabel,\n badge,\n children,\n icon,\n isDisabled = false,\n onBlur,\n onFocus,\n onHoverIn,\n onHoverOut,\n onPressIn,\n onPressOut,\n selected,\n style,\n ...props\n}: NavigationDestinationProps & { readonly selected: boolean }) {\n const theme = useTheme()\n const { form, measuring } = use(NavigationContext)\n const own = stylesOf(theme)\n const beside = BESIDE[form]\n const feedback = usePressFeedback({\n area: beside ? undefined : INDICATOR,\n color: theme.colors.onSecondaryContainer,\n corners: own.pill,\n disabled: isDisabled,\n onBlur,\n onFocus,\n onHoverIn,\n onHoverOut,\n onPressIn,\n onPressOut,\n })\n const content = (\n <DestinationContent\n badge={badge}\n form={form}\n icon={icon}\n isDisabled={isDisabled}\n label={children}\n selected={selected}\n />\n )\n\n if (measuring) {\n return <View style={own.horizontal}>{content}</View>\n }\n\n if (beside) {\n return (\n <Pressable\n aria-label={ariaLabel ?? nameOf(children)}\n aria-selected={selected}\n hitSlop={form === 'horizontal' ? hitSlop(PILL_HEIGHT) : undefined}\n role=\"tab\"\n {...props}\n {...feedback.handlers}\n disabled={isDisabled}\n style={composeStyles<ViewStyle>(own[form], feedback.ring, style)}\n >\n <ActiveIndicator selected={selected} />\n {feedback.layer}\n {content}\n </Pressable>\n )\n }\n\n return (\n <Pressable\n aria-label={ariaLabel ?? nameOf(children)}\n aria-selected={selected}\n role=\"tab\"\n {...props}\n {...feedback.handlers}\n disabled={isDisabled}\n style={composeStyles<ViewStyle>(own[form], style)}\n >\n <Label form={form} isDisabled={isDisabled} selected={selected}>\n {children}\n </Label>\n <View style={composeStyles<ViewStyle>(own.indicator, feedback.ring)}>\n <ActiveIndicator selected={selected} />\n {feedback.layer}\n {content}\n </View>\n </Pressable>\n )\n}\n\n/**\n * A destination that goes to its `href` through the app's router, selected\n * while the `selectedRoute` around it is that `href`: the item of a bar and\n * of a rail alike.\n */\nfunction NavigationItem({ href, onPress, ...props }: NavigationItemProps) {\n const { selectedRoute } = use(NavigationContext)\n const press = useLinkPress(href, onPress)\n\n return (\n <NavigationDestination\n {...props}\n onPress={press}\n selected={selectedRoute !== undefined && href === selectedRoute}\n />\n )\n}\n\nexport type {\n NavigationContextValue,\n NavigationDestinationProps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,MAAAsE;EAAAtE,EAAA,MAAA4E;CAAA,OAAAA,MAAA5E,EAAA;CAAA,OAjBZ4E;AAiBY;;;;;;AAShB,SAAAC,eAAA9E,IAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAf;CAAA,IAAA4F;CAAA,IAAApB;CAAA,IAAA1D,EAAA,OAAAD,IAAA;EAAwB,CAAA,CAAAb,MAAA4F,SAAA,GAAApB,SAAA3D;EAAgDC,EAAA,KAAAD;EAAAC,EAAA,KAAAd;EAAAc,EAAA,KAAA8E;EAAA9E,EAAA,KAAA0D;CAAA,OAAA;EAAAxE,OAAAc,EAAA;EAAA8E,UAAA9E,EAAA;EAAA0D,QAAA1D,EAAA;CAAA;CACtE,MAAA,EAAAxB,kBAA0BhC,IAAIqD,iBAAiB;CAC/C,MAAAkF,QAAcpH,aAAauB,MAAM4F,OAAO;CAM1B,MAAAtE,KAAAhC,kBAAkB4D,KAAAA,KAAalD,SAASV;CAAa,IAAAiC;CAAA,IAAAT,EAAA,OAAA+E,SAAA/E,EAAA,OAAA0D,SAAA1D,EAAA,OAAAQ,IAAA;EAHjEC,KAAA,oBAAC,uBAAD;GAAsB,GAChBiD;GACKqB,SAAAA;GACC,UAAAvE;EAAqD,CAAA;EAC/DR,EAAA,KAAA+E;EAAA/E,EAAA,KAAA0D;EAAA1D,EAAA,KAAAQ;EAAAR,EAAA,KAAAS;CAAA,OAAAA,KAAAT,EAAA;CAAA,OAJFS;AAIE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/number/count.ts
|
|
2
|
+
const formats = /* @__PURE__ */ new Map();
|
|
3
|
+
/** A count in `locale`'s digits and grouping. */
|
|
4
|
+
function formatCount(count, locale) {
|
|
5
|
+
let format = formats.get(locale);
|
|
6
|
+
if (format === void 0) {
|
|
7
|
+
format = new Intl.NumberFormat(locale);
|
|
8
|
+
formats.set(locale, format);
|
|
9
|
+
}
|
|
10
|
+
return format.format(count);
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { formatCount };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=count.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"count.js","names":["formats","Map","Intl","NumberFormat","formatCount","count","locale","format","get","undefined","set"],"sources":["../../src/number/count.ts"],"sourcesContent":["// One plain formatter per locale, for the counts a badge and a field's counter\n// write, which change often enough that building a formatter on each would\n// show. The keys are the locales an app renders in, so the map settles at that\n// size.\nconst formats = new Map<string, Intl.NumberFormat>()\n\n/** A count in `locale`'s digits and grouping. */\nfunction formatCount(count: number, locale: string) {\n let format = formats.get(locale)\n\n if (format === undefined) {\n format = new Intl.NumberFormat(locale)\n formats.set(locale, format)\n }\n\n return format.format(count)\n}\n\nexport { formatCount }\n"],"mappings":";AAIA,MAAMA,0BAAU,IAAIC,IAA+B;;AAGnD,SAASG,YAAYC,OAAeC,QAAgB;CAClD,IAAIC,SAASP,QAAQQ,IAAIF,MAAM;CAE/B,IAAIC,WAAWE,KAAAA,GAAW;EACxBF,SAAS,IAAIL,KAAKC,aAAaG,MAAM;EACrCN,QAAQU,IAAIJ,QAAQC,MAAM;CAC5B;CAEA,OAAOA,OAAOA,OAAOF,KAAK;AAC5B"}
|
|
@@ -1 +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//
|
|
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// Which one is given is `useLocaleOf`'s in src/i18n/provider.tsx, the\n// component's own prop or the `I18nProvider`'s, as web reads the page's from\n// React Aria's provider.\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,4 +1,5 @@
|
|
|
1
1
|
import { ScopeContext, useScope } from "../theme/scope.js";
|
|
2
|
+
import { I18nProvider, useProvidedLocale } from "../i18n/provider.js";
|
|
2
3
|
import { c } from "react/compiler-runtime";
|
|
3
4
|
import { StyleSheet, View } from "react-native";
|
|
4
5
|
import { createContext, use, useId, useLayoutEffect, useState, useSyncExternalStore } from "react";
|
|
@@ -18,59 +19,67 @@ const styles = StyleSheet.create({ fill: {
|
|
|
18
19
|
* outermost `ThemeScope`, for as long as it is mounted. A later overlay draws
|
|
19
20
|
* above an earlier one.
|
|
20
21
|
*
|
|
21
|
-
* The content reads the `ThemeScope`
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
22
|
+
* The content reads the `ThemeScope` and the `I18nProvider` around the
|
|
23
|
+
* `Overlay`, as anything else there would, so a dialog writes in the locale
|
|
24
|
+
* of the screen that opened it, as web's portal does. Other context set
|
|
25
|
+
* between the host and the `Overlay` does not reach it: an overlay is a
|
|
26
|
+
* surface of its own, as web's `OverlayScope` makes one, so it starts from
|
|
27
|
+
* what is around the app rather than from what is around the control that
|
|
28
|
+
* opened it.
|
|
26
29
|
*/
|
|
27
30
|
function Overlay(t0) {
|
|
28
|
-
const $ = c(
|
|
31
|
+
const $ = c(11);
|
|
29
32
|
const { children } = t0;
|
|
30
33
|
const store = use(OverlayHostContext);
|
|
31
34
|
const scope = useScope();
|
|
35
|
+
const locale = useProvidedLocale();
|
|
32
36
|
const key = useId();
|
|
33
37
|
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
38
|
let t1;
|
|
35
39
|
let t2;
|
|
36
|
-
if ($[0] !== children || $[1] !== key || $[2] !==
|
|
40
|
+
if ($[0] !== children || $[1] !== key || $[2] !== locale || $[3] !== scope || $[4] !== store) {
|
|
37
41
|
t1 = () => {
|
|
38
42
|
store.set(key, /* @__PURE__ */ jsx(ScopeContext, {
|
|
39
43
|
value: scope,
|
|
40
|
-
children
|
|
44
|
+
children: /* @__PURE__ */ jsx(I18nProvider, {
|
|
45
|
+
locale,
|
|
46
|
+
children
|
|
47
|
+
})
|
|
41
48
|
}));
|
|
42
49
|
};
|
|
43
50
|
t2 = [
|
|
44
51
|
children,
|
|
45
52
|
key,
|
|
53
|
+
locale,
|
|
46
54
|
scope,
|
|
47
55
|
store
|
|
48
56
|
];
|
|
49
57
|
$[0] = children;
|
|
50
58
|
$[1] = key;
|
|
51
|
-
$[2] =
|
|
52
|
-
$[3] =
|
|
53
|
-
$[4] =
|
|
54
|
-
$[5] =
|
|
59
|
+
$[2] = locale;
|
|
60
|
+
$[3] = scope;
|
|
61
|
+
$[4] = store;
|
|
62
|
+
$[5] = t1;
|
|
63
|
+
$[6] = t2;
|
|
55
64
|
} else {
|
|
56
|
-
t1 = $[
|
|
57
|
-
t2 = $[
|
|
65
|
+
t1 = $[5];
|
|
66
|
+
t2 = $[6];
|
|
58
67
|
}
|
|
59
68
|
useLayoutEffect(t1, t2);
|
|
60
69
|
let t3;
|
|
61
70
|
let t4;
|
|
62
|
-
if ($[
|
|
71
|
+
if ($[7] !== key || $[8] !== store) {
|
|
63
72
|
t3 = () => () => {
|
|
64
73
|
store.remove(key);
|
|
65
74
|
};
|
|
66
75
|
t4 = [key, store];
|
|
67
|
-
$[
|
|
68
|
-
$[
|
|
69
|
-
$[
|
|
70
|
-
$[
|
|
76
|
+
$[7] = key;
|
|
77
|
+
$[8] = store;
|
|
78
|
+
$[9] = t3;
|
|
79
|
+
$[10] = t4;
|
|
71
80
|
} else {
|
|
72
|
-
t3 = $[
|
|
73
|
-
t4 = $[
|
|
81
|
+
t3 = $[9];
|
|
82
|
+
t4 = $[10];
|
|
74
83
|
}
|
|
75
84
|
useLayoutEffect(t3, t4);
|
|
76
85
|
return null;
|
package/dist/overlay/host.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 *
|
|
1
|
+
{"version":3,"file":"host.js","names":["ComponentRef","ReactNode","createContext","use","useId","useLayoutEffect","useState","useSyncExternalStore","StyleSheet","View","I18nProvider","useProvidedLocale","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","locale","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 { I18nProvider, useProvidedLocale } from '../i18n/provider'\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` and the `I18nProvider` around the\n * `Overlay`, as anything else there would, so a dialog writes in the locale\n * of the screen that opened it, as web's portal does. Other context set\n * between the host and the `Overlay` does not reach it: an overlay is a\n * surface of its own, as web's `OverlayScope` makes one, so it starts from\n * what is around the app rather than from what is around the control that\n * opened it.\n */\nfunction Overlay({ children }: { readonly children?: ReactNode }) {\n const store = use(OverlayHostContext)\n const scope = useScope()\n const locale = useProvidedLocale()\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(\n key,\n <ScopeContext value={scope}>\n <I18nProvider locale={locale}>{children}</I18nProvider>\n </ScopeContext>,\n )\n }, [children, key, locale, 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":";;;;;;;AA6BA,MAAMyB,qBAAqBvB,cAAmC,IAAI;AAElE,MAAMwB,SAASlB,WAAWmB,OAAO,EAI/BC,MAAM;CACJC,QAAQ;CACRC,MAAM;CACNC,eAAe;CACfC,UAAU;CACVC,OAAO;CACPC,KAAK;AACP,EACF,CAAC;;;;;;;;;;;;;;AAeD,SAAAC,QAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAiB,MAAA,EAAAC,aAAAH;CACf,MAAAI,QAAcrC,IAAIsB,kBAAkB;CACpC,MAAAgB,QAAc5B,SAAS;CACvB,MAAA6B,SAAe/B,kBAAkB;CACjC,MAAAI,MAAYX,MAAM;CAElB,IAAIoC,UAAU,MACZ,MAAM,IAAIG,MACR,qIACF;CACD,IAAAC;CAAA,IAAAC;CAAA,IAAAR,EAAA,OAAAE,YAA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K,MAAMQ,YAAY8B,WACrB9B,SAAS;CAEb;CAEA,OAAO;EACLN,SAASuC,SAAS;GAChBtC,QAAQsC;EACV;EACArC,eAAeA;EACfD,aAAaA;EACbE,SAASN,QAAQ;GACf,IAAIC,QAAQ0C,OAAO3C,GAAG,GACpByC,QAAQ;EAEZ;EACAlC,MAAMP,KAAK4C,SAAS;GAClB3C,QAAQM,IAAIP,KAAK4C,IAAI;GACrBH,QAAQ;EACV;EACAjC,YAAYC,aAAa;GACvB8B,UAAUM,IAAIpC,QAAQ;GACtB,aAAa;IACX8B,UAAUI,OAAOlC,QAAQ;GAC3B;EACF;CACF;AACF"}
|
|
@@ -28,7 +28,9 @@ function boundsOf(window, insets, padding) {
|
|
|
28
28
|
}
|
|
29
29
|
function edgeOf(align, inline, rtl) {
|
|
30
30
|
if (align === "center") return "center";
|
|
31
|
-
|
|
31
|
+
const fromRight = inline && rtl;
|
|
32
|
+
if (align === "start") return fromRight ? "far" : "near";
|
|
33
|
+
return fromRight ? "near" : "far";
|
|
32
34
|
}
|
|
33
35
|
function isVertical(side) {
|
|
34
36
|
return side === "bottom" || side === "top";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placement.js","names":["Edge","OverlayAlign","OverlaySide","Placement","maxHeight","side","x","y","PlacementInput","align","alignOffset","anchor","Rect","bounds","rtl","sideOffset","surface","Size","height","width","OPPOSITE","bottom","left","right","top","const","Record","along","start","length","size","edge","offset","lined","Math","min","max","boundsOf","window","insets","padding","edgeOf","inline","isVertical","place","preferred","room","on","spaceOn","opposite","within","position"],"sources":["../../src/overlay/placement.ts"],"sourcesContent":["// Which end of the anchor the surface lines up with, along the side.\ntype Edge = 'center' | 'far' | 'near'\n\n/** Where along that side it lines up with the anchor. */\ntype OverlayAlign = 'center' | 'end' | 'start'\n\n/** Which side of the anchor a surface opens on. */\ntype OverlaySide = 'bottom' | 'left' | 'right' | 'top'\n\n/** Where an anchored surface sits, in the coordinates its inputs were in. */\ntype Placement = {\n /**\n * The height the surface may take before it would pass the edge of the\n * bounds on the side it opened on. A surface taller than this scrolls.\n */\n readonly maxHeight: number\n /** The side it opened on, which is the opposite one after a flip. */\n readonly side: OverlaySide\n readonly x: number\n readonly y: number\n}\n\ntype PlacementInput = {\n readonly align: OverlayAlign\n /** Moves the surface along the side, in dp: right or down when positive. */\n readonly alignOffset: number\n readonly anchor: Rect\n /** The area the surface stays inside, padding already taken off. */\n readonly bounds: Rect\n /** Whether `start` and `end` read from the right, on `top` and `bottom`. */\n readonly rtl: boolean\n readonly side: OverlaySide\n /** The gap between the anchor and the surface, in dp. */\n readonly sideOffset: number\n readonly surface: Size\n}\n\ntype Rect = Size & { readonly x: number; readonly y: number }\n\ntype Size = { readonly height: number; readonly width: number }\n\nconst OPPOSITE = {\n bottom: 'top',\n left: 'right',\n right: 'left',\n top: 'bottom',\n} as const satisfies Record<OverlaySide, OverlaySide>\n\n/**\n * Where a surface of a given length starts along the anchor, for an edge,\n * moved by the offset. However far the offset moves it, it keeps overlapping\n * the anchor, as React Aria's placement does on web.\n */\nfunction along(\n start: number,\n length: number,\n size: number,\n edge: Edge,\n offset: number,\n) {\n const lined =\n edge === 'near'\n ? start\n : edge === 'far'\n ? start + length - size\n : start + (length - size) / 2\n\n return Math.min(Math.max(lined + offset, start - size), start + length)\n}\n\n/**\n * Bounds a surface stays inside: the window, less the safe area's insets and\n * a padding on every side.\n */\nfunction boundsOf(\n window: Size,\n insets: { bottom: number; left: number; right: number; top: number },\n padding: number,\n): Rect {\n return {\n height: window.height - insets.top - insets.bottom - padding * 2,\n width: window.width - insets.left - insets.right - padding * 2,\n x: insets.left + padding,\n y: insets.top + padding,\n }\n}\n\n// Which end of the anchor an alignment names. On `top` and `bottom` the\n// surface lines up along the inline axis, so `start` is the left edge, or the\n// right one in a right-to-left layout; on `left` and `right` it lines up along\n// the block axis, where `start` is the top edge in both.\nfunction edgeOf(align: OverlayAlign, inline: boolean, rtl: boolean): Edge {\n if (align === 'center') {\n return 'center'\n }\n\n
|
|
1
|
+
{"version":3,"file":"placement.js","names":["Edge","OverlayAlign","OverlaySide","Placement","maxHeight","side","x","y","PlacementInput","align","alignOffset","anchor","Rect","bounds","rtl","sideOffset","surface","Size","height","width","OPPOSITE","bottom","left","right","top","const","Record","along","start","length","size","edge","offset","lined","Math","min","max","boundsOf","window","insets","padding","edgeOf","inline","fromRight","isVertical","place","preferred","room","on","spaceOn","opposite","within","position"],"sources":["../../src/overlay/placement.ts"],"sourcesContent":["// Which end of the anchor the surface lines up with, along the side.\ntype Edge = 'center' | 'far' | 'near'\n\n/** Where along that side it lines up with the anchor. */\ntype OverlayAlign = 'center' | 'end' | 'start'\n\n/** Which side of the anchor a surface opens on. */\ntype OverlaySide = 'bottom' | 'left' | 'right' | 'top'\n\n/** Where an anchored surface sits, in the coordinates its inputs were in. */\ntype Placement = {\n /**\n * The height the surface may take before it would pass the edge of the\n * bounds on the side it opened on. A surface taller than this scrolls.\n */\n readonly maxHeight: number\n /** The side it opened on, which is the opposite one after a flip. */\n readonly side: OverlaySide\n readonly x: number\n readonly y: number\n}\n\ntype PlacementInput = {\n readonly align: OverlayAlign\n /** Moves the surface along the side, in dp: right or down when positive. */\n readonly alignOffset: number\n readonly anchor: Rect\n /** The area the surface stays inside, padding already taken off. */\n readonly bounds: Rect\n /** Whether `start` and `end` read from the right, on `top` and `bottom`. */\n readonly rtl: boolean\n readonly side: OverlaySide\n /** The gap between the anchor and the surface, in dp. */\n readonly sideOffset: number\n readonly surface: Size\n}\n\ntype Rect = Size & { readonly x: number; readonly y: number }\n\ntype Size = { readonly height: number; readonly width: number }\n\nconst OPPOSITE = {\n bottom: 'top',\n left: 'right',\n right: 'left',\n top: 'bottom',\n} as const satisfies Record<OverlaySide, OverlaySide>\n\n/**\n * Where a surface of a given length starts along the anchor, for an edge,\n * moved by the offset. However far the offset moves it, it keeps overlapping\n * the anchor, as React Aria's placement does on web.\n */\nfunction along(\n start: number,\n length: number,\n size: number,\n edge: Edge,\n offset: number,\n) {\n const lined =\n edge === 'near'\n ? start\n : edge === 'far'\n ? start + length - size\n : start + (length - size) / 2\n\n return Math.min(Math.max(lined + offset, start - size), start + length)\n}\n\n/**\n * Bounds a surface stays inside: the window, less the safe area's insets and\n * a padding on every side.\n */\nfunction boundsOf(\n window: Size,\n insets: { bottom: number; left: number; right: number; top: number },\n padding: number,\n): Rect {\n return {\n height: window.height - insets.top - insets.bottom - padding * 2,\n width: window.width - insets.left - insets.right - padding * 2,\n x: insets.left + padding,\n y: insets.top + padding,\n }\n}\n\n// Which end of the anchor an alignment names. On `top` and `bottom` the\n// surface lines up along the inline axis, so `start` is the left edge, or the\n// right one in a right-to-left layout; on `left` and `right` it lines up along\n// the block axis, where `start` is the top edge in both.\n//\n// `rtl` is read for its truth rather than compared with a boolean: it comes\n// from `I18nManager.isRTL`, which React Native Web leaves undefined, and an\n// equality with undefined put every `end` at the start there.\nfunction edgeOf(align: OverlayAlign, inline: boolean, rtl: boolean): Edge {\n if (align === 'center') {\n return 'center'\n }\n\n const fromRight = inline && rtl\n\n if (align === 'start') {\n return fromRight ? 'far' : 'near'\n }\n\n return fromRight ? 'near' : 'far'\n}\n\nfunction isVertical(side: OverlaySide) {\n return side === 'bottom' || side === 'top'\n}\n\n/**\n * Places a surface beside its anchor, as React Aria places a popover on web.\n *\n * It opens on `side`, lined up along it by `align`, and flips to the opposite\n * side when it does not fit and that side has more room. Along the side it is\n * shifted to stay inside the bounds; across it, on `top` and `bottom`, it\n * stays inside them through `maxHeight`, and on `left` and `right`, where a\n * surface wider than both sides has nowhere to go, it is shifted over the\n * anchor rather than past the edge.\n */\nfunction place({\n align,\n alignOffset,\n anchor,\n bounds,\n rtl,\n side: preferred,\n sideOffset,\n surface,\n}: PlacementInput): Placement {\n const room = (on: OverlaySide) => spaceOn(on, anchor, bounds, sideOffset)\n const opposite = OPPOSITE[preferred]\n const length = isVertical(preferred) ? surface.height : surface.width\n const side =\n length > room(preferred) && room(opposite) > room(preferred)\n ? opposite\n : preferred\n\n if (isVertical(side)) {\n const maxHeight = Math.max(0, room(side))\n const height = Math.min(surface.height, maxHeight)\n const x = along(\n anchor.x,\n anchor.width,\n surface.width,\n edgeOf(align, true, rtl),\n alignOffset,\n )\n\n return {\n maxHeight,\n side,\n x: within(x, bounds.x, bounds.width, surface.width),\n y:\n side === 'bottom'\n ? anchor.y + anchor.height + sideOffset\n : anchor.y - sideOffset - height,\n }\n }\n\n const maxHeight = Math.max(0, bounds.height)\n const height = Math.min(surface.height, maxHeight)\n const x =\n side === 'right'\n ? anchor.x + anchor.width + sideOffset\n : anchor.x - sideOffset - surface.width\n const y = along(\n anchor.y,\n anchor.height,\n height,\n edgeOf(align, false, rtl),\n alignOffset,\n )\n\n return {\n maxHeight,\n side,\n x: within(x, bounds.x, bounds.width, surface.width),\n y: within(y, bounds.y, bounds.height, height),\n }\n}\n\n// The room between the anchor and the edge of the bounds on a side, less the\n// gap the surface keeps from the anchor.\nfunction spaceOn(\n side: OverlaySide,\n anchor: Rect,\n bounds: Rect,\n sideOffset: number,\n) {\n const room = {\n bottom: bounds.y + bounds.height - anchor.y - anchor.height,\n left: anchor.x - bounds.x,\n right: bounds.x + bounds.width - anchor.x - anchor.width,\n top: anchor.y - bounds.y,\n }\n\n return room[side] - sideOffset\n}\n\n// Shifts a surface along an axis until it is inside the bounds, or, when it is\n// longer than they are, until it starts where they start.\nfunction within(position: number, start: number, length: number, size: number) {\n if (position < start) {\n return start\n }\n\n if (position + size > start + length) {\n return Math.max(start + length - size, start)\n }\n\n return position\n}\n\nexport type { OverlayAlign, OverlaySide, Placement, PlacementInput, Rect, Size }\n\nexport { boundsOf, place }\n"],"mappings":";AAyCA,MAAMoB,WAAW;CACfC,QAAQ;CACRC,MAAM;CACNC,OAAO;CACPC,KAAK;AACP;;;;;;AAOA,SAASG,MACPC,OACAC,QACAC,MACAC,MACAC,QACA;CACA,MAAMC,QACJF,SAAS,SACLH,QACAG,SAAS,QACPH,QAAQC,SAASC,OACjBF,SAASC,SAAS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SeparatorOrientationContext"],"sources":["../../src/separator/index.ts"],"sourcesContent":["import { createContext } from 'react'\n\n// Which way a Separator runs where its call site does not say, as React\n// Aria's separator context does on web. A Toolbar provides the direction\n// across its own, so a rule between two of its controls divides them rather\n// than running along the bar; a modal window clears it, so a rule in a\n// dialog, sheet or popover opened from the bar draws as it does anywhere\n// else. Null is no direction provided, and a Separator then runs\n// horizontally.\nconst SeparatorOrientationContext = createContext<\n 'horizontal' | 'vertical' | null\n>(null)\n\nexport { SeparatorOrientationContext }\n"],"mappings":";;AASA,MAAMC,8BAA8BD,cAElC,IAAI"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
//#region src/typography/size.ts
|
|
3
|
+
const TextSizeContext = createContext(void 0);
|
|
4
|
+
/**
|
|
5
|
+
* The font size of the library's Text around the caller, or `undefined` when
|
|
6
|
+
* the caller is not inside one.
|
|
7
|
+
*/
|
|
8
|
+
function useTextSize() {
|
|
9
|
+
return useContext(TextSizeContext);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { TextSizeContext, useTextSize };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=size.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"size.js","names":["createContext","useContext","TextSizeContext","undefined","useTextSize"],"sources":["../../src/typography/size.ts"],"sourcesContent":["import { createContext, useContext } from 'react'\n\n// The font size the Text around a caller draws in, once its role and its call\n// site's style have both applied, and `undefined` outside one. A native Text\n// nested in another takes the outer one's size without being able to read it,\n// and Code and Keycap set a share of that size, which takes the number.\nconst TextSizeContext = createContext<number | undefined>(undefined)\n\n/**\n * The font size of the library's Text around the caller, or `undefined` when\n * the caller is not inside one.\n */\nfunction useTextSize(): number | undefined {\n return useContext(TextSizeContext)\n}\n\nexport { TextSizeContext, useTextSize }\n"],"mappings":";;AAMA,MAAME,kBAAkBF,cAAkCG,KAAAA,CAAS;;;;;AAMnE,SAAAC,cAAA;CAAA,OACSH,WAAWC,eAAe;AAAC"}
|
package/package.json
CHANGED
package/dist/badge/styles.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","names":["StyleSheet","themedStyles","ICON_SIZE","OVERLAP","RISE","SMALL_SIZE","LARGE_SIZE","styles","create","anchor","alignItems","flexDirection","inFlow","marginStart","position","top","over","start","small","end","height","width","space","stylesOf","colors","radii","spacing","count","color","onError","fontVariant","large","justifyContent","minHeight","minWidth","paddingHorizontal","xs","mark","backgroundColor","error","borderRadius","pill","pointerEvents"],"sources":["../../src/badge/styles.ts"],"sourcesContent":["import { StyleSheet } from 'react-native'\n\nimport { themedStyles } from '../theme/styles'\n\n// The icon a badge is drawn on, which the large badge's corner is measured\n// from: the 24dp every destination draws.\nconst ICON_SIZE = 24\n\n// How far back over the icon the large badge reaches, from the icon's\n// trailing edge, and how far above the icon it stands. The page's own\n// figures: its bottom leading corner 14dp down and 12dp in from the icon's\n// top trailing corner, on a 16dp badge.\nconst OVERLAP = 12\nconst RISE = 2\n\n// The small badge's side, and the large badge's least height and width.\nconst SMALL_SIZE = 6\nconst LARGE_SIZE = 16\n\nconst styles = StyleSheet.create({\n // What the badge is drawn on. It shrinks to what it holds, so its box is\n // the icon's and the mark lands where the page puts it, and lays a mark\n // that joins the flow after the icon.\n anchor: {\n alignItems: 'flex-start',\n flexDirection: 'row',\n },\n // The large badge in the flow after the icon, 12dp back over it and 2dp\n // above it, which is where its own placement puts it, so what follows the\n // icon starts after the badge rather than under it.\n inFlow: {\n marginStart: -OVERLAP,\n position: 'relative',\n top: -RISE,\n },\n // The large badge over the icon's top trailing corner.\n over: {\n position: 'absolute',\n start: ICON_SIZE - OVERLAP,\n top: -RISE,\n },\n // The small badge, filling the icon's top trailing 6dp square.\n small: {\n end: 0,\n height: SMALL_SIZE,\n position: 'absolute',\n top: 0,\n width: SMALL_SIZE,\n },\n // The space before the count, out of the flow, so it sets the count apart\n // from the text before it without moving anything.\n space: {\n position: 'absolute',\n },\n})\n\nconst stylesOf = themedStyles(({ colors, radii, spacing }) =>\n StyleSheet.create({\n // The count, in label small with tabular figures, so a count that\n // changes does not change the badge's width digit by digit.\n count: {\n color: colors.onError,\n fontVariant: ['tabular-nums'],\n },\n // The page's large badge: at least 16dp tall and as wide, 4dp either\n // side of its count. A minimum rather than a size, so a larger text size\n // the device asks for grows the badge rather than cutting the count.\n large: {\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: LARGE_SIZE,\n minWidth: LARGE_SIZE,\n paddingHorizontal: spacing.xs,\n },\n // The fill and corner both badges share. It takes no touches, so a press\n // on it lands on what it is drawn on.\n mark: {\n backgroundColor: colors.error,\n borderRadius: radii.pill,\n pointerEvents: 'none',\n },\n }),\n)\n\nexport { styles, stylesOf }\n"],"mappings":";;;AAgBA,MAAMK,aAAa;AACnB,MAAMC,aAAa;AAEnB,MAAMC,SAASP,WAAWQ,OAAO;CAI/BC,QAAQ;EACNC,YAAY;EACZC,eAAe;CACjB;CAIAC,QAAQ;EACNC,aAAa;EACbC,UAAU;EACVC,KAAK;CACP;CAEAC,MAAM;EACJF,UAAU;EACVG,OAAOf;EACPa,KAAK;CACP;CAEAG,OAAO;EACLC,KAAK;EACLC,QAAQf;EACRS,UAAU;EACVC,KAAK;EACLM,OAAOhB;CACT;CAGAiB,OAAO,EACLR,UAAU,WACZ;AACF,CAAC;AAED,MAAMS,WAAWtB,cAAc,EAAEuB,QAAQC,OAAOC,cAC9C1B,WAAWQ,OAAO;CAGhBmB,OAAO;EACLC,OAAOJ,OAAOK;EACdC,aAAa,CAAC,cAAc;CAC9B;CAIAC,OAAO;EACLrB,YAAY;EACZsB,gBAAgB;EAChBC,WAAW3B;EACX4B,UAAU5B;EACV6B,mBAAmBT,QAAQU;CAC7B;CAGAC,MAAM;EACJC,iBAAiBd,OAAOe;EACxBC,cAAcf,MAAMgB;EACpBC,eAAe;CACjB;AACF,CAAC,CACH"}
|