@bsky.app/peek-menu 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/.eslintrc.js +5 -0
  2. package/CHANGELOG.md +7 -0
  3. package/README.md +121 -0
  4. package/build/ExpoContextMenuNativeView.android.d.ts +6 -0
  5. package/build/ExpoContextMenuNativeView.android.d.ts.map +1 -0
  6. package/build/ExpoContextMenuNativeView.android.js +9 -0
  7. package/build/ExpoContextMenuNativeView.android.js.map +1 -0
  8. package/build/ExpoContextMenuNativeView.d.ts +5 -0
  9. package/build/ExpoContextMenuNativeView.d.ts.map +1 -0
  10. package/build/ExpoContextMenuNativeView.js +4 -0
  11. package/build/ExpoContextMenuNativeView.js.map +1 -0
  12. package/build/ExpoContextMenuNativeView.web.d.ts +7 -0
  13. package/build/ExpoContextMenuNativeView.web.d.ts.map +1 -0
  14. package/build/ExpoContextMenuNativeView.web.js +10 -0
  15. package/build/ExpoContextMenuNativeView.web.js.map +1 -0
  16. package/build/Menu.d.ts +6 -0
  17. package/build/Menu.d.ts.map +1 -0
  18. package/build/Menu.js +10 -0
  19. package/build/Menu.js.map +1 -0
  20. package/build/MenuItem.d.ts +11 -0
  21. package/build/MenuItem.d.ts.map +1 -0
  22. package/build/MenuItem.js +10 -0
  23. package/build/MenuItem.js.map +1 -0
  24. package/build/MenuItemIcon.d.ts +6 -0
  25. package/build/MenuItemIcon.d.ts.map +1 -0
  26. package/build/MenuItemIcon.js +11 -0
  27. package/build/MenuItemIcon.js.map +1 -0
  28. package/build/MenuItemText.d.ts +5 -0
  29. package/build/MenuItemText.d.ts.map +1 -0
  30. package/build/MenuItemText.js +11 -0
  31. package/build/MenuItemText.js.map +1 -0
  32. package/build/Root.d.ts +8 -0
  33. package/build/Root.d.ts.map +1 -0
  34. package/build/Root.js +81 -0
  35. package/build/Root.js.map +1 -0
  36. package/build/Trigger.d.ts +15 -0
  37. package/build/Trigger.d.ts.map +1 -0
  38. package/build/Trigger.js +10 -0
  39. package/build/Trigger.js.map +1 -0
  40. package/build/index.d.ts +8 -0
  41. package/build/index.d.ts.map +1 -0
  42. package/build/index.js +7 -0
  43. package/build/index.js.map +1 -0
  44. package/build/registry.d.ts +13 -0
  45. package/build/registry.d.ts.map +1 -0
  46. package/build/registry.js +18 -0
  47. package/build/registry.js.map +1 -0
  48. package/build/types.d.ts +70 -0
  49. package/build/types.d.ts.map +1 -0
  50. package/build/types.js +2 -0
  51. package/build/types.js.map +1 -0
  52. package/expo-module.config.json +6 -0
  53. package/ios/ExpoBlueskyPeekMenu.podspec +22 -0
  54. package/ios/ExpoBlueskyPeekMenuModule.swift +24 -0
  55. package/ios/ExpoBlueskyPeekMenuView.swift +111 -0
  56. package/ios/IconRenderer.swift +69 -0
  57. package/ios/ImagePreviewController.swift +133 -0
  58. package/ios/MenuBuilder.swift +51 -0
  59. package/ios/PreviewFactory.swift +27 -0
  60. package/ios/SVGPathParser.swift +320 -0
  61. package/package.json +38 -0
  62. package/src/ExpoContextMenuNativeView.android.tsx +10 -0
  63. package/src/ExpoContextMenuNativeView.tsx +10 -0
  64. package/src/ExpoContextMenuNativeView.web.tsx +11 -0
  65. package/src/Menu.tsx +17 -0
  66. package/src/MenuItem.tsx +22 -0
  67. package/src/MenuItemIcon.tsx +17 -0
  68. package/src/MenuItemText.tsx +16 -0
  69. package/src/Root.tsx +119 -0
  70. package/src/Trigger.tsx +26 -0
  71. package/src/index.ts +12 -0
  72. package/src/registry.ts +32 -0
  73. package/src/types.ts +71 -0
  74. package/tsconfig.json +9 -0
  75. package/vitest.config.ts +7 -0
package/src/types.ts ADDED
@@ -0,0 +1,71 @@
1
+ import {type ReactNode} from 'react'
2
+ import {type StyleProp, type ViewStyle} from 'react-native'
3
+
4
+ /**
5
+ * The subset of SVG metadata needed by the native menu icon renderer.
6
+ * Any icon component that carries these three properties can be passed
7
+ * to `MenuItemIcon`. In practice this is satisfied by every icon
8
+ * created with `createSinglePathSVG` / `createMultiPathSVG`.
9
+ */
10
+ export type SvgIconMeta = {
11
+ svgPaths: string[]
12
+ svgViewBox: string
13
+ svgStrokeWidth: number
14
+ }
15
+
16
+ /**
17
+ * Content to show during the peek preview. Discriminated by `type`; the native
18
+ * side dispatches on it to build the right `UIViewController`.
19
+ *
20
+ * Only `image` is implemented on iOS today. `video` and `externalCard` are the
21
+ * planned follow-ups; leaving them in the type keeps the JS call-sites honest.
22
+ */
23
+ export type PreviewContent =
24
+ | {
25
+ type: 'image'
26
+ uri: string
27
+ /** Thumb URL. When present, the native side paints it in as an instant
28
+ * placeholder (reading from the shared SDWebImage cache) while the
29
+ * fullsize loads — avoids the black flash on first peek. */
30
+ thumbUri?: string
31
+ /** Aspect ratio as width / height. */
32
+ aspectRatio: number
33
+ }
34
+ | {
35
+ type: 'video'
36
+ uri: string
37
+ poster?: string
38
+ aspectRatio: number
39
+ }
40
+ | {
41
+ type: 'externalCard'
42
+ thumbUri?: string
43
+ title: string
44
+ description?: string
45
+ url: string
46
+ }
47
+
48
+ export type MenuItemSpec = {
49
+ id: string
50
+ label: string
51
+ destructive?: boolean
52
+ disabled?: boolean
53
+ icon?: {
54
+ paths: string[]
55
+ viewBox: string
56
+ strokeWidth: number
57
+ }
58
+ }
59
+
60
+ export type MenuItemIconSource = SvgIconMeta
61
+
62
+ export type NativeViewProps = {
63
+ preview?: PreviewContent
64
+ menuItems: MenuItemSpec[]
65
+ /** Named distinctly from `borderRadius`, which RN owns as a style prop. */
66
+ previewCornerRadius: number
67
+ onItemPress: (e: {nativeEvent: {id: string}}) => void
68
+ onPreviewPress: (e: {nativeEvent: {}}) => void
69
+ style?: StyleProp<ViewStyle>
70
+ children?: ReactNode
71
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "expo-module-scripts/tsconfig.base",
3
+ "compilerOptions": {
4
+ "outDir": "./build",
5
+ "jsx": "react-jsx"
6
+ },
7
+ "include": ["./src"],
8
+ "exclude": ["**/__mocks__/*", "**/__tests__/*", "**/__rsc_tests__/*"]
9
+ }
@@ -0,0 +1,7 @@
1
+ import {defineConfig} from 'vitest/config'
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ include: ['src/__tests__/**/*.test.ts'],
6
+ },
7
+ })