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,366 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
createContext,
|
|
4
|
+
isValidElement,
|
|
5
|
+
useContext,
|
|
6
|
+
useState,
|
|
7
|
+
type ReactNode,
|
|
8
|
+
} from 'react';
|
|
9
|
+
import { View, ScrollView, type ViewProps, type TextInputProps } from 'react-native';
|
|
10
|
+
import { Box, LabelText, Muted, row, useControllable } from './_core';
|
|
11
|
+
import { Button, type ButtonProps } from './button';
|
|
12
|
+
import { Input } from './input';
|
|
13
|
+
import {
|
|
14
|
+
OverlayRoot,
|
|
15
|
+
OverlayTrigger,
|
|
16
|
+
OverlayContent,
|
|
17
|
+
useOverlay,
|
|
18
|
+
type OverlayProps,
|
|
19
|
+
} from './_overlay';
|
|
20
|
+
export type SelectOption = { value: string; label: string; disabled?: boolean };
|
|
21
|
+
const SelectContext = createContext<{
|
|
22
|
+
value: string;
|
|
23
|
+
set: (value: string) => void;
|
|
24
|
+
labels: Map<string, string>;
|
|
25
|
+
disabled: boolean;
|
|
26
|
+
} | null>(null);
|
|
27
|
+
function textOf(node: ReactNode): string {
|
|
28
|
+
return Children.toArray(node)
|
|
29
|
+
.map((child) =>
|
|
30
|
+
typeof child === 'string' || typeof child === 'number'
|
|
31
|
+
? String(child)
|
|
32
|
+
: isValidElement<{ children?: ReactNode }>(child)
|
|
33
|
+
? textOf(child.props.children)
|
|
34
|
+
: '',
|
|
35
|
+
)
|
|
36
|
+
.join('');
|
|
37
|
+
}
|
|
38
|
+
function itemLabels(node: ReactNode, labels = new Map<string, string>()) {
|
|
39
|
+
Children.forEach(node, (child) => {
|
|
40
|
+
if (isValidElement<{ value?: string; children?: ReactNode }>(child)) {
|
|
41
|
+
if (child.type === SelectItem && child.props.value)
|
|
42
|
+
labels.set(child.props.value, textOf(child.props.children));
|
|
43
|
+
itemLabels(child.props.children, labels);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return labels;
|
|
47
|
+
}
|
|
48
|
+
export function Select({
|
|
49
|
+
value,
|
|
50
|
+
defaultValue = '',
|
|
51
|
+
onValueChange,
|
|
52
|
+
disabled = false,
|
|
53
|
+
children,
|
|
54
|
+
...overlay
|
|
55
|
+
}: OverlayProps & {
|
|
56
|
+
value?: string;
|
|
57
|
+
defaultValue?: string;
|
|
58
|
+
onValueChange?: (value: string) => void;
|
|
59
|
+
disabled?: boolean;
|
|
60
|
+
}) {
|
|
61
|
+
const [selected, set] = useControllable(value, defaultValue, onValueChange);
|
|
62
|
+
return (
|
|
63
|
+
<SelectContext.Provider
|
|
64
|
+
value={{ value: selected, set, labels: itemLabels(children), disabled }}
|
|
65
|
+
>
|
|
66
|
+
<OverlayRoot {...overlay}>{children}</OverlayRoot>
|
|
67
|
+
</SelectContext.Provider>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
function useSelect() {
|
|
71
|
+
const value = useContext(SelectContext);
|
|
72
|
+
if (!value) throw Error('Select parts require Select.');
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
export function SelectTrigger(props: ButtonProps) {
|
|
76
|
+
const state = useSelect();
|
|
77
|
+
return (
|
|
78
|
+
<OverlayTrigger
|
|
79
|
+
variant="outline"
|
|
80
|
+
{...props}
|
|
81
|
+
disabled={state.disabled || props.disabled}
|
|
82
|
+
accessibilityRole="combobox"
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
export function SelectValue({
|
|
87
|
+
placeholder = 'Select an option',
|
|
88
|
+
children,
|
|
89
|
+
}: {
|
|
90
|
+
placeholder?: string;
|
|
91
|
+
children?: ReactNode;
|
|
92
|
+
}) {
|
|
93
|
+
const state = useSelect();
|
|
94
|
+
return (
|
|
95
|
+
<LabelText>
|
|
96
|
+
{children ?? (state.value ? (state.labels.get(state.value) ?? state.value) : placeholder)}
|
|
97
|
+
</LabelText>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
export function SelectContent({ children, ...props }: React.ComponentProps<typeof OverlayContent>) {
|
|
101
|
+
return (
|
|
102
|
+
<OverlayContent {...props}>
|
|
103
|
+
<ScrollView style={{ maxHeight: 400 }}>{children}</ScrollView>
|
|
104
|
+
</OverlayContent>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
export function SelectItem({ value, children, ...props }: ButtonProps & { value: string }) {
|
|
108
|
+
const selection = useSelect();
|
|
109
|
+
const overlay = useOverlay();
|
|
110
|
+
return (
|
|
111
|
+
<Button
|
|
112
|
+
variant="ghost"
|
|
113
|
+
{...props}
|
|
114
|
+
disabled={selection.disabled || props.disabled}
|
|
115
|
+
accessibilityRole="radio"
|
|
116
|
+
accessibilityState={{
|
|
117
|
+
checked: selection.value === value,
|
|
118
|
+
disabled: !!(selection.disabled || props.disabled),
|
|
119
|
+
}}
|
|
120
|
+
onPress={() => {
|
|
121
|
+
selection.set(value);
|
|
122
|
+
overlay.set(false);
|
|
123
|
+
}}
|
|
124
|
+
>
|
|
125
|
+
{children}
|
|
126
|
+
</Button>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
export const SelectGroup = Box;
|
|
130
|
+
export const SelectLabel = Muted;
|
|
131
|
+
export const SelectItemText = LabelText;
|
|
132
|
+
export const SelectSeparator = () => <View style={{ height: 8 }} />;
|
|
133
|
+
export function NativeSelect({
|
|
134
|
+
options,
|
|
135
|
+
value,
|
|
136
|
+
defaultValue,
|
|
137
|
+
onValueChange,
|
|
138
|
+
placeholder,
|
|
139
|
+
disabled,
|
|
140
|
+
accessibilityLabel,
|
|
141
|
+
}: {
|
|
142
|
+
options: SelectOption[];
|
|
143
|
+
value?: string;
|
|
144
|
+
defaultValue?: string;
|
|
145
|
+
onValueChange?: (value: string) => void;
|
|
146
|
+
placeholder?: string;
|
|
147
|
+
disabled?: boolean;
|
|
148
|
+
accessibilityLabel?: string;
|
|
149
|
+
}) {
|
|
150
|
+
return (
|
|
151
|
+
<Select
|
|
152
|
+
value={value}
|
|
153
|
+
defaultValue={defaultValue}
|
|
154
|
+
onValueChange={onValueChange}
|
|
155
|
+
disabled={disabled}
|
|
156
|
+
>
|
|
157
|
+
<SelectTrigger accessibilityLabel={accessibilityLabel}>
|
|
158
|
+
<SelectValue placeholder={placeholder} />
|
|
159
|
+
</SelectTrigger>
|
|
160
|
+
<SelectContent>
|
|
161
|
+
{options.map((item) => (
|
|
162
|
+
<SelectItem key={item.value} value={item.value} disabled={item.disabled}>
|
|
163
|
+
{item.label}
|
|
164
|
+
</SelectItem>
|
|
165
|
+
))}
|
|
166
|
+
</SelectContent>
|
|
167
|
+
</Select>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
export const NativeSelectOption = SelectItem;
|
|
171
|
+
export const NativeSelectOptGroup = SelectGroup;
|
|
172
|
+
export function Combobox({
|
|
173
|
+
options,
|
|
174
|
+
value,
|
|
175
|
+
defaultValue = '',
|
|
176
|
+
onValueChange,
|
|
177
|
+
placeholder = 'Select an option',
|
|
178
|
+
searchPlaceholder = 'Search options',
|
|
179
|
+
emptyText = 'No options found',
|
|
180
|
+
disabled,
|
|
181
|
+
accessibilityLabel,
|
|
182
|
+
}: {
|
|
183
|
+
options: SelectOption[];
|
|
184
|
+
value?: string;
|
|
185
|
+
defaultValue?: string;
|
|
186
|
+
onValueChange?: (value: string) => void;
|
|
187
|
+
placeholder?: string;
|
|
188
|
+
searchPlaceholder?: string;
|
|
189
|
+
emptyText?: string;
|
|
190
|
+
disabled?: boolean;
|
|
191
|
+
accessibilityLabel?: string;
|
|
192
|
+
}) {
|
|
193
|
+
const [selected, set] = useControllable(value, defaultValue, onValueChange);
|
|
194
|
+
const [open, setOpen] = useState(false);
|
|
195
|
+
const [query, setQuery] = useState('');
|
|
196
|
+
const filtered = options.filter((item) =>
|
|
197
|
+
item.label.toLocaleLowerCase().includes(query.toLocaleLowerCase()),
|
|
198
|
+
);
|
|
199
|
+
return (
|
|
200
|
+
<OverlayRoot
|
|
201
|
+
open={open}
|
|
202
|
+
onOpenChange={(next) => {
|
|
203
|
+
setOpen(next);
|
|
204
|
+
if (!next) setQuery('');
|
|
205
|
+
}}
|
|
206
|
+
>
|
|
207
|
+
<OverlayTrigger
|
|
208
|
+
variant="outline"
|
|
209
|
+
disabled={disabled}
|
|
210
|
+
accessibilityLabel={accessibilityLabel}
|
|
211
|
+
accessibilityRole="combobox"
|
|
212
|
+
>
|
|
213
|
+
{options.find((item) => item.value === selected)?.label ?? placeholder}
|
|
214
|
+
</OverlayTrigger>
|
|
215
|
+
<OverlayContent>
|
|
216
|
+
<Input
|
|
217
|
+
accessibilityLabel={searchPlaceholder}
|
|
218
|
+
placeholder={searchPlaceholder}
|
|
219
|
+
value={query}
|
|
220
|
+
onChangeText={setQuery}
|
|
221
|
+
/>
|
|
222
|
+
<ScrollView style={{ maxHeight: 300 }}>
|
|
223
|
+
{filtered.length ? (
|
|
224
|
+
filtered.map((item) => (
|
|
225
|
+
<Button
|
|
226
|
+
key={item.value}
|
|
227
|
+
disabled={item.disabled}
|
|
228
|
+
accessibilityRole="radio"
|
|
229
|
+
accessibilityState={{ checked: item.value === selected }}
|
|
230
|
+
onPress={() => {
|
|
231
|
+
set(item.value);
|
|
232
|
+
setOpen(false);
|
|
233
|
+
setQuery('');
|
|
234
|
+
}}
|
|
235
|
+
>
|
|
236
|
+
{item.label}
|
|
237
|
+
</Button>
|
|
238
|
+
))
|
|
239
|
+
) : (
|
|
240
|
+
<Muted accessibilityLiveRegion="polite">{emptyText}</Muted>
|
|
241
|
+
)}
|
|
242
|
+
</ScrollView>
|
|
243
|
+
</OverlayContent>
|
|
244
|
+
</OverlayRoot>
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
const CommandContext = createContext<{
|
|
248
|
+
query: string;
|
|
249
|
+
setQuery: (value: string) => void;
|
|
250
|
+
value: string;
|
|
251
|
+
setValue: (value: string) => void;
|
|
252
|
+
count: number;
|
|
253
|
+
} | null>(null);
|
|
254
|
+
function commandCount(node: ReactNode, query: string): number {
|
|
255
|
+
let count = 0;
|
|
256
|
+
Children.forEach(node, (child) => {
|
|
257
|
+
if (!isValidElement<{ value?: string; keywords?: string[]; children?: ReactNode }>(child))
|
|
258
|
+
return;
|
|
259
|
+
if (
|
|
260
|
+
child.type === CommandItem &&
|
|
261
|
+
[child.props.value, ...(child.props.keywords ?? [])]
|
|
262
|
+
.join(' ')
|
|
263
|
+
.toLocaleLowerCase()
|
|
264
|
+
.includes(query.toLocaleLowerCase())
|
|
265
|
+
)
|
|
266
|
+
count++;
|
|
267
|
+
else count += commandCount(child.props.children, query);
|
|
268
|
+
});
|
|
269
|
+
return count;
|
|
270
|
+
}
|
|
271
|
+
export function Command({
|
|
272
|
+
children,
|
|
273
|
+
value,
|
|
274
|
+
defaultValue = '',
|
|
275
|
+
onValueChange,
|
|
276
|
+
...props
|
|
277
|
+
}: ViewProps & { value?: string; defaultValue?: string; onValueChange?: (value: string) => void }) {
|
|
278
|
+
const [query, setQuery] = useState('');
|
|
279
|
+
const [selected, setValue] = useControllable(value, defaultValue, onValueChange);
|
|
280
|
+
return (
|
|
281
|
+
<CommandContext.Provider
|
|
282
|
+
value={{ query, setQuery, value: selected, setValue, count: commandCount(children, query) }}
|
|
283
|
+
>
|
|
284
|
+
<Box {...props}>{children}</Box>
|
|
285
|
+
</CommandContext.Provider>
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
function useCommand() {
|
|
289
|
+
const value = useContext(CommandContext);
|
|
290
|
+
if (!value) throw Error('Command parts require Command.');
|
|
291
|
+
return value;
|
|
292
|
+
}
|
|
293
|
+
export function CommandInput(props: TextInputProps) {
|
|
294
|
+
const state = useCommand();
|
|
295
|
+
return (
|
|
296
|
+
<Input
|
|
297
|
+
accessibilityLabel="Search commands"
|
|
298
|
+
{...props}
|
|
299
|
+
value={state.query}
|
|
300
|
+
onChangeText={state.setQuery}
|
|
301
|
+
/>
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
export const CommandList = ({ children, ...props }: React.ComponentProps<typeof ScrollView>) => (
|
|
305
|
+
<ScrollView {...props} style={[{ maxHeight: 350 }, props.style]}>
|
|
306
|
+
{children}
|
|
307
|
+
</ScrollView>
|
|
308
|
+
);
|
|
309
|
+
export function CommandEmpty(props: React.ComponentProps<typeof Muted>) {
|
|
310
|
+
return useCommand().count ? null : <Muted accessibilityLiveRegion="polite" {...props} />;
|
|
311
|
+
}
|
|
312
|
+
export function CommandGroup({ heading, ...props }: ViewProps & { heading?: string }) {
|
|
313
|
+
return (
|
|
314
|
+
<Box>
|
|
315
|
+
{heading && <Muted accessibilityRole="header">{heading}</Muted>}
|
|
316
|
+
<Box {...props} />
|
|
317
|
+
</Box>
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
export function CommandItem({
|
|
321
|
+
value,
|
|
322
|
+
keywords = [],
|
|
323
|
+
onSelect,
|
|
324
|
+
children,
|
|
325
|
+
...props
|
|
326
|
+
}: ButtonProps & { value: string; keywords?: string[]; onSelect?: (value: string) => void }) {
|
|
327
|
+
const state = useCommand();
|
|
328
|
+
if (![value, ...keywords].join(' ').toLocaleLowerCase().includes(state.query.toLocaleLowerCase()))
|
|
329
|
+
return null;
|
|
330
|
+
return (
|
|
331
|
+
<Button
|
|
332
|
+
variant="ghost"
|
|
333
|
+
{...props}
|
|
334
|
+
accessibilityState={{ selected: state.value === value, disabled: !!props.disabled }}
|
|
335
|
+
onPress={() => {
|
|
336
|
+
state.setValue(value);
|
|
337
|
+
onSelect?.(value);
|
|
338
|
+
}}
|
|
339
|
+
>
|
|
340
|
+
{children}
|
|
341
|
+
</Button>
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
export const CommandSeparator = SelectSeparator;
|
|
345
|
+
export const CommandShortcut = Muted;
|
|
346
|
+
export function CommandDialog({ children, ...props }: OverlayProps) {
|
|
347
|
+
return (
|
|
348
|
+
<OverlayRoot {...props}>
|
|
349
|
+
<OverlayContent>
|
|
350
|
+
<Command>{children}</Command>
|
|
351
|
+
</OverlayContent>
|
|
352
|
+
</OverlayRoot>
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
export const NavigationMenu = ({ style, ...props }: ViewProps) => (
|
|
356
|
+
<Box {...props} style={row(style)} />
|
|
357
|
+
);
|
|
358
|
+
export const NavigationMenuList = NavigationMenu;
|
|
359
|
+
export const NavigationMenuItem = OverlayRoot;
|
|
360
|
+
export const NavigationMenuTrigger = OverlayTrigger;
|
|
361
|
+
export const NavigationMenuContent = OverlayContent;
|
|
362
|
+
export const NavigationMenuLink = (props: ButtonProps) => (
|
|
363
|
+
<Button variant="link" {...props} accessibilityRole="link" />
|
|
364
|
+
);
|
|
365
|
+
export const NavigationMenuViewport = Box;
|
|
366
|
+
export const NavigationMenuIndicator = () => <LabelText accessibilityElementsHidden>▾</LabelText>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from './_controls';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Alert, AlertTitle, AlertDescription } from './_display';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AspectRatio } from './_display';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Badge } from './_display';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Bubble, BubbleContent, BubbleActions, BubbleHeader, BubbleFooter } from './_display';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ButtonGroup, ButtonGroupText, ButtonGroupSeparator } from './_display';
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Pressable, Text, StyleSheet, type View, type PressableProps } from 'react-native';
|
|
2
|
+
import { Children, type ReactNode, type Ref } from 'react';
|
|
3
|
+
import { useTheme } from '../theme';
|
|
4
|
+
export type ButtonProps = Omit<PressableProps, 'children'> & {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
ref?: Ref<View>;
|
|
7
|
+
variant?: 'default' | 'outline' | 'secondary' | 'ghost' | 'destructive' | 'link';
|
|
8
|
+
size?: 'default' | 'sm' | 'lg' | 'icon';
|
|
9
|
+
};
|
|
10
|
+
const sizes = {
|
|
11
|
+
default: { minHeight: 44 },
|
|
12
|
+
sm: { minHeight: 44 },
|
|
13
|
+
lg: { minHeight: 48 },
|
|
14
|
+
icon: { minHeight: 44, minWidth: 44 },
|
|
15
|
+
};
|
|
16
|
+
export function Button({
|
|
17
|
+
children,
|
|
18
|
+
variant = 'default',
|
|
19
|
+
size = 'default',
|
|
20
|
+
style,
|
|
21
|
+
disabled,
|
|
22
|
+
accessibilityState,
|
|
23
|
+
accessibilityRole = 'button',
|
|
24
|
+
...props
|
|
25
|
+
}: ButtonProps) {
|
|
26
|
+
const { colors } = useTheme();
|
|
27
|
+
const backgrounds = {
|
|
28
|
+
default: colors.primary,
|
|
29
|
+
secondary: colors.secondary,
|
|
30
|
+
outline: colors.background,
|
|
31
|
+
ghost: 'transparent',
|
|
32
|
+
destructive: 'transparent',
|
|
33
|
+
link: 'transparent',
|
|
34
|
+
};
|
|
35
|
+
const foregrounds = {
|
|
36
|
+
default: colors['primary-foreground'],
|
|
37
|
+
secondary: colors.foreground,
|
|
38
|
+
outline: colors.foreground,
|
|
39
|
+
ghost: colors.foreground,
|
|
40
|
+
destructive: colors.destructive,
|
|
41
|
+
link: colors.primary,
|
|
42
|
+
};
|
|
43
|
+
const surface = {
|
|
44
|
+
backgroundColor: backgrounds[variant],
|
|
45
|
+
borderColor: variant === 'outline' ? colors.border : 'transparent',
|
|
46
|
+
};
|
|
47
|
+
return (
|
|
48
|
+
<Pressable
|
|
49
|
+
{...props}
|
|
50
|
+
accessibilityRole={accessibilityRole}
|
|
51
|
+
accessibilityState={{ ...accessibilityState, disabled: !!disabled }}
|
|
52
|
+
disabled={disabled}
|
|
53
|
+
style={(state) => [
|
|
54
|
+
styles.button,
|
|
55
|
+
sizes[size],
|
|
56
|
+
surface,
|
|
57
|
+
disabled && styles.disabled,
|
|
58
|
+
state.pressed && styles.pressed,
|
|
59
|
+
typeof style === 'function' ? style(state) : style,
|
|
60
|
+
]}
|
|
61
|
+
>
|
|
62
|
+
{Children.map(children, (child) =>
|
|
63
|
+
typeof child === 'string' || typeof child === 'number' ? (
|
|
64
|
+
<Text style={[styles.label, { color: foregrounds[variant] }]}>{child}</Text>
|
|
65
|
+
) : (
|
|
66
|
+
child
|
|
67
|
+
),
|
|
68
|
+
)}
|
|
69
|
+
</Pressable>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
const styles = StyleSheet.create({
|
|
73
|
+
button: {
|
|
74
|
+
borderRadius: 8,
|
|
75
|
+
borderWidth: 1,
|
|
76
|
+
paddingHorizontal: 12,
|
|
77
|
+
paddingVertical: 10,
|
|
78
|
+
flexDirection: 'row',
|
|
79
|
+
gap: 6,
|
|
80
|
+
alignItems: 'center',
|
|
81
|
+
justifyContent: 'center',
|
|
82
|
+
},
|
|
83
|
+
label: { fontSize: 14, fontWeight: '500' },
|
|
84
|
+
disabled: { opacity: 0.5 },
|
|
85
|
+
pressed: { opacity: 0.75 },
|
|
86
|
+
});
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { View, type ViewProps } from 'react-native';
|
|
3
|
+
import { Box, LabelText, row, useControllable } from './_core';
|
|
4
|
+
import { Button } from './button';
|
|
5
|
+
export type DateRange = { from?: Date; to?: Date };
|
|
6
|
+
type Common = ViewProps & {
|
|
7
|
+
month?: Date;
|
|
8
|
+
defaultMonth?: Date;
|
|
9
|
+
onMonthChange?: (month: Date) => void;
|
|
10
|
+
disabled?: (date: Date) => boolean;
|
|
11
|
+
fromDate?: Date;
|
|
12
|
+
toDate?: Date;
|
|
13
|
+
locale?: string;
|
|
14
|
+
weekStartsOn?: number;
|
|
15
|
+
showOutsideDays?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export type CalendarProps = Common &
|
|
18
|
+
(
|
|
19
|
+
| { mode?: 'single'; selected?: Date; onSelect?: (date: Date | undefined) => void }
|
|
20
|
+
| { mode: 'multiple'; selected?: Date[]; onSelect?: (dates: Date[]) => void }
|
|
21
|
+
| { mode: 'range'; selected?: DateRange; onSelect?: (range: DateRange) => void }
|
|
22
|
+
);
|
|
23
|
+
const dayKey = (date: Date) =>
|
|
24
|
+
new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
|
|
25
|
+
export function Calendar(props: CalendarProps) {
|
|
26
|
+
const {
|
|
27
|
+
month,
|
|
28
|
+
defaultMonth = new Date(),
|
|
29
|
+
onMonthChange,
|
|
30
|
+
disabled,
|
|
31
|
+
fromDate,
|
|
32
|
+
toDate,
|
|
33
|
+
locale,
|
|
34
|
+
weekStartsOn = 0,
|
|
35
|
+
showOutsideDays = true,
|
|
36
|
+
style,
|
|
37
|
+
...view
|
|
38
|
+
} = props;
|
|
39
|
+
const [visible, setVisible] = useControllable(month, defaultMonth, onMonthChange);
|
|
40
|
+
const [internal, setInternal] = useState<Date | Date[] | DateRange | undefined>();
|
|
41
|
+
const controlled = Object.prototype.hasOwnProperty.call(props, 'selected');
|
|
42
|
+
const selected = controlled ? props.selected : internal;
|
|
43
|
+
const start = new Date(visible.getFullYear(), visible.getMonth(), 1);
|
|
44
|
+
const weekStart = ((Math.trunc(weekStartsOn) % 7) + 7) % 7;
|
|
45
|
+
const offset = (start.getDay() - weekStart + 7) % 7;
|
|
46
|
+
const count =
|
|
47
|
+
Math.ceil((offset + new Date(visible.getFullYear(), visible.getMonth() + 1, 0).getDate()) / 7) *
|
|
48
|
+
7;
|
|
49
|
+
const same = (date: Date, other?: Date) =>
|
|
50
|
+
other instanceof Date && dayKey(date) === dayKey(other);
|
|
51
|
+
function select(date: Date) {
|
|
52
|
+
if (props.mode === 'multiple') {
|
|
53
|
+
const current = Array.isArray(selected) ? selected : [];
|
|
54
|
+
const next = current.some((item) => same(date, item))
|
|
55
|
+
? current.filter((item) => !same(date, item))
|
|
56
|
+
: [...current, date];
|
|
57
|
+
if (!controlled) setInternal(next);
|
|
58
|
+
props.onSelect?.(next);
|
|
59
|
+
} else if (props.mode === 'range') {
|
|
60
|
+
const current =
|
|
61
|
+
selected && !(selected instanceof Date) && !Array.isArray(selected) ? selected : {};
|
|
62
|
+
const next =
|
|
63
|
+
!current.from || current.to
|
|
64
|
+
? { from: date }
|
|
65
|
+
: dayKey(date) < dayKey(current.from)
|
|
66
|
+
? { from: date, to: current.from }
|
|
67
|
+
: { from: current.from, to: date };
|
|
68
|
+
if (!controlled) setInternal(next);
|
|
69
|
+
props.onSelect?.(next);
|
|
70
|
+
} else {
|
|
71
|
+
const next = selected instanceof Date && same(date, selected) ? undefined : date;
|
|
72
|
+
if (!controlled) setInternal(next);
|
|
73
|
+
props.onSelect?.(next);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const blocked = (date: Date) =>
|
|
77
|
+
!!disabled?.(date) ||
|
|
78
|
+
(!!fromDate && dayKey(date) < dayKey(fromDate)) ||
|
|
79
|
+
(!!toDate && dayKey(date) > dayKey(toDate));
|
|
80
|
+
function highlighted(date: Date) {
|
|
81
|
+
if (selected instanceof Date) return same(date, selected);
|
|
82
|
+
if (Array.isArray(selected)) return selected.some((item) => same(date, item));
|
|
83
|
+
return (
|
|
84
|
+
!!selected?.from &&
|
|
85
|
+
dayKey(date) >= dayKey(selected.from) &&
|
|
86
|
+
dayKey(date) <= dayKey(selected.to ?? selected.from)
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
const previous = new Date(start.getFullYear(), start.getMonth() - 1, 1);
|
|
90
|
+
const next = new Date(start.getFullYear(), start.getMonth() + 1, 1);
|
|
91
|
+
// Selection props belong to Calendar, never to the native host view.
|
|
92
|
+
const host: ViewProps = { ...view };
|
|
93
|
+
delete (host as Partial<CalendarProps>).selected;
|
|
94
|
+
delete (host as Partial<CalendarProps>).onSelect;
|
|
95
|
+
delete (host as Partial<CalendarProps>).mode;
|
|
96
|
+
return (
|
|
97
|
+
<Box {...host} style={style}>
|
|
98
|
+
<View style={row({ justifyContent: 'space-between' })}>
|
|
99
|
+
<Button
|
|
100
|
+
variant="ghost"
|
|
101
|
+
accessibilityLabel="Previous month"
|
|
102
|
+
disabled={
|
|
103
|
+
!!fromDate &&
|
|
104
|
+
new Date(previous.getFullYear(), previous.getMonth() + 1, 0).getTime() <
|
|
105
|
+
dayKey(fromDate)
|
|
106
|
+
}
|
|
107
|
+
onPress={() => setVisible(previous)}
|
|
108
|
+
>
|
|
109
|
+
‹
|
|
110
|
+
</Button>
|
|
111
|
+
<LabelText accessibilityRole="header" accessibilityLiveRegion="polite">
|
|
112
|
+
{start.toLocaleDateString(locale, { month: 'long', year: 'numeric' })}
|
|
113
|
+
</LabelText>
|
|
114
|
+
<Button
|
|
115
|
+
variant="ghost"
|
|
116
|
+
accessibilityLabel="Next month"
|
|
117
|
+
disabled={!!toDate && dayKey(next) > dayKey(toDate)}
|
|
118
|
+
onPress={() => setVisible(next)}
|
|
119
|
+
>
|
|
120
|
+
›
|
|
121
|
+
</Button>
|
|
122
|
+
</View>
|
|
123
|
+
<View style={{ flexDirection: 'row' }}>
|
|
124
|
+
{Array.from({ length: 7 }, (_, index) => (
|
|
125
|
+
<LabelText key={index} style={{ width: `${100 / 7}%`, textAlign: 'center' }}>
|
|
126
|
+
{new Date(2026, 0, 4 + weekStart + index).toLocaleDateString(locale, {
|
|
127
|
+
weekday: 'short',
|
|
128
|
+
})}
|
|
129
|
+
</LabelText>
|
|
130
|
+
))}
|
|
131
|
+
</View>
|
|
132
|
+
{Array.from({ length: count / 7 }, (_, week) => (
|
|
133
|
+
<View key={week} style={{ flexDirection: 'row' }}>
|
|
134
|
+
{Array.from({ length: 7 }, (_, column) => {
|
|
135
|
+
const date = new Date(
|
|
136
|
+
start.getFullYear(),
|
|
137
|
+
start.getMonth(),
|
|
138
|
+
week * 7 + column - offset + 1,
|
|
139
|
+
);
|
|
140
|
+
const outside = date.getMonth() !== start.getMonth();
|
|
141
|
+
return (
|
|
142
|
+
<View key={column} style={{ width: `${100 / 7}%` }}>
|
|
143
|
+
{outside && !showOutsideDays ? (
|
|
144
|
+
<View style={{ minHeight: 44 }} />
|
|
145
|
+
) : (
|
|
146
|
+
<Button
|
|
147
|
+
size="icon"
|
|
148
|
+
variant={highlighted(date) ? 'secondary' : 'ghost'}
|
|
149
|
+
disabled={blocked(date)}
|
|
150
|
+
accessibilityLabel={date.toLocaleDateString(locale, {
|
|
151
|
+
weekday: 'long',
|
|
152
|
+
year: 'numeric',
|
|
153
|
+
month: 'long',
|
|
154
|
+
day: 'numeric',
|
|
155
|
+
})}
|
|
156
|
+
accessibilityState={{ selected: highlighted(date), disabled: blocked(date) }}
|
|
157
|
+
onPress={() => select(date)}
|
|
158
|
+
style={{ opacity: outside ? 0.5 : 1, minWidth: 0, paddingHorizontal: 0 }}
|
|
159
|
+
>
|
|
160
|
+
{date.getDate()}
|
|
161
|
+
</Button>
|
|
162
|
+
)}
|
|
163
|
+
</View>
|
|
164
|
+
);
|
|
165
|
+
})}
|
|
166
|
+
</View>
|
|
167
|
+
))}
|
|
168
|
+
</Box>
|
|
169
|
+
);
|
|
170
|
+
}
|