@dxos/react-ui-form 0.8.0 → 0.8.1-main.a06ad20

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.
Files changed (53) hide show
  1. package/dist/lib/browser/index.mjs +56 -6
  2. package/dist/lib/browser/index.mjs.map +3 -3
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +75 -25
  5. package/dist/lib/node/index.cjs.map +3 -3
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/index.mjs +56 -6
  8. package/dist/lib/node-esm/index.mjs.map +3 -3
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +2 -1
  11. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
  12. package/dist/types/src/components/Form/ArrayField.d.ts +2 -1
  13. package/dist/types/src/components/Form/ArrayField.d.ts.map +1 -1
  14. package/dist/types/src/components/Form/Defaults.d.ts +6 -5
  15. package/dist/types/src/components/Form/Defaults.d.ts.map +1 -1
  16. package/dist/types/src/components/Form/Form.d.ts +2 -2
  17. package/dist/types/src/components/Form/Form.d.ts.map +1 -1
  18. package/dist/types/src/components/Form/Form.stories.d.ts +7 -7
  19. package/dist/types/src/components/Form/FormActions.d.ts +2 -1
  20. package/dist/types/src/components/Form/FormActions.d.ts.map +1 -1
  21. package/dist/types/src/components/Form/FormContent.d.ts +3 -2
  22. package/dist/types/src/components/Form/FormContent.d.ts.map +1 -1
  23. package/dist/types/src/components/Form/FormContext.d.ts +1 -1
  24. package/dist/types/src/components/Form/FormContext.d.ts.map +1 -1
  25. package/dist/types/src/components/Form/Input.d.ts +2 -2
  26. package/dist/types/src/components/Form/Input.d.ts.map +1 -1
  27. package/dist/types/src/components/Form/custom/GeoPointInput.d.ts +2 -1
  28. package/dist/types/src/components/Form/custom/GeoPointInput.d.ts.map +1 -1
  29. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts +2 -1
  30. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +1 -1
  31. package/dist/types/src/components/Form/custom/TupleInput.d.ts +2 -1
  32. package/dist/types/src/components/Form/custom/TupleInput.d.ts.map +1 -1
  33. package/dist/types/src/components/ViewEditor/Test.stories.d.ts +2 -1
  34. package/dist/types/src/components/ViewEditor/Test.stories.d.ts.map +1 -1
  35. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +2 -1
  36. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  37. package/dist/types/src/components/deprecated/Form.d.ts +3 -2
  38. package/dist/types/src/components/deprecated/Form.d.ts.map +1 -1
  39. package/dist/types/src/components/deprecated/Form.stories.d.ts +2 -1
  40. package/dist/types/src/components/deprecated/Form.stories.d.ts.map +1 -1
  41. package/dist/types/src/components/deprecated/FormInput.d.ts +2 -2
  42. package/dist/types/src/components/deprecated/FormInput.d.ts.map +1 -1
  43. package/dist/types/src/components/testing.d.ts +3 -3
  44. package/dist/types/src/components/testing.d.ts.map +1 -1
  45. package/dist/types/src/hooks/useForm.d.ts +2 -1
  46. package/dist/types/src/hooks/useForm.d.ts.map +1 -1
  47. package/dist/types/src/translations.d.ts +1 -0
  48. package/dist/types/src/translations.d.ts.map +1 -1
  49. package/package.json +26 -28
  50. package/src/components/ViewEditor/ViewEditor.tsx +71 -2
  51. package/src/components/deprecated/Form.tsx +2 -2
  52. package/src/hooks/useForm.ts +2 -1
  53. package/src/translations.ts +1 -0
@@ -5,6 +5,7 @@ var translations_default = [
5
5
  "en-US": {
6
6
  [translationKey]: {
7
7
  "fields label": "Fields",
8
+ "hidden fields label": "Hidden Fields",
8
9
  // TODO(burdon): Standardize field/property.
9
10
  "button add property": "Add property",
10
11
  "field property label": "Property",
@@ -112,9 +113,10 @@ import { getValue as getValue2 } from "@dxos/echo-schema";
112
113
  import { createJsonPath as createJsonPath2 } from "@dxos/effect";
113
114
 
114
115
  // packages/ui/react-ui-form/src/hooks/useForm.ts
116
+ import { SchemaAST as AST } from "effect";
115
117
  import { useCallback, useEffect, useMemo, useState } from "react";
116
118
  import { getValue, setValue } from "@dxos/echo-schema";
117
- import { AST, createJsonPath, fromEffectValidationPath } from "@dxos/effect";
119
+ import { createJsonPath, fromEffectValidationPath } from "@dxos/effect";
118
120
  import { invariant } from "@dxos/invariant";
119
121
  import { log } from "@dxos/log";
120
122
  import { validateSchema } from "@dxos/schema";
@@ -122,7 +124,7 @@ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/ho
122
124
  var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, onSave }) => {
123
125
  invariant(AST.isTypeLiteral(schema.ast), void 0, {
124
126
  F: __dxlog_file,
125
- L: 92,
127
+ L: 93,
126
128
  S: void 0,
127
129
  A: [
128
130
  "AST.isTypeLiteral(schema.ast)",
@@ -218,7 +220,7 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
218
220
  } catch (err) {
219
221
  log.catch(err, void 0, {
220
222
  F: __dxlog_file,
221
- L: 202,
223
+ L: 203,
222
224
  S: void 0,
223
225
  C: (f, a) => f(...a)
224
226
  });
@@ -289,7 +291,7 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
289
291
  var createKeySet = (obj, value) => {
290
292
  invariant(obj, void 0, {
291
293
  F: __dxlog_file,
292
- L: 264,
294
+ L: 265,
293
295
  S: void 0,
294
296
  A: [
295
297
  "obj",
@@ -1357,6 +1359,15 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
1357
1359
  }, [
1358
1360
  view
1359
1361
  ]);
1362
+ const handleDelete = useCallback7((fieldId) => {
1363
+ if (fieldId === field?.id) {
1364
+ setField(void 0);
1365
+ }
1366
+ onDelete(fieldId);
1367
+ }, [
1368
+ onDelete,
1369
+ field
1370
+ ]);
1360
1371
  const handleMove = useCallback7((fromIndex, toIndex) => {
1361
1372
  const fields = [
1362
1373
  ...view.fields
@@ -1368,6 +1379,19 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
1368
1379
  view.fields
1369
1380
  ]);
1370
1381
  const handleClose = useCallback7(() => setField(void 0), []);
1382
+ const hiddenProperties = projection.getHiddenProperties();
1383
+ const handleHide = useCallback7((fieldId) => {
1384
+ setField(void 0);
1385
+ projection.hideFieldProjection(fieldId);
1386
+ }, [
1387
+ projection
1388
+ ]);
1389
+ const handleShow = useCallback7((property) => {
1390
+ setField(void 0);
1391
+ projection.showFieldProjection(property);
1392
+ }, [
1393
+ projection
1394
+ ]);
1371
1395
  return /* @__PURE__ */ React13.createElement("div", {
1372
1396
  role: "none",
1373
1397
  className: mx8("flex flex-col w-full divide-y divide-separator", classNames)
@@ -1400,9 +1424,35 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
1400
1424
  classNames: mx8(grid, ghostHover, "cursor-pointer")
1401
1425
  }, /* @__PURE__ */ React13.createElement(List2.ItemDragHandle, null), /* @__PURE__ */ React13.createElement(List2.ItemTitle, {
1402
1426
  onClick: () => handleSelect(field2)
1403
- }, field2.path), /* @__PURE__ */ React13.createElement(List2.ItemDeleteButton, {
1427
+ }, field2.path), /* @__PURE__ */ React13.createElement("div", {
1428
+ className: "flex items-center gap-2 -ml-4"
1429
+ }, /* @__PURE__ */ React13.createElement(List2.ItemButton, {
1430
+ icon: "ph--eye-slash--regular",
1404
1431
  disabled: view.fields.length <= 1,
1405
- onClick: () => onDelete(field2.id)
1432
+ onClick: () => handleHide(field2.id)
1433
+ }), /* @__PURE__ */ React13.createElement(List2.ItemDeleteButton, {
1434
+ icon: "ph--trash--regular",
1435
+ disabled: view.fields.length <= 1,
1436
+ onClick: () => handleDelete(field2.id)
1437
+ }))))))), hiddenProperties.length > 0 && /* @__PURE__ */ React13.createElement("div", null, /* @__PURE__ */ React13.createElement("div", {
1438
+ role: "none",
1439
+ className: "p-2"
1440
+ }, /* @__PURE__ */ React13.createElement("label", {
1441
+ className: mx8(inputTextLabel)
1442
+ }, t("hidden fields label"))), /* @__PURE__ */ React13.createElement(List2.Root, {
1443
+ items: hiddenProperties,
1444
+ isItem: (item) => typeof item === "string",
1445
+ getId: (property) => property
1446
+ }, ({ items: properties }) => /* @__PURE__ */ React13.createElement("div", {
1447
+ role: "list",
1448
+ className: "flex flex-col w-full"
1449
+ }, properties?.map((property) => /* @__PURE__ */ React13.createElement(List2.Item, {
1450
+ key: property,
1451
+ item: property,
1452
+ classNames: mx8(grid, ghostHover, "cursor-pointer")
1453
+ }, /* @__PURE__ */ React13.createElement("div", null), /* @__PURE__ */ React13.createElement(List2.ItemTitle, null, property), /* @__PURE__ */ React13.createElement(List2.ItemButton, {
1454
+ icon: "ph--eye--regular",
1455
+ onClick: () => handleShow(property)
1406
1456
  }))))))), field && /* @__PURE__ */ React13.createElement(FieldEditor, {
1407
1457
  key: field.id,
1408
1458
  view,