@marktiderman/genesis-ui-native 3.3.0 → 3.5.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 +24 -0
- package/dist/{chunk-VZ3PQLZ4.js → chunk-ABVSSJNT.js} +3 -3
- package/dist/{chunk-VZ3PQLZ4.js.map → chunk-ABVSSJNT.js.map} +1 -1
- package/dist/{chunk-ZHVQTMNV.js → chunk-ONH2PCGH.js} +7 -4
- package/dist/chunk-ONH2PCGH.js.map +1 -0
- package/dist/data/index.d.ts +104 -7
- package/dist/data/index.js +407 -79
- package/dist/data/index.js.map +1 -1
- package/dist/{inbox-page-DZUR-PJ1.d.ts → inbox-page-BEarNEIP.d.ts} +11 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/layouts/index.d.ts +2 -2
- package/dist/layouts/index.js +2 -2
- package/package.json +3 -3
- package/src/data/NativeResourceFormField.tsx +12 -3
- package/src/data/resource-view/NativeLinkPicker.tsx +191 -0
- package/src/data/resource-view/NativeRecordView.tsx +15 -5
- package/src/data/resource-view/NativeResourceFormSheet.tsx +25 -1
- package/src/data/resource-view/NativeResourceView.tsx +296 -50
- package/src/data/resource-view/__tests__/native-link-picker.test.tsx +201 -0
- package/src/data/resource-view/__tests__/native-record-view.test.tsx +11 -0
- package/src/data/resource-view/__tests__/native-resource-view-delete.test.tsx +171 -0
- package/src/data/resource-view/__tests__/native-resource-view.test.tsx +226 -2
- package/src/data/resource-view/__tests__/native-tel-field.test.tsx +79 -0
- package/src/data/resource-view/index.ts +8 -1
- package/src/data/resource-view/mapping.ts +60 -7
- package/src/data/resource-view/messages.ts +25 -0
- package/src/data/resource-view/use-native-resource-view.ts +62 -13
- package/src/layouts/__tests__/screen-container.test.tsx +51 -2
- package/src/layouts/screen-container.tsx +20 -1
- package/dist/chunk-ZHVQTMNV.js.map +0 -1
|
@@ -42,6 +42,16 @@ interface ScreenContainerProps {
|
|
|
42
42
|
loading?: boolean;
|
|
43
43
|
/** Text under the spinner while `loading`, and what screen readers announce: pass translated text. */
|
|
44
44
|
loadingLabel?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Pull to refresh: a theme-tinted `NativeRefreshControl` on the body, as InboxPage and
|
|
47
|
+
* NotificationsPage have. Pulling needs a scroll view, so passing it makes the body scroll
|
|
48
|
+
* (as `scroll`). Off unless passed. Never with a list child (FlatList, SectionList,
|
|
49
|
+
* NativeResourceView, InboxPage): a list inside a ScrollView loses virtualization, and those
|
|
50
|
+
* lists have their own pull to refresh.
|
|
51
|
+
*/
|
|
52
|
+
onRefresh?: () => void | Promise<void>;
|
|
53
|
+
/** The refresh spinner shows while `true`: pass your query's refetching state. Default `false`. */
|
|
54
|
+
refreshing?: boolean;
|
|
45
55
|
/** Style on the root, e.g. a theme-role background color. */
|
|
46
56
|
style?: ViewStyle;
|
|
47
57
|
/** testID on the root container. */
|
|
@@ -82,7 +92,7 @@ interface ScreenHeaderProps {
|
|
|
82
92
|
* return <><Stack.Screen options={opts} /><ScreenContainer>...</ScreenContainer></>;
|
|
83
93
|
*/
|
|
84
94
|
declare function composeHeaderOptions(props: ScreenHeaderProps): Record<string, unknown>;
|
|
85
|
-
declare function ScreenContainer({ children, scroll, safeAreaEdges, statusBar, themeMode, className, contentClassName, keyboardShouldPersistTaps, loading, loadingLabel, style, testID, }: ScreenContainerProps): react.JSX.Element;
|
|
95
|
+
declare function ScreenContainer({ children, scroll, safeAreaEdges, statusBar, themeMode, className, contentClassName, keyboardShouldPersistTaps, loading, loadingLabel, onRefresh, refreshing, style, testID, }: ScreenContainerProps): react.JSX.Element;
|
|
86
96
|
|
|
87
97
|
/** An action on a row: swipe, long press, or an accessibility action. */
|
|
88
98
|
interface InboxSwipeAction {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Box, BoxBackground, BoxProps, FULL_SCREEN_DARK, FlexAlign, FlexJustify, Grid, GridProps, Inline, InlineProps, NativeAccordion, NativeAccordionContent, NativeAccordionContentProps, NativeAccordionItem, NativeAccordionItemProps, NativeAccordionProps, NativeAccordionTrigger, NativeAccordionTriggerProps, NativeAccordionType, NativeAlert, NativeAlertDescription, NativeAlertDescriptionProps, NativeAlertProps, NativeAlertTitle, NativeAlertTitleProps, NativeAvatar, NativeAvatarProps, NativeBadge, NativeBadgeProps, NativeBanner, NativeBannerProps, NativeButton, NativeButtonProps, NativeCard, NativeCardContent, NativeCardDescription, NativeCardFooter, NativeCardHeader, NativeCardProps, NativeCardTitle, NativeCardTitleProps, NativeCheckbox, NativeCheckboxProps, NativeChip, NativeChipGroup, NativeChipGroupMode, NativeChipGroupProps, NativeChipProps, NativeCombobox, NativeComboboxOption, NativeComboboxProps, NativeDatePicker, NativeDatePickerProps, NativeDialog, NativeDialogContent, NativeDialogContentProps, NativeDialogDescription, NativeDialogDescriptionProps, NativeDialogFooter, NativeDialogFooterProps, NativeDialogHeader, NativeDialogHeaderProps, NativeDialogProps, NativeDialogTitle, NativeDialogTitleProps, NativeDrawer, NativeDrawerProps, NativeDropdownMenu, NativeDropdownMenuContent, NativeDropdownMenuContentProps, NativeDropdownMenuItem, NativeDropdownMenuItemProps, NativeDropdownMenuProps, NativeDropdownMenuTrigger, NativeDropdownMenuTriggerProps, NativeEmptyState, NativeEmptyStateProps, NativeEmptyStateVariant, NativeFullScreenModal, NativeFullScreenModalProps, NativeGlassSurface, NativeGlassSurfaceProps, NativeHeaderCard, NativeHeaderCardProps, NativeIcon, NativeIconProps, NativeImage, NativeImageProps, NativeInlineAlert, NativeInlineAlertProps, NativeInlineAlertVariant, NativeInput, NativeInputProps, NativeLabel, NativeLabelProps, NativeListItem, NativeListItemDivider, NativeListItemProps, NativeLoadingState, NativeLoadingStateEdge, NativeLoadingStateProps, NativeNumberInput, NativeNumberInputProps, NativePagination, NativePaginationProps, NativePopover, NativePopoverContent, NativePopoverContentProps, NativePopoverProps, NativePopoverTrigger, NativePopoverTriggerProps, NativeProgress, NativeProgressProps, NativeRadioGroup, NativeRadioGroupItem, NativeRadioGroupItemProps, NativeRadioGroupProps, NativeRangeSlider, NativeRangeSliderProps, NativeRefreshControl, NativeRefreshControlProps, NativeSearchBar, NativeSearchBarProps, NativeSectionListHeader, NativeSectionListHeaderProps, NativeSegmentedControl, NativeSegmentedControlOption, NativeSegmentedControlProps, NativeSelect, NativeSelectContent, NativeSelectContentProps, NativeSelectItem, NativeSelectItemProps, NativeSelectProps, NativeSelectTrigger, NativeSelectTriggerProps, NativeSeparator, NativeSeparatorProps, NativeSheet, NativeSheetLibrary, NativeSheetProps, NativeSheetProvider, NativeSheetProviderProps, NativeSheetScrollView, NativeSkeleton, NativeSkeletonProps, NativeSlider, NativeSliderProps, NativeStepper, NativeStepperProps, NativeStepperStep, NativeSwitch, NativeSwitchProps, NativeTabs, NativeTabsContent, NativeTabsContentProps, NativeTabsList, NativeTabsListProps, NativeTabsProps, NativeTabsTrigger, NativeTabsTriggerProps, NativeText, NativeTextProps, NativeTextarea, NativeTextareaProps, NativeTimePicker, NativeTimePickerProps, NativeToastOptions, NativeToastProvider, NativeToastProviderProps, NativeToastVariant, NativeToggle, NativeToggleProps, NativeTooltip, NativeTooltipContent, NativeTooltipContentProps, NativeTooltipProps, NativeTooltipTrigger, NativeTooltipTriggerProps, SpaceToken, SpacingPrefix, Stack, StackProps, TextPreset, alertVariants, badgeTextVariants, badgeVariants, buttonTextVariants, buttonVariants, spaceScale, spacingClass, textVariants, toggleVariants, useLiquidGlass, useReduceTransparency, useToast } from './components/index.js';
|
|
2
2
|
export { G as GenesisDatePickerComponent, a as GenesisDatePickerProps, b as GenesisGlassModule, c as GenesisIconComponent, d as GenesisIconSet, e as GenesisImageComponent, f as GenesisImageProps, g as GenesisListComponent, h as GenesisListProps, i as GenesisModules, j as GenesisModulesProvider, k as GenesisModulesProviderProps, l as GenesisNavigationModule, m as GenesisNavigationTheme, n as GenesisReanimatedModule, o as GenesisSymbolComponent, p as GenesisSymbolProps, N as NATIVE_ICON_NAMES, q as NativeIconName, S as SF_SYMBOLS, u as useGenesisModules } from './native-modules-PwnGltOU.js';
|
|
3
3
|
export { BrandExtensionsProvider, BrandExtensionsProviderProps, BrandExtensionsValue, ThemeMode, ThemeRoleColors, UseThemeRolesOptions, useGenesisExtension, useReducedMotion, useThemeMode, useThemeRoles } from './hooks/index.js';
|
|
4
|
-
export { I as InboxItem, a as InboxPage, b as InboxPageProps, c as InboxPageSlotMap, d as InboxSwipeAction, S as SafeAreaEdge, e as ScreenContainer, f as ScreenContainerProps, g as ScreenHeaderProps, h as ScrollEdgeBehavior, i as composeHeaderOptions, j as formatInboxTime, k as getInboxPageStackOptions, s as showInboxActions } from './inbox-page-
|
|
4
|
+
export { I as InboxItem, a as InboxPage, b as InboxPageProps, c as InboxPageSlotMap, d as InboxSwipeAction, S as SafeAreaEdge, e as ScreenContainer, f as ScreenContainerProps, g as ScreenHeaderProps, h as ScrollEdgeBehavior, i as composeHeaderOptions, j as formatInboxTime, k as getInboxPageStackOptions, s as showInboxActions } from './inbox-page-BEarNEIP.js';
|
|
5
5
|
export { AppleButtonModuleLike, AppleProviderOptions, AppleSignInButton, AppleSignInButtonProps, AuthBranding, AuthBrandingProps, AuthForm, AuthFormProps, AuthFormValues, AuthScreen, AuthScreenProps, AuthScreenSlotMap, ForgotPasswordLink, GoogleProviderOptions, KEYBOARD_TOOLBAR_HEIGHT, KeyboardScrollProps, KeyboardScrollProvider, KeyboardToolbarProps, NavBarSaveButton, NavBarSaveButtonProps, NavBarSearchBar, NavBarSearchBarProps, NavBarTitle, NavBarTitleProps, NotificationItem, NotificationsPage, NotificationsPageProps, NotificationsPageSlotMap, SettingsPage, SettingsPageDangerousAction, SettingsPageProps, SettingsPageRow, SettingsPageSection, SettingsPageSlotMap, SettingsSubPage, SettingsSubPageProps, SocialAuthProvider, SocialAuthRow, SocialAuthRowProps, ThreadAttachment, ThreadComposer, ThreadLabels, ThreadMessage, ThreadPage, ThreadPageProps, ThreadPageSlotMap, appleProvider, confirmDiscardChanges, defaultStickyHeaderOffset, getNotificationsPageStackOptions, getSettingsPageStackOptions, getSettingsSubPageStackOptions, getThreadPageStackOptions, googleProvider, iosCompactNavigationBarHeight, readReceiptFor, useKeyboardScroll, useKeyboardToolbar } from './layouts/index.js';
|
|
6
6
|
export { cn } from './utils.js';
|
|
7
7
|
import 'react';
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@ export { Box, FULL_SCREEN_DARK, Grid, Inline, NativeAccordion, NativeAccordionCo
|
|
|
2
2
|
export { NativeAlert, NativeAlertDescription, NativeAlertTitle, NativeAvatar, NativeBanner, NativeCard, NativeCardContent, NativeCardDescription, NativeCardFooter, NativeCardHeader, NativeCardTitle, NativeCheckbox, NativeDatePicker, NativeImage, NativeInlineAlert, NativeLabel, NativeSearchBar, NativeSegmentedControl, NativeSelect, NativeSelectContent, NativeSelectItem, NativeSelectTrigger, NativeSeparator, NativeSheet, NativeSheetProvider, NativeSheetScrollView, NativeSkeleton, NativeSwitch, NativeTextarea, NativeTimePicker, alertVariants } from './chunk-GHYUNNNU.js';
|
|
3
3
|
export { BrandExtensionsProvider, useGenesisExtension } from './chunk-D5RKSPMH.js';
|
|
4
4
|
export { useReducedMotion } from './chunk-7PCWEY6R.js';
|
|
5
|
-
export { AppleSignInButton, AuthBranding, AuthForm, AuthScreen, ForgotPasswordLink, KEYBOARD_TOOLBAR_HEIGHT, KeyboardScrollProvider, NotificationsPage, SettingsPage, SettingsSubPage, SocialAuthRow, ThreadPage, appleProvider, confirmDiscardChanges, defaultStickyHeaderOffset, getNotificationsPageStackOptions, getSettingsPageStackOptions, getSettingsSubPageStackOptions, getThreadPageStackOptions, googleProvider, iosCompactNavigationBarHeight, readReceiptFor, useKeyboardScroll, useKeyboardToolbar } from './chunk-
|
|
6
|
-
export { InboxPage, NavBarSaveButton, NavBarSearchBar, NavBarTitle, ScreenContainer, composeHeaderOptions, formatInboxTime, getInboxPageStackOptions, showInboxActions } from './chunk-
|
|
5
|
+
export { AppleSignInButton, AuthBranding, AuthForm, AuthScreen, ForgotPasswordLink, KEYBOARD_TOOLBAR_HEIGHT, KeyboardScrollProvider, NotificationsPage, SettingsPage, SettingsSubPage, SocialAuthRow, ThreadPage, appleProvider, confirmDiscardChanges, defaultStickyHeaderOffset, getNotificationsPageStackOptions, getSettingsPageStackOptions, getSettingsSubPageStackOptions, getThreadPageStackOptions, googleProvider, iosCompactNavigationBarHeight, readReceiptFor, useKeyboardScroll, useKeyboardToolbar } from './chunk-ABVSSJNT.js';
|
|
6
|
+
export { InboxPage, NavBarSaveButton, NavBarSearchBar, NavBarTitle, ScreenContainer, composeHeaderOptions, formatInboxTime, getInboxPageStackOptions, showInboxActions } from './chunk-ONH2PCGH.js';
|
|
7
7
|
export { GenesisModulesProvider, NATIVE_ICON_NAMES, NativeBadge, NativeButton, NativeEmptyState, NativeIcon, NativeInput, NativeListItem, NativeListItemDivider, NativeLoadingState, NativeRefreshControl, NativeSectionListHeader, NativeText, SF_SYMBOLS, badgeTextVariants, badgeVariants, buttonTextVariants, buttonVariants, textVariants, useGenesisModules } from './chunk-6KWEAGRD.js';
|
|
8
8
|
export { useThemeMode, useThemeRoles } from './chunk-Z3AQYVUA.js';
|
|
9
9
|
export { cn } from './chunk-OHZD7KRO.js';
|
package/dist/layouts/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as ScreenHeaderProps } from '../inbox-page-
|
|
2
|
-
export { I as InboxItem, a as InboxPage, b as InboxPageProps, c as InboxPageSlotMap, d as InboxSwipeAction, S as SafeAreaEdge, e as ScreenContainer, f as ScreenContainerProps, h as ScrollEdgeBehavior, i as composeHeaderOptions, j as formatInboxTime, k as getInboxPageStackOptions, s as showInboxActions } from '../inbox-page-
|
|
1
|
+
import { g as ScreenHeaderProps } from '../inbox-page-BEarNEIP.js';
|
|
2
|
+
export { I as InboxItem, a as InboxPage, b as InboxPageProps, c as InboxPageSlotMap, d as InboxSwipeAction, S as SafeAreaEdge, e as ScreenContainer, f as ScreenContainerProps, h as ScrollEdgeBehavior, i as composeHeaderOptions, j as formatInboxTime, k as getInboxPageStackOptions, s as showInboxActions } from '../inbox-page-BEarNEIP.js';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { ReactNode, ComponentType } from 'react';
|
|
5
5
|
import { Slots, SlotPropsFor } from '@marktiderman/genesis-core/slots';
|
package/dist/layouts/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { AppleSignInButton, AuthBranding, AuthForm, AuthScreen, ForgotPasswordLink, KEYBOARD_TOOLBAR_HEIGHT, KeyboardScrollProvider, NotificationsPage, SettingsPage, SettingsSubPage, SocialAuthRow, ThreadPage, appleProvider, confirmDiscardChanges, defaultStickyHeaderOffset, getNotificationsPageStackOptions, getSettingsPageStackOptions, getSettingsSubPageStackOptions, getThreadPageStackOptions, googleProvider, iosCompactNavigationBarHeight, readReceiptFor, useKeyboardScroll, useKeyboardToolbar } from '../chunk-
|
|
2
|
-
export { InboxPage, NavBarSaveButton, NavBarSearchBar, NavBarTitle, ScreenContainer, composeHeaderOptions, formatInboxTime, getInboxPageStackOptions, showInboxActions } from '../chunk-
|
|
1
|
+
export { AppleSignInButton, AuthBranding, AuthForm, AuthScreen, ForgotPasswordLink, KEYBOARD_TOOLBAR_HEIGHT, KeyboardScrollProvider, NotificationsPage, SettingsPage, SettingsSubPage, SocialAuthRow, ThreadPage, appleProvider, confirmDiscardChanges, defaultStickyHeaderOffset, getNotificationsPageStackOptions, getSettingsPageStackOptions, getSettingsSubPageStackOptions, getThreadPageStackOptions, googleProvider, iosCompactNavigationBarHeight, readReceiptFor, useKeyboardScroll, useKeyboardToolbar } from '../chunk-ABVSSJNT.js';
|
|
2
|
+
export { InboxPage, NavBarSaveButton, NavBarSearchBar, NavBarTitle, ScreenContainer, composeHeaderOptions, formatInboxTime, getInboxPageStackOptions, showInboxActions } from '../chunk-ONH2PCGH.js';
|
|
3
3
|
import '../chunk-6KWEAGRD.js';
|
|
4
4
|
import '../chunk-Z3AQYVUA.js';
|
|
5
5
|
import '../chunk-OHZD7KRO.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marktiderman/genesis-ui-native",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"@expo/ui": ">=58.0.0",
|
|
84
84
|
"@gorhom/bottom-sheet": ">=5.0.0",
|
|
85
85
|
"@hookform/resolvers": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0",
|
|
86
|
-
"@marktiderman/genesis-core": "^2.
|
|
87
|
-
"@marktiderman/genesis-design-system": "^1.
|
|
86
|
+
"@marktiderman/genesis-core": "^2.8.0",
|
|
87
|
+
"@marktiderman/genesis-design-system": "^1.7.0",
|
|
88
88
|
"@react-native-community/datetimepicker": ">=8.0.0",
|
|
89
89
|
"@shopify/flash-list": ">=2.0.0",
|
|
90
90
|
"@tanstack/react-query": "^5.0.0",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { titleCase } from "@marktiderman/genesis-core";
|
|
2
2
|
import type { ResourceFormFieldDef } from "@marktiderman/genesis-core";
|
|
3
3
|
import { Controller, type Control } from "react-hook-form";
|
|
4
|
-
import { Pressable, View } from "react-native";
|
|
4
|
+
import { Pressable, View, type TextInputProps } from "react-native";
|
|
5
5
|
import { NativeCheckbox } from "../components/checkbox";
|
|
6
6
|
import { NativeInput } from "../components/input";
|
|
7
7
|
import { NativeLabel } from "../components/label";
|
|
@@ -31,9 +31,10 @@ export interface NativeResourceFormFieldRendererProps {
|
|
|
31
31
|
// Static lookup maps (module-scoped to avoid re-creation on each render)
|
|
32
32
|
// ---------------------------------------------------------------------------
|
|
33
33
|
|
|
34
|
-
const KEYBOARD_TYPE_MAP: Record<string, "default" | "email-address" | "url"> = {
|
|
34
|
+
const KEYBOARD_TYPE_MAP: Record<string, "default" | "email-address" | "url" | "phone-pad"> = {
|
|
35
35
|
email: "email-address",
|
|
36
36
|
url: "url",
|
|
37
|
+
tel: "phone-pad",
|
|
37
38
|
text: "default",
|
|
38
39
|
date: "default",
|
|
39
40
|
};
|
|
@@ -41,6 +42,7 @@ const KEYBOARD_TYPE_MAP: Record<string, "default" | "email-address" | "url"> = {
|
|
|
41
42
|
const AUTO_CAPITALIZE_MAP: Record<string, "none" | "sentences" | "words" | "characters"> = {
|
|
42
43
|
email: "none",
|
|
43
44
|
url: "none",
|
|
45
|
+
tel: "none",
|
|
44
46
|
text: "sentences",
|
|
45
47
|
date: "none",
|
|
46
48
|
};
|
|
@@ -246,7 +248,9 @@ function NativeResourceFormFieldRenderer({
|
|
|
246
248
|
}
|
|
247
249
|
|
|
248
250
|
// ------------------------------------------------------------------
|
|
249
|
-
// Text, email, url, date (and any other text-like types)
|
|
251
|
+
// Text, email, tel, url, date (and any other text-like types). Autofill only when the
|
|
252
|
+
// field asks for it (as on the web): on a form about someone else it would fill in the
|
|
253
|
+
// person holding the phone.
|
|
250
254
|
// ------------------------------------------------------------------
|
|
251
255
|
return (
|
|
252
256
|
<View className="gap-1.5">
|
|
@@ -255,6 +259,11 @@ function NativeResourceFormFieldRenderer({
|
|
|
255
259
|
placeholder={field.placeholder}
|
|
256
260
|
keyboardType={KEYBOARD_TYPE_MAP[fieldType] ?? "default"}
|
|
257
261
|
autoCapitalize={AUTO_CAPITALIZE_MAP[fieldType] ?? "sentences"}
|
|
262
|
+
{...(field.autoComplete
|
|
263
|
+
? { autoComplete: field.autoComplete as TextInputProps["autoComplete"] }
|
|
264
|
+
: {})}
|
|
265
|
+
{...(field.inputMode ? { inputMode: field.inputMode } : {})}
|
|
266
|
+
{...(field.enterKeyHint ? { enterKeyHint: field.enterKeyHint } : {})}
|
|
258
267
|
value={f.value != null ? String(f.value) : ""}
|
|
259
268
|
onChangeText={f.onChange}
|
|
260
269
|
editable={!isDisabled}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// A link's picker in NativeResourceView's form sheet (docs/RESOURCE-VIEW.md, "Links in forms"): the
|
|
2
|
+
// same rows as the web's RelationField, from core's useLinkOptions: the linked resource through
|
|
3
|
+
// the provider, under the linked view's scope and default filter, searched on the server and a
|
|
4
|
+
// page at a time. A row shows the chosen row's words; pressing it opens the list in place (no
|
|
5
|
+
// second sheet over the form), with a search bar, None for an optional link, and Show more.
|
|
6
|
+
|
|
7
|
+
import { useEffect, useMemo, useState } from "react";
|
|
8
|
+
import { Pressable, Text, View } from "react-native";
|
|
9
|
+
import { useLinkOptions, useRelationLabel, useViewer } from "@marktiderman/genesis-core/hooks";
|
|
10
|
+
import { NativeLabel } from "../../components/label";
|
|
11
|
+
import { NativeSearchBar } from "../../components/search-bar";
|
|
12
|
+
import { NativeText } from "../../components/text";
|
|
13
|
+
import { NativeButton } from "../../components/button";
|
|
14
|
+
import { isEmptyValue, useNativeResourceViewMessages } from "./display";
|
|
15
|
+
import { defaultNativeResourceViewMessages } from "./messages";
|
|
16
|
+
import type { NativeFormField } from "./mapping";
|
|
17
|
+
|
|
18
|
+
/** How long typing settles before the search goes to the server. */
|
|
19
|
+
const SEARCH_DEBOUNCE_MS = 300;
|
|
20
|
+
|
|
21
|
+
export interface NativeLinkPickerProps {
|
|
22
|
+
field: NativeFormField;
|
|
23
|
+
value: unknown;
|
|
24
|
+
/** The picked row's key as the row holds it; `null` when None is chosen. */
|
|
25
|
+
onChange: (value: string | number | null) => void;
|
|
26
|
+
/** The form's values, for a picker whose filters follow another field. */
|
|
27
|
+
values: Readonly<Record<string, unknown>>;
|
|
28
|
+
error?: string | undefined;
|
|
29
|
+
testID: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function NativeLinkPicker({ field, value, onChange, values, error, testID }: NativeLinkPickerProps) {
|
|
33
|
+
const messages = useNativeResourceViewMessages();
|
|
34
|
+
const words = { ...defaultNativeResourceViewMessages.link!, ...messages.link };
|
|
35
|
+
const link = field.link!;
|
|
36
|
+
const viewer = useViewer();
|
|
37
|
+
const [open, setOpen] = useState(false);
|
|
38
|
+
const [query, setQuery] = useState("");
|
|
39
|
+
const [search, setSearch] = useState("");
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
const timer = setTimeout(() => setSearch(query), SEARCH_DEBOUNCE_MS);
|
|
42
|
+
return () => clearTimeout(timer);
|
|
43
|
+
}, [query]);
|
|
44
|
+
|
|
45
|
+
// By value: the sheet re-renders on every keystroke.
|
|
46
|
+
const filtersKey = JSON.stringify(link.filters(viewer.scope, values));
|
|
47
|
+
const filters = useMemo(() => JSON.parse(filtersKey) as ReturnType<typeof link.filters>, [filtersKey]);
|
|
48
|
+
const labelField = field.labelField ?? link.labelField;
|
|
49
|
+
const list = useLinkOptions(
|
|
50
|
+
{ resource: link.resource, field: link.field, labelField, searchFields: link.searchFields },
|
|
51
|
+
{ filters, search, enabled: open, untitled: words.untitled! },
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const loaded = isEmptyValue(value) ? undefined : list.options.find((o) => String(o.value) === String(value));
|
|
55
|
+
const looked = useRelationLabel({ resource: link.resource, field: link.field }, value, {
|
|
56
|
+
...((list.labelField ?? labelField) ? { labelField: (list.labelField ?? labelField)! } : {}),
|
|
57
|
+
enabled: !isEmptyValue(value) && !loaded,
|
|
58
|
+
});
|
|
59
|
+
const chosen = isEmptyValue(value)
|
|
60
|
+
? null
|
|
61
|
+
: (loaded?.label ??
|
|
62
|
+
(looked === undefined
|
|
63
|
+
? undefined
|
|
64
|
+
: (looked ?? field.missingLabel ?? messages.common.hiddenLink ?? defaultNativeResourceViewMessages.common.hiddenLink!)));
|
|
65
|
+
const shown = chosen === undefined ? messages.common.empty : (chosen ?? words.placeholder!);
|
|
66
|
+
|
|
67
|
+
const pick = (next: string | number | null) => {
|
|
68
|
+
onChange(next);
|
|
69
|
+
setOpen(false);
|
|
70
|
+
setQuery("");
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<View testID={testID} style={{ gap: 6 }}>
|
|
75
|
+
<NativeLabel>{field.label}</NativeLabel>
|
|
76
|
+
<Pressable
|
|
77
|
+
testID={`${testID}-trigger`}
|
|
78
|
+
accessibilityRole="button"
|
|
79
|
+
// The error is read with the field, not only shown under it.
|
|
80
|
+
accessibilityLabel={error ? `${field.label}, ${shown}, ${error}` : `${field.label}, ${shown}`}
|
|
81
|
+
accessibilityState={{ expanded: open }}
|
|
82
|
+
onPress={() => setOpen((was) => !was)}
|
|
83
|
+
className="min-h-[44px] flex-row items-center justify-between rounded-md border border-input bg-background px-3"
|
|
84
|
+
>
|
|
85
|
+
<Text className={chosen ? "text-base text-foreground" : "text-base text-muted-foreground"} numberOfLines={1}>
|
|
86
|
+
{shown}
|
|
87
|
+
</Text>
|
|
88
|
+
<Text className="text-muted-foreground" accessible={false}>
|
|
89
|
+
{open ? "▴" : "▾"}
|
|
90
|
+
</Text>
|
|
91
|
+
</Pressable>
|
|
92
|
+
{open ? (
|
|
93
|
+
<View testID={`${testID}-list`} style={{ gap: 4 }} accessibilityRole="radiogroup" accessibilityLabel={field.label}>
|
|
94
|
+
{list.searchable ? (
|
|
95
|
+
<NativeSearchBar
|
|
96
|
+
testID={`${testID}-search`}
|
|
97
|
+
value={query}
|
|
98
|
+
onChange={setQuery}
|
|
99
|
+
placeholder={words.search!}
|
|
100
|
+
showCancel={false}
|
|
101
|
+
/>
|
|
102
|
+
) : null}
|
|
103
|
+
{!field.required && query === "" ? (
|
|
104
|
+
<Option
|
|
105
|
+
testID={`${testID}-none`}
|
|
106
|
+
label={words.none!}
|
|
107
|
+
muted
|
|
108
|
+
selected={isEmptyValue(value)}
|
|
109
|
+
onPress={() => pick(null)}
|
|
110
|
+
/>
|
|
111
|
+
) : null}
|
|
112
|
+
{list.isLoading ? (
|
|
113
|
+
<NativeText preset="caption" className="px-3 py-2 text-muted-foreground" testID={`${testID}-loading`}>
|
|
114
|
+
{messages.form.loading}
|
|
115
|
+
</NativeText>
|
|
116
|
+
) : list.isError ? (
|
|
117
|
+
<NativeText preset="caption" className="px-3 py-2 text-destructive" accessibilityRole="alert">
|
|
118
|
+
{words.loadFailed}
|
|
119
|
+
</NativeText>
|
|
120
|
+
) : list.options.length === 0 ? (
|
|
121
|
+
<NativeText preset="caption" className="px-3 py-2 text-muted-foreground" testID={`${testID}-empty`}>
|
|
122
|
+
{words.noResults}
|
|
123
|
+
</NativeText>
|
|
124
|
+
) : (
|
|
125
|
+
list.options.map((option) => (
|
|
126
|
+
<Option
|
|
127
|
+
key={String(option.value)}
|
|
128
|
+
testID={`${testID}-option-${String(option.value)}`}
|
|
129
|
+
label={option.label}
|
|
130
|
+
selected={!isEmptyValue(value) && String(value) === String(option.value)}
|
|
131
|
+
onPress={() => pick(option.value)}
|
|
132
|
+
/>
|
|
133
|
+
))
|
|
134
|
+
)}
|
|
135
|
+
{list.hasMore ? (
|
|
136
|
+
<NativeButton
|
|
137
|
+
variant="ghost"
|
|
138
|
+
size="sm"
|
|
139
|
+
testID={`${testID}-more`}
|
|
140
|
+
disabled={list.isLoadingMore}
|
|
141
|
+
onPress={list.loadMore}
|
|
142
|
+
>
|
|
143
|
+
{list.isLoadingMore ? messages.list.loadingMore : words.loadMore!}
|
|
144
|
+
</NativeButton>
|
|
145
|
+
) : null}
|
|
146
|
+
</View>
|
|
147
|
+
) : null}
|
|
148
|
+
{error ? (
|
|
149
|
+
// A live region on Android; the alert role on iOS and the web.
|
|
150
|
+
<View accessibilityLiveRegion="polite">
|
|
151
|
+
<NativeText preset="caption" className="text-destructive" testID={`${testID}-error`} accessibilityRole="alert">
|
|
152
|
+
{error}
|
|
153
|
+
</NativeText>
|
|
154
|
+
</View>
|
|
155
|
+
) : null}
|
|
156
|
+
</View>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function Option({
|
|
161
|
+
label,
|
|
162
|
+
selected,
|
|
163
|
+
muted = false,
|
|
164
|
+
onPress,
|
|
165
|
+
testID,
|
|
166
|
+
}: {
|
|
167
|
+
label: string;
|
|
168
|
+
selected: boolean;
|
|
169
|
+
muted?: boolean;
|
|
170
|
+
onPress: () => void;
|
|
171
|
+
testID: string;
|
|
172
|
+
}) {
|
|
173
|
+
return (
|
|
174
|
+
<Pressable
|
|
175
|
+
testID={testID}
|
|
176
|
+
// One choice of several: a radio, checked when it's the link's row.
|
|
177
|
+
accessibilityRole="radio"
|
|
178
|
+
accessibilityLabel={label}
|
|
179
|
+
accessibilityState={{ checked: selected }}
|
|
180
|
+
onPress={onPress}
|
|
181
|
+
className="min-h-[44px] flex-row items-center justify-between px-3"
|
|
182
|
+
>
|
|
183
|
+
<Text className={muted ? "text-base text-muted-foreground" : "text-base text-foreground"}>{label}</Text>
|
|
184
|
+
{selected ? (
|
|
185
|
+
<Text className="text-base text-primary" accessible={false}>
|
|
186
|
+
✓
|
|
187
|
+
</Text>
|
|
188
|
+
) : null}
|
|
189
|
+
</Pressable>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
// - readiness → a summary chip, then the checks while any is unmet.
|
|
10
10
|
// A section with neither list nor settings is the screen's own, through `slots[id]`.
|
|
11
11
|
|
|
12
|
-
import { useMemo, useRef, useState, type ReactNode } from "react";
|
|
12
|
+
import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";
|
|
13
13
|
import { ActionSheetIOS, Alert, Platform, Pressable, ScrollView, View } from "react-native";
|
|
14
14
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
15
15
|
import { DataWriteError, resourceKeys, useCapabilities, useDataProvider, useViewer, type DataRow, type ResourceContract } from "@marktiderman/genesis-core";
|
|
16
16
|
import { readinessChip, type ReadinessLabels } from "@marktiderman/genesis-core/resource";
|
|
17
|
-
import type
|
|
17
|
+
import { sameFormValue, type Allowed, type RecordView as RecordViewDef, type RecordViewHeaderAction } from "@marktiderman/genesis-core/resource-view";
|
|
18
18
|
import { NativeBadge } from "../../components/badge";
|
|
19
19
|
import { NativeButton } from "../../components/button";
|
|
20
20
|
import { NativeIcon } from "../../components/icon";
|
|
@@ -498,19 +498,29 @@ function SettingsGroup({
|
|
|
498
498
|
// The view's update guard, for this viewer: when it refuses, the settings are read-only with its reason.
|
|
499
499
|
const viewer = useViewer();
|
|
500
500
|
const locked = recordView.settingsLocked(row, viewer);
|
|
501
|
-
|
|
501
|
+
// Only the fields this person changed are theirs: the others show the row as it is now (a live
|
|
502
|
+
// refresh updates them) and are never sent, so a stale draft can't overwrite someone else's change.
|
|
503
|
+
const [edits, setEdits] = useState<Values>({});
|
|
504
|
+
const draft = useMemo<Values>(() => ({ ...Object.fromEntries(fields.map((f) => [f.key, row[f.key]])), ...edits }), [fields, row, edits]);
|
|
505
|
+
// An edit the row now holds (after a save, or someone else's same change) is no longer an edit.
|
|
506
|
+
useEffect(() => {
|
|
507
|
+
setEdits((current) => {
|
|
508
|
+
const left = Object.fromEntries(Object.entries(current).filter(([k, v]) => !sameFormValue(v, row[k])));
|
|
509
|
+
return Object.keys(left).length === Object.keys(current).length ? current : left;
|
|
510
|
+
});
|
|
511
|
+
}, [row]);
|
|
502
512
|
const [invalid, setInvalid] = useState<Record<string, string>>({});
|
|
503
513
|
const [saving, setSaving] = useState(false);
|
|
504
514
|
const [refusal, setRefusal] = useState<string | null>(null);
|
|
505
515
|
const shown = fields.filter((f) => !f.visible || f.visible(draft));
|
|
506
516
|
const changed: Values = {};
|
|
507
|
-
for (const f of shown) if (draft[f.key]
|
|
517
|
+
for (const f of shown) if (f.key in edits && !sameFormValue(draft[f.key], row[f.key])) changed[f.key] = draft[f.key];
|
|
508
518
|
const dirty = Object.keys(changed).length > 0 && !shown.some((f) => invalid[f.key]);
|
|
509
519
|
|
|
510
520
|
const set = (key: string, value: unknown, error?: string) => {
|
|
511
521
|
setRefusal(null);
|
|
512
522
|
setInvalid(({ [key]: _old, ...rest }) => (error ? { ...rest, [key]: error } : rest));
|
|
513
|
-
|
|
523
|
+
setEdits((d) => ({ ...d, [key]: value }));
|
|
514
524
|
};
|
|
515
525
|
const save = async () => {
|
|
516
526
|
setSaving(true);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// The form sheet a NativeResourceView opens for New and Edit: Cancel and Save in the bar, the
|
|
2
2
|
// view's sections as grouped sections, native date and time pickers, choices as a segmented
|
|
3
|
-
// control (up to four) or a list
|
|
3
|
+
// control (up to four) or a list, links as a searchable list of the linked rows (NativeLinkPicker).
|
|
4
|
+
// Text, number, switch and list fields are drawn by
|
|
4
5
|
// NativeResourceFormFieldRenderer, the same as NativeResourceForm. Read-only fields are text, never
|
|
5
6
|
// inputs, and a save sends only the view's writable keys.
|
|
6
7
|
|
|
@@ -22,6 +23,7 @@ import { NativeResourceFormFieldRenderer } from "../NativeResourceFormField";
|
|
|
22
23
|
import { dateToDay, dayToDate, displayText, isEmptyValue, resolveZone, useDisplayTimeZones, useNativeResourceViewMessages } from "./display";
|
|
23
24
|
import { defaultNativeResourceViewMessages, fill } from "./messages";
|
|
24
25
|
import { shownFields, type NativeFormField } from "./mapping";
|
|
26
|
+
import { NativeLinkPicker } from "./NativeLinkPicker";
|
|
25
27
|
import type { SaveResult } from "./use-native-resource-view";
|
|
26
28
|
|
|
27
29
|
type Values = Record<string, unknown>;
|
|
@@ -46,6 +48,7 @@ export interface NativeResourceFormSheetProps {
|
|
|
46
48
|
const FIELD_TYPE: Partial<Record<NativeFormField["kind"], ResourceFormFieldDef["type"]>> = {
|
|
47
49
|
text: "text",
|
|
48
50
|
email: "email",
|
|
51
|
+
tel: "tel",
|
|
49
52
|
url: "url",
|
|
50
53
|
number: "number",
|
|
51
54
|
textarea: "textarea",
|
|
@@ -221,6 +224,24 @@ function FormField({
|
|
|
221
224
|
</View>
|
|
222
225
|
);
|
|
223
226
|
}
|
|
227
|
+
if (field.kind === "link" && field.link) {
|
|
228
|
+
return (
|
|
229
|
+
<Controller
|
|
230
|
+
name={field.key}
|
|
231
|
+
control={f.control}
|
|
232
|
+
render={({ field: input }) => (
|
|
233
|
+
<NativeLinkPicker
|
|
234
|
+
field={field}
|
|
235
|
+
value={input.value}
|
|
236
|
+
onChange={input.onChange}
|
|
237
|
+
values={f.getValues()}
|
|
238
|
+
error={error}
|
|
239
|
+
testID={id}
|
|
240
|
+
/>
|
|
241
|
+
)}
|
|
242
|
+
/>
|
|
243
|
+
);
|
|
244
|
+
}
|
|
224
245
|
const type = FIELD_TYPE[field.kind];
|
|
225
246
|
if (type) {
|
|
226
247
|
const def: ResourceFormFieldDef = {
|
|
@@ -230,6 +251,9 @@ function FormField({
|
|
|
230
251
|
required: field.required,
|
|
231
252
|
...(field.options ? { options: field.options } : {}),
|
|
232
253
|
...(field.max !== undefined ? { maxLength: field.max } : {}),
|
|
254
|
+
...(field.autoComplete ? { autoComplete: field.autoComplete } : {}),
|
|
255
|
+
...(field.inputMode ? { inputMode: field.inputMode } : {}),
|
|
256
|
+
...(field.enterKeyHint ? { enterKeyHint: field.enterKeyHint } : {}),
|
|
233
257
|
};
|
|
234
258
|
return (
|
|
235
259
|
<View testID={id}>
|