@agimon-ai/po-native-components 0.0.0-alpha.157 → 0.0.0-alpha.159

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.
@@ -148,6 +148,7 @@ function SheetFrame({ open, onClose, onDismiss, children, scrollable = true, foo
148
148
  }, []);
149
149
  return /* @__PURE__ */ jsx(BottomSheetModal, {
150
150
  ref: sheet,
151
+ accessible: false,
151
152
  stackBehavior: "push",
152
153
  enablePanDownToClose: true,
153
154
  topInset: insets?.top ?? 0,
@@ -1 +1 @@
1
- {"version":3,"file":"SheetFrame.mjs","names":["dismissSheet","InsideSheetContext","OpenSheet","registerSheet","unregisterSheet","withAlpha","BottomSheetBackdrop","BottomSheetBackdropProps","BottomSheetModal","BottomSheetFooter","BottomSheetFooterProps","BottomSheetScrollView","ReactNode","useCallback","useContext","useEffect","useLayoutEffect","useMemo","useRef","useState","useSyncExternalStore","BackHandler","Keyboard","SafeAreaInsetsContext","StyleSheet","useUnistyles","fontOf","BACKDROP_ALPHA_PERCENT","SheetFrameProps","open","onClose","onDismiss","children","footer","scrollable","keep","sheetsYielded","yieldSheets","FooterHolder","get","set","subscribe","listener","footerHolder","initial","listeners","Set","next","add","delete","FooterBody","holder","SheetFrame","theme","insets","sheet","openRef","presented","dismissing","footerHeight","setFooterHeight","note","setNote","latest","current","entry","close","footers","undefined","dismiss","present","subscription","addEventListener","remove","backdropColor","colors","deep","renderBackdrop","props","style","backgroundColor","footerInset","bottom","renderFooter","event","nativeEvent","layout","height","paddingBottom","rail","backgroundStyle","borderRadius","lg","handleIndicatorStyle","border","onChange","index","onSheetDismiss","reopen","top","footerComponent","styles","content","SheetNote","create","flexGrow","marginHorizontal","spacing","marginBottom","color","magenta","fontFamily","sans","fontSize","sm","lineHeight","uni__dependencies"],"sources":["../../src/components/SheetFrame.tsx"],"sourcesContent":["import {\n dismissSheet,\n InsideSheetContext,\n type OpenSheet,\n registerSheet,\n unregisterSheet,\n} from '@agimon-ai/po-native-components/shell';\nimport { withAlpha } from '@agimon-ai/po-web-components/nativeTheme';\nimport {\n BottomSheetBackdrop,\n type BottomSheetBackdropProps,\n BottomSheetModal,\n BottomSheetFooter,\n type BottomSheetFooterProps,\n BottomSheetScrollView,\n} from '@gorhom/bottom-sheet';\nimport {\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from 'react';\nimport { BackHandler, Keyboard, Text, View } from 'react-native';\nimport { SafeAreaInsetsContext } from 'react-native-safe-area-context';\nimport { StyleSheet, useUnistyles } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\n\n/** `bg-po-deep/70`, the overlay every web sheet and dialog draws. */\nconst BACKDROP_ALPHA_PERCENT = 70;\n\nexport interface SheetFrameProps {\n open: boolean;\n /** The sheet asked to close: a drag down, a backdrop tap or Android back. */\n onClose: () => void;\n onDismiss?: () => void;\n children?: ReactNode;\n footer?: ReactNode;\n /** False when the content supplies its own Gorhom virtualized scroll owner. */\n scrollable?: boolean;\n /** The sheet holds work not yet saved, so a prompt arriving leaves it open with a note instead of closing it. */\n keep?: boolean;\n}\n\nexport { sheetsYielded, yieldSheets } from '@agimon-ai/po-native-components/shell';\n\n/** The latest footer, read by a footer component whose identity never changes while the sheet lives. */\ninterface FooterHolder {\n get: () => ReactNode;\n set: (footer: ReactNode) => void;\n subscribe: (listener: () => void) => () => void;\n}\n\nfunction footerHolder(initial: ReactNode): FooterHolder {\n let footer = initial;\n const listeners = new Set<() => void>();\n return {\n get: () => footer,\n set: (next) => {\n if (next === footer) return;\n footer = next;\n for (const listener of listeners) listener();\n },\n subscribe: (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n}\n\nfunction FooterBody({ holder }: { holder: FooterHolder }) {\n const footer = useSyncExternalStore(holder.subscribe, holder.get);\n return <InsideSheetContext.Provider value>{footer}</InsideSheetContext.Provider>;\n}\n\n/**\n * The bottom sheet both Sheet and DropdownMenu sit in: a drag handle, sized\n * to its content, closed by dragging down, tapping the backdrop or Android\n * back, clear of the safe area and lifted by the keyboard. Private: the public\n * parts keep bottom-sheet types out of the package API.\n */\nexport function SheetFrame({\n open,\n onClose,\n onDismiss,\n children,\n scrollable = true,\n footer,\n keep = false,\n}: SheetFrameProps) {\n const { theme } = useUnistyles();\n const insets = useContext(SafeAreaInsetsContext);\n const sheet = useRef<BottomSheetModal>(null);\n const openRef = useRef(open);\n const presented = useRef(false);\n const dismissing = useRef(false);\n const [footerHeight, setFooterHeight] = useState(0);\n const [note, setNote] = useState<string>();\n const latest = useRef({ keep, onClose, onDismiss });\n latest.current = { keep, onClose, onDismiss };\n const entry = useRef<OpenSheet>({\n keep: () => latest.current.keep,\n close: () => latest.current.onClose(),\n setNote,\n });\n // Gorhom takes the footer as a component; a new one each render would remount its fields mid-typing.\n const footers = useRef<FooterHolder>(undefined);\n footers.current ??= footerHolder(footer);\n const holder = footers.current;\n useLayoutEffect(() => holder.set(footer), [holder, footer]);\n\n useEffect(() => {\n openRef.current = open;\n if (open && !dismissing.current) {\n presented.current = true;\n registerSheet(entry.current);\n // The keyboard of the field behind would cover the sheet; a field inside it focuses after this.\n Keyboard.dismiss();\n sheet.current?.present();\n } else if (!open) {\n unregisterSheet(entry.current);\n setNote(undefined);\n if (presented.current && !dismissing.current) {\n // A new open waits for native dismissal, otherwise its callback closes the new request.\n dismissing.current = true;\n sheet.current?.dismiss();\n }\n }\n }, [open]);\n\n useEffect(\n () => () => {\n openRef.current = false;\n unregisterSheet(entry.current);\n dismissSheet?.(entry.current);\n },\n [],\n );\n\n useEffect(() => {\n if (!open) return undefined;\n const subscription = BackHandler.addEventListener('hardwareBackPress', () => {\n latest.current.onClose();\n return true;\n });\n return () => subscription.remove();\n }, [open]);\n\n const backdropColor = withAlpha(theme.colors.deep, BACKDROP_ALPHA_PERCENT);\n const renderBackdrop = useCallback(\n (props: BottomSheetBackdropProps) => (\n <BottomSheetBackdrop\n {...props}\n appearsOnIndex={0}\n disappearsOnIndex={-1}\n opacity={1}\n pressBehavior=\"close\"\n style={[props.style, { backgroundColor: backdropColor }]}\n />\n ),\n [backdropColor],\n );\n\n const footerInset = insets?.bottom ?? 0;\n const renderFooter = useCallback(\n (props: BottomSheetFooterProps) => (\n <BottomSheetFooter {...props}>\n <View\n onLayout={(event) => setFooterHeight(event.nativeEvent.layout.height)}\n style={{ paddingBottom: footerInset, backgroundColor: theme.colors.rail }}\n >\n <FooterBody holder={holder} />\n </View>\n </BottomSheetFooter>\n ),\n [holder, footerInset, theme.colors.rail],\n );\n const backgroundStyle = useMemo(\n () => ({ backgroundColor: theme.colors.rail, borderRadius: theme.borderRadius.lg }),\n [theme.colors.rail, theme.borderRadius.lg],\n );\n const handleIndicatorStyle = useMemo(() => ({ backgroundColor: theme.colors.border }), [theme.colors.border]);\n const onChange = useCallback((index: number) => {\n // present() mounts on the next frame, so an earlier dismiss() may have had nothing to close.\n if (index >= 0 && dismissing.current) sheet.current?.dismiss();\n }, []);\n // A sheet the caller closed is already shut; only a close the sheet started is reported.\n const onSheetDismiss = useCallback(() => {\n const reopen = dismissing.current && openRef.current;\n dismissing.current = false;\n presented.current = false;\n dismissSheet?.(entry.current);\n if (reopen) {\n presented.current = true;\n registerSheet(entry.current);\n sheet.current?.present();\n return;\n }\n if (openRef.current) latest.current.onClose();\n latest.current.onDismiss?.();\n }, []);\n\n return (\n <BottomSheetModal\n ref={sheet}\n stackBehavior=\"push\"\n enablePanDownToClose\n topInset={insets?.top ?? 0}\n keyboardBehavior=\"interactive\"\n keyboardBlurBehavior=\"restore\"\n android_keyboardInputMode=\"adjustResize\"\n backdropComponent={renderBackdrop}\n {...(footer === undefined ? {} : { footerComponent: renderFooter })}\n backgroundStyle={backgroundStyle}\n handleIndicatorStyle={handleIndicatorStyle}\n onChange={onChange}\n onDismiss={onSheetDismiss}\n >\n {scrollable ? (\n <BottomSheetScrollView\n keyboardShouldPersistTaps=\"handled\"\n contentContainerStyle={[\n styles.content,\n { paddingBottom: footer === undefined ? (insets?.bottom ?? 0) : footerHeight },\n ]}\n >\n {note ? <SheetNote note={note} /> : null}\n <InsideSheetContext.Provider value>{children}</InsideSheetContext.Provider>\n </BottomSheetScrollView>\n ) : (\n <>\n {note ? <SheetNote note={note} /> : null}\n <InsideSheetContext.Provider value>{children}</InsideSheetContext.Provider>\n </>\n )}\n </BottomSheetModal>\n );\n}\n\n/** A gentle rose line: the person is asked something below, never told to hurry. */\nfunction SheetNote({ note }: { note: string }) {\n return (\n <Text style={styles.note} accessibilityRole=\"alert\">\n {note}\n </Text>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n content: { flexGrow: 1 },\n note: {\n marginHorizontal: theme.spacing(4),\n marginBottom: theme.spacing(2),\n color: theme.colors.magenta,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n}));\n"],"mappings":";;;;;;;;;;;;;;AAkCA,MAAM2B,yBAAyB;AAwB/B,SAASgB,aAAaC,SAAkC;CACtD,IAAIX,SAASW;CACb,MAAMC,4BAAY,IAAIC,IAAgB;CACtC,OAAO;EACLP,WAAWN;EACXO,MAAMO,SAAS;GACb,IAAIA,SAASd,QAAQ;GACrBA,SAASc;GACT,KAAK,MAAML,YAAYG,WAAWH,SAAS;EAC7C;EACAD,YAAYC,aAAa;GACvBG,UAAUG,IAAIN,QAAQ;GACtB,aAAaG,UAAUI,OAAOP,QAAQ;EACxC;CACF;AACF;AAEA,SAASQ,WAAW,EAAEC,UAAoC;CACxD,MAAMlB,SAASb,qBAAqB+B,OAAOV,WAAWU,OAAOZ,GAAG;CAChE,OAAO,oBAAC,mBAAmB,UAApB;EAA6B;YAAON;CAAoC;AACjF;;;;;;;AAQA,SAAgBmB,WAAW,EACzBvB,MACAC,SACAC,WACAC,UACAE,aAAa,MACbD,QACAE,OAAO,SACW;CAClB,MAAM,EAAEkB,UAAU5B,aAAa;CAC/B,MAAM6B,SAASxC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,CAAC;EAC7BE,OAAOxD,MAAMsB,OAAOmC;EACpBC,YAAYrF,OAAO2B,MAAM0D,WAAWC,IAAI;EACxCC,UAAU5D,MAAM4D,SAASC;EACzBC,YAAY9D,MAAM8D,WAAWD;EAAEE,mBAAA,CAAA,CAAA;CACjC;AACF,EAAE"}
1
+ {"version":3,"file":"SheetFrame.mjs","names":["dismissSheet","InsideSheetContext","OpenSheet","registerSheet","unregisterSheet","withAlpha","BottomSheetBackdrop","BottomSheetBackdropProps","BottomSheetModal","BottomSheetFooter","BottomSheetFooterProps","BottomSheetScrollView","ReactNode","useCallback","useContext","useEffect","useLayoutEffect","useMemo","useRef","useState","useSyncExternalStore","BackHandler","Keyboard","SafeAreaInsetsContext","StyleSheet","useUnistyles","fontOf","BACKDROP_ALPHA_PERCENT","SheetFrameProps","open","onClose","onDismiss","children","footer","scrollable","keep","sheetsYielded","yieldSheets","FooterHolder","get","set","subscribe","listener","footerHolder","initial","listeners","Set","next","add","delete","FooterBody","holder","SheetFrame","theme","insets","sheet","openRef","presented","dismissing","footerHeight","setFooterHeight","note","setNote","latest","current","entry","close","footers","undefined","dismiss","present","subscription","addEventListener","remove","backdropColor","colors","deep","renderBackdrop","props","style","backgroundColor","footerInset","bottom","renderFooter","event","nativeEvent","layout","height","paddingBottom","rail","backgroundStyle","borderRadius","lg","handleIndicatorStyle","border","onChange","index","onSheetDismiss","reopen","top","footerComponent","styles","content","SheetNote","create","flexGrow","marginHorizontal","spacing","marginBottom","color","magenta","fontFamily","sans","fontSize","sm","lineHeight","uni__dependencies"],"sources":["../../src/components/SheetFrame.tsx"],"sourcesContent":["import {\n dismissSheet,\n InsideSheetContext,\n type OpenSheet,\n registerSheet,\n unregisterSheet,\n} from '@agimon-ai/po-native-components/shell';\nimport { withAlpha } from '@agimon-ai/po-web-components/nativeTheme';\nimport {\n BottomSheetBackdrop,\n type BottomSheetBackdropProps,\n BottomSheetModal,\n BottomSheetFooter,\n type BottomSheetFooterProps,\n BottomSheetScrollView,\n} from '@gorhom/bottom-sheet';\nimport {\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from 'react';\nimport { BackHandler, Keyboard, Text, View } from 'react-native';\nimport { SafeAreaInsetsContext } from 'react-native-safe-area-context';\nimport { StyleSheet, useUnistyles } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\n\n/** `bg-po-deep/70`, the overlay every web sheet and dialog draws. */\nconst BACKDROP_ALPHA_PERCENT = 70;\n\nexport interface SheetFrameProps {\n open: boolean;\n /** The sheet asked to close: a drag down, a backdrop tap or Android back. */\n onClose: () => void;\n onDismiss?: () => void;\n children?: ReactNode;\n footer?: ReactNode;\n /** False when the content supplies its own Gorhom virtualized scroll owner. */\n scrollable?: boolean;\n /** The sheet holds work not yet saved, so a prompt arriving leaves it open with a note instead of closing it. */\n keep?: boolean;\n}\n\nexport { sheetsYielded, yieldSheets } from '@agimon-ai/po-native-components/shell';\n\n/** The latest footer, read by a footer component whose identity never changes while the sheet lives. */\ninterface FooterHolder {\n get: () => ReactNode;\n set: (footer: ReactNode) => void;\n subscribe: (listener: () => void) => () => void;\n}\n\nfunction footerHolder(initial: ReactNode): FooterHolder {\n let footer = initial;\n const listeners = new Set<() => void>();\n return {\n get: () => footer,\n set: (next) => {\n if (next === footer) return;\n footer = next;\n for (const listener of listeners) listener();\n },\n subscribe: (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n}\n\nfunction FooterBody({ holder }: { holder: FooterHolder }) {\n const footer = useSyncExternalStore(holder.subscribe, holder.get);\n return <InsideSheetContext.Provider value>{footer}</InsideSheetContext.Provider>;\n}\n\n/**\n * The bottom sheet both Sheet and DropdownMenu sit in: a drag handle, sized\n * to its content, closed by dragging down, tapping the backdrop or Android\n * back, clear of the safe area and lifted by the keyboard. Private: the public\n * parts keep bottom-sheet types out of the package API.\n */\nexport function SheetFrame({\n open,\n onClose,\n onDismiss,\n children,\n scrollable = true,\n footer,\n keep = false,\n}: SheetFrameProps) {\n const { theme } = useUnistyles();\n const insets = useContext(SafeAreaInsetsContext);\n const sheet = useRef<BottomSheetModal>(null);\n const openRef = useRef(open);\n const presented = useRef(false);\n const dismissing = useRef(false);\n const [footerHeight, setFooterHeight] = useState(0);\n const [note, setNote] = useState<string>();\n const latest = useRef({ keep, onClose, onDismiss });\n latest.current = { keep, onClose, onDismiss };\n const entry = useRef<OpenSheet>({\n keep: () => latest.current.keep,\n close: () => latest.current.onClose(),\n setNote,\n });\n // Gorhom takes the footer as a component; a new one each render would remount its fields mid-typing.\n const footers = useRef<FooterHolder>(undefined);\n footers.current ??= footerHolder(footer);\n const holder = footers.current;\n useLayoutEffect(() => holder.set(footer), [holder, footer]);\n\n useEffect(() => {\n openRef.current = open;\n if (open && !dismissing.current) {\n presented.current = true;\n registerSheet(entry.current);\n // The keyboard of the field behind would cover the sheet; a field inside it focuses after this.\n Keyboard.dismiss();\n sheet.current?.present();\n } else if (!open) {\n unregisterSheet(entry.current);\n setNote(undefined);\n if (presented.current && !dismissing.current) {\n // A new open waits for native dismissal, otherwise its callback closes the new request.\n dismissing.current = true;\n sheet.current?.dismiss();\n }\n }\n }, [open]);\n\n useEffect(\n () => () => {\n openRef.current = false;\n unregisterSheet(entry.current);\n dismissSheet?.(entry.current);\n },\n [],\n );\n\n useEffect(() => {\n if (!open) return undefined;\n const subscription = BackHandler.addEventListener('hardwareBackPress', () => {\n latest.current.onClose();\n return true;\n });\n return () => subscription.remove();\n }, [open]);\n\n const backdropColor = withAlpha(theme.colors.deep, BACKDROP_ALPHA_PERCENT);\n const renderBackdrop = useCallback(\n (props: BottomSheetBackdropProps) => (\n <BottomSheetBackdrop\n {...props}\n appearsOnIndex={0}\n disappearsOnIndex={-1}\n opacity={1}\n pressBehavior=\"close\"\n style={[props.style, { backgroundColor: backdropColor }]}\n />\n ),\n [backdropColor],\n );\n\n const footerInset = insets?.bottom ?? 0;\n const renderFooter = useCallback(\n (props: BottomSheetFooterProps) => (\n <BottomSheetFooter {...props}>\n <View\n onLayout={(event) => setFooterHeight(event.nativeEvent.layout.height)}\n style={{ paddingBottom: footerInset, backgroundColor: theme.colors.rail }}\n >\n <FooterBody holder={holder} />\n </View>\n </BottomSheetFooter>\n ),\n [holder, footerInset, theme.colors.rail],\n );\n const backgroundStyle = useMemo(\n () => ({ backgroundColor: theme.colors.rail, borderRadius: theme.borderRadius.lg }),\n [theme.colors.rail, theme.borderRadius.lg],\n );\n const handleIndicatorStyle = useMemo(() => ({ backgroundColor: theme.colors.border }), [theme.colors.border]);\n const onChange = useCallback((index: number) => {\n // present() mounts on the next frame, so an earlier dismiss() may have had nothing to close.\n if (index >= 0 && dismissing.current) sheet.current?.dismiss();\n }, []);\n // A sheet the caller closed is already shut; only a close the sheet started is reported.\n const onSheetDismiss = useCallback(() => {\n const reopen = dismissing.current && openRef.current;\n dismissing.current = false;\n presented.current = false;\n dismissSheet?.(entry.current);\n if (reopen) {\n presented.current = true;\n registerSheet(entry.current);\n sheet.current?.present();\n return;\n }\n if (openRef.current) latest.current.onClose();\n latest.current.onDismiss?.();\n }, []);\n\n return (\n <BottomSheetModal\n ref={sheet}\n // The library marks the whole sheet as one accessible element, which hides its fields and buttons on iOS.\n accessible={false}\n stackBehavior=\"push\"\n enablePanDownToClose\n topInset={insets?.top ?? 0}\n keyboardBehavior=\"interactive\"\n keyboardBlurBehavior=\"restore\"\n android_keyboardInputMode=\"adjustResize\"\n backdropComponent={renderBackdrop}\n {...(footer === undefined ? {} : { footerComponent: renderFooter })}\n backgroundStyle={backgroundStyle}\n handleIndicatorStyle={handleIndicatorStyle}\n onChange={onChange}\n onDismiss={onSheetDismiss}\n >\n {scrollable ? (\n <BottomSheetScrollView\n keyboardShouldPersistTaps=\"handled\"\n contentContainerStyle={[\n styles.content,\n { paddingBottom: footer === undefined ? (insets?.bottom ?? 0) : footerHeight },\n ]}\n >\n {note ? <SheetNote note={note} /> : null}\n <InsideSheetContext.Provider value>{children}</InsideSheetContext.Provider>\n </BottomSheetScrollView>\n ) : (\n <>\n {note ? <SheetNote note={note} /> : null}\n <InsideSheetContext.Provider value>{children}</InsideSheetContext.Provider>\n </>\n )}\n </BottomSheetModal>\n );\n}\n\n/** A gentle rose line: the person is asked something below, never told to hurry. */\nfunction SheetNote({ note }: { note: string }) {\n return (\n <Text style={styles.note} accessibilityRole=\"alert\">\n {note}\n </Text>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n content: { flexGrow: 1 },\n note: {\n marginHorizontal: theme.spacing(4),\n marginBottom: theme.spacing(2),\n color: theme.colors.magenta,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n}));\n"],"mappings":";;;;;;;;;;;;;;AAkCA,MAAM2B,yBAAyB;AAwB/B,SAASgB,aAAaC,SAAkC;CACtD,IAAIX,SAASW;CACb,MAAMC,4BAAY,IAAIC,IAAgB;CACtC,OAAO;EACLP,WAAWN;EACXO,MAAMO,SAAS;GACb,IAAIA,SAASd,QAAQ;GACrBA,SAASc;GACT,KAAK,MAAML,YAAYG,WAAWH,SAAS;EAC7C;EACAD,YAAYC,aAAa;GACvBG,UAAUG,IAAIN,QAAQ;GACtB,aAAaG,UAAUI,OAAOP,QAAQ;EACxC;CACF;AACF;AAEA,SAASQ,WAAW,EAAEC,UAAoC;CACxD,MAAMlB,SAASb,qBAAqB+B,OAAOV,WAAWU,OAAOZ,GAAG;CAChE,OAAO,oBAAC,mBAAmB,UAApB;EAA6B;YAAON;CAAoC;AACjF;;;;;;;AAQA,SAAgBmB,WAAW,EACzBvB,MACAC,SACAC,WACAC,UACAE,aAAa,MACbD,QACAE,OAAO,SACW;CAClB,MAAM,EAAEkB,UAAU5B,aAAa;CAC/B,MAAM6B,SAASxC,WAAWS,qBAAqB;CAC/C,MAAMgC,QAAQrC,OAAyB,IAAI;CAC3C,MAAMsC,UAAUtC,OAAOW,IAAI;CAC3B,MAAM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CC,UAAU5D,MAAM4D,SAASC;EACzBC,YAAY9D,MAAM8D,WAAWD;EAAEE,mBAAA,CAAA,CAAA;CACjC;AACF,EAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/po-native-components",
3
- "version": "0.0.0-alpha.157",
3
+ "version": "0.0.0-alpha.159",
4
4
  "description": "Shared React Native components for Po and its native plugins: the web component library's look and API on native parts, tuned to the Po palette.",
5
5
  "keywords": [
6
6
  "ai",
@@ -49,12 +49,12 @@
49
49
  "access": "public"
50
50
  },
51
51
  "dependencies": {
52
- "@agimon-ai/po-web-components": "0.0.0-alpha.157"
52
+ "@agimon-ai/po-web-components": "0.0.0-alpha.159"
53
53
  },
54
54
  "devDependencies": {
55
- "@agimon-ai/po-build": "0.0.0-alpha.157",
56
- "@agimon-ai/po-core": "0.0.0-alpha.157",
57
- "@agimon-ai/vibe-lint-plugin-po-web": "0.0.0-alpha.157",
55
+ "@agimon-ai/po-build": "0.0.0-alpha.159",
56
+ "@agimon-ai/po-core": "0.0.0-alpha.159",
57
+ "@agimon-ai/vibe-lint-plugin-po-web": "0.0.0-alpha.159",
58
58
  "@babel/core": "7.29.7",
59
59
  "@expo/vector-icons": "15.1.1",
60
60
  "@fontsource-variable/ibm-plex-sans": "5.3.0",