@dxos/react-ui-form 0.8.4-main.c85a9c8dae → 0.8.4-main.d05673bc65
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/lib/browser/index.mjs +22 -13
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +22 -13
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Form/fields/RefField.d.ts +3 -1
- package/dist/types/src/components/Form/fields/RefField.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +31 -31
- package/src/components/Form/Form.stories.tsx +2 -2
- package/src/components/Form/fields/RefField.tsx +9 -4
- package/src/components/ViewEditor/ViewEditor.stories.tsx +2 -2
- package/src/components/ViewEditor/ViewEditor.tsx +15 -4
|
@@ -1440,6 +1440,7 @@ import { findAnnotation } from "@dxos/effect";
|
|
|
1440
1440
|
import { DXN } from "@dxos/keys";
|
|
1441
1441
|
import { DxAnchor } from "@dxos/lit-ui/react";
|
|
1442
1442
|
import { Button, Icon as Icon2, Input as Input6, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
1443
|
+
import { ParentLabelAnnotationId } from "@dxos/schema";
|
|
1443
1444
|
import { mx as mx3 } from "@dxos/ui-theme";
|
|
1444
1445
|
|
|
1445
1446
|
// src/components/ObjectPicker/ObjectPicker.tsx
|
|
@@ -1538,9 +1539,10 @@ var ObjectPicker = {
|
|
|
1538
1539
|
var isRefSnapshot = (val) => {
|
|
1539
1540
|
return typeof val === "object" && typeof val?.["/"] === "string";
|
|
1540
1541
|
};
|
|
1541
|
-
var defaultGetOptions = (results) => results.map((result) => {
|
|
1542
|
+
var defaultGetOptions = (results, { parentLabel } = {}) => results.map((result) => {
|
|
1542
1543
|
const id = Entity.getDXN(result).toString();
|
|
1543
|
-
const
|
|
1544
|
+
const parent = parentLabel ? Obj.getParent(result) : void 0;
|
|
1545
|
+
const label = parent ? Entity.getLabel(parent) : Entity.getLabel(result);
|
|
1544
1546
|
return {
|
|
1545
1547
|
id,
|
|
1546
1548
|
label: label ?? id
|
|
@@ -1555,9 +1557,15 @@ var RefField = (props) => {
|
|
|
1555
1557
|
type
|
|
1556
1558
|
]);
|
|
1557
1559
|
const results = useResults(db, typename);
|
|
1558
|
-
const options = useMemo6(() =>
|
|
1560
|
+
const options = useMemo6(() => {
|
|
1561
|
+
const parentLabel = type ? findAnnotation(type, ParentLabelAnnotationId) === true : false;
|
|
1562
|
+
return getOptions2(results, {
|
|
1563
|
+
parentLabel
|
|
1564
|
+
});
|
|
1565
|
+
}, [
|
|
1559
1566
|
results,
|
|
1560
|
-
getOptions2
|
|
1567
|
+
getOptions2,
|
|
1568
|
+
type
|
|
1561
1569
|
]);
|
|
1562
1570
|
const handleGetValue = useCallback9(() => {
|
|
1563
1571
|
const formValue = getValue();
|
|
@@ -2278,7 +2286,7 @@ import { useObject, useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
|
2278
2286
|
import { IconButton as IconButton4, Input as Input13, Message, useTranslation as useTranslation10 } from "@dxos/react-ui";
|
|
2279
2287
|
import { QueryForm } from "@dxos/react-ui-components";
|
|
2280
2288
|
import { List as List2 } from "@dxos/react-ui-list";
|
|
2281
|
-
import { ProjectionModel, VIEW_FIELD_LIMIT, createEchoChangeCallback, getTypenameFromQuery } from "@dxos/schema";
|
|
2289
|
+
import { ParentLabelAnnotation, ProjectionModel, VIEW_FIELD_LIMIT, createEchoChangeCallback, getTypenameFromQuery } from "@dxos/schema";
|
|
2282
2290
|
import { mx as mx6, osTranslations as osTranslations2, subtleHover as subtleHover2 } from "@dxos/ui-theme";
|
|
2283
2291
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
|
|
2284
2292
|
var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode = "schema", registry, db, readonly, showHeading = false, types, tags, onQueryChanged, onDelete }, forwardedRef) => {
|
|
@@ -2333,9 +2341,10 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
|
|
|
2333
2341
|
if (mode === "tag") {
|
|
2334
2342
|
return Schema3.Struct({
|
|
2335
2343
|
...base.fields,
|
|
2336
|
-
|
|
2344
|
+
// TODO(wittjosiah): Replace Type.Feed with Dataset.Dataset when Ref.Ref supports unions.
|
|
2345
|
+
target: Ref3.Ref(Feed.Feed).pipe(Schema3.annotations({
|
|
2337
2346
|
title: "Target Feed"
|
|
2338
|
-
}))
|
|
2347
|
+
}), ParentLabelAnnotation.set(true), Schema3.optional)
|
|
2339
2348
|
}).pipe(Schema3.mutable);
|
|
2340
2349
|
}
|
|
2341
2350
|
return base.pipe(Schema3.mutable);
|
|
@@ -2378,7 +2387,7 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
|
|
|
2378
2387
|
const handleDelete = useCallback15((fieldId) => {
|
|
2379
2388
|
invariant(!readonly, void 0, {
|
|
2380
2389
|
F: __dxlog_file3,
|
|
2381
|
-
L:
|
|
2390
|
+
L: 185,
|
|
2382
2391
|
S: void 0,
|
|
2383
2392
|
A: [
|
|
2384
2393
|
"!readonly",
|
|
@@ -2438,7 +2447,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2438
2447
|
const handleAdd = useCallback15(() => {
|
|
2439
2448
|
invariant(!readonly, void 0, {
|
|
2440
2449
|
F: __dxlog_file3,
|
|
2441
|
-
L:
|
|
2450
|
+
L: 250,
|
|
2442
2451
|
S: void 0,
|
|
2443
2452
|
A: [
|
|
2444
2453
|
"!readonly",
|
|
@@ -2459,7 +2468,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2459
2468
|
const handleDelete = useCallback15((fieldId) => {
|
|
2460
2469
|
invariant(!readonly, void 0, {
|
|
2461
2470
|
F: __dxlog_file3,
|
|
2462
|
-
L:
|
|
2471
|
+
L: 264,
|
|
2463
2472
|
S: void 0,
|
|
2464
2473
|
A: [
|
|
2465
2474
|
"!readonly",
|
|
@@ -2478,7 +2487,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2478
2487
|
const handleMove = useCallback15((fromIndex, toIndex) => {
|
|
2479
2488
|
invariant(!readonly, void 0, {
|
|
2480
2489
|
F: __dxlog_file3,
|
|
2481
|
-
L:
|
|
2490
|
+
L: 276,
|
|
2482
2491
|
S: void 0,
|
|
2483
2492
|
A: [
|
|
2484
2493
|
"!readonly",
|
|
@@ -2539,7 +2548,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2539
2548
|
}), /* @__PURE__ */ React19.createElement(List2.ItemTitle, {
|
|
2540
2549
|
classNames: hidden && "text-subdued",
|
|
2541
2550
|
onClick: () => handleToggleField(field)
|
|
2542
|
-
}, field.path), /* @__PURE__ */ React19.createElement(List2.
|
|
2551
|
+
}, field.path), /* @__PURE__ */ React19.createElement(List2.ItemIconButton, {
|
|
2543
2552
|
label: t(hidden ? "show field label" : "hide field label"),
|
|
2544
2553
|
"data-testid": hidden ? "show-field-button" : "hide-field-button",
|
|
2545
2554
|
icon: hidden ? "ph--eye-closed--regular" : "ph--eye--regular",
|
|
@@ -2552,7 +2561,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2552
2561
|
disabled: readonly || schemaReadonly || viewSnapshot.projection.fields.length <= 1,
|
|
2553
2562
|
onClick: () => handleDelete(field.id),
|
|
2554
2563
|
"data-testid": "field.delete"
|
|
2555
|
-
}), /* @__PURE__ */ React19.createElement(
|
|
2564
|
+
}), /* @__PURE__ */ React19.createElement(List2.ItemIconButton, {
|
|
2556
2565
|
iconOnly: true,
|
|
2557
2566
|
variant: "ghost",
|
|
2558
2567
|
label: t("toggle expand label", {
|