@dxos/react-ui-form 0.8.3-main.672df60 → 0.8.3-staging.0fa589b
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 +190 -173
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +150 -133
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +190 -173
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/ControlSection/ControlSection.d.ts +1 -1
- package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +1 -1
- package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +3 -2
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +5 -0
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/Defaults.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.d.ts +6 -14
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +2 -2
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormActions.d.ts +3 -1
- package/dist/types/src/components/Form/FormActions.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormContent.d.ts +30 -3
- package/dist/types/src/components/Form/FormContent.d.ts.map +1 -1
- package/dist/types/src/components/Form/Input.d.ts +6 -4
- package/dist/types/src/components/Form/Input.d.ts.map +1 -1
- package/dist/types/src/components/Form/RefField.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/GeoPointInput.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/TupleInput.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +3 -2
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +7 -0
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +3 -1
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/package.json +28 -26
- package/src/components/ControlSection/ControlSection.stories.tsx +15 -3
- package/src/components/ControlSection/ControlSection.tsx +11 -9
- package/src/components/FieldEditor/FieldEditor.stories.tsx +25 -5
- package/src/components/FieldEditor/FieldEditor.test.tsx +21 -13
- package/src/components/FieldEditor/FieldEditor.tsx +11 -2
- package/src/components/Form/ArrayField.tsx +1 -1
- package/src/components/Form/Defaults.tsx +5 -25
- package/src/components/Form/Form.stories.tsx +5 -5
- package/src/components/Form/Form.tsx +44 -49
- package/src/components/Form/FormActions.tsx +17 -2
- package/src/components/Form/FormContent.tsx +46 -46
- package/src/components/Form/Input.tsx +13 -8
- package/src/components/Form/RefField.tsx +1 -5
- package/src/components/Form/custom/GeoPointInput.tsx +1 -3
- package/src/components/Form/custom/SelectOptionsInput.stories.tsx +7 -5
- package/src/components/Form/custom/SelectOptionsInput.tsx +1 -3
- package/src/components/Form/custom/TupleInput.tsx +1 -3
- package/src/components/ViewEditor/ViewEditor.stories.tsx +25 -9
- package/src/components/ViewEditor/ViewEditor.test.tsx +80 -42
- package/src/components/ViewEditor/ViewEditor.tsx +66 -66
- package/src/components/testing.tsx +12 -7
- package/src/translations.ts +4 -1
|
@@ -28,6 +28,7 @@ var translations_default = [
|
|
|
28
28
|
"format date-time": "DateTime",
|
|
29
29
|
"format did": "DID",
|
|
30
30
|
"format duration": "Duration",
|
|
31
|
+
"format dxn": "DXN",
|
|
31
32
|
"format email": "Email",
|
|
32
33
|
"format formula": "Formula",
|
|
33
34
|
"format hostname": "Hostname",
|
|
@@ -40,12 +41,14 @@ var translations_default = [
|
|
|
40
41
|
"format regex": "RegExp",
|
|
41
42
|
"format string": "String",
|
|
42
43
|
"format single-select": "Select",
|
|
44
|
+
"format multi-select": "Multi-select",
|
|
43
45
|
"format text": "Long text",
|
|
44
46
|
"format time": "Time",
|
|
45
47
|
"format timestamp": "Timestamp",
|
|
46
48
|
"format user": "User",
|
|
47
49
|
"format number": "Number",
|
|
48
50
|
"format uri": "URI",
|
|
51
|
+
"format url": "URL",
|
|
49
52
|
"format uuid": "UUID",
|
|
50
53
|
// Placeholders.
|
|
51
54
|
"placeholder latitude": "Latitude",
|
|
@@ -58,7 +61,7 @@ var translations_default = [
|
|
|
58
61
|
"select option add": "Add option",
|
|
59
62
|
// System schema message.
|
|
60
63
|
"system schema title": "System Schema",
|
|
61
|
-
"system schema description": "This
|
|
64
|
+
"system schema description": "This is a system schema and cannot be modified."
|
|
62
65
|
}
|
|
63
66
|
}
|
|
64
67
|
}
|
|
@@ -126,7 +129,7 @@ var ControlPage = ({ children, classNames, ...props }) => {
|
|
|
126
129
|
try {
|
|
127
130
|
return /* @__PURE__ */ React2.createElement("div", {
|
|
128
131
|
role: "none",
|
|
129
|
-
className: mx2("pli-
|
|
132
|
+
className: mx2("pli-cardSpacingInline", classNames),
|
|
130
133
|
...props
|
|
131
134
|
}, children);
|
|
132
135
|
} finally {
|
|
@@ -149,9 +152,9 @@ var ControlSectionHeading = ({ title, description }) => {
|
|
|
149
152
|
try {
|
|
150
153
|
const { t } = useTranslation(translationKey);
|
|
151
154
|
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("h2", {
|
|
152
|
-
className: "pli-
|
|
155
|
+
className: "pli-trimMd container-max-width text-xl mbs-trimLg mbe-trimMd"
|
|
153
156
|
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React2.createElement("p", {
|
|
154
|
-
className: "pli-
|
|
157
|
+
className: "pli-trimMd mlb-trimMd container-max-width text-description"
|
|
155
158
|
}, toLocalizedString(description, t)));
|
|
156
159
|
} finally {
|
|
157
160
|
_effect.f();
|
|
@@ -176,7 +179,7 @@ var ControlGroup = ({ children, classNames }) => {
|
|
|
176
179
|
try {
|
|
177
180
|
return /* @__PURE__ */ React2.createElement("div", {
|
|
178
181
|
role: "none",
|
|
179
|
-
className: mx2("group container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content] gap-
|
|
182
|
+
className: mx2("group container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content] gap-trimMd", classNames)
|
|
180
183
|
}, children);
|
|
181
184
|
} finally {
|
|
182
185
|
_effect.f();
|
|
@@ -187,15 +190,15 @@ var ControlFrame = ({ children }) => {
|
|
|
187
190
|
try {
|
|
188
191
|
return /* @__PURE__ */ React2.createElement("div", {
|
|
189
192
|
role: "none",
|
|
190
|
-
className: "p-
|
|
193
|
+
className: "p-trimMd container-max-width grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-trimSm md:gap-trimMd border border-separator rounded-md"
|
|
191
194
|
}, children);
|
|
192
195
|
} finally {
|
|
193
196
|
_effect.f();
|
|
194
197
|
}
|
|
195
198
|
};
|
|
196
|
-
var controlItemClasses = "
|
|
199
|
+
var controlItemClasses = "pli-trimMd plb-trimMd container-max-width grid md:col-span-2 grid-cols-subgrid items-center gap-trimSm border border-separator rounded-md *:first:!mbs-0 *:last:!mbe-0";
|
|
197
200
|
var controlItemTitleClasses = "text-lg font-normal";
|
|
198
|
-
var controlItemDescriptionClasses = "text-base mlb-
|
|
201
|
+
var controlItemDescriptionClasses = "text-base mlb-trimSm md:mbe-0 text-description";
|
|
199
202
|
var ControlItem = ({ title, description, children }) => {
|
|
200
203
|
var _effect = _useSignals2();
|
|
201
204
|
try {
|
|
@@ -240,7 +243,7 @@ var ControlFrameItem = ({ title, description, children }) => {
|
|
|
240
243
|
}, /* @__PURE__ */ React2.createElement("h3", {
|
|
241
244
|
className: "text-lg mbe-2"
|
|
242
245
|
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React2.createElement("p", {
|
|
243
|
-
className: "mlb-
|
|
246
|
+
className: "mlb-trimSm md:mbe-0 text-description"
|
|
244
247
|
}, toLocalizedString(description, t)), children);
|
|
245
248
|
} finally {
|
|
246
249
|
_effect.f();
|
|
@@ -259,21 +262,26 @@ import { getFormatSchema, getSchemaProperties as getSchemaProperties3, sortPrope
|
|
|
259
262
|
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
260
263
|
import React4, { useCallback, useState, useEffect, useMemo } from "react";
|
|
261
264
|
import { GeoLocation } from "@dxos/echo-schema";
|
|
262
|
-
import { Input as
|
|
265
|
+
import { Input as Input4, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
263
266
|
import { safeParseFloat } from "@dxos/util";
|
|
264
267
|
|
|
265
268
|
// packages/ui/react-ui-form/src/components/Form/Input.tsx
|
|
266
269
|
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
267
270
|
import React3 from "react";
|
|
268
|
-
import { Icon, Tooltip } from "@dxos/react-ui";
|
|
269
|
-
import {
|
|
270
|
-
|
|
271
|
+
import { Icon, Input as Input3, Tooltip } from "@dxos/react-ui";
|
|
272
|
+
import { labelSpacing } from "@dxos/react-ui-stack";
|
|
273
|
+
import { errorText, mx as mx3 } from "@dxos/react-ui-theme";
|
|
274
|
+
var InputHeader = ({ error, label, readonly }) => {
|
|
271
275
|
var _effect = _useSignals3();
|
|
272
276
|
try {
|
|
277
|
+
const Label = readonly ? "span" : Input3.Label;
|
|
278
|
+
const labelProps = readonly ? {} : {
|
|
279
|
+
classNames: "!mlb-0"
|
|
280
|
+
};
|
|
273
281
|
return /* @__PURE__ */ React3.createElement("div", {
|
|
274
282
|
role: "none",
|
|
275
|
-
className: "flex justify-between items-center
|
|
276
|
-
},
|
|
283
|
+
className: mx3("flex justify-between items-center", labelSpacing)
|
|
284
|
+
}, /* @__PURE__ */ React3.createElement(Label, labelProps, label), error && /* @__PURE__ */ React3.createElement(Tooltip.Trigger, {
|
|
277
285
|
asChild: true,
|
|
278
286
|
content: error,
|
|
279
287
|
side: "bottom"
|
|
@@ -334,14 +342,15 @@ var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, on
|
|
|
334
342
|
onValueChange,
|
|
335
343
|
type
|
|
336
344
|
]);
|
|
337
|
-
return /* @__PURE__ */ React4.createElement(
|
|
345
|
+
return /* @__PURE__ */ React4.createElement(Input4.Root, {
|
|
338
346
|
validationValence: status
|
|
339
347
|
}, /* @__PURE__ */ React4.createElement(InputHeader, {
|
|
340
|
-
error
|
|
341
|
-
|
|
348
|
+
error,
|
|
349
|
+
label
|
|
350
|
+
}), /* @__PURE__ */ React4.createElement("div", {
|
|
342
351
|
role: "none",
|
|
343
352
|
className: "grid grid-cols-2 gap-2"
|
|
344
|
-
}, /* @__PURE__ */ React4.createElement(
|
|
353
|
+
}, /* @__PURE__ */ React4.createElement(Input4.TextInput, {
|
|
345
354
|
type: "text",
|
|
346
355
|
pattern: "^-?[0-9]*\\.?[0-9]*$",
|
|
347
356
|
disabled,
|
|
@@ -349,7 +358,7 @@ var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, on
|
|
|
349
358
|
value: latitudeText,
|
|
350
359
|
onChange: handleCoordinateChange("latitude", setLatitudeText),
|
|
351
360
|
onBlur
|
|
352
|
-
}), /* @__PURE__ */ React4.createElement(
|
|
361
|
+
}), /* @__PURE__ */ React4.createElement(Input4.TextInput, {
|
|
353
362
|
type: "text",
|
|
354
363
|
pattern: "^-?[0-9]*\\.?[0-9]*$",
|
|
355
364
|
disabled,
|
|
@@ -367,10 +376,10 @@ var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, on
|
|
|
367
376
|
import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
|
|
368
377
|
import React5, { useCallback as useCallback2, useEffect as useEffect2, useState as useState2, useRef } from "react";
|
|
369
378
|
import { PublicKey } from "@dxos/keys";
|
|
370
|
-
import { Icon as Icon2, IconButton, Input as
|
|
379
|
+
import { Icon as Icon2, IconButton, Input as Input5, Tag, Toolbar, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
371
380
|
import { List } from "@dxos/react-ui-list";
|
|
372
381
|
import { HuePicker } from "@dxos/react-ui-pickers";
|
|
373
|
-
import { hues, mx as
|
|
382
|
+
import { hues, mx as mx4 } from "@dxos/react-ui-theme";
|
|
374
383
|
var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3, onValueChange }) => {
|
|
375
384
|
var _effect = _useSignals5();
|
|
376
385
|
try {
|
|
@@ -480,11 +489,12 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
480
489
|
selected,
|
|
481
490
|
isNewOption
|
|
482
491
|
]);
|
|
483
|
-
return /* @__PURE__ */ React5.createElement(
|
|
492
|
+
return /* @__PURE__ */ React5.createElement(Input5.Root, {
|
|
484
493
|
validationValence: status
|
|
485
494
|
}, /* @__PURE__ */ React5.createElement(InputHeader, {
|
|
486
|
-
error
|
|
487
|
-
|
|
495
|
+
error,
|
|
496
|
+
label
|
|
497
|
+
}), /* @__PURE__ */ React5.createElement("div", {
|
|
488
498
|
role: "none"
|
|
489
499
|
}, options && /* @__PURE__ */ React5.createElement(List.Root, {
|
|
490
500
|
items: options,
|
|
@@ -498,7 +508,7 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
498
508
|
}, /* @__PURE__ */ React5.createElement(List.Item, {
|
|
499
509
|
role: "button",
|
|
500
510
|
item,
|
|
501
|
-
classNames:
|
|
511
|
+
classNames: mx4("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
|
|
502
512
|
"aria-expanded": selected === item.id
|
|
503
513
|
}, /* @__PURE__ */ React5.createElement("div", {
|
|
504
514
|
className: "flex items-center"
|
|
@@ -512,11 +522,11 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
512
522
|
onClick: () => handleClick(item.id)
|
|
513
523
|
})), selected === item.id && /* @__PURE__ */ React5.createElement("div", {
|
|
514
524
|
className: "mis-4 mbs-2 flex flex-col gap-1"
|
|
515
|
-
}, /* @__PURE__ */ React5.createElement(
|
|
525
|
+
}, /* @__PURE__ */ React5.createElement(Input5.Label, {
|
|
516
526
|
classNames: "text-xs"
|
|
517
527
|
}, t("select option label")), /* @__PURE__ */ React5.createElement("div", {
|
|
518
528
|
className: "flex flex-row items-center gap-1"
|
|
519
|
-
}, /* @__PURE__ */ React5.createElement(
|
|
529
|
+
}, /* @__PURE__ */ React5.createElement(Input5.TextInput, {
|
|
520
530
|
placeholder: t("select option label placeholder"),
|
|
521
531
|
ref: selected === item.id ? inputRef : void 0,
|
|
522
532
|
value: item.title,
|
|
@@ -539,7 +549,7 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
539
549
|
role: "listitem"
|
|
540
550
|
}, /* @__PURE__ */ React5.createElement("div", {
|
|
541
551
|
role: "button",
|
|
542
|
-
className:
|
|
552
|
+
className: mx4("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
|
|
543
553
|
onClick: handleAdd
|
|
544
554
|
}, /* @__PURE__ */ React5.createElement("div", {
|
|
545
555
|
className: "flex items-center gap-1"
|
|
@@ -556,8 +566,8 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
556
566
|
// packages/ui/react-ui-form/src/components/Form/custom/TupleInput.tsx
|
|
557
567
|
import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
|
|
558
568
|
import React6 from "react";
|
|
559
|
-
import { Input as
|
|
560
|
-
import { mx as
|
|
569
|
+
import { Input as Input6 } from "@dxos/react-ui";
|
|
570
|
+
import { mx as mx5 } from "@dxos/react-ui-theme";
|
|
561
571
|
import { safeParseFloat as safeParseFloat2 } from "@dxos/util";
|
|
562
572
|
var gridCols = [
|
|
563
573
|
"grid-cols-1",
|
|
@@ -570,13 +580,14 @@ var TupleInput = ({ binding, type, label, disabled, getStatus, getValue: getValu
|
|
|
570
580
|
try {
|
|
571
581
|
const { status, error } = getStatus();
|
|
572
582
|
const values = getValue3() ?? {};
|
|
573
|
-
return /* @__PURE__ */ React6.createElement(
|
|
583
|
+
return /* @__PURE__ */ React6.createElement(Input6.Root, {
|
|
574
584
|
validationValence: status
|
|
575
585
|
}, /* @__PURE__ */ React6.createElement(InputHeader, {
|
|
576
|
-
error
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
586
|
+
error,
|
|
587
|
+
label
|
|
588
|
+
}), /* @__PURE__ */ React6.createElement("div", {
|
|
589
|
+
className: mx5("grid gap-2", gridCols[binding.length - 1])
|
|
590
|
+
}, binding.map((prop) => /* @__PURE__ */ React6.createElement(Input6.TextInput, {
|
|
580
591
|
key: prop,
|
|
581
592
|
type: "number",
|
|
582
593
|
disabled,
|
|
@@ -595,22 +606,23 @@ var TupleInput = ({ binding, type, label, disabled, getStatus, getValue: getValu
|
|
|
595
606
|
// packages/ui/react-ui-form/src/components/Form/Defaults.tsx
|
|
596
607
|
import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
|
|
597
608
|
import React7, { useCallback as useCallback3, useEffect as useEffect3, useRef as useRef2 } from "react";
|
|
598
|
-
import { Input as
|
|
609
|
+
import { Input as Input7, Select, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
599
610
|
var TextInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
600
611
|
var _effect = _useSignals7();
|
|
601
612
|
try {
|
|
602
613
|
const { status, error } = getStatus();
|
|
603
|
-
return disabled && !getValue3() ? null : disabled && inputOnly ? /* @__PURE__ */ React7.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React7.createElement(
|
|
614
|
+
return disabled && !getValue3() ? null : disabled && inputOnly ? /* @__PURE__ */ React7.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React7.createElement(Input7.Root, {
|
|
604
615
|
validationValence: status
|
|
605
616
|
}, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
|
|
606
|
-
error
|
|
607
|
-
|
|
617
|
+
error,
|
|
618
|
+
label
|
|
619
|
+
}), disabled ? /* @__PURE__ */ React7.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React7.createElement(Input7.TextInput, {
|
|
608
620
|
disabled,
|
|
609
621
|
placeholder,
|
|
610
622
|
value: getValue3() ?? "",
|
|
611
623
|
onChange: (event) => onValueChange(type, event.target.value),
|
|
612
624
|
onBlur
|
|
613
|
-
}), inputOnly && /* @__PURE__ */ React7.createElement(
|
|
625
|
+
}), inputOnly && /* @__PURE__ */ React7.createElement(Input7.Validation, null, error));
|
|
614
626
|
} finally {
|
|
615
627
|
_effect.f();
|
|
616
628
|
}
|
|
@@ -619,18 +631,19 @@ var NumberInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, g
|
|
|
619
631
|
var _effect = _useSignals7();
|
|
620
632
|
try {
|
|
621
633
|
const { status, error } = getStatus();
|
|
622
|
-
return disabled && !getValue3() ? null : disabled && inputOnly ? /* @__PURE__ */ React7.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React7.createElement(
|
|
634
|
+
return disabled && !getValue3() ? null : disabled && inputOnly ? /* @__PURE__ */ React7.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React7.createElement(Input7.Root, {
|
|
623
635
|
validationValence: status
|
|
624
636
|
}, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
|
|
625
|
-
error
|
|
626
|
-
|
|
637
|
+
error,
|
|
638
|
+
label
|
|
639
|
+
}), disabled ? /* @__PURE__ */ React7.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React7.createElement(Input7.TextInput, {
|
|
627
640
|
type: "number",
|
|
628
641
|
disabled,
|
|
629
642
|
placeholder,
|
|
630
643
|
value: getValue3() ?? 0,
|
|
631
644
|
onChange: (event) => onValueChange(type, event.target.value),
|
|
632
645
|
onBlur
|
|
633
|
-
}), inputOnly && /* @__PURE__ */ React7.createElement(
|
|
646
|
+
}), inputOnly && /* @__PURE__ */ React7.createElement(Input7.DescriptionAndValidation, null, error));
|
|
634
647
|
} finally {
|
|
635
648
|
_effect.f();
|
|
636
649
|
}
|
|
@@ -641,14 +654,15 @@ var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, on
|
|
|
641
654
|
const { status, error } = getStatus();
|
|
642
655
|
const checked = Boolean(getValue3());
|
|
643
656
|
const { t } = useTranslation4(translationKey);
|
|
644
|
-
return /* @__PURE__ */ React7.createElement(
|
|
657
|
+
return /* @__PURE__ */ React7.createElement(Input7.Root, {
|
|
645
658
|
validationValence: status
|
|
646
659
|
}, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
|
|
647
|
-
error
|
|
648
|
-
|
|
660
|
+
error,
|
|
661
|
+
label
|
|
662
|
+
}), disabled ? /* @__PURE__ */ React7.createElement("p", null, t(checked ? "boolean input true value" : "boolean input false value")) : /* @__PURE__ */ React7.createElement(Input7.Switch, {
|
|
649
663
|
checked,
|
|
650
664
|
onCheckedChange: (value) => onValueChange(type, value)
|
|
651
|
-
}), inputOnly && /* @__PURE__ */ React7.createElement(
|
|
665
|
+
}), inputOnly && /* @__PURE__ */ React7.createElement(Input7.DescriptionAndValidation, null, error));
|
|
652
666
|
} finally {
|
|
653
667
|
_effect.f();
|
|
654
668
|
}
|
|
@@ -662,11 +676,12 @@ var SelectInput = ({ type, label, inputOnly, disabled, placeholder, options, get
|
|
|
662
676
|
type,
|
|
663
677
|
onValueChange
|
|
664
678
|
]);
|
|
665
|
-
return disabled && !value ? null : /* @__PURE__ */ React7.createElement(
|
|
679
|
+
return disabled && !value ? null : /* @__PURE__ */ React7.createElement(Input7.Root, {
|
|
666
680
|
validationValence: status
|
|
667
681
|
}, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
|
|
668
|
-
error
|
|
669
|
-
|
|
682
|
+
error,
|
|
683
|
+
label
|
|
684
|
+
}), disabled ? /* @__PURE__ */ React7.createElement("p", null, options?.find(({ value: optionValue }) => optionValue === value)?.label ?? String(value)) : /* @__PURE__ */ React7.createElement(Select.Root, {
|
|
670
685
|
value,
|
|
671
686
|
onValueChange: handleValueChange
|
|
672
687
|
}, /* @__PURE__ */ React7.createElement(Select.TriggerButton, {
|
|
@@ -679,7 +694,7 @@ var SelectInput = ({ type, label, inputOnly, disabled, placeholder, options, get
|
|
|
679
694
|
key: String(value2),
|
|
680
695
|
value: String(value2)
|
|
681
696
|
}, label2 ?? String(value2))
|
|
682
|
-
)))))), inputOnly && /* @__PURE__ */ React7.createElement(
|
|
697
|
+
)))))), inputOnly && /* @__PURE__ */ React7.createElement(Input7.DescriptionAndValidation, null, error));
|
|
683
698
|
} finally {
|
|
684
699
|
_effect.f();
|
|
685
700
|
}
|
|
@@ -707,11 +722,12 @@ var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus,
|
|
|
707
722
|
getValue3(),
|
|
708
723
|
adjustHeight
|
|
709
724
|
]);
|
|
710
|
-
return /* @__PURE__ */ React7.createElement(
|
|
725
|
+
return /* @__PURE__ */ React7.createElement(Input7.Root, {
|
|
711
726
|
validationValence: status
|
|
712
727
|
}, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
|
|
713
|
-
error
|
|
714
|
-
|
|
728
|
+
error,
|
|
729
|
+
label
|
|
730
|
+
}), disabled ? /* @__PURE__ */ React7.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React7.createElement(Input7.TextArea, {
|
|
715
731
|
ref: textareaRef,
|
|
716
732
|
disabled,
|
|
717
733
|
placeholder,
|
|
@@ -723,7 +739,7 @@ var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus,
|
|
|
723
739
|
resize: "none"
|
|
724
740
|
},
|
|
725
741
|
spellCheck: false
|
|
726
|
-
}), inputOnly && /* @__PURE__ */ React7.createElement(
|
|
742
|
+
}), inputOnly && /* @__PURE__ */ React7.createElement(Input7.Validation, null, error));
|
|
727
743
|
} finally {
|
|
728
744
|
_effect.f();
|
|
729
745
|
}
|
|
@@ -732,12 +748,14 @@ var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus,
|
|
|
732
748
|
// packages/ui/react-ui-form/src/components/Form/Form.tsx
|
|
733
749
|
import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
|
|
734
750
|
import React13, { useEffect as useEffect7, useMemo as useMemo6, useRef as useRef3 } from "react";
|
|
735
|
-
import {
|
|
751
|
+
import { cardDialogOverflow, cardSpacing as cardSpacing2 } from "@dxos/react-ui-stack";
|
|
736
752
|
|
|
737
753
|
// packages/ui/react-ui-form/src/components/Form/FormActions.tsx
|
|
738
754
|
import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
|
|
739
755
|
import React9 from "react";
|
|
740
756
|
import { IconButton as IconButton2, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
757
|
+
import { cardSpacing } from "@dxos/react-ui-stack";
|
|
758
|
+
import { mx as mx6 } from "@dxos/react-ui-theme";
|
|
741
759
|
|
|
742
760
|
// packages/ui/react-ui-form/src/components/Form/FormContext.tsx
|
|
743
761
|
import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
|
|
@@ -1103,14 +1121,14 @@ var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
|
|
|
1103
1121
|
};
|
|
1104
1122
|
|
|
1105
1123
|
// packages/ui/react-ui-form/src/components/Form/FormActions.tsx
|
|
1106
|
-
var FormActions = ({ readonly, onCancel }) => {
|
|
1124
|
+
var FormActions = ({ readonly, onCancel, outerSpacing = true }) => {
|
|
1107
1125
|
var _effect = _useSignals9();
|
|
1108
1126
|
try {
|
|
1109
1127
|
const { t } = useTranslation5(translationKey);
|
|
1110
1128
|
const { canSave, handleSave } = useFormContext();
|
|
1111
1129
|
return /* @__PURE__ */ React9.createElement("div", {
|
|
1112
1130
|
role: "none",
|
|
1113
|
-
className: "flex [&_button]:grow gap-1
|
|
1131
|
+
className: mx6(outerSpacing === "scroll-fields" ? "pli-cardSpacingInline mbe-cardSpacingBlock" : outerSpacing ? cardSpacing : "mbs-cardSpacingBlock", "flex [&_button]:grow gap-1 first:mbs-0")
|
|
1114
1132
|
}, onCancel && !readonly && /* @__PURE__ */ React9.createElement(IconButton2, {
|
|
1115
1133
|
"data-testid": "cancel-button",
|
|
1116
1134
|
icon: "ph--x--regular",
|
|
@@ -1133,9 +1151,9 @@ var FormActions = ({ readonly, onCancel }) => {
|
|
|
1133
1151
|
import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
|
|
1134
1152
|
import { Schema, SchemaAST as SchemaAST4, pipe as pipe2 } from "effect";
|
|
1135
1153
|
import { capitalize as capitalize2 } from "effect/String";
|
|
1136
|
-
import React12, { useMemo as useMemo5 } from "react";
|
|
1154
|
+
import React12, { forwardRef, useMemo as useMemo5 } from "react";
|
|
1137
1155
|
import { createJsonPath as createJsonPath3, findNode as findNode3, getDiscriminatedType as getDiscriminatedType2, isDiscriminatedUnion as isDiscriminatedUnion2 } from "@dxos/effect";
|
|
1138
|
-
import { mx as
|
|
1156
|
+
import { mx as mx8 } from "@dxos/react-ui-theme";
|
|
1139
1157
|
import { getSchemaProperties as getSchemaProperties2 } from "@dxos/schema";
|
|
1140
1158
|
import { isNotFalsy } from "@dxos/util";
|
|
1141
1159
|
|
|
@@ -1509,7 +1527,10 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1509
1527
|
if (!elementType) {
|
|
1510
1528
|
return null;
|
|
1511
1529
|
}
|
|
1512
|
-
return readonly && values.length < 1 ? null : /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(InputHeader,
|
|
1530
|
+
return readonly && values.length < 1 ? null : /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(InputHeader, {
|
|
1531
|
+
readonly: true,
|
|
1532
|
+
label
|
|
1533
|
+
}), /* @__PURE__ */ React10.createElement("div", {
|
|
1513
1534
|
role: "none",
|
|
1514
1535
|
className: readonly ? "flex flex-wrap gap-1 mlb-1" : values.length > 0 ? "grid gap-1 grid-cols-[1fr_min-content] mlb-1" : "hidden"
|
|
1515
1536
|
}, values.map((_value, index) => {
|
|
@@ -1557,9 +1578,9 @@ import { Expando, getTypeAnnotation, Ref, ReferenceAnnotationId as ReferenceAnno
|
|
|
1557
1578
|
import { findAnnotation as findAnnotation2 } from "@dxos/effect";
|
|
1558
1579
|
import { DXN } from "@dxos/keys";
|
|
1559
1580
|
import { DxRefTag } from "@dxos/lit-ui/react";
|
|
1560
|
-
import { Input as
|
|
1581
|
+
import { Input as Input8, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
1561
1582
|
import { TagPicker } from "@dxos/react-ui-tag-picker";
|
|
1562
|
-
import { descriptionText, mx as
|
|
1583
|
+
import { descriptionText, mx as mx7 } from "@dxos/react-ui-theme";
|
|
1563
1584
|
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
1564
1585
|
var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, getValue: getValue3, onBlur, onQueryRefOptions, onValueChange, ...restInputProps }) => {
|
|
1565
1586
|
var _effect = _useSignals11();
|
|
@@ -1650,14 +1671,15 @@ var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, get
|
|
|
1650
1671
|
}
|
|
1651
1672
|
const { status, error } = restInputProps.getStatus();
|
|
1652
1673
|
const items = handleGetValue();
|
|
1653
|
-
return disabled && items.length < 1 ? null : /* @__PURE__ */ React11.createElement(
|
|
1674
|
+
return disabled && items.length < 1 ? null : /* @__PURE__ */ React11.createElement(Input8.Root, {
|
|
1654
1675
|
validationValence: status
|
|
1655
1676
|
}, !inputOnly && /* @__PURE__ */ React11.createElement(InputHeader, {
|
|
1656
|
-
error
|
|
1657
|
-
|
|
1677
|
+
error,
|
|
1678
|
+
label
|
|
1679
|
+
}), /* @__PURE__ */ React11.createElement("div", {
|
|
1658
1680
|
"data-no-submit": true
|
|
1659
1681
|
}, disabled ? items.length < 1 ? /* @__PURE__ */ React11.createElement("p", {
|
|
1660
|
-
className:
|
|
1682
|
+
className: mx7(descriptionText, "mbe-2")
|
|
1661
1683
|
}, t("empty readonly ref field label")) : items.map((item) => /* @__PURE__ */ React11.createElement(DxRefTag, {
|
|
1662
1684
|
key: item.id,
|
|
1663
1685
|
refid: item.id,
|
|
@@ -1673,7 +1695,7 @@ var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, get
|
|
|
1673
1695
|
onUpdate: handleUpdate,
|
|
1674
1696
|
onSearch: handleSearch,
|
|
1675
1697
|
classNames: "rounded-sm bg-inputSurface p-1.5"
|
|
1676
|
-
})), inputOnly && /* @__PURE__ */ React11.createElement(
|
|
1698
|
+
})), inputOnly && /* @__PURE__ */ React11.createElement(Input8.DescriptionAndValidation, null, error));
|
|
1677
1699
|
} finally {
|
|
1678
1700
|
_effect.f();
|
|
1679
1701
|
}
|
|
@@ -1739,8 +1761,8 @@ var getInputComponent = (type, format) => {
|
|
|
1739
1761
|
var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupComponent, Custom }) => {
|
|
1740
1762
|
var _effect = _useSignals12();
|
|
1741
1763
|
try {
|
|
1742
|
-
const inputProps = useInputProps(path);
|
|
1743
1764
|
const { ast, name, type, format, title, description, options, examples, array } = property;
|
|
1765
|
+
const inputProps = useInputProps(path);
|
|
1744
1766
|
const label = useMemo5(() => title ?? pipe2(name, capitalize2), [
|
|
1745
1767
|
title,
|
|
1746
1768
|
name
|
|
@@ -1833,7 +1855,7 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1833
1855
|
const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, inputProps.getValue()) : findNode3(ast, SchemaAST4.isTypeLiteral);
|
|
1834
1856
|
if (typeLiteral) {
|
|
1835
1857
|
return /* @__PURE__ */ React12.createElement(React12.Fragment, null, !inline && /* @__PURE__ */ React12.createElement("h3", {
|
|
1836
|
-
className: "text-lg
|
|
1858
|
+
className: mx8("text-lg mlb-inputSpacingBlock first:mbs-0")
|
|
1837
1859
|
}, label), /* @__PURE__ */ React12.createElement(FormFields, {
|
|
1838
1860
|
schema: Schema.make(typeLiteral),
|
|
1839
1861
|
path,
|
|
@@ -1849,7 +1871,7 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1849
1871
|
_effect.f();
|
|
1850
1872
|
}
|
|
1851
1873
|
};
|
|
1852
|
-
var FormFields = ({ classNames,
|
|
1874
|
+
var FormFields = /* @__PURE__ */ forwardRef(({ classNames, testId, schema, path, filter, sort, readonly, lookupComponent, Custom, onQueryRefOptions }, forwardRef2) => {
|
|
1853
1875
|
var _effect = _useSignals12();
|
|
1854
1876
|
try {
|
|
1855
1877
|
const values = useFormValues(path);
|
|
@@ -1863,37 +1885,35 @@ var FormFields = ({ classNames, Custom, schema, path, filter, sort, readonly, lo
|
|
|
1863
1885
|
filter,
|
|
1864
1886
|
sort
|
|
1865
1887
|
]);
|
|
1866
|
-
return (
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
path
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
}).filter(isNotFalsy))
|
|
1885
|
-
);
|
|
1888
|
+
return /* @__PURE__ */ React12.createElement("div", {
|
|
1889
|
+
role: "form",
|
|
1890
|
+
className: mx8("is-full", classNames),
|
|
1891
|
+
ref: forwardRef2
|
|
1892
|
+
}, properties.map((property) => {
|
|
1893
|
+
return /* @__PURE__ */ React12.createElement(FormField, {
|
|
1894
|
+
key: property.name,
|
|
1895
|
+
property,
|
|
1896
|
+
path: [
|
|
1897
|
+
...path ?? [],
|
|
1898
|
+
property.name
|
|
1899
|
+
],
|
|
1900
|
+
readonly,
|
|
1901
|
+
onQueryRefOptions,
|
|
1902
|
+
lookupComponent,
|
|
1903
|
+
Custom
|
|
1904
|
+
});
|
|
1905
|
+
}).filter(isNotFalsy));
|
|
1886
1906
|
} finally {
|
|
1887
1907
|
_effect.f();
|
|
1888
1908
|
}
|
|
1889
|
-
};
|
|
1909
|
+
});
|
|
1890
1910
|
|
|
1891
1911
|
// packages/ui/react-ui-form/src/components/Form/Form.tsx
|
|
1892
|
-
var Form = ({ classNames,
|
|
1912
|
+
var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, autoSave, outerSpacing = true, onCancel, schema, onValuesChanged, onValidate, onSave, ...props }) => {
|
|
1893
1913
|
var _effect = _useSignals13();
|
|
1894
1914
|
try {
|
|
1895
1915
|
const formRef = useRef3(null);
|
|
1896
|
-
const
|
|
1916
|
+
const handleValid = useMemo6(() => autoSave ? onSave : void 0, [
|
|
1897
1917
|
autoSave,
|
|
1898
1918
|
onSave
|
|
1899
1919
|
]);
|
|
@@ -1914,25 +1934,26 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1914
1934
|
initialValues,
|
|
1915
1935
|
onValuesChanged,
|
|
1916
1936
|
onValidate,
|
|
1917
|
-
onValid,
|
|
1937
|
+
onValid: handleValid,
|
|
1918
1938
|
onSave
|
|
1919
1939
|
}, /* @__PURE__ */ React13.createElement("div", {
|
|
1920
|
-
ref: formRef,
|
|
1921
1940
|
role: "none",
|
|
1922
|
-
className:
|
|
1941
|
+
className: "contents",
|
|
1923
1942
|
"data-testid": testId
|
|
1924
1943
|
}, /* @__PURE__ */ React13.createElement(FormFields, {
|
|
1925
|
-
|
|
1926
|
-
|
|
1944
|
+
...props,
|
|
1945
|
+
ref: formRef,
|
|
1946
|
+
classNames: [
|
|
1947
|
+
outerSpacing === "blockStart-0" ? "pli-cardSpacingInline mbe-cardSpacingBlock [&>.mbs-inputSpacingBlock:first-child]:!mbs-0" : outerSpacing === "scroll-fields" ? "pli-cardSpacingInline pbe-cardSpacingBlock" : outerSpacing ? cardSpacing2 : false,
|
|
1948
|
+
outerSpacing === "scroll-fields" && cardDialogOverflow,
|
|
1949
|
+
classNames
|
|
1950
|
+
],
|
|
1927
1951
|
readonly,
|
|
1928
|
-
|
|
1929
|
-
sort,
|
|
1930
|
-
onQueryRefOptions,
|
|
1931
|
-
lookupComponent,
|
|
1932
|
-
Custom
|
|
1952
|
+
schema
|
|
1933
1953
|
}), (onCancel || onSave) && !autoSave && /* @__PURE__ */ React13.createElement(FormActions, {
|
|
1954
|
+
readonly,
|
|
1934
1955
|
onCancel,
|
|
1935
|
-
|
|
1956
|
+
outerSpacing
|
|
1936
1957
|
})));
|
|
1937
1958
|
} finally {
|
|
1938
1959
|
_effect.f();
|
|
@@ -1941,7 +1962,7 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1941
1962
|
|
|
1942
1963
|
// packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx
|
|
1943
1964
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
|
|
1944
|
-
var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
1965
|
+
var FieldEditor = ({ view, projection, field, registry, onSave, onCancel, outerSpacing }) => {
|
|
1945
1966
|
var _effect = _useSignals14();
|
|
1946
1967
|
try {
|
|
1947
1968
|
const { t } = useTranslation8(translationKey);
|
|
@@ -2076,7 +2097,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
2076
2097
|
props
|
|
2077
2098
|
}, {
|
|
2078
2099
|
F: __dxlog_file4,
|
|
2079
|
-
L:
|
|
2100
|
+
L: 183,
|
|
2080
2101
|
S: void 0,
|
|
2081
2102
|
C: (f, a) => f(...a)
|
|
2082
2103
|
});
|
|
@@ -2096,7 +2117,8 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
2096
2117
|
onValidate: handleValidate,
|
|
2097
2118
|
onSave: handleSave,
|
|
2098
2119
|
onCancel: handleCancel,
|
|
2099
|
-
Custom: custom
|
|
2120
|
+
Custom: custom,
|
|
2121
|
+
outerSpacing
|
|
2100
2122
|
});
|
|
2101
2123
|
} finally {
|
|
2102
2124
|
_effect.f();
|
|
@@ -2109,12 +2131,13 @@ import { Schema as Schema2 } from "effect";
|
|
|
2109
2131
|
import React15, { useCallback as useCallback10, useMemo as useMemo8, useState as useState6 } from "react";
|
|
2110
2132
|
import { EchoSchema, Format, isMutable, toJsonSchema } from "@dxos/echo-schema";
|
|
2111
2133
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
2112
|
-
import {
|
|
2134
|
+
import { Callout, IconButton as IconButton4, useTranslation as useTranslation9 } from "@dxos/react-ui";
|
|
2113
2135
|
import { List as List2 } from "@dxos/react-ui-list";
|
|
2114
|
-
import {
|
|
2136
|
+
import { cardSpacing as cardSpacing3 } from "@dxos/react-ui-stack";
|
|
2137
|
+
import { ghostHover, inputTextLabel, mx as mx9 } from "@dxos/react-ui-theme";
|
|
2115
2138
|
import { FieldSchema, ViewProjection, VIEW_FIELD_LIMIT } from "@dxos/schema";
|
|
2116
2139
|
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
|
|
2117
|
-
var grid = "grid grid-cols-[
|
|
2140
|
+
var grid = "grid grid-cols-[32px_1fr_32px_32px] min-bs-[2.5rem]";
|
|
2118
2141
|
var ViewMetaSchema = Schema2.Struct({
|
|
2119
2142
|
name: Schema2.String.annotations({
|
|
2120
2143
|
title: "View"
|
|
@@ -2123,7 +2146,7 @@ var ViewMetaSchema = Schema2.Struct({
|
|
|
2123
2146
|
title: "Typename"
|
|
2124
2147
|
})
|
|
2125
2148
|
}).pipe(Schema2.mutable);
|
|
2126
|
-
var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading = false, onTypenameChanged, onDelete }) => {
|
|
2149
|
+
var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, showHeading = false, onTypenameChanged, onDelete, outerSpacing = true }) => {
|
|
2127
2150
|
var _effect = _useSignals15();
|
|
2128
2151
|
try {
|
|
2129
2152
|
const { t } = useTranslation9(translationKey);
|
|
@@ -2135,7 +2158,7 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2135
2158
|
view
|
|
2136
2159
|
]);
|
|
2137
2160
|
const [field, setField] = useState6();
|
|
2138
|
-
const
|
|
2161
|
+
const readonly = _readonly || !isMutable(schema);
|
|
2139
2162
|
const viewValues = useMemo8(() => {
|
|
2140
2163
|
return {
|
|
2141
2164
|
name: view.name,
|
|
@@ -2147,20 +2170,20 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2147
2170
|
view
|
|
2148
2171
|
]);
|
|
2149
2172
|
const handleSelect = useCallback10((field2) => {
|
|
2150
|
-
if (
|
|
2173
|
+
if (readonly) {
|
|
2151
2174
|
return;
|
|
2152
2175
|
}
|
|
2153
2176
|
setField((f) => f === field2 ? void 0 : field2);
|
|
2154
2177
|
}, [
|
|
2155
|
-
|
|
2178
|
+
readonly
|
|
2156
2179
|
]);
|
|
2157
2180
|
const handleAdd = useCallback10(() => {
|
|
2158
|
-
invariant3(!
|
|
2181
|
+
invariant3(!readonly, void 0, {
|
|
2159
2182
|
F: __dxlog_file5,
|
|
2160
|
-
L:
|
|
2183
|
+
L: 92,
|
|
2161
2184
|
S: void 0,
|
|
2162
2185
|
A: [
|
|
2163
|
-
"!
|
|
2186
|
+
"!readonly",
|
|
2164
2187
|
""
|
|
2165
2188
|
]
|
|
2166
2189
|
});
|
|
@@ -2168,15 +2191,16 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2168
2191
|
setField(field2);
|
|
2169
2192
|
}, [
|
|
2170
2193
|
schema,
|
|
2171
|
-
view
|
|
2194
|
+
view,
|
|
2195
|
+
readonly
|
|
2172
2196
|
]);
|
|
2173
2197
|
const handleUpdate = useCallback10(({ name, typename }) => {
|
|
2174
|
-
invariant3(!
|
|
2198
|
+
invariant3(!readonly, void 0, {
|
|
2175
2199
|
F: __dxlog_file5,
|
|
2176
|
-
L:
|
|
2200
|
+
L: 99,
|
|
2177
2201
|
S: void 0,
|
|
2178
2202
|
A: [
|
|
2179
|
-
"!
|
|
2203
|
+
"!readonly",
|
|
2180
2204
|
""
|
|
2181
2205
|
]
|
|
2182
2206
|
});
|
|
@@ -2184,7 +2208,7 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2184
2208
|
if (view.name !== name) {
|
|
2185
2209
|
view.name = name;
|
|
2186
2210
|
}
|
|
2187
|
-
if (view.query.typename !== typename && !
|
|
2211
|
+
if (view.query.typename !== typename && !readonly) {
|
|
2188
2212
|
onTypenameChanged?.(typename);
|
|
2189
2213
|
}
|
|
2190
2214
|
});
|
|
@@ -2192,15 +2216,15 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2192
2216
|
schema,
|
|
2193
2217
|
view,
|
|
2194
2218
|
onTypenameChanged,
|
|
2195
|
-
|
|
2219
|
+
readonly
|
|
2196
2220
|
]);
|
|
2197
2221
|
const handleDelete = useCallback10((fieldId) => {
|
|
2198
|
-
invariant3(!
|
|
2222
|
+
invariant3(!readonly, void 0, {
|
|
2199
2223
|
F: __dxlog_file5,
|
|
2200
|
-
L:
|
|
2224
|
+
L: 115,
|
|
2201
2225
|
S: void 0,
|
|
2202
2226
|
A: [
|
|
2203
|
-
"!
|
|
2227
|
+
"!readonly",
|
|
2204
2228
|
""
|
|
2205
2229
|
]
|
|
2206
2230
|
});
|
|
@@ -2211,15 +2235,16 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2211
2235
|
}, [
|
|
2212
2236
|
schema,
|
|
2213
2237
|
field,
|
|
2214
|
-
onDelete
|
|
2238
|
+
onDelete,
|
|
2239
|
+
readonly
|
|
2215
2240
|
]);
|
|
2216
2241
|
const handleMove = useCallback10((fromIndex, toIndex) => {
|
|
2217
|
-
invariant3(!
|
|
2242
|
+
invariant3(!readonly, void 0, {
|
|
2218
2243
|
F: __dxlog_file5,
|
|
2219
|
-
L:
|
|
2244
|
+
L: 127,
|
|
2220
2245
|
S: void 0,
|
|
2221
2246
|
A: [
|
|
2222
|
-
"!
|
|
2247
|
+
"!readonly",
|
|
2223
2248
|
""
|
|
2224
2249
|
]
|
|
2225
2250
|
});
|
|
@@ -2231,7 +2256,8 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2231
2256
|
view.fields = fields;
|
|
2232
2257
|
}, [
|
|
2233
2258
|
schema,
|
|
2234
|
-
view.fields
|
|
2259
|
+
view.fields,
|
|
2260
|
+
readonly
|
|
2235
2261
|
]);
|
|
2236
2262
|
const handleClose = useCallback10(() => setField(void 0), []);
|
|
2237
2263
|
const hiddenProperties = projection.getHiddenProperties();
|
|
@@ -2249,36 +2275,30 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2249
2275
|
]);
|
|
2250
2276
|
return /* @__PURE__ */ React15.createElement("div", {
|
|
2251
2277
|
role: "none",
|
|
2252
|
-
className:
|
|
2253
|
-
},
|
|
2278
|
+
className: mx9(classNames)
|
|
2279
|
+
}, readonly && /* @__PURE__ */ React15.createElement("div", {
|
|
2254
2280
|
role: "none",
|
|
2255
|
-
className: "
|
|
2256
|
-
}, /* @__PURE__ */ React15.createElement(
|
|
2257
|
-
valence: "
|
|
2258
|
-
|
|
2259
|
-
}, /* @__PURE__ */ React15.createElement(Message.Title, null, /* @__PURE__ */ React15.createElement(Icon3, {
|
|
2260
|
-
icon: "ph--info--regular",
|
|
2261
|
-
size: 5,
|
|
2262
|
-
classNames: "inline"
|
|
2263
|
-
}), " ", t("system schema title")), /* @__PURE__ */ React15.createElement(Message.Body, null, t("system schema description")))), /* @__PURE__ */ React15.createElement(Form, {
|
|
2281
|
+
className: mx9("is-full", outerSpacing && "plb-cardSpacingBlock pli-cardSpacingInline")
|
|
2282
|
+
}, /* @__PURE__ */ React15.createElement(Callout.Root, {
|
|
2283
|
+
valence: "info"
|
|
2284
|
+
}, /* @__PURE__ */ React15.createElement(Callout.Title, null, t("system schema description")))), /* @__PURE__ */ React15.createElement(Form, {
|
|
2264
2285
|
autoSave: true,
|
|
2265
2286
|
schema: ViewMetaSchema,
|
|
2266
2287
|
values: viewValues,
|
|
2288
|
+
readonly,
|
|
2267
2289
|
onSave: handleUpdate,
|
|
2268
|
-
|
|
2290
|
+
outerSpacing
|
|
2269
2291
|
}), /* @__PURE__ */ React15.createElement("div", {
|
|
2270
2292
|
role: "none",
|
|
2271
|
-
className: "
|
|
2272
|
-
}, /* @__PURE__ */ React15.createElement("div", {
|
|
2273
|
-
role: "none",
|
|
2274
|
-
className: "p-2"
|
|
2293
|
+
className: outerSpacing ? cardSpacing3 : "mlb-cardSpacingBlock"
|
|
2275
2294
|
}, /* @__PURE__ */ React15.createElement("label", {
|
|
2276
|
-
className:
|
|
2277
|
-
}, t("fields label"))
|
|
2295
|
+
className: mx9(inputTextLabel)
|
|
2296
|
+
}, t("fields label")), /* @__PURE__ */ React15.createElement(List2.Root, {
|
|
2278
2297
|
items: view.fields,
|
|
2279
2298
|
isItem: Schema2.is(FieldSchema),
|
|
2280
2299
|
getId: (field2) => field2.id,
|
|
2281
|
-
|
|
2300
|
+
readonly,
|
|
2301
|
+
onMove: readonly ? void 0 : handleMove
|
|
2282
2302
|
}, ({ items: fields }) => /* @__PURE__ */ React15.createElement(React15.Fragment, null, showHeading && /* @__PURE__ */ React15.createElement("div", {
|
|
2283
2303
|
role: "heading",
|
|
2284
2304
|
className: grid
|
|
@@ -2286,41 +2306,38 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2286
2306
|
className: "flex items-center text-sm"
|
|
2287
2307
|
}, t("field path label"))), /* @__PURE__ */ React15.createElement("div", {
|
|
2288
2308
|
role: "list",
|
|
2289
|
-
className: "flex flex-col
|
|
2309
|
+
className: "flex flex-col is-full"
|
|
2290
2310
|
}, fields?.map((field2) => /* @__PURE__ */ React15.createElement(List2.Item, {
|
|
2291
2311
|
key: field2.id,
|
|
2292
2312
|
item: field2,
|
|
2293
|
-
classNames:
|
|
2313
|
+
classNames: mx9(grid, ghostHover, "overflow-hidden", !readonly && "cursor-pointer")
|
|
2294
2314
|
}, /* @__PURE__ */ React15.createElement(List2.ItemDragHandle, null), /* @__PURE__ */ React15.createElement(List2.ItemTitle, {
|
|
2295
2315
|
onClick: () => handleSelect(field2)
|
|
2296
|
-
}, field2.path), /* @__PURE__ */ React15.createElement(
|
|
2297
|
-
|
|
2298
|
-
}, /* @__PURE__ */ React15.createElement(List2.ItemButton, {
|
|
2316
|
+
}, field2.path), /* @__PURE__ */ React15.createElement(List2.ItemButton, {
|
|
2317
|
+
"data-testid": "hide-field-button",
|
|
2299
2318
|
icon: "ph--eye-slash--regular",
|
|
2319
|
+
// TDOO(burdon): Is this the correct test?
|
|
2300
2320
|
disabled: view.fields.length <= 1,
|
|
2301
|
-
onClick: () => handleHide(field2.id)
|
|
2302
|
-
|
|
2303
|
-
}), !immutable && /* @__PURE__ */ React15.createElement(List2.ItemDeleteButton, {
|
|
2304
|
-
icon: "ph--trash--regular",
|
|
2321
|
+
onClick: () => handleHide(field2.id)
|
|
2322
|
+
}), !readonly && /* @__PURE__ */ React15.createElement(List2.ItemDeleteButton, {
|
|
2305
2323
|
disabled: view.fields.length <= 1,
|
|
2306
2324
|
onClick: () => handleDelete(field2.id)
|
|
2307
|
-
}))))))
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
}, /* @__PURE__ */ React15.createElement("label", {
|
|
2311
|
-
className: mx8(inputTextLabel)
|
|
2312
|
-
}, t("hidden fields label"))), /* @__PURE__ */ React15.createElement(List2.Root, {
|
|
2325
|
+
})))))), hiddenProperties.length > 0 && /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement("label", {
|
|
2326
|
+
className: mx9(inputTextLabel)
|
|
2327
|
+
}, t("hidden fields label")), /* @__PURE__ */ React15.createElement(List2.Root, {
|
|
2313
2328
|
items: hiddenProperties,
|
|
2314
2329
|
isItem: (item) => typeof item === "string",
|
|
2315
2330
|
getId: (property) => property
|
|
2316
2331
|
}, ({ items: properties }) => /* @__PURE__ */ React15.createElement("div", {
|
|
2317
2332
|
role: "list",
|
|
2318
|
-
className: "flex flex-col
|
|
2333
|
+
className: "flex flex-col is-full"
|
|
2319
2334
|
}, properties?.map((property) => /* @__PURE__ */ React15.createElement(List2.Item, {
|
|
2320
2335
|
key: property,
|
|
2321
2336
|
item: property,
|
|
2322
|
-
classNames:
|
|
2323
|
-
}, /* @__PURE__ */ React15.createElement(
|
|
2337
|
+
classNames: mx9(grid, ghostHover, !readonly && "cursor-pointer")
|
|
2338
|
+
}, /* @__PURE__ */ React15.createElement(List2.ItemDragHandle, {
|
|
2339
|
+
disabled: true
|
|
2340
|
+
}), /* @__PURE__ */ React15.createElement(List2.ItemTitle, null, property), /* @__PURE__ */ React15.createElement(List2.ItemButton, {
|
|
2324
2341
|
icon: "ph--eye--regular",
|
|
2325
2342
|
onClick: () => handleShow(property),
|
|
2326
2343
|
"data-testid": "show-field-button"
|
|
@@ -2333,11 +2350,11 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2333
2350
|
onSave: handleClose
|
|
2334
2351
|
}), !readonly && !field && /* @__PURE__ */ React15.createElement("div", {
|
|
2335
2352
|
role: "none",
|
|
2336
|
-
className: "
|
|
2353
|
+
className: outerSpacing ? cardSpacing3 : "mlb-cardSpacingBlock"
|
|
2337
2354
|
}, /* @__PURE__ */ React15.createElement(IconButton4, {
|
|
2338
2355
|
icon: "ph--plus--regular",
|
|
2339
2356
|
label: t("button add property"),
|
|
2340
|
-
onClick:
|
|
2357
|
+
onClick: readonly ? void 0 : handleAdd,
|
|
2341
2358
|
// TODO(burdon): Show field limit in ux (not tooltip).
|
|
2342
2359
|
disabled: view.fields.length >= VIEW_FIELD_LIMIT,
|
|
2343
2360
|
classNames: "flex is-full"
|