@dxos/react-ui-form 0.8.4-main.84f28bd → 0.8.4-main.c1de068
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 +29 -35
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +29 -35
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +3 -4
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +2 -2
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +2 -2
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +3 -3
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/deprecated/Form.d.ts +3 -3
- package/dist/types/src/components/deprecated/Form.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +29 -29
- package/src/components/FieldEditor/FieldEditor.stories.tsx +12 -10
- package/src/components/FieldEditor/FieldEditor.test.tsx +11 -11
- package/src/components/FieldEditor/FieldEditor.tsx +5 -15
- package/src/components/Form/ArrayField.tsx +1 -1
- package/src/components/Form/custom/SelectOptionsInput.tsx +1 -1
- package/src/components/ViewEditor/ViewEditor.stories.tsx +14 -8
- package/src/components/ViewEditor/ViewEditor.test.tsx +14 -12
- package/src/components/ViewEditor/ViewEditor.tsx +17 -32
- package/src/components/deprecated/Form.stories.tsx +3 -3
- package/src/components/deprecated/Form.tsx +4 -4
|
@@ -508,7 +508,12 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
508
508
|
}, /* @__PURE__ */ React5.createElement(List.Item, {
|
|
509
509
|
role: "button",
|
|
510
510
|
item,
|
|
511
|
-
classNames:
|
|
511
|
+
classNames: [
|
|
512
|
+
"p-1 plb-2",
|
|
513
|
+
"flex flex-col",
|
|
514
|
+
"cursor-pointer",
|
|
515
|
+
"hover:bg-hoverOverlay"
|
|
516
|
+
],
|
|
512
517
|
"aria-expanded": selected === item.id
|
|
513
518
|
}, /* @__PURE__ */ React5.createElement("div", {
|
|
514
519
|
className: "flex items-center"
|
|
@@ -1561,7 +1566,7 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1561
1566
|
classNames: "self-center"
|
|
1562
1567
|
}));
|
|
1563
1568
|
})), !readonly && /* @__PURE__ */ React10.createElement(IconButton3, {
|
|
1564
|
-
classNames: "is-full mlb-
|
|
1569
|
+
classNames: "is-full mlb-cardSpacingBlock flex",
|
|
1565
1570
|
icon: "ph--plus--regular",
|
|
1566
1571
|
label: t("add field"),
|
|
1567
1572
|
onClick: handleAdd
|
|
@@ -1962,7 +1967,7 @@ var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, au
|
|
|
1962
1967
|
|
|
1963
1968
|
// src/components/FieldEditor/FieldEditor.tsx
|
|
1964
1969
|
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
|
|
1965
|
-
var FieldEditor = ({
|
|
1970
|
+
var FieldEditor = ({ projection, field, registry, onSave, onCancel, outerSpacing }) => {
|
|
1966
1971
|
var _effect = _useSignals14();
|
|
1967
1972
|
try {
|
|
1968
1973
|
const { t } = useTranslation8(translationKey);
|
|
@@ -2036,7 +2041,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel, outerS
|
|
|
2036
2041
|
props.referenceSchema
|
|
2037
2042
|
]);
|
|
2038
2043
|
const handleValidate = useCallback9(({ property }) => {
|
|
2039
|
-
if (property &&
|
|
2044
|
+
if (property && projection.fields.find((f) => f.path === property && f.path !== field.path)) {
|
|
2040
2045
|
return [
|
|
2041
2046
|
{
|
|
2042
2047
|
path: "property",
|
|
@@ -2045,7 +2050,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel, outerS
|
|
|
2045
2050
|
];
|
|
2046
2051
|
}
|
|
2047
2052
|
}, [
|
|
2048
|
-
|
|
2053
|
+
projection.fields,
|
|
2049
2054
|
field
|
|
2050
2055
|
]);
|
|
2051
2056
|
const handleSave = useCallback9((props2) => {
|
|
@@ -2097,7 +2102,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel, outerS
|
|
|
2097
2102
|
props
|
|
2098
2103
|
}, {
|
|
2099
2104
|
F: __dxlog_file4,
|
|
2100
|
-
L:
|
|
2105
|
+
L: 173,
|
|
2101
2106
|
S: void 0,
|
|
2102
2107
|
C: (f, a) => f(...a)
|
|
2103
2108
|
});
|
|
@@ -2135,13 +2140,10 @@ import { Callout, IconButton as IconButton4, useTranslation as useTranslation9 }
|
|
|
2135
2140
|
import { List as List2 } from "@dxos/react-ui-list";
|
|
2136
2141
|
import { cardSpacing as cardSpacing3 } from "@dxos/react-ui-stack";
|
|
2137
2142
|
import { ghostHover, inputTextLabel, mx as mx9 } from "@dxos/react-ui-theme";
|
|
2138
|
-
import { FieldSchema,
|
|
2143
|
+
import { FieldSchema, VIEW_FIELD_LIMIT, ProjectionModel } from "@dxos/schema";
|
|
2139
2144
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
|
|
2140
2145
|
var grid = "grid grid-cols-[32px_1fr_32px_32px] min-bs-[2.5rem]";
|
|
2141
2146
|
var ViewMetaSchema = Schema2.Struct({
|
|
2142
|
-
name: Schema2.String.annotations({
|
|
2143
|
-
title: "View"
|
|
2144
|
-
}),
|
|
2145
2147
|
typename: Format.URL.annotations({
|
|
2146
2148
|
title: "Typename"
|
|
2147
2149
|
})
|
|
@@ -2152,22 +2154,21 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
|
|
|
2152
2154
|
const { t } = useTranslation9(translationKey);
|
|
2153
2155
|
const projection = useMemo8(() => {
|
|
2154
2156
|
const jsonSchema = schema instanceof EchoSchema ? schema.jsonSchema : toJsonSchema(schema);
|
|
2155
|
-
return new
|
|
2157
|
+
return new ProjectionModel(jsonSchema, view.projection);
|
|
2156
2158
|
}, [
|
|
2157
2159
|
schema,
|
|
2158
|
-
view
|
|
2160
|
+
view.projection
|
|
2159
2161
|
]);
|
|
2160
2162
|
const [field, setField] = useState6();
|
|
2161
2163
|
const readonly = _readonly || !isMutable(schema);
|
|
2162
2164
|
const viewValues = useMemo8(() => {
|
|
2163
2165
|
return {
|
|
2164
|
-
name: view.name,
|
|
2165
2166
|
// TODO(burdon): Need to warn user of possible consequences of editing.
|
|
2166
2167
|
// TODO(burdon): Settings should have domain name owned by user.
|
|
2167
2168
|
typename: view.query.typename
|
|
2168
2169
|
};
|
|
2169
2170
|
}, [
|
|
2170
|
-
view
|
|
2171
|
+
view.query.typename
|
|
2171
2172
|
]);
|
|
2172
2173
|
const handleSelect = useCallback10((field2) => {
|
|
2173
2174
|
if (readonly) {
|
|
@@ -2180,7 +2181,7 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
|
|
|
2180
2181
|
const handleAdd = useCallback10(() => {
|
|
2181
2182
|
invariant3(!readonly, void 0, {
|
|
2182
2183
|
F: __dxlog_file5,
|
|
2183
|
-
L:
|
|
2184
|
+
L: 88,
|
|
2184
2185
|
S: void 0,
|
|
2185
2186
|
A: [
|
|
2186
2187
|
"!readonly",
|
|
@@ -2191,13 +2192,13 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
|
|
|
2191
2192
|
setField(field2);
|
|
2192
2193
|
}, [
|
|
2193
2194
|
schema,
|
|
2194
|
-
|
|
2195
|
+
projection,
|
|
2195
2196
|
readonly
|
|
2196
2197
|
]);
|
|
2197
|
-
const handleUpdate = useCallback10(({
|
|
2198
|
+
const handleUpdate = useCallback10(({ typename }) => {
|
|
2198
2199
|
invariant3(!readonly, void 0, {
|
|
2199
2200
|
F: __dxlog_file5,
|
|
2200
|
-
L:
|
|
2201
|
+
L: 95,
|
|
2201
2202
|
S: void 0,
|
|
2202
2203
|
A: [
|
|
2203
2204
|
"!readonly",
|
|
@@ -2205,23 +2206,19 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
|
|
|
2205
2206
|
]
|
|
2206
2207
|
});
|
|
2207
2208
|
requestAnimationFrame(() => {
|
|
2208
|
-
if (view.name !== name) {
|
|
2209
|
-
view.name = name;
|
|
2210
|
-
}
|
|
2211
2209
|
if (view.query.typename !== typename && !readonly) {
|
|
2212
2210
|
onTypenameChanged?.(typename);
|
|
2213
2211
|
}
|
|
2214
2212
|
});
|
|
2215
2213
|
}, [
|
|
2216
|
-
|
|
2217
|
-
view,
|
|
2214
|
+
view.query.typename,
|
|
2218
2215
|
onTypenameChanged,
|
|
2219
2216
|
readonly
|
|
2220
2217
|
]);
|
|
2221
2218
|
const handleDelete = useCallback10((fieldId) => {
|
|
2222
2219
|
invariant3(!readonly, void 0, {
|
|
2223
2220
|
F: __dxlog_file5,
|
|
2224
|
-
L:
|
|
2221
|
+
L: 107,
|
|
2225
2222
|
S: void 0,
|
|
2226
2223
|
A: [
|
|
2227
2224
|
"!readonly",
|
|
@@ -2233,7 +2230,6 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
|
|
|
2233
2230
|
}
|
|
2234
2231
|
onDelete?.(fieldId);
|
|
2235
2232
|
}, [
|
|
2236
|
-
schema,
|
|
2237
2233
|
field,
|
|
2238
2234
|
onDelete,
|
|
2239
2235
|
readonly
|
|
@@ -2241,7 +2237,7 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
|
|
|
2241
2237
|
const handleMove = useCallback10((fromIndex, toIndex) => {
|
|
2242
2238
|
invariant3(!readonly, void 0, {
|
|
2243
2239
|
F: __dxlog_file5,
|
|
2244
|
-
L:
|
|
2240
|
+
L: 119,
|
|
2245
2241
|
S: void 0,
|
|
2246
2242
|
A: [
|
|
2247
2243
|
"!readonly",
|
|
@@ -2249,14 +2245,13 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
|
|
|
2249
2245
|
]
|
|
2250
2246
|
});
|
|
2251
2247
|
const fields = [
|
|
2252
|
-
...view.fields
|
|
2248
|
+
...view.projection.fields
|
|
2253
2249
|
];
|
|
2254
2250
|
const [moved] = fields.splice(fromIndex, 1);
|
|
2255
2251
|
fields.splice(toIndex, 0, moved);
|
|
2256
|
-
view.fields = fields;
|
|
2252
|
+
view.projection.fields = fields;
|
|
2257
2253
|
}, [
|
|
2258
|
-
|
|
2259
|
-
view.fields,
|
|
2254
|
+
view.projection.fields,
|
|
2260
2255
|
readonly
|
|
2261
2256
|
]);
|
|
2262
2257
|
const handleClose = useCallback10(() => setField(void 0), []);
|
|
@@ -2294,7 +2289,7 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
|
|
|
2294
2289
|
}, /* @__PURE__ */ React15.createElement("label", {
|
|
2295
2290
|
className: mx9(inputTextLabel)
|
|
2296
2291
|
}, t("fields label")), /* @__PURE__ */ React15.createElement(List2.Root, {
|
|
2297
|
-
items: view.fields,
|
|
2292
|
+
items: view.projection.fields,
|
|
2298
2293
|
isItem: Schema2.is(FieldSchema),
|
|
2299
2294
|
getId: (field2) => field2.id,
|
|
2300
2295
|
readonly,
|
|
@@ -2317,10 +2312,10 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
|
|
|
2317
2312
|
"data-testid": "hide-field-button",
|
|
2318
2313
|
icon: "ph--eye-slash--regular",
|
|
2319
2314
|
// TDOO(burdon): Is this the correct test?
|
|
2320
|
-
disabled: view.fields.length <= 1,
|
|
2315
|
+
disabled: view.projection.fields.length <= 1,
|
|
2321
2316
|
onClick: () => handleHide(field2.id)
|
|
2322
2317
|
}), !readonly && /* @__PURE__ */ React15.createElement(List2.ItemDeleteButton, {
|
|
2323
|
-
disabled: view.fields.length <= 1,
|
|
2318
|
+
disabled: view.projection.fields.length <= 1,
|
|
2324
2319
|
onClick: () => handleDelete(field2.id)
|
|
2325
2320
|
})))))), hiddenProperties.length > 0 && /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement("label", {
|
|
2326
2321
|
className: mx9(inputTextLabel)
|
|
@@ -2343,7 +2338,6 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
|
|
|
2343
2338
|
"data-testid": "show-field-button"
|
|
2344
2339
|
}))))))), field && /* @__PURE__ */ React15.createElement(FieldEditor, {
|
|
2345
2340
|
key: field.id,
|
|
2346
|
-
view,
|
|
2347
2341
|
projection,
|
|
2348
2342
|
field,
|
|
2349
2343
|
registry,
|
|
@@ -2356,7 +2350,7 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
|
|
|
2356
2350
|
label: t("button add property"),
|
|
2357
2351
|
onClick: readonly ? void 0 : handleAdd,
|
|
2358
2352
|
// TODO(burdon): Show field limit in ux (not tooltip).
|
|
2359
|
-
disabled: view.fields.length >= VIEW_FIELD_LIMIT,
|
|
2353
|
+
disabled: view.projection.fields.length >= VIEW_FIELD_LIMIT,
|
|
2360
2354
|
classNames: "flex is-full"
|
|
2361
2355
|
})));
|
|
2362
2356
|
} finally {
|