@dxos/react-ui-form 0.8.2 → 0.8.3-main.7f5a14c
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 +19 -19
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +18 -18
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +19 -19
- 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.stories.d.ts +6 -0
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.d.ts +2 -1
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +8 -0
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.test.d.ts +2 -0
- package/dist/types/src/components/ViewEditor/ViewEditor.test.d.ts.map +1 -0
- package/package.json +27 -26
- package/src/components/FieldEditor/FieldEditor.stories.tsx +27 -4
- package/src/components/FieldEditor/FieldEditor.test.tsx +20 -13
- package/src/components/Form/Form.stories.tsx +3 -3
- package/src/components/Form/Form.tsx +4 -1
- package/src/components/Form/FormActions.tsx +1 -1
- package/src/components/Form/FormContent.tsx +2 -2
- package/src/components/ViewEditor/ViewEditor.stories.tsx +27 -8
- package/src/components/ViewEditor/ViewEditor.test.tsx +203 -0
- package/src/components/ViewEditor/ViewEditor.tsx +25 -22
- package/src/hooks/useRefQueryLookupHandler.ts +2 -2
|
@@ -732,6 +732,7 @@ var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus,
|
|
|
732
732
|
// packages/ui/react-ui-form/src/components/Form/Form.tsx
|
|
733
733
|
import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
|
|
734
734
|
import React13, { useEffect as useEffect7, useMemo as useMemo6, useRef as useRef3 } from "react";
|
|
735
|
+
import { cardSpacing } from "@dxos/react-ui-stack";
|
|
735
736
|
import { mx as mx7 } from "@dxos/react-ui-theme";
|
|
736
737
|
|
|
737
738
|
// packages/ui/react-ui-form/src/components/Form/FormActions.tsx
|
|
@@ -957,7 +958,7 @@ var flatMap = (errors) => {
|
|
|
957
958
|
|
|
958
959
|
// packages/ui/react-ui-form/src/hooks/useRefQueryLookupHandler.ts
|
|
959
960
|
import { useCallback as useCallback5 } from "react";
|
|
960
|
-
import {
|
|
961
|
+
import { getObjectDXN } from "@dxos/echo-schema";
|
|
961
962
|
import { Filter } from "@dxos/react-client/echo";
|
|
962
963
|
import { isNonNullable } from "@dxos/util";
|
|
963
964
|
var useRefQueryLookupHandler = ({ space }) => {
|
|
@@ -968,7 +969,7 @@ var useRefQueryLookupHandler = ({ space }) => {
|
|
|
968
969
|
const query = space.db.query(Filter.typename(typeInfo.typename));
|
|
969
970
|
const { objects } = await query.run();
|
|
970
971
|
return objects.map((object) => {
|
|
971
|
-
const dxn =
|
|
972
|
+
const dxn = getObjectDXN(object);
|
|
972
973
|
if (!dxn) {
|
|
973
974
|
return void 0;
|
|
974
975
|
}
|
|
@@ -1110,7 +1111,7 @@ var FormActions = ({ readonly, onCancel }) => {
|
|
|
1110
1111
|
const { canSave, handleSave } = useFormContext();
|
|
1111
1112
|
return /* @__PURE__ */ React9.createElement("div", {
|
|
1112
1113
|
role: "none",
|
|
1113
|
-
className: "flex [&_button]:grow gap-1"
|
|
1114
|
+
className: "flex [&_button]:grow gap-1 mlb-3 last:mbe-0 first:mbs-0"
|
|
1114
1115
|
}, onCancel && !readonly && /* @__PURE__ */ React9.createElement(IconButton2, {
|
|
1115
1116
|
"data-testid": "cancel-button",
|
|
1116
1117
|
icon: "ph--x--regular",
|
|
@@ -1833,7 +1834,7 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1833
1834
|
const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, inputProps.getValue()) : findNode3(ast, SchemaAST4.isTypeLiteral);
|
|
1834
1835
|
if (typeLiteral) {
|
|
1835
1836
|
return /* @__PURE__ */ React12.createElement(React12.Fragment, null, !inline && /* @__PURE__ */ React12.createElement("h3", {
|
|
1836
|
-
className: "text-lg
|
|
1837
|
+
className: mx6("text-lg mlb-card-spacing-block first:mbs-0")
|
|
1837
1838
|
}, label), /* @__PURE__ */ React12.createElement(FormFields, {
|
|
1838
1839
|
schema: Schema.make(typeLiteral),
|
|
1839
1840
|
path,
|
|
@@ -1867,7 +1868,7 @@ var FormFields = ({ classNames, Custom, schema, path, filter, sort, readonly, lo
|
|
|
1867
1868
|
// TODO(burdon): Consistent padding (with composite forms).
|
|
1868
1869
|
/* @__PURE__ */ React12.createElement("div", {
|
|
1869
1870
|
role: "form",
|
|
1870
|
-
className: mx6("
|
|
1871
|
+
className: mx6("is-full", classNames)
|
|
1871
1872
|
}, properties.map((property) => {
|
|
1872
1873
|
return /* @__PURE__ */ React12.createElement(FormField, {
|
|
1873
1874
|
key: property.name,
|
|
@@ -1889,7 +1890,7 @@ var FormFields = ({ classNames, Custom, schema, path, filter, sort, readonly, lo
|
|
|
1889
1890
|
};
|
|
1890
1891
|
|
|
1891
1892
|
// packages/ui/react-ui-form/src/components/Form/Form.tsx
|
|
1892
|
-
var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, readonly, filter, sort, autoSave, testId, onValuesChanged, onValidate, onSave, onCancel, onQueryRefOptions, lookupComponent, Custom }) => {
|
|
1893
|
+
var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, readonly, filter, sort, autoSave, flush, testId, onValuesChanged, onValidate, onSave, onCancel, onQueryRefOptions, lookupComponent, Custom }) => {
|
|
1893
1894
|
var _effect = _useSignals13();
|
|
1894
1895
|
try {
|
|
1895
1896
|
const formRef = useRef3(null);
|
|
@@ -1919,7 +1920,7 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1919
1920
|
}, /* @__PURE__ */ React13.createElement("div", {
|
|
1920
1921
|
ref: formRef,
|
|
1921
1922
|
role: "none",
|
|
1922
|
-
className: mx7(
|
|
1923
|
+
className: mx7(!flush && cardSpacing, classNames),
|
|
1923
1924
|
"data-testid": testId
|
|
1924
1925
|
}, /* @__PURE__ */ React13.createElement(FormFields, {
|
|
1925
1926
|
schema,
|
|
@@ -2250,13 +2251,10 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2250
2251
|
return /* @__PURE__ */ React15.createElement("div", {
|
|
2251
2252
|
role: "none",
|
|
2252
2253
|
className: mx8("overflow-y-auto", classNames)
|
|
2253
|
-
}, /* @__PURE__ */ React15.createElement("div", {
|
|
2254
|
-
role: "none",
|
|
2255
|
-
className: "p-2"
|
|
2256
|
-
}, /* @__PURE__ */ React15.createElement("div", {
|
|
2254
|
+
}, immutable && /* @__PURE__ */ React15.createElement("div", {
|
|
2257
2255
|
role: "none",
|
|
2258
|
-
className: "mbe-
|
|
2259
|
-
},
|
|
2256
|
+
className: "mbe-card-spacing-block"
|
|
2257
|
+
}, /* @__PURE__ */ React15.createElement(Message.Root, {
|
|
2260
2258
|
valence: "neutral",
|
|
2261
2259
|
className: "rounded"
|
|
2262
2260
|
}, /* @__PURE__ */ React15.createElement(Message.Title, null, /* @__PURE__ */ React15.createElement(Icon3, {
|
|
@@ -2269,12 +2267,12 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2269
2267
|
values: viewValues,
|
|
2270
2268
|
onSave: handleUpdate,
|
|
2271
2269
|
classNames: "min-bs-0 overflow-y-auto"
|
|
2272
|
-
})
|
|
2270
|
+
}), /* @__PURE__ */ React15.createElement("div", {
|
|
2273
2271
|
role: "none",
|
|
2274
2272
|
className: "min-bs-0 overflow-y-auto"
|
|
2275
2273
|
}, /* @__PURE__ */ React15.createElement("div", {
|
|
2276
2274
|
role: "none",
|
|
2277
|
-
className: "
|
|
2275
|
+
className: "pli-card-spacing-inline mlb-card-spacing-block"
|
|
2278
2276
|
}, /* @__PURE__ */ React15.createElement("label", {
|
|
2279
2277
|
className: mx8(inputTextLabel)
|
|
2280
2278
|
}, t("fields label"))), /* @__PURE__ */ React15.createElement(List2.Root, {
|
|
@@ -2301,14 +2299,15 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2301
2299
|
}, /* @__PURE__ */ React15.createElement(List2.ItemButton, {
|
|
2302
2300
|
icon: "ph--eye-slash--regular",
|
|
2303
2301
|
disabled: view.fields.length <= 1,
|
|
2304
|
-
onClick: () => handleHide(field2.id)
|
|
2302
|
+
onClick: () => handleHide(field2.id),
|
|
2303
|
+
"data-testid": "hide-field-button"
|
|
2305
2304
|
}), !immutable && /* @__PURE__ */ React15.createElement(List2.ItemDeleteButton, {
|
|
2306
2305
|
icon: "ph--trash--regular",
|
|
2307
2306
|
disabled: view.fields.length <= 1,
|
|
2308
2307
|
onClick: () => handleDelete(field2.id)
|
|
2309
2308
|
}))))))), hiddenProperties.length > 0 && /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement("div", {
|
|
2310
2309
|
role: "none",
|
|
2311
|
-
className: "
|
|
2310
|
+
className: "pli-card-spacing-inline mlb-card-spacing-block"
|
|
2312
2311
|
}, /* @__PURE__ */ React15.createElement("label", {
|
|
2313
2312
|
className: mx8(inputTextLabel)
|
|
2314
2313
|
}, t("hidden fields label"))), /* @__PURE__ */ React15.createElement(List2.Root, {
|
|
@@ -2324,7 +2323,8 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2324
2323
|
classNames: mx8(grid, ghostHover, !immutable && "cursor-pointer")
|
|
2325
2324
|
}, /* @__PURE__ */ React15.createElement("div", null), /* @__PURE__ */ React15.createElement(List2.ItemTitle, null, property), /* @__PURE__ */ React15.createElement(List2.ItemButton, {
|
|
2326
2325
|
icon: "ph--eye--regular",
|
|
2327
|
-
onClick: () => handleShow(property)
|
|
2326
|
+
onClick: () => handleShow(property),
|
|
2327
|
+
"data-testid": "show-field-button"
|
|
2328
2328
|
}))))))), field && /* @__PURE__ */ React15.createElement(FieldEditor, {
|
|
2329
2329
|
key: field.id,
|
|
2330
2330
|
view,
|
|
@@ -2334,7 +2334,7 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2334
2334
|
onSave: handleClose
|
|
2335
2335
|
}), !readonly && !field && /* @__PURE__ */ React15.createElement("div", {
|
|
2336
2336
|
role: "none",
|
|
2337
|
-
className: "
|
|
2337
|
+
className: "pli-card-spacing-chrome mlb-card-spacing-chrome"
|
|
2338
2338
|
}, /* @__PURE__ */ React15.createElement(IconButton4, {
|
|
2339
2339
|
icon: "ph--plus--regular",
|
|
2340
2340
|
label: t("button add property"),
|