@dxos/react-ui-form 0.8.4-main.bc674ce → 0.8.4-main.c351d160a8
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 +538 -458
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +538 -458
- 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 +0 -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 +9 -10
- 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 -20
- package/src/components/Form/FormFieldSet.tsx +106 -104
- 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 +92 -63
- 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
|
|
390
|
+
import { IconButton, ScrollArea, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
391
|
+
import { mx } 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,9 +751,7 @@ var FormFieldErrorBoundary = class extends Component {
|
|
|
834
751
|
};
|
|
835
752
|
|
|
836
753
|
// src/components/Form/FormFieldSet.tsx
|
|
837
|
-
import
|
|
838
|
-
import { mx as mx3 } from "@dxos/ui-theme";
|
|
839
|
-
import { isTruthy } from "@dxos/util";
|
|
754
|
+
import React3, { useMemo as useMemo3 } from "react";
|
|
840
755
|
|
|
841
756
|
// src/components/Form/FormField.tsx
|
|
842
757
|
import * as Match from "effect/Match";
|
|
@@ -844,10 +759,10 @@ import * as Option2 from "effect/Option";
|
|
|
844
759
|
import * as Schema from "effect/Schema";
|
|
845
760
|
import * as SchemaAST from "effect/SchemaAST";
|
|
846
761
|
import * as String2 from "effect/String";
|
|
847
|
-
import
|
|
762
|
+
import React2, { useMemo as useMemo2 } from "react";
|
|
848
763
|
import { Format as Format3 } from "@dxos/echo";
|
|
849
764
|
import { createJsonPath as createJsonPath2, findNode, getAnnotation, getDiscriminatedType, isArrayType as isArrayType2, isDiscriminatedUnion, isLiteralUnion, isNestedType } from "@dxos/effect";
|
|
850
|
-
import { useTranslation
|
|
765
|
+
import { useTranslation } from "@dxos/react-ui";
|
|
851
766
|
var FormField = (props) => {
|
|
852
767
|
const {
|
|
853
768
|
type,
|
|
@@ -867,7 +782,7 @@ var FormField = (props) => {
|
|
|
867
782
|
getOptions: getRefOptions,
|
|
868
783
|
onCreate
|
|
869
784
|
} = props;
|
|
870
|
-
const { t } =
|
|
785
|
+
const { t } = useTranslation(translationKey);
|
|
871
786
|
const title = getAnnotation(SchemaAST.TitleAnnotationId)(type);
|
|
872
787
|
const description = getAnnotation(SchemaAST.DescriptionAnnotationId)(type);
|
|
873
788
|
const examples = getAnnotation(SchemaAST.ExamplesAnnotationId)(type);
|
|
@@ -893,7 +808,7 @@ var FormField = (props) => {
|
|
|
893
808
|
const jsonPath = createJsonPath2(path ?? []);
|
|
894
809
|
const CustomField = fieldMap?.[jsonPath];
|
|
895
810
|
if (CustomField) {
|
|
896
|
-
return /* @__PURE__ */
|
|
811
|
+
return /* @__PURE__ */ React2.createElement(CustomField, fieldProps);
|
|
897
812
|
}
|
|
898
813
|
const component = fieldProvider?.({
|
|
899
814
|
schema: Schema.make(type),
|
|
@@ -904,7 +819,7 @@ var FormField = (props) => {
|
|
|
904
819
|
return component;
|
|
905
820
|
}
|
|
906
821
|
if (isArrayType2(type)) {
|
|
907
|
-
return /* @__PURE__ */
|
|
822
|
+
return /* @__PURE__ */ React2.createElement(ArrayField, {
|
|
908
823
|
fieldProps: fieldState,
|
|
909
824
|
label,
|
|
910
825
|
...props
|
|
@@ -912,21 +827,27 @@ var FormField = (props) => {
|
|
|
912
827
|
}
|
|
913
828
|
const Field = getFormField(fieldProps);
|
|
914
829
|
if (Field) {
|
|
915
|
-
return /* @__PURE__ */
|
|
830
|
+
return /* @__PURE__ */ React2.createElement(Field, fieldProps);
|
|
916
831
|
}
|
|
917
832
|
const options = getOptions(type);
|
|
918
833
|
if (options) {
|
|
919
|
-
|
|
834
|
+
const fieldProjections = projection?.getFieldProjections();
|
|
835
|
+
const fieldProjection = fieldProjections?.find((fp) => fp.field.path === name);
|
|
836
|
+
const selectOptions = fieldProjection?.props.options;
|
|
837
|
+
return /* @__PURE__ */ React2.createElement(SelectField, {
|
|
920
838
|
...fieldProps,
|
|
921
|
-
options: options.map((option) =>
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
839
|
+
options: options.map((option) => {
|
|
840
|
+
const selectOption = selectOptions?.find((so) => so.id === globalThis.String(option));
|
|
841
|
+
return {
|
|
842
|
+
value: option,
|
|
843
|
+
label: selectOption?.title ?? option.toString()
|
|
844
|
+
};
|
|
845
|
+
})
|
|
925
846
|
});
|
|
926
847
|
}
|
|
927
848
|
const refProps = getRefProps(type);
|
|
928
849
|
if (refProps) {
|
|
929
|
-
return /* @__PURE__ */
|
|
850
|
+
return /* @__PURE__ */ React2.createElement(RefField, {
|
|
930
851
|
...fieldProps,
|
|
931
852
|
...refProps,
|
|
932
853
|
createOptionLabel,
|
|
@@ -943,7 +864,7 @@ var FormField = (props) => {
|
|
|
943
864
|
const typeLiteral = baseNode ? getDiscriminatedType(baseNode, fieldState.getValue()) : findNode(type, SchemaAST.isTypeLiteral);
|
|
944
865
|
if (typeLiteral) {
|
|
945
866
|
const schema = Schema.make(typeLiteral);
|
|
946
|
-
return /* @__PURE__ */
|
|
867
|
+
return /* @__PURE__ */ React2.createElement(FormFieldSet, {
|
|
947
868
|
schema,
|
|
948
869
|
path,
|
|
949
870
|
readonly,
|
|
@@ -989,17 +910,19 @@ var getOptions = (ast) => {
|
|
|
989
910
|
};
|
|
990
911
|
|
|
991
912
|
// src/components/Form/FormFieldSet.tsx
|
|
992
|
-
var
|
|
993
|
-
|
|
913
|
+
var FORM_FIELDSET_NAME = "Form.FieldSet";
|
|
914
|
+
var FormFieldSet = ({ label, schema, readonly, path, sort, exclude, projection, layout, ...props }) => {
|
|
915
|
+
const values = useFormValues(FORM_FIELDSET_NAME, path);
|
|
994
916
|
const properties = useMemo3(() => {
|
|
995
917
|
if (!schema) {
|
|
996
918
|
return [];
|
|
997
919
|
}
|
|
998
|
-
const
|
|
920
|
+
const schemaProps = getFormProperties(schema.ast);
|
|
921
|
+
const filteredProps = exclude ? exclude(schemaProps) : schemaProps;
|
|
999
922
|
if (projection) {
|
|
1000
923
|
const fieldProjections = projection.getFieldProjections();
|
|
1001
924
|
const hiddenProperties = new Set(projection.getHiddenProperties());
|
|
1002
|
-
const visibleProps =
|
|
925
|
+
const visibleProps = filteredProps.filter((prop) => !hiddenProperties.has(prop.name.toString()));
|
|
1003
926
|
const orderedProps = [];
|
|
1004
927
|
for (const fieldProjection of fieldProjections) {
|
|
1005
928
|
const fieldPath = String(fieldProjection.field.path);
|
|
@@ -1013,34 +936,31 @@ var FormFieldSet = /* @__PURE__ */ forwardRef(({ classNames, label, schema, read
|
|
|
1013
936
|
orderedProps.push(...remainingProps);
|
|
1014
937
|
return orderedProps;
|
|
1015
938
|
}
|
|
1016
|
-
|
|
1017
|
-
|
|
939
|
+
return sort ? [
|
|
940
|
+
...filteredProps
|
|
941
|
+
].sort(({ name: a }, { name: b }) => sort.indexOf(a.toString()) - sort.indexOf(b.toString())) : filteredProps;
|
|
1018
942
|
}, [
|
|
1019
943
|
schema,
|
|
1020
944
|
values,
|
|
1021
945
|
exclude,
|
|
1022
946
|
sort,
|
|
1023
|
-
projection
|
|
947
|
+
projection
|
|
1024
948
|
]);
|
|
1025
949
|
if ((readonly || layout === "static") && values == null) {
|
|
1026
950
|
return null;
|
|
1027
951
|
}
|
|
1028
|
-
return /* @__PURE__ */
|
|
1029
|
-
role: "form",
|
|
1030
|
-
className: mx3("is-full", layout === "inline" && "flex flex-col gap-2", classNames),
|
|
1031
|
-
ref: forwardRef4
|
|
1032
|
-
}, layout !== "inline" && label && /* @__PURE__ */ React4.createElement(FormFieldLabel, {
|
|
952
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, layout !== "inline" && label && /* @__PURE__ */ React3.createElement(FormFieldLabel, {
|
|
1033
953
|
label,
|
|
1034
954
|
asChild: true
|
|
1035
955
|
}), properties.map((property) => {
|
|
1036
956
|
const name = property.name.toString();
|
|
1037
|
-
return /* @__PURE__ */
|
|
957
|
+
return /* @__PURE__ */ React3.createElement(FormFieldErrorBoundary, {
|
|
1038
958
|
key: name,
|
|
1039
959
|
path: [
|
|
1040
960
|
...path ?? [],
|
|
1041
961
|
name
|
|
1042
962
|
]
|
|
1043
|
-
}, /* @__PURE__ */
|
|
963
|
+
}, /* @__PURE__ */ React3.createElement(FormField, {
|
|
1044
964
|
type: property.type,
|
|
1045
965
|
name,
|
|
1046
966
|
path: [
|
|
@@ -1052,24 +972,32 @@ var FormFieldSet = /* @__PURE__ */ forwardRef(({ classNames, label, schema, read
|
|
|
1052
972
|
projection,
|
|
1053
973
|
...props
|
|
1054
974
|
}));
|
|
1055
|
-
})
|
|
1056
|
-
}
|
|
1057
|
-
FormFieldSet.displayName =
|
|
975
|
+
}));
|
|
976
|
+
};
|
|
977
|
+
FormFieldSet.displayName = FORM_FIELDSET_NAME;
|
|
1058
978
|
|
|
1059
979
|
// src/components/Form/Form.tsx
|
|
1060
980
|
var omitId = (schema) => schema.pipe(Schema2.omit("id"));
|
|
1061
981
|
var [FormContextProvider, useFormContext] = createContext("Form");
|
|
1062
|
-
var useFormValues = (componentName, path
|
|
1063
|
-
const
|
|
1064
|
-
|
|
982
|
+
var useFormValues = (componentName, path, defaultValue) => {
|
|
983
|
+
const stablePath = useMemo4(() => path ?? [], [
|
|
984
|
+
path ? path.join(".") : void 0
|
|
985
|
+
]);
|
|
986
|
+
const jsonPath = createJsonPath3(stablePath);
|
|
987
|
+
const { form: { values, onValueChange } } = useFormContext(componentName);
|
|
1065
988
|
const value3 = getValue$2(values, jsonPath);
|
|
989
|
+
const lastAppliedPathRef = useRef(null);
|
|
1066
990
|
useEffect3(() => {
|
|
1067
|
-
if (
|
|
1068
|
-
|
|
991
|
+
if (value3 == null && defaultValue && lastAppliedPathRef.current !== jsonPath) {
|
|
992
|
+
lastAppliedPathRef.current = jsonPath;
|
|
993
|
+
onValueChange(stablePath, SchemaAST2.stringKeyword, defaultValue());
|
|
1069
994
|
}
|
|
1070
995
|
}, [
|
|
1071
996
|
value3,
|
|
1072
|
-
defaultValue
|
|
997
|
+
defaultValue,
|
|
998
|
+
onValueChange,
|
|
999
|
+
stablePath,
|
|
1000
|
+
jsonPath
|
|
1073
1001
|
]);
|
|
1074
1002
|
return value3;
|
|
1075
1003
|
};
|
|
@@ -1099,60 +1027,64 @@ var FormRoot = ({ children, schema, values, onSave, onCancel, ...props }) => {
|
|
|
1099
1027
|
onCancel,
|
|
1100
1028
|
...props
|
|
1101
1029
|
});
|
|
1102
|
-
return /* @__PURE__ */
|
|
1030
|
+
return /* @__PURE__ */ React4.createElement(FormContextProvider, {
|
|
1103
1031
|
form,
|
|
1104
1032
|
...props
|
|
1105
1033
|
}, children);
|
|
1106
1034
|
};
|
|
1107
1035
|
FormRoot.displayName = "Form.Root";
|
|
1108
|
-
var
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1036
|
+
var FORM_VIEWPORT_NAME = "Form.Viewport";
|
|
1037
|
+
var FormViewport = ({ children, classNames, margin = true, padding = true, thin = true, ...props }) => {
|
|
1038
|
+
return /* @__PURE__ */ React4.createElement(ScrollArea.Root, {
|
|
1039
|
+
orientation: "vertical",
|
|
1040
|
+
classNames,
|
|
1041
|
+
margin,
|
|
1042
|
+
padding,
|
|
1043
|
+
thin,
|
|
1044
|
+
...props
|
|
1045
|
+
}, /* @__PURE__ */ React4.createElement(ScrollArea.Viewport, null, children));
|
|
1117
1046
|
};
|
|
1118
|
-
FormViewport.displayName =
|
|
1047
|
+
FormViewport.displayName = FORM_VIEWPORT_NAME;
|
|
1048
|
+
var FORM_CONTENT_NAME = "Form.Content";
|
|
1119
1049
|
var FormContent = ({ classNames, children }) => {
|
|
1120
|
-
const { form, testId } = useFormContext(
|
|
1050
|
+
const { form, testId } = useFormContext(FORM_CONTENT_NAME);
|
|
1121
1051
|
const ref = useRef(null);
|
|
1122
1052
|
useKeyHandler(ref.current, form);
|
|
1123
|
-
return /* @__PURE__ */
|
|
1053
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
1124
1054
|
ref,
|
|
1125
1055
|
role: "form",
|
|
1126
|
-
className:
|
|
1056
|
+
className: mx("w-full flex flex-col gap-form-padding", classNames),
|
|
1127
1057
|
"data-testid": testId
|
|
1128
1058
|
}, children);
|
|
1129
1059
|
};
|
|
1130
|
-
FormContent.displayName =
|
|
1131
|
-
var
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1060
|
+
FormContent.displayName = FORM_CONTENT_NAME;
|
|
1061
|
+
var FORM_FIELDSET_NAME2 = "Form.FieldSet";
|
|
1062
|
+
var FormFieldSet2 = (props) => {
|
|
1063
|
+
const { form, ...contextProps } = useFormContext(FORM_FIELDSET_NAME2);
|
|
1064
|
+
return /* @__PURE__ */ React4.createElement(FormFieldSet, {
|
|
1135
1065
|
schema: form.schema,
|
|
1066
|
+
...contextProps,
|
|
1136
1067
|
...props
|
|
1137
1068
|
});
|
|
1138
1069
|
};
|
|
1139
|
-
FormFieldSet2.displayName =
|
|
1070
|
+
FormFieldSet2.displayName = FORM_FIELDSET_NAME2;
|
|
1071
|
+
var FORM_ACTIONS_NAME = "Form.Actions";
|
|
1140
1072
|
var FormActions = ({ classNames }) => {
|
|
1141
|
-
const { t } =
|
|
1142
|
-
const { form: { canSave, onSave, onCancel }, readonly, layout } = useFormContext(
|
|
1073
|
+
const { t } = useTranslation2(translationKey);
|
|
1074
|
+
const { form: { canSave, onSave, onCancel }, readonly, layout } = useFormContext(FORM_ACTIONS_NAME);
|
|
1143
1075
|
if (readonly || layout === "static") {
|
|
1144
1076
|
return null;
|
|
1145
1077
|
}
|
|
1146
|
-
return /* @__PURE__ */
|
|
1078
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
1147
1079
|
role: "none",
|
|
1148
|
-
className:
|
|
1149
|
-
}, onCancel && /* @__PURE__ */
|
|
1080
|
+
className: mx("grid grid-flow-col gap-2 auto-cols-fr py-form-padding", classNames)
|
|
1081
|
+
}, onCancel && /* @__PURE__ */ React4.createElement(IconButton, {
|
|
1150
1082
|
icon: "ph--x--regular",
|
|
1151
1083
|
iconEnd: true,
|
|
1152
1084
|
label: t("cancel button label"),
|
|
1153
1085
|
onClick: onCancel,
|
|
1154
1086
|
"data-testid": "cancel-button"
|
|
1155
|
-
}), onSave && /* @__PURE__ */
|
|
1087
|
+
}), onSave && /* @__PURE__ */ React4.createElement(IconButton, {
|
|
1156
1088
|
type: "submit",
|
|
1157
1089
|
variant: "primary",
|
|
1158
1090
|
disabled: !canSave,
|
|
@@ -1163,52 +1095,53 @@ var FormActions = ({ classNames }) => {
|
|
|
1163
1095
|
"data-testid": "save-button"
|
|
1164
1096
|
}));
|
|
1165
1097
|
};
|
|
1166
|
-
FormActions.displayName =
|
|
1167
|
-
var
|
|
1168
|
-
|
|
1169
|
-
const {
|
|
1098
|
+
FormActions.displayName = FORM_ACTIONS_NAME;
|
|
1099
|
+
var FORM_SUBMIT_NAME = "Form.Submit";
|
|
1100
|
+
var FormSubmit = ({ classNames, label, icon, disabled }) => {
|
|
1101
|
+
const { t } = useTranslation2(translationKey);
|
|
1102
|
+
const { form: { canSave, onSave }, readonly, layout } = useFormContext(FORM_SUBMIT_NAME);
|
|
1170
1103
|
if (readonly || layout === "static") {
|
|
1171
1104
|
return null;
|
|
1172
1105
|
}
|
|
1173
|
-
return /* @__PURE__ */
|
|
1106
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
1174
1107
|
role: "none",
|
|
1175
|
-
className:
|
|
1176
|
-
}, /* @__PURE__ */
|
|
1177
|
-
classNames: "
|
|
1108
|
+
className: mx("flex w-full pt-form-padding", classNames)
|
|
1109
|
+
}, /* @__PURE__ */ React4.createElement(IconButton, {
|
|
1110
|
+
classNames: "w-full",
|
|
1178
1111
|
type: "submit",
|
|
1179
1112
|
variant: "primary",
|
|
1180
|
-
disabled: !canSave,
|
|
1113
|
+
disabled: disabled ?? !canSave,
|
|
1181
1114
|
icon: icon ?? "ph--check--regular",
|
|
1182
1115
|
label: label ?? t("save button label"),
|
|
1183
1116
|
onClick: onSave,
|
|
1184
1117
|
"data-testid": "save-button"
|
|
1185
1118
|
}));
|
|
1186
1119
|
};
|
|
1187
|
-
FormSubmit.displayName =
|
|
1120
|
+
FormSubmit.displayName = FORM_SUBMIT_NAME;
|
|
1188
1121
|
var Form = {
|
|
1189
1122
|
Root: FormRoot,
|
|
1190
1123
|
Viewport: FormViewport,
|
|
1191
1124
|
Content: FormContent,
|
|
1192
1125
|
FieldSet: FormFieldSet2,
|
|
1126
|
+
Label: FormFieldLabel,
|
|
1193
1127
|
Actions: FormActions,
|
|
1194
|
-
Submit: FormSubmit
|
|
1195
|
-
Label: FormFieldLabel
|
|
1128
|
+
Submit: FormSubmit
|
|
1196
1129
|
};
|
|
1197
1130
|
|
|
1198
1131
|
// src/components/Form/fields/ArrayField.tsx
|
|
1199
1132
|
var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps, ...props }) => {
|
|
1200
|
-
const { t } =
|
|
1133
|
+
const { t } = useTranslation3(translationKey);
|
|
1201
1134
|
const elementType = getArrayElementType2(type);
|
|
1202
1135
|
const { onValueChange } = inputProps;
|
|
1203
1136
|
const values = useFormValues(ArrayField.displayName, path, () => []);
|
|
1204
1137
|
const getDefaultObjectValue = (typeNode) => {
|
|
1205
1138
|
const baseNode = findNode2(typeNode, isDiscriminatedUnion2);
|
|
1206
|
-
const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, {}) : findNode2(typeNode,
|
|
1139
|
+
const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, {}) : findNode2(typeNode, SchemaAST3.isTypeLiteral);
|
|
1207
1140
|
if (!typeLiteral) {
|
|
1208
1141
|
return {};
|
|
1209
1142
|
}
|
|
1210
1143
|
return Object.fromEntries(getFormProperties(typeLiteral).map((prop) => {
|
|
1211
|
-
const defaultValue =
|
|
1144
|
+
const defaultValue = SchemaAST3.getDefaultAnnotation(prop.type).pipe((annotation) => Option3.getOrUndefined(annotation));
|
|
1212
1145
|
return [
|
|
1213
1146
|
prop.name,
|
|
1214
1147
|
defaultValue
|
|
@@ -1237,19 +1170,19 @@ var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps,
|
|
|
1237
1170
|
if (!elementType || (readonly || layout === "static") && values && values.length < 1) {
|
|
1238
1171
|
return null;
|
|
1239
1172
|
}
|
|
1240
|
-
return /* @__PURE__ */
|
|
1173
|
+
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, (layout !== "static" || values && values.length > 0) && /* @__PURE__ */ React5.createElement(FormFieldLabel, {
|
|
1241
1174
|
readonly,
|
|
1242
1175
|
label,
|
|
1243
1176
|
asChild: true
|
|
1244
|
-
}), /* @__PURE__ */
|
|
1177
|
+
}), /* @__PURE__ */ React5.createElement("div", {
|
|
1245
1178
|
role: "none",
|
|
1246
1179
|
className: "flex flex-col gap-2"
|
|
1247
1180
|
}, values?.map((_, index) => {
|
|
1248
|
-
return /* @__PURE__ */
|
|
1181
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
1249
1182
|
role: "none",
|
|
1250
1183
|
key: index,
|
|
1251
1184
|
className: "grid grid-cols-[1fr_min-content] gap-2 last:mb-3"
|
|
1252
|
-
}, /* @__PURE__ */
|
|
1185
|
+
}, /* @__PURE__ */ React5.createElement(FormField, {
|
|
1253
1186
|
autoFocus: index === values.length - 1,
|
|
1254
1187
|
type: elementType,
|
|
1255
1188
|
path: [
|
|
@@ -1259,21 +1192,21 @@ var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps,
|
|
|
1259
1192
|
readonly: readonly || layout === "static",
|
|
1260
1193
|
layout: "inline",
|
|
1261
1194
|
...props
|
|
1262
|
-
}), !readonly && layout !== "static" && /* @__PURE__ */
|
|
1195
|
+
}), !readonly && layout !== "static" && /* @__PURE__ */ React5.createElement("div", {
|
|
1263
1196
|
role: "none",
|
|
1264
|
-
className: "flex flex-col
|
|
1265
|
-
}, /* @__PURE__ */
|
|
1197
|
+
className: "flex flex-col h-full justify-end"
|
|
1198
|
+
}, /* @__PURE__ */ React5.createElement("div", {
|
|
1266
1199
|
role: "none",
|
|
1267
|
-
className: "flex items-center
|
|
1268
|
-
}, /* @__PURE__ */
|
|
1200
|
+
className: "flex items-center h-[2rem]"
|
|
1201
|
+
}, /* @__PURE__ */ React5.createElement(IconButton2, {
|
|
1269
1202
|
icon: "ph--x--regular",
|
|
1270
1203
|
iconOnly: true,
|
|
1271
1204
|
label: t("button remove"),
|
|
1272
1205
|
onClick: () => handleDelete(index),
|
|
1273
1206
|
classNames: "self-center"
|
|
1274
1207
|
}))));
|
|
1275
|
-
})), !readonly && layout !== "static" && /* @__PURE__ */
|
|
1276
|
-
classNames: "flex
|
|
1208
|
+
})), !readonly && layout !== "static" && /* @__PURE__ */ React5.createElement(IconButton2, {
|
|
1209
|
+
classNames: "flex w-full",
|
|
1277
1210
|
icon: "ph--plus--regular",
|
|
1278
1211
|
label: t("add field"),
|
|
1279
1212
|
onClick: handleAdd
|
|
@@ -1291,6 +1224,9 @@ var getDefaultValue = (ast) => {
|
|
|
1291
1224
|
case "BooleanKeyword": {
|
|
1292
1225
|
return false;
|
|
1293
1226
|
}
|
|
1227
|
+
case "Suspend": {
|
|
1228
|
+
return getDefaultValue(ast.f());
|
|
1229
|
+
}
|
|
1294
1230
|
default: {
|
|
1295
1231
|
if (ast && isNestedType2(ast)) {
|
|
1296
1232
|
return {};
|
|
@@ -1302,17 +1238,17 @@ var getDefaultValue = (ast) => {
|
|
|
1302
1238
|
};
|
|
1303
1239
|
|
|
1304
1240
|
// src/components/Form/fields/BooleanField.tsx
|
|
1305
|
-
import
|
|
1306
|
-
import { Input as
|
|
1241
|
+
import React6, { useCallback as useCallback4 } from "react";
|
|
1242
|
+
import { Input as Input2 } from "@dxos/react-ui";
|
|
1307
1243
|
var BooleanField = ({ type, readonly, onValueChange, ...props }) => {
|
|
1308
1244
|
const handleChange = useCallback4((value3) => onValueChange?.(type, value3), [
|
|
1309
1245
|
type,
|
|
1310
1246
|
onValueChange
|
|
1311
1247
|
]);
|
|
1312
|
-
return /* @__PURE__ */
|
|
1248
|
+
return /* @__PURE__ */ React6.createElement(FormFieldWrapper, {
|
|
1313
1249
|
readonly,
|
|
1314
1250
|
...props
|
|
1315
|
-
}, ({ value: value3 }) => /* @__PURE__ */
|
|
1251
|
+
}, ({ value: value3 }) => /* @__PURE__ */ React6.createElement(Input2.Switch, {
|
|
1316
1252
|
disabled: !!readonly,
|
|
1317
1253
|
checked: value3,
|
|
1318
1254
|
onCheckedChange: handleChange
|
|
@@ -1320,12 +1256,12 @@ var BooleanField = ({ type, readonly, onValueChange, ...props }) => {
|
|
|
1320
1256
|
};
|
|
1321
1257
|
|
|
1322
1258
|
// src/components/Form/fields/GeoPointField.tsx
|
|
1323
|
-
import
|
|
1259
|
+
import React7, { useCallback as useCallback5, useEffect as useEffect4, useMemo as useMemo5, useState as useState2 } from "react";
|
|
1324
1260
|
import { GeoLocation as GeoLocation3 } from "@dxos/echo/internal";
|
|
1325
|
-
import { Input as
|
|
1261
|
+
import { Input as Input3, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
1326
1262
|
import { safeParseFloat } from "@dxos/util";
|
|
1327
1263
|
var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onValueChange, onBlur }) => {
|
|
1328
|
-
const { t } =
|
|
1264
|
+
const { t } = useTranslation4(translationKey);
|
|
1329
1265
|
const { status, error } = getStatus();
|
|
1330
1266
|
const geoPoint = useMemo5(() => getValue() ?? [
|
|
1331
1267
|
0,
|
|
@@ -1371,17 +1307,17 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
|
|
|
1371
1307
|
if ((readonly || layout === "static") && !value3?.latitude && !value3?.longitude) {
|
|
1372
1308
|
return null;
|
|
1373
1309
|
}
|
|
1374
|
-
return /* @__PURE__ */
|
|
1310
|
+
return /* @__PURE__ */ React7.createElement(Input3.Root, {
|
|
1375
1311
|
validationValence: status
|
|
1376
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
1312
|
+
}, layout !== "inline" && /* @__PURE__ */ React7.createElement(FormFieldLabel, {
|
|
1377
1313
|
error,
|
|
1378
1314
|
readonly,
|
|
1379
1315
|
label,
|
|
1380
1316
|
asChild: true
|
|
1381
|
-
}), layout === "static" ? /* @__PURE__ */
|
|
1317
|
+
}), layout === "static" ? /* @__PURE__ */ React7.createElement(LatLng, value3) : /* @__PURE__ */ React7.createElement("div", {
|
|
1382
1318
|
role: "none",
|
|
1383
1319
|
className: "grid grid-cols-2 gap-2"
|
|
1384
|
-
}, /* @__PURE__ */
|
|
1320
|
+
}, /* @__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
1321
|
type: "number",
|
|
1386
1322
|
step: "0.00001",
|
|
1387
1323
|
min: "-90",
|
|
@@ -1391,7 +1327,7 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
|
|
|
1391
1327
|
value: latitudeText ?? "",
|
|
1392
1328
|
onChange: handleChange("latitude", setLatitudeText),
|
|
1393
1329
|
onBlur
|
|
1394
|
-
}))), /* @__PURE__ */
|
|
1330
|
+
}))), /* @__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
1331
|
type: "number",
|
|
1396
1332
|
step: "0.00001",
|
|
1397
1333
|
min: "-180",
|
|
@@ -1406,18 +1342,18 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
|
|
|
1406
1342
|
var LatLng = ({ latitude = 0, longitude = 0 }) => {
|
|
1407
1343
|
const latHem = latitude >= 0 ? "N" : "S";
|
|
1408
1344
|
const lngHem = longitude >= 0 ? "E" : "W";
|
|
1409
|
-
return /* @__PURE__ */
|
|
1345
|
+
return /* @__PURE__ */ React7.createElement("span", {
|
|
1410
1346
|
className: "inline-flex items-center gap-1"
|
|
1411
|
-
}, /* @__PURE__ */
|
|
1347
|
+
}, /* @__PURE__ */ React7.createElement("span", null, /* @__PURE__ */ React7.createElement("span", null, Math.abs(latitude).toFixed(5)), /* @__PURE__ */ React7.createElement("span", {
|
|
1412
1348
|
className: "text-subdued"
|
|
1413
|
-
}, "\xB0", latHem)), /* @__PURE__ */
|
|
1349
|
+
}, "\xB0", latHem)), /* @__PURE__ */ React7.createElement("span", null, /* @__PURE__ */ React7.createElement("span", null, Math.abs(longitude).toFixed(5)), /* @__PURE__ */ React7.createElement("span", {
|
|
1414
1350
|
className: "text-subdued"
|
|
1415
1351
|
}, "\xB0", lngHem)));
|
|
1416
1352
|
};
|
|
1417
1353
|
|
|
1418
1354
|
// src/components/Form/fields/MarkdownField.tsx
|
|
1419
|
-
import
|
|
1420
|
-
import { Input as
|
|
1355
|
+
import React8, { useCallback as useCallback6, useEffect as useEffect5, useRef as useRef2 } from "react";
|
|
1356
|
+
import { Input as Input4 } from "@dxos/react-ui";
|
|
1421
1357
|
var MarkdownField = ({ type, readonly, label, placeholder, layout, getStatus, getValue, onValueChange, onBlur }) => {
|
|
1422
1358
|
const { status, error } = getStatus();
|
|
1423
1359
|
const textareaRef = useRef2(null);
|
|
@@ -1447,40 +1383,40 @@ var MarkdownField = ({ type, readonly, label, placeholder, layout, getStatus, ge
|
|
|
1447
1383
|
if ((readonly || layout === "static") && !value3) {
|
|
1448
1384
|
return null;
|
|
1449
1385
|
}
|
|
1450
|
-
return /* @__PURE__ */
|
|
1386
|
+
return /* @__PURE__ */ React8.createElement(Input4.Root, {
|
|
1451
1387
|
validationValence: status
|
|
1452
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
1388
|
+
}, layout !== "inline" && /* @__PURE__ */ React8.createElement(FormFieldLabel, {
|
|
1453
1389
|
error,
|
|
1454
1390
|
readonly,
|
|
1455
1391
|
label
|
|
1456
|
-
}), layout === "static" ? /* @__PURE__ */
|
|
1392
|
+
}), layout === "static" ? /* @__PURE__ */ React8.createElement("p", null, value3) : /* @__PURE__ */ React8.createElement(Input4.TextArea, {
|
|
1457
1393
|
ref: textareaRef,
|
|
1458
1394
|
disabled: !!readonly,
|
|
1459
1395
|
placeholder,
|
|
1460
1396
|
value: value3 ?? "",
|
|
1461
|
-
classNames: "min-
|
|
1397
|
+
classNames: "min-h-auto max-h-40 overflow-auto",
|
|
1462
1398
|
onChange: handleChange,
|
|
1463
1399
|
onBlur,
|
|
1464
1400
|
style: {
|
|
1465
1401
|
resize: "none"
|
|
1466
1402
|
},
|
|
1467
1403
|
spellCheck: false
|
|
1468
|
-
}), layout === "full" && /* @__PURE__ */
|
|
1404
|
+
}), layout === "full" && /* @__PURE__ */ React8.createElement(Input4.Validation, null, error));
|
|
1469
1405
|
};
|
|
1470
1406
|
|
|
1471
1407
|
// src/components/Form/fields/NumberField.tsx
|
|
1472
|
-
import
|
|
1473
|
-
import { Input as
|
|
1408
|
+
import React9, { useCallback as useCallback7 } from "react";
|
|
1409
|
+
import { Input as Input5 } from "@dxos/react-ui";
|
|
1474
1410
|
import { safeParseFloat as safeParseFloat2 } from "@dxos/util";
|
|
1475
1411
|
var NumberField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props }) => {
|
|
1476
1412
|
const handleChange = useCallback7((event) => onValueChange(type, safeParseFloat2(event.target.value) || 0), [
|
|
1477
1413
|
type,
|
|
1478
1414
|
onValueChange
|
|
1479
1415
|
]);
|
|
1480
|
-
return /* @__PURE__ */
|
|
1416
|
+
return /* @__PURE__ */ React9.createElement(FormFieldWrapper, {
|
|
1481
1417
|
readonly,
|
|
1482
1418
|
...props
|
|
1483
|
-
}, ({ value: value3 = "" }) => /* @__PURE__ */
|
|
1419
|
+
}, ({ value: value3 = "" }) => /* @__PURE__ */ React9.createElement(Input5.TextInput, {
|
|
1484
1420
|
type: "number",
|
|
1485
1421
|
disabled: !!readonly,
|
|
1486
1422
|
placeholder,
|
|
@@ -1492,24 +1428,25 @@ var NumberField = ({ type, readonly, placeholder, onValueChange, onBlur, ...prop
|
|
|
1492
1428
|
|
|
1493
1429
|
// src/components/Form/fields/RefField.tsx
|
|
1494
1430
|
import "@dxos/lit-ui/dx-tag-picker.pcss";
|
|
1495
|
-
import
|
|
1496
|
-
import { Entity, Filter, Ref as Ref2 } from "@dxos/echo";
|
|
1431
|
+
import React11, { useCallback as useCallback9, useMemo as useMemo6 } from "react";
|
|
1432
|
+
import { Entity, Filter, Obj, Ref as Ref2, Type } from "@dxos/echo";
|
|
1497
1433
|
import { ReferenceAnnotationId } from "@dxos/echo/internal";
|
|
1498
1434
|
import { useQuery, useSchema as useSchema$ } from "@dxos/echo-react";
|
|
1499
1435
|
import { findAnnotation } from "@dxos/effect";
|
|
1500
1436
|
import { DXN } from "@dxos/keys";
|
|
1501
1437
|
import { DxAnchor } from "@dxos/lit-ui/react";
|
|
1502
|
-
import { Button
|
|
1503
|
-
import {
|
|
1438
|
+
import { Button, Icon as Icon2, Input as Input6, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
1439
|
+
import { ParentLabelAnnotationId } from "@dxos/schema";
|
|
1440
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
1504
1441
|
|
|
1505
1442
|
// src/components/ObjectPicker/ObjectPicker.tsx
|
|
1506
|
-
import
|
|
1507
|
-
import { Popover, useTranslation as
|
|
1443
|
+
import React10, { forwardRef, useCallback as useCallback8, useState as useState3 } from "react";
|
|
1444
|
+
import { Popover, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
1508
1445
|
import { Combobox, useSearchListInput, useSearchListResults } from "@dxos/react-ui-searchlist";
|
|
1509
1446
|
var CreateItem = ({ createOptionLabel, createOptionIcon, onCreateItemSelect }) => {
|
|
1510
|
-
const { t } =
|
|
1447
|
+
const { t } = useTranslation5(translationKey);
|
|
1511
1448
|
const { query } = useSearchListInput();
|
|
1512
|
-
return /* @__PURE__ */
|
|
1449
|
+
return /* @__PURE__ */ React10.createElement(Combobox.Item, {
|
|
1513
1450
|
value: "__create__",
|
|
1514
1451
|
label: t(createOptionLabel[0], {
|
|
1515
1452
|
ns: createOptionLabel[1].ns,
|
|
@@ -1523,8 +1460,8 @@ var CreateItem = ({ createOptionLabel, createOptionIcon, onCreateItemSelect }) =
|
|
|
1523
1460
|
}
|
|
1524
1461
|
});
|
|
1525
1462
|
};
|
|
1526
|
-
var ObjectPickerContent = /* @__PURE__ */
|
|
1527
|
-
const { t } =
|
|
1463
|
+
var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, createSchema, createOptionLabel, createOptionIcon, createInitialValuePath, onSelect, onCreate, ...props }, ref) => {
|
|
1464
|
+
const { t } = useTranslation5(translationKey);
|
|
1528
1465
|
const [showForm, setShowForm] = useState3(false);
|
|
1529
1466
|
const [formInitialValue, setFormInitialValue] = useState3("");
|
|
1530
1467
|
const { results, handleSearch } = useSearchListResults({
|
|
@@ -1553,12 +1490,12 @@ var ObjectPickerContent = /* @__PURE__ */ forwardRef2(({ options, selectedIds, c
|
|
|
1553
1490
|
}, [
|
|
1554
1491
|
createSchema
|
|
1555
1492
|
]);
|
|
1556
|
-
return /* @__PURE__ */
|
|
1493
|
+
return /* @__PURE__ */ React10.createElement(Combobox.Content, {
|
|
1557
1494
|
...props,
|
|
1558
1495
|
ref,
|
|
1559
1496
|
onSearch: handleSearch,
|
|
1560
1497
|
onKeyDownCapture: handleKeyDown
|
|
1561
|
-
}, showForm && createSchema ? /* @__PURE__ */
|
|
1498
|
+
}, showForm && createSchema ? /* @__PURE__ */ React10.createElement(Popover.Viewport, null, /* @__PURE__ */ React10.createElement(Form.Root, {
|
|
1562
1499
|
testId: "create-referenced-object-form",
|
|
1563
1500
|
schema: createSchema,
|
|
1564
1501
|
values: createInitialValuePath ? {
|
|
@@ -1566,24 +1503,24 @@ var ObjectPickerContent = /* @__PURE__ */ forwardRef2(({ options, selectedIds, c
|
|
|
1566
1503
|
} : {},
|
|
1567
1504
|
onSave: handleFormSave,
|
|
1568
1505
|
onCancel: handleFormCancel
|
|
1569
|
-
}, /* @__PURE__ */
|
|
1506
|
+
}, /* @__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
1507
|
placeholder: t("ref field combobox input placeholder"),
|
|
1571
1508
|
autoFocus: true
|
|
1572
|
-
}), /* @__PURE__ */
|
|
1509
|
+
}), /* @__PURE__ */ React10.createElement(Combobox.List, null, results.map((option) => /* @__PURE__ */ React10.createElement(Combobox.Item, {
|
|
1573
1510
|
key: option.id,
|
|
1574
1511
|
value: option.id,
|
|
1575
1512
|
label: option.label,
|
|
1576
1513
|
checked: selectedIds?.includes(option.id),
|
|
1577
1514
|
onSelect: () => onSelect(option.id),
|
|
1578
1515
|
classNames: "flex items-center gap-2"
|
|
1579
|
-
})), createOptionLabel && createOptionIcon && createSchema && onCreate && /* @__PURE__ */
|
|
1516
|
+
})), createOptionLabel && createOptionIcon && createSchema && onCreate && /* @__PURE__ */ React10.createElement(CreateItem, {
|
|
1580
1517
|
createOptionLabel,
|
|
1581
1518
|
createOptionIcon,
|
|
1582
1519
|
onCreateItemSelect: (query) => {
|
|
1583
1520
|
setFormInitialValue(query);
|
|
1584
1521
|
setShowForm(true);
|
|
1585
1522
|
}
|
|
1586
|
-
}))), /* @__PURE__ */
|
|
1523
|
+
}))), /* @__PURE__ */ React10.createElement(Combobox.Arrow, null));
|
|
1587
1524
|
});
|
|
1588
1525
|
ObjectPickerContent.displayName = "ObjectPickerContent";
|
|
1589
1526
|
var ObjectPicker = {
|
|
@@ -1598,26 +1535,33 @@ var ObjectPicker = {
|
|
|
1598
1535
|
var isRefSnapshot = (val) => {
|
|
1599
1536
|
return typeof val === "object" && typeof val?.["/"] === "string";
|
|
1600
1537
|
};
|
|
1601
|
-
var defaultGetOptions = (results) => results.map((result) => {
|
|
1538
|
+
var defaultGetOptions = (results, { parentLabel } = {}) => results.map((result) => {
|
|
1602
1539
|
const id = Entity.getDXN(result).toString();
|
|
1603
|
-
const
|
|
1540
|
+
const parent = parentLabel ? Obj.getParent(result) : void 0;
|
|
1541
|
+
const label = parent ? Entity.getLabel(parent) : Entity.getLabel(result);
|
|
1604
1542
|
return {
|
|
1605
1543
|
id,
|
|
1606
1544
|
label: label ?? id
|
|
1607
1545
|
};
|
|
1608
1546
|
});
|
|
1609
|
-
var defaultResultsHook = (db, typename) => useQuery(db, typename ? Filter.typename(typename) : Filter.nothing());
|
|
1547
|
+
var defaultResultsHook = (db, typename) => useQuery(db, typename ? typename === Type.getTypename(Obj.Unknown) ? Filter.everything() : Filter.typename(typename) : Filter.nothing());
|
|
1610
1548
|
var RefField = (props) => {
|
|
1611
1549
|
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 } =
|
|
1550
|
+
const { t } = useTranslation6(translationKey);
|
|
1613
1551
|
const { status, error } = getStatus();
|
|
1614
1552
|
const typename = useMemo6(() => type ? findAnnotation(type, ReferenceAnnotationId)?.typename : void 0, [
|
|
1615
1553
|
type
|
|
1616
1554
|
]);
|
|
1617
1555
|
const results = useResults(db, typename);
|
|
1618
|
-
const options = useMemo6(() =>
|
|
1556
|
+
const options = useMemo6(() => {
|
|
1557
|
+
const parentLabel = type ? findAnnotation(type, ParentLabelAnnotationId) === true : false;
|
|
1558
|
+
return getOptions2(results, {
|
|
1559
|
+
parentLabel
|
|
1560
|
+
});
|
|
1561
|
+
}, [
|
|
1619
1562
|
results,
|
|
1620
|
-
getOptions2
|
|
1563
|
+
getOptions2,
|
|
1564
|
+
type
|
|
1621
1565
|
]);
|
|
1622
1566
|
const handleGetValue = useCallback9(() => {
|
|
1623
1567
|
const formValue = getValue();
|
|
@@ -1674,41 +1618,41 @@ var RefField = (props) => {
|
|
|
1674
1618
|
if (!typename || (readonly || layout === "static") && !item) {
|
|
1675
1619
|
return null;
|
|
1676
1620
|
}
|
|
1677
|
-
return /* @__PURE__ */
|
|
1621
|
+
return /* @__PURE__ */ React11.createElement(Input6.Root, {
|
|
1678
1622
|
validationValence: status
|
|
1679
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
1623
|
+
}, layout !== "inline" && /* @__PURE__ */ React11.createElement(FormFieldLabel, {
|
|
1680
1624
|
error,
|
|
1681
1625
|
readonly,
|
|
1682
1626
|
label
|
|
1683
|
-
}), /* @__PURE__ */
|
|
1684
|
-
className:
|
|
1685
|
-
}, t("empty readonly ref field label")) : /* @__PURE__ */
|
|
1627
|
+
}), /* @__PURE__ */ React11.createElement("div", null, readonly ? !item ? /* @__PURE__ */ React11.createElement("p", {
|
|
1628
|
+
className: mx2("text-description", "mb-2")
|
|
1629
|
+
}, t("empty readonly ref field label")) : /* @__PURE__ */ React11.createElement(DxAnchor, {
|
|
1686
1630
|
key: item.id,
|
|
1687
|
-
|
|
1688
|
-
rootclassname: "
|
|
1689
|
-
}, item.label) : /* @__PURE__ */
|
|
1631
|
+
dxn: item.id,
|
|
1632
|
+
rootclassname: "me-1"
|
|
1633
|
+
}, item.label) : /* @__PURE__ */ React11.createElement(ObjectPicker.Root, null, /* @__PURE__ */ React11.createElement(ObjectPicker.Trigger, {
|
|
1690
1634
|
asChild: true,
|
|
1691
1635
|
classNames: "p-0"
|
|
1692
|
-
}, item ? /* @__PURE__ */
|
|
1693
|
-
className: "flex gap-2
|
|
1694
|
-
}, /* @__PURE__ */
|
|
1636
|
+
}, item ? /* @__PURE__ */ React11.createElement("div", {
|
|
1637
|
+
className: "flex gap-2 w-full"
|
|
1638
|
+
}, /* @__PURE__ */ React11.createElement(Input6.Root, {
|
|
1695
1639
|
key: item.id
|
|
1696
|
-
}, /* @__PURE__ */
|
|
1640
|
+
}, /* @__PURE__ */ React11.createElement(Input6.TextInput, {
|
|
1697
1641
|
value: item.label,
|
|
1698
1642
|
readOnly: true,
|
|
1699
|
-
classNames: "
|
|
1700
|
-
}))) : /* @__PURE__ */
|
|
1701
|
-
classNames: "
|
|
1702
|
-
}, /* @__PURE__ */
|
|
1643
|
+
classNames: "w-full"
|
|
1644
|
+
}))) : /* @__PURE__ */ React11.createElement(Button, {
|
|
1645
|
+
classNames: "w-full text-start gap-2"
|
|
1646
|
+
}, /* @__PURE__ */ React11.createElement("div", {
|
|
1703
1647
|
role: "none",
|
|
1704
1648
|
className: "grow overflow-hidden"
|
|
1705
|
-
}, /* @__PURE__ */
|
|
1649
|
+
}, /* @__PURE__ */ React11.createElement("span", {
|
|
1706
1650
|
className: "flex truncate text-description"
|
|
1707
|
-
}, placeholder ?? t("ref field placeholder"))), /* @__PURE__ */
|
|
1651
|
+
}, placeholder ?? t("ref field placeholder"))), /* @__PURE__ */ React11.createElement(Icon2, {
|
|
1708
1652
|
size: 3,
|
|
1709
1653
|
icon: "ph--caret-down--bold"
|
|
1710
|
-
}))), /* @__PURE__ */
|
|
1711
|
-
classNames: "
|
|
1654
|
+
}))), /* @__PURE__ */ React11.createElement(ObjectPicker.Portal, null, /* @__PURE__ */ React11.createElement(ObjectPicker.Content, {
|
|
1655
|
+
classNames: "dx-card-popover-width",
|
|
1712
1656
|
options,
|
|
1713
1657
|
selectedIds,
|
|
1714
1658
|
createSchema: createSchema && omitId(createSchema),
|
|
@@ -1717,12 +1661,12 @@ var RefField = (props) => {
|
|
|
1717
1661
|
createInitialValuePath,
|
|
1718
1662
|
onCreate: handleCreate,
|
|
1719
1663
|
onSelect: handleSelect
|
|
1720
|
-
})))), layout === "full" && /* @__PURE__ */
|
|
1664
|
+
})))), layout === "full" && /* @__PURE__ */ React11.createElement(Input6.DescriptionAndValidation, null, error));
|
|
1721
1665
|
};
|
|
1722
1666
|
|
|
1723
1667
|
// src/components/Form/fields/SelectField.tsx
|
|
1724
|
-
import
|
|
1725
|
-
import { Input as
|
|
1668
|
+
import React12, { useCallback as useCallback10 } from "react";
|
|
1669
|
+
import { Input as Input7, Select } from "@dxos/react-ui";
|
|
1726
1670
|
var SelectField = ({ type, readonly, label, layout, placeholder, options, getStatus, getValue, onValueChange }) => {
|
|
1727
1671
|
const { status, error } = getStatus();
|
|
1728
1672
|
const value3 = getValue();
|
|
@@ -1733,37 +1677,37 @@ var SelectField = ({ type, readonly, label, layout, placeholder, options, getSta
|
|
|
1733
1677
|
if ((readonly || layout === "static") && value3 == null) {
|
|
1734
1678
|
return null;
|
|
1735
1679
|
}
|
|
1736
|
-
return /* @__PURE__ */
|
|
1680
|
+
return /* @__PURE__ */ React12.createElement(Input7.Root, {
|
|
1737
1681
|
validationValence: status
|
|
1738
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
1682
|
+
}, layout !== "inline" && /* @__PURE__ */ React12.createElement(FormFieldLabel, {
|
|
1739
1683
|
error,
|
|
1740
1684
|
readonly,
|
|
1741
1685
|
label
|
|
1742
|
-
}), layout === "static" ? /* @__PURE__ */
|
|
1686
|
+
}), layout === "static" ? /* @__PURE__ */ React12.createElement("p", null, options?.find(({ value: optionValue }) => optionValue === value3)?.label ?? String(value3)) : /* @__PURE__ */ React12.createElement(Select.Root, {
|
|
1743
1687
|
value: value3,
|
|
1744
1688
|
onValueChange: handleValueChange
|
|
1745
|
-
}, /* @__PURE__ */
|
|
1746
|
-
classNames: "
|
|
1689
|
+
}, /* @__PURE__ */ React12.createElement(Select.TriggerButton, {
|
|
1690
|
+
classNames: "w-full",
|
|
1747
1691
|
disabled: !!readonly,
|
|
1748
1692
|
placeholder
|
|
1749
|
-
}), /* @__PURE__ */
|
|
1693
|
+
}), /* @__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
1694
|
// NOTE: Numeric values are converted to and from strings.
|
|
1751
|
-
/* @__PURE__ */
|
|
1695
|
+
/* @__PURE__ */ React12.createElement(Select.Option, {
|
|
1752
1696
|
key: String(value4),
|
|
1753
1697
|
value: String(value4)
|
|
1754
1698
|
}, label2 ?? String(value4))
|
|
1755
|
-
))), /* @__PURE__ */
|
|
1699
|
+
))), /* @__PURE__ */ React12.createElement(Select.Arrow, null)))), layout === "full" && /* @__PURE__ */ React12.createElement(Input7.DescriptionAndValidation, null, error));
|
|
1756
1700
|
};
|
|
1757
1701
|
|
|
1758
1702
|
// src/components/Form/fields/SelectOptionField.tsx
|
|
1759
|
-
import
|
|
1703
|
+
import React13, { useCallback as useCallback11, useEffect as useEffect6, useRef as useRef3, useState as useState4 } from "react";
|
|
1760
1704
|
import { PublicKey } from "@dxos/keys";
|
|
1761
|
-
import { IconButton as IconButton3, Input as
|
|
1705
|
+
import { IconButton as IconButton3, Input as Input8, Tag, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
1762
1706
|
import { List } from "@dxos/react-ui-list";
|
|
1763
1707
|
import { HuePicker } from "@dxos/react-ui-pickers";
|
|
1764
1708
|
import { hues, osTranslations, subtleHover } from "@dxos/ui-theme";
|
|
1765
1709
|
var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueChange }) => {
|
|
1766
|
-
const { t } =
|
|
1710
|
+
const { t } = useTranslation7(translationKey);
|
|
1767
1711
|
const { status, error } = getStatus();
|
|
1768
1712
|
const [selected, setSelectedId] = useState4(null);
|
|
1769
1713
|
const [isNewOption, setIsNewOption] = useState4(false);
|
|
@@ -1869,42 +1813,42 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
1869
1813
|
selected,
|
|
1870
1814
|
isNewOption
|
|
1871
1815
|
]);
|
|
1872
|
-
return /* @__PURE__ */
|
|
1816
|
+
return /* @__PURE__ */ React13.createElement(Input8.Root, {
|
|
1873
1817
|
validationValence: status
|
|
1874
|
-
}, /* @__PURE__ */
|
|
1818
|
+
}, /* @__PURE__ */ React13.createElement(FormFieldLabel, {
|
|
1875
1819
|
error,
|
|
1876
1820
|
readonly,
|
|
1877
1821
|
label
|
|
1878
|
-
}), /* @__PURE__ */
|
|
1822
|
+
}), /* @__PURE__ */ React13.createElement("div", {
|
|
1879
1823
|
role: "none"
|
|
1880
|
-
}, options && /* @__PURE__ */
|
|
1824
|
+
}, options && /* @__PURE__ */ React13.createElement(List.Root, {
|
|
1881
1825
|
items: options,
|
|
1882
1826
|
isItem: (_item) => true,
|
|
1883
1827
|
onMove: readonly ? void 0 : handleMove,
|
|
1884
1828
|
readonly: !!readonly
|
|
1885
|
-
}, ({ items }) => /* @__PURE__ */
|
|
1829
|
+
}, ({ items }) => /* @__PURE__ */ React13.createElement("div", {
|
|
1886
1830
|
role: "list",
|
|
1887
|
-
className: "
|
|
1888
|
-
}, items?.map((item) => /* @__PURE__ */
|
|
1831
|
+
className: "w-full overflow-auto"
|
|
1832
|
+
}, items?.map((item) => /* @__PURE__ */ React13.createElement("div", {
|
|
1889
1833
|
key: item.id
|
|
1890
|
-
}, /* @__PURE__ */
|
|
1834
|
+
}, /* @__PURE__ */ React13.createElement(List.Item, {
|
|
1891
1835
|
role: "button",
|
|
1892
1836
|
item,
|
|
1893
1837
|
classNames: [
|
|
1894
1838
|
subtleHover,
|
|
1895
|
-
"flex flex-col cursor-pointer rounded-
|
|
1839
|
+
"flex flex-col cursor-pointer rounded-xs"
|
|
1896
1840
|
],
|
|
1897
1841
|
"aria-expanded": selected === item.id
|
|
1898
|
-
}, /* @__PURE__ */
|
|
1842
|
+
}, /* @__PURE__ */ React13.createElement("div", {
|
|
1899
1843
|
className: "flex items-center"
|
|
1900
|
-
}, /* @__PURE__ */
|
|
1844
|
+
}, /* @__PURE__ */ React13.createElement(List.ItemDragHandle, {
|
|
1901
1845
|
disabled: !!readonly
|
|
1902
|
-
}), /* @__PURE__ */
|
|
1846
|
+
}), /* @__PURE__ */ React13.createElement(List.ItemTitle, {
|
|
1903
1847
|
onClick: () => handleClick(item.id),
|
|
1904
1848
|
classNames: "flex-1"
|
|
1905
|
-
}, /* @__PURE__ */
|
|
1849
|
+
}, /* @__PURE__ */ React13.createElement(Tag, {
|
|
1906
1850
|
palette: item.color
|
|
1907
|
-
}, item.title || "\u200B")), /* @__PURE__ */
|
|
1851
|
+
}, item.title || "\u200B")), /* @__PURE__ */ React13.createElement(IconButton3, {
|
|
1908
1852
|
iconOnly: true,
|
|
1909
1853
|
variant: "ghost",
|
|
1910
1854
|
label: t(selected === item.id ? "collapse label" : "expand label", {
|
|
@@ -1912,13 +1856,13 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
1912
1856
|
}),
|
|
1913
1857
|
icon: selected === item.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
|
|
1914
1858
|
onClick: () => handleClick(item.id)
|
|
1915
|
-
})), selected === item.id && /* @__PURE__ */
|
|
1916
|
-
className: "
|
|
1917
|
-
}, /* @__PURE__ */
|
|
1859
|
+
})), selected === item.id && /* @__PURE__ */ React13.createElement("div", {
|
|
1860
|
+
className: "flex flex-col p-form-padding gap-1 dx-density-fine"
|
|
1861
|
+
}, /* @__PURE__ */ React13.createElement(Input8.Label, {
|
|
1918
1862
|
classNames: "text-xs"
|
|
1919
|
-
}, t("select option label")), /* @__PURE__ */
|
|
1863
|
+
}, t("select option label")), /* @__PURE__ */ React13.createElement("div", {
|
|
1920
1864
|
className: "grid grid-cols-[1fr_min-content_min-content] gap-1"
|
|
1921
|
-
}, /* @__PURE__ */
|
|
1865
|
+
}, /* @__PURE__ */ React13.createElement(Input8.TextInput, {
|
|
1922
1866
|
disabled: !!readonly,
|
|
1923
1867
|
placeholder: t("select option label placeholder"),
|
|
1924
1868
|
ref: selected === item.id ? inputRef : void 0,
|
|
@@ -1926,38 +1870,38 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
1926
1870
|
onChange: handleTitleChange(item.id),
|
|
1927
1871
|
onKeyDown: handleKeyDown,
|
|
1928
1872
|
classNames: "flex-1"
|
|
1929
|
-
}), /* @__PURE__ */
|
|
1873
|
+
}), /* @__PURE__ */ React13.createElement(HuePicker, {
|
|
1930
1874
|
disabled: !!readonly,
|
|
1931
1875
|
value: item.color,
|
|
1932
1876
|
onChange: handleColorChange(item.id)
|
|
1933
|
-
}), /* @__PURE__ */
|
|
1877
|
+
}), /* @__PURE__ */ React13.createElement(IconButton3, {
|
|
1934
1878
|
disabled: !!readonly,
|
|
1935
1879
|
icon: "ph--trash--fill",
|
|
1936
1880
|
iconOnly: true,
|
|
1937
1881
|
label: t("select option delete"),
|
|
1938
1882
|
onClick: () => handleDelete(item.id)
|
|
1939
|
-
})))))), /* @__PURE__ */
|
|
1883
|
+
})))))), /* @__PURE__ */ React13.createElement(IconButton3, {
|
|
1940
1884
|
variant: "ghost",
|
|
1941
1885
|
icon: "ph--plus--regular",
|
|
1942
1886
|
label: t("select option add"),
|
|
1943
1887
|
onClick: handleAdd,
|
|
1944
1888
|
disabled: !!readonly,
|
|
1945
|
-
classNames: "
|
|
1889
|
+
classNames: "w-full"
|
|
1946
1890
|
})))));
|
|
1947
1891
|
};
|
|
1948
1892
|
|
|
1949
1893
|
// src/components/Form/fields/TextField.tsx
|
|
1950
|
-
import
|
|
1951
|
-
import { Input as
|
|
1894
|
+
import React14, { useCallback as useCallback12 } from "react";
|
|
1895
|
+
import { Input as Input9 } from "@dxos/react-ui";
|
|
1952
1896
|
var TextField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props }) => {
|
|
1953
1897
|
const handleChange = useCallback12((event) => onValueChange(type, event.target.value), [
|
|
1954
1898
|
type,
|
|
1955
1899
|
onValueChange
|
|
1956
1900
|
]);
|
|
1957
|
-
return /* @__PURE__ */
|
|
1901
|
+
return /* @__PURE__ */ React14.createElement(FormFieldWrapper, {
|
|
1958
1902
|
readonly,
|
|
1959
1903
|
...props
|
|
1960
|
-
}, ({ value: value3 = "" }) => /* @__PURE__ */
|
|
1904
|
+
}, ({ value: value3 = "" }) => /* @__PURE__ */ React14.createElement(Input9.TextInput, {
|
|
1961
1905
|
noAutoFill: true,
|
|
1962
1906
|
disabled: !!readonly,
|
|
1963
1907
|
placeholder,
|
|
@@ -1968,17 +1912,17 @@ var TextField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props
|
|
|
1968
1912
|
};
|
|
1969
1913
|
|
|
1970
1914
|
// src/components/Form/fields/TextAreaField.tsx
|
|
1971
|
-
import
|
|
1972
|
-
import { Input as
|
|
1915
|
+
import React15, { useCallback as useCallback13 } from "react";
|
|
1916
|
+
import { Input as Input10 } from "@dxos/react-ui";
|
|
1973
1917
|
var TextAreaField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props }) => {
|
|
1974
1918
|
const handleChange = useCallback13((event) => onValueChange(type, event.target.value), [
|
|
1975
1919
|
type,
|
|
1976
1920
|
onValueChange
|
|
1977
1921
|
]);
|
|
1978
|
-
return /* @__PURE__ */
|
|
1922
|
+
return /* @__PURE__ */ React15.createElement(FormFieldWrapper, {
|
|
1979
1923
|
readonly,
|
|
1980
1924
|
...props
|
|
1981
|
-
}, ({ value: value3 = "" }) => /* @__PURE__ */
|
|
1925
|
+
}, ({ value: value3 = "" }) => /* @__PURE__ */ React15.createElement(Input10.TextArea, {
|
|
1982
1926
|
rows: 3,
|
|
1983
1927
|
disabled: !!readonly,
|
|
1984
1928
|
placeholder,
|
|
@@ -1989,9 +1933,9 @@ var TextAreaField = ({ type, readonly, placeholder, onValueChange, onBlur, ...pr
|
|
|
1989
1933
|
};
|
|
1990
1934
|
|
|
1991
1935
|
// src/components/Form/fields/TupleField.tsx
|
|
1992
|
-
import
|
|
1993
|
-
import { Input as
|
|
1994
|
-
import { mx as
|
|
1936
|
+
import React16 from "react";
|
|
1937
|
+
import { Input as Input11 } from "@dxos/react-ui";
|
|
1938
|
+
import { mx as mx3 } from "@dxos/ui-theme";
|
|
1995
1939
|
import { safeParseFloat as safeParseFloat3 } from "@dxos/util";
|
|
1996
1940
|
var gridCols = [
|
|
1997
1941
|
"grid-cols-1",
|
|
@@ -2002,15 +1946,15 @@ var gridCols = [
|
|
|
2002
1946
|
var TupleField = ({ binding, type, readonly, label, getStatus, getValue, onValueChange, onBlur }) => {
|
|
2003
1947
|
const { status, error } = getStatus();
|
|
2004
1948
|
const values = getValue() ?? {};
|
|
2005
|
-
return /* @__PURE__ */
|
|
1949
|
+
return /* @__PURE__ */ React16.createElement(Input11.Root, {
|
|
2006
1950
|
validationValence: status
|
|
2007
|
-
}, /* @__PURE__ */
|
|
1951
|
+
}, /* @__PURE__ */ React16.createElement(FormFieldLabel, {
|
|
2008
1952
|
error,
|
|
2009
1953
|
readonly,
|
|
2010
1954
|
label
|
|
2011
|
-
}), /* @__PURE__ */
|
|
2012
|
-
className:
|
|
2013
|
-
}, binding.map((prop) => /* @__PURE__ */
|
|
1955
|
+
}), /* @__PURE__ */ React16.createElement("div", {
|
|
1956
|
+
className: mx3("grid gap-2", gridCols[binding.length - 1])
|
|
1957
|
+
}, binding.map((prop) => /* @__PURE__ */ React16.createElement(Input11.TextInput, {
|
|
2014
1958
|
key: prop,
|
|
2015
1959
|
type: "number",
|
|
2016
1960
|
disabled: !!readonly,
|
|
@@ -2028,7 +1972,7 @@ var TupleField = ({ binding, type, readonly, label, getStatus, getValue, onValue
|
|
|
2028
1972
|
// src/components/FieldEditor/FieldEditor.tsx
|
|
2029
1973
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
|
|
2030
1974
|
var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCancel }) => {
|
|
2031
|
-
const { t } =
|
|
1975
|
+
const { t } = useTranslation8(translationKey);
|
|
2032
1976
|
const [props, setProps] = useState5(projection.getFieldProjection(field.id).props);
|
|
2033
1977
|
useEffect7(() => setProps(projection.getFieldProjection(field.id).props), [
|
|
2034
1978
|
field,
|
|
@@ -2059,26 +2003,26 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2059
2003
|
fieldSchema: getFormatSchema(props?.format)
|
|
2060
2004
|
});
|
|
2061
2005
|
const fieldMap = useMemo7(() => ({
|
|
2062
|
-
["format"]: (props2) => /* @__PURE__ */
|
|
2006
|
+
["format"]: (props2) => /* @__PURE__ */ React17.createElement(SelectField, {
|
|
2063
2007
|
...props2,
|
|
2064
2008
|
options: FormatEnums.filter((value3) => value3 !== Format4.TypeFormat.None).map((value3) => ({
|
|
2065
2009
|
value: value3,
|
|
2066
2010
|
label: t(`format ${value3}`)
|
|
2067
2011
|
}))
|
|
2068
2012
|
}),
|
|
2069
|
-
["referenceSchema"]: (props2) => /* @__PURE__ */
|
|
2013
|
+
["referenceSchema"]: (props2) => /* @__PURE__ */ React17.createElement(SelectField, {
|
|
2070
2014
|
...props2,
|
|
2071
2015
|
options: schemas.map((schema) => ({
|
|
2072
2016
|
value: schema.typename
|
|
2073
2017
|
}))
|
|
2074
2018
|
}),
|
|
2075
|
-
["referencePath"]: (props2) => /* @__PURE__ */
|
|
2019
|
+
["referencePath"]: (props2) => /* @__PURE__ */ React17.createElement(SelectField, {
|
|
2076
2020
|
...props2,
|
|
2077
2021
|
options: referenceSchema ? getFormProperties(referenceSchema.ast).sort((a, b) => a.name.toString().localeCompare(b.name.toString())).map((p) => ({
|
|
2078
2022
|
value: p.name.toString()
|
|
2079
2023
|
})) : []
|
|
2080
2024
|
}),
|
|
2081
|
-
["options"]: (props2) => /* @__PURE__ */
|
|
2025
|
+
["options"]: (props2) => /* @__PURE__ */ React17.createElement(SelectOptionField, props2)
|
|
2082
2026
|
}), [
|
|
2083
2027
|
t,
|
|
2084
2028
|
schemas,
|
|
@@ -2137,7 +2081,7 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2137
2081
|
]);
|
|
2138
2082
|
const handleSave = useCallback14((props2) => {
|
|
2139
2083
|
if (view) {
|
|
2140
|
-
|
|
2084
|
+
Obj2.change(view, () => {
|
|
2141
2085
|
projection.setFieldProjection({
|
|
2142
2086
|
field,
|
|
2143
2087
|
props: props2
|
|
@@ -2167,13 +2111,13 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2167
2111
|
props
|
|
2168
2112
|
}, {
|
|
2169
2113
|
F: __dxlog_file2,
|
|
2170
|
-
L:
|
|
2114
|
+
L: 172,
|
|
2171
2115
|
S: void 0,
|
|
2172
2116
|
C: (f, a) => f(...a)
|
|
2173
2117
|
});
|
|
2174
2118
|
return null;
|
|
2175
2119
|
}
|
|
2176
|
-
return /* @__PURE__ */
|
|
2120
|
+
return /* @__PURE__ */ React17.createElement(Form.Root, {
|
|
2177
2121
|
key: field.id,
|
|
2178
2122
|
fieldMap,
|
|
2179
2123
|
autoFocus: true,
|
|
@@ -2189,7 +2133,139 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2189
2133
|
onValidate: handleValidate,
|
|
2190
2134
|
onSave: handleSave,
|
|
2191
2135
|
onCancel: handleCancel
|
|
2192
|
-
}, /* @__PURE__ */
|
|
2136
|
+
}, /* @__PURE__ */ React17.createElement(Form.Content, null, /* @__PURE__ */ React17.createElement(Form.FieldSet, null), /* @__PURE__ */ React17.createElement(Form.Actions, null)));
|
|
2137
|
+
};
|
|
2138
|
+
|
|
2139
|
+
// src/components/Settings/Settings.tsx
|
|
2140
|
+
import React18 from "react";
|
|
2141
|
+
import { Button as Button2, Input as Input12, ScrollArea as ScrollArea2, toLocalizedString, useTranslation as useTranslation9 } from "@dxos/react-ui";
|
|
2142
|
+
import { mx as mx4 } from "@dxos/ui-theme";
|
|
2143
|
+
var SETTINGS_ROOT_NAME = "Settings.Root";
|
|
2144
|
+
var SETTINGS_SECTION_NAME = "Settings.Section";
|
|
2145
|
+
var SETTINGS_SECTION_HEADING_NAME = "Settings.SectionHeading";
|
|
2146
|
+
var SETTINGS_GROUP_NAME = "Settings.Group";
|
|
2147
|
+
var SETTINGS_GROUP_BUTTON_NAME = "Settings.GroupButton";
|
|
2148
|
+
var SETTINGS_CONTAINER_NAME = "Settings.Container";
|
|
2149
|
+
var SETTINGS_FRAME_NAME = "Settings.Frame";
|
|
2150
|
+
var SETTINGS_FRAME_ITEM_NAME = "Settings.FrameItem";
|
|
2151
|
+
var SETTINGS_ITEM_NAME = "Settings.Item";
|
|
2152
|
+
var SETTINGS_ITEM_INPUT_NAME = "Settings.ItemInput";
|
|
2153
|
+
var styles = {
|
|
2154
|
+
title: "pb-trim-md text-base-surface-text text-lg",
|
|
2155
|
+
description: "text-base text-description",
|
|
2156
|
+
grid: "grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-x-trim-lg"
|
|
2157
|
+
};
|
|
2158
|
+
var SettingsRoot = ({ children }) => {
|
|
2159
|
+
return /* @__PURE__ */ React18.createElement(ScrollArea2.Root, {
|
|
2160
|
+
className: "dx-document",
|
|
2161
|
+
orientation: "vertical",
|
|
2162
|
+
margin: true
|
|
2163
|
+
}, /* @__PURE__ */ React18.createElement(ScrollArea2.Viewport, {
|
|
2164
|
+
classNames: "p-trim-md"
|
|
2165
|
+
}, children));
|
|
2166
|
+
};
|
|
2167
|
+
SettingsRoot.displayName = SETTINGS_ROOT_NAME;
|
|
2168
|
+
var SettingsSection = ({ title, description, children }) => {
|
|
2169
|
+
return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(SettingsSectionHeading, {
|
|
2170
|
+
title,
|
|
2171
|
+
description
|
|
2172
|
+
}), /* @__PURE__ */ React18.createElement("div", {
|
|
2173
|
+
className: "w-full pt-trim-md space-y-trim-md"
|
|
2174
|
+
}, children));
|
|
2175
|
+
};
|
|
2176
|
+
SettingsSection.displayName = SETTINGS_SECTION_NAME;
|
|
2177
|
+
var SettingsSectionHeading = ({ title, description }) => {
|
|
2178
|
+
const { t } = useTranslation9(translationKey);
|
|
2179
|
+
return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement("h2", {
|
|
2180
|
+
className: "px-trim-md mt-trim-md mb-trim-md text-xl"
|
|
2181
|
+
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React18.createElement("p", {
|
|
2182
|
+
className: "px-trim-md my-trim-md text-description"
|
|
2183
|
+
}, toLocalizedString(description, t)));
|
|
2184
|
+
};
|
|
2185
|
+
SettingsSectionHeading.displayName = SETTINGS_SECTION_HEADING_NAME;
|
|
2186
|
+
var SettingsGroupButton = ({ classNames, ...props }) => {
|
|
2187
|
+
return /* @__PURE__ */ React18.createElement(Button2, {
|
|
2188
|
+
...props,
|
|
2189
|
+
classNames: [
|
|
2190
|
+
"md:col-span-2",
|
|
2191
|
+
classNames
|
|
2192
|
+
]
|
|
2193
|
+
});
|
|
2194
|
+
};
|
|
2195
|
+
SettingsGroupButton.displayName = SETTINGS_GROUP_BUTTON_NAME;
|
|
2196
|
+
var SettingsGroup = ({ children, classNames }) => /* @__PURE__ */ React18.createElement("div", {
|
|
2197
|
+
role: "none",
|
|
2198
|
+
className: mx4("group space-y-trim-md", classNames)
|
|
2199
|
+
}, children);
|
|
2200
|
+
SettingsGroup.displayName = SETTINGS_GROUP_NAME;
|
|
2201
|
+
var SettingsFrame = ({ children }) => /* @__PURE__ */ React18.createElement("div", {
|
|
2202
|
+
role: "none",
|
|
2203
|
+
className: "p-trim-md border border-separator rounded-md"
|
|
2204
|
+
}, children);
|
|
2205
|
+
SettingsFrame.displayName = SETTINGS_FRAME_NAME;
|
|
2206
|
+
var SettingsFrameItem = ({ title, description, children }) => {
|
|
2207
|
+
const { t } = useTranslation9(translationKey);
|
|
2208
|
+
return /* @__PURE__ */ React18.createElement("div", {
|
|
2209
|
+
role: "group",
|
|
2210
|
+
className: "min-w-0"
|
|
2211
|
+
}, /* @__PURE__ */ React18.createElement("h3", {
|
|
2212
|
+
className: "text-lg mb-2"
|
|
2213
|
+
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React18.createElement("p", {
|
|
2214
|
+
className: "my-trim-sm md:mb-0 text-description"
|
|
2215
|
+
}, toLocalizedString(description, t)), children);
|
|
2216
|
+
};
|
|
2217
|
+
SettingsFrameItem.displayName = SETTINGS_FRAME_ITEM_NAME;
|
|
2218
|
+
var SettingsContainer = ({ classNames, children }) => {
|
|
2219
|
+
return /* @__PURE__ */ React18.createElement("div", {
|
|
2220
|
+
role: "none",
|
|
2221
|
+
className: mx4([
|
|
2222
|
+
"dx-document",
|
|
2223
|
+
"*:first:mt-0! *:last:mb-0! px-trim-md py-trim-md",
|
|
2224
|
+
"border border-separator rounded-md",
|
|
2225
|
+
classNames
|
|
2226
|
+
])
|
|
2227
|
+
}, children);
|
|
2228
|
+
};
|
|
2229
|
+
SettingsContainer.displayName = SETTINGS_CONTAINER_NAME;
|
|
2230
|
+
var SettingsItem = ({ title, description = "", children }) => {
|
|
2231
|
+
const { t } = useTranslation9(translationKey);
|
|
2232
|
+
return /* @__PURE__ */ React18.createElement(SettingsContainer, {
|
|
2233
|
+
classNames: styles.grid
|
|
2234
|
+
}, /* @__PURE__ */ React18.createElement("h3", {
|
|
2235
|
+
className: mx4(styles.title, "md:col-span-2")
|
|
2236
|
+
}, toLocalizedString(title, t)), /* @__PURE__ */ React18.createElement("p", {
|
|
2237
|
+
className: styles.description
|
|
2238
|
+
}, toLocalizedString(description, t)), /* @__PURE__ */ React18.createElement("div", {
|
|
2239
|
+
role: "none",
|
|
2240
|
+
className: "overflow-hidden text-end py-1"
|
|
2241
|
+
}, children));
|
|
2242
|
+
};
|
|
2243
|
+
SettingsItem.displayName = SETTINGS_ITEM_NAME;
|
|
2244
|
+
var SettingsItemInput = ({ title, description = "", children }) => {
|
|
2245
|
+
const { t } = useTranslation9(translationKey);
|
|
2246
|
+
return /* @__PURE__ */ React18.createElement(Input12.Root, null, /* @__PURE__ */ React18.createElement(SettingsContainer, {
|
|
2247
|
+
classNames: styles.grid
|
|
2248
|
+
}, /* @__PURE__ */ React18.createElement(Input12.Label, {
|
|
2249
|
+
classNames: mx4(styles.title, "md:col-span-2")
|
|
2250
|
+
}, toLocalizedString(title, t)), /* @__PURE__ */ React18.createElement(Input12.DescriptionAndValidation, null, /* @__PURE__ */ React18.createElement(Input12.Description, {
|
|
2251
|
+
classNames: styles.description
|
|
2252
|
+
}, toLocalizedString(description, t))), /* @__PURE__ */ React18.createElement("div", {
|
|
2253
|
+
role: "none",
|
|
2254
|
+
className: "text-end py-1"
|
|
2255
|
+
}, children)));
|
|
2256
|
+
};
|
|
2257
|
+
SettingsItemInput.displayName = SETTINGS_ITEM_INPUT_NAME;
|
|
2258
|
+
var Settings = {
|
|
2259
|
+
Root: SettingsRoot,
|
|
2260
|
+
Section: SettingsSection,
|
|
2261
|
+
SectionHeading: SettingsSectionHeading,
|
|
2262
|
+
Group: SettingsGroup,
|
|
2263
|
+
GroupButton: SettingsGroupButton,
|
|
2264
|
+
Container: SettingsContainer,
|
|
2265
|
+
Frame: SettingsFrame,
|
|
2266
|
+
FrameItem: SettingsFrameItem,
|
|
2267
|
+
Item: SettingsItem,
|
|
2268
|
+
ItemInput: SettingsItemInput
|
|
2193
2269
|
};
|
|
2194
2270
|
|
|
2195
2271
|
// src/components/ViewEditor/ViewEditor.tsx
|
|
@@ -2198,20 +2274,19 @@ import * as Array2 from "effect/Array";
|
|
|
2198
2274
|
import * as Match2 from "effect/Match";
|
|
2199
2275
|
import * as Option4 from "effect/Option";
|
|
2200
2276
|
import * as Schema3 from "effect/Schema";
|
|
2201
|
-
import React19, { forwardRef as
|
|
2202
|
-
import { Filter as Filter2, Format as Format5, Obj as
|
|
2277
|
+
import React19, { forwardRef as forwardRef2, useCallback as useCallback15, useContext, useImperativeHandle, useMemo as useMemo8, useState as useState6 } from "react";
|
|
2278
|
+
import { Entity as Entity2, Feed, Filter as Filter2, Format as Format5, Obj as Obj3, Query, QueryAST, Ref as Ref3 } from "@dxos/echo";
|
|
2279
|
+
import { View } from "@dxos/echo";
|
|
2203
2280
|
import { EchoSchema, isMutable, toJsonSchema } from "@dxos/echo/internal";
|
|
2204
2281
|
import { invariant } from "@dxos/invariant";
|
|
2205
|
-
import { useObject } from "@dxos/react-client/echo";
|
|
2206
|
-
import {
|
|
2282
|
+
import { useObject, useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
2283
|
+
import { IconButton as IconButton4, Input as Input13, Message, useTranslation as useTranslation10 } from "@dxos/react-ui";
|
|
2207
2284
|
import { QueryForm } from "@dxos/react-ui-components";
|
|
2208
2285
|
import { List as List2 } from "@dxos/react-ui-list";
|
|
2209
|
-
import {
|
|
2210
|
-
import { mx as
|
|
2286
|
+
import { ParentLabelAnnotation, ProjectionModel, VIEW_FIELD_LIMIT, createEchoChangeCallback, getTypenameFromQuery } from "@dxos/schema";
|
|
2287
|
+
import { mx as mx5, osTranslations as osTranslations2, subtleHover as subtleHover2 } from "@dxos/ui-theme";
|
|
2211
2288
|
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) => {
|
|
2289
|
+
var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode = "schema", registry, db, readonly, showHeading = false, types, tags, onQueryChanged, onDelete }, forwardedRef) => {
|
|
2215
2290
|
const atomRegistry = useContext(RegistryContext);
|
|
2216
2291
|
const schemaReadonly = !isMutable(schema);
|
|
2217
2292
|
const { t } = useTranslation10(translationKey);
|
|
@@ -2233,12 +2308,25 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
|
|
|
2233
2308
|
useImperativeHandle(forwardedRef, () => projectionModel, [
|
|
2234
2309
|
projectionModel
|
|
2235
2310
|
]);
|
|
2236
|
-
const [expandedField, setExpandedField] = useState6();
|
|
2237
2311
|
const queueTarget = Match2.value(view.query.ast).pipe(Match2.when({
|
|
2238
|
-
type: "
|
|
2239
|
-
}, ({
|
|
2240
|
-
|
|
2312
|
+
type: "from"
|
|
2313
|
+
}, ({ from }) => {
|
|
2314
|
+
if (from._tag !== "scope") {
|
|
2315
|
+
return void 0;
|
|
2316
|
+
}
|
|
2317
|
+
return Option4.fromNullable(from.scope.queues).pipe(Option4.flatMap((queues) => Array2.head(queues)), Option4.map(String), Option4.getOrUndefined);
|
|
2241
2318
|
}), Match2.orElse(() => void 0));
|
|
2319
|
+
const feeds = useQuery2(db, Filter2.type(Feed.Feed));
|
|
2320
|
+
const targetRef = useMemo8(() => {
|
|
2321
|
+
if (!queueTarget) {
|
|
2322
|
+
return void 0;
|
|
2323
|
+
}
|
|
2324
|
+
const feed = feeds.find((feed2) => Feed.getQueueDxn(feed2)?.toString() === queueTarget);
|
|
2325
|
+
return feed ? Ref3.fromDXN(Entity2.getDXN(feed)) : void 0;
|
|
2326
|
+
}, [
|
|
2327
|
+
queueTarget,
|
|
2328
|
+
feeds
|
|
2329
|
+
]);
|
|
2242
2330
|
const viewSchema = useMemo8(() => {
|
|
2243
2331
|
const base = Schema3.Struct({
|
|
2244
2332
|
query: mode === "schema" ? Format5.URL.annotations({
|
|
@@ -2250,9 +2338,10 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
|
|
|
2250
2338
|
if (mode === "tag") {
|
|
2251
2339
|
return Schema3.Struct({
|
|
2252
2340
|
...base.fields,
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2341
|
+
// TODO(wittjosiah): Replace Type.Feed with Dataset.Dataset when Ref.Ref supports unions.
|
|
2342
|
+
target: Ref3.Ref(Feed.Feed).pipe(Schema3.annotations({
|
|
2343
|
+
title: "Target Feed"
|
|
2344
|
+
}), ParentLabelAnnotation.set(true), Schema3.optional)
|
|
2256
2345
|
}).pipe(Schema3.mutable);
|
|
2257
2346
|
}
|
|
2258
2347
|
return base.pipe(Schema3.mutable);
|
|
@@ -2261,11 +2350,11 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
|
|
|
2261
2350
|
]);
|
|
2262
2351
|
const viewValues = useMemo8(() => ({
|
|
2263
2352
|
query: mode === "schema" ? getTypenameFromQuery(view.query.ast) : view.query.ast,
|
|
2264
|
-
target:
|
|
2353
|
+
target: targetRef
|
|
2265
2354
|
}), [
|
|
2266
2355
|
mode,
|
|
2267
2356
|
view.query.ast,
|
|
2268
|
-
|
|
2357
|
+
targetRef
|
|
2269
2358
|
]);
|
|
2270
2359
|
const fieldMap = useMemo8(() => mode === "tag" ? customFields({
|
|
2271
2360
|
types,
|
|
@@ -2275,64 +2364,50 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
|
|
|
2275
2364
|
types,
|
|
2276
2365
|
tags
|
|
2277
2366
|
]);
|
|
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
2367
|
const handleUpdate = useCallback15((values) => {
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2368
|
+
const targetValue = values.target;
|
|
2369
|
+
let queueDxn;
|
|
2370
|
+
if (Ref3.isRef(targetValue)) {
|
|
2371
|
+
const feedDxn = targetValue.dxn.toString();
|
|
2372
|
+
const feed = feeds.find((feed2) => Obj3.getDXN(feed2).toString() === feedDxn);
|
|
2373
|
+
if (feed) {
|
|
2374
|
+
queueDxn = Feed.getQueueDxn(feed)?.toString();
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
const query = mode === "schema" ? Query.select(Filter2.typename(values.query)).ast : JSON.parse(JSON.stringify(values.query));
|
|
2378
|
+
onQueryChanged?.(query, queueDxn);
|
|
2299
2379
|
}, [
|
|
2300
2380
|
onQueryChanged,
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
mode
|
|
2381
|
+
mode,
|
|
2382
|
+
feeds
|
|
2304
2383
|
]);
|
|
2305
2384
|
const handleDelete = useCallback15((fieldId) => {
|
|
2306
2385
|
invariant(!readonly, void 0, {
|
|
2307
2386
|
F: __dxlog_file3,
|
|
2308
|
-
L:
|
|
2387
|
+
L: 185,
|
|
2309
2388
|
S: void 0,
|
|
2310
2389
|
A: [
|
|
2311
2390
|
"!readonly",
|
|
2312
2391
|
""
|
|
2313
2392
|
]
|
|
2314
2393
|
});
|
|
2315
|
-
if (fieldId === expandedField) {
|
|
2316
|
-
setExpandedField(void 0);
|
|
2317
|
-
}
|
|
2318
2394
|
onDelete?.(fieldId);
|
|
2319
2395
|
}, [
|
|
2320
|
-
expandedField,
|
|
2321
2396
|
onDelete,
|
|
2322
2397
|
readonly
|
|
2323
2398
|
]);
|
|
2324
2399
|
return /* @__PURE__ */ React19.createElement("div", {
|
|
2325
2400
|
role: "none",
|
|
2326
|
-
className:
|
|
2327
|
-
}, schemaReadonly && !readonly && /* @__PURE__ */ React19.createElement(
|
|
2401
|
+
className: mx5(classNames)
|
|
2402
|
+
}, schemaReadonly && !readonly && /* @__PURE__ */ React19.createElement(Message.Root, {
|
|
2328
2403
|
valence: "info",
|
|
2329
|
-
classNames: "
|
|
2330
|
-
}, /* @__PURE__ */ React19.createElement(
|
|
2404
|
+
classNames: "my-form-padding"
|
|
2405
|
+
}, /* @__PURE__ */ React19.createElement(Message.Title, null, t("system schema description"))), /* @__PURE__ */ React19.createElement(Form.Root, {
|
|
2331
2406
|
schema: viewSchema,
|
|
2332
2407
|
values: viewValues,
|
|
2333
2408
|
fieldMap,
|
|
2334
|
-
|
|
2335
|
-
|
|
2409
|
+
db,
|
|
2410
|
+
onValuesChanged: handleUpdate
|
|
2336
2411
|
}, /* @__PURE__ */ React19.createElement(Form.FieldSet, null), /* @__PURE__ */ React19.createElement(FormFieldLabel, {
|
|
2337
2412
|
label: t("fields label"),
|
|
2338
2413
|
asChild: true
|
|
@@ -2343,16 +2418,6 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
|
|
|
2343
2418
|
readonly,
|
|
2344
2419
|
showHeading,
|
|
2345
2420
|
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
2421
|
})));
|
|
2357
2422
|
});
|
|
2358
2423
|
var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDelete }) => {
|
|
@@ -2376,6 +2441,22 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2376
2441
|
view
|
|
2377
2442
|
]);
|
|
2378
2443
|
const [expandedField, setExpandedField] = useState6();
|
|
2444
|
+
const handleAdd = useCallback15(() => {
|
|
2445
|
+
invariant(!readonly, void 0, {
|
|
2446
|
+
F: __dxlog_file3,
|
|
2447
|
+
L: 250,
|
|
2448
|
+
S: void 0,
|
|
2449
|
+
A: [
|
|
2450
|
+
"!readonly",
|
|
2451
|
+
""
|
|
2452
|
+
]
|
|
2453
|
+
});
|
|
2454
|
+
const field = projectionModel.createFieldProjection();
|
|
2455
|
+
setExpandedField(field.id);
|
|
2456
|
+
}, [
|
|
2457
|
+
projectionModel,
|
|
2458
|
+
readonly
|
|
2459
|
+
]);
|
|
2379
2460
|
const handleToggleField = useCallback15((field) => {
|
|
2380
2461
|
setExpandedField((prevExpandedFieldId) => prevExpandedFieldId === field.id ? void 0 : field.id);
|
|
2381
2462
|
}, [
|
|
@@ -2384,7 +2465,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2384
2465
|
const handleDelete = useCallback15((fieldId) => {
|
|
2385
2466
|
invariant(!readonly, void 0, {
|
|
2386
2467
|
F: __dxlog_file3,
|
|
2387
|
-
L:
|
|
2468
|
+
L: 264,
|
|
2388
2469
|
S: void 0,
|
|
2389
2470
|
A: [
|
|
2390
2471
|
"!readonly",
|
|
@@ -2403,14 +2484,14 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2403
2484
|
const handleMove = useCallback15((fromIndex, toIndex) => {
|
|
2404
2485
|
invariant(!readonly, void 0, {
|
|
2405
2486
|
F: __dxlog_file3,
|
|
2406
|
-
L:
|
|
2487
|
+
L: 276,
|
|
2407
2488
|
S: void 0,
|
|
2408
2489
|
A: [
|
|
2409
2490
|
"!readonly",
|
|
2410
2491
|
""
|
|
2411
2492
|
]
|
|
2412
2493
|
});
|
|
2413
|
-
|
|
2494
|
+
Obj3.change(view, (v) => {
|
|
2414
2495
|
const fields = [
|
|
2415
2496
|
...v.projection.fields
|
|
2416
2497
|
];
|
|
@@ -2440,7 +2521,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2440
2521
|
}
|
|
2441
2522
|
return /* @__PURE__ */ React19.createElement(List2.Root, {
|
|
2442
2523
|
items: viewSnapshot.projection.fields,
|
|
2443
|
-
isItem: Schema3.is(FieldSchema),
|
|
2524
|
+
isItem: Schema3.is(View.FieldSchema),
|
|
2444
2525
|
getId: (field) => field.id,
|
|
2445
2526
|
onMove: readonly ? void 0 : handleMove,
|
|
2446
2527
|
readonly
|
|
@@ -2448,23 +2529,23 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2448
2529
|
className: "text-sm"
|
|
2449
2530
|
}, t("field path label")), /* @__PURE__ */ React19.createElement("div", {
|
|
2450
2531
|
role: "list",
|
|
2451
|
-
className:
|
|
2532
|
+
className: "grid grid-cols-[min-content_1fr_min-content_min-content_min-content]"
|
|
2452
2533
|
}, fields?.map((field) => {
|
|
2453
2534
|
const hidden = field.visible === false;
|
|
2454
2535
|
return /* @__PURE__ */ React19.createElement(List2.Item, {
|
|
2455
2536
|
key: field.id,
|
|
2456
2537
|
item: field,
|
|
2457
|
-
classNames:
|
|
2538
|
+
classNames: "grid grid-cols-subgrid col-span-5",
|
|
2458
2539
|
"aria-expanded": expandedField === field.id
|
|
2459
2540
|
}, /* @__PURE__ */ React19.createElement("div", {
|
|
2460
2541
|
role: "none",
|
|
2461
|
-
className:
|
|
2542
|
+
className: mx5(subtleHover2, "grid grid-cols-subgrid col-span-5", "rounded-xs cursor-pointer min-h-10")
|
|
2462
2543
|
}, /* @__PURE__ */ React19.createElement(List2.ItemDragHandle, {
|
|
2463
2544
|
disabled: readonly || schemaReadonly
|
|
2464
2545
|
}), /* @__PURE__ */ React19.createElement(List2.ItemTitle, {
|
|
2465
2546
|
classNames: hidden && "text-subdued",
|
|
2466
2547
|
onClick: () => handleToggleField(field)
|
|
2467
|
-
}, field.path), /* @__PURE__ */ React19.createElement(List2.
|
|
2548
|
+
}, field.path), /* @__PURE__ */ React19.createElement(List2.ItemIconButton, {
|
|
2468
2549
|
label: t(hidden ? "show field label" : "hide field label"),
|
|
2469
2550
|
"data-testid": hidden ? "show-field-button" : "hide-field-button",
|
|
2470
2551
|
icon: hidden ? "ph--eye-closed--regular" : "ph--eye--regular",
|
|
@@ -2477,7 +2558,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2477
2558
|
disabled: readonly || schemaReadonly || viewSnapshot.projection.fields.length <= 1,
|
|
2478
2559
|
onClick: () => handleDelete(field.id),
|
|
2479
2560
|
"data-testid": "field.delete"
|
|
2480
|
-
}), /* @__PURE__ */ React19.createElement(
|
|
2561
|
+
}), /* @__PURE__ */ React19.createElement(List2.ItemIconButton, {
|
|
2481
2562
|
iconOnly: true,
|
|
2482
2563
|
variant: "ghost",
|
|
2483
2564
|
label: t("toggle expand label", {
|
|
@@ -2488,7 +2569,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2488
2569
|
"data-testid": "field.toggle"
|
|
2489
2570
|
}))), expandedField === field.id && !readonly && /* @__PURE__ */ React19.createElement("div", {
|
|
2490
2571
|
role: "none",
|
|
2491
|
-
className: "col-span-5
|
|
2572
|
+
className: "col-span-5 mt-1 mb-1 border border-separator rounded-md"
|
|
2492
2573
|
}, /* @__PURE__ */ React19.createElement(FieldEditor, {
|
|
2493
2574
|
readonly: readonly || schemaReadonly,
|
|
2494
2575
|
registry,
|
|
@@ -2496,6 +2577,15 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2496
2577
|
field,
|
|
2497
2578
|
onSave: handleClose
|
|
2498
2579
|
})));
|
|
2580
|
+
})), !readonly && !expandedField && /* @__PURE__ */ React19.createElement("div", {
|
|
2581
|
+
role: "none",
|
|
2582
|
+
className: "my-form-padding"
|
|
2583
|
+
}, /* @__PURE__ */ React19.createElement(IconButton4, {
|
|
2584
|
+
icon: "ph--plus--regular",
|
|
2585
|
+
label: t("add property button label"),
|
|
2586
|
+
onClick: handleAdd,
|
|
2587
|
+
disabled: viewSnapshot.projection.fields.length >= VIEW_FIELD_LIMIT,
|
|
2588
|
+
classNames: "w-full"
|
|
2499
2589
|
}))));
|
|
2500
2590
|
};
|
|
2501
2591
|
var customFields = ({ types, tags }) => ({
|
|
@@ -2517,15 +2607,6 @@ var customFields = ({ types, tags }) => ({
|
|
|
2517
2607
|
export {
|
|
2518
2608
|
ArrayField,
|
|
2519
2609
|
BooleanField,
|
|
2520
|
-
ControlFrame,
|
|
2521
|
-
ControlFrameItem,
|
|
2522
|
-
ControlGroup,
|
|
2523
|
-
ControlGroupButton,
|
|
2524
|
-
ControlItem,
|
|
2525
|
-
ControlItemInput,
|
|
2526
|
-
ControlPage,
|
|
2527
|
-
ControlSection,
|
|
2528
|
-
ControlSectionHeading,
|
|
2529
2610
|
FieldEditor,
|
|
2530
2611
|
Form,
|
|
2531
2612
|
FormFieldErrorBoundary,
|
|
@@ -2538,12 +2619,12 @@ export {
|
|
|
2538
2619
|
RefField,
|
|
2539
2620
|
SelectField,
|
|
2540
2621
|
SelectOptionField,
|
|
2622
|
+
Settings,
|
|
2541
2623
|
TextAreaField,
|
|
2542
2624
|
TextField,
|
|
2543
2625
|
TupleField,
|
|
2544
2626
|
ViewEditor,
|
|
2545
2627
|
cellClassesForFieldType,
|
|
2546
|
-
controlItemClasses,
|
|
2547
2628
|
formatForDisplay,
|
|
2548
2629
|
formatForEditing,
|
|
2549
2630
|
getDefaultValue,
|
|
@@ -2552,7 +2633,6 @@ export {
|
|
|
2552
2633
|
omitId,
|
|
2553
2634
|
parseValue,
|
|
2554
2635
|
pathNotUniqueError,
|
|
2555
|
-
setValueEchoAware,
|
|
2556
2636
|
translations,
|
|
2557
2637
|
useFormContext,
|
|
2558
2638
|
useFormFieldState,
|