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