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