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