@dxos/react-ui-form 0.8.3-main.7f5a14c → 0.8.3
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 -174
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +150 -134
- 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 -174
- 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 +0 -1
- 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 -15
- 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 +0 -1
- 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 -27
- package/src/components/ControlSection/ControlSection.stories.tsx +15 -3
- package/src/components/ControlSection/ControlSection.tsx +11 -9
- package/src/components/FieldEditor/FieldEditor.stories.tsx +1 -4
- package/src/components/FieldEditor/FieldEditor.test.tsx +2 -1
- 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 -52
- 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 +1 -4
- package/src/components/ViewEditor/ViewEditor.test.tsx +2 -1
- 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,13 +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 { cardSpacing } from "@dxos/react-ui-stack";
|
|
736
|
-
import { mx as mx7 } from "@dxos/react-ui-theme";
|
|
751
|
+
import { cardDialogOverflow, cardSpacing as cardSpacing2 } from "@dxos/react-ui-stack";
|
|
737
752
|
|
|
738
753
|
// packages/ui/react-ui-form/src/components/Form/FormActions.tsx
|
|
739
754
|
import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
|
|
740
755
|
import React9 from "react";
|
|
741
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";
|
|
742
759
|
|
|
743
760
|
// packages/ui/react-ui-form/src/components/Form/FormContext.tsx
|
|
744
761
|
import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
|
|
@@ -1104,14 +1121,14 @@ var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
|
|
|
1104
1121
|
};
|
|
1105
1122
|
|
|
1106
1123
|
// packages/ui/react-ui-form/src/components/Form/FormActions.tsx
|
|
1107
|
-
var FormActions = ({ readonly, onCancel }) => {
|
|
1124
|
+
var FormActions = ({ readonly, onCancel, outerSpacing = true }) => {
|
|
1108
1125
|
var _effect = _useSignals9();
|
|
1109
1126
|
try {
|
|
1110
1127
|
const { t } = useTranslation5(translationKey);
|
|
1111
1128
|
const { canSave, handleSave } = useFormContext();
|
|
1112
1129
|
return /* @__PURE__ */ React9.createElement("div", {
|
|
1113
1130
|
role: "none",
|
|
1114
|
-
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")
|
|
1115
1132
|
}, onCancel && !readonly && /* @__PURE__ */ React9.createElement(IconButton2, {
|
|
1116
1133
|
"data-testid": "cancel-button",
|
|
1117
1134
|
icon: "ph--x--regular",
|
|
@@ -1134,9 +1151,9 @@ var FormActions = ({ readonly, onCancel }) => {
|
|
|
1134
1151
|
import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
|
|
1135
1152
|
import { Schema, SchemaAST as SchemaAST4, pipe as pipe2 } from "effect";
|
|
1136
1153
|
import { capitalize as capitalize2 } from "effect/String";
|
|
1137
|
-
import React12, { useMemo as useMemo5 } from "react";
|
|
1154
|
+
import React12, { forwardRef, useMemo as useMemo5 } from "react";
|
|
1138
1155
|
import { createJsonPath as createJsonPath3, findNode as findNode3, getDiscriminatedType as getDiscriminatedType2, isDiscriminatedUnion as isDiscriminatedUnion2 } from "@dxos/effect";
|
|
1139
|
-
import { mx as
|
|
1156
|
+
import { mx as mx8 } from "@dxos/react-ui-theme";
|
|
1140
1157
|
import { getSchemaProperties as getSchemaProperties2 } from "@dxos/schema";
|
|
1141
1158
|
import { isNotFalsy } from "@dxos/util";
|
|
1142
1159
|
|
|
@@ -1510,7 +1527,10 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1510
1527
|
if (!elementType) {
|
|
1511
1528
|
return null;
|
|
1512
1529
|
}
|
|
1513
|
-
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", {
|
|
1514
1534
|
role: "none",
|
|
1515
1535
|
className: readonly ? "flex flex-wrap gap-1 mlb-1" : values.length > 0 ? "grid gap-1 grid-cols-[1fr_min-content] mlb-1" : "hidden"
|
|
1516
1536
|
}, values.map((_value, index) => {
|
|
@@ -1558,9 +1578,9 @@ import { Expando, getTypeAnnotation, Ref, ReferenceAnnotationId as ReferenceAnno
|
|
|
1558
1578
|
import { findAnnotation as findAnnotation2 } from "@dxos/effect";
|
|
1559
1579
|
import { DXN } from "@dxos/keys";
|
|
1560
1580
|
import { DxRefTag } from "@dxos/lit-ui/react";
|
|
1561
|
-
import { Input as
|
|
1581
|
+
import { Input as Input8, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
1562
1582
|
import { TagPicker } from "@dxos/react-ui-tag-picker";
|
|
1563
|
-
import { descriptionText, mx as
|
|
1583
|
+
import { descriptionText, mx as mx7 } from "@dxos/react-ui-theme";
|
|
1564
1584
|
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
1565
1585
|
var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, getValue: getValue3, onBlur, onQueryRefOptions, onValueChange, ...restInputProps }) => {
|
|
1566
1586
|
var _effect = _useSignals11();
|
|
@@ -1651,14 +1671,15 @@ var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, get
|
|
|
1651
1671
|
}
|
|
1652
1672
|
const { status, error } = restInputProps.getStatus();
|
|
1653
1673
|
const items = handleGetValue();
|
|
1654
|
-
return disabled && items.length < 1 ? null : /* @__PURE__ */ React11.createElement(
|
|
1674
|
+
return disabled && items.length < 1 ? null : /* @__PURE__ */ React11.createElement(Input8.Root, {
|
|
1655
1675
|
validationValence: status
|
|
1656
1676
|
}, !inputOnly && /* @__PURE__ */ React11.createElement(InputHeader, {
|
|
1657
|
-
error
|
|
1658
|
-
|
|
1677
|
+
error,
|
|
1678
|
+
label
|
|
1679
|
+
}), /* @__PURE__ */ React11.createElement("div", {
|
|
1659
1680
|
"data-no-submit": true
|
|
1660
1681
|
}, disabled ? items.length < 1 ? /* @__PURE__ */ React11.createElement("p", {
|
|
1661
|
-
className:
|
|
1682
|
+
className: mx7(descriptionText, "mbe-2")
|
|
1662
1683
|
}, t("empty readonly ref field label")) : items.map((item) => /* @__PURE__ */ React11.createElement(DxRefTag, {
|
|
1663
1684
|
key: item.id,
|
|
1664
1685
|
refid: item.id,
|
|
@@ -1674,7 +1695,7 @@ var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, get
|
|
|
1674
1695
|
onUpdate: handleUpdate,
|
|
1675
1696
|
onSearch: handleSearch,
|
|
1676
1697
|
classNames: "rounded-sm bg-inputSurface p-1.5"
|
|
1677
|
-
})), inputOnly && /* @__PURE__ */ React11.createElement(
|
|
1698
|
+
})), inputOnly && /* @__PURE__ */ React11.createElement(Input8.DescriptionAndValidation, null, error));
|
|
1678
1699
|
} finally {
|
|
1679
1700
|
_effect.f();
|
|
1680
1701
|
}
|
|
@@ -1740,8 +1761,8 @@ var getInputComponent = (type, format) => {
|
|
|
1740
1761
|
var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupComponent, Custom }) => {
|
|
1741
1762
|
var _effect = _useSignals12();
|
|
1742
1763
|
try {
|
|
1743
|
-
const inputProps = useInputProps(path);
|
|
1744
1764
|
const { ast, name, type, format, title, description, options, examples, array } = property;
|
|
1765
|
+
const inputProps = useInputProps(path);
|
|
1745
1766
|
const label = useMemo5(() => title ?? pipe2(name, capitalize2), [
|
|
1746
1767
|
title,
|
|
1747
1768
|
name
|
|
@@ -1834,7 +1855,7 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1834
1855
|
const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, inputProps.getValue()) : findNode3(ast, SchemaAST4.isTypeLiteral);
|
|
1835
1856
|
if (typeLiteral) {
|
|
1836
1857
|
return /* @__PURE__ */ React12.createElement(React12.Fragment, null, !inline && /* @__PURE__ */ React12.createElement("h3", {
|
|
1837
|
-
className:
|
|
1858
|
+
className: mx8("text-lg mlb-inputSpacingBlock first:mbs-0")
|
|
1838
1859
|
}, label), /* @__PURE__ */ React12.createElement(FormFields, {
|
|
1839
1860
|
schema: Schema.make(typeLiteral),
|
|
1840
1861
|
path,
|
|
@@ -1850,7 +1871,7 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1850
1871
|
_effect.f();
|
|
1851
1872
|
}
|
|
1852
1873
|
};
|
|
1853
|
-
var FormFields = ({ classNames,
|
|
1874
|
+
var FormFields = /* @__PURE__ */ forwardRef(({ classNames, testId, schema, path, filter, sort, readonly, lookupComponent, Custom, onQueryRefOptions }, forwardRef2) => {
|
|
1854
1875
|
var _effect = _useSignals12();
|
|
1855
1876
|
try {
|
|
1856
1877
|
const values = useFormValues(path);
|
|
@@ -1864,37 +1885,35 @@ var FormFields = ({ classNames, Custom, schema, path, filter, sort, readonly, lo
|
|
|
1864
1885
|
filter,
|
|
1865
1886
|
sort
|
|
1866
1887
|
]);
|
|
1867
|
-
return (
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
path
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
}).filter(isNotFalsy))
|
|
1886
|
-
);
|
|
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));
|
|
1887
1906
|
} finally {
|
|
1888
1907
|
_effect.f();
|
|
1889
1908
|
}
|
|
1890
|
-
};
|
|
1909
|
+
});
|
|
1891
1910
|
|
|
1892
1911
|
// packages/ui/react-ui-form/src/components/Form/Form.tsx
|
|
1893
|
-
var Form = ({ classNames,
|
|
1912
|
+
var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, autoSave, outerSpacing = true, onCancel, schema, onValuesChanged, onValidate, onSave, ...props }) => {
|
|
1894
1913
|
var _effect = _useSignals13();
|
|
1895
1914
|
try {
|
|
1896
1915
|
const formRef = useRef3(null);
|
|
1897
|
-
const
|
|
1916
|
+
const handleValid = useMemo6(() => autoSave ? onSave : void 0, [
|
|
1898
1917
|
autoSave,
|
|
1899
1918
|
onSave
|
|
1900
1919
|
]);
|
|
@@ -1915,25 +1934,26 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1915
1934
|
initialValues,
|
|
1916
1935
|
onValuesChanged,
|
|
1917
1936
|
onValidate,
|
|
1918
|
-
onValid,
|
|
1937
|
+
onValid: handleValid,
|
|
1919
1938
|
onSave
|
|
1920
1939
|
}, /* @__PURE__ */ React13.createElement("div", {
|
|
1921
|
-
ref: formRef,
|
|
1922
1940
|
role: "none",
|
|
1923
|
-
className:
|
|
1941
|
+
className: "contents",
|
|
1924
1942
|
"data-testid": testId
|
|
1925
1943
|
}, /* @__PURE__ */ React13.createElement(FormFields, {
|
|
1926
|
-
|
|
1927
|
-
|
|
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
|
+
],
|
|
1928
1951
|
readonly,
|
|
1929
|
-
|
|
1930
|
-
sort,
|
|
1931
|
-
onQueryRefOptions,
|
|
1932
|
-
lookupComponent,
|
|
1933
|
-
Custom
|
|
1952
|
+
schema
|
|
1934
1953
|
}), (onCancel || onSave) && !autoSave && /* @__PURE__ */ React13.createElement(FormActions, {
|
|
1954
|
+
readonly,
|
|
1935
1955
|
onCancel,
|
|
1936
|
-
|
|
1956
|
+
outerSpacing
|
|
1937
1957
|
})));
|
|
1938
1958
|
} finally {
|
|
1939
1959
|
_effect.f();
|
|
@@ -1942,7 +1962,7 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1942
1962
|
|
|
1943
1963
|
// packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx
|
|
1944
1964
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
|
|
1945
|
-
var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
1965
|
+
var FieldEditor = ({ view, projection, field, registry, onSave, onCancel, outerSpacing }) => {
|
|
1946
1966
|
var _effect = _useSignals14();
|
|
1947
1967
|
try {
|
|
1948
1968
|
const { t } = useTranslation8(translationKey);
|
|
@@ -2077,7 +2097,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
2077
2097
|
props
|
|
2078
2098
|
}, {
|
|
2079
2099
|
F: __dxlog_file4,
|
|
2080
|
-
L:
|
|
2100
|
+
L: 183,
|
|
2081
2101
|
S: void 0,
|
|
2082
2102
|
C: (f, a) => f(...a)
|
|
2083
2103
|
});
|
|
@@ -2097,7 +2117,8 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
2097
2117
|
onValidate: handleValidate,
|
|
2098
2118
|
onSave: handleSave,
|
|
2099
2119
|
onCancel: handleCancel,
|
|
2100
|
-
Custom: custom
|
|
2120
|
+
Custom: custom,
|
|
2121
|
+
outerSpacing
|
|
2101
2122
|
});
|
|
2102
2123
|
} finally {
|
|
2103
2124
|
_effect.f();
|
|
@@ -2110,12 +2131,13 @@ import { Schema as Schema2 } from "effect";
|
|
|
2110
2131
|
import React15, { useCallback as useCallback10, useMemo as useMemo8, useState as useState6 } from "react";
|
|
2111
2132
|
import { EchoSchema, Format, isMutable, toJsonSchema } from "@dxos/echo-schema";
|
|
2112
2133
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
2113
|
-
import {
|
|
2134
|
+
import { Callout, IconButton as IconButton4, useTranslation as useTranslation9 } from "@dxos/react-ui";
|
|
2114
2135
|
import { List as List2 } from "@dxos/react-ui-list";
|
|
2115
|
-
import {
|
|
2136
|
+
import { cardSpacing as cardSpacing3 } from "@dxos/react-ui-stack";
|
|
2137
|
+
import { ghostHover, inputTextLabel, mx as mx9 } from "@dxos/react-ui-theme";
|
|
2116
2138
|
import { FieldSchema, ViewProjection, VIEW_FIELD_LIMIT } from "@dxos/schema";
|
|
2117
2139
|
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
|
|
2118
|
-
var grid = "grid grid-cols-[
|
|
2140
|
+
var grid = "grid grid-cols-[32px_1fr_32px_32px] min-bs-[2.5rem]";
|
|
2119
2141
|
var ViewMetaSchema = Schema2.Struct({
|
|
2120
2142
|
name: Schema2.String.annotations({
|
|
2121
2143
|
title: "View"
|
|
@@ -2124,7 +2146,7 @@ var ViewMetaSchema = Schema2.Struct({
|
|
|
2124
2146
|
title: "Typename"
|
|
2125
2147
|
})
|
|
2126
2148
|
}).pipe(Schema2.mutable);
|
|
2127
|
-
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 }) => {
|
|
2128
2150
|
var _effect = _useSignals15();
|
|
2129
2151
|
try {
|
|
2130
2152
|
const { t } = useTranslation9(translationKey);
|
|
@@ -2136,7 +2158,7 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2136
2158
|
view
|
|
2137
2159
|
]);
|
|
2138
2160
|
const [field, setField] = useState6();
|
|
2139
|
-
const
|
|
2161
|
+
const readonly = _readonly || !isMutable(schema);
|
|
2140
2162
|
const viewValues = useMemo8(() => {
|
|
2141
2163
|
return {
|
|
2142
2164
|
name: view.name,
|
|
@@ -2148,20 +2170,20 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2148
2170
|
view
|
|
2149
2171
|
]);
|
|
2150
2172
|
const handleSelect = useCallback10((field2) => {
|
|
2151
|
-
if (
|
|
2173
|
+
if (readonly) {
|
|
2152
2174
|
return;
|
|
2153
2175
|
}
|
|
2154
2176
|
setField((f) => f === field2 ? void 0 : field2);
|
|
2155
2177
|
}, [
|
|
2156
|
-
|
|
2178
|
+
readonly
|
|
2157
2179
|
]);
|
|
2158
2180
|
const handleAdd = useCallback10(() => {
|
|
2159
|
-
invariant3(!
|
|
2181
|
+
invariant3(!readonly, void 0, {
|
|
2160
2182
|
F: __dxlog_file5,
|
|
2161
|
-
L:
|
|
2183
|
+
L: 92,
|
|
2162
2184
|
S: void 0,
|
|
2163
2185
|
A: [
|
|
2164
|
-
"!
|
|
2186
|
+
"!readonly",
|
|
2165
2187
|
""
|
|
2166
2188
|
]
|
|
2167
2189
|
});
|
|
@@ -2169,15 +2191,16 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2169
2191
|
setField(field2);
|
|
2170
2192
|
}, [
|
|
2171
2193
|
schema,
|
|
2172
|
-
view
|
|
2194
|
+
view,
|
|
2195
|
+
readonly
|
|
2173
2196
|
]);
|
|
2174
2197
|
const handleUpdate = useCallback10(({ name, typename }) => {
|
|
2175
|
-
invariant3(!
|
|
2198
|
+
invariant3(!readonly, void 0, {
|
|
2176
2199
|
F: __dxlog_file5,
|
|
2177
|
-
L:
|
|
2200
|
+
L: 99,
|
|
2178
2201
|
S: void 0,
|
|
2179
2202
|
A: [
|
|
2180
|
-
"!
|
|
2203
|
+
"!readonly",
|
|
2181
2204
|
""
|
|
2182
2205
|
]
|
|
2183
2206
|
});
|
|
@@ -2185,7 +2208,7 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2185
2208
|
if (view.name !== name) {
|
|
2186
2209
|
view.name = name;
|
|
2187
2210
|
}
|
|
2188
|
-
if (view.query.typename !== typename && !
|
|
2211
|
+
if (view.query.typename !== typename && !readonly) {
|
|
2189
2212
|
onTypenameChanged?.(typename);
|
|
2190
2213
|
}
|
|
2191
2214
|
});
|
|
@@ -2193,15 +2216,15 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2193
2216
|
schema,
|
|
2194
2217
|
view,
|
|
2195
2218
|
onTypenameChanged,
|
|
2196
|
-
|
|
2219
|
+
readonly
|
|
2197
2220
|
]);
|
|
2198
2221
|
const handleDelete = useCallback10((fieldId) => {
|
|
2199
|
-
invariant3(!
|
|
2222
|
+
invariant3(!readonly, void 0, {
|
|
2200
2223
|
F: __dxlog_file5,
|
|
2201
|
-
L:
|
|
2224
|
+
L: 115,
|
|
2202
2225
|
S: void 0,
|
|
2203
2226
|
A: [
|
|
2204
|
-
"!
|
|
2227
|
+
"!readonly",
|
|
2205
2228
|
""
|
|
2206
2229
|
]
|
|
2207
2230
|
});
|
|
@@ -2212,15 +2235,16 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2212
2235
|
}, [
|
|
2213
2236
|
schema,
|
|
2214
2237
|
field,
|
|
2215
|
-
onDelete
|
|
2238
|
+
onDelete,
|
|
2239
|
+
readonly
|
|
2216
2240
|
]);
|
|
2217
2241
|
const handleMove = useCallback10((fromIndex, toIndex) => {
|
|
2218
|
-
invariant3(!
|
|
2242
|
+
invariant3(!readonly, void 0, {
|
|
2219
2243
|
F: __dxlog_file5,
|
|
2220
|
-
L:
|
|
2244
|
+
L: 127,
|
|
2221
2245
|
S: void 0,
|
|
2222
2246
|
A: [
|
|
2223
|
-
"!
|
|
2247
|
+
"!readonly",
|
|
2224
2248
|
""
|
|
2225
2249
|
]
|
|
2226
2250
|
});
|
|
@@ -2232,7 +2256,8 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2232
2256
|
view.fields = fields;
|
|
2233
2257
|
}, [
|
|
2234
2258
|
schema,
|
|
2235
|
-
view.fields
|
|
2259
|
+
view.fields,
|
|
2260
|
+
readonly
|
|
2236
2261
|
]);
|
|
2237
2262
|
const handleClose = useCallback10(() => setField(void 0), []);
|
|
2238
2263
|
const hiddenProperties = projection.getHiddenProperties();
|
|
@@ -2250,36 +2275,30 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2250
2275
|
]);
|
|
2251
2276
|
return /* @__PURE__ */ React15.createElement("div", {
|
|
2252
2277
|
role: "none",
|
|
2253
|
-
className:
|
|
2254
|
-
},
|
|
2278
|
+
className: mx9(classNames)
|
|
2279
|
+
}, readonly && /* @__PURE__ */ React15.createElement("div", {
|
|
2255
2280
|
role: "none",
|
|
2256
|
-
className: "
|
|
2257
|
-
}, /* @__PURE__ */ React15.createElement(
|
|
2258
|
-
valence: "
|
|
2259
|
-
|
|
2260
|
-
}, /* @__PURE__ */ React15.createElement(Message.Title, null, /* @__PURE__ */ React15.createElement(Icon3, {
|
|
2261
|
-
icon: "ph--info--regular",
|
|
2262
|
-
size: 5,
|
|
2263
|
-
classNames: "inline"
|
|
2264
|
-
}), " ", 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, {
|
|
2265
2285
|
autoSave: true,
|
|
2266
2286
|
schema: ViewMetaSchema,
|
|
2267
2287
|
values: viewValues,
|
|
2288
|
+
readonly,
|
|
2268
2289
|
onSave: handleUpdate,
|
|
2269
|
-
|
|
2290
|
+
outerSpacing
|
|
2270
2291
|
}), /* @__PURE__ */ React15.createElement("div", {
|
|
2271
2292
|
role: "none",
|
|
2272
|
-
className: "
|
|
2273
|
-
}, /* @__PURE__ */ React15.createElement("div", {
|
|
2274
|
-
role: "none",
|
|
2275
|
-
className: "pli-card-spacing-inline mlb-card-spacing-block"
|
|
2293
|
+
className: outerSpacing ? cardSpacing3 : "mlb-cardSpacingBlock"
|
|
2276
2294
|
}, /* @__PURE__ */ React15.createElement("label", {
|
|
2277
|
-
className:
|
|
2278
|
-
}, t("fields label"))
|
|
2295
|
+
className: mx9(inputTextLabel)
|
|
2296
|
+
}, t("fields label")), /* @__PURE__ */ React15.createElement(List2.Root, {
|
|
2279
2297
|
items: view.fields,
|
|
2280
2298
|
isItem: Schema2.is(FieldSchema),
|
|
2281
2299
|
getId: (field2) => field2.id,
|
|
2282
|
-
|
|
2300
|
+
readonly,
|
|
2301
|
+
onMove: readonly ? void 0 : handleMove
|
|
2283
2302
|
}, ({ items: fields }) => /* @__PURE__ */ React15.createElement(React15.Fragment, null, showHeading && /* @__PURE__ */ React15.createElement("div", {
|
|
2284
2303
|
role: "heading",
|
|
2285
2304
|
className: grid
|
|
@@ -2287,41 +2306,38 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2287
2306
|
className: "flex items-center text-sm"
|
|
2288
2307
|
}, t("field path label"))), /* @__PURE__ */ React15.createElement("div", {
|
|
2289
2308
|
role: "list",
|
|
2290
|
-
className: "flex flex-col
|
|
2309
|
+
className: "flex flex-col is-full"
|
|
2291
2310
|
}, fields?.map((field2) => /* @__PURE__ */ React15.createElement(List2.Item, {
|
|
2292
2311
|
key: field2.id,
|
|
2293
2312
|
item: field2,
|
|
2294
|
-
classNames:
|
|
2313
|
+
classNames: mx9(grid, ghostHover, "overflow-hidden", !readonly && "cursor-pointer")
|
|
2295
2314
|
}, /* @__PURE__ */ React15.createElement(List2.ItemDragHandle, null), /* @__PURE__ */ React15.createElement(List2.ItemTitle, {
|
|
2296
2315
|
onClick: () => handleSelect(field2)
|
|
2297
|
-
}, field2.path), /* @__PURE__ */ React15.createElement(
|
|
2298
|
-
|
|
2299
|
-
}, /* @__PURE__ */ React15.createElement(List2.ItemButton, {
|
|
2316
|
+
}, field2.path), /* @__PURE__ */ React15.createElement(List2.ItemButton, {
|
|
2317
|
+
"data-testid": "hide-field-button",
|
|
2300
2318
|
icon: "ph--eye-slash--regular",
|
|
2319
|
+
// TDOO(burdon): Is this the correct test?
|
|
2301
2320
|
disabled: view.fields.length <= 1,
|
|
2302
|
-
onClick: () => handleHide(field2.id)
|
|
2303
|
-
|
|
2304
|
-
}), !immutable && /* @__PURE__ */ React15.createElement(List2.ItemDeleteButton, {
|
|
2305
|
-
icon: "ph--trash--regular",
|
|
2321
|
+
onClick: () => handleHide(field2.id)
|
|
2322
|
+
}), !readonly && /* @__PURE__ */ React15.createElement(List2.ItemDeleteButton, {
|
|
2306
2323
|
disabled: view.fields.length <= 1,
|
|
2307
2324
|
onClick: () => handleDelete(field2.id)
|
|
2308
|
-
}))))))
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
}, /* @__PURE__ */ React15.createElement("label", {
|
|
2312
|
-
className: mx8(inputTextLabel)
|
|
2313
|
-
}, 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, {
|
|
2314
2328
|
items: hiddenProperties,
|
|
2315
2329
|
isItem: (item) => typeof item === "string",
|
|
2316
2330
|
getId: (property) => property
|
|
2317
2331
|
}, ({ items: properties }) => /* @__PURE__ */ React15.createElement("div", {
|
|
2318
2332
|
role: "list",
|
|
2319
|
-
className: "flex flex-col
|
|
2333
|
+
className: "flex flex-col is-full"
|
|
2320
2334
|
}, properties?.map((property) => /* @__PURE__ */ React15.createElement(List2.Item, {
|
|
2321
2335
|
key: property,
|
|
2322
2336
|
item: property,
|
|
2323
|
-
classNames:
|
|
2324
|
-
}, /* @__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, {
|
|
2325
2341
|
icon: "ph--eye--regular",
|
|
2326
2342
|
onClick: () => handleShow(property),
|
|
2327
2343
|
"data-testid": "show-field-button"
|
|
@@ -2334,11 +2350,11 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2334
2350
|
onSave: handleClose
|
|
2335
2351
|
}), !readonly && !field && /* @__PURE__ */ React15.createElement("div", {
|
|
2336
2352
|
role: "none",
|
|
2337
|
-
className: "
|
|
2353
|
+
className: outerSpacing ? cardSpacing3 : "mlb-cardSpacingBlock"
|
|
2338
2354
|
}, /* @__PURE__ */ React15.createElement(IconButton4, {
|
|
2339
2355
|
icon: "ph--plus--regular",
|
|
2340
2356
|
label: t("button add property"),
|
|
2341
|
-
onClick:
|
|
2357
|
+
onClick: readonly ? void 0 : handleAdd,
|
|
2342
2358
|
// TODO(burdon): Show field limit in ux (not tooltip).
|
|
2343
2359
|
disabled: view.fields.length >= VIEW_FIELD_LIMIT,
|
|
2344
2360
|
classNames: "flex is-full"
|