@marktiderman/genesis-ui-native 3.2.2 → 3.4.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/dist/{chunk-C6Q5ZAVT.js → chunk-6KWEAGRD.js} +2 -2
- package/dist/chunk-6KWEAGRD.js.map +1 -0
- package/dist/{chunk-PO3MK6IY.js → chunk-GHYUNNNU.js} +3 -3
- package/dist/{chunk-PO3MK6IY.js.map → chunk-GHYUNNNU.js.map} +1 -1
- package/dist/{chunk-7HWS2JGX.js → chunk-LBVD7XXL.js} +3 -3
- package/dist/{chunk-7HWS2JGX.js.map → chunk-LBVD7XXL.js.map} +1 -1
- package/dist/{chunk-ON7WP4T6.js → chunk-VZ3PQLZ4.js} +4 -4
- package/dist/{chunk-ON7WP4T6.js.map → chunk-VZ3PQLZ4.js.map} +1 -1
- package/dist/{chunk-SXCG2REG.js → chunk-ZHVQTMNV.js} +3 -3
- package/dist/{chunk-SXCG2REG.js.map → chunk-ZHVQTMNV.js.map} +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +3 -3
- package/dist/data/index.d.ts +42 -5
- package/dist/data/index.js +210 -20
- package/dist/data/index.js.map +1 -1
- package/dist/icons/lucide.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/layouts/index.js +3 -3
- package/dist/{native-modules-_Q5vIbd5.d.ts → native-modules-PwnGltOU.d.ts} +27 -1
- package/package.json +3 -3
- package/src/components/index.ts +2 -0
- package/src/data/NativeResourceFormField.tsx +12 -3
- package/src/data/resource-view/NativeLinkPicker.tsx +191 -0
- package/src/data/resource-view/NativeResourceFormSheet.tsx +25 -1
- package/src/data/resource-view/__tests__/native-link-picker.test.tsx +201 -0
- package/src/data/resource-view/__tests__/native-tel-field.test.tsx +79 -0
- 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 +21 -10
- package/src/native-modules.tsx +22 -1
- package/dist/chunk-C6Q5ZAVT.js.map +0 -1
package/dist/data/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { NativeImage, NativeAvatar, NativeCard, NativeCardContent, NativeSeparator, NativeLabel, NativeSwitch, NativeCheckbox, NativeSelect, NativeSelectTrigger, NativeSelectContent, NativeSelectItem, NativeTextarea, NativeAlert, NativeAlertTitle, NativeAlertDescription, NativeSheet, NativeSheetScrollView, NativeInlineAlert, NativeSegmentedControl, NativeDatePicker, NativeTimePicker, NativeSearchBar, NativeSkeleton, NativeCardHeader, NativeCardTitle } from '../chunk-
|
|
1
|
+
import { NativeImage, NativeAvatar, NativeCard, NativeCardContent, NativeSeparator, NativeLabel, NativeSwitch, NativeCheckbox, NativeSelect, NativeSelectTrigger, NativeSelectContent, NativeSelectItem, NativeTextarea, NativeAlert, NativeAlertTitle, NativeAlertDescription, NativeSheet, NativeSheetScrollView, NativeInlineAlert, NativeSegmentedControl, NativeDatePicker, NativeTimePicker, NativeSearchBar, NativeSkeleton, NativeCardHeader, NativeCardTitle } from '../chunk-GHYUNNNU.js';
|
|
2
2
|
import '../chunk-7PCWEY6R.js';
|
|
3
|
-
import { showInboxActions, NavBarSaveButton, composeHeaderOptions } from '../chunk-
|
|
4
|
-
import { NativeListItem, NativeBadge, NativeText, NativeButton, NativeInput, useGenesisModules, NativeLoadingState, NativeSectionListHeader, NativeEmptyState, NativeRefreshControl, NativeIcon } from '../chunk-
|
|
3
|
+
import { showInboxActions, NavBarSaveButton, composeHeaderOptions } from '../chunk-ZHVQTMNV.js';
|
|
4
|
+
import { NativeListItem, NativeBadge, NativeText, NativeButton, NativeInput, useGenesisModules, NativeLoadingState, NativeSectionListHeader, NativeEmptyState, NativeRefreshControl, NativeIcon } from '../chunk-6KWEAGRD.js';
|
|
5
5
|
import { useThemeRoles } from '../chunk-Z3AQYVUA.js';
|
|
6
6
|
import '../chunk-OHZD7KRO.js';
|
|
7
7
|
import '../chunk-DGUM43GV.js';
|
|
@@ -12,10 +12,10 @@ import { createContext, memo, useState, useCallback, useMemo, useEffect, useCont
|
|
|
12
12
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
13
13
|
import { titleCase, useResourceForm, resourceKeys, useDataProvider, useViewer as useViewer$1, encodeRecordKey, useCapabilities as useCapabilities$1, DataWriteError } from '@marktiderman/genesis-core';
|
|
14
14
|
import { Controller, useForm } from 'react-hook-form';
|
|
15
|
-
import { useRelationLabel, useResource, useViewer, useInfiniteResource, useCapabilities, useOptionalViewerScope, scopeClock, useOne } from '@marktiderman/genesis-core/hooks';
|
|
15
|
+
import { useRelationLabel, useResource, useViewer, useInfiniteResource, useCapabilities, useOptionalViewerScope, scopeClock, useOne, useLinkOptions } from '@marktiderman/genesis-core/hooks';
|
|
16
16
|
import { personTimeZone, isTimeZone, wallClock } from '@marktiderman/genesis-core/dates';
|
|
17
17
|
import { isSafeUrl } from '@marktiderman/genesis-core/urls';
|
|
18
|
-
import { valueText, rowPicture } from '@marktiderman/genesis-core/resource-view';
|
|
18
|
+
import { valueText, rowPicture, filterParams as filterParams$1 } from '@marktiderman/genesis-core/resource-view';
|
|
19
19
|
import { useQueryClient, useQuery } from '@tanstack/react-query';
|
|
20
20
|
import { readinessChip } from '@marktiderman/genesis-core/resource';
|
|
21
21
|
|
|
@@ -235,12 +235,14 @@ function NativeDetailPanel({
|
|
|
235
235
|
var KEYBOARD_TYPE_MAP = {
|
|
236
236
|
email: "email-address",
|
|
237
237
|
url: "url",
|
|
238
|
+
tel: "phone-pad",
|
|
238
239
|
text: "default",
|
|
239
240
|
date: "default"
|
|
240
241
|
};
|
|
241
242
|
var AUTO_CAPITALIZE_MAP = {
|
|
242
243
|
email: "none",
|
|
243
244
|
url: "none",
|
|
245
|
+
tel: "none",
|
|
244
246
|
text: "sentences",
|
|
245
247
|
date: "none"
|
|
246
248
|
};
|
|
@@ -392,6 +394,9 @@ function NativeResourceFormFieldRenderer({
|
|
|
392
394
|
placeholder: field.placeholder,
|
|
393
395
|
keyboardType: KEYBOARD_TYPE_MAP[fieldType] ?? "default",
|
|
394
396
|
autoCapitalize: AUTO_CAPITALIZE_MAP[fieldType] ?? "sentences",
|
|
397
|
+
...field.autoComplete ? { autoComplete: field.autoComplete } : {},
|
|
398
|
+
...field.inputMode ? { inputMode: field.inputMode } : {},
|
|
399
|
+
...field.enterKeyHint ? { enterKeyHint: field.enterKeyHint } : {},
|
|
395
400
|
value: f.value != null ? String(f.value) : "",
|
|
396
401
|
onChangeText: f.onChange,
|
|
397
402
|
editable: !isDisabled,
|
|
@@ -844,6 +849,15 @@ var defaultNativeResourceViewMessages = {
|
|
|
844
849
|
clear: "Clear {label}",
|
|
845
850
|
loading: "Loading"
|
|
846
851
|
},
|
|
852
|
+
link: {
|
|
853
|
+
placeholder: "Choose\u2026",
|
|
854
|
+
search: "Search",
|
|
855
|
+
none: "None",
|
|
856
|
+
noResults: "No matches",
|
|
857
|
+
loadMore: "Show more",
|
|
858
|
+
loadFailed: "Couldn't load the choices.",
|
|
859
|
+
untitled: "Untitled"
|
|
860
|
+
},
|
|
847
861
|
refusal: {
|
|
848
862
|
deleteFailed: "This {noun} couldn't be deleted. Try again.",
|
|
849
863
|
dismiss: "Dismiss"
|
|
@@ -1087,8 +1101,9 @@ function swipeActionsFor(view, row, options) {
|
|
|
1087
1101
|
return actions;
|
|
1088
1102
|
}
|
|
1089
1103
|
var SEGMENTED_MAX = 4;
|
|
1090
|
-
function kindFor(display, options) {
|
|
1104
|
+
function kindFor(display, options, widget) {
|
|
1091
1105
|
if (options) return options.length <= SEGMENTED_MAX ? "segmented" : "select";
|
|
1106
|
+
if (widget === "tel" && display === "text") return "tel";
|
|
1092
1107
|
switch (display) {
|
|
1093
1108
|
case "boolean":
|
|
1094
1109
|
return "switch";
|
|
@@ -1111,23 +1126,43 @@ function kindFor(display, options) {
|
|
|
1111
1126
|
return "text";
|
|
1112
1127
|
}
|
|
1113
1128
|
}
|
|
1114
|
-
function
|
|
1115
|
-
|
|
1129
|
+
function heldTo(link, keys) {
|
|
1130
|
+
if (!keys) return link;
|
|
1131
|
+
const held = { field: link.field, operator: "in", value: [...keys] };
|
|
1132
|
+
return Object.freeze({
|
|
1133
|
+
resource: link.resource,
|
|
1134
|
+
field: link.field,
|
|
1135
|
+
get labelField() {
|
|
1136
|
+
return link.labelField;
|
|
1137
|
+
},
|
|
1138
|
+
...link.searchFields ? { searchFields: link.searchFields } : {},
|
|
1139
|
+
filters: (scope, values) => [...link.filters(scope, values), held]
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1142
|
+
function formFieldsFor(view, mode, options = {}) {
|
|
1143
|
+
const pinned = new Set(options.pinned ?? []);
|
|
1144
|
+
const within = options.within ?? {};
|
|
1145
|
+
const writable = new Set([...view.writable(mode)].filter((name) => !(pinned.has(name) && view.field(name)?.references)));
|
|
1116
1146
|
return view.form(mode).filter((f) => f.display !== "json" && !f.field.array).filter((f) => mode === "edit" || writable.has(f.field.name)).map((f) => {
|
|
1117
|
-
const
|
|
1147
|
+
const options2 = f.options?.map((o) => ({ value: o.value, label: o.label }));
|
|
1118
1148
|
const readOnly = !writable.has(f.field.name);
|
|
1149
|
+
const link = !readOnly && !options2 && f.link ? heldTo(f.link, Object.hasOwn(within, f.field.name) ? within[f.field.name] : void 0) : void 0;
|
|
1119
1150
|
return {
|
|
1120
1151
|
key: f.field.name,
|
|
1121
1152
|
label: f.label,
|
|
1122
|
-
kind: kindFor(f.display,
|
|
1153
|
+
kind: link ? "link" : kindFor(f.display, options2, f.field.widget),
|
|
1123
1154
|
display: f.display,
|
|
1124
1155
|
required: !readOnly && f.required,
|
|
1125
1156
|
readOnly,
|
|
1126
1157
|
...typeof f.field.nullable === "boolean" ? { nullable: f.field.nullable } : {},
|
|
1127
1158
|
...f.field.hasDefault || f.field.generated ? { hasDefault: true } : {},
|
|
1128
1159
|
...f.max !== void 0 ? { max: f.max } : {},
|
|
1129
|
-
...
|
|
1160
|
+
...f.autoComplete ? { autoComplete: f.autoComplete } : {},
|
|
1161
|
+
...f.inputMode ? { inputMode: f.inputMode } : {},
|
|
1162
|
+
...f.enterKeyHint ? { enterKeyHint: f.enterKeyHint } : {},
|
|
1163
|
+
...options2 ? { options: options2 } : {},
|
|
1130
1164
|
...f.field.references ? { references: f.field.references } : {},
|
|
1165
|
+
...link ? { link } : {},
|
|
1131
1166
|
...f.labelField ? { labelField: f.labelField } : {},
|
|
1132
1167
|
...f.missingLabel ? { missingLabel: f.missingLabel } : {},
|
|
1133
1168
|
section: f.section,
|
|
@@ -1181,9 +1216,131 @@ function refusalFields(error) {
|
|
|
1181
1216
|
}
|
|
1182
1217
|
return {};
|
|
1183
1218
|
}
|
|
1219
|
+
var SEARCH_DEBOUNCE_MS = 300;
|
|
1220
|
+
function NativeLinkPicker({ field, value, onChange, values, error, testID }) {
|
|
1221
|
+
const messages = useNativeResourceViewMessages();
|
|
1222
|
+
const words = { ...defaultNativeResourceViewMessages.link, ...messages.link };
|
|
1223
|
+
const link = field.link;
|
|
1224
|
+
const viewer = useViewer();
|
|
1225
|
+
const [open, setOpen] = useState(false);
|
|
1226
|
+
const [query, setQuery] = useState("");
|
|
1227
|
+
const [search, setSearch] = useState("");
|
|
1228
|
+
useEffect(() => {
|
|
1229
|
+
const timer = setTimeout(() => setSearch(query), SEARCH_DEBOUNCE_MS);
|
|
1230
|
+
return () => clearTimeout(timer);
|
|
1231
|
+
}, [query]);
|
|
1232
|
+
const filtersKey = JSON.stringify(link.filters(viewer.scope, values));
|
|
1233
|
+
const filters = useMemo(() => JSON.parse(filtersKey), [filtersKey]);
|
|
1234
|
+
const labelField = field.labelField ?? link.labelField;
|
|
1235
|
+
const list = useLinkOptions(
|
|
1236
|
+
{ resource: link.resource, field: link.field, labelField, searchFields: link.searchFields },
|
|
1237
|
+
{ filters, search, enabled: open, untitled: words.untitled }
|
|
1238
|
+
);
|
|
1239
|
+
const loaded = isEmptyValue(value) ? void 0 : list.options.find((o) => String(o.value) === String(value));
|
|
1240
|
+
const looked = useRelationLabel({ resource: link.resource, field: link.field }, value, {
|
|
1241
|
+
...list.labelField ?? labelField ? { labelField: list.labelField ?? labelField } : {},
|
|
1242
|
+
enabled: !isEmptyValue(value) && !loaded
|
|
1243
|
+
});
|
|
1244
|
+
const chosen = isEmptyValue(value) ? null : loaded?.label ?? (looked === void 0 ? void 0 : looked ?? field.missingLabel ?? messages.common.hiddenLink ?? defaultNativeResourceViewMessages.common.hiddenLink);
|
|
1245
|
+
const shown = chosen === void 0 ? messages.common.empty : chosen ?? words.placeholder;
|
|
1246
|
+
const pick = (next) => {
|
|
1247
|
+
onChange(next);
|
|
1248
|
+
setOpen(false);
|
|
1249
|
+
setQuery("");
|
|
1250
|
+
};
|
|
1251
|
+
return /* @__PURE__ */ jsxs(View, { testID, style: { gap: 6 }, children: [
|
|
1252
|
+
/* @__PURE__ */ jsx(NativeLabel, { children: field.label }),
|
|
1253
|
+
/* @__PURE__ */ jsxs(
|
|
1254
|
+
Pressable,
|
|
1255
|
+
{
|
|
1256
|
+
testID: `${testID}-trigger`,
|
|
1257
|
+
accessibilityRole: "button",
|
|
1258
|
+
accessibilityLabel: error ? `${field.label}, ${shown}, ${error}` : `${field.label}, ${shown}`,
|
|
1259
|
+
accessibilityState: { expanded: open },
|
|
1260
|
+
onPress: () => setOpen((was) => !was),
|
|
1261
|
+
className: "min-h-[44px] flex-row items-center justify-between rounded-md border border-input bg-background px-3",
|
|
1262
|
+
children: [
|
|
1263
|
+
/* @__PURE__ */ jsx(Text, { className: chosen ? "text-base text-foreground" : "text-base text-muted-foreground", numberOfLines: 1, children: shown }),
|
|
1264
|
+
/* @__PURE__ */ jsx(Text, { className: "text-muted-foreground", accessible: false, children: open ? "\u25B4" : "\u25BE" })
|
|
1265
|
+
]
|
|
1266
|
+
}
|
|
1267
|
+
),
|
|
1268
|
+
open ? /* @__PURE__ */ jsxs(View, { testID: `${testID}-list`, style: { gap: 4 }, accessibilityRole: "radiogroup", accessibilityLabel: field.label, children: [
|
|
1269
|
+
list.searchable ? /* @__PURE__ */ jsx(
|
|
1270
|
+
NativeSearchBar,
|
|
1271
|
+
{
|
|
1272
|
+
testID: `${testID}-search`,
|
|
1273
|
+
value: query,
|
|
1274
|
+
onChange: setQuery,
|
|
1275
|
+
placeholder: words.search,
|
|
1276
|
+
showCancel: false
|
|
1277
|
+
}
|
|
1278
|
+
) : null,
|
|
1279
|
+
!field.required && query === "" ? /* @__PURE__ */ jsx(
|
|
1280
|
+
Option,
|
|
1281
|
+
{
|
|
1282
|
+
testID: `${testID}-none`,
|
|
1283
|
+
label: words.none,
|
|
1284
|
+
muted: true,
|
|
1285
|
+
selected: isEmptyValue(value),
|
|
1286
|
+
onPress: () => pick(null)
|
|
1287
|
+
}
|
|
1288
|
+
) : null,
|
|
1289
|
+
list.isLoading ? /* @__PURE__ */ jsx(NativeText, { preset: "caption", className: "px-3 py-2 text-muted-foreground", testID: `${testID}-loading`, children: messages.form.loading }) : list.isError ? /* @__PURE__ */ jsx(NativeText, { preset: "caption", className: "px-3 py-2 text-destructive", accessibilityRole: "alert", children: words.loadFailed }) : list.options.length === 0 ? /* @__PURE__ */ jsx(NativeText, { preset: "caption", className: "px-3 py-2 text-muted-foreground", testID: `${testID}-empty`, children: words.noResults }) : list.options.map((option) => /* @__PURE__ */ jsx(
|
|
1290
|
+
Option,
|
|
1291
|
+
{
|
|
1292
|
+
testID: `${testID}-option-${String(option.value)}`,
|
|
1293
|
+
label: option.label,
|
|
1294
|
+
selected: !isEmptyValue(value) && String(value) === String(option.value),
|
|
1295
|
+
onPress: () => pick(option.value)
|
|
1296
|
+
},
|
|
1297
|
+
String(option.value)
|
|
1298
|
+
)),
|
|
1299
|
+
list.hasMore ? /* @__PURE__ */ jsx(
|
|
1300
|
+
NativeButton,
|
|
1301
|
+
{
|
|
1302
|
+
variant: "ghost",
|
|
1303
|
+
size: "sm",
|
|
1304
|
+
testID: `${testID}-more`,
|
|
1305
|
+
disabled: list.isLoadingMore,
|
|
1306
|
+
onPress: list.loadMore,
|
|
1307
|
+
children: list.isLoadingMore ? messages.list.loadingMore : words.loadMore
|
|
1308
|
+
}
|
|
1309
|
+
) : null
|
|
1310
|
+
] }) : null,
|
|
1311
|
+
error ? (
|
|
1312
|
+
// A live region on Android; the alert role on iOS and the web.
|
|
1313
|
+
/* @__PURE__ */ jsx(View, { accessibilityLiveRegion: "polite", children: /* @__PURE__ */ jsx(NativeText, { preset: "caption", className: "text-destructive", testID: `${testID}-error`, accessibilityRole: "alert", children: error }) })
|
|
1314
|
+
) : null
|
|
1315
|
+
] });
|
|
1316
|
+
}
|
|
1317
|
+
function Option({
|
|
1318
|
+
label,
|
|
1319
|
+
selected,
|
|
1320
|
+
muted = false,
|
|
1321
|
+
onPress,
|
|
1322
|
+
testID
|
|
1323
|
+
}) {
|
|
1324
|
+
return /* @__PURE__ */ jsxs(
|
|
1325
|
+
Pressable,
|
|
1326
|
+
{
|
|
1327
|
+
testID,
|
|
1328
|
+
accessibilityRole: "radio",
|
|
1329
|
+
accessibilityLabel: label,
|
|
1330
|
+
accessibilityState: { checked: selected },
|
|
1331
|
+
onPress,
|
|
1332
|
+
className: "min-h-[44px] flex-row items-center justify-between px-3",
|
|
1333
|
+
children: [
|
|
1334
|
+
/* @__PURE__ */ jsx(Text, { className: muted ? "text-base text-muted-foreground" : "text-base text-foreground", children: label }),
|
|
1335
|
+
selected ? /* @__PURE__ */ jsx(Text, { className: "text-base text-primary", accessible: false, children: "\u2713" }) : null
|
|
1336
|
+
]
|
|
1337
|
+
}
|
|
1338
|
+
);
|
|
1339
|
+
}
|
|
1184
1340
|
var FIELD_TYPE = {
|
|
1185
1341
|
text: "text",
|
|
1186
1342
|
email: "email",
|
|
1343
|
+
tel: "tel",
|
|
1187
1344
|
url: "url",
|
|
1188
1345
|
number: "number",
|
|
1189
1346
|
textarea: "textarea",
|
|
@@ -1322,6 +1479,26 @@ function FormField({
|
|
|
1322
1479
|
/* @__PURE__ */ jsx(NativeText, { testID: `${id}-value`, preset: "body", className: "text-muted-foreground", children: shown })
|
|
1323
1480
|
] });
|
|
1324
1481
|
}
|
|
1482
|
+
if (field.kind === "link" && field.link) {
|
|
1483
|
+
return /* @__PURE__ */ jsx(
|
|
1484
|
+
Controller,
|
|
1485
|
+
{
|
|
1486
|
+
name: field.key,
|
|
1487
|
+
control: f.control,
|
|
1488
|
+
render: ({ field: input }) => /* @__PURE__ */ jsx(
|
|
1489
|
+
NativeLinkPicker,
|
|
1490
|
+
{
|
|
1491
|
+
field,
|
|
1492
|
+
value: input.value,
|
|
1493
|
+
onChange: input.onChange,
|
|
1494
|
+
values: f.getValues(),
|
|
1495
|
+
error,
|
|
1496
|
+
testID: id
|
|
1497
|
+
}
|
|
1498
|
+
)
|
|
1499
|
+
}
|
|
1500
|
+
);
|
|
1501
|
+
}
|
|
1325
1502
|
const type = FIELD_TYPE[field.kind];
|
|
1326
1503
|
if (type) {
|
|
1327
1504
|
const def = {
|
|
@@ -1330,7 +1507,10 @@ function FormField({
|
|
|
1330
1507
|
type,
|
|
1331
1508
|
required: field.required,
|
|
1332
1509
|
...field.options ? { options: field.options } : {},
|
|
1333
|
-
...field.max !== void 0 ? { maxLength: field.max } : {}
|
|
1510
|
+
...field.max !== void 0 ? { maxLength: field.max } : {},
|
|
1511
|
+
...field.autoComplete ? { autoComplete: field.autoComplete } : {},
|
|
1512
|
+
...field.inputMode ? { inputMode: field.inputMode } : {},
|
|
1513
|
+
...field.enterKeyHint ? { enterKeyHint: field.enterKeyHint } : {}
|
|
1334
1514
|
};
|
|
1335
1515
|
return /* @__PURE__ */ jsx(View, { testID: id, children: /* @__PURE__ */ jsx(NativeResourceFormFieldRenderer, { field: def, control: f.control, action: m }) });
|
|
1336
1516
|
}
|
|
@@ -1394,11 +1574,9 @@ function DateField({
|
|
|
1394
1574
|
clearable ? /* @__PURE__ */ jsx(NativeButton, { variant: "ghost", size: "sm", testID: `${testID}-clear`, onPress: () => onChange(null), children: fill(messages.form.clear, { label: label.toLowerCase() }) }) : null
|
|
1395
1575
|
] });
|
|
1396
1576
|
}
|
|
1397
|
-
var
|
|
1577
|
+
var SEARCH_DEBOUNCE_MS2 = 300;
|
|
1398
1578
|
function filterParams(filter) {
|
|
1399
|
-
return
|
|
1400
|
-
([field, value]) => value === null ? { field, operator: "is_null" } : Array.isArray(value) ? { field, operator: "in", value: [...value] } : { field, operator: "eq", value }
|
|
1401
|
-
);
|
|
1579
|
+
return filterParams$1(filter);
|
|
1402
1580
|
}
|
|
1403
1581
|
function screenValues(...filters) {
|
|
1404
1582
|
const out = {};
|
|
@@ -1409,6 +1587,16 @@ function screenValues(...filters) {
|
|
|
1409
1587
|
}
|
|
1410
1588
|
return out;
|
|
1411
1589
|
}
|
|
1590
|
+
function screenLists(...filters) {
|
|
1591
|
+
const out = {};
|
|
1592
|
+
for (const filter of filters) {
|
|
1593
|
+
for (const [field, value] of Object.entries(filter ?? {})) {
|
|
1594
|
+
if (Array.isArray(value)) out[field] = [...value];
|
|
1595
|
+
else delete out[field];
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
return out;
|
|
1599
|
+
}
|
|
1412
1600
|
var DEFAULT_MAX_PAGES = 10;
|
|
1413
1601
|
function serverSorts(view) {
|
|
1414
1602
|
const groupBy = view.definition.groupBy;
|
|
@@ -1434,6 +1622,8 @@ function useNativeResourceView(view, options = {}) {
|
|
|
1434
1622
|
);
|
|
1435
1623
|
const createKey = JSON.stringify(screenValues(tabFilter, filter));
|
|
1436
1624
|
const createDefaults = useMemo(() => JSON.parse(createKey), [createKey]);
|
|
1625
|
+
const listKey = JSON.stringify(screenLists(tabFilter, filter));
|
|
1626
|
+
const within = useMemo(() => JSON.parse(listKey), [listKey]);
|
|
1437
1627
|
const sorts = useMemo(() => serverSorts(view), [view]);
|
|
1438
1628
|
const searchFields = useMemo(
|
|
1439
1629
|
() => searchOption ?? (view.labelField ? [view.labelField] : void 0),
|
|
@@ -1455,7 +1645,7 @@ function useNativeResourceView(view, options = {}) {
|
|
|
1455
1645
|
(text2) => {
|
|
1456
1646
|
setSearchText(text2);
|
|
1457
1647
|
if (timer.current) clearTimeout(timer.current);
|
|
1458
|
-
timer.current = setTimeout(() => sendSearch(text2),
|
|
1648
|
+
timer.current = setTimeout(() => sendSearch(text2), SEARCH_DEBOUNCE_MS2);
|
|
1459
1649
|
},
|
|
1460
1650
|
[sendSearch]
|
|
1461
1651
|
);
|
|
@@ -1475,8 +1665,8 @@ function useNativeResourceView(view, options = {}) {
|
|
|
1475
1665
|
const capabilities = useCapabilities(view.resource);
|
|
1476
1666
|
const softDelete = capabilities.data?.softDelete === true;
|
|
1477
1667
|
const formFields = useCallback(
|
|
1478
|
-
(mode) => mode === "create" ? formFieldsFor(view, "create").filter((f) => !(f.key in createDefaults)) : formFieldsFor(view, "edit"),
|
|
1479
|
-
[view, createDefaults]
|
|
1668
|
+
(mode) => mode === "create" ? formFieldsFor(view, "create", { within }).filter((f) => !(f.key in createDefaults)) : formFieldsFor(view, "edit", { pinned: Object.keys(createDefaults), within }),
|
|
1669
|
+
[view, createDefaults, within]
|
|
1480
1670
|
);
|
|
1481
1671
|
const editable = useMemo(() => formFieldsFor(view, "edit").some((f) => !f.readOnly), [view]);
|
|
1482
1672
|
const viewer = useViewer();
|
|
@@ -2336,6 +2526,6 @@ function Cell({ last, children }) {
|
|
|
2336
2526
|
] });
|
|
2337
2527
|
}
|
|
2338
2528
|
|
|
2339
|
-
export { DEFAULT_MAX_PAGES, DisplayRenderersProvider, DisplayTimeZonesProvider, NativeDataFilters, NativeDataPageShell, NativeDetailPanel, NativeEmptyState2 as NativeEmptyState, NativeRecordView, NativeRecordViewMenu, NativeResourceForm, NativeResourceFormFieldRenderer, NativeResourceFormSheet, NativeResourcePage, NativeResourceView, NativeResourceViewMessagesProvider, NativeResourceWorkspace, NativeResourceWorkspaceMenu, SEARCH_DEBOUNCE_MS, SEGMENTED_SECTIONS_MAX, allowed, dateToDay, dayToDate, defaultNativeRecordViewMessages, defaultNativeResourceViewMessages, defaultNativeResourceWorkspaceMessages, displayText, formFieldsFor, formatDay, formatInstant, getNativeRecordViewStackOptions, getNativeResourceWorkspaceStackOptions, nativeDisplayRenderers, openableUrl, parseSettingNumber, resolveZone, rowItem, screenValues, sectionsFor, serverSort, serverSorts, swipeActionsFor, useDisplayCell, useDisplayTimeZones, useNativeResourceView, useNativeResourceViewMessages, validateValues, writableValues };
|
|
2529
|
+
export { DEFAULT_MAX_PAGES, DisplayRenderersProvider, DisplayTimeZonesProvider, NativeDataFilters, NativeDataPageShell, NativeDetailPanel, NativeEmptyState2 as NativeEmptyState, NativeRecordView, NativeRecordViewMenu, NativeResourceForm, NativeResourceFormFieldRenderer, NativeResourceFormSheet, NativeResourcePage, NativeResourceView, NativeResourceViewMessagesProvider, NativeResourceWorkspace, NativeResourceWorkspaceMenu, SEARCH_DEBOUNCE_MS2 as SEARCH_DEBOUNCE_MS, SEGMENTED_SECTIONS_MAX, allowed, dateToDay, dayToDate, defaultNativeRecordViewMessages, defaultNativeResourceViewMessages, defaultNativeResourceWorkspaceMessages, displayText, formFieldsFor, formatDay, formatInstant, getNativeRecordViewStackOptions, getNativeResourceWorkspaceStackOptions, nativeDisplayRenderers, openableUrl, parseSettingNumber, resolveZone, rowItem, screenValues, sectionsFor, serverSort, serverSorts, swipeActionsFor, useDisplayCell, useDisplayTimeZones, useNativeResourceView, useNativeResourceViewMessages, validateValues, writableValues };
|
|
2340
2530
|
//# sourceMappingURL=index.js.map
|
|
2341
2531
|
//# sourceMappingURL=index.js.map
|