anhedral 0.13.0 → 0.16.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 +23 -229
- package/assets/patches/audit-deps.mjs +12 -2
- package/assets/stack/ai-schema.ts.txt +5 -0
- package/assets/stack/ai.ts.txt +30 -0
- package/assets/stack/api-index.ts.txt +15 -0
- package/assets/stack/auth-features.ts.txt +4 -0
- package/assets/stack/auth-journal.json.txt +13 -0
- package/assets/stack/auth-migration.sql.txt +53 -0
- package/assets/stack/auth-routes.ts.txt +11 -0
- package/assets/stack/auth-schema.ts.txt +64 -0
- package/assets/stack/auth-snapshot.json.txt +346 -0
- package/assets/stack/auth.ts.txt +32 -0
- package/assets/stack/billing-mode.ts.txt +8 -0
- package/assets/stack/billing-schema.ts.txt +11 -0
- package/assets/stack/desktop.rs.txt +21 -0
- package/assets/stack/entitlement-guard.ts.txt +32 -0
- package/assets/stack/entitlements.ts.txt +8 -0
- package/assets/stack/events-schema.ts.txt +12 -0
- package/assets/stack/events.ts.txt +59 -0
- package/assets/stack/mobile-auth.ts.txt +25 -0
- package/assets/stack/mobile-billing.tsx.txt +63 -0
- package/assets/stack/mobile-session.tsx.txt +83 -0
- package/assets/stack/native-button.tsx.txt +108 -0
- package/assets/stack/native-global.css.txt +4 -0
- package/assets/stack/native-lib-utils.ts.txt +5 -0
- package/assets/stack/native-metro.config.js.txt +6 -0
- package/assets/stack/native-nativewind-env.d.ts.txt +1 -0
- package/assets/stack/native-tailwind.config.js.txt +73 -0
- package/assets/stack/native-text.tsx.txt +89 -0
- package/assets/stack/purchases.ts.txt +65 -0
- package/assets/stack/revenuecat.ts.txt +88 -0
- package/assets/stack/rtc-schema.ts.txt +10 -0
- package/assets/stack/rtc.ts.txt +122 -0
- package/assets/stack/security.ts.txt +31 -0
- package/assets/stack/storage.ts.txt +36 -0
- package/assets/stack/stripe.ts.txt +126 -0
- package/assets/stack/web-sign-in.tsx.txt +51 -0
- package/assets/ui/LICENSE.react-native-reusables +21 -0
- package/assets/ui/LICENSE.shadcn +21 -0
- package/assets/ui/UPSTREAM.json +39 -0
- package/assets/ui/catalog.json +891 -0
- package/assets/ui/extensions/registry.json +6 -0
- package/assets/ui/native/_controls.tsx +521 -0
- package/assets/ui/native/_core.tsx +118 -0
- package/assets/ui/native/_data.tsx +200 -0
- package/assets/ui/native/_display.tsx +453 -0
- package/assets/ui/native/_feedback.tsx +242 -0
- package/assets/ui/native/_legacy-dialog.tsx +38 -0
- package/assets/ui/native/_motion.tsx +520 -0
- package/assets/ui/native/_overlay.tsx +402 -0
- package/assets/ui/native/_selection.tsx +366 -0
- package/assets/ui/native/accordion.tsx +1 -0
- package/assets/ui/native/alert-dialog.tsx +11 -0
- package/assets/ui/native/alert.tsx +1 -0
- package/assets/ui/native/aspect-ratio.tsx +1 -0
- package/assets/ui/native/attachment.tsx +8 -0
- package/assets/ui/native/avatar.tsx +8 -0
- package/assets/ui/native/badge.tsx +1 -0
- package/assets/ui/native/breadcrumb.tsx +9 -0
- package/assets/ui/native/bubble.tsx +1 -0
- package/assets/ui/native/button-group.tsx +1 -0
- package/assets/ui/native/button.tsx +86 -0
- package/assets/ui/native/calendar.tsx +170 -0
- package/assets/ui/native/card.tsx +44 -0
- package/assets/ui/native/carousel.tsx +1 -0
- package/assets/ui/native/chart.tsx +193 -0
- package/assets/ui/native/checkbox.tsx +1 -0
- package/assets/ui/native/code-block.tsx +137 -0
- package/assets/ui/native/collapsible.tsx +1 -0
- package/assets/ui/native/combobox.tsx +1 -0
- package/assets/ui/native/command.tsx +11 -0
- package/assets/ui/native/context-menu.tsx +16 -0
- package/assets/ui/native/data-table.tsx +1 -0
- package/assets/ui/native/date-picker.tsx +43 -0
- package/assets/ui/native/dialog.tsx +15 -0
- package/assets/ui/native/direction.tsx +1 -0
- package/assets/ui/native/drawer.tsx +10 -0
- package/assets/ui/native/dropdown-menu.tsx +16 -0
- package/assets/ui/native/empty.tsx +8 -0
- package/assets/ui/native/field.tsx +13 -0
- package/assets/ui/native/hover-card.tsx +1 -0
- package/assets/ui/native/input-group.tsx +8 -0
- package/assets/ui/native/input-otp.tsx +1 -0
- package/assets/ui/native/input.tsx +28 -0
- package/assets/ui/native/item.tsx +12 -0
- package/assets/ui/native/kbd.tsx +1 -0
- package/assets/ui/native/label.tsx +4 -0
- package/assets/ui/native/layout.tsx +26 -0
- package/assets/ui/native/marker.tsx +1 -0
- package/assets/ui/native/menubar.tsx +17 -0
- package/assets/ui/native/message-scroller.tsx +6 -0
- package/assets/ui/native/message.tsx +10 -0
- package/assets/ui/native/native-select.tsx +1 -0
- package/assets/ui/native/navigation-menu.tsx +10 -0
- package/assets/ui/native/pagination.tsx +9 -0
- package/assets/ui/native/popover.tsx +1 -0
- package/assets/ui/native/progress.tsx +1 -0
- package/assets/ui/native/questionnaire.tsx +130 -0
- package/assets/ui/native/radio-group.tsx +1 -0
- package/assets/ui/native/registry.json +1103 -0
- package/assets/ui/native/resizable.tsx +1 -0
- package/assets/ui/native/scroll-area.tsx +1 -0
- package/assets/ui/native/select.tsx +11 -0
- package/assets/ui/native/separator.tsx +1 -0
- package/assets/ui/native/sheet.tsx +10 -0
- package/assets/ui/native/sidebar.tsx +22 -0
- package/assets/ui/native/skeleton.tsx +1 -0
- package/assets/ui/native/slider.tsx +1 -0
- package/assets/ui/native/spinner.tsx +1 -0
- package/assets/ui/native/switch.tsx +1 -0
- package/assets/ui/native/table.tsx +10 -0
- package/assets/ui/native/tabs.tsx +1 -0
- package/assets/ui/native/text.tsx +20 -0
- package/assets/ui/native/textarea.tsx +1 -0
- package/assets/ui/native/theme-switcher.tsx +22 -0
- package/assets/ui/native/toast.tsx +11 -0
- package/assets/ui/native/toggle-group.tsx +1 -0
- package/assets/ui/native/toggle.tsx +1 -0
- package/assets/ui/native/tooltip.tsx +1 -0
- package/assets/ui/native/trace.tsx +20 -0
- package/assets/ui/native/typography.tsx +15 -0
- package/assets/ui/theme-storage.ts +25 -0
- package/assets/ui/theme.tsx +66 -0
- package/assets/ui/web/button.tsx +59 -0
- package/assets/ui/web/input.tsx +21 -0
- package/assets/ui/web/label.tsx +19 -0
- package/dist/bin.js +7 -12
- package/dist/capabilities.d.ts +4 -33
- package/dist/capabilities.js +2 -84
- package/dist/capability-catalog.d.ts +83 -0
- package/dist/capability-catalog.js +121 -0
- package/dist/capability-command.d.ts +3 -0
- package/dist/capability-command.js +188 -0
- package/dist/capability-editor.d.ts +17 -0
- package/dist/capability-editor.js +97 -0
- package/dist/capability-recipes.d.ts +4 -0
- package/dist/capability-recipes.js +520 -0
- package/dist/capability-references.d.ts +4 -0
- package/dist/capability-references.js +7 -0
- package/dist/cli-commands.d.ts +1 -2
- package/dist/cli-commands.js +10 -104
- package/dist/cli-output.d.ts +1 -2
- package/dist/cli-output.js +6 -251
- package/dist/command-schema.js +40 -374
- package/dist/dependencies.d.ts +34 -62
- package/dist/dependencies.js +112 -199
- package/dist/index.d.ts +1 -45
- package/dist/index.js +1 -30
- package/dist/platforms/mobile.js +29 -139
- package/dist/platforms/web.d.ts +3 -0
- package/dist/platforms/web.js +251 -0
- package/dist/project-config.d.ts +2 -13
- package/dist/project-config.js +10 -83
- package/dist/registry/context.js +0 -1
- package/dist/registry/options.js +6 -40
- package/dist/registry/resolve.d.ts +3 -4
- package/dist/registry/resolve.js +18 -108
- package/dist/registry/types.d.ts +1 -7
- package/dist/registry/usage.js +3 -9
- package/dist/runtime-policy.d.ts +0 -2
- package/dist/runtime-policy.js +0 -16
- package/dist/scaffold/backend.d.ts +0 -4
- package/dist/scaffold/backend.js +1 -189
- package/dist/scaffold/bootstrap.d.ts +2 -3
- package/dist/scaffold/bootstrap.js +37 -43
- package/dist/scaffold/compose.js +2 -14
- package/dist/scaffold/database.d.ts +1 -1
- package/dist/scaffold/database.js +19 -126
- package/dist/scaffold/documentation.d.ts +0 -1
- package/dist/scaffold/documentation.js +82 -84
- package/dist/scaffold/expo-runtime.d.ts +2 -2
- package/dist/scaffold/expo-runtime.js +9 -101
- package/dist/scaffold/native-ui.d.ts +2 -0
- package/dist/scaffold/native-ui.js +74 -0
- package/dist/scaffold/stack-documentation.d.ts +0 -1
- package/dist/scaffold/stack-documentation.js +3 -49
- package/dist/scaffold/storage.d.ts +2 -0
- package/dist/scaffold/storage.js +21 -0
- package/dist/scaffold/styling.d.ts +1 -1
- package/dist/scaffold/styling.js +20 -28
- package/dist/scaffold/workspace.js +63 -199
- package/dist/stack-registry.d.ts +2 -58
- package/dist/stack-registry.js +22 -446
- package/dist/standard.js +7 -24
- package/dist/ui-catalog.d.ts +26 -0
- package/dist/ui-catalog.js +31 -0
- package/dist/ui-command.d.ts +3 -0
- package/dist/ui-command.js +219 -0
- package/dist/ui-project.d.ts +22 -0
- package/dist/ui-project.js +110 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/anhedral-stack.md +4 -119
- package/docs/capabilities.md +110 -0
- package/docs/native-ui.md +102 -0
- package/docs/software-factory.md +16 -577
- package/docs/stack-standard.md +11 -307
- package/docs/ui.md +33 -0
- package/docs/verification.md +511 -0
- package/package.json +26 -27
- package/dist/access.d.ts +0 -10
- package/dist/access.js +0 -93
- package/dist/auth-schema-snapshot.d.ts +0 -346
- package/dist/auth-schema-snapshot.js +0 -347
- package/dist/auth-schema.d.ts +0 -1
- package/dist/auth-schema.js +0 -57
- package/dist/capability-contract.d.ts +0 -47
- package/dist/capability-contract.js +0 -168
- package/dist/catalog-model.d.ts +0 -24
- package/dist/catalog-model.js +0 -1
- package/dist/catalog-registration.d.ts +0 -16
- package/dist/catalog-registration.js +0 -22
- package/dist/catalog-snapshot.d.ts +0 -5
- package/dist/catalog-snapshot.js +0 -97
- package/dist/cli-delivery.d.ts +0 -3
- package/dist/cli-delivery.js +0 -172
- package/dist/cloudflare.d.ts +0 -25
- package/dist/cloudflare.js +0 -226
- package/dist/delivery-evidence.d.ts +0 -62
- package/dist/delivery-evidence.js +0 -186
- package/dist/delivery.d.ts +0 -88
- package/dist/delivery.js +0 -570
- package/dist/inspector-model.d.ts +0 -123
- package/dist/inspector-model.js +0 -1
- package/dist/integration-service-readers.d.ts +0 -13
- package/dist/integration-service-readers.js +0 -173
- package/dist/lifecycle-model.d.ts +0 -15
- package/dist/lifecycle-model.js +0 -20
- package/dist/lifecycle.d.ts +0 -11
- package/dist/lifecycle.js +0 -91
- package/dist/management.d.ts +0 -3
- package/dist/management.js +0 -47
- package/dist/mobile-delivery.d.ts +0 -77
- package/dist/mobile-delivery.js +0 -366
- package/dist/neon-service-data.d.ts +0 -8
- package/dist/neon-service-data.js +0 -117
- package/dist/platforms/desktop.d.ts +0 -2
- package/dist/platforms/desktop.js +0 -415
- package/dist/platforms/extension.d.ts +0 -2
- package/dist/platforms/extension.js +0 -328
- package/dist/project-catalog.d.ts +0 -41
- package/dist/project-catalog.js +0 -288
- package/dist/project-inspector.d.ts +0 -4
- package/dist/project-inspector.js +0 -702
- package/dist/project-lifecycle.d.ts +0 -25
- package/dist/project-lifecycle.js +0 -57
- package/dist/project-state.d.ts +0 -49
- package/dist/project-state.js +0 -563
- package/dist/provider-auth.d.ts +0 -41
- package/dist/provider-auth.js +0 -215
- package/dist/provider-readiness.d.ts +0 -30
- package/dist/provider-readiness.js +0 -104
- package/dist/providers/adapters.d.ts +0 -17
- package/dist/providers/adapters.js +0 -278
- package/dist/providers/api.d.ts +0 -29
- package/dist/providers/api.js +0 -253
- package/dist/providers/config.d.ts +0 -15
- package/dist/providers/config.js +0 -182
- package/dist/providers/definitions.d.ts +0 -318
- package/dist/providers/definitions.js +0 -127
- package/dist/providers/provision.d.ts +0 -24
- package/dist/providers/provision.js +0 -76
- package/dist/providers/receipts.d.ts +0 -20
- package/dist/providers/receipts.js +0 -66
- package/dist/providers/recovery-verification.d.ts +0 -7
- package/dist/providers/recovery-verification.js +0 -112
- package/dist/providers/recovery.d.ts +0 -30
- package/dist/providers/recovery.js +0 -34
- package/dist/providers/runtime.d.ts +0 -10
- package/dist/providers/runtime.js +0 -265
- package/dist/providers/schema.d.ts +0 -28
- package/dist/providers/schema.js +0 -49
- package/dist/providers/state.d.ts +0 -55
- package/dist/providers/state.js +0 -289
- package/dist/provision.d.ts +0 -55
- package/dist/provision.js +0 -284
- package/dist/r2-service-data.d.ts +0 -2
- package/dist/r2-service-data.js +0 -136
- package/dist/readiness.d.ts +0 -23
- package/dist/readiness.js +0 -122
- package/dist/registry/add.d.ts +0 -24
- package/dist/registry/add.js +0 -270
- package/dist/registry/bootstrap.d.ts +0 -2
- package/dist/registry/bootstrap.js +0 -14
- package/dist/registry/commands.d.ts +0 -3
- package/dist/registry/commands.js +0 -85
- package/dist/registry/presets.d.ts +0 -4
- package/dist/registry/presets.js +0 -41
- package/dist/registry/preview.d.ts +0 -11
- package/dist/registry/preview.js +0 -91
- package/dist/registry/receipt.d.ts +0 -3
- package/dist/registry/receipt.js +0 -68
- package/dist/repository.d.ts +0 -24
- package/dist/repository.js +0 -96
- package/dist/scaffold/auth.d.ts +0 -3
- package/dist/scaffold/auth.js +0 -151
- package/dist/scaffold/billing-config.d.ts +0 -1
- package/dist/scaffold/billing-config.js +0 -73
- package/dist/scaffold/billing-contracts.d.ts +0 -2
- package/dist/scaffold/billing-contracts.js +0 -48
- package/dist/scaffold/billing-providers.d.ts +0 -1
- package/dist/scaffold/billing-providers.js +0 -249
- package/dist/scaffold/billing-schema.d.ts +0 -1
- package/dist/scaffold/billing-schema.js +0 -34
- package/dist/scaffold/billing-security.d.ts +0 -1
- package/dist/scaffold/billing-security.js +0 -46
- package/dist/scaffold/billing-server.d.ts +0 -1
- package/dist/scaffold/billing-server.js +0 -139
- package/dist/scaffold/billing-store.d.ts +0 -1
- package/dist/scaffold/billing-store.js +0 -72
- package/dist/scaffold/billing.d.ts +0 -2
- package/dist/scaffold/billing.js +0 -216
- package/dist/scaffold/cloudflare-services.d.ts +0 -8
- package/dist/scaffold/cloudflare-services.js +0 -198
- package/dist/scaffold/expo-auth.d.ts +0 -3
- package/dist/scaffold/expo-auth.js +0 -192
- package/dist/scaffold/expo-billing.d.ts +0 -3
- package/dist/scaffold/expo-billing.js +0 -292
- package/dist/scaffold/integrations.d.ts +0 -4
- package/dist/scaffold/integrations.js +0 -12
- package/dist/scaffold/lint.d.ts +0 -4
- package/dist/scaffold/lint.js +0 -56
- package/dist/scaffold/neon-realtime.d.ts +0 -2
- package/dist/scaffold/neon-realtime.js +0 -97
- package/dist/scaffold/services.d.ts +0 -5
- package/dist/scaffold/services.js +0 -108
- package/dist/scaffold/stream.d.ts +0 -2
- package/dist/scaffold/stream.js +0 -114
- package/dist/scaffold/void.d.ts +0 -4
- package/dist/scaffold/void.js +0 -264
- package/dist/scaffold/web.d.ts +0 -2
- package/dist/scaffold/web.js +0 -130
- package/dist/service-deletion.d.ts +0 -29
- package/dist/service-deletion.js +0 -195
- package/dist/service-descriptor.d.ts +0 -10
- package/dist/service-descriptor.js +0 -78
- package/dist/service-model.d.ts +0 -49
- package/dist/service-model.js +0 -8
- package/dist/service-operations.d.ts +0 -29
- package/dist/service-operations.js +0 -78
- package/dist/service-readers.d.ts +0 -8
- package/dist/service-readers.js +0 -247
- package/dist/services-command.d.ts +0 -39
- package/dist/services-command.js +0 -102
- package/dist/ship.d.ts +0 -348
- package/dist/ship.js +0 -239
- package/dist/vercel-project.d.ts +0 -101
- package/dist/vercel-project.js +0 -305
- package/dist/vercel.d.ts +0 -67
- package/dist/vercel.js +0 -581
- package/dist/vinext.d.ts +0 -2
- package/dist/vinext.js +0 -86
- package/dist/void-execution.d.ts +0 -10
- package/dist/void-execution.js +0 -94
- package/dist/void-migrations.d.ts +0 -6
- package/dist/void-migrations.js +0 -110
- package/dist/void-state.d.ts +0 -16
- package/dist/void-state.js +0 -65
- package/dist/void.d.ts +0 -3
- package/dist/void.js +0 -5
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
useContext,
|
|
4
|
+
useEffect,
|
|
5
|
+
useId,
|
|
6
|
+
useRef,
|
|
7
|
+
type ReactNode,
|
|
8
|
+
type RefObject,
|
|
9
|
+
} from 'react';
|
|
10
|
+
import {
|
|
11
|
+
View,
|
|
12
|
+
Modal,
|
|
13
|
+
KeyboardAvoidingView,
|
|
14
|
+
Pressable,
|
|
15
|
+
AccessibilityInfo,
|
|
16
|
+
findNodeHandle,
|
|
17
|
+
Platform,
|
|
18
|
+
PanResponder,
|
|
19
|
+
type ViewProps,
|
|
20
|
+
} from 'react-native';
|
|
21
|
+
import { Box, LabelText, Muted, row, content, useControllable } from './_core';
|
|
22
|
+
import { Button, type ButtonProps } from './button';
|
|
23
|
+
import { SafeAreaInsetsContext } from 'react-native-safe-area-context';
|
|
24
|
+
import { useTheme } from '../theme';
|
|
25
|
+
|
|
26
|
+
type OverlayState = {
|
|
27
|
+
open: boolean;
|
|
28
|
+
set: (open: boolean) => void;
|
|
29
|
+
trigger: RefObject<View | null>;
|
|
30
|
+
heading: RefObject<View | null>;
|
|
31
|
+
id: string;
|
|
32
|
+
};
|
|
33
|
+
const OverlayContext = createContext<OverlayState | null>(null);
|
|
34
|
+
export function useOverlay() {
|
|
35
|
+
const value = useContext(OverlayContext);
|
|
36
|
+
if (!value) throw Error('Overlay parts require a Dialog, Sheet, Popover or menu root.');
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
export type OverlayProps = {
|
|
40
|
+
children?: ReactNode;
|
|
41
|
+
open?: boolean;
|
|
42
|
+
defaultOpen?: boolean;
|
|
43
|
+
onOpenChange?: (open: boolean) => void;
|
|
44
|
+
};
|
|
45
|
+
export function OverlayRoot({ open, defaultOpen = false, onOpenChange, children }: OverlayProps) {
|
|
46
|
+
const [value, set] = useControllable(open, defaultOpen, onOpenChange);
|
|
47
|
+
const trigger = useRef<View>(null);
|
|
48
|
+
const heading = useRef<View>(null);
|
|
49
|
+
const id = useId();
|
|
50
|
+
return (
|
|
51
|
+
<OverlayContext.Provider value={{ open: value, set, trigger, heading, id }}>
|
|
52
|
+
{children}
|
|
53
|
+
</OverlayContext.Provider>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
function focus(ref: RefObject<View | null>) {
|
|
57
|
+
const node = ref.current && findNodeHandle(ref.current);
|
|
58
|
+
if (node) AccessibilityInfo.setAccessibilityFocus(node);
|
|
59
|
+
}
|
|
60
|
+
export function OverlayTrigger({ onPress, ...props }: ButtonProps) {
|
|
61
|
+
const state = useOverlay();
|
|
62
|
+
return (
|
|
63
|
+
<Button
|
|
64
|
+
{...props}
|
|
65
|
+
ref={state.trigger}
|
|
66
|
+
accessibilityState={{ ...props.accessibilityState, expanded: state.open }}
|
|
67
|
+
onPress={(event) => {
|
|
68
|
+
onPress?.(event);
|
|
69
|
+
if (!event.isDefaultPrevented()) state.set(true);
|
|
70
|
+
}}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
export function LongPressTrigger({ onLongPress, ...props }: ButtonProps) {
|
|
75
|
+
const state = useOverlay();
|
|
76
|
+
return (
|
|
77
|
+
<Button
|
|
78
|
+
{...props}
|
|
79
|
+
ref={state.trigger}
|
|
80
|
+
accessibilityHint="Touch and hold to open"
|
|
81
|
+
accessibilityState={{ expanded: state.open }}
|
|
82
|
+
onLongPress={(event) => {
|
|
83
|
+
onLongPress?.(event);
|
|
84
|
+
state.set(true);
|
|
85
|
+
}}
|
|
86
|
+
accessibilityActions={[{ name: 'activate', label: 'Open preview' }]}
|
|
87
|
+
onAccessibilityAction={() => state.set(true)}
|
|
88
|
+
/>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
export function OverlayClose({ onPress, ...props }: ButtonProps) {
|
|
92
|
+
const state = useOverlay();
|
|
93
|
+
return (
|
|
94
|
+
<Button
|
|
95
|
+
{...props}
|
|
96
|
+
onPress={(event) => {
|
|
97
|
+
onPress?.(event);
|
|
98
|
+
if (!event.isDefaultPrevented()) state.set(false);
|
|
99
|
+
}}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
export function OverlayContent({
|
|
104
|
+
children,
|
|
105
|
+
side = 'center',
|
|
106
|
+
dismissOnBackdrop = true,
|
|
107
|
+
swipeToDismiss = false,
|
|
108
|
+
style,
|
|
109
|
+
...props
|
|
110
|
+
}: ViewProps & {
|
|
111
|
+
side?: 'center' | 'top' | 'bottom' | 'left' | 'right';
|
|
112
|
+
dismissOnBackdrop?: boolean;
|
|
113
|
+
swipeToDismiss?: boolean;
|
|
114
|
+
}) {
|
|
115
|
+
const state = useOverlay();
|
|
116
|
+
const { colors } = useTheme();
|
|
117
|
+
const insets = useContext(SafeAreaInsetsContext) ?? { top: 0, right: 0, bottom: 0, left: 0 };
|
|
118
|
+
const previous = useRef(state.open);
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
const closed = previous.current && !state.open;
|
|
121
|
+
previous.current = state.open;
|
|
122
|
+
if (!closed || Platform.OS === 'ios') return;
|
|
123
|
+
const frame = requestAnimationFrame(() => focus(state.trigger));
|
|
124
|
+
return () => cancelAnimationFrame(frame);
|
|
125
|
+
}, [state.open, state.trigger]);
|
|
126
|
+
const pan = PanResponder.create({
|
|
127
|
+
onMoveShouldSetPanResponder: (_event, gesture) =>
|
|
128
|
+
swipeToDismiss && Math.abs(gesture.dx) < 20 && gesture.dy > 16,
|
|
129
|
+
onPanResponderRelease: (_event, gesture) => {
|
|
130
|
+
if (gesture.dy > 80) state.set(false);
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
const horizontal = side === 'left' || side === 'right';
|
|
134
|
+
return (
|
|
135
|
+
<Modal
|
|
136
|
+
testID={props.testID ? `${props.testID}-modal` : undefined}
|
|
137
|
+
visible={state.open}
|
|
138
|
+
transparent
|
|
139
|
+
animationType="none"
|
|
140
|
+
onShow={() => focus(state.heading)}
|
|
141
|
+
onDismiss={() => focus(state.trigger)}
|
|
142
|
+
onRequestClose={() => state.set(false)}
|
|
143
|
+
>
|
|
144
|
+
<KeyboardAvoidingView
|
|
145
|
+
style={{ flex: 1 }}
|
|
146
|
+
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
147
|
+
>
|
|
148
|
+
<View
|
|
149
|
+
accessibilityElementsHidden={!state.open}
|
|
150
|
+
importantForAccessibility={state.open ? 'auto' : 'no-hide-descendants'}
|
|
151
|
+
style={{
|
|
152
|
+
flex: 1,
|
|
153
|
+
justifyContent:
|
|
154
|
+
side === 'top' ? 'flex-start' : side === 'bottom' ? 'flex-end' : 'center',
|
|
155
|
+
alignItems: side === 'left' ? 'flex-start' : side === 'right' ? 'flex-end' : 'stretch',
|
|
156
|
+
padding: side === 'center' ? 24 : 0,
|
|
157
|
+
}}
|
|
158
|
+
>
|
|
159
|
+
<Pressable
|
|
160
|
+
accessible={dismissOnBackdrop}
|
|
161
|
+
accessibilityRole="button"
|
|
162
|
+
accessibilityLabel="Dismiss overlay"
|
|
163
|
+
disabled={!dismissOnBackdrop}
|
|
164
|
+
onPress={() => state.set(false)}
|
|
165
|
+
style={{
|
|
166
|
+
position: 'absolute',
|
|
167
|
+
inset: 0,
|
|
168
|
+
backgroundColor: colors.foreground,
|
|
169
|
+
opacity: 0.35,
|
|
170
|
+
}}
|
|
171
|
+
/>
|
|
172
|
+
<View
|
|
173
|
+
{...props}
|
|
174
|
+
accessibilityViewIsModal
|
|
175
|
+
onAccessibilityEscape={() => state.set(false)}
|
|
176
|
+
style={[
|
|
177
|
+
{
|
|
178
|
+
backgroundColor: colors.popover,
|
|
179
|
+
padding: 20,
|
|
180
|
+
paddingTop: 20 + insets.top,
|
|
181
|
+
paddingBottom: 20 + insets.bottom,
|
|
182
|
+
paddingLeft: 20 + insets.left,
|
|
183
|
+
paddingRight: 20 + insets.right,
|
|
184
|
+
gap: 12,
|
|
185
|
+
borderRadius: side === 'center' ? 12 : 0,
|
|
186
|
+
maxHeight: '90%',
|
|
187
|
+
width: horizontal ? '85%' : undefined,
|
|
188
|
+
},
|
|
189
|
+
horizontal && { height: '100%', maxHeight: '100%' },
|
|
190
|
+
style,
|
|
191
|
+
]}
|
|
192
|
+
>
|
|
193
|
+
{swipeToDismiss && (
|
|
194
|
+
<Pressable
|
|
195
|
+
accessible
|
|
196
|
+
accessibilityRole="button"
|
|
197
|
+
accessibilityLabel="Close drawer"
|
|
198
|
+
onPress={() => state.set(false)}
|
|
199
|
+
>
|
|
200
|
+
<View
|
|
201
|
+
{...pan.panHandlers}
|
|
202
|
+
style={{ minHeight: 28, justifyContent: 'center', alignItems: 'center' }}
|
|
203
|
+
>
|
|
204
|
+
<View
|
|
205
|
+
style={{
|
|
206
|
+
width: 40,
|
|
207
|
+
height: 4,
|
|
208
|
+
borderRadius: 2,
|
|
209
|
+
backgroundColor: colors.border,
|
|
210
|
+
}}
|
|
211
|
+
/>
|
|
212
|
+
</View>
|
|
213
|
+
</Pressable>
|
|
214
|
+
)}
|
|
215
|
+
{content(children)}
|
|
216
|
+
</View>
|
|
217
|
+
</View>
|
|
218
|
+
</KeyboardAvoidingView>
|
|
219
|
+
</Modal>
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
export function OverlayTitle({ children, ...props }: ViewProps) {
|
|
223
|
+
const state = useOverlay();
|
|
224
|
+
return (
|
|
225
|
+
<View
|
|
226
|
+
{...props}
|
|
227
|
+
ref={state.heading}
|
|
228
|
+
accessible
|
|
229
|
+
accessibilityRole="header"
|
|
230
|
+
nativeID={`${state.id}-title`}
|
|
231
|
+
>
|
|
232
|
+
<LabelText style={{ fontSize: 18, fontWeight: '600' }}>{children}</LabelText>
|
|
233
|
+
</View>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
export const OverlayDescription = Muted;
|
|
237
|
+
export const OverlayHeader = Box;
|
|
238
|
+
export const OverlayFooter = ({ style, ...props }: ViewProps) => (
|
|
239
|
+
<Box {...props} style={row(style)} />
|
|
240
|
+
);
|
|
241
|
+
export function AlertDialogContent(props: React.ComponentProps<typeof OverlayContent>) {
|
|
242
|
+
return <OverlayContent {...props} dismissOnBackdrop={false} />;
|
|
243
|
+
}
|
|
244
|
+
export const AlertDialog = OverlayRoot;
|
|
245
|
+
export const AlertDialogTrigger = OverlayTrigger;
|
|
246
|
+
export const AlertDialogTitle = OverlayTitle;
|
|
247
|
+
export const AlertDialogDescription = Muted;
|
|
248
|
+
export const AlertDialogHeader = Box;
|
|
249
|
+
export const AlertDialogFooter = OverlayFooter;
|
|
250
|
+
export const AlertDialogAction = OverlayClose;
|
|
251
|
+
export const AlertDialogCancel = (props: ButtonProps) => (
|
|
252
|
+
<OverlayClose variant="outline" {...props} />
|
|
253
|
+
);
|
|
254
|
+
export const Popover = OverlayRoot;
|
|
255
|
+
export const PopoverTrigger = OverlayTrigger;
|
|
256
|
+
export const PopoverContent = OverlayContent;
|
|
257
|
+
export const PopoverClose = OverlayClose;
|
|
258
|
+
export const PopoverAnchor = Box;
|
|
259
|
+
export const Sheet = OverlayRoot;
|
|
260
|
+
export const SheetTrigger = OverlayTrigger;
|
|
261
|
+
export const SheetContent = ({
|
|
262
|
+
side = 'right',
|
|
263
|
+
...props
|
|
264
|
+
}: React.ComponentProps<typeof OverlayContent>) => <OverlayContent side={side} {...props} />;
|
|
265
|
+
export const SheetClose = OverlayClose;
|
|
266
|
+
export const SheetHeader = Box;
|
|
267
|
+
export const SheetFooter = OverlayFooter;
|
|
268
|
+
export const SheetTitle = OverlayTitle;
|
|
269
|
+
export const SheetDescription = Muted;
|
|
270
|
+
export const Drawer = OverlayRoot;
|
|
271
|
+
export const DrawerTrigger = OverlayTrigger;
|
|
272
|
+
export const DrawerContent = (props: React.ComponentProps<typeof OverlayContent>) => (
|
|
273
|
+
<OverlayContent side="bottom" swipeToDismiss {...props} />
|
|
274
|
+
);
|
|
275
|
+
export const DrawerClose = OverlayClose;
|
|
276
|
+
export const DrawerHeader = Box;
|
|
277
|
+
export const DrawerFooter = OverlayFooter;
|
|
278
|
+
export const DrawerTitle = OverlayTitle;
|
|
279
|
+
export const DrawerDescription = Muted;
|
|
280
|
+
export const HoverCard = OverlayRoot;
|
|
281
|
+
export const HoverCardTrigger = LongPressTrigger;
|
|
282
|
+
export const HoverCardContent = OverlayContent;
|
|
283
|
+
export const TooltipProvider = ({ children }: { children: ReactNode }) => <>{children}</>;
|
|
284
|
+
export const Tooltip = OverlayRoot;
|
|
285
|
+
export const TooltipTrigger = LongPressTrigger;
|
|
286
|
+
export const TooltipContent = OverlayContent;
|
|
287
|
+
export const TooltipClose = OverlayClose;
|
|
288
|
+
export const DropdownMenu = OverlayRoot;
|
|
289
|
+
export const DropdownMenuTrigger = OverlayTrigger;
|
|
290
|
+
export const DropdownMenuContent = (props: React.ComponentProps<typeof OverlayContent>) => (
|
|
291
|
+
<OverlayContent accessibilityRole="menu" {...props} />
|
|
292
|
+
);
|
|
293
|
+
export const DropdownMenuLabel = Muted;
|
|
294
|
+
export const DropdownMenuGroup = Box;
|
|
295
|
+
export const DropdownMenuSeparator = ({ ...props }: ViewProps) => (
|
|
296
|
+
<Box {...props} style={{ height: 4 }} />
|
|
297
|
+
);
|
|
298
|
+
export function DropdownMenuItem({
|
|
299
|
+
onSelect,
|
|
300
|
+
onPress,
|
|
301
|
+
...props
|
|
302
|
+
}: ButtonProps & { onSelect?: (event: { preventDefault: () => void }) => void }) {
|
|
303
|
+
const state = useOverlay();
|
|
304
|
+
return (
|
|
305
|
+
<Button
|
|
306
|
+
variant="ghost"
|
|
307
|
+
{...props}
|
|
308
|
+
accessibilityRole="menuitem"
|
|
309
|
+
onPress={(event) => {
|
|
310
|
+
let prevented = false;
|
|
311
|
+
onPress?.(event);
|
|
312
|
+
onSelect?.({
|
|
313
|
+
preventDefault: () => {
|
|
314
|
+
prevented = true;
|
|
315
|
+
},
|
|
316
|
+
});
|
|
317
|
+
if (!prevented && !event.isDefaultPrevented()) state.set(false);
|
|
318
|
+
}}
|
|
319
|
+
/>
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
export const DropdownMenuShortcut = Muted;
|
|
323
|
+
export function DropdownMenuCheckboxItem({
|
|
324
|
+
checked = false,
|
|
325
|
+
onCheckedChange,
|
|
326
|
+
...props
|
|
327
|
+
}: ButtonProps & { checked?: boolean; onCheckedChange?: (checked: boolean) => void }) {
|
|
328
|
+
return (
|
|
329
|
+
<DropdownMenuItem
|
|
330
|
+
{...props}
|
|
331
|
+
accessibilityState={{ checked }}
|
|
332
|
+
onSelect={(event) => {
|
|
333
|
+
event.preventDefault();
|
|
334
|
+
onCheckedChange?.(!checked);
|
|
335
|
+
}}
|
|
336
|
+
>
|
|
337
|
+
<LabelText accessibilityElementsHidden>{checked ? '✓ ' : ' '}</LabelText>
|
|
338
|
+
{contentForMenu(props.children)}
|
|
339
|
+
</DropdownMenuItem>
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
function contentForMenu(children: ReactNode) {
|
|
343
|
+
return typeof children === 'string' ? <LabelText>{children}</LabelText> : children;
|
|
344
|
+
}
|
|
345
|
+
const MenuRadioContext = createContext({ value: '', change: (_value: string) => {} });
|
|
346
|
+
export function DropdownMenuRadioGroup({
|
|
347
|
+
value = '',
|
|
348
|
+
onValueChange = () => {},
|
|
349
|
+
children,
|
|
350
|
+
}: {
|
|
351
|
+
value?: string;
|
|
352
|
+
onValueChange?: (value: string) => void;
|
|
353
|
+
children: ReactNode;
|
|
354
|
+
}) {
|
|
355
|
+
return (
|
|
356
|
+
<MenuRadioContext.Provider value={{ value, change: onValueChange }}>
|
|
357
|
+
<Box>{children}</Box>
|
|
358
|
+
</MenuRadioContext.Provider>
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
export function DropdownMenuRadioItem({ value, ...props }: ButtonProps & { value: string }) {
|
|
362
|
+
const radio = useContext(MenuRadioContext);
|
|
363
|
+
return (
|
|
364
|
+
<DropdownMenuItem
|
|
365
|
+
{...props}
|
|
366
|
+
accessibilityState={{ checked: radio.value === value }}
|
|
367
|
+
onSelect={() => radio.change(value)}
|
|
368
|
+
/>
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
export const DropdownMenuSub = OverlayRoot;
|
|
372
|
+
export const DropdownMenuSubTrigger = OverlayTrigger;
|
|
373
|
+
export const DropdownMenuSubContent = DropdownMenuContent;
|
|
374
|
+
export const ContextMenu = OverlayRoot;
|
|
375
|
+
export const ContextMenuTrigger = LongPressTrigger;
|
|
376
|
+
export const ContextMenuContent = DropdownMenuContent;
|
|
377
|
+
export const ContextMenuItem = DropdownMenuItem;
|
|
378
|
+
export const ContextMenuCheckboxItem = DropdownMenuCheckboxItem;
|
|
379
|
+
export const ContextMenuRadioGroup = DropdownMenuRadioGroup;
|
|
380
|
+
export const ContextMenuRadioItem = DropdownMenuRadioItem;
|
|
381
|
+
export const ContextMenuLabel = Muted;
|
|
382
|
+
export const ContextMenuSeparator = DropdownMenuSeparator;
|
|
383
|
+
export const ContextMenuGroup = Box;
|
|
384
|
+
export const ContextMenuShortcut = Muted;
|
|
385
|
+
export const ContextMenuSub = OverlayRoot;
|
|
386
|
+
export const ContextMenuSubTrigger = OverlayTrigger;
|
|
387
|
+
export const ContextMenuSubContent = DropdownMenuContent;
|
|
388
|
+
export const Menubar = ({ style, ...props }: ViewProps) => <Box {...props} style={row(style)} />;
|
|
389
|
+
export const MenubarMenu = OverlayRoot;
|
|
390
|
+
export const MenubarTrigger = OverlayTrigger;
|
|
391
|
+
export const MenubarContent = DropdownMenuContent;
|
|
392
|
+
export const MenubarItem = DropdownMenuItem;
|
|
393
|
+
export const MenubarCheckboxItem = DropdownMenuCheckboxItem;
|
|
394
|
+
export const MenubarRadioGroup = DropdownMenuRadioGroup;
|
|
395
|
+
export const MenubarRadioItem = DropdownMenuRadioItem;
|
|
396
|
+
export const MenubarLabel = Muted;
|
|
397
|
+
export const MenubarSeparator = DropdownMenuSeparator;
|
|
398
|
+
export const MenubarGroup = Box;
|
|
399
|
+
export const MenubarShortcut = Muted;
|
|
400
|
+
export const MenubarSub = OverlayRoot;
|
|
401
|
+
export const MenubarSubTrigger = OverlayTrigger;
|
|
402
|
+
export const MenubarSubContent = DropdownMenuContent;
|