@marktiderman/genesis-ui-native 2.7.0 → 2.7.1
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/data/index.js +7 -6
- package/dist/data/index.js.map +1 -1
- package/package.json +2 -2
- package/src/data/resource-view/NativeResourceFormSheet.tsx +4 -1
- package/src/data/resource-view/__tests__/native-resource-view.test.tsx +14 -0
- package/src/data/resource-view/display.tsx +2 -2
- package/src/data/resource-view/mapping.ts +4 -5
package/dist/data/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { Controller, useForm } from 'react-hook-form';
|
|
|
15
15
|
import { useResource, useViewer, useInfiniteResource, useCapabilities, useOptionalViewerScope, useOne } 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 { rowPicture } from '@marktiderman/genesis-core/resource-view';
|
|
18
|
+
import { valueText, rowPicture } 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
|
|
|
@@ -947,7 +947,7 @@ var nativeDisplayRenderers = {
|
|
|
947
947
|
currency: text("currency"),
|
|
948
948
|
percent: text("percent"),
|
|
949
949
|
boolean: text("boolean"),
|
|
950
|
-
badge: (value, { column }) => /* @__PURE__ */ jsx(NativeBadge, { variant: badgeVariant(column.tones?.[String(value)]), children:
|
|
950
|
+
badge: (value, { column }) => /* @__PURE__ */ jsx(NativeBadge, { variant: badgeVariant(column.tones?.[String(value)]), children: valueText(column.labels, value) }),
|
|
951
951
|
date: text("date"),
|
|
952
952
|
datetime: text("datetime"),
|
|
953
953
|
// The linked row's id until relation labels arrive (batched per page, never per row).
|
|
@@ -1029,7 +1029,7 @@ function sectionsFor(view, rows, messages) {
|
|
|
1029
1029
|
const key = isEmptyValue(value) ? "\0" : String(value);
|
|
1030
1030
|
let group = groups.get(key);
|
|
1031
1031
|
if (!group) {
|
|
1032
|
-
const title = isEmptyValue(value) ? fill(messages.list.noGroup, { label: view.label(field).toLowerCase() }) : displayText(display, value, messages);
|
|
1032
|
+
const title = isEmptyValue(value) ? fill(messages.list.noGroup, { label: view.label(field).toLowerCase() }) : display === "badge" ? view.valueLabel(field, value) : displayText(display, value, messages);
|
|
1033
1033
|
group = { key, title, data: [] };
|
|
1034
1034
|
groups.set(key, group);
|
|
1035
1035
|
}
|
|
@@ -1098,7 +1098,7 @@ function kindFor(display, options) {
|
|
|
1098
1098
|
function formFieldsFor(view, mode) {
|
|
1099
1099
|
const writable = new Set(view.writable(mode));
|
|
1100
1100
|
return view.form(mode).filter((f) => f.display !== "json" && !f.field.array).filter((f) => mode === "edit" || writable.has(f.field.name)).map((f) => {
|
|
1101
|
-
const options = f.
|
|
1101
|
+
const options = f.options?.map((o) => ({ value: o.value, label: o.label }));
|
|
1102
1102
|
const readOnly = !writable.has(f.field.name);
|
|
1103
1103
|
return {
|
|
1104
1104
|
key: f.field.name,
|
|
@@ -1115,7 +1115,6 @@ function formFieldsFor(view, mode) {
|
|
|
1115
1115
|
};
|
|
1116
1116
|
});
|
|
1117
1117
|
}
|
|
1118
|
-
var EMPTY_WORDS = { common: { empty: "", yes: "", no: "" } };
|
|
1119
1118
|
function shownFields(fields, values) {
|
|
1120
1119
|
return fields.filter((f) => !f.visible || f.visible(values));
|
|
1121
1120
|
}
|
|
@@ -1282,7 +1281,9 @@ function FormField({
|
|
|
1282
1281
|
const zones = useDisplayTimeZones();
|
|
1283
1282
|
const error = f.formState.errors[field.key]?.message;
|
|
1284
1283
|
if (field.readOnly) {
|
|
1285
|
-
const
|
|
1284
|
+
const value = f.getValues(field.key);
|
|
1285
|
+
const choice = field.options?.find((o) => o.value === String(value));
|
|
1286
|
+
const shown = choice ? choice.label : displayText(field.display, value, messages, resolveZone(void 0, zones));
|
|
1286
1287
|
return /* @__PURE__ */ jsxs(View, { testID: id, style: { gap: 4 }, accessibilityLabel: `${field.label}, ${shown}`, children: [
|
|
1287
1288
|
/* @__PURE__ */ jsx(NativeLabel, { children: field.label }),
|
|
1288
1289
|
/* @__PURE__ */ jsx(NativeText, { testID: `${id}-value`, preset: "body", className: "text-muted-foreground", children: shown })
|