@dxos/react-ui-form 0.8.4-main.69d29f4 → 0.8.4-main.6fa680abb7
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/README.md +0 -1
- package/dist/lib/browser/index.mjs +527 -444
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +527 -444
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +3 -3
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.d.ts +13 -13
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +3 -3
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldComponent.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts +2 -2
- package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldSet.d.ts +7 -7
- package/dist/types/src/components/Form/FormFieldSet.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/ArrayField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/RefField.d.ts +6 -4
- package/dist/types/src/components/Form/fields/RefField.d.ts.map +1 -1
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -1
- package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts.map +1 -1
- package/dist/types/src/components/Settings/Settings.d.ts +56 -0
- package/dist/types/src/components/Settings/Settings.d.ts.map +1 -0
- package/dist/types/src/components/{ControlSection/ControlSection.stories.d.ts → Settings/Settings.stories.d.ts} +2 -8
- package/dist/types/src/components/Settings/Settings.stories.d.ts.map +1 -0
- package/dist/types/src/components/Settings/index.d.ts +2 -0
- package/dist/types/src/components/Settings/index.d.ts.map +1 -0
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +5 -5
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +2 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useFormHandler.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +0 -1
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +35 -37
- package/src/components/FieldEditor/FieldEditor.stories.tsx +4 -6
- package/src/components/FieldEditor/FieldEditor.tsx +2 -3
- package/src/components/Form/Form.stories.tsx +8 -7
- package/src/components/Form/Form.tsx +82 -55
- package/src/components/Form/FormField.tsx +12 -4
- package/src/components/Form/FormFieldComponent.stories.tsx +5 -5
- package/src/components/Form/FormFieldComponent.tsx +17 -19
- package/src/components/Form/FormFieldSet.tsx +32 -34
- package/src/components/Form/fields/ArrayField.tsx +6 -8
- package/src/components/Form/fields/MarkdownField.tsx +1 -1
- package/src/components/Form/fields/RefField.tsx +28 -15
- package/src/components/Form/fields/SelectField.tsx +1 -1
- package/src/components/Form/fields/SelectOptionField.stories.tsx +2 -2
- package/src/components/Form/fields/SelectOptionField.tsx +4 -4
- package/src/components/ObjectPicker/ObjectPicker.stories.tsx +9 -13
- package/src/components/Settings/Settings.stories.tsx +56 -0
- package/src/components/Settings/Settings.tsx +230 -0
- package/src/components/{ControlSection → Settings}/index.ts +1 -1
- package/src/components/ViewEditor/ViewEditor.stories.tsx +14 -12
- package/src/components/ViewEditor/ViewEditor.test.tsx +3 -6
- package/src/components/ViewEditor/ViewEditor.tsx +90 -61
- package/src/components/index.ts +1 -1
- package/src/components/testing.tsx +9 -6
- package/src/hooks/useFormHandler.ts +42 -24
- package/src/util/index.ts +0 -1
- package/dist/types/src/components/ControlSection/ControlSection.d.ts +0 -23
- package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +0 -1
- package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts.map +0 -1
- package/dist/types/src/components/ControlSection/index.d.ts +0 -2
- package/dist/types/src/components/ControlSection/index.d.ts.map +0 -1
- package/dist/types/src/components/Form/Form-old.stories.d.ts +0 -131
- package/dist/types/src/components/Form/Form-old.stories.d.ts.map +0 -1
- package/dist/types/src/util/echo.d.ts +0 -6
- package/dist/types/src/util/echo.d.ts.map +0 -1
- package/src/components/ControlSection/ControlSection.stories.tsx +0 -38
- package/src/components/ControlSection/ControlSection.tsx +0 -153
- package/src/components/Form/Form-old.stories.tsx +0 -314
- package/src/util/echo.ts +0 -25
|
@@ -77,117 +77,14 @@ var translations = [
|
|
|
77
77
|
}
|
|
78
78
|
];
|
|
79
79
|
|
|
80
|
-
// src/components/ControlSection/ControlSection.tsx
|
|
81
|
-
import React from "react";
|
|
82
|
-
import { Button, Input, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
83
|
-
import { Layout } from "@dxos/react-ui-mosaic";
|
|
84
|
-
import { mx } from "@dxos/ui-theme";
|
|
85
|
-
var ControlPage = ({ children, classNames, ...props }) => {
|
|
86
|
-
return /* @__PURE__ */ React.createElement(Layout.Container, {
|
|
87
|
-
scrollable: true,
|
|
88
|
-
classNames: "[--control-spacing:var(--dx-trimMd)]"
|
|
89
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
90
|
-
role: "none",
|
|
91
|
-
className: mx("pli-cardSpacingInline pbe-trimMd", classNames),
|
|
92
|
-
...props
|
|
93
|
-
}, children));
|
|
94
|
-
};
|
|
95
|
-
var ControlSection = ({ title, description, children }) => {
|
|
96
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ControlSectionHeading, {
|
|
97
|
-
title,
|
|
98
|
-
description
|
|
99
|
-
}), children);
|
|
100
|
-
};
|
|
101
|
-
var ControlSectionHeading = ({ title, description }) => {
|
|
102
|
-
const { t } = useTranslation(translationKey);
|
|
103
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h2", {
|
|
104
|
-
className: "pli-trimMd container-max-width text-xl mbs-trimMd mbe-trimMd"
|
|
105
|
-
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement("p", {
|
|
106
|
-
className: "pli-trimMd mlb-trimMd container-max-width text-description"
|
|
107
|
-
}, toLocalizedString(description, t)));
|
|
108
|
-
};
|
|
109
|
-
var ControlGroupButton = ({ classNames, ...props }) => {
|
|
110
|
-
return /* @__PURE__ */ React.createElement(Button, {
|
|
111
|
-
...props,
|
|
112
|
-
classNames: [
|
|
113
|
-
"md:col-span-2",
|
|
114
|
-
classNames
|
|
115
|
-
]
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
|
-
var ControlGroup = ({ children, classNames }) => /* @__PURE__ */ React.createElement("div", {
|
|
119
|
-
role: "none",
|
|
120
|
-
className: mx("group container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content] gap-trimMd", "[--control-spacing:0px] [&_input]:justify-self-end [&_button]:justify-self-end", classNames)
|
|
121
|
-
}, children);
|
|
122
|
-
var ControlFrame = ({ children }) => /* @__PURE__ */ React.createElement("div", {
|
|
123
|
-
role: "none",
|
|
124
|
-
className: mx("container-max-width grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-trimSm md:gap-trimMd p-trimMd", "border border-separator rounded-md")
|
|
125
|
-
}, children);
|
|
126
|
-
var controlItemClasses = mx([
|
|
127
|
-
"container-max-width grid md:col-span-2 grid-cols-subgrid gap-trimSm items-center",
|
|
128
|
-
// TODO(burdon): Use grid gap consistently or apply margins consistently?
|
|
129
|
-
"mlb-[--control-spacing] *:first:!mbs-0 *:last:!mbe-0 pli-trimMd plb-trimMd",
|
|
130
|
-
"border border-separator rounded-md"
|
|
131
|
-
]);
|
|
132
|
-
var controlItemTitleClasses = "mbe-0 text-lg text-baseText font-normal";
|
|
133
|
-
var controlItemDescriptionClasses = "mlb-trimSm md:mbe-0 text-base text-description";
|
|
134
|
-
var ControlItem = ({ title, description, children }) => {
|
|
135
|
-
const { t } = useTranslation(translationKey);
|
|
136
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
137
|
-
className: controlItemClasses
|
|
138
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
139
|
-
role: "none"
|
|
140
|
-
}, /* @__PURE__ */ React.createElement("h3", {
|
|
141
|
-
className: controlItemTitleClasses
|
|
142
|
-
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement("p", {
|
|
143
|
-
className: controlItemDescriptionClasses
|
|
144
|
-
}, toLocalizedString(description, t))), children);
|
|
145
|
-
};
|
|
146
|
-
var ControlItemInput = ({ title, description, children }) => {
|
|
147
|
-
const { t } = useTranslation(translationKey);
|
|
148
|
-
return /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement("div", {
|
|
149
|
-
className: controlItemClasses
|
|
150
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
151
|
-
role: "none"
|
|
152
|
-
}, /* @__PURE__ */ React.createElement(Input.Label, {
|
|
153
|
-
classNames: controlItemTitleClasses
|
|
154
|
-
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement(Input.DescriptionAndValidation, null, /* @__PURE__ */ React.createElement(Input.Description, {
|
|
155
|
-
classNames: controlItemDescriptionClasses
|
|
156
|
-
}, toLocalizedString(description, t)))), children));
|
|
157
|
-
};
|
|
158
|
-
var ControlFrameItem = ({ title, description, children }) => {
|
|
159
|
-
const { t } = useTranslation(translationKey);
|
|
160
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
161
|
-
role: "group",
|
|
162
|
-
className: "min-is-0"
|
|
163
|
-
}, /* @__PURE__ */ React.createElement("h3", {
|
|
164
|
-
className: "text-lg mbe-2"
|
|
165
|
-
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement("p", {
|
|
166
|
-
className: "mlb-trimSm md:mbe-0 text-description"
|
|
167
|
-
}, toLocalizedString(description, t)), children);
|
|
168
|
-
};
|
|
169
|
-
|
|
170
80
|
// src/components/FieldEditor/FieldEditor.tsx
|
|
171
|
-
import
|
|
172
|
-
import { Obj as
|
|
81
|
+
import React17, { useCallback as useCallback14, useEffect as useEffect7, useMemo as useMemo7, useState as useState5 } from "react";
|
|
82
|
+
import { Obj as Obj2 } from "@dxos/echo";
|
|
173
83
|
import { Format as Format4, FormatEnums, formatToType } from "@dxos/echo/internal";
|
|
174
84
|
import { log as log2 } from "@dxos/log";
|
|
175
|
-
import { useAsyncEffect, useTranslation as
|
|
85
|
+
import { useAsyncEffect, useTranslation as useTranslation8 } from "@dxos/react-ui";
|
|
176
86
|
import { formatToAdditionalPropertyAttributes, getFormatSchema } from "@dxos/schema";
|
|
177
87
|
|
|
178
|
-
// src/util/echo.ts
|
|
179
|
-
import { Obj } from "@dxos/echo";
|
|
180
|
-
import { setValue as setValuePlain, splitJsonPath } from "@dxos/effect";
|
|
181
|
-
var setValueEchoAware = (obj, path, value3) => {
|
|
182
|
-
if (Obj.isObject(obj)) {
|
|
183
|
-
Obj.change(obj, (mutableObj) => {
|
|
184
|
-
Obj.setValue(mutableObj, splitJsonPath(path), value3);
|
|
185
|
-
});
|
|
186
|
-
return obj;
|
|
187
|
-
}
|
|
188
|
-
return setValuePlain(obj, path, value3);
|
|
189
|
-
};
|
|
190
|
-
|
|
191
88
|
// src/util/field.ts
|
|
192
89
|
import { Format, GeoLocation, TypeEnum } from "@dxos/echo/internal";
|
|
193
90
|
var parseValue = ({ type, format, value: value3 }) => {
|
|
@@ -481,24 +378,24 @@ var getRefProps = (ast) => {
|
|
|
481
378
|
|
|
482
379
|
// src/components/Form/fields/ArrayField.tsx
|
|
483
380
|
import * as Option3 from "effect/Option";
|
|
484
|
-
import * as
|
|
485
|
-
import
|
|
381
|
+
import * as SchemaAST3 from "effect/SchemaAST";
|
|
382
|
+
import React5, { useCallback as useCallback3 } from "react";
|
|
486
383
|
import { findNode as findNode2, getArrayElementType as getArrayElementType2, getDiscriminatedType as getDiscriminatedType2, isDiscriminatedUnion as isDiscriminatedUnion2, isNestedType as isNestedType2 } from "@dxos/effect";
|
|
487
|
-
import { IconButton as IconButton2, useTranslation as
|
|
384
|
+
import { IconButton as IconButton2, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
488
385
|
|
|
489
386
|
// src/components/Form/Form.tsx
|
|
490
387
|
import { createContext } from "@radix-ui/react-context";
|
|
491
388
|
import * as Schema2 from "effect/Schema";
|
|
492
|
-
import
|
|
389
|
+
import * as SchemaAST2 from "effect/SchemaAST";
|
|
390
|
+
import React4, { useEffect as useEffect3, useMemo as useMemo4, useRef } from "react";
|
|
493
391
|
import { createJsonPath as createJsonPath3, getValue as getValue$2 } from "@dxos/effect";
|
|
494
|
-
import { IconButton, ScrollArea, useTranslation as
|
|
495
|
-
import { mx as
|
|
392
|
+
import { IconButton, ScrollArea, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
393
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
496
394
|
|
|
497
395
|
// src/hooks/useFormHandler.ts
|
|
498
396
|
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
499
397
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
500
|
-
import {
|
|
501
|
-
import { createJsonPath, fromEffectValidationPath, getValue as getValue$, setValue as setValue$ } from "@dxos/effect";
|
|
398
|
+
import { createJsonPath, fromEffectValidationPath, getValue as getValue$ } from "@dxos/effect";
|
|
502
399
|
import { log } from "@dxos/log";
|
|
503
400
|
import { useDefaultValue } from "@dxos/react-ui";
|
|
504
401
|
import { validateSchema } from "@dxos/schema";
|
|
@@ -513,11 +410,13 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
|
|
|
513
410
|
prop: valuesProp,
|
|
514
411
|
defaultProp: defaultValues,
|
|
515
412
|
onChange: () => {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
413
|
+
if (valuesProp !== void 0) {
|
|
414
|
+
setValues(valuesProp ?? defaultValues);
|
|
415
|
+
setChanged({});
|
|
416
|
+
setTouched({});
|
|
417
|
+
setErrors({});
|
|
418
|
+
setSaving(false);
|
|
419
|
+
}
|
|
521
420
|
}
|
|
522
421
|
});
|
|
523
422
|
const values = values$;
|
|
@@ -531,7 +430,7 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
|
|
|
531
430
|
errors: errors2
|
|
532
431
|
}, {
|
|
533
432
|
F: __dxlog_file,
|
|
534
|
-
L:
|
|
433
|
+
L: 155,
|
|
535
434
|
S: void 0,
|
|
536
435
|
C: (f, a) => f(...a)
|
|
537
436
|
});
|
|
@@ -624,11 +523,12 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
|
|
|
624
523
|
value: value3
|
|
625
524
|
}, {
|
|
626
525
|
F: __dxlog_file,
|
|
627
|
-
L:
|
|
526
|
+
L: 254,
|
|
628
527
|
S: void 0,
|
|
629
528
|
C: (f, a) => f(...a)
|
|
630
529
|
});
|
|
631
530
|
const jsonPath = createJsonPath(path);
|
|
531
|
+
const pathArray = path;
|
|
632
532
|
let parsedValue = value3;
|
|
633
533
|
try {
|
|
634
534
|
if (type._tag === "NumberKeyword") {
|
|
@@ -637,33 +537,33 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
|
|
|
637
537
|
} catch (err) {
|
|
638
538
|
log.catch(err, void 0, {
|
|
639
539
|
F: __dxlog_file,
|
|
640
|
-
L:
|
|
540
|
+
L: 264,
|
|
641
541
|
S: void 0,
|
|
642
542
|
C: (f, a) => f(...a)
|
|
643
543
|
});
|
|
644
544
|
parsedValue = void 0;
|
|
645
545
|
}
|
|
646
|
-
const newValues =
|
|
647
|
-
...setValue$(values, jsonPath, parsedValue)
|
|
648
|
-
};
|
|
649
|
-
setValues(newValues);
|
|
546
|
+
const newValues = mergeAtPath(values, pathArray, parsedValue);
|
|
650
547
|
const newChanged = {
|
|
651
548
|
[jsonPath]: true
|
|
652
549
|
};
|
|
653
|
-
setChanged({
|
|
654
|
-
...
|
|
550
|
+
setChanged((prev) => ({
|
|
551
|
+
...prev,
|
|
655
552
|
...newChanged
|
|
656
|
-
});
|
|
553
|
+
}));
|
|
657
554
|
const isValid2 = validate(newValues);
|
|
658
555
|
onValuesChanged?.(newValues, {
|
|
659
556
|
isValid: isValid2,
|
|
660
557
|
changed: newChanged
|
|
661
558
|
});
|
|
559
|
+
if (valuesProp === void 0) {
|
|
560
|
+
setValues(newValues);
|
|
561
|
+
}
|
|
662
562
|
}, [
|
|
663
563
|
values,
|
|
664
|
-
changed,
|
|
665
564
|
validate,
|
|
666
|
-
onValuesChanged
|
|
565
|
+
onValuesChanged,
|
|
566
|
+
valuesProp
|
|
667
567
|
]);
|
|
668
568
|
const onBlur = useCallback(async (path) => {
|
|
669
569
|
const jsonPath = createJsonPath(path);
|
|
@@ -720,6 +620,24 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
|
|
|
720
620
|
onCancel
|
|
721
621
|
]);
|
|
722
622
|
};
|
|
623
|
+
var mergeAtPath = (obj, path, value3) => {
|
|
624
|
+
if (path.length === 0) {
|
|
625
|
+
return value3;
|
|
626
|
+
}
|
|
627
|
+
const [head2, ...rest] = path;
|
|
628
|
+
const child = rest.length === 0 ? value3 : mergeAtPath(obj?.[head2], rest, value3);
|
|
629
|
+
if (Array.isArray(obj)) {
|
|
630
|
+
const copy = [
|
|
631
|
+
...obj
|
|
632
|
+
];
|
|
633
|
+
copy[head2] = child;
|
|
634
|
+
return copy;
|
|
635
|
+
}
|
|
636
|
+
return {
|
|
637
|
+
...obj,
|
|
638
|
+
[head2]: child
|
|
639
|
+
};
|
|
640
|
+
};
|
|
723
641
|
var flatMap = (errors) => {
|
|
724
642
|
return errors.reduce((result, { path, message }) => {
|
|
725
643
|
const jsonPath = fromEffectValidationPath(path);
|
|
@@ -761,28 +679,24 @@ var useKeyHandler = (formElement, form) => {
|
|
|
761
679
|
};
|
|
762
680
|
|
|
763
681
|
// src/components/Form/FormFieldComponent.tsx
|
|
764
|
-
import
|
|
765
|
-
import { Icon, Input
|
|
766
|
-
import {
|
|
767
|
-
var labelSpacing = "mbs-inputSpacingBlock mbe-labelSpacingBlock";
|
|
682
|
+
import React, { Component } from "react";
|
|
683
|
+
import { Icon, Input, Tooltip } from "@dxos/react-ui";
|
|
684
|
+
import { inputTextLabel } from "@dxos/ui-theme";
|
|
768
685
|
var FormFieldLabel = ({ label, error, readonly, asChild }) => {
|
|
769
|
-
const Label = readonly || asChild ? "span" :
|
|
770
|
-
|
|
771
|
-
className: "text-description text-sm"
|
|
772
|
-
} : {
|
|
773
|
-
classNames: "!mlb-0 text-sm"
|
|
774
|
-
};
|
|
775
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
686
|
+
const Label = readonly || asChild ? "span" : Input.Label;
|
|
687
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
776
688
|
role: "none",
|
|
777
|
-
className:
|
|
778
|
-
}, /* @__PURE__ */
|
|
689
|
+
className: "flex items-center justify-between"
|
|
690
|
+
}, /* @__PURE__ */ React.createElement(Label, {
|
|
691
|
+
className: inputTextLabel
|
|
692
|
+
}, label), error && /* @__PURE__ */ React.createElement(Tooltip.Trigger, {
|
|
779
693
|
asChild: true,
|
|
780
694
|
content: error,
|
|
781
695
|
side: "bottom"
|
|
782
|
-
}, /* @__PURE__ */
|
|
696
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
783
697
|
icon: "ph--warning--regular",
|
|
784
698
|
size: 4,
|
|
785
|
-
classNames:
|
|
699
|
+
classNames: "text-error-text"
|
|
786
700
|
})));
|
|
787
701
|
};
|
|
788
702
|
FormFieldLabel.displayName = "Form.FieldLabel";
|
|
@@ -794,15 +708,18 @@ var FormFieldWrapper = (props) => {
|
|
|
794
708
|
return null;
|
|
795
709
|
}
|
|
796
710
|
const str = String(value3 ?? "");
|
|
797
|
-
return /* @__PURE__ */
|
|
711
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
712
|
+
role: "none",
|
|
713
|
+
className: "contents"
|
|
714
|
+
}, /* @__PURE__ */ React.createElement(Input.Root, {
|
|
798
715
|
validationValence: status
|
|
799
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
716
|
+
}, layout !== "inline" && /* @__PURE__ */ React.createElement(FormFieldLabel, {
|
|
800
717
|
error,
|
|
801
718
|
readonly,
|
|
802
719
|
label
|
|
803
|
-
}), layout === "static" ? /* @__PURE__ */
|
|
720
|
+
}), layout === "static" ? /* @__PURE__ */ React.createElement("p", null, str) : children ? children({
|
|
804
721
|
value: value3
|
|
805
|
-
}) : null, layout === "full" && /* @__PURE__ */
|
|
722
|
+
}) : null, layout === "full" && /* @__PURE__ */ React.createElement(Input.DescriptionAndValidation, null, /* @__PURE__ */ React.createElement(Input.Validation, null, error))));
|
|
806
723
|
};
|
|
807
724
|
var FormFieldErrorBoundary = class extends Component {
|
|
808
725
|
static getDerivedStateFromError(error) {
|
|
@@ -820,10 +737,10 @@ var FormFieldErrorBoundary = class extends Component {
|
|
|
820
737
|
}
|
|
821
738
|
render() {
|
|
822
739
|
if (this.state.error) {
|
|
823
|
-
return /* @__PURE__ */
|
|
824
|
-
className: "flex gap-2 border border-
|
|
825
|
-
}, /* @__PURE__ */
|
|
826
|
-
className: "bg-
|
|
740
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
741
|
+
className: "flex gap-2 border border-rose-fill font-mono text-sm"
|
|
742
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
743
|
+
className: "bg-rose-fill text-surface-text px-1 font-thin"
|
|
827
744
|
}, "ERROR"), String(this.props.path?.join(".")));
|
|
828
745
|
}
|
|
829
746
|
return this.props.children;
|
|
@@ -836,8 +753,8 @@ var FormFieldErrorBoundary = class extends Component {
|
|
|
836
753
|
};
|
|
837
754
|
|
|
838
755
|
// src/components/Form/FormFieldSet.tsx
|
|
839
|
-
import
|
|
840
|
-
import { mx
|
|
756
|
+
import React3, { forwardRef, useMemo as useMemo3 } from "react";
|
|
757
|
+
import { mx } from "@dxos/ui-theme";
|
|
841
758
|
import { isTruthy } from "@dxos/util";
|
|
842
759
|
|
|
843
760
|
// src/components/Form/FormField.tsx
|
|
@@ -846,10 +763,10 @@ import * as Option2 from "effect/Option";
|
|
|
846
763
|
import * as Schema from "effect/Schema";
|
|
847
764
|
import * as SchemaAST from "effect/SchemaAST";
|
|
848
765
|
import * as String2 from "effect/String";
|
|
849
|
-
import
|
|
766
|
+
import React2, { useMemo as useMemo2 } from "react";
|
|
850
767
|
import { Format as Format3 } from "@dxos/echo";
|
|
851
768
|
import { createJsonPath as createJsonPath2, findNode, getAnnotation, getDiscriminatedType, isArrayType as isArrayType2, isDiscriminatedUnion, isLiteralUnion, isNestedType } from "@dxos/effect";
|
|
852
|
-
import { useTranslation
|
|
769
|
+
import { useTranslation } from "@dxos/react-ui";
|
|
853
770
|
var FormField = (props) => {
|
|
854
771
|
const {
|
|
855
772
|
type,
|
|
@@ -869,7 +786,7 @@ var FormField = (props) => {
|
|
|
869
786
|
getOptions: getRefOptions,
|
|
870
787
|
onCreate
|
|
871
788
|
} = props;
|
|
872
|
-
const { t } =
|
|
789
|
+
const { t } = useTranslation(translationKey);
|
|
873
790
|
const title = getAnnotation(SchemaAST.TitleAnnotationId)(type);
|
|
874
791
|
const description = getAnnotation(SchemaAST.DescriptionAnnotationId)(type);
|
|
875
792
|
const examples = getAnnotation(SchemaAST.ExamplesAnnotationId)(type);
|
|
@@ -895,7 +812,7 @@ var FormField = (props) => {
|
|
|
895
812
|
const jsonPath = createJsonPath2(path ?? []);
|
|
896
813
|
const CustomField = fieldMap?.[jsonPath];
|
|
897
814
|
if (CustomField) {
|
|
898
|
-
return /* @__PURE__ */
|
|
815
|
+
return /* @__PURE__ */ React2.createElement(CustomField, fieldProps);
|
|
899
816
|
}
|
|
900
817
|
const component = fieldProvider?.({
|
|
901
818
|
schema: Schema.make(type),
|
|
@@ -906,7 +823,7 @@ var FormField = (props) => {
|
|
|
906
823
|
return component;
|
|
907
824
|
}
|
|
908
825
|
if (isArrayType2(type)) {
|
|
909
|
-
return /* @__PURE__ */
|
|
826
|
+
return /* @__PURE__ */ React2.createElement(ArrayField, {
|
|
910
827
|
fieldProps: fieldState,
|
|
911
828
|
label,
|
|
912
829
|
...props
|
|
@@ -914,21 +831,27 @@ var FormField = (props) => {
|
|
|
914
831
|
}
|
|
915
832
|
const Field = getFormField(fieldProps);
|
|
916
833
|
if (Field) {
|
|
917
|
-
return /* @__PURE__ */
|
|
834
|
+
return /* @__PURE__ */ React2.createElement(Field, fieldProps);
|
|
918
835
|
}
|
|
919
836
|
const options = getOptions(type);
|
|
920
837
|
if (options) {
|
|
921
|
-
|
|
838
|
+
const fieldProjections = projection?.getFieldProjections();
|
|
839
|
+
const fieldProjection = fieldProjections?.find((fp) => fp.field.path === name);
|
|
840
|
+
const selectOptions = fieldProjection?.props.options;
|
|
841
|
+
return /* @__PURE__ */ React2.createElement(SelectField, {
|
|
922
842
|
...fieldProps,
|
|
923
|
-
options: options.map((option) =>
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
843
|
+
options: options.map((option) => {
|
|
844
|
+
const selectOption = selectOptions?.find((so) => so.id === globalThis.String(option));
|
|
845
|
+
return {
|
|
846
|
+
value: option,
|
|
847
|
+
label: selectOption?.title ?? option.toString()
|
|
848
|
+
};
|
|
849
|
+
})
|
|
927
850
|
});
|
|
928
851
|
}
|
|
929
852
|
const refProps = getRefProps(type);
|
|
930
853
|
if (refProps) {
|
|
931
|
-
return /* @__PURE__ */
|
|
854
|
+
return /* @__PURE__ */ React2.createElement(RefField, {
|
|
932
855
|
...fieldProps,
|
|
933
856
|
...refProps,
|
|
934
857
|
createOptionLabel,
|
|
@@ -945,7 +868,7 @@ var FormField = (props) => {
|
|
|
945
868
|
const typeLiteral = baseNode ? getDiscriminatedType(baseNode, fieldState.getValue()) : findNode(type, SchemaAST.isTypeLiteral);
|
|
946
869
|
if (typeLiteral) {
|
|
947
870
|
const schema = Schema.make(typeLiteral);
|
|
948
|
-
return /* @__PURE__ */
|
|
871
|
+
return /* @__PURE__ */ React2.createElement(FormFieldSet, {
|
|
949
872
|
schema,
|
|
950
873
|
path,
|
|
951
874
|
readonly,
|
|
@@ -991,8 +914,9 @@ var getOptions = (ast) => {
|
|
|
991
914
|
};
|
|
992
915
|
|
|
993
916
|
// src/components/Form/FormFieldSet.tsx
|
|
994
|
-
var
|
|
995
|
-
|
|
917
|
+
var FORM_FIELDSET_NAME = "Form.FieldSet";
|
|
918
|
+
var FormFieldSet = /* @__PURE__ */ forwardRef(({ label, schema, readonly, path, exclude, sort, projection, layout, ...props }, forwardRef4) => {
|
|
919
|
+
const values = useFormValues(FORM_FIELDSET_NAME, path);
|
|
996
920
|
const properties = useMemo3(() => {
|
|
997
921
|
if (!schema) {
|
|
998
922
|
return [];
|
|
@@ -1027,22 +951,22 @@ var FormFieldSet = /* @__PURE__ */ forwardRef(({ classNames, label, schema, read
|
|
|
1027
951
|
if ((readonly || layout === "static") && values == null) {
|
|
1028
952
|
return null;
|
|
1029
953
|
}
|
|
1030
|
-
return /* @__PURE__ */
|
|
954
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
1031
955
|
role: "form",
|
|
1032
|
-
className:
|
|
956
|
+
className: mx("w-full", layout === "inline" && "flex flex-col gap-2"),
|
|
1033
957
|
ref: forwardRef4
|
|
1034
|
-
}, layout !== "inline" && label && /* @__PURE__ */
|
|
958
|
+
}, layout !== "inline" && label && /* @__PURE__ */ React3.createElement(FormFieldLabel, {
|
|
1035
959
|
label,
|
|
1036
960
|
asChild: true
|
|
1037
961
|
}), properties.map((property) => {
|
|
1038
962
|
const name = property.name.toString();
|
|
1039
|
-
return /* @__PURE__ */
|
|
963
|
+
return /* @__PURE__ */ React3.createElement(FormFieldErrorBoundary, {
|
|
1040
964
|
key: name,
|
|
1041
965
|
path: [
|
|
1042
966
|
...path ?? [],
|
|
1043
967
|
name
|
|
1044
968
|
]
|
|
1045
|
-
}, /* @__PURE__ */
|
|
969
|
+
}, /* @__PURE__ */ React3.createElement(FormField, {
|
|
1046
970
|
type: property.type,
|
|
1047
971
|
name,
|
|
1048
972
|
path: [
|
|
@@ -1056,22 +980,30 @@ var FormFieldSet = /* @__PURE__ */ forwardRef(({ classNames, label, schema, read
|
|
|
1056
980
|
}));
|
|
1057
981
|
}).filter(isTruthy));
|
|
1058
982
|
});
|
|
1059
|
-
FormFieldSet.displayName =
|
|
983
|
+
FormFieldSet.displayName = FORM_FIELDSET_NAME;
|
|
1060
984
|
|
|
1061
985
|
// src/components/Form/Form.tsx
|
|
1062
986
|
var omitId = (schema) => schema.pipe(Schema2.omit("id"));
|
|
1063
987
|
var [FormContextProvider, useFormContext] = createContext("Form");
|
|
1064
|
-
var useFormValues = (componentName, path
|
|
1065
|
-
const
|
|
1066
|
-
|
|
988
|
+
var useFormValues = (componentName, path, defaultValue) => {
|
|
989
|
+
const stablePath = useMemo4(() => path ?? [], [
|
|
990
|
+
path ? path.join(".") : void 0
|
|
991
|
+
]);
|
|
992
|
+
const jsonPath = createJsonPath3(stablePath);
|
|
993
|
+
const { form: { values, onValueChange } } = useFormContext(componentName);
|
|
1067
994
|
const value3 = getValue$2(values, jsonPath);
|
|
995
|
+
const lastAppliedPathRef = useRef(null);
|
|
1068
996
|
useEffect3(() => {
|
|
1069
|
-
if (
|
|
1070
|
-
|
|
997
|
+
if (value3 == null && defaultValue && lastAppliedPathRef.current !== jsonPath) {
|
|
998
|
+
lastAppliedPathRef.current = jsonPath;
|
|
999
|
+
onValueChange(stablePath, SchemaAST2.stringKeyword, defaultValue());
|
|
1071
1000
|
}
|
|
1072
1001
|
}, [
|
|
1073
1002
|
value3,
|
|
1074
|
-
defaultValue
|
|
1003
|
+
defaultValue,
|
|
1004
|
+
onValueChange,
|
|
1005
|
+
stablePath,
|
|
1006
|
+
jsonPath
|
|
1075
1007
|
]);
|
|
1076
1008
|
return value3;
|
|
1077
1009
|
};
|
|
@@ -1101,60 +1033,64 @@ var FormRoot = ({ children, schema, values, onSave, onCancel, ...props }) => {
|
|
|
1101
1033
|
onCancel,
|
|
1102
1034
|
...props
|
|
1103
1035
|
});
|
|
1104
|
-
return /* @__PURE__ */
|
|
1036
|
+
return /* @__PURE__ */ React4.createElement(FormContextProvider, {
|
|
1105
1037
|
form,
|
|
1106
1038
|
...props
|
|
1107
1039
|
}, children);
|
|
1108
1040
|
};
|
|
1109
1041
|
FormRoot.displayName = "Form.Root";
|
|
1110
|
-
var
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1042
|
+
var FORM_VIEWPORT_NAME = "Form.Viewport";
|
|
1043
|
+
var FormViewport = ({ children, classNames, margin = true, padding = true, thin = true, ...props }) => {
|
|
1044
|
+
return /* @__PURE__ */ React4.createElement(ScrollArea.Root, {
|
|
1045
|
+
orientation: "vertical",
|
|
1046
|
+
classNames,
|
|
1047
|
+
margin,
|
|
1048
|
+
padding,
|
|
1049
|
+
thin,
|
|
1050
|
+
...props
|
|
1051
|
+
}, /* @__PURE__ */ React4.createElement(ScrollArea.Viewport, null, children));
|
|
1119
1052
|
};
|
|
1120
|
-
FormViewport.displayName =
|
|
1053
|
+
FormViewport.displayName = FORM_VIEWPORT_NAME;
|
|
1054
|
+
var FORM_CONTENT_NAME = "Form.Content";
|
|
1121
1055
|
var FormContent = ({ classNames, children }) => {
|
|
1122
|
-
const { form, testId } = useFormContext(
|
|
1056
|
+
const { form, testId } = useFormContext(FORM_CONTENT_NAME);
|
|
1123
1057
|
const ref = useRef(null);
|
|
1124
1058
|
useKeyHandler(ref.current, form);
|
|
1125
|
-
return /* @__PURE__ */
|
|
1059
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
1126
1060
|
ref,
|
|
1127
1061
|
role: "form",
|
|
1128
|
-
className:
|
|
1062
|
+
className: mx2("w-full flex flex-col gap-form-padding", classNames),
|
|
1129
1063
|
"data-testid": testId
|
|
1130
1064
|
}, children);
|
|
1131
1065
|
};
|
|
1132
|
-
FormContent.displayName =
|
|
1133
|
-
var
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1066
|
+
FormContent.displayName = FORM_CONTENT_NAME;
|
|
1067
|
+
var FORM_FIELDSET_NAME2 = "Form.FieldSet";
|
|
1068
|
+
var FormFieldSet2 = (props) => {
|
|
1069
|
+
const { form, ...contextProps } = useFormContext(FORM_FIELDSET_NAME2);
|
|
1070
|
+
return /* @__PURE__ */ React4.createElement(FormFieldSet, {
|
|
1137
1071
|
schema: form.schema,
|
|
1072
|
+
...contextProps,
|
|
1138
1073
|
...props
|
|
1139
1074
|
});
|
|
1140
1075
|
};
|
|
1141
|
-
FormFieldSet2.displayName =
|
|
1076
|
+
FormFieldSet2.displayName = FORM_FIELDSET_NAME2;
|
|
1077
|
+
var FORM_ACTIONS_NAME = "Form.Actions";
|
|
1142
1078
|
var FormActions = ({ classNames }) => {
|
|
1143
|
-
const { t } =
|
|
1144
|
-
const { form: { canSave, onSave, onCancel }, readonly, layout } = useFormContext(
|
|
1079
|
+
const { t } = useTranslation2(translationKey);
|
|
1080
|
+
const { form: { canSave, onSave, onCancel }, readonly, layout } = useFormContext(FORM_ACTIONS_NAME);
|
|
1145
1081
|
if (readonly || layout === "static") {
|
|
1146
1082
|
return null;
|
|
1147
1083
|
}
|
|
1148
|
-
return /* @__PURE__ */
|
|
1084
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
1149
1085
|
role: "none",
|
|
1150
|
-
className:
|
|
1151
|
-
}, onCancel && /* @__PURE__ */
|
|
1086
|
+
className: mx2("grid grid-flow-col gap-2 auto-cols-fr py-form-padding", classNames)
|
|
1087
|
+
}, onCancel && /* @__PURE__ */ React4.createElement(IconButton, {
|
|
1152
1088
|
icon: "ph--x--regular",
|
|
1153
1089
|
iconEnd: true,
|
|
1154
1090
|
label: t("cancel button label"),
|
|
1155
1091
|
onClick: onCancel,
|
|
1156
1092
|
"data-testid": "cancel-button"
|
|
1157
|
-
}), onSave && /* @__PURE__ */
|
|
1093
|
+
}), onSave && /* @__PURE__ */ React4.createElement(IconButton, {
|
|
1158
1094
|
type: "submit",
|
|
1159
1095
|
variant: "primary",
|
|
1160
1096
|
disabled: !canSave,
|
|
@@ -1165,52 +1101,53 @@ var FormActions = ({ classNames }) => {
|
|
|
1165
1101
|
"data-testid": "save-button"
|
|
1166
1102
|
}));
|
|
1167
1103
|
};
|
|
1168
|
-
FormActions.displayName =
|
|
1169
|
-
var
|
|
1170
|
-
|
|
1171
|
-
const {
|
|
1104
|
+
FormActions.displayName = FORM_ACTIONS_NAME;
|
|
1105
|
+
var FORM_SUBMIT_NAME = "Form.Submit";
|
|
1106
|
+
var FormSubmit = ({ classNames, label, icon, disabled }) => {
|
|
1107
|
+
const { t } = useTranslation2(translationKey);
|
|
1108
|
+
const { form: { canSave, onSave }, readonly, layout } = useFormContext(FORM_SUBMIT_NAME);
|
|
1172
1109
|
if (readonly || layout === "static") {
|
|
1173
1110
|
return null;
|
|
1174
1111
|
}
|
|
1175
|
-
return /* @__PURE__ */
|
|
1112
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
1176
1113
|
role: "none",
|
|
1177
|
-
className:
|
|
1178
|
-
}, /* @__PURE__ */
|
|
1179
|
-
classNames: "
|
|
1114
|
+
className: mx2("flex w-full pt-form-padding", classNames)
|
|
1115
|
+
}, /* @__PURE__ */ React4.createElement(IconButton, {
|
|
1116
|
+
classNames: "w-full",
|
|
1180
1117
|
type: "submit",
|
|
1181
1118
|
variant: "primary",
|
|
1182
|
-
disabled: !canSave,
|
|
1119
|
+
disabled: disabled ?? !canSave,
|
|
1183
1120
|
icon: icon ?? "ph--check--regular",
|
|
1184
1121
|
label: label ?? t("save button label"),
|
|
1185
1122
|
onClick: onSave,
|
|
1186
1123
|
"data-testid": "save-button"
|
|
1187
1124
|
}));
|
|
1188
1125
|
};
|
|
1189
|
-
FormSubmit.displayName =
|
|
1126
|
+
FormSubmit.displayName = FORM_SUBMIT_NAME;
|
|
1190
1127
|
var Form = {
|
|
1191
1128
|
Root: FormRoot,
|
|
1192
1129
|
Viewport: FormViewport,
|
|
1193
1130
|
Content: FormContent,
|
|
1194
1131
|
FieldSet: FormFieldSet2,
|
|
1132
|
+
Label: FormFieldLabel,
|
|
1195
1133
|
Actions: FormActions,
|
|
1196
|
-
Submit: FormSubmit
|
|
1197
|
-
Label: FormFieldLabel
|
|
1134
|
+
Submit: FormSubmit
|
|
1198
1135
|
};
|
|
1199
1136
|
|
|
1200
1137
|
// src/components/Form/fields/ArrayField.tsx
|
|
1201
1138
|
var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps, ...props }) => {
|
|
1202
|
-
const { t } =
|
|
1139
|
+
const { t } = useTranslation3(translationKey);
|
|
1203
1140
|
const elementType = getArrayElementType2(type);
|
|
1204
1141
|
const { onValueChange } = inputProps;
|
|
1205
1142
|
const values = useFormValues(ArrayField.displayName, path, () => []);
|
|
1206
1143
|
const getDefaultObjectValue = (typeNode) => {
|
|
1207
1144
|
const baseNode = findNode2(typeNode, isDiscriminatedUnion2);
|
|
1208
|
-
const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, {}) : findNode2(typeNode,
|
|
1145
|
+
const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, {}) : findNode2(typeNode, SchemaAST3.isTypeLiteral);
|
|
1209
1146
|
if (!typeLiteral) {
|
|
1210
1147
|
return {};
|
|
1211
1148
|
}
|
|
1212
1149
|
return Object.fromEntries(getFormProperties(typeLiteral).map((prop) => {
|
|
1213
|
-
const defaultValue =
|
|
1150
|
+
const defaultValue = SchemaAST3.getDefaultAnnotation(prop.type).pipe((annotation) => Option3.getOrUndefined(annotation));
|
|
1214
1151
|
return [
|
|
1215
1152
|
prop.name,
|
|
1216
1153
|
defaultValue
|
|
@@ -1239,19 +1176,19 @@ var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps,
|
|
|
1239
1176
|
if (!elementType || (readonly || layout === "static") && values && values.length < 1) {
|
|
1240
1177
|
return null;
|
|
1241
1178
|
}
|
|
1242
|
-
return /* @__PURE__ */
|
|
1179
|
+
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, (layout !== "static" || values && values.length > 0) && /* @__PURE__ */ React5.createElement(FormFieldLabel, {
|
|
1243
1180
|
readonly,
|
|
1244
1181
|
label,
|
|
1245
1182
|
asChild: true
|
|
1246
|
-
}), /* @__PURE__ */
|
|
1183
|
+
}), /* @__PURE__ */ React5.createElement("div", {
|
|
1247
1184
|
role: "none",
|
|
1248
1185
|
className: "flex flex-col gap-2"
|
|
1249
1186
|
}, values?.map((_, index) => {
|
|
1250
|
-
return /* @__PURE__ */
|
|
1187
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
1251
1188
|
role: "none",
|
|
1252
1189
|
key: index,
|
|
1253
1190
|
className: "grid grid-cols-[1fr_min-content] gap-2 last:mb-3"
|
|
1254
|
-
}, /* @__PURE__ */
|
|
1191
|
+
}, /* @__PURE__ */ React5.createElement(FormField, {
|
|
1255
1192
|
autoFocus: index === values.length - 1,
|
|
1256
1193
|
type: elementType,
|
|
1257
1194
|
path: [
|
|
@@ -1261,21 +1198,21 @@ var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps,
|
|
|
1261
1198
|
readonly: readonly || layout === "static",
|
|
1262
1199
|
layout: "inline",
|
|
1263
1200
|
...props
|
|
1264
|
-
}), !readonly && layout !== "static" && /* @__PURE__ */
|
|
1201
|
+
}), !readonly && layout !== "static" && /* @__PURE__ */ React5.createElement("div", {
|
|
1265
1202
|
role: "none",
|
|
1266
|
-
className: "flex flex-col
|
|
1267
|
-
}, /* @__PURE__ */
|
|
1203
|
+
className: "flex flex-col h-full justify-end"
|
|
1204
|
+
}, /* @__PURE__ */ React5.createElement("div", {
|
|
1268
1205
|
role: "none",
|
|
1269
|
-
className: "flex items-center
|
|
1270
|
-
}, /* @__PURE__ */
|
|
1206
|
+
className: "flex items-center h-[2rem]"
|
|
1207
|
+
}, /* @__PURE__ */ React5.createElement(IconButton2, {
|
|
1271
1208
|
icon: "ph--x--regular",
|
|
1272
1209
|
iconOnly: true,
|
|
1273
1210
|
label: t("button remove"),
|
|
1274
1211
|
onClick: () => handleDelete(index),
|
|
1275
1212
|
classNames: "self-center"
|
|
1276
1213
|
}))));
|
|
1277
|
-
})), !readonly && layout !== "static" && /* @__PURE__ */
|
|
1278
|
-
classNames: "flex
|
|
1214
|
+
})), !readonly && layout !== "static" && /* @__PURE__ */ React5.createElement(IconButton2, {
|
|
1215
|
+
classNames: "flex w-full",
|
|
1279
1216
|
icon: "ph--plus--regular",
|
|
1280
1217
|
label: t("add field"),
|
|
1281
1218
|
onClick: handleAdd
|
|
@@ -1293,6 +1230,9 @@ var getDefaultValue = (ast) => {
|
|
|
1293
1230
|
case "BooleanKeyword": {
|
|
1294
1231
|
return false;
|
|
1295
1232
|
}
|
|
1233
|
+
case "Suspend": {
|
|
1234
|
+
return getDefaultValue(ast.f());
|
|
1235
|
+
}
|
|
1296
1236
|
default: {
|
|
1297
1237
|
if (ast && isNestedType2(ast)) {
|
|
1298
1238
|
return {};
|
|
@@ -1304,17 +1244,17 @@ var getDefaultValue = (ast) => {
|
|
|
1304
1244
|
};
|
|
1305
1245
|
|
|
1306
1246
|
// src/components/Form/fields/BooleanField.tsx
|
|
1307
|
-
import
|
|
1308
|
-
import { Input as
|
|
1247
|
+
import React6, { useCallback as useCallback4 } from "react";
|
|
1248
|
+
import { Input as Input2 } from "@dxos/react-ui";
|
|
1309
1249
|
var BooleanField = ({ type, readonly, onValueChange, ...props }) => {
|
|
1310
1250
|
const handleChange = useCallback4((value3) => onValueChange?.(type, value3), [
|
|
1311
1251
|
type,
|
|
1312
1252
|
onValueChange
|
|
1313
1253
|
]);
|
|
1314
|
-
return /* @__PURE__ */
|
|
1254
|
+
return /* @__PURE__ */ React6.createElement(FormFieldWrapper, {
|
|
1315
1255
|
readonly,
|
|
1316
1256
|
...props
|
|
1317
|
-
}, ({ value: value3 }) => /* @__PURE__ */
|
|
1257
|
+
}, ({ value: value3 }) => /* @__PURE__ */ React6.createElement(Input2.Switch, {
|
|
1318
1258
|
disabled: !!readonly,
|
|
1319
1259
|
checked: value3,
|
|
1320
1260
|
onCheckedChange: handleChange
|
|
@@ -1322,12 +1262,12 @@ var BooleanField = ({ type, readonly, onValueChange, ...props }) => {
|
|
|
1322
1262
|
};
|
|
1323
1263
|
|
|
1324
1264
|
// src/components/Form/fields/GeoPointField.tsx
|
|
1325
|
-
import
|
|
1265
|
+
import React7, { useCallback as useCallback5, useEffect as useEffect4, useMemo as useMemo5, useState as useState2 } from "react";
|
|
1326
1266
|
import { GeoLocation as GeoLocation3 } from "@dxos/echo/internal";
|
|
1327
|
-
import { Input as
|
|
1267
|
+
import { Input as Input3, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
1328
1268
|
import { safeParseFloat } from "@dxos/util";
|
|
1329
1269
|
var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onValueChange, onBlur }) => {
|
|
1330
|
-
const { t } =
|
|
1270
|
+
const { t } = useTranslation4(translationKey);
|
|
1331
1271
|
const { status, error } = getStatus();
|
|
1332
1272
|
const geoPoint = useMemo5(() => getValue() ?? [
|
|
1333
1273
|
0,
|
|
@@ -1373,17 +1313,17 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
|
|
|
1373
1313
|
if ((readonly || layout === "static") && !value3?.latitude && !value3?.longitude) {
|
|
1374
1314
|
return null;
|
|
1375
1315
|
}
|
|
1376
|
-
return /* @__PURE__ */
|
|
1316
|
+
return /* @__PURE__ */ React7.createElement(Input3.Root, {
|
|
1377
1317
|
validationValence: status
|
|
1378
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
1318
|
+
}, layout !== "inline" && /* @__PURE__ */ React7.createElement(FormFieldLabel, {
|
|
1379
1319
|
error,
|
|
1380
1320
|
readonly,
|
|
1381
1321
|
label,
|
|
1382
1322
|
asChild: true
|
|
1383
|
-
}), layout === "static" ? /* @__PURE__ */
|
|
1323
|
+
}), layout === "static" ? /* @__PURE__ */ React7.createElement(LatLng, value3) : /* @__PURE__ */ React7.createElement("div", {
|
|
1384
1324
|
role: "none",
|
|
1385
1325
|
className: "grid grid-cols-2 gap-2"
|
|
1386
|
-
}, /* @__PURE__ */
|
|
1326
|
+
}, /* @__PURE__ */ React7.createElement("div", null, /* @__PURE__ */ React7.createElement(Input3.Root, null, layout !== "inline" && /* @__PURE__ */ React7.createElement(Input3.Label, null, t("latitude label")), /* @__PURE__ */ React7.createElement(Input3.TextInput, {
|
|
1387
1327
|
type: "number",
|
|
1388
1328
|
step: "0.00001",
|
|
1389
1329
|
min: "-90",
|
|
@@ -1393,7 +1333,7 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
|
|
|
1393
1333
|
value: latitudeText ?? "",
|
|
1394
1334
|
onChange: handleChange("latitude", setLatitudeText),
|
|
1395
1335
|
onBlur
|
|
1396
|
-
}))), /* @__PURE__ */
|
|
1336
|
+
}))), /* @__PURE__ */ React7.createElement("div", null, /* @__PURE__ */ React7.createElement(Input3.Root, null, layout !== "inline" && /* @__PURE__ */ React7.createElement(Input3.Label, null, t("longitude label")), /* @__PURE__ */ React7.createElement(Input3.TextInput, {
|
|
1397
1337
|
type: "number",
|
|
1398
1338
|
step: "0.00001",
|
|
1399
1339
|
min: "-180",
|
|
@@ -1408,18 +1348,18 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
|
|
|
1408
1348
|
var LatLng = ({ latitude = 0, longitude = 0 }) => {
|
|
1409
1349
|
const latHem = latitude >= 0 ? "N" : "S";
|
|
1410
1350
|
const lngHem = longitude >= 0 ? "E" : "W";
|
|
1411
|
-
return /* @__PURE__ */
|
|
1351
|
+
return /* @__PURE__ */ React7.createElement("span", {
|
|
1412
1352
|
className: "inline-flex items-center gap-1"
|
|
1413
|
-
}, /* @__PURE__ */
|
|
1353
|
+
}, /* @__PURE__ */ React7.createElement("span", null, /* @__PURE__ */ React7.createElement("span", null, Math.abs(latitude).toFixed(5)), /* @__PURE__ */ React7.createElement("span", {
|
|
1414
1354
|
className: "text-subdued"
|
|
1415
|
-
}, "\xB0", latHem)), /* @__PURE__ */
|
|
1355
|
+
}, "\xB0", latHem)), /* @__PURE__ */ React7.createElement("span", null, /* @__PURE__ */ React7.createElement("span", null, Math.abs(longitude).toFixed(5)), /* @__PURE__ */ React7.createElement("span", {
|
|
1416
1356
|
className: "text-subdued"
|
|
1417
1357
|
}, "\xB0", lngHem)));
|
|
1418
1358
|
};
|
|
1419
1359
|
|
|
1420
1360
|
// src/components/Form/fields/MarkdownField.tsx
|
|
1421
|
-
import
|
|
1422
|
-
import { Input as
|
|
1361
|
+
import React8, { useCallback as useCallback6, useEffect as useEffect5, useRef as useRef2 } from "react";
|
|
1362
|
+
import { Input as Input4 } from "@dxos/react-ui";
|
|
1423
1363
|
var MarkdownField = ({ type, readonly, label, placeholder, layout, getStatus, getValue, onValueChange, onBlur }) => {
|
|
1424
1364
|
const { status, error } = getStatus();
|
|
1425
1365
|
const textareaRef = useRef2(null);
|
|
@@ -1449,40 +1389,40 @@ var MarkdownField = ({ type, readonly, label, placeholder, layout, getStatus, ge
|
|
|
1449
1389
|
if ((readonly || layout === "static") && !value3) {
|
|
1450
1390
|
return null;
|
|
1451
1391
|
}
|
|
1452
|
-
return /* @__PURE__ */
|
|
1392
|
+
return /* @__PURE__ */ React8.createElement(Input4.Root, {
|
|
1453
1393
|
validationValence: status
|
|
1454
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
1394
|
+
}, layout !== "inline" && /* @__PURE__ */ React8.createElement(FormFieldLabel, {
|
|
1455
1395
|
error,
|
|
1456
1396
|
readonly,
|
|
1457
1397
|
label
|
|
1458
|
-
}), layout === "static" ? /* @__PURE__ */
|
|
1398
|
+
}), layout === "static" ? /* @__PURE__ */ React8.createElement("p", null, value3) : /* @__PURE__ */ React8.createElement(Input4.TextArea, {
|
|
1459
1399
|
ref: textareaRef,
|
|
1460
1400
|
disabled: !!readonly,
|
|
1461
1401
|
placeholder,
|
|
1462
1402
|
value: value3 ?? "",
|
|
1463
|
-
classNames: "min-
|
|
1403
|
+
classNames: "min-h-auto max-h-40 overflow-auto",
|
|
1464
1404
|
onChange: handleChange,
|
|
1465
1405
|
onBlur,
|
|
1466
1406
|
style: {
|
|
1467
1407
|
resize: "none"
|
|
1468
1408
|
},
|
|
1469
1409
|
spellCheck: false
|
|
1470
|
-
}), layout === "full" && /* @__PURE__ */
|
|
1410
|
+
}), layout === "full" && /* @__PURE__ */ React8.createElement(Input4.Validation, null, error));
|
|
1471
1411
|
};
|
|
1472
1412
|
|
|
1473
1413
|
// src/components/Form/fields/NumberField.tsx
|
|
1474
|
-
import
|
|
1475
|
-
import { Input as
|
|
1414
|
+
import React9, { useCallback as useCallback7 } from "react";
|
|
1415
|
+
import { Input as Input5 } from "@dxos/react-ui";
|
|
1476
1416
|
import { safeParseFloat as safeParseFloat2 } from "@dxos/util";
|
|
1477
1417
|
var NumberField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props }) => {
|
|
1478
1418
|
const handleChange = useCallback7((event) => onValueChange(type, safeParseFloat2(event.target.value) || 0), [
|
|
1479
1419
|
type,
|
|
1480
1420
|
onValueChange
|
|
1481
1421
|
]);
|
|
1482
|
-
return /* @__PURE__ */
|
|
1422
|
+
return /* @__PURE__ */ React9.createElement(FormFieldWrapper, {
|
|
1483
1423
|
readonly,
|
|
1484
1424
|
...props
|
|
1485
|
-
}, ({ value: value3 = "" }) => /* @__PURE__ */
|
|
1425
|
+
}, ({ value: value3 = "" }) => /* @__PURE__ */ React9.createElement(Input5.TextInput, {
|
|
1486
1426
|
type: "number",
|
|
1487
1427
|
disabled: !!readonly,
|
|
1488
1428
|
placeholder,
|
|
@@ -1494,24 +1434,25 @@ var NumberField = ({ type, readonly, placeholder, onValueChange, onBlur, ...prop
|
|
|
1494
1434
|
|
|
1495
1435
|
// src/components/Form/fields/RefField.tsx
|
|
1496
1436
|
import "@dxos/lit-ui/dx-tag-picker.pcss";
|
|
1497
|
-
import
|
|
1498
|
-
import { Entity, Filter, Ref as Ref2 } from "@dxos/echo";
|
|
1437
|
+
import React11, { useCallback as useCallback9, useMemo as useMemo6 } from "react";
|
|
1438
|
+
import { Entity, Filter, Obj, Ref as Ref2, Type } from "@dxos/echo";
|
|
1499
1439
|
import { ReferenceAnnotationId } from "@dxos/echo/internal";
|
|
1500
1440
|
import { useQuery, useSchema as useSchema$ } from "@dxos/echo-react";
|
|
1501
1441
|
import { findAnnotation } from "@dxos/effect";
|
|
1502
1442
|
import { DXN } from "@dxos/keys";
|
|
1503
1443
|
import { DxAnchor } from "@dxos/lit-ui/react";
|
|
1504
|
-
import { Button
|
|
1505
|
-
import {
|
|
1444
|
+
import { Button, Icon as Icon2, Input as Input6, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
1445
|
+
import { ParentLabelAnnotationId } from "@dxos/schema";
|
|
1446
|
+
import { mx as mx3 } from "@dxos/ui-theme";
|
|
1506
1447
|
|
|
1507
1448
|
// src/components/ObjectPicker/ObjectPicker.tsx
|
|
1508
|
-
import
|
|
1509
|
-
import { Popover, useTranslation as
|
|
1449
|
+
import React10, { forwardRef as forwardRef2, useCallback as useCallback8, useState as useState3 } from "react";
|
|
1450
|
+
import { Popover, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
1510
1451
|
import { Combobox, useSearchListInput, useSearchListResults } from "@dxos/react-ui-searchlist";
|
|
1511
1452
|
var CreateItem = ({ createOptionLabel, createOptionIcon, onCreateItemSelect }) => {
|
|
1512
|
-
const { t } =
|
|
1453
|
+
const { t } = useTranslation5(translationKey);
|
|
1513
1454
|
const { query } = useSearchListInput();
|
|
1514
|
-
return /* @__PURE__ */
|
|
1455
|
+
return /* @__PURE__ */ React10.createElement(Combobox.Item, {
|
|
1515
1456
|
value: "__create__",
|
|
1516
1457
|
label: t(createOptionLabel[0], {
|
|
1517
1458
|
ns: createOptionLabel[1].ns,
|
|
@@ -1526,7 +1467,7 @@ var CreateItem = ({ createOptionLabel, createOptionIcon, onCreateItemSelect }) =
|
|
|
1526
1467
|
});
|
|
1527
1468
|
};
|
|
1528
1469
|
var ObjectPickerContent = /* @__PURE__ */ forwardRef2(({ options, selectedIds, createSchema, createOptionLabel, createOptionIcon, createInitialValuePath, onSelect, onCreate, ...props }, ref) => {
|
|
1529
|
-
const { t } =
|
|
1470
|
+
const { t } = useTranslation5(translationKey);
|
|
1530
1471
|
const [showForm, setShowForm] = useState3(false);
|
|
1531
1472
|
const [formInitialValue, setFormInitialValue] = useState3("");
|
|
1532
1473
|
const { results, handleSearch } = useSearchListResults({
|
|
@@ -1555,12 +1496,12 @@ var ObjectPickerContent = /* @__PURE__ */ forwardRef2(({ options, selectedIds, c
|
|
|
1555
1496
|
}, [
|
|
1556
1497
|
createSchema
|
|
1557
1498
|
]);
|
|
1558
|
-
return /* @__PURE__ */
|
|
1499
|
+
return /* @__PURE__ */ React10.createElement(Combobox.Content, {
|
|
1559
1500
|
...props,
|
|
1560
1501
|
ref,
|
|
1561
1502
|
onSearch: handleSearch,
|
|
1562
1503
|
onKeyDownCapture: handleKeyDown
|
|
1563
|
-
}, showForm && createSchema ? /* @__PURE__ */
|
|
1504
|
+
}, showForm && createSchema ? /* @__PURE__ */ React10.createElement(Popover.Viewport, null, /* @__PURE__ */ React10.createElement(Form.Root, {
|
|
1564
1505
|
testId: "create-referenced-object-form",
|
|
1565
1506
|
schema: createSchema,
|
|
1566
1507
|
values: createInitialValuePath ? {
|
|
@@ -1568,24 +1509,24 @@ var ObjectPickerContent = /* @__PURE__ */ forwardRef2(({ options, selectedIds, c
|
|
|
1568
1509
|
} : {},
|
|
1569
1510
|
onSave: handleFormSave,
|
|
1570
1511
|
onCancel: handleFormCancel
|
|
1571
|
-
}, /* @__PURE__ */
|
|
1512
|
+
}, /* @__PURE__ */ React10.createElement(Form.Viewport, null, /* @__PURE__ */ React10.createElement(Form.Content, null, /* @__PURE__ */ React10.createElement(Form.FieldSet, null), /* @__PURE__ */ React10.createElement(Form.Actions, null))))) : /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(Combobox.Input, {
|
|
1572
1513
|
placeholder: t("ref field combobox input placeholder"),
|
|
1573
1514
|
autoFocus: true
|
|
1574
|
-
}), /* @__PURE__ */
|
|
1515
|
+
}), /* @__PURE__ */ React10.createElement(Combobox.List, null, results.map((option) => /* @__PURE__ */ React10.createElement(Combobox.Item, {
|
|
1575
1516
|
key: option.id,
|
|
1576
1517
|
value: option.id,
|
|
1577
1518
|
label: option.label,
|
|
1578
1519
|
checked: selectedIds?.includes(option.id),
|
|
1579
1520
|
onSelect: () => onSelect(option.id),
|
|
1580
1521
|
classNames: "flex items-center gap-2"
|
|
1581
|
-
})), createOptionLabel && createOptionIcon && createSchema && onCreate && /* @__PURE__ */
|
|
1522
|
+
})), createOptionLabel && createOptionIcon && createSchema && onCreate && /* @__PURE__ */ React10.createElement(CreateItem, {
|
|
1582
1523
|
createOptionLabel,
|
|
1583
1524
|
createOptionIcon,
|
|
1584
1525
|
onCreateItemSelect: (query) => {
|
|
1585
1526
|
setFormInitialValue(query);
|
|
1586
1527
|
setShowForm(true);
|
|
1587
1528
|
}
|
|
1588
|
-
}))), /* @__PURE__ */
|
|
1529
|
+
}))), /* @__PURE__ */ React10.createElement(Combobox.Arrow, null));
|
|
1589
1530
|
});
|
|
1590
1531
|
ObjectPickerContent.displayName = "ObjectPickerContent";
|
|
1591
1532
|
var ObjectPicker = {
|
|
@@ -1600,26 +1541,33 @@ var ObjectPicker = {
|
|
|
1600
1541
|
var isRefSnapshot = (val) => {
|
|
1601
1542
|
return typeof val === "object" && typeof val?.["/"] === "string";
|
|
1602
1543
|
};
|
|
1603
|
-
var defaultGetOptions = (results) => results.map((result) => {
|
|
1544
|
+
var defaultGetOptions = (results, { parentLabel } = {}) => results.map((result) => {
|
|
1604
1545
|
const id = Entity.getDXN(result).toString();
|
|
1605
|
-
const
|
|
1546
|
+
const parent = parentLabel ? Obj.getParent(result) : void 0;
|
|
1547
|
+
const label = parent ? Entity.getLabel(parent) : Entity.getLabel(result);
|
|
1606
1548
|
return {
|
|
1607
1549
|
id,
|
|
1608
1550
|
label: label ?? id
|
|
1609
1551
|
};
|
|
1610
1552
|
});
|
|
1611
|
-
var defaultResultsHook = (db, typename) => useQuery(db, typename ? Filter.typename(typename) : Filter.nothing());
|
|
1553
|
+
var defaultResultsHook = (db, typename) => useQuery(db, typename ? typename === Type.getTypename(Obj.Unknown) ? Filter.everything() : Filter.typename(typename) : Filter.nothing());
|
|
1612
1554
|
var RefField = (props) => {
|
|
1613
1555
|
const { type, readonly, label, placeholder, layout, getStatus, getValue, createOptionLabel, createOptionIcon, createInitialValuePath, db, resultsHook: useResults = defaultResultsHook, schemaHook: useSchema = useSchema$, getOptions: getOptions2 = defaultGetOptions, onCreate, onValueChange } = props;
|
|
1614
|
-
const { t } =
|
|
1556
|
+
const { t } = useTranslation6(translationKey);
|
|
1615
1557
|
const { status, error } = getStatus();
|
|
1616
1558
|
const typename = useMemo6(() => type ? findAnnotation(type, ReferenceAnnotationId)?.typename : void 0, [
|
|
1617
1559
|
type
|
|
1618
1560
|
]);
|
|
1619
1561
|
const results = useResults(db, typename);
|
|
1620
|
-
const options = useMemo6(() =>
|
|
1562
|
+
const options = useMemo6(() => {
|
|
1563
|
+
const parentLabel = type ? findAnnotation(type, ParentLabelAnnotationId) === true : false;
|
|
1564
|
+
return getOptions2(results, {
|
|
1565
|
+
parentLabel
|
|
1566
|
+
});
|
|
1567
|
+
}, [
|
|
1621
1568
|
results,
|
|
1622
|
-
getOptions2
|
|
1569
|
+
getOptions2,
|
|
1570
|
+
type
|
|
1623
1571
|
]);
|
|
1624
1572
|
const handleGetValue = useCallback9(() => {
|
|
1625
1573
|
const formValue = getValue();
|
|
@@ -1676,41 +1624,41 @@ var RefField = (props) => {
|
|
|
1676
1624
|
if (!typename || (readonly || layout === "static") && !item) {
|
|
1677
1625
|
return null;
|
|
1678
1626
|
}
|
|
1679
|
-
return /* @__PURE__ */
|
|
1627
|
+
return /* @__PURE__ */ React11.createElement(Input6.Root, {
|
|
1680
1628
|
validationValence: status
|
|
1681
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
1629
|
+
}, layout !== "inline" && /* @__PURE__ */ React11.createElement(FormFieldLabel, {
|
|
1682
1630
|
error,
|
|
1683
1631
|
readonly,
|
|
1684
1632
|
label
|
|
1685
|
-
}), /* @__PURE__ */
|
|
1686
|
-
className:
|
|
1687
|
-
}, t("empty readonly ref field label")) : /* @__PURE__ */
|
|
1633
|
+
}), /* @__PURE__ */ React11.createElement("div", null, readonly ? !item ? /* @__PURE__ */ React11.createElement("p", {
|
|
1634
|
+
className: mx3("text-description", "mb-2")
|
|
1635
|
+
}, t("empty readonly ref field label")) : /* @__PURE__ */ React11.createElement(DxAnchor, {
|
|
1688
1636
|
key: item.id,
|
|
1689
|
-
|
|
1690
|
-
rootclassname: "
|
|
1691
|
-
}, item.label) : /* @__PURE__ */
|
|
1637
|
+
dxn: item.id,
|
|
1638
|
+
rootclassname: "me-1"
|
|
1639
|
+
}, item.label) : /* @__PURE__ */ React11.createElement(ObjectPicker.Root, null, /* @__PURE__ */ React11.createElement(ObjectPicker.Trigger, {
|
|
1692
1640
|
asChild: true,
|
|
1693
1641
|
classNames: "p-0"
|
|
1694
|
-
}, item ? /* @__PURE__ */
|
|
1695
|
-
className: "flex gap-2
|
|
1696
|
-
}, /* @__PURE__ */
|
|
1642
|
+
}, item ? /* @__PURE__ */ React11.createElement("div", {
|
|
1643
|
+
className: "flex gap-2 w-full"
|
|
1644
|
+
}, /* @__PURE__ */ React11.createElement(Input6.Root, {
|
|
1697
1645
|
key: item.id
|
|
1698
|
-
}, /* @__PURE__ */
|
|
1646
|
+
}, /* @__PURE__ */ React11.createElement(Input6.TextInput, {
|
|
1699
1647
|
value: item.label,
|
|
1700
1648
|
readOnly: true,
|
|
1701
|
-
classNames: "
|
|
1702
|
-
}))) : /* @__PURE__ */
|
|
1703
|
-
classNames: "
|
|
1704
|
-
}, /* @__PURE__ */
|
|
1649
|
+
classNames: "w-full"
|
|
1650
|
+
}))) : /* @__PURE__ */ React11.createElement(Button, {
|
|
1651
|
+
classNames: "w-full text-start gap-2"
|
|
1652
|
+
}, /* @__PURE__ */ React11.createElement("div", {
|
|
1705
1653
|
role: "none",
|
|
1706
1654
|
className: "grow overflow-hidden"
|
|
1707
|
-
}, /* @__PURE__ */
|
|
1655
|
+
}, /* @__PURE__ */ React11.createElement("span", {
|
|
1708
1656
|
className: "flex truncate text-description"
|
|
1709
|
-
}, placeholder ?? t("ref field placeholder"))), /* @__PURE__ */
|
|
1657
|
+
}, placeholder ?? t("ref field placeholder"))), /* @__PURE__ */ React11.createElement(Icon2, {
|
|
1710
1658
|
size: 3,
|
|
1711
1659
|
icon: "ph--caret-down--bold"
|
|
1712
|
-
}))), /* @__PURE__ */
|
|
1713
|
-
classNames: "
|
|
1660
|
+
}))), /* @__PURE__ */ React11.createElement(ObjectPicker.Portal, null, /* @__PURE__ */ React11.createElement(ObjectPicker.Content, {
|
|
1661
|
+
classNames: "dx-card-popover-width",
|
|
1714
1662
|
options,
|
|
1715
1663
|
selectedIds,
|
|
1716
1664
|
createSchema: createSchema && omitId(createSchema),
|
|
@@ -1719,12 +1667,12 @@ var RefField = (props) => {
|
|
|
1719
1667
|
createInitialValuePath,
|
|
1720
1668
|
onCreate: handleCreate,
|
|
1721
1669
|
onSelect: handleSelect
|
|
1722
|
-
})))), layout === "full" && /* @__PURE__ */
|
|
1670
|
+
})))), layout === "full" && /* @__PURE__ */ React11.createElement(Input6.DescriptionAndValidation, null, error));
|
|
1723
1671
|
};
|
|
1724
1672
|
|
|
1725
1673
|
// src/components/Form/fields/SelectField.tsx
|
|
1726
|
-
import
|
|
1727
|
-
import { Input as
|
|
1674
|
+
import React12, { useCallback as useCallback10 } from "react";
|
|
1675
|
+
import { Input as Input7, Select } from "@dxos/react-ui";
|
|
1728
1676
|
var SelectField = ({ type, readonly, label, layout, placeholder, options, getStatus, getValue, onValueChange }) => {
|
|
1729
1677
|
const { status, error } = getStatus();
|
|
1730
1678
|
const value3 = getValue();
|
|
@@ -1735,37 +1683,37 @@ var SelectField = ({ type, readonly, label, layout, placeholder, options, getSta
|
|
|
1735
1683
|
if ((readonly || layout === "static") && value3 == null) {
|
|
1736
1684
|
return null;
|
|
1737
1685
|
}
|
|
1738
|
-
return /* @__PURE__ */
|
|
1686
|
+
return /* @__PURE__ */ React12.createElement(Input7.Root, {
|
|
1739
1687
|
validationValence: status
|
|
1740
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
1688
|
+
}, layout !== "inline" && /* @__PURE__ */ React12.createElement(FormFieldLabel, {
|
|
1741
1689
|
error,
|
|
1742
1690
|
readonly,
|
|
1743
1691
|
label
|
|
1744
|
-
}), layout === "static" ? /* @__PURE__ */
|
|
1692
|
+
}), layout === "static" ? /* @__PURE__ */ React12.createElement("p", null, options?.find(({ value: optionValue }) => optionValue === value3)?.label ?? String(value3)) : /* @__PURE__ */ React12.createElement(Select.Root, {
|
|
1745
1693
|
value: value3,
|
|
1746
1694
|
onValueChange: handleValueChange
|
|
1747
|
-
}, /* @__PURE__ */
|
|
1748
|
-
classNames: "
|
|
1695
|
+
}, /* @__PURE__ */ React12.createElement(Select.TriggerButton, {
|
|
1696
|
+
classNames: "w-full",
|
|
1749
1697
|
disabled: !!readonly,
|
|
1750
1698
|
placeholder
|
|
1751
|
-
}), /* @__PURE__ */
|
|
1699
|
+
}), /* @__PURE__ */ React12.createElement(Select.Portal, null, /* @__PURE__ */ React12.createElement(Select.Content, null, /* @__PURE__ */ React12.createElement(Select.Viewport, null, options?.map(({ value: value4, label: label2 }) => (
|
|
1752
1700
|
// NOTE: Numeric values are converted to and from strings.
|
|
1753
|
-
/* @__PURE__ */
|
|
1701
|
+
/* @__PURE__ */ React12.createElement(Select.Option, {
|
|
1754
1702
|
key: String(value4),
|
|
1755
1703
|
value: String(value4)
|
|
1756
1704
|
}, label2 ?? String(value4))
|
|
1757
|
-
))), /* @__PURE__ */
|
|
1705
|
+
))), /* @__PURE__ */ React12.createElement(Select.Arrow, null)))), layout === "full" && /* @__PURE__ */ React12.createElement(Input7.DescriptionAndValidation, null, error));
|
|
1758
1706
|
};
|
|
1759
1707
|
|
|
1760
1708
|
// src/components/Form/fields/SelectOptionField.tsx
|
|
1761
|
-
import
|
|
1709
|
+
import React13, { useCallback as useCallback11, useEffect as useEffect6, useRef as useRef3, useState as useState4 } from "react";
|
|
1762
1710
|
import { PublicKey } from "@dxos/keys";
|
|
1763
|
-
import { IconButton as IconButton3, Input as
|
|
1711
|
+
import { IconButton as IconButton3, Input as Input8, Tag, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
1764
1712
|
import { List } from "@dxos/react-ui-list";
|
|
1765
1713
|
import { HuePicker } from "@dxos/react-ui-pickers";
|
|
1766
1714
|
import { hues, osTranslations, subtleHover } from "@dxos/ui-theme";
|
|
1767
1715
|
var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueChange }) => {
|
|
1768
|
-
const { t } =
|
|
1716
|
+
const { t } = useTranslation7(translationKey);
|
|
1769
1717
|
const { status, error } = getStatus();
|
|
1770
1718
|
const [selected, setSelectedId] = useState4(null);
|
|
1771
1719
|
const [isNewOption, setIsNewOption] = useState4(false);
|
|
@@ -1871,42 +1819,42 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
1871
1819
|
selected,
|
|
1872
1820
|
isNewOption
|
|
1873
1821
|
]);
|
|
1874
|
-
return /* @__PURE__ */
|
|
1822
|
+
return /* @__PURE__ */ React13.createElement(Input8.Root, {
|
|
1875
1823
|
validationValence: status
|
|
1876
|
-
}, /* @__PURE__ */
|
|
1824
|
+
}, /* @__PURE__ */ React13.createElement(FormFieldLabel, {
|
|
1877
1825
|
error,
|
|
1878
1826
|
readonly,
|
|
1879
1827
|
label
|
|
1880
|
-
}), /* @__PURE__ */
|
|
1828
|
+
}), /* @__PURE__ */ React13.createElement("div", {
|
|
1881
1829
|
role: "none"
|
|
1882
|
-
}, options && /* @__PURE__ */
|
|
1830
|
+
}, options && /* @__PURE__ */ React13.createElement(List.Root, {
|
|
1883
1831
|
items: options,
|
|
1884
1832
|
isItem: (_item) => true,
|
|
1885
1833
|
onMove: readonly ? void 0 : handleMove,
|
|
1886
1834
|
readonly: !!readonly
|
|
1887
|
-
}, ({ items }) => /* @__PURE__ */
|
|
1835
|
+
}, ({ items }) => /* @__PURE__ */ React13.createElement("div", {
|
|
1888
1836
|
role: "list",
|
|
1889
|
-
className: "
|
|
1890
|
-
}, items?.map((item) => /* @__PURE__ */
|
|
1837
|
+
className: "w-full overflow-auto"
|
|
1838
|
+
}, items?.map((item) => /* @__PURE__ */ React13.createElement("div", {
|
|
1891
1839
|
key: item.id
|
|
1892
|
-
}, /* @__PURE__ */
|
|
1840
|
+
}, /* @__PURE__ */ React13.createElement(List.Item, {
|
|
1893
1841
|
role: "button",
|
|
1894
1842
|
item,
|
|
1895
1843
|
classNames: [
|
|
1896
1844
|
subtleHover,
|
|
1897
|
-
"flex flex-col cursor-pointer rounded-
|
|
1845
|
+
"flex flex-col cursor-pointer rounded-xs"
|
|
1898
1846
|
],
|
|
1899
1847
|
"aria-expanded": selected === item.id
|
|
1900
|
-
}, /* @__PURE__ */
|
|
1848
|
+
}, /* @__PURE__ */ React13.createElement("div", {
|
|
1901
1849
|
className: "flex items-center"
|
|
1902
|
-
}, /* @__PURE__ */
|
|
1850
|
+
}, /* @__PURE__ */ React13.createElement(List.ItemDragHandle, {
|
|
1903
1851
|
disabled: !!readonly
|
|
1904
|
-
}), /* @__PURE__ */
|
|
1852
|
+
}), /* @__PURE__ */ React13.createElement(List.ItemTitle, {
|
|
1905
1853
|
onClick: () => handleClick(item.id),
|
|
1906
1854
|
classNames: "flex-1"
|
|
1907
|
-
}, /* @__PURE__ */
|
|
1855
|
+
}, /* @__PURE__ */ React13.createElement(Tag, {
|
|
1908
1856
|
palette: item.color
|
|
1909
|
-
}, item.title || "\u200B")), /* @__PURE__ */
|
|
1857
|
+
}, item.title || "\u200B")), /* @__PURE__ */ React13.createElement(IconButton3, {
|
|
1910
1858
|
iconOnly: true,
|
|
1911
1859
|
variant: "ghost",
|
|
1912
1860
|
label: t(selected === item.id ? "collapse label" : "expand label", {
|
|
@@ -1914,13 +1862,13 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
1914
1862
|
}),
|
|
1915
1863
|
icon: selected === item.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
|
|
1916
1864
|
onClick: () => handleClick(item.id)
|
|
1917
|
-
})), selected === item.id && /* @__PURE__ */
|
|
1918
|
-
className: "
|
|
1919
|
-
}, /* @__PURE__ */
|
|
1865
|
+
})), selected === item.id && /* @__PURE__ */ React13.createElement("div", {
|
|
1866
|
+
className: "flex flex-col p-form-padding gap-1 dx-density-fine"
|
|
1867
|
+
}, /* @__PURE__ */ React13.createElement(Input8.Label, {
|
|
1920
1868
|
classNames: "text-xs"
|
|
1921
|
-
}, t("select option label")), /* @__PURE__ */
|
|
1869
|
+
}, t("select option label")), /* @__PURE__ */ React13.createElement("div", {
|
|
1922
1870
|
className: "grid grid-cols-[1fr_min-content_min-content] gap-1"
|
|
1923
|
-
}, /* @__PURE__ */
|
|
1871
|
+
}, /* @__PURE__ */ React13.createElement(Input8.TextInput, {
|
|
1924
1872
|
disabled: !!readonly,
|
|
1925
1873
|
placeholder: t("select option label placeholder"),
|
|
1926
1874
|
ref: selected === item.id ? inputRef : void 0,
|
|
@@ -1928,38 +1876,38 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
1928
1876
|
onChange: handleTitleChange(item.id),
|
|
1929
1877
|
onKeyDown: handleKeyDown,
|
|
1930
1878
|
classNames: "flex-1"
|
|
1931
|
-
}), /* @__PURE__ */
|
|
1879
|
+
}), /* @__PURE__ */ React13.createElement(HuePicker, {
|
|
1932
1880
|
disabled: !!readonly,
|
|
1933
1881
|
value: item.color,
|
|
1934
1882
|
onChange: handleColorChange(item.id)
|
|
1935
|
-
}), /* @__PURE__ */
|
|
1883
|
+
}), /* @__PURE__ */ React13.createElement(IconButton3, {
|
|
1936
1884
|
disabled: !!readonly,
|
|
1937
1885
|
icon: "ph--trash--fill",
|
|
1938
1886
|
iconOnly: true,
|
|
1939
1887
|
label: t("select option delete"),
|
|
1940
1888
|
onClick: () => handleDelete(item.id)
|
|
1941
|
-
})))))), /* @__PURE__ */
|
|
1889
|
+
})))))), /* @__PURE__ */ React13.createElement(IconButton3, {
|
|
1942
1890
|
variant: "ghost",
|
|
1943
1891
|
icon: "ph--plus--regular",
|
|
1944
1892
|
label: t("select option add"),
|
|
1945
1893
|
onClick: handleAdd,
|
|
1946
1894
|
disabled: !!readonly,
|
|
1947
|
-
classNames: "
|
|
1895
|
+
classNames: "w-full"
|
|
1948
1896
|
})))));
|
|
1949
1897
|
};
|
|
1950
1898
|
|
|
1951
1899
|
// src/components/Form/fields/TextField.tsx
|
|
1952
|
-
import
|
|
1953
|
-
import { Input as
|
|
1900
|
+
import React14, { useCallback as useCallback12 } from "react";
|
|
1901
|
+
import { Input as Input9 } from "@dxos/react-ui";
|
|
1954
1902
|
var TextField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props }) => {
|
|
1955
1903
|
const handleChange = useCallback12((event) => onValueChange(type, event.target.value), [
|
|
1956
1904
|
type,
|
|
1957
1905
|
onValueChange
|
|
1958
1906
|
]);
|
|
1959
|
-
return /* @__PURE__ */
|
|
1907
|
+
return /* @__PURE__ */ React14.createElement(FormFieldWrapper, {
|
|
1960
1908
|
readonly,
|
|
1961
1909
|
...props
|
|
1962
|
-
}, ({ value: value3 = "" }) => /* @__PURE__ */
|
|
1910
|
+
}, ({ value: value3 = "" }) => /* @__PURE__ */ React14.createElement(Input9.TextInput, {
|
|
1963
1911
|
noAutoFill: true,
|
|
1964
1912
|
disabled: !!readonly,
|
|
1965
1913
|
placeholder,
|
|
@@ -1970,17 +1918,17 @@ var TextField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props
|
|
|
1970
1918
|
};
|
|
1971
1919
|
|
|
1972
1920
|
// src/components/Form/fields/TextAreaField.tsx
|
|
1973
|
-
import
|
|
1974
|
-
import { Input as
|
|
1921
|
+
import React15, { useCallback as useCallback13 } from "react";
|
|
1922
|
+
import { Input as Input10 } from "@dxos/react-ui";
|
|
1975
1923
|
var TextAreaField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props }) => {
|
|
1976
1924
|
const handleChange = useCallback13((event) => onValueChange(type, event.target.value), [
|
|
1977
1925
|
type,
|
|
1978
1926
|
onValueChange
|
|
1979
1927
|
]);
|
|
1980
|
-
return /* @__PURE__ */
|
|
1928
|
+
return /* @__PURE__ */ React15.createElement(FormFieldWrapper, {
|
|
1981
1929
|
readonly,
|
|
1982
1930
|
...props
|
|
1983
|
-
}, ({ value: value3 = "" }) => /* @__PURE__ */
|
|
1931
|
+
}, ({ value: value3 = "" }) => /* @__PURE__ */ React15.createElement(Input10.TextArea, {
|
|
1984
1932
|
rows: 3,
|
|
1985
1933
|
disabled: !!readonly,
|
|
1986
1934
|
placeholder,
|
|
@@ -1991,9 +1939,9 @@ var TextAreaField = ({ type, readonly, placeholder, onValueChange, onBlur, ...pr
|
|
|
1991
1939
|
};
|
|
1992
1940
|
|
|
1993
1941
|
// src/components/Form/fields/TupleField.tsx
|
|
1994
|
-
import
|
|
1995
|
-
import { Input as
|
|
1996
|
-
import { mx as
|
|
1942
|
+
import React16 from "react";
|
|
1943
|
+
import { Input as Input11 } from "@dxos/react-ui";
|
|
1944
|
+
import { mx as mx4 } from "@dxos/ui-theme";
|
|
1997
1945
|
import { safeParseFloat as safeParseFloat3 } from "@dxos/util";
|
|
1998
1946
|
var gridCols = [
|
|
1999
1947
|
"grid-cols-1",
|
|
@@ -2004,15 +1952,15 @@ var gridCols = [
|
|
|
2004
1952
|
var TupleField = ({ binding, type, readonly, label, getStatus, getValue, onValueChange, onBlur }) => {
|
|
2005
1953
|
const { status, error } = getStatus();
|
|
2006
1954
|
const values = getValue() ?? {};
|
|
2007
|
-
return /* @__PURE__ */
|
|
1955
|
+
return /* @__PURE__ */ React16.createElement(Input11.Root, {
|
|
2008
1956
|
validationValence: status
|
|
2009
|
-
}, /* @__PURE__ */
|
|
1957
|
+
}, /* @__PURE__ */ React16.createElement(FormFieldLabel, {
|
|
2010
1958
|
error,
|
|
2011
1959
|
readonly,
|
|
2012
1960
|
label
|
|
2013
|
-
}), /* @__PURE__ */
|
|
2014
|
-
className:
|
|
2015
|
-
}, binding.map((prop) => /* @__PURE__ */
|
|
1961
|
+
}), /* @__PURE__ */ React16.createElement("div", {
|
|
1962
|
+
className: mx4("grid gap-2", gridCols[binding.length - 1])
|
|
1963
|
+
}, binding.map((prop) => /* @__PURE__ */ React16.createElement(Input11.TextInput, {
|
|
2016
1964
|
key: prop,
|
|
2017
1965
|
type: "number",
|
|
2018
1966
|
disabled: !!readonly,
|
|
@@ -2030,7 +1978,7 @@ var TupleField = ({ binding, type, readonly, label, getStatus, getValue, onValue
|
|
|
2030
1978
|
// src/components/FieldEditor/FieldEditor.tsx
|
|
2031
1979
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
|
|
2032
1980
|
var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCancel }) => {
|
|
2033
|
-
const { t } =
|
|
1981
|
+
const { t } = useTranslation8(translationKey);
|
|
2034
1982
|
const [props, setProps] = useState5(projection.getFieldProjection(field.id).props);
|
|
2035
1983
|
useEffect7(() => setProps(projection.getFieldProjection(field.id).props), [
|
|
2036
1984
|
field,
|
|
@@ -2061,26 +2009,26 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2061
2009
|
fieldSchema: getFormatSchema(props?.format)
|
|
2062
2010
|
});
|
|
2063
2011
|
const fieldMap = useMemo7(() => ({
|
|
2064
|
-
["format"]: (props2) => /* @__PURE__ */
|
|
2012
|
+
["format"]: (props2) => /* @__PURE__ */ React17.createElement(SelectField, {
|
|
2065
2013
|
...props2,
|
|
2066
2014
|
options: FormatEnums.filter((value3) => value3 !== Format4.TypeFormat.None).map((value3) => ({
|
|
2067
2015
|
value: value3,
|
|
2068
2016
|
label: t(`format ${value3}`)
|
|
2069
2017
|
}))
|
|
2070
2018
|
}),
|
|
2071
|
-
["referenceSchema"]: (props2) => /* @__PURE__ */
|
|
2019
|
+
["referenceSchema"]: (props2) => /* @__PURE__ */ React17.createElement(SelectField, {
|
|
2072
2020
|
...props2,
|
|
2073
2021
|
options: schemas.map((schema) => ({
|
|
2074
2022
|
value: schema.typename
|
|
2075
2023
|
}))
|
|
2076
2024
|
}),
|
|
2077
|
-
["referencePath"]: (props2) => /* @__PURE__ */
|
|
2025
|
+
["referencePath"]: (props2) => /* @__PURE__ */ React17.createElement(SelectField, {
|
|
2078
2026
|
...props2,
|
|
2079
2027
|
options: referenceSchema ? getFormProperties(referenceSchema.ast).sort((a, b) => a.name.toString().localeCompare(b.name.toString())).map((p) => ({
|
|
2080
2028
|
value: p.name.toString()
|
|
2081
2029
|
})) : []
|
|
2082
2030
|
}),
|
|
2083
|
-
["options"]: (props2) => /* @__PURE__ */
|
|
2031
|
+
["options"]: (props2) => /* @__PURE__ */ React17.createElement(SelectOptionField, props2)
|
|
2084
2032
|
}), [
|
|
2085
2033
|
t,
|
|
2086
2034
|
schemas,
|
|
@@ -2139,7 +2087,7 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2139
2087
|
]);
|
|
2140
2088
|
const handleSave = useCallback14((props2) => {
|
|
2141
2089
|
if (view) {
|
|
2142
|
-
|
|
2090
|
+
Obj2.change(view, () => {
|
|
2143
2091
|
projection.setFieldProjection({
|
|
2144
2092
|
field,
|
|
2145
2093
|
props: props2
|
|
@@ -2169,13 +2117,13 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2169
2117
|
props
|
|
2170
2118
|
}, {
|
|
2171
2119
|
F: __dxlog_file2,
|
|
2172
|
-
L:
|
|
2120
|
+
L: 172,
|
|
2173
2121
|
S: void 0,
|
|
2174
2122
|
C: (f, a) => f(...a)
|
|
2175
2123
|
});
|
|
2176
2124
|
return null;
|
|
2177
2125
|
}
|
|
2178
|
-
return /* @__PURE__ */
|
|
2126
|
+
return /* @__PURE__ */ React17.createElement(Form.Root, {
|
|
2179
2127
|
key: field.id,
|
|
2180
2128
|
fieldMap,
|
|
2181
2129
|
autoFocus: true,
|
|
@@ -2191,7 +2139,138 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2191
2139
|
onValidate: handleValidate,
|
|
2192
2140
|
onSave: handleSave,
|
|
2193
2141
|
onCancel: handleCancel
|
|
2194
|
-
}, /* @__PURE__ */
|
|
2142
|
+
}, /* @__PURE__ */ React17.createElement(Form.Content, null, /* @__PURE__ */ React17.createElement(Form.FieldSet, null), /* @__PURE__ */ React17.createElement(Form.Actions, null)));
|
|
2143
|
+
};
|
|
2144
|
+
|
|
2145
|
+
// src/components/Settings/Settings.tsx
|
|
2146
|
+
import React18 from "react";
|
|
2147
|
+
import { Button as Button2, Input as Input12, ScrollArea as ScrollArea2, toLocalizedString, useTranslation as useTranslation9 } from "@dxos/react-ui";
|
|
2148
|
+
import { mx as mx5 } from "@dxos/ui-theme";
|
|
2149
|
+
var SETTINGS_ROOT_NAME = "Settings.Root";
|
|
2150
|
+
var SETTINGS_SECTION_NAME = "Settings.Section";
|
|
2151
|
+
var SETTINGS_SECTION_HEADING_NAME = "Settings.SectionHeading";
|
|
2152
|
+
var SETTINGS_GROUP_NAME = "Settings.Group";
|
|
2153
|
+
var SETTINGS_GROUP_BUTTON_NAME = "Settings.GroupButton";
|
|
2154
|
+
var SETTINGS_CONTAINER_NAME = "Settings.Container";
|
|
2155
|
+
var SETTINGS_FRAME_NAME = "Settings.Frame";
|
|
2156
|
+
var SETTINGS_FRAME_ITEM_NAME = "Settings.FrameItem";
|
|
2157
|
+
var SETTINGS_ITEM_NAME = "Settings.Item";
|
|
2158
|
+
var SETTINGS_ITEM_INPUT_NAME = "Settings.ItemInput";
|
|
2159
|
+
var styles = {
|
|
2160
|
+
title: "pb-trim-md text-base-surface-text text-lg",
|
|
2161
|
+
description: "text-base text-description",
|
|
2162
|
+
grid: "grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-x-trim-lg"
|
|
2163
|
+
};
|
|
2164
|
+
var SettingsRoot = ({ children }) => {
|
|
2165
|
+
return /* @__PURE__ */ React18.createElement(ScrollArea2.Root, {
|
|
2166
|
+
orientation: "vertical",
|
|
2167
|
+
className: "dx-article"
|
|
2168
|
+
}, /* @__PURE__ */ React18.createElement(ScrollArea2.Viewport, {
|
|
2169
|
+
classNames: "p-trim-md"
|
|
2170
|
+
}, children));
|
|
2171
|
+
};
|
|
2172
|
+
SettingsRoot.displayName = SETTINGS_ROOT_NAME;
|
|
2173
|
+
var SettingsSection = ({ title, description, children }) => {
|
|
2174
|
+
return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(SettingsSectionHeading, {
|
|
2175
|
+
title,
|
|
2176
|
+
description
|
|
2177
|
+
}), /* @__PURE__ */ React18.createElement("div", {
|
|
2178
|
+
className: "w-full pt-trim-md space-y-trim-md"
|
|
2179
|
+
}, children));
|
|
2180
|
+
};
|
|
2181
|
+
SettingsSection.displayName = SETTINGS_SECTION_NAME;
|
|
2182
|
+
var SettingsSectionHeading = ({ title, description }) => {
|
|
2183
|
+
const { t } = useTranslation9(translationKey);
|
|
2184
|
+
return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement("h2", {
|
|
2185
|
+
className: "px-trim-md mt-trim-md mb-trim-md text-xl"
|
|
2186
|
+
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React18.createElement("p", {
|
|
2187
|
+
className: "px-trim-md my-trim-md text-description"
|
|
2188
|
+
}, toLocalizedString(description, t)));
|
|
2189
|
+
};
|
|
2190
|
+
SettingsSectionHeading.displayName = SETTINGS_SECTION_HEADING_NAME;
|
|
2191
|
+
var SettingsGroupButton = ({ classNames, ...props }) => {
|
|
2192
|
+
return /* @__PURE__ */ React18.createElement(Button2, {
|
|
2193
|
+
...props,
|
|
2194
|
+
classNames: [
|
|
2195
|
+
"md:col-span-2",
|
|
2196
|
+
classNames
|
|
2197
|
+
]
|
|
2198
|
+
});
|
|
2199
|
+
};
|
|
2200
|
+
SettingsGroupButton.displayName = SETTINGS_GROUP_BUTTON_NAME;
|
|
2201
|
+
var SettingsGroup = ({ children, classNames }) => /* @__PURE__ */ React18.createElement("div", {
|
|
2202
|
+
role: "none",
|
|
2203
|
+
className: mx5("group space-y-trim-md", classNames)
|
|
2204
|
+
}, children);
|
|
2205
|
+
SettingsGroup.displayName = SETTINGS_GROUP_NAME;
|
|
2206
|
+
var SettingsFrame = ({ children }) => /* @__PURE__ */ React18.createElement("div", {
|
|
2207
|
+
role: "none",
|
|
2208
|
+
className: "p-trim-md border border-separator rounded-md"
|
|
2209
|
+
}, children);
|
|
2210
|
+
SettingsFrame.displayName = SETTINGS_FRAME_NAME;
|
|
2211
|
+
var SettingsFrameItem = ({ title, description, children }) => {
|
|
2212
|
+
const { t } = useTranslation9(translationKey);
|
|
2213
|
+
return /* @__PURE__ */ React18.createElement("div", {
|
|
2214
|
+
role: "group",
|
|
2215
|
+
className: "min-w-0"
|
|
2216
|
+
}, /* @__PURE__ */ React18.createElement("h3", {
|
|
2217
|
+
className: "text-lg mb-2"
|
|
2218
|
+
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React18.createElement("p", {
|
|
2219
|
+
className: "my-trim-sm md:mb-0 text-description"
|
|
2220
|
+
}, toLocalizedString(description, t)), children);
|
|
2221
|
+
};
|
|
2222
|
+
SettingsFrameItem.displayName = SETTINGS_FRAME_ITEM_NAME;
|
|
2223
|
+
var SettingsContainer = ({ classNames, children }) => {
|
|
2224
|
+
return /* @__PURE__ */ React18.createElement("div", {
|
|
2225
|
+
role: "none",
|
|
2226
|
+
className: mx5([
|
|
2227
|
+
"dx-article",
|
|
2228
|
+
"*:first:mt-0! *:last:mb-0! px-trim-md py-trim-md",
|
|
2229
|
+
"border border-separator rounded-md",
|
|
2230
|
+
classNames
|
|
2231
|
+
])
|
|
2232
|
+
}, children);
|
|
2233
|
+
};
|
|
2234
|
+
SettingsContainer.displayName = SETTINGS_CONTAINER_NAME;
|
|
2235
|
+
var SettingsItem = ({ title, description = "", children }) => {
|
|
2236
|
+
const { t } = useTranslation9(translationKey);
|
|
2237
|
+
return /* @__PURE__ */ React18.createElement(SettingsContainer, {
|
|
2238
|
+
classNames: styles.grid
|
|
2239
|
+
}, /* @__PURE__ */ React18.createElement("h3", {
|
|
2240
|
+
className: mx5(styles.title, "md:col-span-2")
|
|
2241
|
+
}, toLocalizedString(title, t)), /* @__PURE__ */ React18.createElement("p", {
|
|
2242
|
+
className: styles.description
|
|
2243
|
+
}, toLocalizedString(description, t)), /* @__PURE__ */ React18.createElement("div", {
|
|
2244
|
+
role: "none",
|
|
2245
|
+
className: "overflow-hidden text-end py-1"
|
|
2246
|
+
}, children));
|
|
2247
|
+
};
|
|
2248
|
+
SettingsItem.displayName = SETTINGS_ITEM_NAME;
|
|
2249
|
+
var SettingsItemInput = ({ title, description = "", children }) => {
|
|
2250
|
+
const { t } = useTranslation9(translationKey);
|
|
2251
|
+
return /* @__PURE__ */ React18.createElement(Input12.Root, null, /* @__PURE__ */ React18.createElement(SettingsContainer, {
|
|
2252
|
+
classNames: styles.grid
|
|
2253
|
+
}, /* @__PURE__ */ React18.createElement(Input12.Label, {
|
|
2254
|
+
classNames: mx5(styles.title, "md:col-span-2")
|
|
2255
|
+
}, toLocalizedString(title, t)), /* @__PURE__ */ React18.createElement(Input12.DescriptionAndValidation, null, /* @__PURE__ */ React18.createElement(Input12.Description, {
|
|
2256
|
+
classNames: styles.description
|
|
2257
|
+
}, toLocalizedString(description, t))), /* @__PURE__ */ React18.createElement("div", {
|
|
2258
|
+
role: "none",
|
|
2259
|
+
className: "text-end py-1"
|
|
2260
|
+
}, children)));
|
|
2261
|
+
};
|
|
2262
|
+
SettingsItemInput.displayName = SETTINGS_ITEM_INPUT_NAME;
|
|
2263
|
+
var Settings = {
|
|
2264
|
+
Root: SettingsRoot,
|
|
2265
|
+
Section: SettingsSection,
|
|
2266
|
+
SectionHeading: SettingsSectionHeading,
|
|
2267
|
+
Group: SettingsGroup,
|
|
2268
|
+
GroupButton: SettingsGroupButton,
|
|
2269
|
+
Container: SettingsContainer,
|
|
2270
|
+
Frame: SettingsFrame,
|
|
2271
|
+
FrameItem: SettingsFrameItem,
|
|
2272
|
+
Item: SettingsItem,
|
|
2273
|
+
ItemInput: SettingsItemInput
|
|
2195
2274
|
};
|
|
2196
2275
|
|
|
2197
2276
|
// src/components/ViewEditor/ViewEditor.tsx
|
|
@@ -2201,19 +2280,18 @@ import * as Match2 from "effect/Match";
|
|
|
2201
2280
|
import * as Option4 from "effect/Option";
|
|
2202
2281
|
import * as Schema3 from "effect/Schema";
|
|
2203
2282
|
import React19, { forwardRef as forwardRef3, useCallback as useCallback15, useContext, useImperativeHandle, useMemo as useMemo8, useState as useState6 } from "react";
|
|
2204
|
-
import { Filter as Filter2, Format as Format5, Obj as
|
|
2283
|
+
import { Entity as Entity2, Feed, Filter as Filter2, Format as Format5, Obj as Obj3, Query, QueryAST, Ref as Ref3 } from "@dxos/echo";
|
|
2284
|
+
import { View } from "@dxos/echo";
|
|
2205
2285
|
import { EchoSchema, isMutable, toJsonSchema } from "@dxos/echo/internal";
|
|
2206
2286
|
import { invariant } from "@dxos/invariant";
|
|
2207
|
-
import { useObject } from "@dxos/react-client/echo";
|
|
2208
|
-
import {
|
|
2287
|
+
import { useObject, useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
2288
|
+
import { IconButton as IconButton4, Input as Input13, Message, useTranslation as useTranslation10 } from "@dxos/react-ui";
|
|
2209
2289
|
import { QueryForm } from "@dxos/react-ui-components";
|
|
2210
2290
|
import { List as List2 } from "@dxos/react-ui-list";
|
|
2211
|
-
import {
|
|
2212
|
-
import { mx as
|
|
2291
|
+
import { ParentLabelAnnotation, ProjectionModel, VIEW_FIELD_LIMIT, createEchoChangeCallback, getTypenameFromQuery } from "@dxos/schema";
|
|
2292
|
+
import { mx as mx6, osTranslations as osTranslations2, subtleHover as subtleHover2 } from "@dxos/ui-theme";
|
|
2213
2293
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
|
|
2214
|
-
var
|
|
2215
|
-
var listItemGrid = "grid grid-cols-subgrid col-span-5";
|
|
2216
|
-
var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode = "schema", registry, readonly, showHeading = false, types, tags, onQueryChanged, onDelete }, forwardedRef) => {
|
|
2294
|
+
var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode = "schema", registry, db, readonly, showHeading = false, types, tags, onQueryChanged, onDelete }, forwardedRef) => {
|
|
2217
2295
|
const atomRegistry = useContext(RegistryContext);
|
|
2218
2296
|
const schemaReadonly = !isMutable(schema);
|
|
2219
2297
|
const { t } = useTranslation10(translationKey);
|
|
@@ -2235,12 +2313,25 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
|
|
|
2235
2313
|
useImperativeHandle(forwardedRef, () => projectionModel, [
|
|
2236
2314
|
projectionModel
|
|
2237
2315
|
]);
|
|
2238
|
-
const [expandedField, setExpandedField] = useState6();
|
|
2239
2316
|
const queueTarget = Match2.value(view.query.ast).pipe(Match2.when({
|
|
2240
|
-
type: "
|
|
2241
|
-
}, ({
|
|
2242
|
-
|
|
2317
|
+
type: "from"
|
|
2318
|
+
}, ({ from }) => {
|
|
2319
|
+
if (from._tag !== "scope") {
|
|
2320
|
+
return void 0;
|
|
2321
|
+
}
|
|
2322
|
+
return Option4.fromNullable(from.scope.queues).pipe(Option4.flatMap((queues) => Array2.head(queues)), Option4.map(String), Option4.getOrUndefined);
|
|
2243
2323
|
}), Match2.orElse(() => void 0));
|
|
2324
|
+
const feeds = useQuery2(db, Filter2.type(Feed.Feed));
|
|
2325
|
+
const targetRef = useMemo8(() => {
|
|
2326
|
+
if (!queueTarget) {
|
|
2327
|
+
return void 0;
|
|
2328
|
+
}
|
|
2329
|
+
const feed = feeds.find((feed2) => Feed.getQueueDxn(feed2)?.toString() === queueTarget);
|
|
2330
|
+
return feed ? Ref3.fromDXN(Entity2.getDXN(feed)) : void 0;
|
|
2331
|
+
}, [
|
|
2332
|
+
queueTarget,
|
|
2333
|
+
feeds
|
|
2334
|
+
]);
|
|
2244
2335
|
const viewSchema = useMemo8(() => {
|
|
2245
2336
|
const base = Schema3.Struct({
|
|
2246
2337
|
query: mode === "schema" ? Format5.URL.annotations({
|
|
@@ -2252,9 +2343,10 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
|
|
|
2252
2343
|
if (mode === "tag") {
|
|
2253
2344
|
return Schema3.Struct({
|
|
2254
2345
|
...base.fields,
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2346
|
+
// TODO(wittjosiah): Replace Type.Feed with Dataset.Dataset when Ref.Ref supports unions.
|
|
2347
|
+
target: Ref3.Ref(Feed.Feed).pipe(Schema3.annotations({
|
|
2348
|
+
title: "Target Feed"
|
|
2349
|
+
}), ParentLabelAnnotation.set(true), Schema3.optional)
|
|
2258
2350
|
}).pipe(Schema3.mutable);
|
|
2259
2351
|
}
|
|
2260
2352
|
return base.pipe(Schema3.mutable);
|
|
@@ -2263,11 +2355,11 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
|
|
|
2263
2355
|
]);
|
|
2264
2356
|
const viewValues = useMemo8(() => ({
|
|
2265
2357
|
query: mode === "schema" ? getTypenameFromQuery(view.query.ast) : view.query.ast,
|
|
2266
|
-
target:
|
|
2358
|
+
target: targetRef
|
|
2267
2359
|
}), [
|
|
2268
2360
|
mode,
|
|
2269
2361
|
view.query.ast,
|
|
2270
|
-
|
|
2362
|
+
targetRef
|
|
2271
2363
|
]);
|
|
2272
2364
|
const fieldMap = useMemo8(() => mode === "tag" ? customFields({
|
|
2273
2365
|
types,
|
|
@@ -2277,64 +2369,50 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
|
|
|
2277
2369
|
types,
|
|
2278
2370
|
tags
|
|
2279
2371
|
]);
|
|
2280
|
-
const handleAdd = useCallback15(() => {
|
|
2281
|
-
invariant(!readonly, void 0, {
|
|
2282
|
-
F: __dxlog_file3,
|
|
2283
|
-
L: 146,
|
|
2284
|
-
S: void 0,
|
|
2285
|
-
A: [
|
|
2286
|
-
"!readonly",
|
|
2287
|
-
""
|
|
2288
|
-
]
|
|
2289
|
-
});
|
|
2290
|
-
const field = projectionModel.createFieldProjection();
|
|
2291
|
-
setExpandedField(field.id);
|
|
2292
|
-
}, [
|
|
2293
|
-
projectionModel,
|
|
2294
|
-
readonly
|
|
2295
|
-
]);
|
|
2296
2372
|
const handleUpdate = useCallback15((values) => {
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2373
|
+
const targetValue = values.target;
|
|
2374
|
+
let queueDxn;
|
|
2375
|
+
if (Ref3.isRef(targetValue)) {
|
|
2376
|
+
const feedDxn = targetValue.dxn.toString();
|
|
2377
|
+
const feed = feeds.find((feed2) => Obj3.getDXN(feed2).toString() === feedDxn);
|
|
2378
|
+
if (feed) {
|
|
2379
|
+
queueDxn = Feed.getQueueDxn(feed)?.toString();
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
const query = mode === "schema" ? Query.select(Filter2.typename(values.query)).ast : JSON.parse(JSON.stringify(values.query));
|
|
2383
|
+
onQueryChanged?.(query, queueDxn);
|
|
2301
2384
|
}, [
|
|
2302
2385
|
onQueryChanged,
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
mode
|
|
2386
|
+
mode,
|
|
2387
|
+
feeds
|
|
2306
2388
|
]);
|
|
2307
2389
|
const handleDelete = useCallback15((fieldId) => {
|
|
2308
2390
|
invariant(!readonly, void 0, {
|
|
2309
2391
|
F: __dxlog_file3,
|
|
2310
|
-
L:
|
|
2392
|
+
L: 185,
|
|
2311
2393
|
S: void 0,
|
|
2312
2394
|
A: [
|
|
2313
2395
|
"!readonly",
|
|
2314
2396
|
""
|
|
2315
2397
|
]
|
|
2316
2398
|
});
|
|
2317
|
-
if (fieldId === expandedField) {
|
|
2318
|
-
setExpandedField(void 0);
|
|
2319
|
-
}
|
|
2320
2399
|
onDelete?.(fieldId);
|
|
2321
2400
|
}, [
|
|
2322
|
-
expandedField,
|
|
2323
2401
|
onDelete,
|
|
2324
2402
|
readonly
|
|
2325
2403
|
]);
|
|
2326
2404
|
return /* @__PURE__ */ React19.createElement("div", {
|
|
2327
2405
|
role: "none",
|
|
2328
|
-
className:
|
|
2329
|
-
}, schemaReadonly && !readonly && /* @__PURE__ */ React19.createElement(
|
|
2406
|
+
className: mx6(classNames)
|
|
2407
|
+
}, schemaReadonly && !readonly && /* @__PURE__ */ React19.createElement(Message.Root, {
|
|
2330
2408
|
valence: "info",
|
|
2331
|
-
classNames: "
|
|
2332
|
-
}, /* @__PURE__ */ React19.createElement(
|
|
2409
|
+
classNames: "my-form-padding"
|
|
2410
|
+
}, /* @__PURE__ */ React19.createElement(Message.Title, null, t("system schema description"))), /* @__PURE__ */ React19.createElement(Form.Root, {
|
|
2333
2411
|
schema: viewSchema,
|
|
2334
2412
|
values: viewValues,
|
|
2335
2413
|
fieldMap,
|
|
2336
|
-
|
|
2337
|
-
|
|
2414
|
+
db,
|
|
2415
|
+
onValuesChanged: handleUpdate
|
|
2338
2416
|
}, /* @__PURE__ */ React19.createElement(Form.FieldSet, null), /* @__PURE__ */ React19.createElement(FormFieldLabel, {
|
|
2339
2417
|
label: t("fields label"),
|
|
2340
2418
|
asChild: true
|
|
@@ -2345,16 +2423,6 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
|
|
|
2345
2423
|
readonly,
|
|
2346
2424
|
showHeading,
|
|
2347
2425
|
onDelete: handleDelete
|
|
2348
|
-
})), !readonly && !expandedField && /* @__PURE__ */ React19.createElement("div", {
|
|
2349
|
-
role: "none",
|
|
2350
|
-
className: "mlb-cardSpacingBlock"
|
|
2351
|
-
}, /* @__PURE__ */ React19.createElement(IconButton4, {
|
|
2352
|
-
icon: "ph--plus--regular",
|
|
2353
|
-
label: t("add property button label"),
|
|
2354
|
-
onClick: readonly ? void 0 : handleAdd,
|
|
2355
|
-
// TODO(burdon): Show field limit in ux (not tooltip).
|
|
2356
|
-
disabled: view.projection.fields.length >= VIEW_FIELD_LIMIT,
|
|
2357
|
-
classNames: "is-full"
|
|
2358
2426
|
})));
|
|
2359
2427
|
});
|
|
2360
2428
|
var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDelete }) => {
|
|
@@ -2378,6 +2446,22 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2378
2446
|
view
|
|
2379
2447
|
]);
|
|
2380
2448
|
const [expandedField, setExpandedField] = useState6();
|
|
2449
|
+
const handleAdd = useCallback15(() => {
|
|
2450
|
+
invariant(!readonly, void 0, {
|
|
2451
|
+
F: __dxlog_file3,
|
|
2452
|
+
L: 250,
|
|
2453
|
+
S: void 0,
|
|
2454
|
+
A: [
|
|
2455
|
+
"!readonly",
|
|
2456
|
+
""
|
|
2457
|
+
]
|
|
2458
|
+
});
|
|
2459
|
+
const field = projectionModel.createFieldProjection();
|
|
2460
|
+
setExpandedField(field.id);
|
|
2461
|
+
}, [
|
|
2462
|
+
projectionModel,
|
|
2463
|
+
readonly
|
|
2464
|
+
]);
|
|
2381
2465
|
const handleToggleField = useCallback15((field) => {
|
|
2382
2466
|
setExpandedField((prevExpandedFieldId) => prevExpandedFieldId === field.id ? void 0 : field.id);
|
|
2383
2467
|
}, [
|
|
@@ -2386,7 +2470,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2386
2470
|
const handleDelete = useCallback15((fieldId) => {
|
|
2387
2471
|
invariant(!readonly, void 0, {
|
|
2388
2472
|
F: __dxlog_file3,
|
|
2389
|
-
L:
|
|
2473
|
+
L: 264,
|
|
2390
2474
|
S: void 0,
|
|
2391
2475
|
A: [
|
|
2392
2476
|
"!readonly",
|
|
@@ -2405,14 +2489,14 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2405
2489
|
const handleMove = useCallback15((fromIndex, toIndex) => {
|
|
2406
2490
|
invariant(!readonly, void 0, {
|
|
2407
2491
|
F: __dxlog_file3,
|
|
2408
|
-
L:
|
|
2492
|
+
L: 276,
|
|
2409
2493
|
S: void 0,
|
|
2410
2494
|
A: [
|
|
2411
2495
|
"!readonly",
|
|
2412
2496
|
""
|
|
2413
2497
|
]
|
|
2414
2498
|
});
|
|
2415
|
-
|
|
2499
|
+
Obj3.change(view, (v) => {
|
|
2416
2500
|
const fields = [
|
|
2417
2501
|
...v.projection.fields
|
|
2418
2502
|
];
|
|
@@ -2442,7 +2526,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2442
2526
|
}
|
|
2443
2527
|
return /* @__PURE__ */ React19.createElement(List2.Root, {
|
|
2444
2528
|
items: viewSnapshot.projection.fields,
|
|
2445
|
-
isItem: Schema3.is(FieldSchema),
|
|
2529
|
+
isItem: Schema3.is(View.FieldSchema),
|
|
2446
2530
|
getId: (field) => field.id,
|
|
2447
2531
|
onMove: readonly ? void 0 : handleMove,
|
|
2448
2532
|
readonly
|
|
@@ -2450,17 +2534,17 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2450
2534
|
className: "text-sm"
|
|
2451
2535
|
}, t("field path label")), /* @__PURE__ */ React19.createElement("div", {
|
|
2452
2536
|
role: "list",
|
|
2453
|
-
className:
|
|
2537
|
+
className: "grid grid-cols-[min-content_1fr_min-content_min-content_min-content]"
|
|
2454
2538
|
}, fields?.map((field) => {
|
|
2455
2539
|
const hidden = field.visible === false;
|
|
2456
2540
|
return /* @__PURE__ */ React19.createElement(List2.Item, {
|
|
2457
2541
|
key: field.id,
|
|
2458
2542
|
item: field,
|
|
2459
|
-
classNames:
|
|
2543
|
+
classNames: "grid grid-cols-subgrid col-span-5",
|
|
2460
2544
|
"aria-expanded": expandedField === field.id
|
|
2461
2545
|
}, /* @__PURE__ */ React19.createElement("div", {
|
|
2462
2546
|
role: "none",
|
|
2463
|
-
className:
|
|
2547
|
+
className: mx6(subtleHover2, "grid grid-cols-subgrid col-span-5", "rounded-xs cursor-pointer min-h-10")
|
|
2464
2548
|
}, /* @__PURE__ */ React19.createElement(List2.ItemDragHandle, {
|
|
2465
2549
|
disabled: readonly || schemaReadonly
|
|
2466
2550
|
}), /* @__PURE__ */ React19.createElement(List2.ItemTitle, {
|
|
@@ -2490,7 +2574,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2490
2574
|
"data-testid": "field.toggle"
|
|
2491
2575
|
}))), expandedField === field.id && !readonly && /* @__PURE__ */ React19.createElement("div", {
|
|
2492
2576
|
role: "none",
|
|
2493
|
-
className: "col-span-5
|
|
2577
|
+
className: "col-span-5 mt-1 mb-1 border border-separator rounded-md"
|
|
2494
2578
|
}, /* @__PURE__ */ React19.createElement(FieldEditor, {
|
|
2495
2579
|
readonly: readonly || schemaReadonly,
|
|
2496
2580
|
registry,
|
|
@@ -2498,6 +2582,15 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2498
2582
|
field,
|
|
2499
2583
|
onSave: handleClose
|
|
2500
2584
|
})));
|
|
2585
|
+
})), !readonly && !expandedField && /* @__PURE__ */ React19.createElement("div", {
|
|
2586
|
+
role: "none",
|
|
2587
|
+
className: "my-form-padding"
|
|
2588
|
+
}, /* @__PURE__ */ React19.createElement(IconButton4, {
|
|
2589
|
+
icon: "ph--plus--regular",
|
|
2590
|
+
label: t("add property button label"),
|
|
2591
|
+
onClick: handleAdd,
|
|
2592
|
+
disabled: viewSnapshot.projection.fields.length >= VIEW_FIELD_LIMIT,
|
|
2593
|
+
classNames: "w-full"
|
|
2501
2594
|
}))));
|
|
2502
2595
|
};
|
|
2503
2596
|
var customFields = ({ types, tags }) => ({
|
|
@@ -2519,15 +2612,6 @@ var customFields = ({ types, tags }) => ({
|
|
|
2519
2612
|
export {
|
|
2520
2613
|
ArrayField,
|
|
2521
2614
|
BooleanField,
|
|
2522
|
-
ControlFrame,
|
|
2523
|
-
ControlFrameItem,
|
|
2524
|
-
ControlGroup,
|
|
2525
|
-
ControlGroupButton,
|
|
2526
|
-
ControlItem,
|
|
2527
|
-
ControlItemInput,
|
|
2528
|
-
ControlPage,
|
|
2529
|
-
ControlSection,
|
|
2530
|
-
ControlSectionHeading,
|
|
2531
2615
|
FieldEditor,
|
|
2532
2616
|
Form,
|
|
2533
2617
|
FormFieldErrorBoundary,
|
|
@@ -2540,12 +2624,12 @@ export {
|
|
|
2540
2624
|
RefField,
|
|
2541
2625
|
SelectField,
|
|
2542
2626
|
SelectOptionField,
|
|
2627
|
+
Settings,
|
|
2543
2628
|
TextAreaField,
|
|
2544
2629
|
TextField,
|
|
2545
2630
|
TupleField,
|
|
2546
2631
|
ViewEditor,
|
|
2547
2632
|
cellClassesForFieldType,
|
|
2548
|
-
controlItemClasses,
|
|
2549
2633
|
formatForDisplay,
|
|
2550
2634
|
formatForEditing,
|
|
2551
2635
|
getDefaultValue,
|
|
@@ -2554,7 +2638,6 @@ export {
|
|
|
2554
2638
|
omitId,
|
|
2555
2639
|
parseValue,
|
|
2556
2640
|
pathNotUniqueError,
|
|
2557
|
-
setValueEchoAware,
|
|
2558
2641
|
translations,
|
|
2559
2642
|
useFormContext,
|
|
2560
2643
|
useFormFieldState,
|