anhedral 0.16.0 → 0.18.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 +42 -20
- package/assets/contracts/LICENSE +201 -0
- package/assets/contracts/LICENSE.environment +201 -0
- package/assets/contracts/LICENSE.operations +201 -0
- package/assets/contracts/deployment-provenance.json +15 -0
- package/assets/contracts/environment-provenance.json +11 -0
- package/assets/contracts/operations-provenance.json +11 -0
- package/assets/launch/application.server.ts.txt +13 -0
- package/assets/launch/auth-client.ts.txt +4 -0
- package/assets/launch/home.tsx.txt +20 -0
- package/assets/launch/minimal-application.server.ts.txt +5 -0
- package/assets/launch/minimal-server.ts.txt +7 -0
- package/assets/launch/request-context.ts.txt +3 -0
- package/assets/launch/root.tsx.txt +27 -0
- package/assets/launch/router.tsx.txt +21 -0
- package/assets/launch/server.ts.txt +13 -0
- package/assets/launch/sign-in.tsx.txt +53 -0
- package/assets/launch/styles.css.txt +19 -0
- package/assets/security/credential-patterns.d.mts +3 -0
- package/assets/security/credential-patterns.mjs +59 -0
- package/assets/stack/api-index.ts.txt +6 -1
- package/assets/stack/event-retention.sql.txt +10 -0
- package/assets/stack/stripe.ts.txt +30 -13
- package/assets/ui/UPSTREAM.json +1 -18
- package/dist/bin.js +55 -36
- package/dist/capabilities.d.ts +1 -1
- package/dist/capability-catalog.d.ts +44 -11
- package/dist/capability-catalog.js +96 -11
- package/dist/capability-command.d.ts +2 -2
- package/dist/capability-command.js +178 -27
- package/dist/capability-editor.js +6 -5
- package/dist/capability-recipes.js +54 -6
- package/dist/cli-arguments.d.ts +2 -0
- package/dist/cli-arguments.js +101 -50
- package/dist/cli-commands.d.ts +1 -1
- package/dist/cli-commands.js +30 -6
- package/dist/cli-errors.d.ts +18 -0
- package/dist/cli-errors.js +63 -0
- package/dist/cli-output.d.ts +22 -0
- package/dist/cli-output.js +42 -7
- package/dist/command-runner.d.ts +1 -0
- package/dist/command-runner.js +88 -0
- package/dist/command-schema.d.ts +16 -0
- package/dist/command-schema.js +390 -21
- package/dist/completion.d.ts +2 -0
- package/dist/completion.js +201 -0
- package/dist/composition.d.ts +35 -0
- package/dist/composition.js +28 -0
- package/dist/contracts/cli-transport.d.ts +217 -0
- package/dist/contracts/cli-transport.js +167 -0
- package/dist/contracts/deployment.d.ts +282 -0
- package/dist/contracts/deployment.js +234 -0
- package/dist/contracts/environment-file.d.ts +7 -0
- package/dist/contracts/environment-file.js +112 -0
- package/dist/contracts/environment-transport.d.ts +79 -0
- package/dist/contracts/environment-transport.js +110 -0
- package/dist/contracts/runtime-logs-transport.d.ts +127 -0
- package/dist/contracts/runtime-logs-transport.js +50 -0
- package/dist/contracts/source-bundle.d.ts +11 -0
- package/dist/contracts/source-bundle.js +197 -0
- package/dist/contracts/source-profile.d.ts +4 -0
- package/dist/contracts/source-profile.js +5 -0
- package/dist/contracts/staging-transport.d.ts +79 -0
- package/dist/contracts/staging-transport.js +43 -0
- package/dist/dependencies.d.ts +10 -4
- package/dist/dependencies.js +17 -54
- package/dist/index.d.ts +6 -0
- package/dist/index.js +4 -0
- package/dist/launch.d.ts +21 -0
- package/dist/launch.js +250 -0
- package/dist/platform-command.d.ts +9 -0
- package/dist/platform-command.js +584 -0
- package/dist/platform-environment.d.ts +18 -0
- package/dist/platform-environment.js +257 -0
- package/dist/platform-operations.d.ts +26 -0
- package/dist/platform-operations.js +155 -0
- package/dist/platform-source.d.ts +8 -0
- package/dist/platform-source.js +111 -0
- package/dist/platform-state.d.ts +13 -0
- package/dist/platform-state.js +207 -0
- package/dist/platforms/tanstack.d.ts +8 -0
- package/dist/platforms/tanstack.js +155 -0
- package/dist/registry/options.js +34 -31
- package/dist/registry/resolve.js +2 -0
- package/dist/registry/usage.d.ts +4 -1
- package/dist/registry/usage.js +58 -4
- package/dist/scaffold/documentation.js +17 -48
- package/dist/scaffold/styling.d.ts +1 -1
- package/dist/scaffold/workspace.js +11 -7
- package/dist/stack-registry.d.ts +2 -4
- package/dist/stack-registry.js +1 -11
- package/dist/standard.js +21 -6
- package/dist/transaction.js +28 -3
- package/dist/ui-command.d.ts +4 -2
- package/dist/ui-command.js +79 -38
- package/dist/ui-project.d.ts +2 -0
- package/dist/ui-project.js +38 -8
- package/dist/util.js +40 -61
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/capabilities.md +22 -88
- package/docs/software-factory.md +189 -16
- package/docs/stack-standard.md +6 -18
- package/docs/ui.md +9 -22
- package/docs/verification.md +6 -1067
- package/package.json +33 -22
- package/assets/ui/native/_controls.tsx +0 -521
- package/assets/ui/native/_core.tsx +0 -118
- package/assets/ui/native/_data.tsx +0 -200
- package/assets/ui/native/_display.tsx +0 -453
- package/assets/ui/native/_feedback.tsx +0 -242
- package/assets/ui/native/_legacy-dialog.tsx +0 -38
- package/assets/ui/native/_motion.tsx +0 -520
- package/assets/ui/native/_overlay.tsx +0 -402
- package/assets/ui/native/_selection.tsx +0 -366
- package/assets/ui/native/accordion.tsx +0 -1
- package/assets/ui/native/alert-dialog.tsx +0 -11
- package/assets/ui/native/alert.tsx +0 -1
- package/assets/ui/native/aspect-ratio.tsx +0 -1
- package/assets/ui/native/attachment.tsx +0 -8
- package/assets/ui/native/avatar.tsx +0 -8
- package/assets/ui/native/badge.tsx +0 -1
- package/assets/ui/native/breadcrumb.tsx +0 -9
- package/assets/ui/native/bubble.tsx +0 -1
- package/assets/ui/native/button-group.tsx +0 -1
- package/assets/ui/native/button.tsx +0 -86
- package/assets/ui/native/calendar.tsx +0 -170
- package/assets/ui/native/card.tsx +0 -44
- package/assets/ui/native/carousel.tsx +0 -1
- package/assets/ui/native/chart.tsx +0 -193
- package/assets/ui/native/checkbox.tsx +0 -1
- package/assets/ui/native/code-block.tsx +0 -137
- package/assets/ui/native/collapsible.tsx +0 -1
- package/assets/ui/native/combobox.tsx +0 -1
- package/assets/ui/native/command.tsx +0 -11
- package/assets/ui/native/context-menu.tsx +0 -16
- package/assets/ui/native/data-table.tsx +0 -1
- package/assets/ui/native/date-picker.tsx +0 -43
- package/assets/ui/native/dialog.tsx +0 -15
- package/assets/ui/native/direction.tsx +0 -1
- package/assets/ui/native/drawer.tsx +0 -10
- package/assets/ui/native/dropdown-menu.tsx +0 -16
- package/assets/ui/native/empty.tsx +0 -8
- package/assets/ui/native/field.tsx +0 -13
- package/assets/ui/native/hover-card.tsx +0 -1
- package/assets/ui/native/input-group.tsx +0 -8
- package/assets/ui/native/input-otp.tsx +0 -1
- package/assets/ui/native/input.tsx +0 -28
- package/assets/ui/native/item.tsx +0 -12
- package/assets/ui/native/kbd.tsx +0 -1
- package/assets/ui/native/label.tsx +0 -4
- package/assets/ui/native/layout.tsx +0 -26
- package/assets/ui/native/marker.tsx +0 -1
- package/assets/ui/native/menubar.tsx +0 -17
- package/assets/ui/native/message-scroller.tsx +0 -6
- package/assets/ui/native/message.tsx +0 -10
- package/assets/ui/native/native-select.tsx +0 -1
- package/assets/ui/native/navigation-menu.tsx +0 -10
- package/assets/ui/native/pagination.tsx +0 -9
- package/assets/ui/native/popover.tsx +0 -1
- package/assets/ui/native/progress.tsx +0 -1
- package/assets/ui/native/questionnaire.tsx +0 -130
- package/assets/ui/native/radio-group.tsx +0 -1
- package/assets/ui/native/registry.json +0 -1103
- package/assets/ui/native/resizable.tsx +0 -1
- package/assets/ui/native/scroll-area.tsx +0 -1
- package/assets/ui/native/select.tsx +0 -11
- package/assets/ui/native/separator.tsx +0 -1
- package/assets/ui/native/sheet.tsx +0 -10
- package/assets/ui/native/sidebar.tsx +0 -22
- package/assets/ui/native/skeleton.tsx +0 -1
- package/assets/ui/native/slider.tsx +0 -1
- package/assets/ui/native/spinner.tsx +0 -1
- package/assets/ui/native/switch.tsx +0 -1
- package/assets/ui/native/table.tsx +0 -10
- package/assets/ui/native/tabs.tsx +0 -1
- package/assets/ui/native/text.tsx +0 -20
- package/assets/ui/native/textarea.tsx +0 -1
- package/assets/ui/native/theme-switcher.tsx +0 -22
- package/assets/ui/native/toast.tsx +0 -11
- package/assets/ui/native/toggle-group.tsx +0 -1
- package/assets/ui/native/toggle.tsx +0 -1
- package/assets/ui/native/tooltip.tsx +0 -1
- package/assets/ui/native/trace.tsx +0 -20
- package/assets/ui/native/typography.tsx +0 -15
- package/assets/ui/theme-storage.ts +0 -25
- package/assets/ui/theme.tsx +0 -66
- package/dist/platforms/mobile.d.ts +0 -2
- package/dist/platforms/mobile.js +0 -137
- package/dist/scaffold/expo-runtime.d.ts +0 -3
- package/dist/scaffold/expo-runtime.js +0 -42
- package/dist/scaffold/native-ui.d.ts +0 -2
- package/dist/scaffold/native-ui.js +0 -74
- package/docs/anhedral-stack.md +0 -7
- package/docs/native-ui.md +0 -102
|
@@ -1,366 +0,0 @@
|
|
|
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>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from './_controls';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Alert, AlertTitle, AlertDescription } from './_display';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { AspectRatio } from './_display';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Badge } from './_display';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Bubble, BubbleContent, BubbleActions, BubbleHeader, BubbleFooter } from './_display';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ButtonGroup, ButtonGroupText, ButtonGroupSeparator } from './_display';
|
|
@@ -1,86 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,170 +0,0 @@
|
|
|
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
|
-
}
|